From 9f76d96d46356b18325ca49c383f94a1958fefd3 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 11 Mar 2012 19:11:25 +0100 Subject: [PATCH] Cache: item cache now has an autodelete of old files. The pages plugin now sets a link via redirection. So posting works. --- addon/pages/pages.php | 5 +++-- include/poller.php | 13 +++++++++++++ include/text.php | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/addon/pages/pages.php b/addon/pages/pages.php index 6b242be316..9e90cc24dd 100755 --- a/addon/pages/pages.php +++ b/addon/pages/pages.php @@ -55,7 +55,7 @@ function pages_getpages($uid) { // Look if the profile is a community page foreach($contacts as $contact) { if (pages_iscommunity($contact["url"], $pagelist)) - $pages[] = array("url"=>$contact["url"], "Name"=>$contact["Name"]); + $pages[] = array("url"=>$contact["url"], "Name"=>$contact["Name"], "id"=>$contact["id"]); } // Write back cached pagelist @@ -76,7 +76,8 @@ function pages_page_end($a,&$b) { $contacts = pages_getpages($a->user['uid']); foreach($contacts as $contact) { - $pages .= '
  • '.$contact["Name"]."
  • "; + $pages .= '
  • '. + $contact["Name"]."
  • "; } $pages .= ""; if (sizeof($contacts) > 0) diff --git a/include/poller.php b/include/poller.php index f165ad5905..65fafda4c8 100755 --- a/include/poller.php +++ b/include/poller.php @@ -69,6 +69,19 @@ function poller_run($argv, $argc){ // clear old cache Cache::clear(); + // clear item cache files if they are older than one day + $cache = get_config('system','itemcache'); + if (($cache != '') and is_dir($cache)) { + if ($dh = opendir($cache)) { + while (($file = readdir($dh)) !== false) { + $fullpath = $cache."/".$file; + if ((filetype($fullpath) == "file") and filectime($fullpath) < (time() - 1800)) + unlink($fullpath); + } + closedir($dh); + } + } + $manual_id = 0; $generation = 0; $hub_update = false; diff --git a/include/text.php b/include/text.php index 5bf815105b..08c5a54246 100644 --- a/include/text.php +++ b/include/text.php @@ -879,7 +879,7 @@ function prepare_body($item,$attach = false) { $cache = get_config('system','itemcache'); if (($cache != '')) { - $cachefile = $cache."/".$item["guid"]."-".strtotime($item["edited"])."-".$attach."-".hash("crc32", $item['body']); + $cachefile = $cache."/".$item["guid"]."-".strtotime($item["edited"])."-".hash("crc32", $item['body']); if (file_exists($cachefile)) $s = file_get_contents($cachefile);