mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 21:27:25 +02:00
Issue #2827 Support for multiple static domains for distributed static URLs.
This commit is contained in:
@@ -4030,9 +4030,7 @@ class e107
|
|||||||
return $this->e107_dirs[$dir.'_HTTP'];
|
return $this->e107_dirs[$dir.'_HTTP'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$http = ($dir === "CACHE_IMAGE" && defined('e_MEDIA_STATIC') && defined('e_HTTP_STATIC')) ? e_HTTP_STATIC : e_HTTP;
|
return e_HTTP.$this->e107_dirs[$dir.'_DIRECTORY'];
|
||||||
|
|
||||||
return $http.$this->e107_dirs[$dir.'_DIRECTORY'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -62,6 +62,8 @@ class e_parse extends e_parser
|
|||||||
|
|
||||||
private $thumbEncode = 0;
|
private $thumbEncode = 0;
|
||||||
|
|
||||||
|
private $staticCount = 0;
|
||||||
|
|
||||||
// BBcode that contain preformatted code.
|
// BBcode that contain preformatted code.
|
||||||
private $preformatted = array('html', 'markdown');
|
private $preformatted = array('html', 'markdown');
|
||||||
|
|
||||||
@@ -2568,6 +2570,90 @@ class e_parse extends e_parser
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private function staticCount($val=false)
|
||||||
|
{
|
||||||
|
|
||||||
|
$count = $this->staticCount;
|
||||||
|
|
||||||
|
if($val === 0)
|
||||||
|
{
|
||||||
|
$this->staticCount = 0;
|
||||||
|
}
|
||||||
|
elseif($val !== false)
|
||||||
|
{
|
||||||
|
$this->staticCount = $this->staticCount + (int) $val;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int) $count;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $path - absolute path
|
||||||
|
* @return string - static path.
|
||||||
|
*/
|
||||||
|
public function staticUrl($path=null)
|
||||||
|
{
|
||||||
|
if(!defined('e_HTTP_STATIC'))
|
||||||
|
{
|
||||||
|
return ($path === null) ? e_HTTP : $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$staticArray = e_HTTP_STATIC;
|
||||||
|
|
||||||
|
if(is_array($staticArray))
|
||||||
|
{
|
||||||
|
$cnt = count($staticArray);
|
||||||
|
$staticCount = $this->staticCount();
|
||||||
|
if($staticCount > ($cnt -1))
|
||||||
|
{
|
||||||
|
$staticCount = 0;
|
||||||
|
$this->staticCount(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
$http = !empty($staticArray[$staticCount]) ? $staticArray[$staticCount] : e_HTTP;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$http = e_HTTP_STATIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->staticCount(1);
|
||||||
|
|
||||||
|
if(empty($path))
|
||||||
|
{
|
||||||
|
return $http;
|
||||||
|
}
|
||||||
|
|
||||||
|
$base = '';
|
||||||
|
|
||||||
|
$srch = array(
|
||||||
|
e_PLUGIN_ABS,
|
||||||
|
e_THEME_ABS,
|
||||||
|
e_WEB_ABS,
|
||||||
|
e_CACHE_IMAGE_ABS,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$repl = array(
|
||||||
|
$http.$base.e107::getFolder('plugins'),
|
||||||
|
$http.$base.e107::getFolder('themes'),
|
||||||
|
$http.$base.e107::getFolder('web'),
|
||||||
|
$http.$base.str_replace('../', '', e_CACHE_IMAGE),
|
||||||
|
);
|
||||||
|
|
||||||
|
$ret = str_replace($srch,$repl,$path);
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate an auto-sized Image URL.
|
* Generate an auto-sized Image URL.
|
||||||
* @param $url - path to image or leave blank for a placeholder. eg. {e_MEDIA}folder/my-image.jpg
|
* @param $url - path to image or leave blank for a placeholder. eg. {e_MEDIA}folder/my-image.jpg
|
||||||
@@ -2584,6 +2670,8 @@ class e_parse extends e_parser
|
|||||||
*/
|
*/
|
||||||
public function thumbUrl($url=null, $options = array(), $raw = false, $full = false)
|
public function thumbUrl($url=null, $options = array(), $raw = false, $full = false)
|
||||||
{
|
{
|
||||||
|
$this->staticCount++; // increment counter.
|
||||||
|
|
||||||
if(strpos($url,"{e_") === 0) // Fix for broken links that use {e_MEDIA} etc.
|
if(strpos($url,"{e_") === 0) // Fix for broken links that use {e_MEDIA} etc.
|
||||||
{
|
{
|
||||||
//$url = $this->replaceConstants($url,'abs');
|
//$url = $this->replaceConstants($url,'abs');
|
||||||
@@ -2591,7 +2679,7 @@ class e_parse extends e_parser
|
|||||||
$url = str_replace($this->getUrlConstants('sc'), $this->getUrlConstants('raw'), $url);
|
$url = str_replace($this->getUrlConstants('sc'), $this->getUrlConstants('raw'), $url);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_array($options))
|
if(is_string($options))
|
||||||
{
|
{
|
||||||
parse_str($options, $options);
|
parse_str($options, $options);
|
||||||
}
|
}
|
||||||
@@ -2617,7 +2705,7 @@ class e_parse extends e_parser
|
|||||||
|
|
||||||
if(defined('e_HTTP_STATIC'))
|
if(defined('e_HTTP_STATIC'))
|
||||||
{
|
{
|
||||||
$baseurl = e_HTTP_STATIC.'thumb.php?';
|
$baseurl = $this->staticUrl().'thumb.php?';
|
||||||
}
|
}
|
||||||
|
|
||||||
$thurl = 'src='.urlencode($url).'&';
|
$thurl = 'src='.urlencode($url).'&';
|
||||||
@@ -2678,8 +2766,7 @@ class e_parse extends e_parser
|
|||||||
|
|
||||||
if(!empty($staticFile) && is_readable(e_CACHE_IMAGE.$staticFile))
|
if(!empty($staticFile) && is_readable(e_CACHE_IMAGE.$staticFile))
|
||||||
{
|
{
|
||||||
//file_put_contents(e_LOG."thumbCache.log",$staticFile."\n",FILE_APPEND);
|
return $this->staticUrl(e_CACHE_IMAGE.$staticFile);
|
||||||
return e_CACHE_IMAGE_ABS.$staticFile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$options['nosef'] = true;
|
$options['nosef'] = true;
|
||||||
@@ -2834,7 +2921,7 @@ class e_parse extends e_parser
|
|||||||
|
|
||||||
if(defined('e_HTTP_STATIC'))
|
if(defined('e_HTTP_STATIC'))
|
||||||
{
|
{
|
||||||
$base = e_HTTP_STATIC;
|
$base = $this->staticUrl();
|
||||||
}
|
}
|
||||||
// $base = (!empty($options['full'])) ? SITEURL : e_HTTP;
|
// $base = (!empty($options['full'])) ? SITEURL : e_HTTP;
|
||||||
|
|
||||||
|
@@ -1400,13 +1400,19 @@ class e_jsmanager
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
private function url($path,$cacheId = true)
|
* Return the URL while checking for staticUrl configuration.
|
||||||
|
* @param $path
|
||||||
|
* @param bool $cacheId
|
||||||
|
* @return mixed|string
|
||||||
|
*/
|
||||||
|
private function url($path, $cacheId = true)
|
||||||
{
|
{
|
||||||
if((e_MOD_REWRITE_STATIC === true || defined('e_HTTP_STATIC')) && $this->isInAdmin() !== true)
|
|
||||||
|
if(/*(e_MOD_REWRITE_STATIC === true || defined('e_HTTP_STATIC')) &&*/ $this->isInAdmin() !== true)
|
||||||
{
|
{
|
||||||
|
|
||||||
$srch = array(
|
/* $srch = array(
|
||||||
e_PLUGIN_ABS,
|
e_PLUGIN_ABS,
|
||||||
e_THEME_ABS,
|
e_THEME_ABS,
|
||||||
e_WEB_ABS
|
e_WEB_ABS
|
||||||
@@ -1430,10 +1436,15 @@ class e_jsmanager
|
|||||||
return trim($folder);
|
return trim($folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = $folder;
|
$path = $folder;*/
|
||||||
|
|
||||||
|
$path = e107::getParser()->staticUrl($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(strpos($path,'?')!==false)
|
if(strpos($path,'?')!==false)
|
||||||
{
|
{
|
||||||
$path .= "&".$this->getCacheId();
|
$path .= "&".$this->getCacheId();
|
||||||
|
Reference in New Issue
Block a user