public function checkWriteableDir(class_filesystem $objFilesystem, $strDirName) { if ($objFilesystem->isWritable($strDirName)) { echo "\n Ok, " . $strDirName . " is writeable."; } else { die("\n\n ERROR: " . $strDirName . " is NOT writeable!!\n Please change permissions to let the webserver write in it."); } }
/** * Tries to save the passed file. * Therefore, the following post-params should be given: * action = fileUpload * folder = the folder to store the file within * systemid = the filemanagers' repo-id * inputElement = name of the inputElement * * @return string * @permissions right1 */ protected function actionFileupload() { $strReturn = ""; /** @var class_module_mediamanager_repo|class_module_mediamanager_file $objFile */ $objFile = class_objectfactory::getInstance()->getObject($this->getSystemid()); /** * @var class_module_mediamanager_repo */ $objRepo = null; if ($objFile instanceof class_module_mediamanager_file) { $strFolder = $objFile->getStrFilename(); if (!$objFile->rightEdit() || $objFile->getIntType() != class_module_mediamanager_file::$INT_TYPE_FOLDER) { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_UNAUTHORIZED); $strReturn .= "<message><error>" . xmlSafeString($this->getLang("commons_error_permissions")) . "</error></message>"; return $strReturn; } $objRepo = class_objectfactory::getInstance()->getObject($objFile->getPrevId()); while (!$objRepo instanceof class_module_mediamanager_repo) { $objRepo = class_objectfactory::getInstance()->getObject($objRepo->getPrevId()); } } elseif ($objFile instanceof class_module_mediamanager_repo) { $objRepo = $objFile; $strFolder = $objFile->getStrPath(); if (!$objFile->rightEdit()) { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_UNAUTHORIZED); $strReturn .= "<message><error>" . xmlSafeString($this->getLang("commons_error_permissions")) . "</error></message>"; return $strReturn; } } else { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_UNAUTHORIZED); $strReturn .= "<message><error>" . xmlSafeString($this->getLang("commons_error_permissions")) . "</error></message>"; return $strReturn; } //Handle the fileupload $arrSource = $this->getParam($this->getParam("inputElement")); $bitJsonResponse = $this->getParam("jsonResponse") != ""; $bitPostData = false; if (is_array($arrSource)) { $strFilename = $arrSource["name"]; } else { $bitPostData = getPostRawData() != ""; $strFilename = $arrSource; } $strTarget = $strFolder . "/" . createFilename($strFilename); $objFilesystem = new class_filesystem(); if (!file_exists(_realpath_ . "/" . $strFolder)) { $objFilesystem->folderCreate($strFolder, true); } if ($objFilesystem->isWritable($strFolder)) { //Check file for correct filters $arrAllowed = explode(",", $objRepo->getStrUploadFilter()); $strSuffix = uniStrtolower(uniSubstr($strFilename, uniStrrpos($strFilename, "."))); if ($objRepo->getStrUploadFilter() == "" || in_array($strSuffix, $arrAllowed)) { if ($bitPostData) { $objFilesystem = new class_filesystem(); $objFilesystem->openFilePointer($strTarget); $bitCopySuccess = $objFilesystem->writeToFile(getPostRawData()); $objFilesystem->closeFilePointer(); } else { $bitCopySuccess = $objFilesystem->copyUpload($strTarget, $arrSource["tmp_name"]); } if ($bitCopySuccess) { if ($bitJsonResponse) { $strReturn = json_encode(array('success' => true)); } else { $strReturn .= "<message>" . $this->getLang("xmlupload_success") . "</message>"; } class_logger::getInstance()->addLogRow("uploaded file " . $strTarget, class_logger::$levelInfo); $objRepo->syncRepo(); } else { if ($bitJsonResponse) { $strReturn .= json_encode(array('error' => $this->getLang("xmlupload_error_copyUpload"))); } else { $strReturn .= "<message><error>" . $this->getLang("xmlupload_error_copyUpload") . "</error></message>"; } } } else { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_BADREQUEST); if ($bitJsonResponse) { $strReturn .= json_encode(array('error' => $this->getLang("xmlupload_error_filter"))); } else { $strReturn .= "<message><error>" . $this->getLang("xmlupload_error_filter") . "</error></message>"; } } } else { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_INTERNAL_SERVER_ERROR); if ($bitJsonResponse) { $strReturn .= json_encode(array('error' => $this->getLang("xmlupload_error_notWritable"))); } else { $strReturn .= "<message><error>" . xmlSafeString($this->getLang("xmlupload_error_notWritable")) . "</error></message>"; } } if ($bitJsonResponse) { //disabled for ie. otherwise the upload won't work due to the headers. class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_HTML); //class_response_object::getInstance()->setStResponseType(class_http_responsetypes::STR_TYPE_JSON); } @unlink($arrSource["tmp_name"]); return $strReturn; }
/** * Will be kept for legacy compatibility * * @param bool $bitJsonResponse * * @return string */ private function doUpload($bitJsonResponse = false) { $strReturn = ""; //prepare the folder to be used as a target-folder for the upload $objFilemanagerRepo = new class_module_mediamanager_repo($this->arrElementData["char2"]); $objDownloadfolder = null; //add a special subfolder? $strPath = $objFilemanagerRepo->getStrPath(); if ($this->getParam("portaluploadDlfolder") != "") { /** @var $objDownloadfolder class_module_mediamanager_file */ $objDownloadfolder = class_objectfactory::getInstance()->getObject($this->getParam("portaluploadDlfolder")); //check if the folder is within the current repo /** @var $objTemp class_module_mediamanager_file */ $objTemp = $objDownloadfolder; while (validateSystemid($objTemp->getSystemid()) && ($objTemp instanceof class_module_mediamanager_file || $objTemp instanceof class_module_mediamanager_repo)) { if ($objTemp->getSystemid() == $this->arrElementData["char2"]) { $strPath = $objDownloadfolder->getStrFilename(); break; } $objTemp = class_objectfactory::getInstance()->getObject($objTemp->getPrevId()); } } //upload the file... if ($objFilemanagerRepo->rightRight1()) { //Handle the fileupload $arrSource = $this->getParam("portaluploadFile"); $strTarget = $strPath . "/" . createFilename($arrSource["name"]); $objFilesystem = new class_filesystem(); if ($objFilesystem->isWritable($strPath)) { //Check file for correct filters $arrAllowed = explode(",", $objFilemanagerRepo->getStrUploadFilter()); $strSuffix = uniStrtolower(uniSubstr($arrSource["name"], uniStrrpos($arrSource["name"], "."))); if ($objFilemanagerRepo->getStrUploadFilter() == "" || in_array($strSuffix, $arrAllowed)) { if ($objFilesystem->copyUpload($strTarget, $arrSource["tmp_name"])) { //upload was successfull. try to sync the downloads-archive. if ($objDownloadfolder != null && $objDownloadfolder instanceof class_module_mediamanager_file) { class_module_mediamanager_file::syncRecursive($objDownloadfolder->getSystemid(), $objDownloadfolder->getStrFilename()); } else { $objFilemanagerRepo->syncRepo(); } $this->flushCompletePagesCache(); if ($bitJsonResponse) { return true; } //reload the site to display the new file if (validateSystemid($this->getParam("portaluploadDlfolder"))) { $this->portalReload(class_link::getLinkPortalHref($this->getPagename(), "", "mediaFolder", "uploadSuccess=1", $this->getParam("portaluploadDlfolder"))); } else { $this->portalReload(class_link::getLinkPortalHref($this->getPagename(), "", "", $this->getAction(), "uploadSuccess=1", $this->getSystemid())); } } else { $strReturn .= $this->uploadForm($this->getLang("portaluploadCopyUploadError")); } } else { @unlink($arrSource["tmp_name"]); $strReturn .= $this->uploadForm($this->getLang("portaluploadFilterError")); } } else { $strReturn .= $this->uploadForm($this->getLang("portaluploadNotWritableError")); } } else { $strReturn .= $this->getLang("commons_error_permissions"); } return $strReturn; }
private function update_465_47() { $strReturn = "Updating 4.6.5 to 4.7...\n"; $strReturn .= "Patching bootstrap.php < 4.7\n"; if (is_file(_realpath_ . "/core/bootstrap.php")) { $objFileystem = new class_filesystem(); if (!$objFileystem->isWritable("/core/bootstrap.php")) { $strReturn .= "Error! /core/bootstrap.php is not writable. Please set up write permissions for the update-procedure.\nAborting update."; return $strReturn; } $objFileystem->fileCopy(class_resourceloader::getInstance()->getCorePathForModule("module_system") . "/module_system/installer/bootstrap.php_47", "/core/bootstrap.php", true); } $strReturn .= "Updating module-versions...\n"; $this->updateModuleVersion($this->objMetadata->getStrTitle(), "4.7"); return $strReturn; }
echo "| DB Importer |\n"; echo "| |\n"; echo "+-------------------------------------------------------------------------------+\n"; if (issetPost("doimport")) { $strFilename = getPost("dumpname"); $objDb = class_carrier::getInstance()->getObjDB(); echo "importing " . $strFilename . "\n"; if ($objDb->importDb($strFilename)) { echo "\n<span style='color: green;font-weight:bold;'>import successfull.</span>\n"; } else { echo "\n<span style='color: red;font-weight:bold;'>import failed!!</span>\n"; } } else { echo "Searching for dumps in dbdumps under: " . _projectpath_ . "\n"; $objFilesystem = new class_filesystem(); if ($objFilesystem->isWritable("/project/dbdumps")) { echo "Searching dbdumps available...\n"; $arrFiles = $objFilesystem->getFilelist(_projectpath_ . "/dbdumps/", array(".zip", ".gz", ".sql")); echo "Found " . count($arrFiles) . " dump(s)\n\n"; echo "<form method='post'>"; echo "Dump to import:\n"; $arrImportfileData = array(); foreach ($arrFiles as $strOneFile) { $strFileInfo = ""; $arrDetails = $objFilesystem->getFileDetails(_projectpath_ . "/dbdumps/" . $strOneFile); $strTimestamp = ""; if (uniStrpos($strOneFile, "_") !== false) { $strTimestamp = uniSubstr($strOneFile, uniStrrpos($strOneFile, "_") + 1, uniStrpos($strOneFile, ".") - uniStrrpos($strOneFile, "_")); } if (uniStrlen($strTimestamp) > 9 && is_numeric($strTimestamp)) { //if the timestamp is the last part of the filename, we can use $strTimestamp