Moved "privacy_image_cache" into the core. Enabled by default, can be disabled in the page settings.

This commit is contained in:
Michael Vogel
2014-08-13 00:13:13 +02:00
parent 731d944ab5
commit d4b2d3bf8a
14 changed files with 367 additions and 40 deletions

View File

@@ -1641,21 +1641,16 @@
$a = get_app();
$result = q("SELECT `installed` FROM `addon` WHERE `name` = 'privacy_image_cache' AND `installed`");
$image_cache = (count($result) > 0);
$include_entities = strtolower(x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:"false");
if ($include_entities != "true") {
if ($image_cache) {
require_once("addon/privacy_image_cache/privacy_image_cache.php");
require_once("mod/proxy.php");
preg_match_all("/\[img](.*?)\[\/img\]/ism", $bbcode, $images);
preg_match_all("/\[img](.*?)\[\/img\]/ism", $bbcode, $images);
foreach ($images[1] AS $image) {
$replace = $a->get_baseurl()."/privacy_image_cache/".privacy_image_cache_cachename($image);
$text = str_replace($image, $replace, $text);
}
foreach ($images[1] AS $image) {
$replace = proxy_url($image);
$text = str_replace($image, $replace, $text);
}
return array();
}
@@ -1750,11 +1745,11 @@
require_once("include/Photo.php");
$image = get_photo_info($url);
if ($image) {
// If privacy_image_cache is activated, then use the following sizes:
// If image cache is activated, then use the following sizes:
// thumb (150), small (340), medium (600) and large (1024)
if ($image_cache) {
require_once("addon/privacy_image_cache/privacy_image_cache.php");
$media_url = $a->get_baseurl()."/privacy_image_cache/".privacy_image_cache_cachename($url);
if (!get_config("system", "proxy_disabled")) {
require_once("mod/proxy.php");
$media_url = proxy_url($url);
$sizes = array();
$scale = scale_image($image[0], $image[1], 150);

View File

@@ -145,7 +145,7 @@ function bb_cleanup_share($shared, $plaintext, $nolink) {
if (isset($bookmark[1][0]))
$link = $bookmark[1][0];
if (strpos($shared[1],$title) !== false)
if (($title != "") AND (strpos($shared[1],$title) !== false))
$title = "";
// if (strpos($shared[1],$link) !== false)

View File

@@ -370,6 +370,7 @@ if(!function_exists('conversation')) {
function conversation(&$a, $items, $mode, $update, $preview = false) {
require_once('include/bbcode.php');
require_once('mod/proxy.php');
$ssl_state = ((local_user()) ? true : false);
@@ -656,7 +657,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
'name' => $profile_name_e,
'sparkle' => $sparkle,
'lock' => $lock,
'thumb' => $profile_avatar,
'thumb' => proxy_url($profile_avatar),
'title' => $item['title_e'],
'body' => $body_e,
'tags' => $tags_e,
@@ -675,7 +676,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
'indent' => '',
'owner_name' => $owner_name_e,
'owner_url' => $owner_url,
'owner_photo' => $owner_photo,
'owner_photo' => proxy_url($owner_photo),
'plink' => get_plink($item),
'edpost' => false,
'isstarred' => $isstarred,

View File

@@ -40,7 +40,7 @@ function cronhooks_run(&$argv, &$argc){
$pidfile = new pidfile($lockpath, 'cronhooks');
if($pidfile->is_already_running()) {
logger("cronhooks: Already running");
if ($pidfile->running_time() > 9*60) {
if ($pidfile->running_time() > 19*60) {
$pidfile->kill();
logger("cronhooks: killed stale process");
// Calling a new instance

View File

@@ -109,6 +109,8 @@ function oembed_fetch_url($embedurl, $no_rich_type = false){
}
function oembed_format_object($j){
require_once("mod/proxy.php");
$a = get_app();
$embedurl = $j->embedurl;
$jhtml = oembed_iframe($j->embedurl,(isset($j->width) ? $j->width : null), (isset($j->height) ? $j->height : null) );
@@ -138,8 +140,8 @@ function oembed_format_object($j){
$ret.="<br>";
}; break;
case "photo": {
$ret.= "<img width='".$j->width."' src='".$j->url."'>";
//$ret.= "<img width='".$j->width."' height='".$j->height."' src='".$j->url."'>";
$ret.= "<img width='".$j->width."' src='".proxy_url($j->url)."'>";
//$ret.= "<img width='".$j->width."' height='".$j->height."' src='".proxy_url($j->url)."'>";
$ret.="<br>";
}; break;
case "link": {

View File

@@ -134,6 +134,16 @@ function poller_run(&$argv, &$argc){
// clear smarty cache
clear_cache($a->get_basepath()."/view/smarty3/compiled", $a->get_basepath()."/view/smarty3/compiled");
// clear cache for image proxy
if (!get_config("system", "proxy_disabled")) {
clear_cache($a->get_basepath(), $a->get_basepath()."/proxy");
$cachetime = get_config('system','proxy_cache_time');
if (!$cachetime) $cachetime = PROXY_DEFAULT_TIME;
q('DELETE FROM `photo` WHERE `uid` = 0 AND `resource-id` LIKE "pic:%%" AND `created` < NOW() - INTERVAL %d SECOND', $cachetime);
}
set_config('system','cache_last_cleared', time());
}

View File

@@ -1353,6 +1353,8 @@ function prepare_body(&$item,$attach = false, $preview = false) {
$s = prepare_text($item['body']);
}
require_once("mod/proxy.php");
$s = proxy_parse_html($s);
$prep_arr = array('item' => $item, 'html' => $s, 'preview' => $preview);
call_hooks('prepare_body', $prep_arr);