Skip to content

Commit

Permalink
Issue e107inc#2600 defining e_HTTP_STATIC now applies to images (usin…
Browse files Browse the repository at this point in the history
…g thumbUrl/toImage) as well as js/css.

eg. define('e_HTTP_STATIC', 'http://static.mydomain.com/');
  • Loading branch information
CaMer0n committed Apr 28, 2017
1 parent e755b2c commit 4c6f015
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 22 deletions.
6 changes: 0 additions & 6 deletions class2.php
Original file line number Diff line number Diff line change
Expand Up @@ -2672,12 +2672,6 @@ function send()
$this->setHeader("X-Powered-By: e107", true); // no less secure than e107-specific html.
}

if(defined('e_HTTP_STATIC'))
{
// $this->setHeader("Access-Control-Allow-Origin: *",true);
$this->setHeader("Access-Control-Allow-Origin: ".rtrim(e_HTTP_STATIC,'/'), true);
}

if($this->compression_server_support == true)
{
$this->setHeader('Vary: Accept-Encoding');
Expand Down
6 changes: 4 additions & 2 deletions e107.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
### Security
ServerSignature Off

#Header unset Pragma

# secure htaccess file
<Files .htaccess>
order allow,deny
Expand Down Expand Up @@ -103,11 +105,11 @@
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css text/javascript application/x-javascript application/javascript application/xml text/xml application/rss+xml
</ifmodule>

<FilesMatch "\.(js|css|ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4|eot|otf|ttc|ttf|woff)$">
<FilesMatch "\.(js|css|ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4|eot|otf|ttc|ttf|woff|woff2)$">
Header set Cache-Control "public"
Header unset Cookie
Header unset Set-Cookie
# Header set Access-Control-Allow-Origin "http://static.mydomain.com"
# Header set Access-Control-Allow-Origin "http://mydomain.com"
</FilesMatch>


Expand Down
16 changes: 15 additions & 1 deletion e107_handlers/e_parse_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2529,6 +2529,11 @@ public function thumbUrl($url=null, $options = array(), $raw = false, $full = fa
if($raw) $url = $this->createConstants($url, 'mix');

$baseurl = ($full ? SITEURL : e_HTTP).'thumb.php?';

if(defined('e_HTTP_STATIC'))
{
$baseurl = e_HTTP_STATIC.'thumb.php?';
}

$thurl = 'src='.urlencode($url).'&amp;';

Expand Down Expand Up @@ -2722,6 +2727,11 @@ private function thumbUrlSEF($url='', $options=array())
{
$base = (!empty($options['ebase'])) ? '{e_BASE}' : e_HTTP;
}

if(defined('e_HTTP_STATIC'))
{
$base = e_HTTP_STATIC;
}
// $base = (!empty($options['full'])) ? SITEURL : e_HTTP;

if(!empty($options['x']) && !empty($options['ext'])) // base64 encoded. Build URL for: RewriteRule ^media\/img\/([-A-Za-z0-9+/]*={0,3})\.(jpg|gif|png)?$ thumb.php?id=$1
Expand Down Expand Up @@ -5114,6 +5124,8 @@ function __construct()
return;
}

$base = deftrue('e_HTTP_STATIC', SITEURLBASE);

foreach($this->emotes as $key => $value)
{

Expand All @@ -5130,8 +5142,10 @@ function __construct()
$key = str_replace("!", "_", $key);

$filename = e_IMAGE."emotes/" . $pref['emotepack'] . "/" . $key;



$fileloc = SITEURLBASE.e_IMAGE_ABS."emotes/" . $pref['emotepack'] . "/" . $key;
$fileloc = $base.e_IMAGE_ABS."emotes/" . $pref['emotepack'] . "/" . $key;

$alt = str_replace(array('.png','.gif', '.jpg'),'', $key);

Expand Down
31 changes: 19 additions & 12 deletions e107_handlers/js_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ public function renderFile($file_path_array, $external = false, $label = '', $mo
if(strpos($path, 'http') !== 0)
{
$path = $tp->replaceConstants($path, 'abs').'?external=1'; // &amp;'.$this->getCacheId();
$path = $this->url($path,'css');
$path = $this->url($path);
}

echo $pre.'<link rel="stylesheet" media="'.$media.'" type="text/css" href="'.$path.'" />'.$post;
Expand All @@ -1276,7 +1276,7 @@ public function renderFile($file_path_array, $external = false, $label = '', $mo
$path = $path[0];

$path = $tp->replaceConstants($path, 'abs').'?external=1'; // &amp;'.$this->getCacheId();
$path = $this->url($path,'js');
$path = $this->url($path);
echo $pre.'<script type="text/javascript" src="'.$path.'"></script>'.$post;
echo "\n";
continue;
Expand Down Expand Up @@ -1328,7 +1328,7 @@ public function renderFile($file_path_array, $external = false, $label = '', $mo
continue;
}
$path = $tp->replaceConstants($path, 'abs'); // .'?'.$this->getCacheId();
$path = $this->url($path, 'css');
$path = $this->url($path);
}
elseif($this->isValidUrl($path) === false)
{
Expand Down Expand Up @@ -1401,29 +1401,36 @@ public function renderFile($file_path_array, $external = false, $label = '', $mo



private function url($path,$type)
private function url($path,$cacheId = true)
{
if(e_MOD_REWRITE_STATIC === true && $this->isInAdmin() !== true)
if((e_MOD_REWRITE_STATIC === true || defined('e_HTTP_STATIC')) && $this->isInAdmin() !== true)
{
$base = 'static/';

$srch = array(
e_PLUGIN_ABS,
e_THEME_ABS,
e_WEB_ABS
);


$http = deftrue('e_HTTP_STATIC', e_HTTP);

$base = (e_MOD_REWRITE_STATIC === true) ? 'static/'.$this->getCacheId().'/' : '';

$repl = array(
$http.$base.$this->getCacheId().'/'.e107::getFolder('plugins'),
$http.$base.$this->getCacheId().'/'.e107::getFolder('themes'),
$http.$base.$this->getCacheId().'/'.e107::getFolder('web')
$http.$base.e107::getFolder('plugins'),
$http.$base.e107::getFolder('themes'),
$http.$base.e107::getFolder('web')
);

$folder = str_replace($srch,$repl,$path);

return trim($folder);
if(e_MOD_REWRITE_STATIC === true)
{
return trim($folder);
}

$path = $folder;
}


Expand Down Expand Up @@ -1534,11 +1541,11 @@ public function renderCached($type)

if($type == 'js')
{
echo "<script type='text/javascript' src='".e_WEB_ABS."cache/".$fileName."'></script>\n\n";
echo "<script type='text/javascript' src='".$this->url(e_WEB_ABS."cache/".$fileName,'js','cache')."'></script>\n\n";
}
else
{
echo "<link type='text/css' href='".e_WEB_ABS."cache/".$fileName."' rel='stylesheet' property='stylesheet' />\n\n";
echo "<link type='text/css' href='".$this->url(e_WEB_ABS."cache/".$fileName,'cache')."' rel='stylesheet' property='stylesheet' />\n\n";
if(!empty($this->_cache_list['css_inline']))
{
echo $this->_cache_list['css_inline'];
Expand Down
2 changes: 1 addition & 1 deletion e107_plugins/download/e_url.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private function profile1()
$config['item'] = array(
'regex' => '^{alias}/([\d]*)/(.*)$',
'redirect' => '{e_PLUGIN}download/download.php?action=view&id=$1',
'sef' => '{alias}/{download_id}/{download_sef}'
'sef' => '{alias}/{download_id}/{download_sef}',
);

$config['get'] = array(
Expand Down

0 comments on commit 4c6f015

Please sign in to comment.