2 rcs_id('$Id: loadsave.php,v 1.93 2004-02-26 03:22:05 rurban Exp $');
5 Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam
7 This file is part of PhpWiki.
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.
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.
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
25 require_once("lib/ziplib.php");
26 require_once("lib/Template.php");
28 function StartLoadDump(&$request, $title, $html = '')
30 // FIXME: This is a hack
31 $tmpl = Template('html', array('TITLE' => $title,
33 'CONTENT' => '%BODY%'));
34 echo ereg_replace('%BODY%.*', '', $tmpl->getExpansion($html));
37 function EndLoadDump(&$request)
39 // FIXME: This is a hack
40 $pagelink = WikiLink($request->getPage());
42 PrintXML(HTML::p(HTML::strong(_("Complete."))),
43 HTML::p(fmt("Return to %s", $pagelink)));
44 echo "</body></html>\n";
48 ////////////////////////////////////////////////////////////////
50 // Functions for dumping.
52 ////////////////////////////////////////////////////////////////
56 * http://www.nacs.uci.edu/indiv/ehood/MIME/2045/rfc2045.html
57 * http://www.faqs.org/rfcs/rfc2045.html
58 * (RFC 1521 has been superceeded by RFC 2045 & others).
60 * Also see http://www.faqs.org/rfcs/rfc2822.html
62 function MailifyPage ($page, $nversions = 1)
64 $current = $page->getCurrentRevision();
67 if (STRICT_MAILABLE_PAGEDUMPS) {
68 $from = defined('SERVER_ADMIN') ? SERVER_ADMIN : 'foo@bar';
69 //This is for unix mailbox format: (not RFC (2)822)
70 // $head .= "From $from " . CTime(time()) . "\r\n";
71 $head .= "Subject: " . rawurlencode($page->getName()) . "\r\n";
72 $head .= "From: $from (PhpWiki)\r\n";
73 // RFC 2822 requires only a Date: and originator (From:)
74 // field, however the obsolete standard RFC 822 also
75 // requires a destination field.
76 $head .= "To: $from (PhpWiki)\r\n";
78 $head .= "Date: " . Rfc2822DateTime($current->get('mtime')) . "\r\n";
79 $head .= sprintf("Mime-Version: 1.0 (Produced by PhpWiki %s)\r\n",
82 // This should just be entered by hand (or by script?)
83 // in the actual pgsrc files, since only they should have
85 //$head .= "X-Rcs-Id: \$Id\$\r\n";
87 $iter = $page->getAllRevisions();
89 while ($revision = $iter->next()) {
90 $parts[] = MimeifyPageRevision($revision);
91 if ($nversions > 0 && count($parts) >= $nversions)
94 if (count($parts) > 1)
95 return $head . MimeMultipart($parts);
97 return $head . $parts[0];
101 * Compute filename to used for storing contents of a wiki page.
103 * Basically we do a rawurlencode() which encodes everything except
104 * ASCII alphanumerics and '.', '-', and '_'.
106 * But we also want to encode leading dots to avoid filenames like
107 * '.', and '..'. (Also, there's no point in generating "hidden" file
108 * names, like '.foo'.)
110 * @param $pagename string Pagename.
111 * @return string Filename for page.
113 function FilenameForPage ($pagename)
115 $enc = rawurlencode($pagename);
116 return preg_replace('/^\./', '%2e', $enc);
120 * The main() function which generates a zip archive of a PhpWiki.
122 * If $include_archive is false, only the current version of each page
123 * is included in the zip file; otherwise all archived versions are
126 function MakeWikiZip (&$request)
128 if ($request->getArg('include') == 'all') {
129 $zipname = WIKI_NAME . _("FullDump") . date('Ymd-Hi') . '.zip';
130 $include_archive = true;
133 $zipname = WIKI_NAME . _("LatestSnapshot") . date('Ymd-Hi') . '.zip';
134 $include_archive = false;
139 $zip = new ZipWriter("Created by PhpWiki " . PHPWIKI_VERSION, $zipname);
141 $dbi = $request->getDbh();
142 $pages = $dbi->getAllPages();
143 while ($page = $pages->next()) {
144 if (! $request->getArg('start_debug'))
145 @set_time_limit(30); // Reset watchdog
147 $current = $page->getCurrentRevision();
148 if ($current->getVersion() == 0)
151 $wpn = new WikiPageName($page->getName());
152 if (!$wpn->isValid())
155 $attrib = array('mtime' => $current->get('mtime'),
157 if ($page->get('locked'))
158 $attrib['write_protected'] = 1;
160 if ($include_archive)
161 $content = MailifyPage($page, 0);
163 $content = MailifyPage($page);
165 $zip->addRegularFile( FilenameForPage($page->getName()),
171 function DumpToDir (&$request)
173 $directory = $request->getArg('directory');
174 if (empty($directory))
175 $request->finish(_("You must specify a directory to dump to"));
177 // see if we can access the directory the user wants us to use
178 if (! file_exists($directory)) {
179 if (! mkdir($directory, 0755))
180 $request->finish(fmt("Cannot create directory '%s'", $directory));
182 $html = HTML::p(fmt("Created directory '%s' for the page dump...",
185 $html = HTML::p(fmt("Using directory '%s'", $directory));
188 StartLoadDump($request, _("Dumping Pages"), $html);
190 $dbi = $request->getDbh();
191 $pages = $dbi->getAllPages();
193 while ($page = $pages->next()) {
194 if (! $request->getArg('start_debug'))
195 @set_time_limit(30); // Reset watchdog.
197 $filename = FilenameForPage($page->getName());
199 $msg = HTML(HTML::br(), $page->getName(), ' ... ');
201 if($page->getName() != $filename) {
202 $msg->pushContent(HTML::small(fmt("saved as %s", $filename)),
206 if ($request->getArg('include') == 'all')
207 $data = MailifyPage($page, 0);
209 $data = MailifyPage($page);
211 if ( !($fd = fopen("$directory/$filename", "wb")) ) {
212 $msg->pushContent(HTML::strong(fmt("couldn't open file '%s' for writing",
213 "$directory/$filename")));
214 $request->finish($msg);
217 $num = fwrite($fd, $data, strlen($data));
218 $msg->pushContent(HTML::small(fmt("%s bytes written", $num)));
222 assert($num == strlen($data));
226 EndLoadDump($request);
230 function DumpHtmlToDir (&$request)
232 $directory = $request->getArg('directory');
233 if (empty($directory))
234 $request->finish(_("You must specify a directory to dump to"));
236 // see if we can access the directory the user wants us to use
237 if (! file_exists($directory)) {
238 if (! mkdir($directory, 0755))
239 $request->finish(fmt("Cannot create directory '%s'", $directory));
241 $html = HTML::p(fmt("Created directory '%s' for the page dump...",
244 $html = HTML::p(fmt("Using directory '%s'", $directory));
247 StartLoadDump($request, _("Dumping Pages"), $html);
248 $thispage = $request->getArg('pagename'); // for "Return to ..."
250 $dbi = $request->getDbh();
251 $pages = $dbi->getAllPages();
253 global $HTML_DUMP_SUFFIX, $Theme;
254 if ($HTML_DUMP_SUFFIX)
255 $Theme->HTML_DUMP_SUFFIX = $HTML_DUMP_SUFFIX;
256 $Theme->DUMP_MODE = 'HTML';
258 while ($page = $pages->next()) {
259 if (! $request->getArg('start_debug'))
260 @set_time_limit(30); // Reset watchdog.
262 $pagename = $page->getName();
263 $request->setArg('pagename',$pagename); // Template::_basepage fix
264 $filename = FilenameForPage($pagename) . $Theme->HTML_DUMP_SUFFIX;
266 $msg = HTML(HTML::br(), $pagename, ' ... ');
268 if($page->getName() != $filename) {
269 $msg->pushContent(HTML::small(fmt("saved as %s", $filename)),
273 $revision = $page->getCurrentRevision();
274 $transformedContent = $revision->getTransformedContent();
275 $template = new Template('browse', $request,
276 array('revision' => $revision,
277 'CONTENT' => $transformedContent));
279 $data = GeneratePageasXML($template, $pagename);
281 if ( !($fd = fopen("$directory/$filename", "wb")) ) {
282 $msg->pushContent(HTML::strong(fmt("couldn't open file '%s' for writing",
283 "$directory/$filename")));
284 $request->finish($msg);
287 $num = fwrite($fd, $data, strlen($data));
288 $msg->pushContent(HTML::small(fmt("%s bytes written", $num), "\n"));
292 assert($num == strlen($data));
296 if (is_array($Theme->dumped_images)) {
297 @mkdir("$directory/images");
298 foreach ($Theme->dumped_images as $img_file) {
299 if (($from = $Theme->_findFile($img_file)) and basename($from)) {
300 $target = "$directory/images/".basename($img_file);
301 if (copy($Theme->_path . $from, $target)) {
302 $msg = HTML(HTML::br(), HTML($from), HTML::small(fmt("... copied to %s", $target)));
306 $msg = HTML(HTML::br(), HTML($from), HTML::small(fmt("... not found", $target)));
311 if (is_array($Theme->dumped_css)) {
312 foreach ($Theme->dumped_css as $css_file) {
313 if (($from = $Theme->_findFile(basename($css_file))) and basename($from)) {
314 $target = "$directory/" . basename($css_file);
315 if (copy($Theme->_path . $from, $target)) {
316 $msg = HTML(HTML::br(), HTML($from), HTML::small(fmt("... copied to %s", $target)));
320 $msg = HTML(HTML::br(), HTML($from), HTML::small(fmt("... not found", $target)));
325 $Theme->HTML_DUMP_SUFFIX = '';
326 $Theme->DUMP_MODE = false;
328 $request->setArg('pagename',$thispage); // Template::_basepage fix
329 EndLoadDump($request);
332 /* Known problem: any plugins or other code which echo()s text will
333 * lead to a corrupted html zip file which may produce the following
334 * errors upon unzipping:
336 * warning [wikihtml.zip]: 2401 extra bytes at beginning or within zipfile
337 * file #58: bad zipfile offset (local header sig): 177561
338 * (attempting to re-compensate)
340 * However, the actual wiki page data should be unaffected.
342 function MakeWikiZipHtml (&$request)
344 $zipname = "wikihtml.zip";
345 $zip = new ZipWriter("Created by PhpWiki " . PHPWIKI_VERSION, $zipname);
346 $dbi = $request->getDbh();
347 $pages = $dbi->getAllPages();
349 global $HTML_DUMP_SUFFIX, $Theme;
350 if ($HTML_DUMP_SUFFIX)
351 $Theme->HTML_DUMP_SUFFIX = $HTML_DUMP_SUFFIX;
353 while ($page = $pages->next()) {
354 if (! $request->getArg('start_debug'))
355 @set_time_limit(30); // Reset watchdog.
357 $current = $page->getCurrentRevision();
358 if ($current->getVersion() == 0)
361 $attrib = array('mtime' => $current->get('mtime'),
363 if ($page->get('locked'))
364 $attrib['write_protected'] = 1;
366 $pagename = $page->getName();
367 $request->setArg('pagename',$pagename); // Template::_basepage fix
368 $filename = FilenameForPage($pagename) . $Theme->HTML_DUMP_SUFFIX;
369 $revision = $page->getCurrentRevision();
371 $transformedContent = $revision->getTransformedContent();
373 $template = new Template('browse', $request,
374 array('revision' => $revision,
375 'CONTENT' => $transformedContent));
377 $data = GeneratePageasXML($template, $pagename);
379 $zip->addRegularFile( $filename, $data, $attrib);
381 // FIXME: Deal with images here.
383 $Theme->$HTML_DUMP_SUFFIX = '';
387 ////////////////////////////////////////////////////////////////
389 // Functions for restoring.
391 ////////////////////////////////////////////////////////////////
393 function SavePage (&$request, $pageinfo, $source, $filename)
395 $pagedata = $pageinfo['pagedata']; // Page level meta-data.
396 $versiondata = $pageinfo['versiondata']; // Revision level meta-data.
398 if (empty($pageinfo['pagename'])) {
399 PrintXML(HTML::dt(HTML::strong(_("Empty pagename!"))));
403 if (empty($versiondata['author_id']))
404 $versiondata['author_id'] = $versiondata['author'];
406 $pagename = $pageinfo['pagename'];
407 $content = $pageinfo['content'];
409 if ($pagename ==_("InterWikiMap"))
410 $content = _tryinsertInterWikiMap($content);
412 $dbi = $request->getDbh();
413 $page = $dbi->getPage($pagename);
415 $current = $page->getCurrentRevision();
416 // Try to merge if updated pgsrc contents are different. This
417 // whole thing is hackish
419 // TODO: try merge unless:
420 // if (current contents = default contents && pgsrc_version >=
421 // pgsrc_version) then just upgrade this pgsrc
422 $needs_merge = false;
426 if ($request->getArg('merge')) {
429 else if ($request->getArg('overwrite')) {
433 if ( (! $current->hasDefaultContents())
434 && ($current->getPackedContent() != $content)
435 && ($merging == true) ) {
436 include_once('lib/editpage.php');
437 $request->setArg('pagename', $pagename);
438 $r = $current->getVersion();
439 $request->setArg('revision', $current->getVersion());
440 $p = new LoadFileConflictPageEditor($request);
441 $p->_content = $content;
442 $p->_currentVersion = $r - 1;
443 $p->editPage($saveFailed = true);
444 return; //early return
447 foreach ($pagedata as $key => $value) {
449 $page->set($key, $value);
455 $mesg->pushContent(' ', fmt("from %s", $source));
458 $current = $page->getCurrentRevision();
459 if ($current->getVersion() == 0) {
460 $mesg->pushContent(' ', _("new page"));
464 if ( (! $current->hasDefaultContents())
465 && ($current->getPackedContent() != $content) ) {
467 $mesg->pushContent(' ',
468 fmt("has edit conflicts - overwriting anyway"));
470 if (substr_count($source, 'pgsrc')) {
471 $versiondata['author'] = _("The PhpWiki programming team");
472 // but leave authorid as userid who loaded the file
476 $mesg->pushContent(' ', fmt("has edit conflicts - skipped"));
477 $needs_merge = true; // hackish
481 else if ($current->getPackedContent() == $content
482 && $current->get('author') == $versiondata['author']) {
483 $mesg->pushContent(' ',
484 fmt("is identical to current version %d - skipped",
485 $current->getVersion()));
492 $new = $page->save($content, WIKIDB_FORCE_CREATE, $versiondata);
494 $mesg->pushContent(' ', fmt("- saved to database as version %d",
495 $new->getVersion()));
499 // hackish, $source contains needed path+filename
500 $f = str_replace(sprintf(_("MIME file %s"), ''), '', $f);
501 $f = str_replace(sprintf(_("Serialized file %s"), ''), '', $f);
502 $f = str_replace(sprintf(_("plain file %s"), ''), '', $f);
503 //check if uploaded file? they pass just the content, but the file is gone
506 $meb = Button(array('action' => 'loadfile',
510 _("PhpWikiAdministration"),
512 $owb = Button(array('action' => 'loadfile',
516 _("PhpWikiAdministration"),
519 $mesg->pushContent(' ', $meb, " ", $owb);
523 PrintXML(HTML::dt(HTML::em(WikiLink($pagename))), $mesg);
525 PrintXML(HTML::dt(WikiLink($pagename)), $mesg);
529 function _tryinsertInterWikiMap($content) {
531 if (strpos($content, "<verbatim>")) {
532 //$error_html = " The newly loaded pgsrc already contains a verbatim block.";
535 if (!$goback && !defined('INTERWIKI_MAP_FILE')) {
536 $error_html = sprintf(" "._("%s: not defined"), "INTERWIKI_MAP_FILE");
539 if (!$goback && !file_exists(INTERWIKI_MAP_FILE)) {
540 $error_html = sprintf(" "._("%s: file not found"), INTERWIKI_MAP_FILE);
544 if (!empty($error_html))
545 trigger_error(_("Default InterWiki map file not loaded.")
546 . $error_html, E_USER_NOTICE);
551 $filename = INTERWIKI_MAP_FILE;
552 trigger_error(sprintf(_("Loading InterWikiMap from external file %s."),
553 $filename), E_USER_NOTICE);
555 $fd = fopen ($filename, "rb");
556 $data = fread ($fd, filesize($filename));
558 $content = $content . "\n<verbatim>\n$data</verbatim>\n";
562 function ParseSerializedPage($text, $default_pagename, $user)
564 if (!preg_match('/^a:\d+:{[si]:\d+/', $text))
567 $pagehash = unserialize($text);
569 // Split up pagehash into four parts:
572 // page-level meta-data
573 // revision-level meta-data
575 if (!defined('FLAG_PAGE_LOCKED'))
576 define('FLAG_PAGE_LOCKED', 1);
577 $pageinfo = array('pagedata' => array(),
578 'versiondata' => array());
580 $pagedata = &$pageinfo['pagedata'];
581 $versiondata = &$pageinfo['versiondata'];
584 if (empty($pagehash['pagename']))
585 $pagehash['pagename'] = $default_pagename;
586 if (empty($pagehash['author'])) {
587 $pagehash['author'] = $user->getId();
590 foreach ($pagehash as $key => $value) {
595 $pageinfo[$key] = $value;
598 $pageinfo[$key] = join("\n", $value);
601 if (($value & FLAG_PAGE_LOCKED) != 0)
602 $pagedata['locked'] = 'yes';
605 $pagedata[$key] = $value;
608 $versiondata['mtime'] = $value;
613 $versiondata[$key] = $value;
620 function SortByPageVersion ($a, $b) {
621 return $a['version'] - $b['version'];
624 function LoadFile (&$request, $filename, $text = false, $mtime = false)
626 if (!is_string($text)) {
628 $stat = stat($filename);
630 $text = implode("", file($filename));
633 if (! $request->getArg('start_debug'))
634 @set_time_limit(30); // Reset watchdog.
636 // FIXME: basename("filewithnoslashes") seems to return garbage sometimes.
637 $basename = basename("/dummy/" . $filename);
640 $mtime = time(); // Last resort.
642 $default_pagename = rawurldecode($basename);
644 if ( ($parts = ParseMimeifiedPages($text)) ) {
645 usort($parts, 'SortByPageVersion');
646 foreach ($parts as $pageinfo)
647 SavePage($request, $pageinfo, sprintf(_("MIME file %s"),
648 $filename), $basename);
650 else if ( ($pageinfo = ParseSerializedPage($text, $default_pagename,
651 $request->getUser())) ) {
652 SavePage($request, $pageinfo, sprintf(_("Serialized file %s"),
653 $filename), $basename);
656 $user = $request->getUser();
658 // Assume plain text file.
659 $pageinfo = array('pagename' => $default_pagename,
660 'pagedata' => array(),
662 => array('author' => $user->getId()),
663 'content' => preg_replace('/[ \t\r]*\n/', "\n",
666 SavePage($request, $pageinfo, sprintf(_("plain file %s"), $filename),
671 function LoadZip (&$request, $zipfile, $files = false, $exclude = false) {
672 $zip = new ZipReader($zipfile);
673 while (list ($fn, $data, $attrib) = $zip->readFile()) {
674 // FIXME: basename("filewithnoslashes") seems to return
675 // garbage sometimes.
676 $fn = basename("/dummy/" . $fn);
677 if ( ($files && !in_array($fn, $files))
678 || ($exclude && in_array($fn, $exclude)) ) {
679 PrintXML(HTML::dt(WikiLink($fn)),
680 HTML::dd(_("Skipping")));
684 LoadFile($request, $fn, $data, $attrib['mtime']);
688 function LoadDir (&$request, $dirname, $files = false, $exclude = false) {
689 $fileset = new LimitedFileSet($dirname, $files, $exclude);
691 if (($skiplist = $fileset->getSkippedFiles())) {
692 PrintXML(HTML::dt(HTML::strong(_("Skipping"))));
694 foreach ($skiplist as $file)
695 $list->pushContent(HTML::li(WikiLink($file)));
696 PrintXML(HTML::dd($list));
699 // Defer HomePage loading until the end. If anything goes wrong
700 // the pages can still be loaded again.
701 $files = $fileset->getFiles();
702 if (in_array(HOME_PAGE, $files)) {
703 $files = array_diff($files, array(HOME_PAGE));
704 $files[] = HOME_PAGE;
706 foreach ($files as $file)
707 LoadFile($request, "$dirname/$file");
710 class LimitedFileSet extends FileSet {
711 function LimitedFileSet($dirname, $_include, $exclude) {
712 $this->_includefiles = $_include;
713 $this->_exclude = $exclude;
714 $this->_skiplist = array();
715 parent::FileSet($dirname);
718 function _filenameSelector($fn) {
719 $incl = &$this->_includefiles;
720 $excl = &$this->_exclude;
722 if ( ($incl && !in_array($fn, $incl))
723 || ($excl && in_array($fn, $excl)) ) {
724 $this->_skiplist[] = $fn;
731 function getSkippedFiles () {
732 return $this->_skiplist;
737 function IsZipFile ($filename_or_fd)
739 // See if it looks like zip file
740 if (is_string($filename_or_fd))
742 $fd = fopen($filename_or_fd, "rb");
743 $magic = fread($fd, 4);
748 $fpos = ftell($filename_or_fd);
749 $magic = fread($filename_or_fd, 4);
750 fseek($filename_or_fd, $fpos);
753 return $magic == ZIP_LOCHEAD_MAGIC || $magic == ZIP_CENTHEAD_MAGIC;
757 function LoadAny (&$request, $file_or_dir, $files = false, $exclude = false)
759 // Try urlencoded filename for accented characters.
760 if (!file_exists($file_or_dir)) {
761 // Make sure there are slashes first to avoid confusing phps
762 // with broken dirname or basename functions.
763 // FIXME: windows uses \ and :
764 if (is_integer(strpos($file_or_dir, "/"))) {
765 $file_or_dir = FindFile($file_or_dir);
767 if (!file_exists($file_or_dir))
768 $file_or_dir = dirname($file_or_dir) . "/"
769 . urlencode(basename($file_or_dir));
771 // This is probably just a file.
772 $file_or_dir = urlencode($file_or_dir);
776 $type = filetype($file_or_dir);
777 if ($type == 'link') {
778 // For symbolic links, use stat() to determine
779 // the type of the underlying file.
780 list(,,$mode) = stat($file_or_dir);
781 $type = ($mode >> 12) & 017;
784 elseif ($type == 004)
789 $request->finish(fmt("Unable to load: %s", $file_or_dir));
791 else if ($type == 'dir') {
792 LoadDir($request, $file_or_dir, $files, $exclude);
794 else if ($type != 'file' && !preg_match('/^(http|ftp):/', $file_or_dir))
796 $request->finish(fmt("Bad file type: %s", $type));
798 else if (IsZipFile($file_or_dir)) {
799 LoadZip($request, $file_or_dir, $files, $exclude);
801 else /* if (!$files || in_array(basename($file_or_dir), $files)) */
803 LoadFile($request, $file_or_dir);
807 function LoadFileOrDir (&$request)
809 $source = $request->getArg('source');
810 StartLoadDump($request, fmt("Loading '%s'", HTML(dirname($source),
812 WikiLink(basename($source),
815 LoadAny($request, $source);
817 EndLoadDump($request);
820 function SetupWiki (&$request)
822 global $GenericPages, $LANG;
825 //FIXME: This is a hack (err, "interim solution")
826 // This is a bogo-bogo-login: Login without
827 // saving login information in session state.
828 // This avoids logging in the unsuspecting
829 // visitor as "The PhpWiki programming team".
831 // This really needs to be cleaned up...
832 // (I'm working on it.)
833 $real_user = $request->_user;
835 $request->_user = new _BogoUser(_("The PhpWiki programming team"));
838 $request->_user = new WikiUser($request, _("The PhpWiki programming team"),
841 StartLoadDump($request, _("Loading up virgin wiki"));
844 $pgsrc = FindLocalizedFile(WIKI_PGSRC);
845 $default_pgsrc = FindFile(DEFAULT_WIKI_PGSRC);
847 if ($default_pgsrc != $pgsrc)
848 LoadAny($request, $default_pgsrc, $GenericPages);
850 LoadAny($request, $pgsrc);
853 EndLoadDump($request);
856 function LoadPostFile (&$request)
858 $upload = $request->getUploadedFile('file');
861 $request->finish(_("No uploaded file to upload?")); // FIXME: more concise message
864 // Dump http headers.
865 StartLoadDump($request, sprintf(_("Uploading %s"), $upload->getName()));
868 $fd = $upload->open();
870 LoadZip($request, $fd, false, array(_("RecentChanges")));
872 LoadFile($request, $upload->getName(), $upload->getContents());
875 EndLoadDump($request);
879 $Log: not supported by cvs2svn $
880 Revision 1.92 2004/02/26 02:25:54 rurban
881 fix empty and #-anchored links in XHTML Dumps
883 Revision 1.91 2004/02/24 17:19:37 rurban
884 debugging helpers only
886 Revision 1.90 2004/02/24 17:09:24 rurban
887 fixed \r\r\n with dumping on windows
889 Revision 1.88 2004/02/22 23:20:31 rurban
891 enhanced sortby handling in PageList
892 new button_heading th style (enabled),
893 added sortby and limit support to the db backends and plugins
894 for paging support (<<prev, next>> links on long lists)
896 Revision 1.87 2004/01/26 09:17:49 rurban
897 * changed stored pref representation as before.
898 the array of objects is 1) bigger and 2)
899 less portable. If we would import packed pref
900 objects and the object definition was changed, PHP would fail.
901 This doesn't happen with an simple array of non-default values.
902 * use $prefs->retrieve and $prefs->store methods, where retrieve
903 understands the interim format of array of objects also.
904 * simplified $prefs->get() and fixed $prefs->set()
905 * added $user->_userid and class '_WikiUser' portability functions
906 * fixed $user object ->_level upgrading, mostly using sessions.
907 this fixes yesterdays problems with loosing authorization level.
908 * fixed WikiUserNew::checkPass to return the _level
909 * fixed WikiUserNew::isSignedIn
910 * added explodePageList to class PageList, support sortby arg
911 * fixed UserPreferences for WikiUserNew
912 * fixed WikiPlugin for empty defaults array
913 * UnfoldSubpages: added pagename arg, renamed pages arg,
914 removed sort arg, support sortby arg
916 Revision 1.86 2003/12/02 16:18:26 carstenklapp
917 Minor enhancement: Provide more meaningful filenames for WikiDB zip
920 Revision 1.85 2003/11/30 18:18:13 carstenklapp
921 Minor code optimization: use include_once instead of require_once
922 inside functions that might not always called.
924 Revision 1.84 2003/11/26 20:47:47 carstenklapp
925 Redo bugfix: My last refactoring broke merge-edit & overwrite
926 functionality again, should be fixed now. Sorry.
928 Revision 1.83 2003/11/20 22:18:54 carstenklapp
929 New feature: h1 during merge-edit displays WikiLink to original page.
930 Internal changes: Replaced some hackish url-generation code in
931 function SavePage (for pgsrc merge-edit) with appropriate Button()
934 Revision 1.82 2003/11/18 19:48:01 carstenklapp
935 Fixed missing gettext _() for button name.
937 Revision 1.81 2003/11/18 18:28:35 carstenklapp
938 Bugfix: In the Load File function of PhpWikiAdministration: When doing
939 a "Merge Edit" or "Restore Anyway", page names containing accented
940 letters (such as locale/de/pgsrc/G%E4steBuch) would produce a file not
941 found error (Use FilenameForPage funtion to urlencode page names).
943 Revision 1.80 2003/03/07 02:46:57 dairiki
944 Omit checks for safe_mode before set_time_limit(). Just prefix the
945 set_time_limit() calls with @ so that they fail silently if not
948 Revision 1.79 2003/02/26 01:56:05 dairiki
949 Only zip pages with legal pagenames.
951 Revision 1.78 2003/02/24 02:05:43 dairiki
952 Fix "n bytes written" message when dumping HTML.
954 Revision 1.77 2003/02/21 04:12:05 dairiki
955 Minor fixes for new cached markup.
957 Revision 1.76 2003/02/16 19:47:17 dairiki
958 Update WikiDB timestamp when editing or deleting pages.
960 Revision 1.75 2003/02/15 03:04:30 dairiki
961 Fix for WikiUser constructor API change.
963 Revision 1.74 2003/02/15 02:18:04 dairiki
964 When default language was English (at least), pgsrc was being
967 LimitedFileSet: Fix typo/bug. ($include was being ignored.)
969 SetupWiki(): Fix bugs in loading of $GenericPages.
971 Revision 1.73 2003/01/28 21:09:17 zorloc
972 The get_cfg_var() function should only be used when one is
973 interested in the value from php.ini or similar. Use ini_get()
974 instead to get the effective value of a configuration variable.
977 Revision 1.72 2003/01/03 22:25:53 carstenklapp
978 Cosmetic fix to "Merge Edit" & "Overwrite" buttons. Added "The PhpWiki
979 programming team" as author when loading from pgsrc. Source
982 Revision 1.71 2003/01/03 02:48:05 carstenklapp
983 function SavePage: Added loadfile options for overwriting or merge &
984 compare a loaded pgsrc file with an existing page.
986 function LoadAny: Added a general error message when unable to load a
987 file instead of defaulting to "Bad file type".
996 // c-hanging-comment-ender-p: nil
997 // indent-tabs-mode: nil