]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - admin/loadserial.php
2004-11-28 19:19 rurban
[SourceForge/phpwiki.git] / admin / loadserial.php
1 <!-- $Id: loadserial.php,v 1.1.2.1.2.2 2005-01-07 13:59:57 rurban Exp $ -->
2 <?php
3    /*
4       Load a set of pages that have been serialized with 
5       wiki_dumpserial.php.
6    */
7    if (!defined('WIKI_ADMIN'))
8       die("You must be logged in as the administrator to load serialized pages.");
9
10    $directory = $loadserial;
11    $html = "Loading serialized pages from '$directory'.<p>\n";
12
13    if (! file_exists($directory)) {
14       echo "No such directory '$directory'.<br>\n";
15       exit;
16    }
17    
18    $handle = opendir($directory);
19
20    while ($file = readdir($handle)) {
21
22       if ($file[0] == ".")
23          continue;
24
25       $html .= "Reading '$file'...<br>\n";
26
27       $data = implode("", file("$directory/$file"));
28       $pagehash = unserialize($data);
29
30       // at this point there needs to be some form of verification
31       // that we are about to insert a page.
32
33       $pagename = rawurldecode($file);
34       $html .= "inserting file '".htmlspecialchars($pagename)."' into the database...<br>\n";
35       InsertPage($dbi, $pagename, $pagehash);
36    }
37    closedir($handle); 
38
39    $html .= "<p><b>Load complete.</b>";
40    GeneratePage('MESSAGE', $html, 'Load serialized pages', 0);
41    ExitWiki('');
42 ?>