} } } //print_r($matches); /***********************************************************/ /*CHECK IF FILE ALREADY EXISTS*/ $filePath = ""; $filePathBig = ""; $fname = createFilename($title, $sep = "_"); //Create Filename thru Title with "_" Separator $needle = $fname; global $needle; $matches = array_filter($filesArr, 'my_search'); //check if this filename matches with any filename existing in filesArr if (empty($matches)) { $fname = createFilename(trim($title), $sep = "_"); //Create Filename thru Title with "-" Separator $needle = $fname; global $needle; $matches = array_filter($filesArr, 'my_search'); //check if this filename matches with any filename existing in filesArr } if (!empty($matches)) { $filePath = current($matches); $pathArr = explode("/uploads", $filePath); $filePath = "uploads" . $pathArr[1]; $filePathBig = str_replace("/thumb/", "/poster/", $filePath); } else { $filePath = strtolower("uploads/" . date("My") . "/thumb/" . $fname); $filePathBig = str_replace("/thumb/", "/poster/", $filePath); $filePath = "NEW - " . $filePath;
/** * 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; }
/** * @permissions edit * @return string */ protected function actionCopyPack() { $objForm = $this->getPackAdminForm(); $strPackName = $this->getParam("pack_name"); $strPackName = createFilename($strPackName, true); if ($strPackName != "" && is_dir(_realpath_ . _templatepath_ . "/" . $strPackName)) { $objForm->addValidationError("name", $this->getLang("pack_folder_existing")); } if (!$objForm->validateForm()) { return $this->actionNew($objForm); } $objFilesystem = new class_filesystem(); $objFilesystem->folderCreate(_templatepath_ . "/" . $strPackName); $objFilesystem->folderCreate(_templatepath_ . "/" . $strPackName . "/tpl"); $objFilesystem->folderCreate(_templatepath_ . "/" . $strPackName . "/css"); $objFilesystem->folderCreate(_templatepath_ . "/" . $strPackName . "/js"); $arrModules = $this->getParam("pack_modules"); foreach ($arrModules as $strName => $strValue) { if ($strValue != "") { $objFilesystem->folderCopyRecursive(class_resourceloader::getInstance()->getCorePathForModule($strName) . "/" . $strName . "/templates/default", _templatepath_ . "/" . $strPackName); } } class_resourceloader::getInstance()->flushCache(); class_classloader::getInstance()->flushCache(); class_reflection::flushCache(); $this->adminReload(class_link::getLinkAdminHref($this->getArrModule("modul"), "listTemplates")); return ""; }
/** * 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; }
/** * Queries the packagemanager for the resolved target path, so the folder to package will be located at * after installation (or is already located at since it's already installed. * * @return mixed */ public function getStrTargetPath() { $strTarget = $this->objMetadata->getStrTarget(); if ($strTarget == "") { $strTarget = uniStrtolower($this->objMetadata->getStrType() . "_" . createFilename($this->objMetadata->getStrTitle(), true)); } $arrModules = array_flip(class_resourceloader::getInstance()->getArrModules()); if (isset($arrModules[$strTarget])) { return "/" . $arrModules[$strTarget]; } return "/core/" . $strTarget; }
/** * Queries the packagemanager for the resolved target path, so the folder to package will be located at * after installation (or is already located at since it's already installed. * * @return mixed */ public function getStrTargetPath() { $strTarget = $this->objMetadata->getStrTarget(); if ($strTarget == "") { $strTarget = uniStrtolower(createFilename($this->objMetadata->getStrTitle(), true)); } return "/templates/" . $strTarget; }
/** * Generates an excel sheet based on the changelog entries from the given systemid * * @param string $strSystemid * * @since 4.6.6 * @permissions changelog */ protected function actionGenericChangelogExportExcel($strSystemid = "") { // include phpexcel require_once class_resourceloader::getInstance()->getCorePathForModule("module_phpexcel", true) . '/module_phpexcel/system/phpexcel/PHPExcel.php'; $objPHPExcel = new PHPExcel(); // get system id if ($strSystemid == "") { $strSystemid = $this->getSystemid(); } // get data $arrLogEntries = class_module_system_changelog::getLogEntries($strSystemid); // create excel $objPHPExcel->getProperties()->setCreator("Kajona")->setLastModifiedBy(class_carrier::getInstance()->getObjSession()->getUsername())->setTitle($this->getLang("change_report_title"))->setSubject($this->getLang("change_report_title")); $objDataSheet = $objPHPExcel->getActiveSheet(); $objDataSheet->setTitle($this->getLang("change_report_title")); $objDataSheet->setAutoFilter('A1:F' . (count($arrLogEntries) + 1)); // style $arrStyles = $this->getStylesArray(); $objDataSheet->getStyle("A1:F1")->applyFromArray($arrStyles["header_1"]); $objDataSheet->getDefaultColumnDimension()->setWidth(24); // add header $arrHeader = array(); $arrHeader[] = $this->getLang("commons_date"); $arrHeader[] = $this->getLang("change_user"); if ($strSystemid == "") { $arrHeader[] = $this->getLang("change_module"); } if ($strSystemid == "") { $arrHeader[] = $this->getLang("change_record"); } $arrHeader[] = $this->getLang("change_action"); $arrHeader[] = $this->getLang("change_property"); $arrHeader[] = $this->getLang("change_oldvalue"); $arrHeader[] = $this->getLang("change_newvalue"); $intCol = 0; $intRow = 1; foreach ($arrHeader as $strHeader) { $objDataSheet->setCellValueByColumnAndRow($intCol++, $intRow, $strHeader); } $intRow++; // add body $arrData = array(); /** @var $objOneEntry class_changelog_container */ foreach ($arrLogEntries as $objOneEntry) { $arrRowData = array(); /** @var interface_versionable|class_model $objTarget */ $objTarget = $objOneEntry->getObjTarget(); $strOldValue = $objOneEntry->getStrOldValue(); $strNewValue = $objOneEntry->getStrNewValue(); if ($objTarget != null) { $strOldValue = $objTarget->renderVersionValue($objOneEntry->getStrProperty(), $strOldValue); $strNewValue = $objTarget->renderVersionValue($objOneEntry->getStrProperty(), $strNewValue); } $strOldValue = htmlStripTags($strOldValue); $strNewValue = htmlStripTags($strNewValue); $arrRowData[] = PHPExcel_Shared_Date::PHPToExcel($objOneEntry->getObjDate()->getTimeInOldStyle()); $arrRowData[] = $objOneEntry->getStrUsername(); if ($strSystemid == "") { $arrRowData[] = $objTarget != null ? $objTarget->getArrModule("modul") : ""; } if ($strSystemid == "") { $arrRowData[] = $objTarget != null ? $objTarget->getVersionRecordName() . " " . $objOneEntry->getStrSystemid() : ""; } $arrRowData[] = $objTarget != null ? $objTarget->getVersionActionName($objOneEntry->getStrAction()) : ""; $arrRowData[] = $objTarget != null ? $objTarget->getVersionPropertyName($objOneEntry->getStrProperty()) : ""; $arrRowData[] = $strOldValue; $arrRowData[] = $strNewValue; $arrData[] = $arrRowData; } foreach ($arrData as $arrRow) { $intCol = 0; foreach ($arrRow as $strValue) { $objDataSheet->setCellValueByColumnAndRow($intCol++, $intRow, html_entity_decode(strip_tags($strValue), ENT_COMPAT, "UTF-8")); } // format first column as date $objDataSheet->getStyle('A' . $intRow)->getNumberFormat()->setFormatCode('dd.mm.yyyy hh:mm'); $intRow++; } // Set active sheet index to the first sheet, so Excel opens this as the first sheet $objPHPExcel->setActiveSheetIndex(0); header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="' . createFilename($this->getLang("change_report_title") . '.xlsx') . '"'); header('Pragma: private'); header('Cache-control: private, must-revalidate'); //header('Cache-Control : No Store'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); //and pass everything back to the browser $objWriter->save('php://output'); flush(); die; }
function createFilename($dir) { $fn = time() . mt_rand(0, 1000000000); if (file_exists($dir . $fn)) { return createFilename($dir); } else { return $fn; } }