Move cache code to addon
This commit is contained in:
parent
6f2d09eb20
commit
0ee403eab3
@ -1111,23 +1111,13 @@ function linkify($s, $me = false) {
|
|||||||
function sslify($s) {
|
function sslify($s) {
|
||||||
|
|
||||||
// Local photo cache
|
// Local photo cache
|
||||||
if(get_config('system','photo_cache_enable', 0) && local_channel()) {
|
$str = array(
|
||||||
$matches = null;
|
'body' => $s,
|
||||||
$cnt = preg_match_all("/\<img(.+?)src=[\"|'](https?\:.*?)[\"|'](.*?)\>/", $s, $matches, PREG_SET_ORDER);
|
|
||||||
if ($cnt) {
|
|
||||||
foreach ($matches as $match) {
|
|
||||||
logger('uid: ' . $uid . '; url: ' . $match[2], LOGGER_DEBUG);
|
|
||||||
$cache = array(
|
|
||||||
'url' => $match[2],
|
|
||||||
'uid' => local_channel()
|
'uid' => local_channel()
|
||||||
);
|
);
|
||||||
call_hooks('cache_url_hook', $cache);
|
call_hooks('cache_body_hook', $str);
|
||||||
logger('cache status: ' . intval($cache['status']) .'; cached as: ' . ($cache['cached'] ? $cache['hash'] : '-'), LOGGER_DEBUG);
|
|
||||||
if($cache['cached'])
|
$s = $str['body'];
|
||||||
$s = str_replace($match[2], z_root() . '/photo/' . $cache['hash'] . '-' . $cache['res'], $s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strpos(z_root(),'https:') === false)
|
if (strpos(z_root(),'https:') === false)
|
||||||
return $s;
|
return $s;
|
||||||
|
Reference in New Issue
Block a user