* @access public
* @author
* @create
- * @version $Id: backup.php,v 1.13 2011/01/25 15:01:01 henoheno Exp $
* Copyright (C)
* 2002-2016 PukiWiki Development Team
* 2001-2002 Originally written by yu-ji
* @return Void
*/
-function make_backup($page, $delete = FALSE)
+function make_backup($page, $is_delete, $wikitext)
{
global $cycle, $maxage;
global $do_backup, $del_backup;
if (PKWK_READONLY || ! $do_backup) return;
- if ($del_backup && $delete) {
+ if ($del_backup && $is_delete) {
_backup_delete($page);
return;
}
}
}
}
- if ($need_backup_by_time || $is_author_differ)
+ if ($need_backup_by_time || $is_author_differ || $is_delete)
{
$backups = get_backup($page);
$count = count($backups) + 1;
-
// 直後に1件追加するので、(最大件数 - 1)を超える要素を捨てる
if ($count > $maxage)
array_splice($backups, 0, $count - $maxage);
$body = preg_replace('/^(' . preg_quote(PKWK_SPLITTER) . "\s\d+)$/", '$1 ', get_source($page));
$body = PKWK_SPLITTER . ' ' . get_filetime($page) . "\n" . join('', $body);
$body = preg_replace("/\n*$/", "\n", $body);
-
+ $body_on_delete = '';
+ if ($is_delete) {
+ $body_on_delete = PKWK_SPLITTER . ' ' . UTIME . "\n" . $wikitext;
+ $body_on_delete = preg_replace("/\n*$/", "\n", $body_on_delete);
+ }
$fp = _backup_fopen($page, 'wb')
or die_message('Cannot open ' . htmlsc(_backup_get_filename($page)) .
'<br />Maybe permission is not writable or filename is too long');
_backup_fputs($fp, $strout);
_backup_fputs($fp, $body);
+ _backup_fputs($fp, $body_on_delete);
_backup_fclose($fp);
}
}
<?php
// PukiWiki - Yet another WikiWikiWeb clone.
-// $Id: file.php,v 1.95 2011/01/25 15:01:01 henoheno Exp $
+// file.php
// Copyright (C)
-// 2002-2006 PukiWiki Developers Team
+// 2002-2016 PukiWiki Development Team
// 2001-2002 Originally written by yu-ji
// License: GPL v2 or (at your option) any later version
//
if (PKWK_READONLY) return; // Do nothing
$postdata = make_str_rules($postdata);
- $postdata = add_author_info(remove_author_info($postdata));
+ $text_without_author = remove_author_info($postdata);
+ $postdata = add_author_info($text_without_author);
+ $is_delete = empty($text_without_author);
// Create and write diff
$oldpostdata = is_page($page) ? join('', get_source($page)) : '';
file_write(DIFF_DIR, $page, $diffdata);
// Create backup
- make_backup($page, $postdata == ''); // Is $postdata null?
+ make_backup($page, $is_delete, $postdata); // Is $postdata null?
// Create wiki text
- file_write(DATA_DIR, $page, $postdata, $notimestamp);
+ file_write(DATA_DIR, $page, $postdata, $notimestamp, $is_delete);
links_update($page);
}
}
// Output to a file
-function file_write($dir, $page, $str, $notimestamp = FALSE)
+function file_write($dir, $page, $str, $notimestamp = FALSE, $is_delete = FALSE)
{
global $_msg_invalidiwn, $notify, $notify_diff_only, $notify_subject;
global $whatsdeleted, $maxshow_deleted;
// ----
// Delete?
- if ($dir == DATA_DIR && $str === '') {
+ if ($dir == DATA_DIR && $is_delete) {
// Page deletion
if (! $file_exists) return; // Ignore null posting for DATA_DIR
htmlsc(basename($filename)));
}
}
-