/**
  * The real "download" or "upload" should be handled right here.
  * All packages have to be downloaded to /project/temp in order to be processed afterwards.
  *
  * @return string the filename of the package downloaded
  */
 public function processPackageUpload()
 {
     //fetch the upload, validate a few settings and copy the package to /project/temp
     $arrSource = class_carrier::getInstance()->getParam("provider_local_file");
     $strTarget = "/project/temp/" . generateSystemid() . ".zip";
     $objFilesystem = new class_filesystem();
     //Check file for correct filters
     $strSuffix = uniStrtolower(uniSubstr($arrSource["name"], uniStrrpos($arrSource["name"], ".")));
     if (in_array($strSuffix, array(".zip"))) {
         if ($objFilesystem->copyUpload($strTarget, $arrSource["tmp_name"])) {
             class_logger::getInstance(class_logger::PACKAGEMANAGEMENT)->addLogRow("uploaded package " . $arrSource["name"] . " to " . $strTarget, class_logger::$levelInfo);
             class_resourceloader::getInstance()->flushCache();
             class_classloader::getInstance()->flushCache();
             class_reflection::flushCache();
             return $strTarget;
         }
     }
     class_logger::getInstance(class_logger::PACKAGEMANAGEMENT)->addLogRow("error in uploaded package " . $arrSource["name"] . " either wrong format or not writeable target folder", class_logger::$levelInfo);
     @unlink($arrSource["tmp_name"]);
     return null;
 }
 /**
  * @see interface_admin_systemtask::getAdminForm()
  * @return string
  */
 public function getAdminForm()
 {
     $strReturn = "";
     //show dropdown to select db-dump
     $objFilesystem = new class_filesystem();
     $arrFiles = $objFilesystem->getFilelist(_projectpath_ . "/dbdumps/", array(".sql", ".gz"));
     $arrOptions = array();
     foreach ($arrFiles as $strOneFile) {
         $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)) {
             $arrOptions[$strOneFile] = $strOneFile . " (" . bytesToString($arrDetails["filesize"]) . ")" . "<br />" . $this->getLang("systemtask_dbimport_datefilename") . " " . timeToString($strTimestamp) . "<br />" . $this->getLang("systemtask_dbimport_datefileinfo") . " " . timeToString($arrDetails['filechange']);
         } else {
             $arrOptions[$strOneFile] = $strOneFile . " (" . bytesToString($arrDetails["filesize"]) . ")" . "<br />" . $this->getLang("systemtask_dbimport_datefileinfo") . " " . timeToString($arrDetails['filechange']);
         }
     }
     $strReturn .= $this->objToolkit->formInputRadiogroup("dbImportFile", $arrOptions, $this->getLang("systemtask_dbimport_file"));
     return $strReturn;
 }
Example #3
0
/**
 * Returns the file extension for a file (including the dot).
 *
 * @param string $strPath
 *
 * @return string
 */
function getFileExtension($strPath)
{
    return uniStrtolower(uniSubstr($strPath, uniStrrpos($strPath, ".")));
}
 /**
  * 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;
 }
 /**
  * @see interface_admin_systemtask::getSubmitParams()
  * @return string
  */
 public function getSubmitParams()
 {
     $arrFile = $this->getParam("pageimport_file");
     $strError = "";
     $objFilesystem = new class_filesystem();
     $strTarget = "/import_" . generateSystemid() . ".xml";
     $strSuffix = uniStrtolower(uniSubstr($arrFile["name"], uniStrrpos($arrFile["name"], ".")));
     if ($strSuffix == ".xml") {
         if ($objFilesystem->copyUpload($strTarget, $arrFile["tmp_name"])) {
             class_logger::getInstance()->addLogRow("uploaded file " . $strTarget, class_logger::$levelInfo);
         } else {
             $strError = "upload";
         }
     } else {
         $strError = "suffix";
     }
     return "&pageimport_file=" . $strTarget . "&pageimport_error=" . $strError . "&pageimport_replace=" . $this->getParam("pageimport_replace");
 }
 /**
  * Prints a file as a detailed-view
  * and generates forward / backward links + a strip of prev / next files
  *
  * @param bool $bitRegisterAdditionalTitle
  * @return string
  */
 protected function actionFileDetails($bitRegisterAdditionalTitle = true)
 {
     if (!$this->checkIfRequestedIdIsInElementsTree()) {
         return $this->actionList();
     }
     $bitIsImage = false;
     //Load record
     $objFile = new class_module_mediamanager_file($this->getSystemid());
     //common fields
     $arrDetailsTemplate = array();
     $arrDetailsTemplate["file_name"] = $objFile->getStrName();
     $arrDetailsTemplate["file_description"] = $objFile->getStrDescription();
     $arrDetailsTemplate["file_subtitle"] = $objFile->getStrSubtitle();
     $arrDetailsTemplate["file_filename"] = $objFile->getStrFilename();
     $arrDetailsTemplate["file_size"] = bytesToString($objFile->getIntFileSize());
     $arrDetailsTemplate["file_hits"] = $objFile->getIntHits();
     $arrDetailsTemplate["file_systemid"] = $objFile->getSystemid();
     $arrDetailsTemplate["file_elementid"] = $this->arrElementData["content_id"];
     $arrDetailsTemplate["file_lmtime"] = timeToString(filemtime(_realpath_ . $objFile->getStrFilename()));
     if (validateSystemid($objFile->getOwnerId())) {
         $objUser = new class_module_user_user($objFile->getOwnerId());
         $arrDetailsTemplate["file_owner"] = $objUser->getStrUsername();
     }
     if ($objFile->rightRight2()) {
         $arrDetailsTemplate["file_link_href"] = _webpath_ . "/download.php?systemid=" . $objFile->getSystemid();
         $arrDetailsTemplate["file_link"] = "<a href=\"" . _webpath_ . "/download.php?systemid=" . $objFile->getSystemid() . "\">" . $this->getLang("download_link") . "</a>";
     }
     //if its an image, provide additional information
     $strSuffix = uniStrtolower(uniSubstr($objFile->getStrFilename(), uniStrrpos($objFile->getStrFilename(), ".")));
     if (in_array($strSuffix, $this->arrImageTypes) && isset($this->arrElementData["gallery_maxh_d"]) && isset($this->arrElementData["gallery_maxw_d"])) {
         $bitIsImage = true;
         $arrDetailsTemplate["image_src"] = $this->getImageUrl($objFile->getStrFilename(), $this->arrElementData["gallery_maxh_d"], $this->arrElementData["gallery_maxw_d"], $this->arrElementData["gallery_text"], $this->arrElementData["gallery_overlay"], $objFile->getSystemid(), $this->arrElementData["content_id"]);
     }
     $arrStripIds = $this->getNextPrevIds();
     $arrDetailsTemplate["backlink"] = $arrStripIds["backward_1"] != "" ? class_link::getLinkPortal($this->getPagename(), "", "", $this->getLang("commons_back"), "fileDetails", "", $arrStripIds["backward_1"]) : "";
     $arrDetailsTemplate["forwardlink"] = $arrStripIds["forward_1"] != "" ? class_link::getLinkPortal($this->getPagename(), "", "", $this->getLang("commons_next"), "fileDetails", "", $arrStripIds["forward_1"]) : "";
     //next /prev 3 files
     for ($intI = 1; $intI <= 3; $intI++) {
         if ($arrStripIds["forward_" . $intI] != "") {
             $objCurFile = new class_module_mediamanager_file($arrStripIds["forward_" . $intI]);
             $arrDetailsTemplate["forwardlink_" . $intI] = $this->renderFileStripEntry($objCurFile);
         }
         if ($arrStripIds["backward_" . $intI] != "") {
             $objCurFile = new class_module_mediamanager_file($arrStripIds["backward_" . $intI]);
             $arrDetailsTemplate["backlink_" . $intI] = $this->renderFileStripEntry($objCurFile);
         }
     }
     //current file
     $arrDetailsTemplate["filestrip_current"] = $this->renderFileStripEntry($objFile);
     $arrDetailsTemplate["overview"] = getLinkPortal($this->getPagename(), "", "", $this->getLang("overview"), "mediaFolder", "", $objFile->getPrevId());
     $arrDetailsTemplate["pathnavigation"] = $this->generatePathnavi(true);
     //ratings available?
     if ($objFile->getFloatRating() !== null) {
         /** @var $objRating class_module_rating_portal */
         $objRating = class_module_system_module::getModuleByName("rating")->getPortalInstanceOfConcreteModule();
         $arrDetailsTemplate["file_rating"] = $objRating->buildRatingBar($objFile->getFloatRating(), $objFile->getIntRatingHits(), $objFile->getSystemid(), $objFile->isRateableByUser(), $objFile->rightRight3());
     }
     $strTemplateID = $this->objTemplate->readTemplate("/module_mediamanager/" . $this->arrElementData["repo_template"], "filedetail");
     $strReturn = $this->fillTemplate($arrDetailsTemplate, $strTemplateID);
     //Add pe code
     $arrPeConfig = array("pe_module" => "mediamanager", "pe_action_edit" => "editFile", "pe_action_edit_params" => "&systemid=" . $objFile->getSystemid());
     $strReturn = class_element_portal::addPortalEditorCode($strReturn, $objFile->getSystemid(), $arrPeConfig);
     //set the name of the current image to the page title via class_pages
     if ($bitRegisterAdditionalTitle) {
         class_module_pages_portal::registerAdditionalTitle($objFile->getStrName());
     }
     //Update view counter
     if ($bitIsImage) {
         $objFile->increaseHits();
     }
     return $this->addPortaleditorCode($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;
 }
 /**
  * Loads all files in a passed folder, as usual relative to the core whereas the single module-folders may be skipped.
  * The array returned is based on [path_to_file] = [filename] where the key is relative to the project-root.
  * If you want to filter the list of files being returned, pass a callback/closure as the 4th argument. The callback is used
  * as defined in array_filter.
  * If you want to apply a custom function on each (filtered) element, use the 5th param to pass a closure. The callback is passed to array_walk,
  * so the same conventions should be applied,
  *
  * @param string $strFolder
  * @param array $arrExtensionFilter
  * @param bool $bitWithSubfolders includes folders into the return set, otherwise only files will be returned
  * @param callable $objFilterFunction
  * @param callable $objWalkFunction
  *
  * @return array
  * @see http://php.net/manual/de/function.array-filter.php
  * @see http://php.net/manual/de/function.array-walk.php
  */
 public function getFolderContent($strFolder, $arrExtensionFilter = array(), $bitWithSubfolders = false, Closure $objFilterFunction = null, Closure $objWalkFunction = null)
 {
     $arrReturn = array();
     $strCachename = md5($strFolder . implode(",", $arrExtensionFilter) . ($bitWithSubfolders ? "sub" : "nosub"));
     if (isset($this->arrFoldercontent[$strCachename])) {
         return $this->applyCallbacks($this->arrFoldercontent[$strCachename], $objFilterFunction, $objWalkFunction);
     }
     $this->bitCacheSaveRequired = true;
     //loop all given modules
     foreach ($this->arrModules as $strCorePath => $strSingleModule) {
         if (is_dir(_realpath_ . "/" . $strCorePath . $strFolder)) {
             $arrContent = scandir(_realpath_ . "/" . $strCorePath . $strFolder);
             foreach ($arrContent as $strSingleEntry) {
                 if ($strSingleEntry != "." && $strSingleEntry != ".." && ($bitWithSubfolders || is_file(_realpath_ . "/" . $strCorePath . $strFolder . "/" . $strSingleEntry))) {
                     //Wanted Type?
                     if (count($arrExtensionFilter) == 0) {
                         $arrReturn["/" . $strCorePath . $strFolder . "/" . $strSingleEntry] = $strSingleEntry;
                     } else {
                         //check, if suffix is in allowed list
                         $strFileSuffix = uniSubstr($strSingleEntry, uniStrrpos($strSingleEntry, "."));
                         if (in_array($strFileSuffix, $arrExtensionFilter)) {
                             $arrReturn["/" . $strCorePath . $strFolder . "/" . $strSingleEntry] = $strSingleEntry;
                         }
                     }
                 }
             }
         }
     }
     //check if the same is available in the projects-folder and overwrite the first hits
     if (is_dir(_realpath_ . _projectpath_ . "/" . $strFolder)) {
         $arrContent = scandir(_realpath_ . _projectpath_ . "/" . $strFolder);
         foreach ($arrContent as $strSingleEntry) {
             //Wanted Type?
             if (count($arrExtensionFilter) == 0) {
                 $strKey = array_search($strSingleEntry, $arrReturn);
                 if ($strKey !== false) {
                     unset($arrReturn[$strKey]);
                 }
                 $arrReturn[_projectpath_ . "/" . $strFolder . "/" . $strSingleEntry] = $strSingleEntry;
             } else {
                 //check, if suffix is in allowed list
                 $strFileSuffix = uniSubstr($strSingleEntry, uniStrrpos($strSingleEntry, "."));
                 if (in_array($strFileSuffix, $arrExtensionFilter)) {
                     $strKey = array_search($strSingleEntry, $arrReturn);
                     if ($strKey !== false) {
                         unset($arrReturn[$strKey]);
                     }
                     $arrReturn[_projectpath_ . "/" . $strFolder . "/" . $strSingleEntry] = $strSingleEntry;
                 }
             }
         }
     }
     $this->arrFoldercontent[$strCachename] = $arrReturn;
     return $this->applyCallbacks($arrReturn, $objFilterFunction, $objWalkFunction);
 }
 /**
  * Generates a view to browse the filesystem directly.
  * By default, the methods takes two params into account: folder and form_element
  *
  * @return string
  * @autoTestable
  */
 protected function actionFolderListFolderview()
 {
     $this->setArrModuleEntry("template", "/folderview.tpl");
     $strReturn = "";
     //param inits
     $strFolder = "/files";
     if ($this->getParam("folder") != "") {
         $strFolder = $this->getParam("folder");
     }
     $arrExcludeFolder = array(0 => ".", 1 => "..");
     $strFormElement = $this->getParam("form_element");
     $objFilesystem = new class_filesystem();
     $arrContent = $objFilesystem->getCompleteList($strFolder, array(), array(), $arrExcludeFolder, true, false);
     $strReturn .= $this->objToolkit->listHeader();
     $strReturn .= $this->objToolkit->genericAdminList(generateSystemid(), $this->getLang("commons_path"), "", $strFolder, 1);
     $strReturn .= $this->objToolkit->listFooter();
     $strReturn .= $this->objToolkit->divider();
     $intCounter = 0;
     //Show Folders
     //Folder to jump one back up
     $arrFolderStart = array("/files");
     $strReturn .= $this->objToolkit->listHeader();
     $bitHit = false;
     if (!in_array($strFolder, $arrFolderStart) && $bitHit == false) {
         $strAction = $this->objToolkit->listButton(class_link::getLinkAdmin($this->getArrModule("modul"), "folderListFolderview", "&folder=" . uniSubstr($strFolder, 0, uniStrrpos($strFolder, "/")) . "&form_element=" . $strFormElement, $this->getLang("commons_one_level_up"), $this->getLang("commons_one_level_up"), "icon_folderActionLevelup"));
         $strReturn .= $this->objToolkit->genericAdminList(generateSystemid(), "..", class_adminskin_helper::getAdminImage("icon_folderOpen"), $strAction, $intCounter++);
     }
     if ($arrContent["nrFolders"] != 0) {
         foreach ($arrContent["folders"] as $strFolderCur) {
             $strAction = $this->objToolkit->listButton(class_link::getLinkAdmin($this->getArrModule("modul"), "folderListFolderview", "&folder=" . $strFolder . "/" . $strFolderCur . "&form_element=" . $strFormElement, $this->getLang("action_open_folder"), $this->getLang("action_open_folder"), "icon_folderActionOpen"));
             $strAction .= $this->objToolkit->listButton("<a href=\"#\" title=\"" . $this->getLang("commons_accept") . "\" rel=\"tooltip\" onclick=\"KAJONA.admin.folderview.selectCallback([['" . $strFormElement . "', '" . $strFolder . "/" . $strFolderCur . "']]);\">" . class_adminskin_helper::getAdminImage("icon_accept"));
             $strReturn .= $this->objToolkit->genericAdminList(generateSystemid(), $strFolderCur, class_adminskin_helper::getAdminImage("icon_folderOpen"), $strAction, $intCounter++);
         }
     }
     if ($bitHit) {
         $strReturn .= $this->objToolkit->listFooter();
     }
     return $strReturn;
 }
Example #10
0
 /**
  * Returns detailed info about a file
  *
  * @param string $strFile
  *
  * @return mixed
  */
 public function getFileDetails($strFile)
 {
     $arrReturn = array();
     if (strpos($strFile, _realpath_) === false) {
         $strFile = _realpath_ . $strFile;
     }
     if (is_file($strFile)) {
         //Filename
         $arrReturn["filename"] = basename($strFile);
         //Type
         $intTemp = uniStrrpos($strFile, ".");
         if ($intTemp !== false) {
             $arrReturn["filetype"] = uniSubstr($strFile, $intTemp);
         } else {
             $arrReturn["filetype"] = $strFile;
         }
         $arrReturn["filetype"] = uniStrtolower($arrReturn["filetype"]);
         //Size
         $arrReturn["filesize"] = filesize($strFile);
         //creatipn
         $arrReturn["filecreation"] = filemtime($strFile);
         //change
         $arrReturn["filechange"] = filectime($strFile);
         //access
         $arrReturn["fileaccess"] = fileatime($strFile);
         //path
         $arrReturn["filepath"] = $strFile;
     }
     return $arrReturn;
 }
Example #11
0
 /**
  * Looks up the MIME-Type fot the passed filename
  *
  * @param string $strFilename
  *
  * @return array[type, suffix, icon]
  */
 public function mimeType($strFilename)
 {
     $arrMime = array();
     $arrMime["doc"] = array("application/msword", "doc", "icon_word");
     $arrMime["xls"] = array("application/msexcel", "xls", "icon_excel");
     $arrMime["bin"] = array("application/octet-stream", "bin", "icon_binary");
     $arrMime["dms"] = array("application/octet-stream", "dms", "icon_binary");
     $arrMime["lha"] = array("application/octet-stream", "lha", "icon_binary");
     $arrMime["lzh"] = array("application/octet-stream", "lzh", "icon_binary");
     $arrMime["exe"] = array("application/octet-stream", "exe", "icon_binary");
     $arrMime["class"] = array("application/octet-stream", "class", "icon_binary");
     $arrMime["so"] = array("application/octet-stream", "so", "icon_binary");
     $arrMime["dll"] = array("application/octet-stream", "dll", "icon_binary");
     $arrMime["dmg"] = array("application/octet-stream", "dmg", "icon_binary");
     $arrMime["oda"] = array("application/oda", "oda", "icon_binary");
     $arrMime["ogg"] = array("application/ogg", "ogg", "icon_binary");
     $arrMime["pdf"] = array("application/pdf", "pdf", "icon_binary");
     $arrMime["ai"] = array("application/postscript", "ai", "icon_binary");
     $arrMime["eps"] = array("application/postscript", "eps", "icon_binary");
     $arrMime["ps"] = array("application/postscript", "ps", "icon_binary");
     $arrMime["rdf"] = array("application/rdf+xml", "rdf", "icon_binary");
     $arrMime["vxml"] = array("application/voicexml+xml", "vxml", "icon_binary");
     $arrMime["vcd"] = array("application/x-cdlink", "vcd", "icon_binary");
     $arrMime["dcr"] = array("application/x-director", "dcr", "icon_binary");
     $arrMime["dir"] = array("application/x-director", "dir", "icon_binary");
     $arrMime["dxr"] = array("application/x-director", "dxr", "icon_binary");
     $arrMime["dvi"] = array("application/x-dvi", "dvi", "icon_binary");
     $arrMime["js"] = array("application/x-javascript", "js", "icon_binary");
     $arrMime["latex"] = array("application/x-latex", "latex", "icon_binary");
     $arrMime["swf"] = array("application/x-shockwave-flash", "swf", "icon_binary");
     $arrMime["sit"] = array("application/x-stuffit", "sit", "icon_binary");
     $arrMime["tar"] = array("application/x-tar", "tar", "icon_binary");
     $arrMime["tcl"] = array("application/x-tcl", "tcl", "icon_binary");
     $arrMime["tex"] = array("application/x-tex", "tex", "icon_binary");
     $arrMime["texinfo"] = array("application/x-texinfo", "texinfo", "icon_binary");
     $arrMime["texi"] = array("application/x-texinfo", "texi", "icon_binary");
     $arrMime["xhtml"] = array("application/xhtml+xml", "xhtml", "icon_binary");
     $arrMime["xht"] = array("application/xhtml+xml", "xht", "icon_binary");
     $arrMime["xslt"] = array("application/xslt+xml", "xslt", "icon_binary");
     $arrMime["xml"] = array("application/xml", "xml", "icon_binary");
     $arrMime["xsl"] = array("application/xml", "xsl", "icon_binary");
     $arrMime["dtd"] = array("application/xml-dtd", "dtd", "icon_binary");
     $arrMime["zip"] = array("application/zip", "zip", "icon_binary");
     $arrMime["mid"] = array("audio/midi", "mid", "icon_sound");
     $arrMime["midi"] = array("audio/midi", "midi", "icon_sound");
     $arrMime["kar"] = array("audio/midi", "kar", "icon_sound");
     $arrMime["mpga"] = array("audio/mpeg", "mpga", "icon_sound");
     $arrMime["mp2"] = array("audio/mpeg", "mp2", "icon_sound");
     $arrMime["mp3"] = array("audio/mpeg", "mp3", "icon_sound");
     $arrMime["aif"] = array("audio/x-aiff", "aif", "icon_sound");
     $arrMime["aiff"] = array("audio/x-aiff", "aiff", "icon_sound");
     $arrMime["aifc"] = array("audio/x-aiff", "aifc", "icon_sound");
     $arrMime["m3u"] = array("audio/x-mpegurl", "m3u", "icon_sound");
     $arrMime["ram"] = array("audio/x-pn-realaudio", "ram", "icon_sound");
     $arrMime["ra"] = array("audio/x-pn-realaudio", "ra", "icon_sound");
     $arrMime["rm"] = array("application/vnd.rn-realmedia", "rm", "icon_sound");
     $arrMime["wav"] = array("audio/x-wav", "wav", "icon_sound");
     $arrMime["bmp"] = array("image/bmp", "bmp", "icon_image");
     $arrMime["cgm"] = array("image/cgm", "cgm", "icon_image");
     $arrMime["gif"] = array("image/gif", "gif", "icon_image");
     $arrMime["ief"] = array("image/ief", "ief", "icon_image");
     $arrMime["jpeg"] = array("image/jpeg", "jpeg", "icon_image");
     $arrMime["jpg"] = array("image/jpeg", "jpg", "icon_image");
     $arrMime["jpe"] = array("image/jpeg", "jpe", "icon_image");
     $arrMime["png"] = array("image/png", "png", "icon_image");
     $arrMime["svg"] = array("image/svg+xml", "svg", "icon_image");
     $arrMime["tiff"] = array("image/tiff", "tiff", "icon_image");
     $arrMime["tif"] = array("image/tiff", "tif", "icon_image");
     $arrMime["djvu"] = array("image/vnd.djvu", "djvu", "icon_image");
     $arrMime["djv"] = array("image/vnd.djvu", "djv", "icon_image");
     $arrMime["wbmp"] = array("image/vnd.wap.wbmp", "wbmp", "icon_image");
     $arrMime["pnm"] = array("image/x-portable-anymap", "pnm", "icon_image");
     $arrMime["pbm"] = array("image/x-portable-bitmap", "pbm", "icon_image");
     $arrMime["pgm"] = array("image/x-portable-graymap", "pgm", "icon_image");
     $arrMime["ppm"] = array("image/x-portable-pixmap", "ppm", "icon_image");
     $arrMime["rgb"] = array("image/x-rgb", "rgb", "icon_image");
     $arrMime["xbm"] = array("image/x-xbitmap", "xbm", "icon_image");
     $arrMime["xpm"] = array("image/x-xpixmap", "xpm", "icon_image");
     $arrMime["xwd"] = array("image/x-xwindowdump", "xwd", "icon_image");
     $arrMime["ics"] = array("text/calendar", "ics", "icon_text");
     $arrMime["ifb"] = array("text/calendar", "ifb", "icon_text");
     $arrMime["css"] = array("text/css", "css", "icon_text");
     $arrMime["html"] = array("text/html", "html", "icon_text");
     $arrMime["htm"] = array("text/html", "htm", "icon_text");
     $arrMime["asc"] = array("text/plain", "asc", "icon_text");
     $arrMime["txt"] = array("text/plain", "txt", "icon_text");
     $arrMime["php"] = array("text/php", "php", "icon_text");
     $arrMime["rtx"] = array("text/richtext", "rtx", "icon_text");
     $arrMime["rtf"] = array("text/rtf", "rtf", "icon_text");
     $arrMime["sgml"] = array("text/sgml", "sgml", "icon_text");
     $arrMime["sgm"] = array("text/sgml", "sgm", "icon_text");
     $arrMime["tsv"] = array("text/tab-separated-values", "tsv", "icon_text");
     $arrMime["wml"] = array("text/vnd.wap.wml", "wml", "icon_text");
     $arrMime["wmls"] = array("text/vnd.wap.wmlscript", "wmls", "icon_text");
     $arrMime["etx"] = array("text/x-setext", "etx", "icon_text");
     $arrMime["mpeg"] = array("video/mpeg", "mpeg", "icon_movie");
     $arrMime["mpg"] = array("video/mpeg", "mpg", "icon_movie");
     $arrMime["mpe"] = array("video/mpeg", "mpe", "icon_movie");
     $arrMime["qt"] = array("video/quicktime", "qt", "icon_movie");
     $arrMime["mov"] = array("video/quicktime", "mov", "icon_movie");
     $arrMime["mxu"] = array("video/vnd.mpegurl", "mxu", "icon_movie");
     $arrMime["m4u"] = array("video/vnd.mpegurl", "m4u", "icon_movie");
     $arrMime["avi"] = array("video/x-msvideo", "avi", "icon_movie");
     $arrMime["movie"] = array("video/x-sgi-movie", "movie", "icon_movie");
     $arrMime["default"] = array("application/octet-stream", "", "icon_binary");
     //Determing the type
     $strType = "";
     if (uniStrpos($strFilename, ".") !== false) {
         $strType = uniSubstr($strFilename, uniStrrpos($strFilename, ".") + 1);
     } else {
         $strType = $strFilename;
     }
     $strType = uniStrtolower($strType);
     //Known Type?
     if (isset($arrMime[$strType])) {
         $arrReturn = $arrMime[$strType];
     } else {
         $arrReturn = $arrMime["default"];
         $arrReturn[1] = $strType;
     }
     return $arrReturn;
 }
Example #12
0
} 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
                $strFileInfo = $strOneFile . " (" . bytesToString($arrDetails['filesize']) . ")" . "\n    Timestamp according to file name: " . timeToString($strTimestamp) . "\n    Timestamp according to file info: " . timeToString($arrDetails['filechange']);
            } else {
                $strFileInfo = $strOneFile . " (" . bytesToString($arrDetails['filesize']) . ")" . "\n    Timestamp according to file info: " . timeToString($arrDetails['filechange']);
            }
            $arrImportfileData[$strOneFile] = $strFileInfo;
        }
        $bitShowButton = false;
        foreach ($arrImportfileData as $strFilename => $strFileInfo) {
            echo "\n<input type='radio' name='dumpname' id='dumpname_" . $strFilename . "' value='{$strFilename}' /><label for='dumpname_" . $strFilename . "'>" . $strFileInfo . "</label>";
            $bitShowButton = true;
        }
        if ($bitShowButton) {
Example #13
0
 /**
  * Saves the current image to the filesystem and sends it to the browser
  *
  * @param int $intJpegQuality
  */
 public function sendImageToBrowser($intJpegQuality = 90)
 {
     //Check, if we already got an image
     if ($this->objImage == null && $this->bitPreload) {
         if (is_file(_realpath_ . $this->strCachepath . $this->strCachename)) {
             $this->preLoadImage($this->strCachepath . $this->strCachename);
         }
         $this->finalLoadImage();
     }
     if (!is_numeric($intJpegQuality) || $intJpegQuality < 0) {
         $intJpegQuality = 90;
     }
     $this->saveImage("", true, $intJpegQuality);
     //and send it to the browser
     if ($this->strCachename != null && $this->strCachename != "") {
         $strType = uniSubstr($this->strCachename, uniStrrpos($this->strCachename, "."));
     } else {
         $strType = $this->strType;
     }
     switch ($strType) {
         case ".jpg":
             class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JPEG);
             break;
         case ".png":
             class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_PNG);
             break;
         case ".gif":
             class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_GIF);
             break;
     }
     //send all mandatory headers
     class_response_object::getInstance()->sendHeaders();
     //stream image directly from the filesystem if available
     if (is_file(_realpath_ . $this->strCachepath . $this->strCachename)) {
         $ptrFile = @fopen(_realpath_ . $this->strCachepath . $this->strCachename, 'rb');
         fpassthru($ptrFile);
         @fclose($ptrFile);
     } else {
         switch ($strType) {
             case ".jpg":
                 imagejpeg($this->objImage, null, $intJpegQuality);
                 break;
             case ".png":
                 imagepng($this->objImage);
                 break;
             case ".gif":
                 imagegif($this->objImage);
                 break;
         }
     }
 }