function actionImport_upload(&$system, $args) { global $abspath; $chroot = "$abspath/upload"; $object = new mObject($this->getNodeId($args)); if ($object->getNodeId() <= 0) { $system->addAlert(ucf(i18n("invalid upload target"))); return; } if (!$object->hasRight("write")) { $system->addAlert(ucf(i18n("not enough rights"))); return; } // Validate path... only folders under upload if (count($args['filenames']) == 0) { $system->addAlert(ucf(i18n("you must select some files or folders to import"))); return; } $path = empty($args['path']) ? "/" : urldecode($args['path']); $fullpath = extractPath("$chroot$path"); $testpath = substr($fullpath, 0, strlen($chroot)); if ($testpath != $chroot) { $system->addAlert(ucf(i18n("this path is not allowed"))); return; } $logtext = "<strong>Beginning import from upload folder</strong> - ".date("Y-m-d H:i:s")."<hr/>"; foreach ($args['filenames'] as $filename) { if (is_dir("$fullpath$filename")) { $logtext .= importDir($object, "$fullpath$filename"); } else if (is_file("$fullpath$filename")) { createObject($object, $filename, "file", array("file" => "$filename:$fullpath$filename")); $logtext .= "Created ".$object->getPathInTree()."/$filename<br/>"; } else $logtext .= "Did not find $path$filename - skipping<br/>"; } $logtext .= "<hr/><strong>Finished import</strong> - ".date("Y-m-d H:i:s")."<br/><br/>"; $system->paddZoneData("zone_import_log", utf8e($logtext)); }
global $abspath; switch ($args['view']) { case "custom": echo "<div id=\"zone_import_custom\">"; echo compiletplWithOutput("scripts/import/custom", $args, $object); echo "</div>"; break; case "upload": $chroot = "$abspath/upload"; $path = empty($args['path']) ? "/" : urldecode($args['path']); $fullpath = extractPath("$chroot$path"); $testpath = substr($fullpath, 0, strlen($chroot)); if ($testpath != $chroot) { $system->addAlert(ucf(i18n("this path is not allowed"))); $args['path'] = "/"; } else $args['path'] = empty($args['path']) ? "/" : urldecode($args['path']); echo compiletplWithOutput("scripts/import/upload", $args, $object); break; case "files": echo compiletplWithOutput("scripts/import/files", $args, $object);