<?php
// PukiWiki - Yet another WikiWikiWeb clone.
-// $Id: file.php,v 1.66 2006/04/29 02:37:33 henoheno Exp $
+// $Id: file.php,v 1.67 2006/04/30 03:58:35 henoheno Exp $
// Copyright (C)
// 2002-2006 PukiWiki Developers Team
// 2001-2002 Originally written by yu-ji
// Update RecentDeleted (Add the $page)
add_recent($page, $whatsdeleted, '', $maxshow_deleted);
+ // Remove the page
unlink($file);
- // Update RecentChanges (Remove the $page from RecentChanges)
- put_lastmodified();
+ // Update RecentDeleted, and remove the page from RecentChanges
+ lastmodified_add($whatsdeleted, $page);
// Clear is_page() cache
is_page($page, TRUE);
// Update PKWK_MAXSHOW_CACHE itself (Add or renew about the $page) (Light)
// Use without $autolink
-function lastmodified_add($page = '')
+function lastmodified_add($update = '', $remove = '')
{
global $maxshow, $whatsnew, $autolink;
return;
}
- if (check_non_list($page)) return; // No need
+ if (($update == '' || check_non_list($update)) && $remove == '')
+ return; // No need
$file = CACHE_DIR . PKWK_MAXSHOW_CACHE;
if (! file_exists($file)) {
$recent_pages[$matches[2]] = $matches[1];
// Remove if it exists inside
- if (isset($recent_pages[$page])) unset($recent_pages[$page]);
+ if (isset($recent_pages[$update])) unset($recent_pages[$update]);
+ if (isset($recent_pages[$remove])) unset($recent_pages[$remove]);
// Add to the top: like array_unshift()
- if ($page != '') $recent_pages = array($page => get_filetime($page)) + $recent_pages;
+ if ($update != '')
+ $recent_pages = array($update => get_filetime($update)) + $recent_pages;
- // Write
- ftruncate($fp, 0);
- rewind($fp);
- foreach ($recent_pages as $_page=>$time)
- fputs($fp, $time . "\t" . $_page . "\n");
+ // Check
+ $abort = count($recent_pages) < $maxshow;
+
+ if (! $abort) {
+ // Write
+ ftruncate($fp, 0);
+ rewind($fp);
+ foreach ($recent_pages as $_page=>$time)
+ fputs($fp, $time . "\t" . $_page . "\n");
+ }
flock($fp, LOCK_UN);
fclose($fp);
+ if ($abort) {
+ put_lastmodified(); // Try to (re)create ALL
+ return;
+ }
+
+
// ----
// Update the page 'RecentChanges'