1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 19:30:25 +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.
}
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');

View File

@@ -13,6 +13,8 @@
### Security
ServerSignature Off
#Header unset Pragma
# secure htaccess file
<Files .htaccess>
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
</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>

View File

@@ -2529,6 +2529,11 @@ class e_parse extends e_parser
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;';
@@ -2722,6 +2727,11 @@ class e_parse extends e_parser
{
$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
@@ -5114,6 +5124,8 @@ class e_emotefilter
return;
}
$base = deftrue('e_HTTP_STATIC', SITEURLBASE);
foreach($this->emotes as $key => $value)
{
@@ -5130,8 +5142,10 @@ class e_emotefilter
$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);

View File

@@ -1256,7 +1256,7 @@ class e_jsmanager
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;
@@ -1276,7 +1276,7 @@ class e_jsmanager
$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;
@@ -1328,7 +1328,7 @@ class e_jsmanager
continue;
}
$path = $tp->replaceConstants($path, 'abs'); // .'?'.$this->getCacheId();
$path = $this->url($path, 'css');
$path = $this->url($path);
}
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(
e_PLUGIN_ABS,
@@ -1413,17 +1412,25 @@ class e_jsmanager
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;
}
@@ -1534,11 +1541,11 @@ class e_jsmanager
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'];

View File

@@ -105,7 +105,7 @@ class download_url // plugin-folder + '_url'
$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(