1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 13:47:31 +02:00

Issue #2600 defining e_HTTP_STATIC now applies to images (using thumbUrl/toImage) as well as js/css.

eg. define('e_HTTP_STATIC', 'http://static.mydomain.com/');
This commit is contained in:
Cameron
2017-04-28 15:07:36 -07:00
parent e755b2c9d4
commit 4c6f015fa8
5 changed files with 39 additions and 22 deletions

View File

@@ -2672,12 +2672,6 @@ class e_http_header
$this->setHeader("X-Powered-By: e107", true); // no less secure than e107-specific html. $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) if($this->compression_server_support == true)
{ {
$this->setHeader('Vary: Accept-Encoding'); $this->setHeader('Vary: Accept-Encoding');

View File

@@ -13,6 +13,8 @@
### Security ### Security
ServerSignature Off ServerSignature Off
#Header unset Pragma
# secure htaccess file # secure htaccess file
<Files .htaccess> <Files .htaccess>
order allow,deny order allow,deny
@@ -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 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> </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 set Cache-Control "public"
Header unset Cookie Header unset Cookie
Header unset Set-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> </FilesMatch>

View File

@@ -2530,6 +2530,11 @@ class e_parse extends e_parser
$baseurl = ($full ? SITEURL : e_HTTP).'thumb.php?'; $baseurl = ($full ? SITEURL : e_HTTP).'thumb.php?';
if(defined('e_HTTP_STATIC'))
{
$baseurl = e_HTTP_STATIC.'thumb.php?';
}
$thurl = 'src='.urlencode($url).'&amp;'; $thurl = 'src='.urlencode($url).'&amp;';
// e107::getDebug()->log("Thumb: ".basename($url). print_a($options,true), E107_DBG_BASIC); // e107::getDebug()->log("Thumb: ".basename($url). print_a($options,true), E107_DBG_BASIC);
@@ -2722,6 +2727,11 @@ class e_parse extends e_parser
{ {
$base = (!empty($options['ebase'])) ? '{e_BASE}' : e_HTTP; $base = (!empty($options['ebase'])) ? '{e_BASE}' : e_HTTP;
} }
if(defined('e_HTTP_STATIC'))
{
$base = e_HTTP_STATIC;
}
// $base = (!empty($options['full'])) ? SITEURL : e_HTTP; // $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 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
@@ -5114,6 +5124,8 @@ class e_emotefilter
return; return;
} }
$base = deftrue('e_HTTP_STATIC', SITEURLBASE);
foreach($this->emotes as $key => $value) foreach($this->emotes as $key => $value)
{ {
@@ -5131,7 +5143,9 @@ class e_emotefilter
$filename = e_IMAGE."emotes/" . $pref['emotepack'] . "/" . $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); $alt = str_replace(array('.png','.gif', '.jpg'),'', $key);

View File

@@ -1256,7 +1256,7 @@ class e_jsmanager
if(strpos($path, 'http') !== 0) if(strpos($path, 'http') !== 0)
{ {
$path = $tp->replaceConstants($path, 'abs').'?external=1'; // &amp;'.$this->getCacheId(); $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; echo $pre.'<link rel="stylesheet" media="'.$media.'" type="text/css" href="'.$path.'" />'.$post;
@@ -1276,7 +1276,7 @@ class e_jsmanager
$path = $path[0]; $path = $path[0];
$path = $tp->replaceConstants($path, 'abs').'?external=1'; // &amp;'.$this->getCacheId(); $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 $pre.'<script type="text/javascript" src="'.$path.'"></script>'.$post;
echo "\n"; echo "\n";
continue; continue;
@@ -1328,7 +1328,7 @@ class e_jsmanager
continue; continue;
} }
$path = $tp->replaceConstants($path, 'abs'); // .'?'.$this->getCacheId(); $path = $tp->replaceConstants($path, 'abs'); // .'?'.$this->getCacheId();
$path = $this->url($path, 'css'); $path = $this->url($path);
} }
elseif($this->isValidUrl($path) === false) elseif($this->isValidUrl($path) === false)
{ {
@@ -1401,11 +1401,10 @@ class e_jsmanager
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( $srch = array(
e_PLUGIN_ABS, e_PLUGIN_ABS,
@@ -1413,19 +1412,27 @@ class e_jsmanager
e_WEB_ABS e_WEB_ABS
); );
$http = deftrue('e_HTTP_STATIC', e_HTTP); $http = deftrue('e_HTTP_STATIC', e_HTTP);
$base = (e_MOD_REWRITE_STATIC === true) ? 'static/'.$this->getCacheId().'/' : '';
$repl = array( $repl = array(
$http.$base.$this->getCacheId().'/'.e107::getFolder('plugins'), $http.$base.e107::getFolder('plugins'),
$http.$base.$this->getCacheId().'/'.e107::getFolder('themes'), $http.$base.e107::getFolder('themes'),
$http.$base.$this->getCacheId().'/'.e107::getFolder('web') $http.$base.e107::getFolder('web')
); );
$folder = str_replace($srch,$repl,$path); $folder = str_replace($srch,$repl,$path);
if(e_MOD_REWRITE_STATIC === true)
{
return trim($folder); return trim($folder);
} }
$path = $folder;
}
if(strpos($path,'?')!==false) if(strpos($path,'?')!==false)
{ {
@@ -1534,11 +1541,11 @@ class e_jsmanager
if($type == 'js') 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 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'])) if(!empty($this->_cache_list['css_inline']))
{ {
echo $this->_cache_list['css_inline']; echo $this->_cache_list['css_inline'];

View File

@@ -105,7 +105,7 @@ class download_url // plugin-folder + '_url'
$config['item'] = array( $config['item'] = array(
'regex' => '^{alias}/([\d]*)/(.*)$', 'regex' => '^{alias}/([\d]*)/(.*)$',
'redirect' => '{e_PLUGIN}download/download.php?action=view&id=$1', '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( $config['get'] = array(