/** * The main() function which generates a zip archive of a PhpWiki. * * If $include_archive is false, only the current version of each page * is included in the zip file; otherwise all archived versions are * included as well. */ function MakeWikiZip($include_archive = false) { global $dbi, $WikiPageStore, $ArchivePageStore; $pages = GetAllWikiPageNames($dbi); $zipname = "wiki.zip"; if ($include_archive) { $zipname = "wikidb.zip"; } $zip = new ZipWriter("Created by PhpWiki", $zipname); for (reset($pages); $pagename = current($pages); next($pages)) { set_time_limit(30); // Reset watchdog. $pagehash = RetrievePage($dbi, $pagename, $WikiPageStore); if (!is_array($pagehash)) { continue; } if ($include_archive) { $oldpagehash = RetrievePage($dbi, $pagename, $ArchivePageStore); } else { $oldpagehash = false; } $attrib = array('mtime' => $pagehash['lastmodified'], 'is_ascii' => 1); if (($pagehash['flags'] & FLAG_PAGE_LOCKED) != 0) { $attrib['write_protected'] = 1; } $content = MailifyPage($pagehash, $oldpagehash); $zip->addRegularFile(encode_pagename_for_wikizip($pagehash['pagename']), $content, $attrib); } $zip->finish(); }
function InitBackLinkSearch($dbi, $pagename) { $pos['search'] = MakeBackLinkSearchRegexp($pagename); $pos['data'] = GetAllWikiPageNames($dbi['wiki']); return $pos; }