]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/loadsave.php
new [Overwrite All] button
[SourceForge/phpwiki.git] / lib / loadsave.php
1 <?php //-*-php-*-
2 rcs_id('$Id: loadsave.php,v 1.126 2004-10-16 15:13:39 rurban Exp $');
3
4 /*
5  Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam
6
7  This file is part of PhpWiki.
8
9  PhpWiki is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13
14  PhpWiki is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with PhpWiki; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23
24
25 require_once("lib/ziplib.php");
26 require_once("lib/Template.php");
27
28 /**
29  * ignore fatal errors during dump
30  */
31 function _dump_error_handler(&$error) {
32     if ($error->isFatal()) {
33         $error->errno = E_USER_WARNING;
34         return true;
35     }
36     return true;         // Ignore error
37     /*
38     if (preg_match('/Plugin/', $error->errstr))
39         return true;
40     */
41     // let the message come through: call the remaining handlers:
42     // return false; 
43 }
44
45 function StartLoadDump(&$request, $title, $html = '')
46 {
47     // MockRequest is from the unit testsuite, a faked request. (may be cmd-line)
48     // We are silent on unittests.
49     if (isa($request,'MockRequest'))
50         return;
51     // FIXME: This is a hack. This really is the worst overall hack in phpwiki.
52     if ($html)
53         $html->pushContent('%BODY%');
54     $tmpl = Template('html', array('TITLE' => $title,
55                                    'HEADER' => $title,
56                                    'CONTENT' => $html ? $html : '%BODY%'));
57     echo ereg_replace('%BODY%.*', '', $tmpl->getExpansion($html));
58     // set marker for sendPageChangeNotification()
59     $GLOBALS['deferredPageChangeNotification'] = array();
60
61     /* Ignore fatals or warnings in any pagedumps (failing plugins). 
62      * WikiFunctionCb() fails with 4.0.6, works ok with 4.1.1 
63      */
64     if (!check_php_version(4,1) or (DEBUG & _DEBUG_VERBOSE)) return;
65     global $ErrorManager;
66     $ErrorManager->pushErrorHandler(new WikiFunctionCb('_dump_error_handler'));
67 }
68
69 function EndLoadDump(&$request)
70 {
71     if (isa($request,'MockRequest'))
72         return;
73     if (check_php_version(4,1)) {
74         global $ErrorManager;
75         $ErrorManager->popErrorHandler();
76     }
77     $action = $request->getArg('action');
78     $label = '';
79     switch ($action) {
80     case 'zip':        $label = _("ZIP files of database"); break;
81     case 'dumpserial': $label = _("Dump to directory"); break;
82     case 'upload':     $label = _("Upload File"); break;
83     case 'loadfile':   $label = _("Load File"); break;
84     case 'upgrade':    $label = _("Upgrade"); break;
85     case 'dumphtml': 
86     case 'ziphtml':    $label = _("Dump pages as XHTML"); break;
87     }
88     if ($label) $label = str_replace(" ","_",$label);
89     if ($action == 'browse') // loading virgin 
90         $pagelink = WikiLink(HOME_PAGE);
91     else
92         $pagelink = WikiLink(new WikiPageName(_("PhpWikiAdministration"),false,$label));
93     // do deferred sendPageChangeNotification()
94     if (!empty($GLOBALS['deferredPageChangeNotification'])) {
95         $pages = $all_emails = $all_users = array();
96         foreach ($GLOBALS['deferredPageChangeNotification'] as $p) {
97             list($pagename, $emails, $userids) = $p;
98             $pages[] = $pagename;
99             $all_emails = array_unique(array_merge($all_emails, $emails));
100             $all_users = array_unique(array_merge($all_users, $userids));
101         }
102         $editedby = sprintf(_("Edited by: %s"), $request->_userid);
103         $content = "Loaded the following pages:\n" . join("\n", $pages);
104         if (mail(join(',',$all_emails),"[".WIKI_NAME."] "._("LoadDump"), 
105                  _("LoadDump")."\n".
106                  $editedby."\n\n".
107                  $content))
108             trigger_error(sprintf(_("PageChange Notification sent to %s"),
109                                   join(',',$all_users)), E_USER_NOTICE);
110         else
111             trigger_error(sprintf(_("PageChange Notification Error: Couldn't send to %s"),
112                                   join(',',$all_users)), E_USER_WARNING);
113         unset($pages);
114         unset($all_emails);
115         unset($all_users);
116     }
117     unset($GLOBALS['deferredPageChangeNotification']);
118
119     PrintXML(HTML::p(HTML::strong(_("Complete."))),
120              HTML::p(fmt("Return to %s", $pagelink)));
121     echo "</body></html>\n";
122 }
123
124
125 ////////////////////////////////////////////////////////////////
126 //
127 //  Functions for dumping.
128 //
129 ////////////////////////////////////////////////////////////////
130
131 /**
132  * For reference see:
133  * http://www.nacs.uci.edu/indiv/ehood/MIME/2045/rfc2045.html
134  * http://www.faqs.org/rfcs/rfc2045.html
135  * (RFC 1521 has been superceeded by RFC 2045 & others).
136  *
137  * Also see http://www.faqs.org/rfcs/rfc2822.html
138  */
139 function MailifyPage ($page, $nversions = 1)
140 {
141     $current = $page->getCurrentRevision();
142     $head = '';
143
144     if (STRICT_MAILABLE_PAGEDUMPS) {
145         $from = defined('SERVER_ADMIN') ? SERVER_ADMIN : 'foo@bar';
146         //This is for unix mailbox format: (not RFC (2)822)
147         // $head .= "From $from  " . CTime(time()) . "\r\n";
148         $head .= "Subject: " . rawurlencode($page->getName()) . "\r\n";
149         $head .= "From: $from (PhpWiki)\r\n";
150         // RFC 2822 requires only a Date: and originator (From:)
151         // field, however the obsolete standard RFC 822 also
152         // requires a destination field.
153         $head .= "To: $from (PhpWiki)\r\n";
154     }
155     $head .= "Date: " . Rfc2822DateTime($current->get('mtime')) . "\r\n";
156     $head .= sprintf("Mime-Version: 1.0 (Produced by PhpWiki %s)\r\n",
157                      PHPWIKI_VERSION);
158
159     // This should just be entered by hand (or by script?)
160     // in the actual pgsrc files, since only they should have
161     // RCS ids.
162     //$head .= "X-Rcs-Id: \$Id\$\r\n";
163
164     $iter = $page->getAllRevisions();
165     $parts = array();
166     while ($revision = $iter->next()) {
167         $parts[] = MimeifyPageRevision($revision);
168         if ($nversions > 0 && count($parts) >= $nversions)
169             break;
170     }
171     if (count($parts) > 1)
172         return $head . MimeMultipart($parts);
173     assert($parts);
174     return $head . $parts[0];
175 }
176
177 /***
178  * Compute filename to used for storing contents of a wiki page.
179  *
180  * Basically we do a rawurlencode() which encodes everything except
181  * ASCII alphanumerics and '.', '-', and '_'.
182  *
183  * But we also want to encode leading dots to avoid filenames like
184  * '.', and '..'. (Also, there's no point in generating "hidden" file
185  * names, like '.foo'.)
186  *
187  * @param $pagename string Pagename.
188  * @return string Filename for page.
189  */
190 function FilenameForPage ($pagename)
191 {
192     $enc = rawurlencode($pagename);
193     return preg_replace('/^\./', '%2e', $enc);
194 }
195
196 /**
197  * The main() function which generates a zip archive of a PhpWiki.
198  *
199  * If $include_archive is false, only the current version of each page
200  * is included in the zip file; otherwise all archived versions are
201  * included as well.
202  */
203 function MakeWikiZip (&$request)
204 {
205     if ($request->getArg('include') == 'all') {
206         $zipname         = WIKI_NAME . _("FullDump") . date('Ymd-Hi') . '.zip';
207         $include_archive = true;
208     }
209     else {
210         $zipname         = WIKI_NAME . _("LatestSnapshot") . date('Ymd-Hi') . '.zip';
211         $include_archive = false;
212     }
213
214
215     $zip = new ZipWriter("Created by PhpWiki " . PHPWIKI_VERSION, $zipname);
216
217     /* ignore fatals in plugins */
218     if (check_php_version(4,1)) {
219         global $ErrorManager;
220         $ErrorManager->pushErrorHandler(new WikiFunctionCb('_dump_error_handler'));
221     }
222
223     $dbi = $request->getDbh();
224     $thispage = $request->getArg('pagename'); // for "Return to ..."
225     if ($exclude = $request->getArg('exclude')) {   // exclude which pagenames
226         $excludeList = explodePageList($exclude); 
227     } else {
228         $excludeList = array();
229     }
230     if ($whichpages = $request->getArg('pages')) {  // which pagenames
231         if ($whichpages == '[]') // current page
232             $whichpages = $thispage;
233         $pages = new WikiDB_Array_PageIterator(explodePageList($whichpages));
234     } else {
235         $pages = $dbi->getAllPages();
236     }
237     $request_args = $request->args;
238     
239     while ($page = $pages->next()) {
240         $request->args = $request_args; // some plugins might change them (esp. on POST)
241         if (! $request->getArg('start_debug'))
242             @set_time_limit(30); // Reset watchdog
243         else    
244             @set_time_limit(240);
245
246         $current = $page->getCurrentRevision();
247         if ($current->getVersion() == 0)
248             continue;
249
250         $pagename = $page->getName();
251         $wpn = new WikiPageName($pagename);
252         if (!$wpn->isValid())
253             continue;
254         if (in_array($page->getName(), $excludeList)) {
255             continue;
256         }
257
258         $attrib = array('mtime'    => $current->get('mtime'),
259                         'is_ascii' => 1);
260         if ($page->get('locked'))
261             $attrib['write_protected'] = 1;
262
263         if ($include_archive)
264             $content = MailifyPage($page, 0);
265         else
266             $content = MailifyPage($page);
267
268         $zip->addRegularFile( FilenameForPage($pagename),
269                               $content, $attrib);
270     }
271     $zip->finish();
272     if (check_php_version(4,1)) {
273         $ErrorManager->popErrorHandler();
274     }
275 }
276
277 function DumpToDir (&$request)
278 {
279     $directory = $request->getArg('directory');
280     if (empty($directory))
281         $directory = DEFAULT_DUMP_DIR; // See lib/plugin/WikiForm.php:87
282     if (empty($directory))
283         $request->finish(_("You must specify a directory to dump to"));
284
285     // see if we can access the directory the user wants us to use
286     if (! file_exists($directory)) {
287         if (! mkdir($directory, 0755))
288             $request->finish(fmt("Cannot create directory '%s'", $directory));
289         else
290             $html = HTML::p(fmt("Created directory '%s' for the page dump...",
291                                 $directory));
292     } else {
293         $html = HTML::p(fmt("Using directory '%s'", $directory));
294     }
295
296     StartLoadDump($request, _("Dumping Pages"), $html);
297
298     $dbi = $request->getDbh();
299     $thispage = $request->getArg('pagename'); // for "Return to ..."
300     if ($exclude = $request->getArg('exclude')) {   // exclude which pagenames
301         $excludeList = explodePageList($exclude); 
302     } else {
303         $excludeList = array();
304     }
305     if ($whichpages = $request->getArg('pages')) {  // which pagenames
306         if ($whichpages == '[]') // current page
307             $whichpages = $thispage;
308         $pages = new WikiDB_Array_PageIterator(explodePageList($whichpages));
309     } else {
310         $pages = $dbi->getAllPages();
311     }
312
313     $request_args = $request->args;
314     
315     while ($page = $pages->next()) {
316         $request->args = $request_args; // some plugins might change them (esp. on POST)
317         if (! $request->getArg('start_debug'))
318             @set_time_limit(30); // Reset watchdog.
319         else    
320             @set_time_limit(240);
321
322         $pagename = $page->getName();
323         if (!isa($request,'MockRequest')) {
324             PrintXML(HTML::br(), $pagename, ' ... ');
325             flush();
326         }
327
328         if (in_array($pagename, $excludeList)) {
329             if (!isa($request,'MockRequest')) {
330                 PrintXML(_("Skipped."));
331                 flush();
332             }
333             continue;
334         }
335         $filename = FilenameForPage($pagename);
336         $msg = HTML();
337         if($page->getName() != $filename) {
338             $msg->pushContent(HTML::small(fmt("saved as %s", $filename)),
339                               " ... ");
340         }
341
342         if ($request->getArg('include') == 'all')
343             $data = MailifyPage($page, 0);
344         else
345             $data = MailifyPage($page);
346
347         if ( !($fd = fopen("$directory/$filename", "wb")) ) {
348             $msg->pushContent(HTML::strong(fmt("couldn't open file '%s' for writing",
349                                                "$directory/$filename")));
350             $request->finish($msg);
351         }
352
353         $num = fwrite($fd, $data, strlen($data));
354         $msg->pushContent(HTML::small(fmt("%s bytes written", $num)));
355         if (!isa($request,'MockRequest')) {
356             PrintXML($msg);
357             flush();
358         }
359         assert($num == strlen($data));
360         fclose($fd);
361     }
362
363     EndLoadDump($request);
364 }
365
366 /**
367  * Dump all pages as XHTML to a directory, as pagename.html.
368  * Copies all used css files to the directory, all used images to a 
369  * "images" subdirectory, and all used buttons to a "images/buttons" subdirectory.
370  * The webserver must have write permissions to these directories. 
371  *   chown httpd HTML_DUMP_DIR; chmod u+rwx HTML_DUMP_DIR 
372  * should be enough.
373  *
374  * @param string directory (optional) path to dump to. Default: HTML_DUMP_DIR
375  * @param string pages     (optional) Comma-seperated of glob-style pagenames to dump
376  * @param string exclude   (optional) Comma-seperated of glob-style pagenames to exclude
377  */
378 function DumpHtmlToDir (&$request)
379 {
380     $directory = $request->getArg('directory');
381     if (empty($directory))
382         $directory = HTML_DUMP_DIR; // See lib/plugin/WikiForm.php:87
383     if (empty($directory))
384         $request->finish(_("You must specify a directory to dump to"));
385
386     // see if we can access the directory the user wants us to use
387     if (! file_exists($directory)) {
388         if (! mkdir($directory, 0755))
389             $request->finish(fmt("Cannot create directory '%s'", $directory));
390         else
391             $html = HTML::p(fmt("Created directory '%s' for the page dump...",
392                                 $directory));
393     } else {
394         $html = HTML::p(fmt("Using directory '%s'", $directory));
395     }
396
397     StartLoadDump($request, _("Dumping Pages"), $html);
398     $thispage = $request->getArg('pagename'); // for "Return to ..."
399
400     $dbi = $request->getDbh();
401     if ($exclude = $request->getArg('exclude')) {   // exclude which pagenames
402         $excludeList = explodePageList($exclude); 
403     } else {
404         $excludeList = array();
405     }
406     if ($whichpages = $request->getArg('pages')) {  // which pagenames
407         if ($whichpages == '[]') // current page
408             $whichpages = $thispage;
409         $pages = new WikiDB_Array_PageIterator(explodePageList($whichpages));
410     } else {
411         $pages = $dbi->getAllPages();
412     }
413
414     global $WikiTheme;
415     if (defined('HTML_DUMP_SUFFIX'))
416         $WikiTheme->HTML_DUMP_SUFFIX = HTML_DUMP_SUFFIX;
417     $WikiTheme->DUMP_MODE = 'HTML';
418     $request_args = $request->args;
419
420     // check if the dumped file will be accessible from outside
421     $doc_root = $request->get("DOCUMENT_ROOT");
422     $ldir = NormalizeLocalFileName($directory);
423     $wikiroot = NormalizeLocalFileName('');
424     if (string_starts_with($ldir, $doc_root)) {
425         $link_prefix = substr($directory, strlen($doc_root))."/";
426     } elseif (string_starts_with($ldir, $wikiroot)) {
427         $link_prefix = NormalizeWebFileName(substr($directory, strlen($wikiroot)))."/";
428     } else {
429         $prefix = '';
430         if (isWindows()) {
431             $prefix = '/' . substr($doc_root,0,2); // add drive where apache is installed
432         }
433         $link_prefix = "file://".$prefix.$directory."/";
434     }
435     
436     while ($page = $pages->next()) {
437         $request->args = $request_args; // some plugins might change them (esp. on POST)
438         if (! $request->getArg('start_debug'))
439             @set_time_limit(30); // Reset watchdog.
440         else    
441             @set_time_limit(240);
442           
443         $pagename = $page->getName();
444         if (!isa($request,'MockRequest')) {
445             PrintXML(HTML::br(), $pagename, ' ... ');
446             flush();
447         }
448         if (in_array($pagename, $excludeList)) {
449             if (!isa($request,'MockRequest')) {
450                 PrintXML(_("Skipped."));
451                 flush();
452             }
453             continue;
454         }
455
456         $request->setArg('pagename', $pagename); // Template::_basepage fix
457         $filename = FilenameForPage($pagename) . $WikiTheme->HTML_DUMP_SUFFIX;
458         $msg = HTML();
459
460         $revision = $page->getCurrentRevision();
461         $transformedContent = $revision->getTransformedContent();
462         $template = new Template('browse', $request,
463                                  array('revision' => $revision,
464                                        'CONTENT' => $transformedContent));
465
466         $data = GeneratePageasXML($template, $pagename);
467
468         if ( !($fd = fopen("$directory/$filename", "wb")) ) {
469             $msg->pushContent(HTML::strong(fmt("couldn't open file '%s' for writing",
470                                                "$directory/$filename")));
471             $request->finish($msg);
472         }
473         $num = fwrite($fd, $data, strlen($data));
474         if ($page->getName() != $filename) {
475             $link = LinkURL($link_prefix.$filename, $filename);
476             $msg->pushContent(HTML::small(_("saved as "), $link, " ... "));
477         }
478         $msg->pushContent(HTML::small(fmt("%s bytes written", $num), "\n"));
479         if (!isa($request,'MockRequest')) {
480             PrintXML($msg);
481             flush();
482         }
483
484         assert($num == strlen($data));
485         fclose($fd);
486     }
487
488     if (!empty($WikiTheme->dumped_images) and is_array($WikiTheme->dumped_images)) {
489         @mkdir("$directory/images");
490         foreach ($WikiTheme->dumped_images as $img_file) {
491             if (($from = $WikiTheme->_findFile($img_file)) and basename($from)) {
492                 $target = "$directory/images/".basename($img_file);
493                 if (copy($WikiTheme->_path . $from, $target)) {
494                     $msg = HTML(HTML::br(), HTML($from), HTML::small(fmt("... copied to %s", $target)));
495                     if (!isa($request,'MockRequest'))
496                         PrintXML($msg);
497                 }
498             } else {
499                 $msg = HTML(HTML::br(), HTML($from), HTML::small(fmt("... not found", $target)));
500                 if (!isa($request,'MockRequest'))
501                     PrintXML($msg);
502             }
503         }
504     }
505     if (!empty($WikiTheme->dumped_buttons) and is_array($WikiTheme->dumped_buttons)) {
506         // Buttons also
507         @mkdir("$directory/images/buttons");
508         foreach ($WikiTheme->dumped_buttons as $text => $img_file) {
509             if (($from = $WikiTheme->_findFile($img_file)) and basename($from)) {
510                 $target = "$directory/images/buttons/".basename($img_file);
511                 if (copy($WikiTheme->_path . $from, $target)) {
512                     $msg = HTML(HTML::br(), HTML($from), HTML::small(fmt("... copied to %s", $target)));
513                     if (!isa($request,'MockRequest'))
514                         PrintXML($msg);
515                 }
516             } else {
517                 $msg = HTML(HTML::br(), HTML($from), HTML::small(fmt("... not found", $target)));
518                 if (!isa($request,'MockRequest'))
519                     PrintXML($msg);
520             }
521         }
522     }
523     if (!empty($WikiTheme->dumped_css) and is_array($WikiTheme->dumped_css)) {
524       foreach ($WikiTheme->dumped_css as $css_file) {
525           if (($from = $WikiTheme->_findFile(basename($css_file))) and basename($from)) {
526               $target = "$directory/" . basename($css_file);
527               if (copy($WikiTheme->_path . $from, $target)) {
528                   $msg = HTML(HTML::br(), HTML($from), HTML::small(fmt("... copied to %s", $target)));
529                   if (!isa($request,'MockRequest'))
530                       PrintXML($msg);
531               }
532           } else {
533               $msg = HTML(HTML::br(), HTML($from), HTML::small(fmt("... not found", $target)));
534               if (!isa($request,'MockRequest'))
535                   PrintXML($msg);
536           }
537       }
538     }
539     $WikiTheme->HTML_DUMP_SUFFIX = '';
540     $WikiTheme->DUMP_MODE = false;
541
542     $request->setArg('pagename',$thispage); // Template::_basepage fix
543     EndLoadDump($request);
544 }
545
546 /* Known problem: any plugins or other code which echo()s text will
547  * lead to a corrupted html zip file which may produce the following
548  * errors upon unzipping:
549  *
550  * warning [wikihtml.zip]:  2401 extra bytes at beginning or within zipfile
551  * file #58:  bad zipfile offset (local header sig):  177561
552  *  (attempting to re-compensate)
553  *
554  * However, the actual wiki page data should be unaffected.
555  */
556 function MakeWikiZipHtml (&$request)
557 {
558     $zipname = "wikihtml.zip";
559     $zip = new ZipWriter("Created by PhpWiki " . PHPWIKI_VERSION, $zipname);
560     $dbi = $request->getDbh();
561     $thispage = $request->getArg('pagename'); // for "Return to ..."
562     if ($exclude = $request->getArg('exclude')) {   // exclude which pagenames
563         $excludeList = explodePageList($exclude); 
564     } else {
565         $excludeList = array();
566     }
567     if ($whichpages = $request->getArg('pages')) {  // which pagenames
568         if ($whichpages == '[]') // current page
569             $whichpages = $thispage;
570         $pages = new WikiDB_Array_PageIterator(explodePageList($whichpages));
571     } else {
572         $pages = $dbi->getAllPages();
573     }
574
575     global $WikiTheme;
576     if (defined('HTML_DUMP_SUFFIX'))
577         $WikiTheme->HTML_DUMP_SUFFIX = HTML_DUMP_SUFFIX;
578
579     /* ignore fatals in plugins */
580     if (check_php_version(4,1)) {
581         global $ErrorManager;
582         $ErrorManager->pushErrorHandler(new WikiFunctionCb('_dump_error_handler'));
583     }
584
585     $request_args = $request->args;
586     
587     while ($page = $pages->next()) {
588         $request->args = $request_args; // some plugins might change them (esp. on POST)
589         if (! $request->getArg('start_debug'))
590             @set_time_limit(30); // Reset watchdog.
591         else    
592             @set_time_limit(240);
593
594         $current = $page->getCurrentRevision();
595         if ($current->getVersion() == 0)
596             continue;
597         $pagename = $page->getName();
598         if (in_array($pagename, $excludeList)) {
599             continue;
600         }
601
602         $attrib = array('mtime'    => $current->get('mtime'),
603                         'is_ascii' => 1);
604         if ($page->get('locked'))
605             $attrib['write_protected'] = 1;
606
607         $request->setArg('pagename',$pagename); // Template::_basepage fix
608         $filename = FilenameForPage($pagename) . $WikiTheme->HTML_DUMP_SUFFIX;
609         $revision = $page->getCurrentRevision();
610
611         $transformedContent = $revision->getTransformedContent();
612
613         $template = new Template('browse', $request,
614                                  array('revision' => $revision,
615                                        'CONTENT' => $transformedContent));
616
617         $data = GeneratePageasXML($template, $pagename);
618
619         $zip->addRegularFile( $filename, $data, $attrib);
620     }
621     // FIXME: Deal with images here.
622     $zip->finish();
623     if (check_php_version(4,1)) {
624         $ErrorManager->popErrorHandler();
625     }
626     $WikiTheme->$HTML_DUMP_SUFFIX = '';
627 }
628
629
630 ////////////////////////////////////////////////////////////////
631 //
632 //  Functions for restoring.
633 //
634 ////////////////////////////////////////////////////////////////
635
636 function SavePage (&$request, &$pageinfo, $source, $filename)
637 {
638     static $overwite_all = false;
639     $pagedata    = $pageinfo['pagedata'];    // Page level meta-data.
640     $versiondata = $pageinfo['versiondata']; // Revision level meta-data.
641
642     if (empty($pageinfo['pagename'])) {
643         PrintXML(HTML::dt(HTML::strong(_("Empty pagename!"))));
644         return;
645     }
646
647     if (empty($versiondata['author_id']))
648         $versiondata['author_id'] = $versiondata['author'];
649
650     $pagename = $pageinfo['pagename'];
651     $content  = $pageinfo['content'];
652
653     if ($pagename ==_("InterWikiMap"))
654         $content = _tryinsertInterWikiMap($content);
655
656     $dbi = $request->getDbh();
657     $page = $dbi->getPage($pagename);
658
659     // Try to merge if updated pgsrc contents are different. This
660     // whole thing is hackish
661     //
662     // TODO: try merge unless:
663     // if (current contents = default contents && pgsrc_version >=
664     // pgsrc_version) then just upgrade this pgsrc
665     $needs_merge = false;
666     $merging = false;
667     $overwrite = false;
668
669     if ($request->getArg('merge')) {
670         $merging = true;
671     }
672     else if ($request->getArg('overwrite')) {
673         $overwrite = true;
674     }
675
676     $current = $page->getCurrentRevision();
677     if ( $current and (! $current->hasDefaultContents())
678          && ($current->getPackedContent() != $content)
679          && ($merging == true) ) {
680         include_once('lib/editpage.php');
681         $request->setArg('pagename', $pagename);
682         $r = $current->getVersion();
683         $request->setArg('revision', $current->getVersion());
684         $p = new LoadFileConflictPageEditor($request);
685         $p->_content = $content;
686         $p->_currentVersion = $r - 1;
687         $p->editPage($saveFailed = true);
688         return; //early return
689     }
690
691     foreach ($pagedata as $key => $value) {
692         if (!empty($value))
693             $page->set($key, $value);
694     }
695
696     $mesg = HTML::dd();
697     $skip = false;
698     if ($source)
699         $mesg->pushContent(' ', fmt("from %s", $source));
700
701
702     if (!$current) {
703         //FIXME: This should not happen! (empty vdata, corrupt cache or db)
704         $current = $page->getCurrentRevision();
705     }
706     if ($current->getVersion() == 0) {
707         $mesg->pushContent(' - ', _("new page"));
708         $isnew = true;
709     }
710     else {
711         if ( (! $current->hasDefaultContents())
712              && ($current->getPackedContent() != $content) ) {
713             if ($overwrite) {
714                 $mesg->pushContent(' ',
715                                    fmt("has edit conflicts - overwriting anyway"));
716                 $skip = false;
717                 if (substr_count($source, 'pgsrc')) {
718                     $versiondata['author'] = _("The PhpWiki programming team");
719                     // but leave authorid as userid who loaded the file
720                 }
721             }
722             else {
723                 $mesg->pushContent(' ', fmt("has edit conflicts - skipped"));
724                 $needs_merge = true; // hackish
725                 $skip = true;
726             }
727         }
728         else if ($current->getPackedContent() == $content
729                  && $current->get('author') == $versiondata['author']) {
730             // The page metadata is already changed, we don't need a new revision.
731             // This was called previously "is identical to current version %d - skipped"
732             // which is wrong, since the pagedata was stored, not skipped.
733             $mesg->pushContent(' ',
734                                fmt("content is identical to current version %d - no new revision created",
735                                    $current->getVersion()));
736             $skip = true;
737         }
738         $isnew = false;
739     }
740
741     if (! $skip ) {
742         // in case of failures print the culprit:
743         if (!isa($request,'MockRequest')) {
744             PrintXML(HTML::dt(WikiLink($pagename))); flush();
745         }
746         $new = $page->save($content, WIKIDB_FORCE_CREATE, $versiondata);
747         $dbi->touch();
748         $mesg->pushContent(' ', fmt("- saved to database as version %d",
749                                     $new->getVersion()));
750     }
751     if ($needs_merge) {
752         $f = $source;
753         // hackish, $source contains needed path+filename
754         $f = str_replace(sprintf(_("MIME file %s"), ''), '', $f);
755         $f = str_replace(sprintf(_("Serialized file %s"), ''), '', $f);
756         $f = str_replace(sprintf(_("plain file %s"), ''), '', $f);
757         //check if uploaded file? they pass just the content, but the file is gone
758         if (@stat($f)) {
759             global $WikiTheme;
760             $meb = Button(array('action' => 'loadfile',
761                                 'merge'=> true,
762                                 'source'=> $f),
763                           _("Merge Edit"),
764                           _("PhpWikiAdministration"),
765                           'wikiadmin');
766             $owb = Button(array('action' => 'loadfile',
767                                 'overwrite'=> true,
768                                 'source'=> $f),
769                           _("Restore Anyway"),
770                           _("PhpWikiAdministration"),
771                           'wikiunsafe');
772             $mesg->pushContent(' ', $meb, " ", $owb);
773             if (!$overwite_all) {
774               $owb = Button(array('action' => 'loadfile',
775                                 'overwrite'=> true,
776                                 'source'=> $request->getArg('source')),
777                           _("Overwrite All"),
778                           _("PhpWikiAdministration"),
779                           'wikiunsafe');
780               $mesg->pushContent(HTML::div(array('class' => 'hint'), $owb));
781               $overwite_all = true;
782             }
783         } else {
784             $mesg->pushContent(HTML::em(_(" Sorry, cannot merge.")));
785         }
786     }
787
788     if (!isa($request,'MockRequest')) {
789       if ($skip)
790         PrintXML(HTML::dt(HTML::em(WikiLink($pagename))), $mesg);
791       else
792         PrintXML($mesg);
793       flush();
794     }
795 }
796
797 // action=revert (by diff)
798 function RevertPage (&$request)
799 {
800     $mesg = HTML::dd();
801     $pagename = $request->getArg('pagename');
802     $version = $request->getArg('version');
803     if (!$version) {
804         PrintXML(HTML::dt(fmt("Revert")," ",WikiLink($pagename)),
805                  HTML::dd(_("missing required version argument")));
806         return;
807     }
808     $dbi = $request->getDbh();
809     $page = $dbi->getPage($pagename);
810     $current = $page->getCurrentRevision();
811     if ($current->getVersion() == 0) {
812         $mesg->pushContent(' ', _("no page content"));
813         PrintXML(HTML::dt(fmt("Revert")," ",WikiLink($pagename)),
814                  $mesg);
815         return;
816     }
817     if ($current->getVersion() == $version) {
818         $mesg->pushContent(' ', _("same version page"));
819         return;
820     }
821     $rev = $page->getRevision($version);
822     $content = $rev->getPackedContent();
823     $versiondata = $rev->_data;
824     $versiondata['summary'] = sprintf(_("revert to version %d"), $version);
825     $new = $page->save($content, $current->getVersion() + 1, $versiondata);
826     $dbi->touch();
827     $mesg->pushContent(' ', fmt("- version %d saved to database as version %d",
828                                 $version, $new->getVersion()));
829     PrintXML(HTML::dt(fmt("Revert")," ",WikiLink($pagename)),
830              $mesg);
831     flush();
832 }
833
834 function _tryinsertInterWikiMap($content) {
835     $goback = false;
836     if (strpos($content, "<verbatim>")) {
837         //$error_html = " The newly loaded pgsrc already contains a verbatim block.";
838         $goback = true;
839     }
840     if (!$goback && !defined('INTERWIKI_MAP_FILE')) {
841         $error_html = sprintf(" "._("%s: not defined"), "INTERWIKI_MAP_FILE");
842         $goback = true;
843     }
844     $mapfile = FindFile(INTERWIKI_MAP_FILE,1);
845     if (!$goback && !file_exists($mapfile)) {
846         $error_html = sprintf(" "._("%s: file not found"), INTERWIKI_MAP_FILE);
847         $goback = true;
848     }
849
850     if (!empty($error_html))
851         trigger_error(_("Default InterWiki map file not loaded.")
852                       . $error_html, E_USER_NOTICE);
853     if ($goback)
854         return $content;
855
856     // if loading from virgin setup do echo, otherwise trigger_error E_USER_NOTICE
857     if (!isa($GLOBALS['request'],'MockRequest'))
858         echo sprintf(_("Loading InterWikiMap from external file %s."), $mapfile),"<br />";
859
860     $fd = fopen ($mapfile, "rb");
861     $data = fread ($fd, filesize($mapfile));
862     fclose ($fd);
863     $content = $content . "\n<verbatim>\n$data</verbatim>\n";
864     return $content;
865 }
866
867 function ParseSerializedPage($text, $default_pagename, $user)
868 {
869     if (!preg_match('/^a:\d+:{[si]:\d+/', $text))
870         return false;
871
872     $pagehash = unserialize($text);
873
874     // Split up pagehash into four parts:
875     //   pagename
876     //   content
877     //   page-level meta-data
878     //   revision-level meta-data
879
880     if (!defined('FLAG_PAGE_LOCKED'))
881         define('FLAG_PAGE_LOCKED', 1);
882     $pageinfo = array('pagedata'    => array(),
883                       'versiondata' => array());
884
885     $pagedata = &$pageinfo['pagedata'];
886     $versiondata = &$pageinfo['versiondata'];
887
888     // Fill in defaults.
889     if (empty($pagehash['pagename']))
890         $pagehash['pagename'] = $default_pagename;
891     if (empty($pagehash['author'])) {
892         $pagehash['author'] = $user->getId();
893     }
894
895     foreach ($pagehash as $key => $value) {
896         switch($key) {
897             case 'pagename':
898             case 'version':
899             case 'hits':
900                 $pageinfo[$key] = $value;
901                 break;
902             case 'content':
903                 $pageinfo[$key] = join("\n", $value);
904                 break;
905             case 'flags':
906                 if (($value & FLAG_PAGE_LOCKED) != 0)
907                     $pagedata['locked'] = 'yes';
908                 break;
909             case 'owner':
910             case 'created':
911                 $pagedata[$key] = $value;
912                 break;
913             case 'acl':
914             case 'perm':
915                 $pagedata['perm'] = ParseMimeifiedPerm($value);
916                 break;
917             case 'lastmodified':
918                 $versiondata['mtime'] = $value;
919                 break;
920             case 'author':
921             case 'author_id':
922             case 'summary':
923                 $versiondata[$key] = $value;
924                 break;
925         }
926     }
927     return $pageinfo;
928 }
929
930 function SortByPageVersion ($a, $b) {
931     return $a['version'] - $b['version'];
932 }
933
934 function LoadFile (&$request, $filename, $text = false, $mtime = false)
935 {
936     if (!is_string($text)) {
937         // Read the file.
938         $stat  = stat($filename);
939         $mtime = $stat[9];
940         $text  = implode("", file($filename));
941     }
942
943         if (! $request->getArg('start_debug'))
944         @set_time_limit(30); // Reset watchdog.
945     else    
946         @set_time_limit(240);
947
948     // FIXME: basename("filewithnoslashes") seems to return garbage sometimes.
949     $basename = basename("/dummy/" . $filename);
950
951     if (!$mtime)
952         $mtime = time();    // Last resort.
953
954     $default_pagename = rawurldecode($basename);
955
956     if ( ($parts = ParseMimeifiedPages($text)) ) {
957         usort($parts, 'SortByPageVersion');
958         foreach ($parts as $pageinfo)
959             SavePage($request, $pageinfo, sprintf(_("MIME file %s"),
960                                                   $filename), $basename);
961     }
962     else if ( ($pageinfo = ParseSerializedPage($text, $default_pagename,
963                                                $request->getUser())) ) {
964         SavePage($request, $pageinfo, sprintf(_("Serialized file %s"),
965                                               $filename), $basename);
966     }
967     else {
968         $user = $request->getUser();
969
970         // Assume plain text file.
971         $pageinfo = array('pagename' => $default_pagename,
972                           'pagedata' => array(),
973                           'versiondata'
974                           => array('author' => $user->getId()),
975                           'content'  => preg_replace('/[ \t\r]*\n/', "\n",
976                                                      chop($text))
977                           );
978         SavePage($request, $pageinfo, sprintf(_("plain file %s"), $filename),
979                  $basename);
980     }
981 }
982
983 function LoadZip (&$request, $zipfile, $files = false, $exclude = false) {
984     $zip = new ZipReader($zipfile);
985     while (list ($fn, $data, $attrib) = $zip->readFile()) {
986         // FIXME: basename("filewithnoslashes") seems to return
987         // garbage sometimes.
988         $fn = basename("/dummy/" . $fn);
989         if ( ($files && !in_array($fn, $files))
990              || ($exclude && in_array($fn, $exclude)) ) {
991             PrintXML(HTML::dt(WikiLink($fn)),
992                      HTML::dd(_("Skipping")));
993             flush();
994             continue;
995         }
996
997         LoadFile($request, $fn, $data, $attrib['mtime']);
998     }
999 }
1000
1001 function LoadDir (&$request, $dirname, $files = false, $exclude = false) {
1002     $fileset = new LimitedFileSet($dirname, $files, $exclude);
1003
1004     if (!$files and ($skiplist = $fileset->getSkippedFiles())) {
1005         PrintXML(HTML::dt(HTML::strong(_("Skipping"))));
1006         $list = HTML::ul();
1007         foreach ($skiplist as $file)
1008             $list->pushContent(HTML::li(WikiLink($file)));
1009         PrintXML(HTML::dd($list));
1010     }
1011
1012     // Defer HomePage loading until the end. If anything goes wrong
1013     // the pages can still be loaded again.
1014     $files = $fileset->getFiles();
1015     if (in_array(HOME_PAGE, $files)) {
1016         $files = array_diff($files, array(HOME_PAGE));
1017         $files[] = HOME_PAGE;
1018     }
1019     foreach ($files as $file) {
1020         if (substr($file,-1,1) != '~') // refuse to load backup files
1021             LoadFile($request, "$dirname/$file");
1022     }
1023 }
1024
1025 class LimitedFileSet extends FileSet {
1026     function LimitedFileSet($dirname, $_include, $exclude) {
1027         $this->_includefiles = $_include;
1028         $this->_exclude = $exclude;
1029         $this->_skiplist = array();
1030         parent::FileSet($dirname);
1031     }
1032
1033     function _filenameSelector($fn) {
1034         $incl = &$this->_includefiles;
1035         $excl = &$this->_exclude;
1036
1037         if ( ($incl && !in_array($fn, $incl))
1038              || ($excl && in_array($fn, $excl)) ) {
1039             $this->_skiplist[] = $fn;
1040             return false;
1041         } else {
1042             return true;
1043         }
1044     }
1045
1046     function getSkippedFiles () {
1047         return $this->_skiplist;
1048     }
1049 }
1050
1051
1052 function IsZipFile ($filename_or_fd)
1053 {
1054     // See if it looks like zip file
1055     if (is_string($filename_or_fd))
1056     {
1057         $fd    = fopen($filename_or_fd, "rb");
1058         $magic = fread($fd, 4);
1059         fclose($fd);
1060     }
1061     else
1062     {
1063         $fpos  = ftell($filename_or_fd);
1064         $magic = fread($filename_or_fd, 4);
1065         fseek($filename_or_fd, $fpos);
1066     }
1067
1068     return $magic == ZIP_LOCHEAD_MAGIC || $magic == ZIP_CENTHEAD_MAGIC;
1069 }
1070
1071
1072 function LoadAny (&$request, $file_or_dir, $files = false, $exclude = false)
1073 {
1074     // Try urlencoded filename for accented characters.
1075     if (!file_exists($file_or_dir)) {
1076         // Make sure there are slashes first to avoid confusing phps
1077         // with broken dirname or basename functions.
1078         // FIXME: windows uses \ and :
1079         if (is_integer(strpos($file_or_dir, "/"))) {
1080             $file_or_dir = FindFile($file_or_dir);
1081             // Panic
1082             if (!file_exists($file_or_dir))
1083                 $file_or_dir = dirname($file_or_dir) . "/"
1084                     . urlencode(basename($file_or_dir));
1085         } else {
1086             // This is probably just a file.
1087             $file_or_dir = urlencode($file_or_dir);
1088         }
1089     }
1090
1091     $type = filetype($file_or_dir);
1092     if ($type == 'link') {
1093         // For symbolic links, use stat() to determine
1094         // the type of the underlying file.
1095         list(,,$mode) = stat($file_or_dir);
1096         $type = ($mode >> 12) & 017;
1097         if ($type == 010)
1098             $type = 'file';
1099         elseif ($type == 004)
1100             $type = 'dir';
1101     }
1102
1103     if (! $type) {
1104         $request->finish(fmt("Unable to load: %s", $file_or_dir));
1105     }
1106     else if ($type == 'dir') {
1107         LoadDir($request, $file_or_dir, $files, $exclude);
1108     }
1109     else if ($type != 'file' && !preg_match('/^(http|ftp):/', $file_or_dir))
1110     {
1111         $request->finish(fmt("Bad file type: %s", $type));
1112     }
1113     else if (IsZipFile($file_or_dir)) {
1114         LoadZip($request, $file_or_dir, $files, $exclude);
1115     }
1116     else /* if (!$files || in_array(basename($file_or_dir), $files)) */
1117     {
1118         LoadFile($request, $file_or_dir);
1119     }
1120 }
1121
1122 function LoadFileOrDir (&$request)
1123 {
1124     $source = $request->getArg('source');
1125     $finder = new FileFinder;
1126     $source = $finder->slashifyPath($source);
1127     $page = rawurldecode(basename($source));
1128     StartLoadDump($request, fmt("Loading '%s'", 
1129         HTML(dirname($source),
1130              dirname($source) ? "/" : "",
1131              WikiLink($page,'auto'))));
1132     echo "<dl>\n";
1133     LoadAny($request, $source);
1134     echo "</dl>\n";
1135     EndLoadDump($request);
1136 }
1137
1138 function SetupWiki (&$request)
1139 {
1140     global $GenericPages, $LANG;
1141
1142
1143     //FIXME: This is a hack (err, "interim solution")
1144     // This is a bogo-bogo-login:  Login without
1145     // saving login information in session state.
1146     // This avoids logging in the unsuspecting
1147     // visitor as "The PhpWiki programming team".
1148     //
1149     // This really needs to be cleaned up...
1150     // (I'm working on it.)
1151     $real_user = $request->_user;
1152     if (ENABLE_USER_NEW)
1153         $request->_user = new _BogoUser(_("The PhpWiki programming team"));
1154
1155     else
1156         $request->_user = new WikiUser($request, _("The PhpWiki programming team"),
1157                                        WIKIAUTH_BOGO);
1158
1159     StartLoadDump($request, _("Loading up virgin wiki"));
1160     echo "<dl>\n";
1161
1162     $pgsrc = FindLocalizedFile(WIKI_PGSRC);
1163     $default_pgsrc = FindFile(DEFAULT_WIKI_PGSRC);
1164
1165     $request->setArg('overwrite',true);
1166     if ($default_pgsrc != $pgsrc) {
1167         LoadAny($request, $default_pgsrc, $GenericPages);
1168     }
1169     $request->setArg('overwrite',false);
1170     LoadAny($request, $pgsrc);
1171
1172     // Ensure that all mandatory pages are loaded
1173     $finder = new FileFinder;
1174     foreach (array_merge(explode(':','OldTextFormattingRules:TextFormattingRules:PhpWikiAdministration'),
1175                          $GLOBALS['AllActionPages'],
1176                          array(constant('HOME_PAGE'))) as $f) {
1177         $page = gettext($f);
1178         if (isSubPage($page))
1179             $page = urlencode($page);
1180         if (! $request->_dbi->isWikiPage(urldecode($page)) ) {
1181             // translated version provided?
1182             if ($lf = FindLocalizedFile($pgsrc . $finder->_pathsep . $page, 1))
1183                 LoadAny($request, $lf);
1184             else { // load english version of required action page
1185                 LoadAny($request, FindFile(DEFAULT_WIKI_PGSRC . $finder->_pathsep . urlencode($f)));
1186                 $page = $f;
1187             }
1188         }
1189         if (!$request->_dbi->isWikiPage(urldecode($page))) {
1190             trigger_error(sprintf("Mandatory file %s couldn't be loaded!", $page),
1191                           E_USER_WARNING);
1192         }
1193     }
1194
1195     echo "</dl>\n";
1196     EndLoadDump($request);
1197 }
1198
1199 function LoadPostFile (&$request)
1200 {
1201     $upload = $request->getUploadedFile('file');
1202
1203     if (!$upload)
1204         $request->finish(_("No uploaded file to upload?")); // FIXME: more concise message
1205
1206
1207     // Dump http headers.
1208     StartLoadDump($request, sprintf(_("Uploading %s"), $upload->getName()));
1209     echo "<dl>\n";
1210
1211     $fd = $upload->open();
1212     if (IsZipFile($fd))
1213         LoadZip($request, $fd, false, array(_("RecentChanges")));
1214     else
1215         LoadFile($request, $upload->getName(), $upload->getContents());
1216
1217     echo "</dl>\n";
1218     EndLoadDump($request);
1219 }
1220
1221 /**
1222  $Log: not supported by cvs2svn $
1223  Revision 1.125  2004/10/14 19:19:33  rurban
1224  loadsave: check if the dumped file will be accessible from outside.
1225  and some other minor fixes. (cvsclient native not yet ready)
1226
1227  Revision 1.124  2004/10/04 23:44:28  rurban
1228  for older or CGI phps
1229
1230  Revision 1.123  2004/09/25 16:26:54  rurban
1231  deferr notifies (to be improved)
1232
1233  Revision 1.122  2004/09/17 14:25:45  rurban
1234  update comments
1235
1236  Revision 1.121  2004/09/08 13:38:00  rurban
1237  improve loadfile stability by using markup=2 as default for undefined markup-style.
1238  use more refs for huge objects.
1239  fix debug=static issue in WikiPluginCached
1240
1241  Revision 1.120  2004/07/08 19:04:42  rurban
1242  more unittest fixes (file backend, metadata RatingsDb)
1243
1244  Revision 1.119  2004/07/08 15:23:59  rurban
1245  less verbose for tests
1246
1247  Revision 1.118  2004/07/08 13:50:32  rurban
1248  various unit test fixes: print error backtrace on _DEBUG_TRACE; allusers fix; new PHPWIKI_NOMAIN constant for omitting the mainloop
1249
1250  Revision 1.117  2004/07/02 09:55:58  rurban
1251  more stability fixes: new DISABLE_GETIMAGESIZE if your php crashes when loading LinkIcons: failing getimagesize in old phps; blockparser stabilized
1252
1253  Revision 1.116  2004/07/01 09:05:41  rurban
1254  support pages and exclude arguments for all 4 dump methods
1255
1256  Revision 1.115  2004/07/01 08:51:22  rurban
1257  dumphtml: added exclude, print pagename before processing
1258
1259  Revision 1.114  2004/06/28 12:51:41  rurban
1260  improved dumphtml and virgin setup
1261
1262  Revision 1.113  2004/06/27 10:26:02  rurban
1263  oci8 patch by Philippe Vanhaesendonck + some ADODB notes+fixes
1264
1265  Revision 1.112  2004/06/25 14:29:20  rurban
1266  WikiGroup refactoring:
1267    global group attached to user, code for not_current user.
1268    improved helpers for special groups (avoid double invocations)
1269  new experimental config option ENABLE_XHTML_XML (fails with IE, and document.write())
1270  fixed a XHTML validation error on userprefs.tmpl
1271
1272  Revision 1.111  2004/06/21 16:38:55  rurban
1273  fixed the StartLoadDump html argument hack.
1274
1275  Revision 1.110  2004/06/21 16:22:30  rurban
1276  add DEFAULT_DUMP_DIR and HTML_DUMP_DIR constants, for easier cmdline dumps,
1277  fixed dumping buttons locally (images/buttons/),
1278  support pages arg for dumphtml,
1279  optional directory arg for dumpserial + dumphtml,
1280  fix a AllPages warning,
1281  show dump warnings/errors on DEBUG,
1282  don't warn just ignore on wikilens pagelist columns, if not loaded.
1283  RateIt pagelist column is called "rating", not "ratingwidget" (Dan?)
1284
1285  Revision 1.109  2004/06/17 11:31:05  rurban
1286  jump back to label after dump/upgrade
1287
1288  Revision 1.108  2004/06/16 12:43:01  rurban
1289  4.0.6 cannot use this errorhandler (not found)
1290
1291  Revision 1.107  2004/06/14 11:31:37  rurban
1292  renamed global $Theme to $WikiTheme (gforge nameclash)
1293  inherit PageList default options from PageList
1294    default sortby=pagename
1295  use options in PageList_Selectable (limit, sortby, ...)
1296  added action revert, with button at action=diff
1297  added option regex to WikiAdminSearchReplace
1298
1299  Revision 1.106  2004/06/13 13:54:25  rurban
1300  Catch fatals on the four dump calls (as file and zip, as html and mimified)
1301  FoafViewer: Check against external requirements, instead of fatal.
1302  Change output for xhtmldumps: using file:// urls to the local fs.
1303  Catch SOAP fatal by checking for GOOGLE_LICENSE_KEY
1304  Import GOOGLE_LICENSE_KEY and FORTUNE_DIR from config.ini.
1305
1306  Revision 1.105  2004/06/08 19:48:16  rurban
1307  fixed foreign setup: no ugly skipped msg for the GenericPages, load english actionpages if translated not found
1308
1309  Revision 1.104  2004/06/08 13:51:57  rurban
1310  some comments only
1311
1312  Revision 1.103  2004/06/08 10:54:46  rurban
1313  better acl dump representation, read back acl and owner
1314
1315  Revision 1.102  2004/06/06 16:58:51  rurban
1316  added more required ActionPages for foreign languages
1317  install now english ActionPages if no localized are found. (again)
1318  fixed default anon user level to be 0, instead of -1
1319    (wrong "required administrator to view this page"...)
1320
1321  Revision 1.101  2004/06/04 20:32:53  rurban
1322  Several locale related improvements suggested by Pierrick Meignen
1323  LDAP fix by John Cole
1324  reanable admin check without ENABLE_PAGEPERM in the admin plugins
1325
1326  Revision 1.100  2004/05/02 21:26:38  rurban
1327  limit user session data (HomePageHandle and auth_dbi have to invalidated anyway)
1328    because they will not survive db sessions, if too large.
1329  extended action=upgrade
1330  some WikiTranslation button work
1331  revert WIKIAUTH_UNOBTAINABLE (need it for main.php)
1332  some temp. session debug statements
1333
1334  Revision 1.99  2004/05/02 15:10:07  rurban
1335  new finally reliable way to detect if /index.php is called directly
1336    and if to include lib/main.php
1337  new global AllActionPages
1338  SetupWiki now loads all mandatory pages: HOME_PAGE, action pages, and warns if not.
1339  WikiTranslation what=buttons for Carsten to create the missing MacOSX buttons
1340  PageGroupTestOne => subpages
1341  renamed PhpWikiRss to PhpWikiRecentChanges
1342  more docs, default configs, ...
1343
1344  Revision 1.98  2004/04/29 23:25:12  rurban
1345  re-ordered locale init (as in 1.3.9)
1346  fixed loadfile with subpages, and merge/restore anyway
1347    (sf.net bug #844188)
1348
1349  Revision 1.96  2004/04/19 23:13:03  zorloc
1350  Connect the rest of PhpWiki to the IniConfig system.  Also the keyword regular expression is not a config setting
1351
1352  Revision 1.95  2004/04/18 01:11:52  rurban
1353  more numeric pagename fixes.
1354  fixed action=upload with merge conflict warnings.
1355  charset changed from constant to global (dynamic utf-8 switching)
1356
1357  Revision 1.94  2004/03/14 16:36:37  rurban
1358  dont load backup files
1359
1360  Revision 1.93  2004/02/26 03:22:05  rurban
1361  also copy css and images with XHTML Dump
1362
1363  Revision 1.92  2004/02/26 02:25:54  rurban
1364  fix empty and #-anchored links in XHTML Dumps
1365
1366  Revision 1.91  2004/02/24 17:19:37  rurban
1367  debugging helpers only
1368
1369  Revision 1.90  2004/02/24 17:09:24  rurban
1370  fixed \r\r\n with dumping on windows
1371
1372  Revision 1.88  2004/02/22 23:20:31  rurban
1373  fixed DumpHtmlToDir,
1374  enhanced sortby handling in PageList
1375    new button_heading th style (enabled),
1376  added sortby and limit support to the db backends and plugins
1377    for paging support (<<prev, next>> links on long lists)
1378
1379  Revision 1.87  2004/01/26 09:17:49  rurban
1380  * changed stored pref representation as before.
1381    the array of objects is 1) bigger and 2)
1382    less portable. If we would import packed pref
1383    objects and the object definition was changed, PHP would fail.
1384    This doesn't happen with an simple array of non-default values.
1385  * use $prefs->retrieve and $prefs->store methods, where retrieve
1386    understands the interim format of array of objects also.
1387  * simplified $prefs->get() and fixed $prefs->set()
1388  * added $user->_userid and class '_WikiUser' portability functions
1389  * fixed $user object ->_level upgrading, mostly using sessions.
1390    this fixes yesterdays problems with loosing authorization level.
1391  * fixed WikiUserNew::checkPass to return the _level
1392  * fixed WikiUserNew::isSignedIn
1393  * added explodePageList to class PageList, support sortby arg
1394  * fixed UserPreferences for WikiUserNew
1395  * fixed WikiPlugin for empty defaults array
1396  * UnfoldSubpages: added pagename arg, renamed pages arg,
1397    removed sort arg, support sortby arg
1398
1399  Revision 1.86  2003/12/02 16:18:26  carstenklapp
1400  Minor enhancement: Provide more meaningful filenames for WikiDB zip
1401  dumps & snapshots.
1402
1403  Revision 1.85  2003/11/30 18:18:13  carstenklapp
1404  Minor code optimization: use include_once instead of require_once
1405  inside functions that might not always called.
1406
1407  Revision 1.84  2003/11/26 20:47:47  carstenklapp
1408  Redo bugfix: My last refactoring broke merge-edit & overwrite
1409  functionality again, should be fixed now. Sorry.
1410
1411  Revision 1.83  2003/11/20 22:18:54  carstenklapp
1412  New feature: h1 during merge-edit displays WikiLink to original page.
1413  Internal changes: Replaced some hackish url-generation code in
1414  function SavePage (for pgsrc merge-edit) with appropriate Button()
1415  calls.
1416
1417  Revision 1.82  2003/11/18 19:48:01  carstenklapp
1418  Fixed missing gettext _() for button name.
1419
1420  Revision 1.81  2003/11/18 18:28:35  carstenklapp
1421  Bugfix: In the Load File function of PhpWikiAdministration: When doing
1422  a "Merge Edit" or "Restore Anyway", page names containing accented
1423  letters (such as locale/de/pgsrc/G%E4steBuch) would produce a file not
1424  found error (Use FilenameForPage funtion to urlencode page names).
1425
1426  Revision 1.80  2003/03/07 02:46:57  dairiki
1427  Omit checks for safe_mode before set_time_limit().  Just prefix the
1428  set_time_limit() calls with @ so that they fail silently if not
1429  supported.
1430
1431  Revision 1.79  2003/02/26 01:56:05  dairiki
1432  Only zip pages with legal pagenames.
1433
1434  Revision 1.78  2003/02/24 02:05:43  dairiki
1435  Fix "n bytes written" message when dumping HTML.
1436
1437  Revision 1.77  2003/02/21 04:12:05  dairiki
1438  Minor fixes for new cached markup.
1439
1440  Revision 1.76  2003/02/16 19:47:17  dairiki
1441  Update WikiDB timestamp when editing or deleting pages.
1442
1443  Revision 1.75  2003/02/15 03:04:30  dairiki
1444  Fix for WikiUser constructor API change.
1445
1446  Revision 1.74  2003/02/15 02:18:04  dairiki
1447  When default language was English (at least), pgsrc was being
1448  loaded twice.
1449
1450  LimitedFileSet: Fix typo/bug. ($include was being ignored.)
1451
1452  SetupWiki(): Fix bugs in loading of $GenericPages.
1453
1454  Revision 1.73  2003/01/28 21:09:17  zorloc
1455  The get_cfg_var() function should only be used when one is
1456  interested in the value from php.ini or similar. Use ini_get()
1457  instead to get the effective value of a configuration variable.
1458  -- Martin Geisler
1459
1460  Revision 1.72  2003/01/03 22:25:53  carstenklapp
1461  Cosmetic fix to "Merge Edit" & "Overwrite" buttons. Added "The PhpWiki
1462  programming team" as author when loading from pgsrc. Source
1463  reformatting.
1464
1465  Revision 1.71  2003/01/03 02:48:05  carstenklapp
1466  function SavePage: Added loadfile options for overwriting or merge &
1467  compare a loaded pgsrc file with an existing page.
1468
1469  function LoadAny: Added a general error message when unable to load a
1470  file instead of defaulting to "Bad file type".
1471
1472  */
1473
1474 // For emacs users
1475 // Local Variables:
1476 // mode: php
1477 // tab-width: 8
1478 // c-basic-offset: 4
1479 // c-hanging-comment-ender-p: nil
1480 // indent-tabs-mode: nil
1481 // End:
1482 ?>