* @create
* @version $Id: backup.php,v 1.13 2011/01/25 15:01:01 henoheno Exp $
* 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
**/
{
global $cycle, $maxage;
global $do_backup, $del_backup;
+ global $auth_user;
if (PKWK_READONLY || ! $do_backup) return;
if (! is_page($page)) return;
$lastmod = _backup_get_filetime($page);
- if ($lastmod == 0 || UTIME - $lastmod > 60 * 60 * $cycle)
+ $backups = get_backup($page);
+ $is_author_differ = false;
+ $need_backup_by_time = $lastmod == 0 || UTIME - $lastmod > 60 * 60 * $cycle;
+ if (!$need_backup_by_time) {
+ // Backup file is saved recently, but the author may differ.
+ $last_content = get_source($page, FALSE, TRUE);
+ $m = array();
+ if (preg_match('/^\s*#author\("([^"]+)","([^"]+)","([^"]*)"\)/m', $last_content, $m)) {
+ $prev_author = $m[2];
+ $simple_author =preg_replace('/^[^:]:/', '', $prev_author);
+ if ($simple_author !== $auth_user) {
+ $is_author_differ = true;
+ }
+ }
+ }
+ if ($need_backup_by_time || $is_author_differ)
{
$backups = get_backup($page);
$count = count($backups) + 1;
// Allocate
$retvars[$_age] = array('time'=>$match[1], 'data'=>array());
+ } else if (preg_match('/^\s*#author\("([^"]+)","([^"]+)","([^"]*)"\)/', $line, $match)) {
+ $retvars[$_age]['author_datetime'] = $match[1];
+ $retvars[$_age]['author'] = $match[2];
+ $retvars[$_age]['author_fullname'] = $match[3];
+ $retvars[$_age]['data'][] = $line;
} else {
// The first ... the last line of the data
$retvars[$_age]['data'][] = $line;
array();
}
}
-?>
<?php
// PukiWiki - Yet another WikiWikiWeb clone.
-// $Id: backup.inc.php,v 1.29 2011/01/25 15:01:01 henoheno Exp $
+// backup.inc.php
// Copyright (C)
-// 2002-2005 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
//
$_anchor_to = '</a>';
}
$date = format_date($data['time'], TRUE);
+ $author_info = '';
+ if (isset($data['author'])) {
+ $author_info = htmlsc('by ' . $data['author_fullname']
+ . '(' . $data['author'] . ')');
+ }
$retval[1] .= <<<EOD
<li>$_anchor_from$age $date$_anchor_to
[ <a href="$href$age&action=diff">$_msg_diff</a>
| <a href="$href$age&action=nowdiff">$_msg_nowdiff</a>
| <a href="$href$age&action=source">$_msg_source</a>
- ]
+ ] $author_info
</li>
EOD;
}
return page_list($pages, 'backup', $withfilename);
}
}
-?>