mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 03:40:37 +02:00
Fixes #1257 SEFURLs for thumb images. Needs testing. See e107.htaccess for required additions/modifications - Set HTTP_MOD_REWRITE_MEDIA to "On"
This commit is contained in:
@@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
<IfModule mod_env.c>
|
<IfModule mod_env.c>
|
||||||
SetEnv HTTP_MOD_REWRITE On
|
SetEnv HTTP_MOD_REWRITE On
|
||||||
|
SetEnv HTTP_MOD_REWRITE_MEDIA Off
|
||||||
</IfModule>
|
</IfModule>
|
||||||
|
|
||||||
### enable rewrites
|
### enable rewrites
|
||||||
@@ -54,8 +55,14 @@
|
|||||||
|
|
||||||
### Allow only GET and POST methods
|
### Allow only GET and POST methods
|
||||||
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS|HEAD)
|
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS|HEAD)
|
||||||
|
|
||||||
|
|
||||||
RewriteRule .* - [F]
|
RewriteRule .* - [F]
|
||||||
|
|
||||||
|
### Rewrite for Image URLs
|
||||||
|
ReWriteRule ^media\/img\/(a)?([\d]*)x(a)?([\d]*)\/(.*)?$ thumb.php?src=e_MEDIA_IMAGE/$5&$1w=$2&$3h=$4 [NC,L]
|
||||||
|
RewriteRule ^media\/img\/([-A-Za-z0-9+/]*={0,3})\.(jpg|gif|png)?$ thumb.php?id=$1 [NC,L]
|
||||||
|
|
||||||
### send 404 on missing files in these folders
|
### send 404 on missing files in these folders
|
||||||
RewriteCond %{REQUEST_URI} !^/(e107_images|e107_files)/
|
RewriteCond %{REQUEST_URI} !^/(e107_images|e107_files)/
|
||||||
|
|
||||||
|
@@ -3218,6 +3218,12 @@ class e107
|
|||||||
{
|
{
|
||||||
define('e_MOD_REWRITE', (getenv('HTTP_MOD_REWRITE')=='On' ? true : false));
|
define('e_MOD_REWRITE', (getenv('HTTP_MOD_REWRITE')=='On' ? true : false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!defined('e_MOD_REWRITE_MEDIA')) // Allow e107_config.php to override.
|
||||||
|
{
|
||||||
|
define('e_MOD_REWRITE_MEDIA', (getenv('HTTP_MOD_REWRITE_MEDIA')=='On' ? true : false));
|
||||||
|
}
|
||||||
|
|
||||||
// Define the domain name and subdomain name.
|
// Define the domain name and subdomain name.
|
||||||
if(is_numeric(str_replace(".","",$_SERVER['HTTP_HOST'])))
|
if(is_numeric(str_replace(".","",$_SERVER['HTTP_HOST'])))
|
||||||
{
|
{
|
||||||
|
@@ -2266,18 +2266,62 @@ class e_parse extends e_parser
|
|||||||
}
|
}
|
||||||
$thurl .= 'w='.((integer) vartrue($options['w'], 0)).'&h='.((integer) vartrue($options['h'], 0));
|
$thurl .= 'w='.((integer) vartrue($options['w'], 0)).'&h='.((integer) vartrue($options['h'], 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(e_MOD_REWRITE_MEDIA == true && (strstr($thurl, 'e_MEDIA_IMAGE') || !empty($options['x'])))// Experimental SEF URL support.
|
||||||
|
{
|
||||||
|
$options['full'] = $full;
|
||||||
|
$options['ext'] = substr($url,-3);
|
||||||
|
$options['thurl'] = $thurl;
|
||||||
|
return $this->thumbUrlSEF($url,$options);
|
||||||
|
}
|
||||||
|
|
||||||
if(vartrue($options['x']))//base64 encode url
|
if(vartrue($options['x']))//base64 encode url
|
||||||
{
|
{
|
||||||
$thurl = 'id='.base64_encode($thurl);
|
$thurl = 'id='.base64_encode($thurl);
|
||||||
}
|
}
|
||||||
|
|
||||||
// echo "<br /><br />".$thurl;
|
|
||||||
|
|
||||||
return $baseurl.$thurl;
|
return $baseurl.$thurl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used by thumbUrl when SEF Image URLS is active. @see e107.htaccess
|
||||||
|
* @param $url
|
||||||
|
* @param array $options
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function thumbUrlSEF($url='', $options=array())
|
||||||
|
{
|
||||||
|
$clean = array('{e_MEDIA_IMAGE}','e_MEDIA_IMAGE/');
|
||||||
|
|
||||||
|
$base = (!empty($options['full'])) ? SITEURL : e_HTTP;
|
||||||
|
|
||||||
|
// 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']))
|
||||||
|
{
|
||||||
|
$ext = strtolower($options['ext']);
|
||||||
|
return $base.'media/img/'.base64_encode($options['thurl']).'.'.str_replace("jpeg", "jpg", $ext);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build URL for ReWriteRule ^media\/img\/(a)?([\d]*)x(a)?([\d]*)\/(.*)?$ thumb.php?src=e_MEDIA_IMAGE/$5&$1w=$2&$3h=$4
|
||||||
|
$sefUrl = $base.'media/img/';
|
||||||
|
|
||||||
|
if(vartrue($options['aw']) || vartrue($options['ah']))
|
||||||
|
{
|
||||||
|
$sefUrl .= 'a'.intval($options['aw']) .'xa'. intval($options['ah']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sefUrl .= intval($options['w']) .'x'. intval($options['h']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sefUrl .= '/';
|
||||||
|
$sefUrl .= str_replace($clean,'',$url);
|
||||||
|
|
||||||
|
return $sefUrl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Help for converting to more safe URLs
|
* Help for converting to more safe URLs
|
||||||
* e.g. {e_MEDIA_FILE}path/to/video.flv => e_MEDIA_FILE/path/to/video.flv
|
* e.g. {e_MEDIA_FILE}path/to/video.flv => e_MEDIA_FILE/path/to/video.flv
|
||||||
|
Reference in New Issue
Block a user