mirror of
https://github.com/e107inc/e107.git
synced 2025-07-26 09:20:28 +02:00
Issue #1257 Added SEF Thumb Urls for Avatar images.
This commit is contained in:
@@ -61,6 +61,7 @@
|
|||||||
|
|
||||||
### Rewrite for Image URLs
|
### 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)?([\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]
|
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
|
||||||
|
@@ -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['full'] = $full;
|
||||||
$options['ext'] = substr($url,-3);
|
$options['ext'] = substr($url,-3);
|
||||||
$options['thurl'] = $thurl;
|
$options['thurl'] = $thurl;
|
||||||
return $this->thumbUrlSEF($url,$options);
|
|
||||||
|
if($sefUrl = $this->thumbUrlSEF($url,$options))
|
||||||
|
{
|
||||||
|
return $sefUrl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(vartrue($options['x']))//base64 encode url
|
if(vartrue($options['x']))//base64 encode url
|
||||||
@@ -2292,19 +2296,31 @@ class e_parse extends e_parser
|
|||||||
*/
|
*/
|
||||||
private function thumbUrlSEF($url='', $options=array())
|
private function thumbUrlSEF($url='', $options=array())
|
||||||
{
|
{
|
||||||
$clean = array('{e_MEDIA_IMAGE}','e_MEDIA_IMAGE/');
|
|
||||||
|
|
||||||
$base = (!empty($options['full'])) ? SITEURL : e_HTTP;
|
$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'])) // 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']))
|
|
||||||
{
|
{
|
||||||
$ext = strtolower($options['ext']);
|
$ext = strtolower($options['ext']);
|
||||||
return $base.'media/img/'.base64_encode($options['thurl']).'.'.str_replace("jpeg", "jpg", $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
|
// 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']))
|
if(vartrue($options['aw']) || vartrue($options['ah']))
|
||||||
{
|
{
|
||||||
|
@@ -258,6 +258,8 @@ class e_thumbpage
|
|||||||
$this->sendHeaders($thumbnfo);
|
$this->sendHeaders($thumbnfo);
|
||||||
|
|
||||||
|
|
||||||
|
//$bench->end()->logResult('thumb.php', $_GET['src'].' - 304 not modified');
|
||||||
|
// exit;
|
||||||
// check browser cache
|
// 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']))
|
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('Pragma:');
|
||||||
header('Cache-Control: must-revalidate');
|
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('Last-Modified: '.gmdate('D, d M Y H:i:s', $thumbnfo['lmodified']).' GMT');
|
||||||
header('Content-Length: '.$thumbnfo['fsize']);
|
header('Content-Length: '.$thumbnfo['fsize']);
|
||||||
header('Content-Disposition: filename='.$thumbnfo['basename']); // important for right-click save-as.
|
header('Content-Disposition: filename='.$thumbnfo['basename']); // important for right-click save-as.
|
||||||
|
Reference in New Issue
Block a user