5 Copyright 1999,2000,2001,2002,2004,2005,2006,2007 $ThePhpWikiProgrammingTeam
6 Copyright 2008-2009 Marc-Etienne Vargenau, Alcatel-Lucent
8 This file is part of PhpWiki.
10 PhpWiki is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 PhpWiki is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with PhpWiki; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 require_once("lib/ziplib.php");
26 require_once("lib/Template.php");
29 * ignore fatal errors during dump
31 function _dump_error_handler(&$error) {
32 if ($error->isFatal()) {
33 $error->errno = E_USER_WARNING;
36 return true; // Ignore error
38 if (preg_match('/Plugin/', $error->errstr))
41 // let the message come through: call the remaining handlers:
45 function StartLoadDump(&$request, $title, $html = '')
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'))
51 // FIXME: This is a hack. This really is the worst overall hack in phpwiki.
53 $html->pushContent('%BODY%');
54 $tmpl = Template('html', array('TITLE' => $title,
56 'CONTENT' => $html ? $html : '%BODY%'));
57 echo ereg_replace('%BODY%.*', '', $tmpl->getExpansion($html));
58 $request->chunkOutput();
60 // set marker for sendPageChangeNotification()
61 $request->_deferredPageChangeNotification = array();
64 function EndLoadDump(&$request)
68 if (isa($request,'MockRequest'))
70 $action = $request->getArg('action');
73 case 'zip': $label = _("ZIP files of database"); break;
74 case 'dumpserial': $label = _("Dump to directory"); break;
75 case 'upload': $label = _("Upload File"); break;
76 case 'loadfile': $label = _("Load File"); break;
77 case 'upgrade': $label = _("Upgrade"); break;
79 case 'ziphtml': $label = _("Dump pages as XHTML"); break;
81 if ($label) $label = str_replace(" ","_",$label);
82 if ($action == 'browse') // loading virgin
83 $pagelink = WikiLink(HOME_PAGE);
85 $pagelink = WikiLink(new WikiPageName(_("PhpWikiAdministration"),false,$label));
87 // do deferred sendPageChangeNotification()
88 if (!empty($request->_deferredPageChangeNotification)) {
89 $pages = $all_emails = $all_users = array();
90 foreach ($request->_deferredPageChangeNotification as $p) {
91 list($pagename, $emails, $userids) = $p;
93 $all_emails = array_unique(array_merge($all_emails, $emails));
94 $all_users = array_unique(array_merge($all_users, $userids));
96 $editedby = sprintf(_("Edited by: %s"), $request->_user->getId());
97 $content = "Loaded the following pages:\n" . join("\n", $pages);
98 if (mail(join(',',$all_emails),"[".WIKI_NAME."] "._("LoadDump"),
102 trigger_error(sprintf(_("PageChange Notification of %s sent to %s"),
103 join("\n",$pages), join(',',$all_users)), E_USER_NOTICE);
105 trigger_error(sprintf(_("PageChange Notification Error: Couldn't send %s to %s"),
106 join("\n",$pages), join(',',$all_users)), E_USER_WARNING);
111 unset($request->_deferredPageChangeNotification);
113 PrintXML(HTML::p(HTML::strong(_("Complete."))),
114 HTML::p(fmt("Return to %s", $pagelink)));
115 // Ugly hack to get valid XHTML code
116 if (isa($WikiTheme, 'WikiTheme_gforge')) {
123 if (isa($WikiTheme, 'WikiTheme_MonoBook')) {
129 echo "</body></html>\n";
133 ////////////////////////////////////////////////////////////////
135 // Functions for dumping.
137 ////////////////////////////////////////////////////////////////
141 * http://www.nacs.uci.edu/indiv/ehood/MIME/2045/rfc2045.html
142 * http://www.faqs.org/rfcs/rfc2045.html
143 * (RFC 1521 has been superceeded by RFC 2045 & others).
145 * Also see http://www.faqs.org/rfcs/rfc2822.html
147 function MailifyPage ($page, $nversions = 1)
149 $current = $page->getCurrentRevision(false);
152 if (STRICT_MAILABLE_PAGEDUMPS) {
153 $from = defined('SERVER_ADMIN') ? SERVER_ADMIN : 'foo@bar';
154 //This is for unix mailbox format: (not RFC (2)822)
155 // $head .= "From $from " . CTime(time()) . "\r\n";
156 $head .= "Subject: " . rawurlencode($page->getName()) . "\r\n";
157 $head .= "From: $from (PhpWiki)\r\n";
158 // RFC 2822 requires only a Date: and originator (From:)
159 // field, however the obsolete standard RFC 822 also
160 // requires a destination field.
161 $head .= "To: $from (PhpWiki)\r\n";
163 $head .= "Date: " . Rfc2822DateTime($current->get('mtime')) . "\r\n";
164 $head .= sprintf("Mime-Version: 1.0 (Produced by PhpWiki %s)\r\n",
167 // This should just be entered by hand (or by script?)
168 // in the actual pgsrc files, since only they should have
170 //$head .= "X-Rcs-Id: \$Id\$\r\n";
172 $iter = $page->getAllRevisions();
174 while ($revision = $iter->next()) {
175 $parts[] = MimeifyPageRevision($page, $revision);
176 if ($nversions > 0 && count($parts) >= $nversions)
179 if (count($parts) > 1)
180 return $head . MimeMultipart($parts);
182 return $head . $parts[0];
186 * Compute filename to used for storing contents of a wiki page.
188 * Basically we do a rawurlencode() which encodes everything except
189 * ASCII alphanumerics and '.', '-', and '_'.
191 * But we also want to encode leading dots to avoid filenames like
192 * '.', and '..'. (Also, there's no point in generating "hidden" file
193 * names, like '.foo'.)
195 * We have to apply a different "/" logic for dumpserial, htmldump and zipdump.
196 * dirs are allowed for zipdump and htmldump, not for dumpserial
199 * @param $pagename string Pagename.
200 * @return string Filename for page.
202 function FilenameForPage ($pagename, $action = false)
204 $enc = rawurlencode($pagename);
207 $action = $request->getArg('action');
209 if ($action != 'dumpserial') { // zip, ziphtml, dumphtml
210 // For every %2F we will need to mkdir -p dirname($pagename)
211 $enc = preg_replace('/%2F/', '/', $enc);
213 $enc = preg_replace('/^\./', '%2E', $enc);
214 $enc = preg_replace('/%20/', ' ', $enc);
215 $enc = preg_replace('/\.$/', '%2E', $enc);
220 * The main() function which generates a zip archive of a PhpWiki.
222 * If $include_archive is false, only the current version of each page
223 * is included in the zip file; otherwise all archived versions are
226 function MakeWikiZip (&$request)
228 global $ErrorManager;
229 if ($request->getArg('include') == 'all') {
230 $zipname = WIKI_NAME . _("FullDump") . date('Ymd-Hi') . '.zip';
231 $include_archive = true;
234 $zipname = WIKI_NAME . _("LatestSnapshot") . date('Ymd-Hi') . '.zip';
235 $include_archive = false;
237 $include_empty = false;
238 if ($request->getArg('include') == 'empty') {
239 $include_empty = true;
242 $zip = new ZipWriter("Created by PhpWiki " . PHPWIKI_VERSION, $zipname);
244 /* ignore fatals in plugins */
245 $ErrorManager->pushErrorHandler(new WikiFunctionCb('_dump_error_handler'));
247 $dbi =& $request->_dbi;
248 $thispage = $request->getArg('pagename'); // for "Return to ..."
249 if ($exclude = $request->getArg('exclude')) { // exclude which pagenames
250 $excludeList = explodePageList($exclude);
252 $excludeList = array();
254 if ($pages = $request->getArg('pages')) { // which pagenames
255 if ($pages == '[]') // current page
257 $page_iter = new WikiDB_Array_PageIterator(explodePageList($pages));
259 $page_iter = $dbi->getAllPages(false,false,false,$excludeList);
261 $request_args = $request->args;
262 $timeout = (! $request->getArg('start_debug')) ? 30 : 240;
264 while ($page = $page_iter->next()) {
265 $request->args = $request_args; // some plugins might change them (esp. on POST)
266 longer_timeout($timeout); // Reset watchdog
268 $current = $page->getCurrentRevision();
269 if ($current->getVersion() == 0)
272 $pagename = $page->getName();
273 $wpn = new WikiPageName($pagename);
274 if (!$wpn->isValid())
276 if (in_array($page->getName(), $excludeList)) {
280 $attrib = array('mtime' => $current->get('mtime'),
282 if ($page->get('locked'))
283 $attrib['write_protected'] = 1;
285 if ($include_archive)
286 $content = MailifyPage($page, 0);
288 $content = MailifyPage($page);
290 $zip->addRegularFile( FilenameForPage($pagename),
295 $ErrorManager->popErrorHandler();
298 function DumpToDir (&$request)
300 $directory = $request->getArg('directory');
301 if (empty($directory))
302 $directory = DEFAULT_DUMP_DIR; // See lib/plugin/WikiForm.php:87
303 if (empty($directory))
304 $request->finish(_("You must specify a directory to dump to"));
306 // see if we can access the directory the user wants us to use
307 if (! file_exists($directory)) {
308 if (! mkdir($directory, 0755))
309 $request->finish(fmt("Cannot create directory '%s'", $directory));
311 $html = HTML::p(fmt("Created directory '%s' for the page dump...",
314 $html = HTML::p(fmt("Using directory '%s'", $directory));
317 StartLoadDump($request, _("Dumping Pages"), $html);
319 $dbi =& $request->_dbi;
320 $thispage = $request->getArg('pagename'); // for "Return to ..."
321 if ($exclude = $request->getArg('exclude')) { // exclude which pagenames
322 $excludeList = explodePageList($exclude);
324 $excludeList = array();
326 $include_empty = false;
327 if ($request->getArg('include') == 'empty') {
328 $include_empty = true;
330 if ($pages = $request->getArg('pages')) { // which pagenames
331 if ($pages == '[]') // current page
333 $page_iter = new WikiDB_Array_PageIterator(explodePageList($pages));
335 $page_iter = $dbi->getAllPages($include_empty,false,false,$excludeList);
338 $request_args = $request->args;
339 $timeout = (! $request->getArg('start_debug')) ? 30 : 240;
341 while ($page = $page_iter->next()) {
342 $request->args = $request_args; // some plugins might change them (esp. on POST)
343 longer_timeout($timeout); // Reset watchdog
345 $pagename = $page->getName();
346 if (!isa($request,'MockRequest')) {
347 PrintXML(HTML::br(), $pagename, ' ... ');
351 if (in_array($pagename, $excludeList)) {
352 if (!isa($request, 'MockRequest')) {
353 PrintXML(_("Skipped."));
358 $filename = FilenameForPage($pagename);
360 if($page->getName() != $filename) {
361 $msg->pushContent(HTML::small(fmt("saved as %s", $filename)),
365 if ($request->getArg('include') == 'all')
366 $data = MailifyPage($page, 0);
368 $data = MailifyPage($page);
370 if ( !($fd = fopen($directory."/".$filename, "wb")) ) {
371 $msg->pushContent(HTML::strong(fmt("couldn't open file '%s' for writing",
372 "$directory/$filename")));
373 $request->finish($msg);
376 $num = fwrite($fd, $data, strlen($data));
377 $msg->pushContent(HTML::small(fmt("%s bytes written", $num)));
378 if (!isa($request, 'MockRequest')) {
382 assert($num == strlen($data));
386 EndLoadDump($request);
389 function _copyMsg($page, $smallmsg) {
390 if (!isa($GLOBALS['request'], 'MockRequest')) {
391 if ($page) $msg = HTML(HTML::br(), HTML($page), HTML::small($smallmsg));
392 else $msg = HTML::small($smallmsg);
398 function mkdir_p($pathname, $permission = 0777) {
399 $arr = explode("/", $pathname);
401 return mkdir($pathname, $permission);
403 $s = array_shift($arr);
405 foreach ($arr as $p) {
408 $ok = mkdir($curr, $permission);
410 if (!$ok) return FALSE;
416 * Dump all pages as XHTML to a directory, as pagename.html.
417 * Copies all used css files to the directory, all used images to a
418 * "images" subdirectory, and all used buttons to a "images/buttons" subdirectory.
419 * The webserver must have write permissions to these directories.
420 * chown httpd HTML_DUMP_DIR; chmod u+rwx HTML_DUMP_DIR
423 * @param string directory (optional) path to dump to. Default: HTML_DUMP_DIR
424 * @param string pages (optional) Comma-seperated of glob-style pagenames to dump.
425 * Also array of pagenames allowed.
426 * @param string exclude (optional) Comma-seperated of glob-style pagenames to exclude
428 function DumpHtmlToDir (&$request)
431 $directory = $request->getArg('directory');
432 if (empty($directory))
433 $directory = HTML_DUMP_DIR; // See lib/plugin/WikiForm.php:87
434 if (empty($directory))
435 $request->finish(_("You must specify a directory to dump to"));
437 // See if we can access the directory the user wants us to use
438 if (! file_exists($directory)) {
439 if (! mkdir($directory, 0755))
440 $request->finish(fmt("Cannot create directory '%s'", $directory));
442 $html = HTML::p(fmt("Created directory '%s' for the page dump...",
445 $html = HTML::p(fmt("Using directory '%s'", $directory));
447 StartLoadDump($request, _("Dumping Pages"), $html);
448 $thispage = $request->getArg('pagename'); // for "Return to ..."
450 $dbi =& $request->_dbi;
451 if ($exclude = $request->getArg('exclude')) { // exclude which pagenames
452 $excludeList = explodePageList($exclude);
454 $excludeList = array('DebugAuthInfo', 'DebugGroupInfo', 'AuthInfo');
456 if ($pages = $request->getArg('pages')) { // which pagenames
457 if ($pages == '[]') // current page
459 $page_iter = new WikiDB_Array_generic_iter(explodePageList($pages));
460 // not at admin page: dump only the current page
461 } elseif ($thispage != _("PhpWikiAdministration")) {
462 $page_iter = new WikiDB_Array_generic_iter(array($thispage));
464 $page_iter = $dbi->getAllPages(false,false,false,$excludeList);
467 $WikiTheme->DUMP_MODE = 'HTML';
468 _DumpHtmlToDir($directory, $page_iter, $request->getArg('exclude'));
469 $WikiTheme->DUMP_MODE = false;
471 $request->setArg('pagename',$thispage); // Template::_basepage fix
472 EndLoadDump($request);
475 /* Known problem: any plugins or other code which echo()s text will
476 * lead to a corrupted html zip file which may produce the following
477 * errors upon unzipping:
479 * warning [wikihtml.zip]: 2401 extra bytes at beginning or within zipfile
480 * file #58: bad zipfile offset (local header sig): 177561
481 * (attempting to re-compensate)
483 * However, the actual wiki page data should be unaffected.
485 function MakeWikiZipHtml (&$request)
488 if ($request->getArg('zipname')) {
489 $zipname = basename($request->getArg('zipname'));
490 if (!preg_match("/\.zip$/i", $zipname))
492 $request->setArg('zipname', false);
494 $zipname = "wikihtml.zip";
496 $zip = new ZipWriter("Created by PhpWiki " . PHPWIKI_VERSION, $zipname);
497 $dbi =& $request->_dbi;
498 $thispage = $request->getArg('pagename'); // for "Return to ..."
499 if ($pages = $request->getArg('pages')) { // which pagenames
500 if ($pages == '[]') // current page
502 $page_iter = new WikiDB_Array_generic_iter(explodePageList($pages));
504 $page_iter = $dbi->getAllPages(false,false,false,$request->getArg('exclude'));
507 $WikiTheme->DUMP_MODE = 'ZIPHTML';
508 _DumpHtmlToDir($zip, $page_iter, $request->getArg('exclude'));
509 $WikiTheme->DUMP_MODE = false;
513 * Internal html dumper. Used for dumphtml, ziphtml and pdf
515 function _DumpHtmlToDir ($target, $page_iter, $exclude = false)
517 global $WikiTheme, $request, $ErrorManager;
518 $silent = true; $zip = false; $directory = false;
519 if ($WikiTheme->DUMP_MODE == 'HTML') {
520 $directory = $target;
522 } elseif ($WikiTheme->DUMP_MODE == 'PDFHTML') {
523 $directory = $target;
524 } elseif (is_object($target)) { // $WikiTheme->DUMP_MODE == 'ZIPHTML'
528 $request->_TemplatesProcessed = array();
529 if ($exclude) { // exclude which pagenames
530 $excludeList = explodePageList($exclude);
532 $excludeList = array('DebugAuthInfo', 'DebugGroupInfo', 'AuthInfo');
534 $WikiTheme->VALID_LINKS = array();
535 if ($request->getArg('format')) { // pagelist
536 $page_iter_sav = $page_iter;
537 foreach ($page_iter_sav->asArray() as $handle) {
538 $WikiTheme->VALID_LINKS[] = is_string($handle) ? $handle : $handle->getName();
540 $page_iter_sav->reset();
543 if (defined('HTML_DUMP_SUFFIX'))
544 $WikiTheme->HTML_DUMP_SUFFIX = HTML_DUMP_SUFFIX;
545 $_bodyAttr = @$WikiTheme->_MoreAttr['body'];
546 unset($WikiTheme->_MoreAttr['body']);
548 $ErrorManager->pushErrorHandler(new WikiFunctionCb('_dump_error_handler'));
550 // check if the dumped file will be accessible from outside
551 $doc_root = $request->get("DOCUMENT_ROOT");
552 if ($WikiTheme->DUMP_MODE == 'HTML') {
553 $ldir = NormalizeLocalFileName($directory);
554 $wikiroot = NormalizeLocalFileName('');
555 if (string_starts_with($ldir, $doc_root)) {
556 $link_prefix = substr($directory, strlen($doc_root))."/";
557 } elseif (string_starts_with($ldir, $wikiroot)) {
558 $link_prefix = NormalizeWebFileName(substr($directory, strlen($wikiroot)))."/";
562 $prefix = '/'; // . substr($doc_root,0,2); // add drive where apache is installed
564 $link_prefix = "file://".$prefix.$directory."/";
570 $request_args = $request->args;
571 $timeout = (! $request->getArg('start_debug')) ? 60 : 240;
574 $directory = str_replace("\\", "/", $directory); // no Win95 support.
575 @mkdir("$directory/images");
579 $already_images = array();
581 while ($page = $page_iter->next()) {
582 if (is_string($page)) {
584 $page = $request->_dbi->getPage($pagename);
586 $pagename = $page->getName();
588 if (empty($firstpage)) $firstpage = $pagename;
589 if (array_key_exists($pagename, $already))
591 $already[$pagename] = 1;
592 $current = $page->getCurrentRevision();
593 //if ($current->getVersion() == 0)
596 $request->args = $request_args; // some plugins might change them (esp. on POST)
597 longer_timeout($timeout); // Reset watchdog
600 $attrib = array('mtime' => $current->get('mtime'),
602 if ($page->get('locked'))
603 $attrib['write_protected'] = 1;
604 } elseif (!$silent) {
605 if (!isa($request,'MockRequest')) {
606 PrintXML(HTML::br(), $pagename, ' ... ');
610 if (in_array($pagename, $excludeList)) {
611 if (!$silent and !isa($request,'MockRequest')) {
612 PrintXML(_("Skipped."));
618 if ($WikiTheme->DUMP_MODE == 'PDFHTML')
619 $request->setArg('action', 'pdf'); // to omit cache headers
620 $request->setArg('pagename', $pagename); // Template::_basepage fix
621 $filename = FilenameForPage($pagename) . $WikiTheme->HTML_DUMP_SUFFIX;
622 $args = array('revision' => $current,
623 'CONTENT' => $current->getTransformedContent(),
624 'relative_base' => $relative_base);
625 // For every %2F will need to mkdir -p dirname($pagename)
626 if (preg_match("/(%2F|\/)/", $filename)) {
627 // mkdir -p and set relative base for subdir pages
628 $filename = preg_replace("/%2F/", "/", $filename);
629 $count = substr_count($filename, "/");
630 $dirname = dirname($filename);
632 mkdir_p($directory."/".$dirname);
633 // Fails with "XX / YY", "XX" is created, "XX / YY" cannot be written
634 // if (isWindows()) // interesting Windows bug: cannot mkdir "bla "
635 // Since dumps needs to be copied, we have to disallow this for all platforms.
636 $filename = preg_replace("/ \//", "/", $filename);
637 $relative_base = "../";
639 $relative_base .= "../";
642 $args['relative_base'] = $relative_base;
646 $DUMP_MODE = $WikiTheme->DUMP_MODE;
647 $data = GeneratePageasXML(new Template('browse', $request, $args),
648 $pagename, $current, $args);
649 $WikiTheme->DUMP_MODE = $DUMP_MODE;
651 if (preg_match_all("/<img .*?src=\"(\/.+?)\"/", $data, $m)) {
652 // fix to local relative path for uploaded images, so that pdf will work
653 foreach ($m[1] as $img_file) {
654 $base = basename($img_file);
655 $data = str_replace('src="'.$img_file.'"','src="images/'.$base.'"', $data);
656 if (array_key_exists($img_file, $already_images))
658 $already_images[$img_file] = 1;
659 // resolve src from webdata to file
660 $src = $doc_root . $img_file;
661 if (file_exists($src) and $base) {
663 $target = "$directory/images/$base";
664 if (copy($src, $target)) {
666 _copyMsg($img_file, fmt("... copied to %s", $target));
669 _copyMsg($img_file, fmt("... not copied to %s", $target));
672 $target = "images/$base";
673 $zip->addSrcFile($target, $src);
680 $outfile = $directory."/".$filename;
681 if ( !($fd = fopen($outfile, "wb")) ) {
682 $msg->pushContent(HTML::strong(fmt("couldn't open file '%s' for writing",
684 $request->finish($msg);
686 $len = strlen($data);
687 $num = fwrite($fd, $data, $len);
688 if ($pagename != $filename) {
689 $link = LinkURL($link_prefix.$filename, $filename);
690 $msg->pushContent(HTML::small(_("saved as "), $link, " ... "));
692 $msg->pushContent(HTML::small(fmt("%s bytes written", $num), "\n"));
694 if (!isa($request, 'MockRequest')) {
698 $request->chunkOutput();
700 assert($num == $len);
702 $outfiles[] = $outfile;
704 $zip->addRegularFile($filename, $data, $attrib);
708 $request->_dbi->_cache->invalidate_cache($pagename);
709 unset ($request->_dbi->_cache->_pagedata_cache);
710 unset ($request->_dbi->_cache->_versiondata_cache);
711 unset ($request->_dbi->_cache->_glv_cache);
713 unset ($request->_dbi->_cache->_backend->_page_data);
716 unset($current->_transformedContent);
718 if (!empty($template)) {
719 unset($template->_request);
726 $attrib = false; //array('is_ascii' => 0);
727 if (!empty($WikiTheme->dumped_images) and is_array($WikiTheme->dumped_images)) {
728 // @mkdir("$directory/images");
729 foreach ($WikiTheme->dumped_images as $img_file) {
730 if (array_key_exists($img_file, $already_images))
732 $already_images[$img_file] = 1;
734 and ($from = $WikiTheme->_findFile($img_file, true))
738 $target = "$directory/images/".basename($from);
740 copy($WikiTheme->_path . $from, $target);
742 if (copy($WikiTheme->_path . $from, $target)) {
743 _copyMsg($from, fmt("... copied to %s", $target));
745 _copyMsg($from, fmt("... not copied to %s", $target));
749 $target = "images/".basename($from);
750 $zip->addSrcFile($target, $WikiTheme->_path . $from);
752 } elseif (!$silent) {
753 _copyMsg($from, _("... not found"));
758 if (!empty($WikiTheme->dumped_buttons)
759 and is_array($WikiTheme->dumped_buttons))
763 @mkdir("$directory/images/buttons");
764 foreach ($WikiTheme->dumped_buttons as $text => $img_file) {
765 if (array_key_exists($img_file, $already_images))
767 $already_images[$img_file] = 1;
769 and ($from = $WikiTheme->_findFile($img_file, true))
773 $target = "$directory/images/buttons/".basename($from);
775 copy($WikiTheme->_path . $from, $target);
777 if (copy($WikiTheme->_path . $from, $target)) {
778 _copyMsg($from, fmt("... copied to %s", $target));
780 _copyMsg($from, fmt("... not copied to %s", $target));
784 $target = "images/buttons/".basename($from);
785 $zip->addSrcFile($target, $WikiTheme->_path . $from);
787 } elseif (!$silent) {
788 _copyMsg($from, _("... not found"));
792 if (!empty($WikiTheme->dumped_css) and is_array($WikiTheme->dumped_css)) {
793 foreach ($WikiTheme->dumped_css as $css_file) {
794 if (array_key_exists($css_file, $already_images))
796 $already_images[$css_file] = 1;
798 and ($from = $WikiTheme->_findFile(basename($css_file), true))
801 // TODO: fix @import url(main.css);
803 $target = "$directory/" . basename($css_file);
805 copy($WikiTheme->_path . $from, $target);
807 if (copy($WikiTheme->_path . $from, $target)) {
808 _copyMsg($from, fmt("... copied to %s", $target));
810 _copyMsg($from, fmt("... not copied to %s", $target));
814 //$attrib = array('is_ascii' => 0);
815 $target = basename($css_file);
816 $zip->addSrcFile($target, $WikiTheme->_path . $from);
818 } elseif (!$silent) {
819 _copyMsg($from, _("... not found"));
827 if ($WikiTheme->DUMP_MODE == 'PDFHTML') {
828 if (USE_EXTERNAL_HTML2PDF and $outfiles) {
829 $cmd = EXTERNAL_HTML2PDF_PAGELIST.' "'.join('" "', $outfiles).'"';
830 $filename = FilenameForPage($firstpage);
832 $tmpfile = $directory . "/createpdf.bat";
833 $fp = fopen($tmpfile, "wb");
834 fwrite($fp, $cmd . " > $filename.pdf");
837 if (!headers_sent()) {
838 Header('Content-Type: application/pdf');
842 $tmpdir = getUploadFilePath();
843 $s = passthru($cmd . " > $tmpdir/$filename.pdf");
844 $errormsg = "<br />\nGenerated <a href=\"".getUploadDataPath()."$filename.pdf\">Upload:$filename.pdf</a>\n";
849 foreach($outfiles as $f) unlink($f);
852 if (!empty($errormsg)) {
853 $request->discardOutput();
854 $GLOBALS['ErrorManager']->_postponed_errors = array();
858 $ErrorManager->popErrorHandler();
860 $WikiTheme->HTML_DUMP_SUFFIX = '';
861 $WikiTheme->DUMP_MODE = false;
862 $WikiTheme->_MoreAttr['body'] = $_bodyAttr;
866 ////////////////////////////////////////////////////////////////
868 // Functions for restoring.
870 ////////////////////////////////////////////////////////////////
872 function SavePage (&$request, &$pageinfo, $source, $filename)
874 static $overwite_all = false;
875 $pagedata = $pageinfo['pagedata']; // Page level meta-data.
876 $versiondata = $pageinfo['versiondata']; // Revision level meta-data.
878 if (empty($pageinfo['pagename'])) {
879 PrintXML(HTML::p(HTML::strong(_("Empty pagename!"))));
883 if (empty($versiondata['author_id']))
884 $versiondata['author_id'] = $versiondata['author'];
886 // remove invalid backend specific chars. utf8 issues mostly
887 $pagename_check = new WikiPagename($pageinfo['pagename']);
888 if (!$pagename_check->isValid()) {
889 PrintXML(HTML::p(HTML::strong(_("Invalid pagename!")." ".$pageinfo['pagename'])));
892 $pagename = $pagename_check->getName();
893 $content = $pageinfo['content'];
895 if ($pagename == _("InterWikiMap"))
896 $content = _tryinsertInterWikiMap($content);
898 $dbi =& $request->_dbi;
899 $page = $dbi->getPage($pagename);
901 // Try to merge if updated pgsrc contents are different. This
902 // whole thing is hackish
904 // TODO: try merge unless:
905 // if (current contents = default contents && pgsrc_version >=
906 // pgsrc_version) then just upgrade this pgsrc
907 $needs_merge = false;
911 if ($request->getArg('merge')) {
914 else if ($request->getArg('overwrite')) {
918 $current = $page->getCurrentRevision();
920 $edit = $request->getArg('edit');
922 if (isset($edit['keep_old'])) {
926 elseif (isset($edit['overwrite'])) {
930 elseif ( $current and (! $current->hasDefaultContents())
931 && ($current->getPackedContent() != $content) )
933 include_once('lib/editpage.php');
934 $request->setArg('pagename', $pagename);
935 $v = $current->getVersion();
936 $request->setArg('revision', $current->getVersion());
937 $p = new LoadFileConflictPageEditor($request);
938 $p->_content = $content;
939 $p->_currentVersion = $v - 1;
940 $p->editPage($saveFailed = true);
941 return; //early return
945 foreach ($pagedata as $key => $value) {
947 $page->set($key, $value);
950 $mesg = HTML::p(array('style' => 'text-indent: 3em;'));
952 $mesg->pushContent(' ', fmt("from %s", $source));
955 //FIXME: This should not happen! (empty vdata, corrupt cache or db)
956 $current = $page->getCurrentRevision();
958 if ($current->getVersion() == 0) {
959 $mesg->pushContent(' - ', _("New page"));
963 if ( (! $current->hasDefaultContents())
964 && ($current->getPackedContent() != $content) ) {
966 $mesg->pushContent(' ',
967 fmt("has edit conflicts - overwriting anyway"));
969 if (substr_count($source, 'pgsrc')) {
970 $versiondata['author'] = ADMIN_USER;
971 // but leave authorid as userid who loaded the file
975 if (isset($edit['keep_old'])) {
976 $mesg->pushContent(' ', fmt("keep old"));
978 $mesg->pushContent(' ', fmt("has edit conflicts - skipped"));
979 $needs_merge = true; // hackish, to display the buttons
984 else if ($current->getPackedContent() == $content
985 && $current->get('author') == $versiondata['author']) {
986 // The page metadata is already changed, we don't need a new revision.
987 // This was called previously "is identical to current version %d - skipped"
988 // which is wrong, since the pagedata was stored, not skipped.
989 $mesg->pushContent(' ',
990 fmt("content is identical to current version %d - no new revision created",
991 $current->getVersion()));
998 // in case of failures print the culprit:
999 if (!isa($request,'MockRequest')) {
1000 PrintXML(HTML::p(WikiLink($pagename))); flush();
1002 $new = $page->save($content, WIKIDB_FORCE_CREATE, $versiondata);
1004 $mesg->pushContent(' ', fmt("- saved to database as version %d",
1005 $new->getVersion()));
1009 // hackish, $source contains needed path+filename
1010 $f = str_replace(sprintf(_("MIME file %s"), ''), '', $f);
1011 $f = str_replace(sprintf(_("Serialized file %s"), ''), '', $f);
1012 $f = str_replace(sprintf(_("plain file %s"), ''), '', $f);
1013 //check if uploaded file? they pass just the content, but the file is gone
1016 $meb = Button(array('action' => 'loadfile',
1020 _("PhpWikiAdministration"),
1022 $owb = Button(array('action' => 'loadfile',
1025 _("Restore Anyway"),
1026 _("PhpWikiAdministration"),
1028 $mesg->pushContent(' ', $meb, " ", $owb);
1029 if (!$overwite_all) {
1030 $args = $request->getArgs();
1031 $args['overwrite'] = 1;
1032 $owb = Button($args,
1034 _("PhpWikiAdministration"),
1036 $mesg->pushContent(HTML::span(array('class' => 'hint'), $owb));
1037 $overwite_all = true;
1040 $mesg->pushContent(HTML::em(_(" Sorry, cannot merge.")));
1044 if (!isa($request,'MockRequest')) {
1046 PrintXML(HTML::p(HTML::em(WikiLink($pagename))), $mesg);
1053 // action=revert (by diff)
1054 function RevertPage (&$request)
1056 $mesg = HTML::div();
1057 $pagename = $request->getArg('pagename');
1058 $version = $request->getArg('version');
1060 PrintXML(HTML::p(fmt("Revert")," ",WikiLink($pagename)),
1061 HTML::p(_("missing required version argument")));
1064 $dbi =& $request->_dbi;
1065 $page = $dbi->getPage($pagename);
1066 $current = $page->getCurrentRevision();
1067 $currversion = $current->getVersion();
1068 if ($currversion == 0) {
1069 $mesg->pushContent(' ', _("no page content"));
1070 PrintXML(HTML::p(fmt("Revert")," ",WikiLink($pagename)),
1075 if ($currversion == $version) {
1076 $mesg->pushContent(' ', _("same version page"));
1077 PrintXML(HTML::p(fmt("Revert")," ",WikiLink($pagename)),
1082 if ($request->getArg('cancel')) {
1083 $mesg->pushContent(' ', _("Cancelled"));
1084 PrintXML(HTML::p(fmt("Revert")," ",WikiLink($pagename)),
1089 if (!$request->getArg('verify')) {
1090 $mesg->pushContent(HTML::p(fmt("Are you sure to revert %s to version $version?", WikiLink($pagename))),
1091 HTML::form(array('action' => $request->getPostURL(),
1092 'method' => 'post'),
1093 HiddenInputs($request->getArgs(), false, array('verify')),
1094 HiddenInputs(array('verify' => 1)),
1095 Button('submit:verify', _("Yes"), 'button'),
1096 HTML::Raw(' '),
1097 Button('submit:cancel', _("Cancel"), 'button'))
1099 $rev = $page->getRevision($version);
1100 $html = HTML(HTML::fieldset($mesg), HTML::hr(), $rev->getTransformedContent());
1101 $template = Template('browse',
1102 array('CONTENT' => $html));
1103 GeneratePage($template, $pagename, $rev);
1104 $request->checkValidators();
1108 $rev = $page->getRevision($version);
1109 $content = $rev->getPackedContent();
1110 $versiondata = $rev->_data;
1111 $versiondata['summary'] = sprintf(_("revert to version %d"), $version);
1112 $new = $page->save($content, $currversion + 1, $versiondata);
1115 $mesg = HTML::span();
1116 $pagelink = WikiLink($pagename);
1117 $mesg->pushContent(fmt("Revert: %s", $pagelink),
1118 fmt("- version %d saved to database as version %d",
1119 $version, $new->getVersion()));
1120 // Force browse of current page version.
1121 $request->setArg('version', false);
1122 $template = Template('savepage', array());
1123 $template->replace('CONTENT', $new->getTransformedContent());
1125 GeneratePage($template, $mesg, $new);
1129 function _tryinsertInterWikiMap($content) {
1131 if (strpos($content, "<verbatim>")) {
1132 //$error_html = " The newly loaded pgsrc already contains a verbatim block.";
1135 if (!$goback && !defined('INTERWIKI_MAP_FILE')) {
1136 $error_html = sprintf(" "._("%s: not defined"), "INTERWIKI_MAP_FILE");
1139 $mapfile = FindFile(INTERWIKI_MAP_FILE,1);
1140 if (!$goback && !file_exists($mapfile)) {
1141 $error_html = sprintf(" "._("%s: file not found"), INTERWIKI_MAP_FILE);
1145 if (!empty($error_html))
1146 trigger_error(_("Default InterWiki map file not loaded.")
1147 . $error_html, E_USER_NOTICE);
1151 // if loading from virgin setup do echo, otherwise trigger_error E_USER_NOTICE
1152 if (!isa($GLOBALS['request'], 'MockRequest'))
1153 echo sprintf(_("Loading InterWikiMap from external file %s."), $mapfile),"<br />";
1155 $fd = fopen ($mapfile, "rb");
1156 $data = fread ($fd, filesize($mapfile));
1158 $content = $content . "\n<verbatim>\n$data</verbatim>\n";
1162 function ParseSerializedPage($text, $default_pagename, $user)
1164 if (!preg_match('/^a:\d+:{[si]:\d+/', $text))
1167 $pagehash = unserialize($text);
1169 // Split up pagehash into four parts:
1172 // page-level meta-data
1173 // revision-level meta-data
1175 if (!defined('FLAG_PAGE_LOCKED'))
1176 define('FLAG_PAGE_LOCKED', 1);
1177 if (!defined('FLAG_PAGE_EXTERNAL'))
1178 define('FLAG_PAGE_EXTERNAL', 1);
1179 $pageinfo = array('pagedata' => array(),
1180 'versiondata' => array());
1182 $pagedata = &$pageinfo['pagedata'];
1183 $versiondata = &$pageinfo['versiondata'];
1185 // Fill in defaults.
1186 if (empty($pagehash['pagename']))
1187 $pagehash['pagename'] = $default_pagename;
1188 if (empty($pagehash['author'])) {
1189 $pagehash['author'] = $user->getId();
1192 foreach ($pagehash as $key => $value) {
1197 $pageinfo[$key] = $value;
1200 $pageinfo[$key] = join("\n", $value);
1203 if (($value & FLAG_PAGE_LOCKED) != 0)
1204 $pagedata['locked'] = 'yes';
1205 if (($value & FLAG_PAGE_EXTERNAL) != 0)
1206 $pagedata['external'] = 'yes';
1210 $pagedata[$key] = $value;
1214 $pagedata['perm'] = ParseMimeifiedPerm($value);
1216 case 'lastmodified':
1217 $versiondata['mtime'] = $value;
1222 $versiondata[$key] = $value;
1226 if (empty($pagehash['charset']))
1227 $pagehash['charset'] = 'utf-8';
1228 // compare to target charset
1229 if (strtolower($pagehash['charset']) != strtolower($GLOBALS['charset'])) {
1230 $pageinfo['content'] = charset_convert($params['charset'], $GLOBALS['charset'], $pageinfo['content']);
1231 $pageinfo['pagename'] = charset_convert($params['charset'], $GLOBALS['charset'], $pageinfo['pagename']);
1236 function SortByPageVersion ($a, $b) {
1237 return $a['version'] - $b['version'];
1241 * Security alert! We should not allow to import config.ini into our wiki (or from a sister wiki?)
1242 * because the sql passwords are in plaintext there. And the webserver must be able to read it.
1243 * Detected by Santtu Jarvi.
1245 function LoadFile (&$request, $filename, $text = false, $mtime = false)
1247 if (preg_match("/config$/", dirname($filename)) // our or other config
1248 and preg_match("/config.*\.ini/", basename($filename))) // backups and other versions also
1250 trigger_error(sprintf("Refused to load %s", $filename), E_USER_WARNING);
1253 if (!is_string($text)) {
1255 $stat = stat($filename);
1257 $text = implode("", file($filename));
1260 if (! $request->getArg('start_debug')) @set_time_limit(30); // Reset watchdog
1261 else @set_time_limit(240);
1263 // FIXME: basename("filewithnoslashes") seems to return garbage sometimes.
1264 $basename = basename("/dummy/" . $filename);
1267 $mtime = time(); // Last resort.
1269 // DONE: check source - target charset for content and pagename
1270 // but only for pgsrc'ed content, not from the browser.
1272 $default_pagename = rawurldecode($basename);
1273 if ( ($parts = ParseMimeifiedPages($text)) ) {
1274 if (count($parts) > 1)
1275 $overwrite = $request->getArg('overwrite');
1276 usort($parts, 'SortByPageVersion');
1277 foreach ($parts as $pageinfo) {
1279 if (count($parts) > 1)
1280 $request->setArg('overwrite', 1);
1281 SavePage($request, $pageinfo, sprintf(_("MIME file %s"),
1282 $filename), $basename);
1284 if (count($parts) > 1)
1286 $request->setArg('overwrite', $overwrite);
1288 unset($request->_args['overwrite']);
1290 else if ( ($pageinfo = ParseSerializedPage($text, $default_pagename,
1291 $request->getUser())) ) {
1292 SavePage($request, $pageinfo, sprintf(_("Serialized file %s"),
1293 $filename), $basename);
1297 $user = $request->getUser();
1299 $file_charset = 'utf-8';
1300 // compare to target charset
1301 if ($file_charset != strtolower($GLOBALS['charset'])) {
1302 $text = charset_convert($file_charset, $GLOBALS['charset'], $text);
1303 $default_pagename = charset_convert($file_charset, $GLOBALS['charset'], $default_pagename);
1306 // Assume plain text file.
1307 $pageinfo = array('pagename' => $default_pagename,
1308 'pagedata' => array(),
1310 => array('author' => $user->getId()),
1311 'content' => preg_replace('/[ \t\r]*\n/', "\n",
1314 SavePage($request, $pageinfo, sprintf(_("plain file %s"), $filename),
1319 function LoadZip (&$request, $zipfile, $files = false, $exclude = false) {
1320 $zip = new ZipReader($zipfile);
1321 $timeout = (! $request->getArg('start_debug')) ? 20 : 120;
1322 while (list ($fn, $data, $attrib) = $zip->readFile()) {
1323 // FIXME: basename("filewithnoslashes") seems to return
1324 // garbage sometimes.
1325 $fn = basename("/dummy/" . $fn);
1326 if ( ($files && !in_array($fn, $files))
1327 || ($exclude && in_array($fn, $exclude)) ) {
1328 PrintXML(HTML::p(WikiLink($fn)),
1329 HTML::p(_("Skipping")));
1333 longer_timeout($timeout); // longer timeout per page
1334 LoadFile($request, $fn, $data, $attrib['mtime']);
1338 function LoadDir (&$request, $dirname, $files = false, $exclude = false) {
1339 $fileset = new LimitedFileSet($dirname, $files, $exclude);
1341 if (!$files and ($skiplist = $fileset->getSkippedFiles())) {
1342 PrintXML(HTML::p(HTML::strong(_("Skipping"))));
1344 foreach ($skiplist as $file)
1345 $list->pushContent(HTML::li(WikiLink($file)));
1346 PrintXML(HTML::p($list));
1349 // Defer HomePage loading until the end. If anything goes wrong
1350 // the pages can still be loaded again.
1351 $files = $fileset->getFiles();
1352 if (in_array(HOME_PAGE, $files)) {
1353 $files = array_diff($files, array(HOME_PAGE));
1354 $files[] = HOME_PAGE;
1356 $timeout = (! $request->getArg('start_debug')) ? 20 : 120;
1357 foreach ($files as $file) {
1358 longer_timeout($timeout); // longer timeout per page
1359 if (substr($file,-1,1) != '~') // refuse to load backup files
1360 LoadFile($request, "$dirname/$file");
1364 class LimitedFileSet extends FileSet {
1365 function LimitedFileSet($dirname, $_include, $exclude) {
1366 $this->_includefiles = $_include;
1367 $this->_exclude = $exclude;
1368 $this->_skiplist = array();
1369 parent::FileSet($dirname);
1372 function _filenameSelector($fn) {
1373 $incl = &$this->_includefiles;
1374 $excl = &$this->_exclude;
1376 if ( ($incl && !in_array($fn, $incl))
1377 || ($excl && in_array($fn, $excl)) ) {
1378 $this->_skiplist[] = $fn;
1385 function getSkippedFiles () {
1386 return $this->_skiplist;
1391 function IsZipFile ($filename_or_fd)
1393 // See if it looks like zip file
1394 if (is_string($filename_or_fd))
1396 $fd = fopen($filename_or_fd, "rb");
1397 $magic = fread($fd, 4);
1402 $fpos = ftell($filename_or_fd);
1403 $magic = fread($filename_or_fd, 4);
1404 fseek($filename_or_fd, $fpos);
1407 return $magic == ZIP_LOCHEAD_MAGIC || $magic == ZIP_CENTHEAD_MAGIC;
1411 function LoadAny (&$request, $file_or_dir, $files = false, $exclude = false)
1413 // Try urlencoded filename for accented characters.
1414 if (!file_exists($file_or_dir)) {
1415 // Make sure there are slashes first to avoid confusing phps
1416 // with broken dirname or basename functions.
1417 // FIXME: windows uses \ and :
1418 if (is_integer(strpos($file_or_dir, "/"))) {
1419 $newfile = FindFile($file_or_dir, true);
1420 // Panic. urlencoded by the browser (e.g. San%20Diego => San Diego)
1422 $file_or_dir = dirname($file_or_dir) . "/"
1423 . rawurlencode(basename($file_or_dir));
1425 // This is probably just a file.
1426 $file_or_dir = rawurlencode($file_or_dir);
1430 $type = filetype($file_or_dir);
1431 if ($type == 'link') {
1432 // For symbolic links, use stat() to determine
1433 // the type of the underlying file.
1434 list(,,$mode) = stat($file_or_dir);
1435 $type = ($mode >> 12) & 017;
1438 elseif ($type == 004)
1443 $request->finish(fmt("Empty or not existing source. Unable to load: %s", $file_or_dir));
1445 else if ($type == 'dir') {
1446 LoadDir($request, $file_or_dir, $files, $exclude);
1448 else if ($type != 'file' && !preg_match('/^(http|ftp):/', $file_or_dir))
1450 $request->finish(fmt("Bad file type: %s", $type));
1452 else if (IsZipFile($file_or_dir)) {
1453 LoadZip($request, $file_or_dir, $files, $exclude);
1455 else /* if (!$files || in_array(basename($file_or_dir), $files)) */
1457 LoadFile($request, $file_or_dir);
1461 function LoadFileOrDir (&$request)
1463 $source = $request->getArg('source');
1464 $finder = new FileFinder;
1465 $source = $finder->slashifyPath($source);
1466 $page = rawurldecode(basename($source));
1467 StartLoadDump($request, fmt("Loading '%s'",
1468 HTML(dirname($source),
1469 dirname($source) ? "/" : "",
1470 WikiLink($page,'auto'))));
1471 LoadAny($request, $source);
1472 EndLoadDump($request);
1476 * HomePage was not found so first-time install is supposed to run.
1477 * - import all pgsrc pages.
1478 * - Todo: installer interface to edit config/config.ini settings
1479 * - Todo: ask for existing old index.php to convert to config/config.ini
1480 * - Todo: theme-specific pages:
1481 * blog - HomePage, ADMIN_USER/Blogs
1483 function SetupWiki (&$request)
1485 global $GenericPages, $LANG;
1487 //FIXME: This is a hack (err, "interim solution")
1488 // This is a bogo-bogo-login: Login without
1489 // saving login information in session state.
1490 // This avoids logging in the unsuspecting
1491 // visitor as ADMIN_USER
1493 // This really needs to be cleaned up...
1494 // (I'm working on it.)
1495 $real_user = $request->_user;
1496 if (ENABLE_USER_NEW)
1497 $request->_user = new _BogoUser(ADMIN_USER);
1500 $request->_user = new WikiUser($request, ADMIN_USER, WIKIAUTH_BOGO);
1502 StartLoadDump($request, _("Loading up virgin wiki"));
1504 $pgsrc = FindLocalizedFile(WIKI_PGSRC);
1505 $default_pgsrc = FindFile(DEFAULT_WIKI_PGSRC);
1507 $request->setArg('overwrite', true);
1508 if ($default_pgsrc != $pgsrc) {
1509 LoadAny($request, $default_pgsrc, $GenericPages);
1511 $request->setArg('overwrite', false);
1512 LoadAny($request, $pgsrc);
1513 $dbi =& $request->_dbi;
1515 // Ensure that all mandatory pages are loaded
1516 $finder = new FileFinder;
1519 $mandatory = explode(':','SandBox:Template/Category:TemplateTalk:SpecialPages:CategoryCategory:CategoryActionPage:Help/OldTextFormattingRules:Help/TextFormattingRules:PhpWikiAdministration');
1520 } else if (WIKI_NAME == "help") {
1521 $mandatory = explode(':','SandBox:Template/Category:TemplateTalk:SpecialPages:CategoryCategory:CategoryActionPage:Help/TextFormattingRules:PhpWikiAdministration');
1523 $mandatory = explode(':','SandBox:Template/Category:TemplateTalk:SpecialPages:CategoryCategory:CategoryActionPage:TextFormattingRules:PhpWikiAdministration');
1525 foreach (array_merge($mandatory,
1526 $GLOBALS['AllActionPages'],
1527 array(constant('HOME_PAGE'))) as $f)
1529 $page = gettext($f);
1530 $epage = urlencode($page);
1531 if (! $dbi->isWikiPage($page) ) {
1532 // translated version provided?
1533 if ($lf = FindLocalizedFile($pgsrc . $finder->_pathsep . $epage, 1)) {
1534 LoadAny($request, $lf);
1535 } else { // load english version of required action page
1536 LoadAny($request, FindFile(DEFAULT_WIKI_PGSRC . $finder->_pathsep . urlencode($f)));
1540 if (! $dbi->isWikiPage($page)) {
1541 trigger_error(sprintf("Mandatory file %s couldn't be loaded!", $page),
1546 $pagename = _("InterWikiMap");
1547 $map = $dbi->getPage($pagename);
1548 $map->set('locked', true);
1549 PrintXML(HTML::p(HTML::em(WikiLink($pagename)), HTML::strong(" locked")));
1550 EndLoadDump($request);
1553 function LoadPostFile (&$request)
1555 $upload = $request->getUploadedFile('file');
1558 $request->finish(_("No uploaded file to upload?")); // FIXME: more concise message
1560 // Dump http headers.
1561 StartLoadDump($request, sprintf(_("Uploading %s"), $upload->getName()));
1563 $fd = $upload->open();
1565 LoadZip($request, $fd, false, array(_("RecentChanges")));
1567 LoadFile($request, $upload->getName(), $upload->getContents());
1569 EndLoadDump($request);
1576 // c-basic-offset: 4
1577 // c-hanging-comment-ender-p: nil
1578 // indent-tabs-mode: nil