From: <var...@us...> - 2021-08-03 15:47:10
|
Revision: 10415 http://sourceforge.net/p/phpwiki/code/10415 Author: vargenau Date: 2021-08-03 15:47:08 +0000 (Tue, 03 Aug 2021) Log Message: ----------- DumpToDir: better error handling Modified Paths: -------------- trunk/lib/loadsave.php Modified: trunk/lib/loadsave.php =================================================================== --- trunk/lib/loadsave.php 2021-08-03 11:11:27 UTC (rev 10414) +++ trunk/lib/loadsave.php 2021-08-03 15:47:08 UTC (rev 10415) @@ -292,18 +292,36 @@ function DumpToDir(&$request) { $directory = $request->getArg('directory'); - if (empty($directory)) - $directory = DEFAULT_DUMP_DIR; // See lib/plugin/WikiForm.php:87 - if (empty($directory)) - $request->finish(_("You must specify a directory to dump to")); + if (empty($directory)) { + $directory = DEFAULT_DUMP_DIR; + } + if (empty($directory)) { + $html = HTML::p(array('class' => 'error'), + _("You must specify a directory to dump to")); + StartLoadDump($request, _("Dumping Pages"), $html); + EndLoadDump($request); + return; + } // see if we can access the directory the user wants us to use if (!file_exists($directory)) { - if (!mkdir($directory, 0755)) - $request->finish(fmt("Cannot create directory “%s”", $directory)); - else + if (!mkdir_p($directory, 0755)) { + $html = HTML::p(array('class' => 'error'), + fmt("Cannot create directory “%s”", $directory)); + StartLoadDump($request, _("Dumping Pages"), $html); + EndLoadDump($request); + return; + } else { $html = HTML::p(fmt("Created directory “%s” for the page dump...", $directory)); + } + } elseif (!is_writable($directory)) { + $html = HTML::p(array('class' => 'error'), + fmt("Cannot use directory “%s”, it is not writable", + $directory)); + StartLoadDump($request, _("Dumping Pages"), $html); + EndLoadDump($request); + return; } else { $html = HTML::p(fmt("Using directory “%s”", $directory)); } @@ -389,15 +407,16 @@ return mkdir($pathname, $permission); } $s = array_shift($arr); - $ok = TRUE; + $ok = true; foreach ($arr as $p) { $curr = "$s/$p"; if (!is_dir($curr)) $ok = mkdir($curr, $permission); $s = $curr; - if (!$ok) return FALSE; + if (!$ok) + return false; } - return TRUE; + return true; } /** @@ -422,7 +441,7 @@ // See if we can access the directory the user wants us to use if (!file_exists($directory)) { - if (!mkdir($directory, 0755)) + if (!mkdir_p($directory, 0755)) $request->finish(fmt("Cannot create directory “%s”", $directory)); else $html = HTML::p(fmt("Created directory “%s” for the page dump...", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |