mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 04:38:27 +01:00
Issue #1257 Added SEF Thumb Urls for Avatar images.
This commit is contained in:
parent
0c3125a11e
commit
767b496c69
@ -61,6 +61,7 @@
|
||||
|
||||
### 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\/avatar\/(a)?([\d]*)x(a)?([\d]*)\/(.*)?$ thumb.php?src=e_AVATAR/$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
|
||||
|
@ -2268,12 +2268,16 @@ class e_parse extends e_parser
|
||||
}
|
||||
|
||||
|
||||
if(e_MOD_REWRITE_MEDIA == true && (strstr($thurl, 'e_MEDIA_IMAGE') || !empty($options['x'])))// Experimental SEF URL support.
|
||||
if(e_MOD_REWRITE_MEDIA == true)// Experimental SEF URL support.
|
||||
{
|
||||
$options['full'] = $full;
|
||||
$options['ext'] = substr($url,-3);
|
||||
$options['thurl'] = $thurl;
|
||||
return $this->thumbUrlSEF($url,$options);
|
||||
|
||||
if($sefUrl = $this->thumbUrlSEF($url,$options))
|
||||
{
|
||||
return $sefUrl;
|
||||
}
|
||||
}
|
||||
|
||||
if(vartrue($options['x']))//base64 encode url
|
||||
@ -2292,19 +2296,31 @@ class e_parse extends e_parser
|
||||
*/
|
||||
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']))
|
||||
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
|
||||
{
|
||||
$ext = strtolower($options['ext']);
|
||||
return $base.'media/img/'.base64_encode($options['thurl']).'.'.str_replace("jpeg", "jpg", $ext);
|
||||
}
|
||||
elseif(strstr($url, 'e_MEDIA_IMAGE')) // media images.
|
||||
{
|
||||
$sefPath = 'media/img/';
|
||||
$clean = array('{e_MEDIA_IMAGE}','e_MEDIA_IMAGE/');
|
||||
}
|
||||
elseif(strstr($url, 'e_AVATAR')) // avatars
|
||||
{
|
||||
$sefPath = 'media/avatar/';
|
||||
$clean = array('{e_AVATAR}','e_AVATAR/');
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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/';
|
||||
$sefUrl = $base.$sefPath;
|
||||
|
||||
if(vartrue($options['aw']) || vartrue($options['ah']))
|
||||
{
|
||||
|
@ -258,6 +258,8 @@ class e_thumbpage
|
||||
$this->sendHeaders($thumbnfo);
|
||||
|
||||
|
||||
//$bench->end()->logResult('thumb.php', $_GET['src'].' - 304 not modified');
|
||||
// exit;
|
||||
// check browser cache
|
||||
if (@$_SERVER['HTTP_IF_MODIFIED_SINCE'] && ($thumbnfo['lmodified'] <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) && (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == $thumbnfo['md5s']))
|
||||
{
|
||||
@ -362,6 +364,7 @@ class e_thumbpage
|
||||
}
|
||||
//header('Pragma:');
|
||||
header('Cache-Control: must-revalidate');
|
||||
// header('Cache-Control: public, max-age=3600');
|
||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $thumbnfo['lmodified']).' GMT');
|
||||
header('Content-Length: '.$thumbnfo['fsize']);
|
||||
header('Content-Disposition: filename='.$thumbnfo['basename']); // important for right-click save-as.
|
||||
|
Loading…
x
Reference in New Issue
Block a user