function switchAction($action, $httpVars, $fileVars) { if (!isset($this->actions[$action])) { return; } $xmlBuffer = ""; foreach ($httpVars as $getName => $getValue) { ${$getName} = Utils::securePath(SystemTextEncoding::magicDequote($getValue)); } $selection = new UserSelection(); $selection->initFromHttpVars($httpVars); if (isset($dir) && $action != "upload") { $safeDir = $dir; $dir = SystemTextEncoding::fromUTF8($dir); } if (isset($dest)) { $dest = SystemTextEncoding::fromUTF8($dest); } $mess = ConfService::getMessages(); $newArgs = RecycleBinManager::filterActions($action, $selection, $dir); foreach ($newArgs as $argName => $argValue) { ${$argName} = $argValue; } // FILTER DIR PAGINATION ANCHOR if (isset($dir) && strstr($dir, "#") !== false) { $parts = explode("#", $dir); $dir = $parts[0]; $page = $parts[1]; } switch ($action) { //------------------------------------ // DOWNLOAD, IMAGE & MP3 PROXYS //------------------------------------ case "download": AJXP_Logger::logAction("Download", array("files" => $selection)); set_error_handler(array("HTMLWriter", "javascriptErrorHandler"), E_ALL & ~E_NOTICE); register_shutdown_function("restore_error_handler"); if ($selection->inZip) { $tmpDir = dirname($selection->getZipPath()) . "/.tmpExtractDownload"; $delDir = $this->getPath() . "/" . $tmpDir; @mkdir($delDir); register_shutdown_function(array($this, "deldir"), $delDir); $this->convertSelectionToTmpFiles($tmpDir, $selection); } $zip = false; if ($selection->isUnique()) { if (is_dir($this->getPath() . "/" . $selection->getUniqueFile())) { $zip = true; $dir .= "/" . basename($selection->getUniqueFile()); } } else { $zip = true; } if ($zip) { // Make a temp zip and send it as download $loggedUser = AuthService::getLoggedUser(); $file = USERS_DIR . "/" . ($loggedUser ? $loggedUser->getId() : "shared") . "/" . time() . "tmpDownload.zip"; $zipFile = $this->makeZip($selection->getFiles(), $file, $dir); if (!$zipFile) { AJXP_Exception::errorToXml("Error while compressing"); } register_shutdown_function("unlink", $file); $localName = (basename($dir) == "" ? "Files" : basename($dir)) . ".zip"; $this->readFile($file, "force-download", $localName, false, false); } else { $this->readFile($this->getPath() . "/" . $selection->getUniqueFile(), "force-download"); } exit(0); break; case "compress": // Make a temp zip and send it as download if (isset($archive_name)) { $localName = SystemTextEncoding::fromUTF8($archive_name); } else { $localName = (basename($dir) == "" ? "Files" : basename($dir)) . ".zip"; } $file = $this->getPath() . "/" . $dir . "/" . $localName; $zipFile = $this->makeZip($selection->getFiles(), $file, $dir); if (!$zipFile) { AJXP_Exception::errorToXml("Error while compressing file {$localName}"); } $reload_current_node = true; $reload_file_list = $localName; break; case "image_proxy": if ($split = UserSelection::detectZip(SystemTextEncoding::fromUTF8($file))) { require_once "server/classes/pclzip.lib.php"; $zip = new PclZip($this->getPath() . $split[0]); $data = $zip->extract(PCLZIP_OPT_BY_NAME, substr($split[1], 1), PCLZIP_OPT_EXTRACT_AS_STRING); header("Content-Type: " . Utils::getImageMimeType(basename($split[1])) . "; name=\"" . basename($split[1]) . "\""); header("Content-Length: " . strlen($data[0]["content"])); header('Cache-Control: public'); print $data[0]["content"]; } else { if (isset($get_thumb) && $get_thumb == "true" && $this->driverConf["GENERATE_THUMBNAIL"]) { require_once "server/classes/PThumb.lib.php"; $pThumb = new PThumb($this->driverConf["THUMBNAIL_QUALITY"]); if (!$pThumb->isError()) { $pThumb->use_cache = $this->driverConf["USE_THUMBNAIL_CACHE"]; $pThumb->cache_dir = $this->driverConf["THUMBNAIL_CACHE_DIR"]; $pThumb->fit_thumbnail($this->getPath() . "/" . SystemTextEncoding::fromUTF8($file), 200); if ($pThumb->isError()) { print_r($pThumb->error_array); } exit(0); } } $this->readFile($this->getPath() . "/" . SystemTextEncoding::fromUTF8($file), "image"); } exit(0); break; case "mp3_proxy": if ($split = UserSelection::detectZip(SystemTextEncoding::fromUTF8($file))) { require_once "server/classes/pclzip.lib.php"; $zip = new PclZip($this->getPath() . $split[0]); $data = $zip->extract(PCLZIP_OPT_BY_NAME, substr($split[1], 1), PCLZIP_OPT_EXTRACT_AS_STRING); header("Content-Type: audio/mp3; name=\"" . basename($split[1]) . "\""); header("Content-Length: " . strlen($data[0]["content"])); print $data[0]["content"]; } else { $this->readFile($this->getPath() . "/" . SystemTextEncoding::fromUTF8($file), "mp3"); } exit(0); break; //------------------------------------ // ONLINE EDIT //------------------------------------ //------------------------------------ // ONLINE EDIT //------------------------------------ case "edit": if (isset($save) && $save == 1 && isset($code)) { // Reload "code" variable directly from POST array, do not "securePath"... $code = $_POST["code"]; AJXP_Logger::logAction("Online Edition", array("file" => SystemTextEncoding::fromUTF8($file))); $code = stripslashes($code); $code = str_replace("<", "<", $code); $fileName = $this->getPath() . SystemTextEncoding::fromUTF8("/{$file}"); if (!is_file($fileName) || !is_writable($fileName)) { header("Content-Type:text/plain"); print !is_writable($fileName) ? "1001" : "1002"; exit(1); } $fp = fopen($fileName, "w"); fputs($fp, $code); fclose($fp); header("Content-Type:text/plain"); print $mess[115]; } else { $this->readFile($this->getPath() . "/" . SystemTextEncoding::fromUTF8($file), "plain"); } exit(0); break; //------------------------------------ // COPY / MOVE //------------------------------------ //------------------------------------ // COPY / MOVE //------------------------------------ case "copy": case "move": if ($selection->isEmpty()) { $errorMessage = $mess[113]; break; } if ($selection->inZip()) { $tmpDir = dirname($selection->getZipPath()) . "/.tmpExtractDownload"; @mkdir($this->getPath() . "/" . $tmpDir); $this->convertSelectionToTmpFiles($tmpDir, $selection); if (is_dir($tmpDir)) { $this->deldir($this->getPath() . "/" . $tmpDir); } } $success = $error = array(); $this->copyOrMove($dest, $selection->getFiles(), $error, $success, $action == "move" ? true : false); if (count($error)) { $errorMessage = join("\n", $error); } else { $logMessage = join("\n", $success); AJXP_Logger::logAction($action == "move" ? "Move" : "Copy", array("files" => $selection, "destination" => $dest)); } $reload_current_node = true; if (isset($dest_node)) { $reload_dest_node = $dest_node; } $reload_file_list = true; break; //------------------------------------ // SUPPRIMER / DELETE //------------------------------------ //------------------------------------ // SUPPRIMER / DELETE //------------------------------------ case "delete": if ($selection->isEmpty()) { $errorMessage = $mess[113]; break; } $logMessages = array(); $errorMessage = $this->delete($selection->getFiles(), $logMessages); if (count($logMessages)) { $logMessage = join("\n", $logMessages); } AJXP_Logger::logAction("Delete", array("files" => $selection)); $reload_current_node = true; $reload_file_list = true; break; //------------------------------------ // RENOMMER / RENAME //------------------------------------ //------------------------------------ // RENOMMER / RENAME //------------------------------------ case "rename": $file = SystemTextEncoding::fromUTF8($file); $filename_new = SystemTextEncoding::fromUTF8($filename_new); $error = $this->rename($file, $filename_new); if ($error != null) { $errorMessage = $error; break; } $logMessage = SystemTextEncoding::toUTF8($file) . " {$mess['41']} " . SystemTextEncoding::toUTF8($filename_new); $reload_current_node = true; $reload_file_list = basename($filename_new); AJXP_Logger::logAction("Rename", array("original" => $file, "new" => $filename_new)); break; //------------------------------------ // CREER UN REPERTOIRE / CREATE DIR //------------------------------------ //------------------------------------ // CREER UN REPERTOIRE / CREATE DIR //------------------------------------ case "mkdir": $messtmp = ""; $dirname = Utils::processFileName(SystemTextEncoding::fromUTF8($dirname)); $error = $this->mkDir($dir, $dirname); if (isset($error)) { $errorMessage = $error; break; } $reload_file_list = $dirname; $messtmp .= "{$mess['38']} " . SystemTextEncoding::toUTF8($dirname) . " {$mess['39']} "; if ($dir == "") { $messtmp .= "/"; } else { $messtmp .= SystemTextEncoding::toUTF8($dir); } $logMessage = $messtmp; $reload_current_node = true; AJXP_Logger::logAction("Create Dir", array("dir" => $dir . "/" . $dirname)); break; //------------------------------------ // CREER UN FICHIER / CREATE FILE //------------------------------------ //------------------------------------ // CREER UN FICHIER / CREATE FILE //------------------------------------ case "mkfile": $messtmp = ""; $filename = Utils::processFileName(SystemTextEncoding::fromUTF8($filename)); $error = $this->createEmptyFile($dir, $filename); if (isset($error)) { $errorMessage = $error; break; } $messtmp .= "{$mess['34']} " . SystemTextEncoding::toUTF8($filename) . " {$mess['39']} "; if ($dir == "") { $messtmp .= "/"; } else { $messtmp .= SystemTextEncoding::toUTF8($dir); } $logMessage = $messtmp; $reload_file_list = $filename; AJXP_Logger::logAction("Create File", array("file" => $dir . "/" . $filename)); break; //------------------------------------ // CHANGE FILE PERMISSION //------------------------------------ //------------------------------------ // CHANGE FILE PERMISSION //------------------------------------ case "chmod": $messtmp = ""; $files = $selection->getFiles(); $changedFiles = array(); foreach ($files as $fileName) { $error = $this->chmod($this->getPath() . $fileName, $chmod_value, $recursive == "on", $recursive == "on" ? $recur_apply_to : "both", $changedFiles); } if (isset($error)) { $errorMessage = $error; break; } //$messtmp.="$mess[34] ".SystemTextEncoding::toUTF8($filename)." $mess[39] "; $logMessage = "Successfully changed permission to " . $chmod_value . " for " . count($changedFiles) . " files or folders"; $reload_file_list = $dir; AJXP_Logger::logAction("Chmod", array("dir" => $dir, "filesCount" => count($changedFiles))); break; //------------------------------------ // UPLOAD //------------------------------------ //------------------------------------ // UPLOAD //------------------------------------ case "upload": $fancyLoader = false; if (isset($fileVars["Filedata"])) { $fancyLoader = true; if ($dir != "") { $dir = "/" . base64_decode($dir); } } if ($dir != "") { $rep_source = "/{$dir}"; } else { $rep_source = ""; } $destination = SystemTextEncoding::fromUTF8($this->getPath() . $rep_source); if (!$this->isWriteable($destination)) { global $_GET; $errorMessage = "{$mess['38']} " . SystemTextEncoding::toUTF8($dir) . " {$mess['99']}."; if ($fancyLoader || isset($_GET["ajxp_sessid"])) { header('HTTP/1.0 412 ' . $errorMessage); die('Error 412 ' . $errorMessage); } else { print "\n if(parent.ajaxplorer.actionBar.multi_selector)parent.ajaxplorer.actionBar.multi_selector.submitNext('" . str_replace("'", "\\'", $errorMessage) . "');"; break; } } $logMessage = ""; foreach ($fileVars as $boxName => $boxData) { if ($boxName != "Filedata" && substr($boxName, 0, 9) != "userfile_") { continue; } if ($boxName == "Filedata") { $fancyLoader = true; } $err = Utils::parseFileDataErrors($boxData, $fancyLoader); if ($err != null) { $errorMessage = $err; break; } $userfile_name = $boxData["name"]; if ($fancyLoader) { $userfile_name = SystemTextEncoding::fromUTF8($userfile_name); } $userfile_name = Utils::processFileName($userfile_name); if (isset($auto_rename)) { $userfile_name = fsDriver::autoRenameForDest($destination, $userfile_name); } if (!move_uploaded_file($boxData["tmp_name"], "{$destination}/" . $userfile_name)) { $errorMessage = ($fancyLoader ? "411 " : "") . "{$mess['33']} " . $userfile_name; break; } $this->changeMode($destination . "/" . $userfile_name); $logMessage .= "{$mess['34']} " . SystemTextEncoding::toUTF8($userfile_name) . " {$mess['35']} {$dir}"; AJXP_Logger::logAction("Upload File", array("file" => SystemTextEncoding::fromUTF8($dir) . "/" . $userfile_name)); } if ($fancyLoader) { if (isset($errorMessage)) { header('HTTP/1.0 ' . $errorMessage); die('Error ' . $errorMessage); } else { header('HTTP/1.0 200 OK'); die("200 OK"); } } else { print "<html><script language=\"javascript\">\n"; if (isset($errorMessage)) { print "\n if(parent.ajaxplorer.actionBar.multi_selector)parent.ajaxplorer.actionBar.multi_selector.submitNext('" . str_replace("'", "\\'", $errorMessage) . "');"; } else { print "\n if(parent.ajaxplorer.actionBar.multi_selector)parent.ajaxplorer.actionBar.multi_selector.submitNext();"; } print "</script></html>"; } exit; break; //------------------------------------ // Public URL //------------------------------------ //------------------------------------ // Public URL //------------------------------------ case "public_url": $file = SystemTextEncoding::fromUTF8($file); $url = $this->makePubliclet($file, $password, $expiration); header("Content-type:text/plain"); echo $url; exit(1); break; //------------------------------------ // XML LISTING //------------------------------------ //------------------------------------ // XML LISTING //------------------------------------ case "ls": if (!isset($dir) || $dir == "/") { $dir = ""; } $searchMode = $fileListMode = $completeMode = false; if (isset($mode)) { if ($mode == "search") { $searchMode = true; } else { if ($mode == "file_list") { $fileListMode = true; } else { if ($mode == "complete") { $completeMode = true; } } } } if (isset($skipZip) && $skipZip == "true") { $skipZip = true; } else { $skipZip = false; } if ($test = UserSelection::detectZip($dir)) { $liste = array(); $zip = $this->zipListing($test[0], $test[1], $liste); AJXP_XMLWriter::header(); $tmpDir = $this->getPath() . dirname($test[0]) . ".tmpZipExtract"; foreach ($liste as $zipEntry) { $atts = array(); if (!$fileListMode && !$zipEntry["folder"]) { continue; } $atts[] = "is_file=\"" . ($zipEntry["folder"] ? "false" : "true") . "\""; $atts[] = "text=\"" . Utils::xmlEntities(basename(SystemTextEncoding::toUTF8($zipEntry["stored_filename"]))) . "\""; $atts[] = "filename=\"" . Utils::xmlEntities(SystemTextEncoding::toUTF8($zipEntry["filename"])) . "\""; if ($fileListMode) { $atts[] = "filesize=\"" . Utils::roundSize($zipEntry["size"]) . "\""; $atts[] = "bytesize=\"" . $zipEntry["size"] . "\""; $atts[] = "ajxp_modiftime=\"" . $zipEntry["mtime"] . "\""; $atts[] = "mimestring=\"" . Utils::mimetype($zipEntry["stored_filename"], "mime", $zipEntry["folder"]) . "\""; $atts[] = "icon=\"" . Utils::mimetype($zipEntry["stored_filename"], "image", $zipEntry["folder"]) . "\""; $is_image = Utils::is_image(basename($zipEntry["stored_filename"])); $atts[] = "is_image=\"" . $is_image . "\""; if ($is_image) { if (!is_dir($tmpDir)) { mkdir($tmpDir); } $currentFile = $tmpDir . "/" . basename($zipEntry["stored_filename"]); $data = $zip->extract(PCLZIP_OPT_BY_NAME, $zipEntry["stored_filename"], PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_PATH, $tmpDir); list($width, $height, $type, $attr) = @getimagesize($currentFile); $atts[] = "image_type=\"" . image_type_to_mime_type($type) . "\""; $atts[] = "image_width=\"{$width}\""; $atts[] = "image_height=\"{$height}\""; unlink($currentFile); } } else { $atts[] = "icon=\"client/images/foldericon.png\""; $atts[] = "openicon=\"client/images/foldericon.png\""; $atts[] = "src=\"content.php?dir=" . urlencode(SystemTextEncoding::toUTF8($zipEntry["filename"])) . "\""; } print "<tree " . join(" ", $atts) . "/>"; } if (is_dir($tmpDir)) { rmdir($tmpDir); } AJXP_XMLWriter::close(); exit(0); } $nom_rep = $this->initName($dir); AJXP_Exception::errorToXml($nom_rep); $threshold = $this->repository->getOption("PAGINATION_THRESHOLD"); if (!isset($threshold) || intval($threshold) == 0) { $threshold = 500; } $limitPerPage = $this->repository->getOption("PAGINATION_NUMBER"); if (!isset($limitPerPage) || intval($limitPerPage) == 0) { $limitPerPage = 200; } if ($fileListMode) { $countFiles = $this->countFiles($nom_rep); if ($countFiles > $threshold) { $offset = 0; $crtPage = 1; if (isset($page)) { $offset = (intval($page) - 1) * $limitPerPage; $crtPage = $page; } $totalPages = floor($countFiles / $limitPerPage) + 1; $reps = $this->listing($nom_rep, false, $offset, $limitPerPage); } else { $reps = $this->listing($nom_rep, $searchMode); } } else { $countFolders = $this->countFiles($nom_rep, true); if ($countFolders > $threshold) { AJXP_XMLWriter::header(); $icon = CLIENT_RESOURCES_FOLDER . "/images/foldericon.png"; $openicon = CLIENT_RESOURCES_FOLDER . "/images/openfoldericon.png"; $attributes = "icon=\"{$icon}\" openicon=\"{$openicon}\""; print "<tree text=\"{$mess['306']} ({$countFolders})...\" {$attributes}></tree>"; AJXP_XMLWriter::close(); exit(1); } $reps = $this->listing($nom_rep, !$searchMode); } //$reps = $result[0]; AJXP_XMLWriter::header(); if (isset($totalPages) && isset($crtPage)) { //print '<columns switchDisplayMode="list" switchGridMode="filelist"/>'; print '<pagination count="' . $countFiles . '" total="' . $totalPages . '" current="' . $crtPage . '"/>'; } foreach ($reps as $repIndex => $repName) { if (preg_match("/\\.zip\$/", $repName) && $skipZip) { continue; } $attributes = ""; if ($searchMode) { if (is_file($nom_rep . "/" . $repIndex)) { $attributes = "is_file=\"true\" icon=\"{$repName}\""; $repName = $repIndex; } } else { if ($fileListMode) { $currentFile = $nom_rep . "/" . $repIndex; $atts = array(); $atts[] = "is_file=\"" . (is_file($currentFile) ? "1" : "0") . "\""; $atts[] = "is_image=\"" . Utils::is_image($currentFile) . "\""; $fGroup = @filegroup($currentFile) || "unknown"; $atts[] = "file_group=\"" . $fGroup . "\""; $fOwner = @fileowner($currentFile) || "unknown"; $atts[] = "file_owner=\"" . $fOwner . "\""; $fPerms = @fileperms($currentFile); if ($fPerms !== false) { $fPerms = substr(decoct($fPerms), is_file($currentFile) ? 2 : 1); } else { $fPerms = '0000'; } $atts[] = "file_perms=\"" . $fPerms . "\""; if (Utils::is_image($currentFile)) { list($width, $height, $type, $attr) = @getimagesize($currentFile); $atts[] = "image_type=\"" . image_type_to_mime_type($type) . "\""; $atts[] = "image_width=\"{$width}\""; $atts[] = "image_height=\"{$height}\""; } $atts[] = "mimestring=\"" . Utils::mimetype($currentFile, "type", is_dir($currentFile)) . "\""; $datemodif = $this->date_modif($currentFile); $atts[] = "ajxp_modiftime=\"" . ($datemodif ? $datemodif : "0") . "\""; $bytesize = @filesize($currentFile) or 0; if ($bytesize < 0) { $bytesize = sprintf("%u", $bytesize); } $atts[] = "filesize=\"" . Utils::roundSize($bytesize) . "\""; $atts[] = "bytesize=\"" . $bytesize . "\""; $atts[] = "filename=\"" . Utils::xmlEntities(SystemTextEncoding::toUTF8($dir . "/" . $repIndex)) . "\""; $atts[] = "icon=\"" . (is_file($currentFile) ? SystemTextEncoding::toUTF8($repName) : (is_dir($currentFile) ? "folder.png" : "mime-empty.png")) . "\""; $attributes = join(" ", $atts); $repName = $repIndex; } else { $folderBaseName = Utils::xmlEntities($repName); $link = SystemTextEncoding::toUTF8(SERVER_ACCESS . "?dir=" . $dir . "/" . $folderBaseName); $link = urlencode($link); $folderFullName = Utils::xmlEntities($dir) . "/" . $folderBaseName; $parentFolderName = $dir; if (!$completeMode) { $icon = CLIENT_RESOURCES_FOLDER . "/images/foldericon.png"; $openicon = CLIENT_RESOURCES_FOLDER . "/images/openfoldericon.png"; if (preg_match("/\\.zip\$/", $repName)) { $icon = $openicon = CLIENT_RESOURCES_FOLDER . "/images/crystal/actions/16/accessories-archiver.png"; } $attributes = "icon=\"{$icon}\" openicon=\"{$openicon}\" filename=\"" . SystemTextEncoding::toUTF8($folderFullName) . "\" src=\"{$link}\""; } } } print "<tree text=\"" . Utils::xmlEntities(SystemTextEncoding::toUTF8($repName)) . "\" {$attributes}>"; print "</tree>"; } // ADD RECYCLE BIN TO THE LIST if ($nom_rep == $this->repository->getOption("PATH") && RecycleBinManager::recycleEnabled() && !$completeMode && !$skipZip) { $recycleBinOption = $this->repository->getOption("RECYCLE_BIN"); if (is_dir($this->repository->getOption("PATH") . "/" . $recycleBinOption)) { $recycleIcon = $this->countFiles($this->repository->getOption("PATH") . "/" . $recycleBinOption, false, true) > 0 ? "trashcan_full.png" : "trashcan.png"; if ($fileListMode) { print "<tree text=\"" . Utils::xmlEntities($mess[122]) . "\" filesize=\"-\" is_file=\"0\" is_recycle=\"1\" mimestring=\"Trashcan\" ajxp_modiftime=\"" . $this->date_modif($this->repository->getOption("PATH") . "/" . $recycleBinOption) . "\" filename=\"/" . $recycleBinOption . "\" icon=\"{$recycleIcon}\"></tree>"; } else { print "<tree text=\"{$mess['122']}\" is_recycle=\"true\" icon=\"" . CLIENT_RESOURCES_FOLDER . "/images/crystal/mimes/16/{$recycleIcon}\" openIcon=\"" . CLIENT_RESOURCES_FOLDER . "/images/crystal/mimes/16/{$recycleIcon}\" filename=\"/" . $recycleBinOption . "\"/>"; } } } AJXP_XMLWriter::close(); exit(1); break; } if (isset($logMessage) || isset($errorMessage)) { $xmlBuffer .= AJXP_XMLWriter::sendMessage(isset($logMessage) ? $logMessage : null, isset($errorMessage) ? $errorMessage : null, false); } if (isset($requireAuth)) { $xmlBuffer .= AJXP_XMLWriter::requireAuth(false); } if (isset($reload_current_node) && $reload_current_node == "true") { $xmlBuffer .= AJXP_XMLWriter::reloadCurrentNode(false); } if (isset($reload_dest_node) && $reload_dest_node != "") { $xmlBuffer .= AJXP_XMLWriter::reloadNode($reload_dest_node, false); } if (isset($reload_file_list)) { $xmlBuffer .= AJXP_XMLWriter::reloadFileList($reload_file_list, false); } return $xmlBuffer; }
function switchAction($action, $httpVars, $fileVars) { if (!isset($this->actions[$action])) { return; } $xmlBuffer = ""; foreach ($httpVars as $getName => $getValue) { ${$getName} = Utils::securePath(SystemTextEncoding::magicDequote($getValue)); } $selection = new UserSelection(); $selection->initFromHttpVars($httpVars); if (isset($dir) && $action != "upload") { $safeDir = $dir; $dir = SystemTextEncoding::fromUTF8($dir); } if (isset($dest)) { $dest = SystemTextEncoding::fromUTF8($dest); } $mess = ConfService::getMessages(); $recycleBinOption = $this->repository->getOption("RECYCLE_BIN"); // FILTER ACTION FOR DELETE if ($recycleBinOption != "" && $action == "delete" && $dir != "/" . $recycleBinOption) { $action = "move"; $dest = "/" . $recycleBinOption; $dest_node = "AJAXPLORER_RECYCLE_NODE"; } // FILTER ACTION FOR RESTORE if ($recycleBinOption != "" && $action == "restore" && $dir == "/" . $recycleBinOption) { $originalRep = RecycleBinManager::getFileOrigin($selection->getUniqueFile()); if ($originalRep != "") { $action = "move"; $dest = $originalRep; } } switch ($action) { //------------------------------------ // DOWNLOAD, IMAGE & MP3 PROXYS //------------------------------------ case "download": AJXP_Logger::logAction("Download", array("files" => $selection)); $zip = false; if ($selection->isUnique()) { if (is_dir($this->getPath() . "/" . $selection->getUniqueFile())) { $zip = true; $dir .= "/" . basename($selection->getUniqueFile()); } } else { $zip = true; } if ($zip) { // Make a temp zip and send it as download $this->downFile($this->makeName($selection->getFiles()), "force-download", "archive.zip"); } else { $this->downFile($this->makeName($selection->getUniqueFile()), "force-download", $selection->getUniqueFile()); } exit(0); break; case "image_proxy": $this->downFile($this->makeName($file), "image", $file); exit(0); break; case "mp3_proxy": $this->downFile($this->makeName($file), "mp3", $file); exit(0); break; //------------------------------------ // ONLINE EDIT //------------------------------------ //------------------------------------ // ONLINE EDIT //------------------------------------ case "edit": if (isset($save) && $save == 1) { AJXP_Logger::logAction("Online Edition", array("file" => SystemTextEncoding::fromUTF8($file))); $code = stripslashes($code); $code = str_replace("<", "<", $code); $this->SSHOperation->setRemoteContent($this->makeName($file), $code); echo $mess[115]; } else { $this->sendFile($this->SSHOperation->getRemoteContent($this->makeName($file)), "plain", $file); } exit(0); break; //------------------------------------ // COPY / MOVE //------------------------------------ //------------------------------------ // COPY / MOVE //------------------------------------ case "copy": case "move": if ($selection->isEmpty()) { $errorMessage = $mess[113]; break; } $result = ""; if ($action == "move") { $result = $this->SSHOperation->moveFile($this->makeName($selection->getFiles()), $this->makeName($dest)); } else { $result = $this->SSHOperation->copyFile($this->makeName($selection->getFiles()), $this->makeName($dest)); } $mess = ConfService::getMessages(); if (strlen($result)) { $errorMessage = $mess[114]; } else { foreach ($selection->getFiles() as $files) { $logMessage .= $mess[34] . " " . SystemTextEncoding::toUTF8(basename($file)) . " " . $mess[$action == "move" ? 74 : 73] . " " . SystemTextEncoding::toUTF8($dest) . "\n"; } AJXP_Logger::logAction($action == "move" ? "Move" : "Copy", array("files" => $selection, "destination" => $dest)); } $reload_current_node = true; if (isset($dest_node)) { $reload_dest_node = $dest_node; } $reload_file_list = true; break; //------------------------------------ // CHANGE FILE PERMISSION //------------------------------------ //------------------------------------ // CHANGE FILE PERMISSION //------------------------------------ case "chmod": $messtmp = ""; $changedFiles = array(); $value = "0" . decoct(octdec(ltrim($chmod_value, "0"))); // On error, the command will fail $result = $this->SSHOperation->chmodFile($this->makeName($selection->getFiles()), $chmod_value); $mess = ConfService::getMessages(); if (strlen($result)) { $errorMessage = $mess[114]; } else { $logMessage = "Successfully changed permission to " . $chmod_value . " for " . count($selection->getFiles()) . " files or folders"; AJXP_Logger::logAction("Chmod", array("dir" => $dir, "filesCount" => count($selection->getFiles()))); $reload_file_list = $dir; } break; //------------------------------------ // SUPPRIMER / DELETE //------------------------------------ //------------------------------------ // SUPPRIMER / DELETE //------------------------------------ case "delete": if ($selection->isEmpty()) { $errorMessage = $mess[113]; break; } $logMessages = array(); $result = $this->SSHOperation->deleteFile($this->makeName($selection->getFiles())); if (strlen($result)) { $mess = ConfService::getMessages(); $errorMessage = $mess[120]; } else { $mess = ConfService::getMessages(); foreach ($selection->getFiles() as $file) { $logMessages[] = "{$mess['34']} " . SystemTextEncoding::toUTF8($file) . " {$mess['44']}."; } $logMessage = join("\n", $logMessages); } AJXP_Logger::logAction("Delete", array("files" => $selection)); $reload_current_node = true; $reload_file_list = true; break; //------------------------------------ // RENOMMER / RENAME //------------------------------------ //------------------------------------ // RENOMMER / RENAME //------------------------------------ case "rename": $filename_new = $dir . "/" . $filename_new; $error = $this->SSHOperation->moveFile($this->makeName($file), $this->makeName($filename_new)); if ($error != null) { $errorMessage = $error; break; } $logMessage = SystemTextEncoding::toUTF8($file) . " {$mess['41']} " . SystemTextEncoding::toUTF8($filename_new); $reload_current_node = true; $reload_file_list = basename($filename_new); AJXP_Logger::logAction("Rename", array("original" => $file, "new" => $filename_new)); break; //------------------------------------ // CREER UN REPERTOIRE / CREATE DIR //------------------------------------ //------------------------------------ // CREER UN REPERTOIRE / CREATE DIR //------------------------------------ case "mkdir": $messtmp = ""; $dirname = Utils::processFileName($dirname); $error = $this->SSHOperation->createRemoteDirectory($this->makeName($dir . "/" . $dirname)); if (isset($error)) { $errorMessage = $error; break; } $reload_file_list = $dirname; $messtmp .= "{$mess['38']} " . SystemTextEncoding::toUTF8($dirname) . " {$mess['39']} "; if ($dir == "") { $messtmp .= "/"; } else { $messtmp .= SystemTextEncoding::toUTF8($dir); } $logMessage = $messtmp; $reload_current_node = true; AJXP_Logger::logAction("Create Dir", array("dir" => $dir . "/" . $dirname)); break; //------------------------------------ // CREER UN FICHIER / CREATE FILE //------------------------------------ //------------------------------------ // CREER UN FICHIER / CREATE FILE //------------------------------------ case "mkfile": $messtmp = ""; $filename = Utils::processFileName($filename); $error = $this->SSHOperation->setRemoteContent($this->makeName($dir . "/" . $filename), ""); if (isset($error)) { $errorMessage = $error; break; } $messtmp .= "{$mess['34']} " . SystemTextEncoding::toUTF8($filename) . " {$mess['39']} "; if ($dir == "") { $messtmp .= "/"; } else { $messtmp .= SystemTextEncoding::toUTF8($dir); } $logMessage = $messtmp; $reload_file_list = $filename; AJXP_Logger::logAction("Create File", array("file" => $dir . "/" . $filename)); break; //------------------------------------ // UPLOAD //------------------------------------ //------------------------------------ // UPLOAD //------------------------------------ case "upload": $fancyLoader = false; if (isset($fileVars["Filedata"])) { $fancyLoader = true; if ($dir != "") { $dir = "/" . base64_decode($dir); } } if ($dir != "") { $rep_source = "/{$dir}"; } else { $rep_source = ""; } $destination = $rep_source; $logMessage = ""; //$fancyLoader = false; foreach ($fileVars as $boxName => $boxData) { if ($boxName != "Filedata" && substr($boxName, 0, 9) != "userfile_") { continue; } if ($boxName == "Filedata") { $fancyLoader = true; } $err = Utils::parseFileDataErrors($boxData, $fancyLoader); if ($err != null) { $errorMessage = $err; break; } $userfile_name = $boxData["name"]; $userfile_name = Utils::processFileName($userfile_name); if (!$this->SSHOperation->uploadFile($boxData["tmp_name"], $this->makeName($destination . "/" . $userfile_name))) { $errorMessage = ($fancyLoader ? "411 " : "") . "{$mess['33']} " . $userfile_name; break; } $logMessage .= "{$mess['34']} " . SystemTextEncoding::toUTF8($userfile_name) . " {$mess['35']} {$dir}"; AJXP_Logger::logAction("Upload File", array("file" => $dir . "/" . $userfile_name)); } if ($fancyLoader) { if (isset($errorMessage)) { header('HTTP/1.0 ' . $errorMessage); die('Error ' . $errorMessage); } else { header('HTTP/1.0 200 OK'); die("200 OK"); } } else { print "<html><script language=\"javascript\">\n"; if (isset($errorMessage)) { print "\n if(parent.ajaxplorer.actionBar.multi_selector)parent.ajaxplorer.actionBar.multi_selector.submitNext('" . str_replace("'", "\\'", $errorMessage) . "');"; } else { print "\n if(parent.ajaxplorer.actionBar.multi_selector)parent.ajaxplorer.actionBar.multi_selector.submitNext();"; } print "</script></html>"; } exit; break; //------------------------------------ // Public URL //------------------------------------ //------------------------------------ // Public URL //------------------------------------ case "public_url": $file = SystemTextEncoding::fromUTF8($file); $url = $this->makePubliclet($file, $password, $expiration); header("Content-type:text/plain"); echo $url; exit(1); break; //------------------------------------ // XML LISTING //------------------------------------ //------------------------------------ // XML LISTING //------------------------------------ case "ls": if (!isset($dir) || $dir == "/") { $dir = ""; } $searchMode = $fileListMode = $completeMode = false; if (isset($mode)) { if ($mode == "search") { $searchMode = true; } else { if ($mode == "file_list") { $fileListMode = true; } else { if ($mode == "complete") { $completeMode = true; } } } } $nom_rep = $dir; AJXP_Exception::errorToXml($nom_rep); $result = $this->SSHOperation->listFilesIn($nom_rep); AJXP_XMLWriter::header(); foreach ($result as $file) { $attributes = ""; $fileName = SystemTextEncoding::toUTF8($file["name"]); $icon = Utils::mimetype($fileName, "image", $file["isDir"] == 1); if ($searchMode) { if ($file["isDir"] == 0) { $attributes = "is_file=\"true\" icon=\"" . SystemTextEncoding::toUTF8($icon) . "\""; } } else { if ($fileListMode) { $atts = array(); $atts[] = "is_file=\"" . (1 - $file["isDir"]) . "\""; $atts[] = "is_image=\"" . Utils::is_image($fileName) . "\""; $atts[] = "mimestring=\"" . Utils::mimetype($fileName, "type", $file["isDir"] == 1) . "\""; $atts[] = "ajxp_modiftime=\"" . $this->dateModif($file["time"]) . "\""; $atts[] = "filesize=\"" . Utils::roundSize($file["size"]) . "\""; $atts[] = "bytesize=\"" . $file["size"] . "\""; $atts[] = "filename=\"" . str_replace("&", "&", $dir . "/" . $fileName) . "\""; $atts[] = "icon=\"" . ($file["isDir"] == 1 ? "folder.png" : SystemTextEncoding::toUTF8($icon)) . "\""; $attributes = join(" ", $atts); } else { if ($file["isDir"] == 1) { $link = SERVER_ACCESS . "?dir=" . $dir . "/" . $fileName; $link = urlencode($link); $folderBaseName = str_replace("&", "&", $fileName); $folderFullName = "{$dir}/" . $folderBaseName; $parentFolderName = $dir; if (!$completeMode) { $icon = CLIENT_RESOURCES_FOLDER . "/images/foldericon.png"; $openicon = CLIENT_RESOURCES_FOLDER . "/images/openfoldericon.png"; if (preg_match("/\\.zip\$/", $file["name"])) { $icon = $openicon = CLIENT_RESOURCES_FOLDER . "/images/crystal/actions/16/accessories-archiver.png"; } $attributes = "icon=\"{$icon}\" openicon=\"{$openicon}\" filename=\"" . $folderFullName . "\" src=\"{$link}\""; } } } } if (strlen($attributes) > 0) { print "<tree text=\"" . str_replace("&", "&", SystemTextEncoding::toUTF8($this->SSHOperation->unescapeFileName($file["name"]))) . "\" {$attributes}>"; print "</tree>"; } } AJXP_XMLWriter::close(); exit(1); break; } if (isset($logMessage) || isset($errorMessage)) { $xmlBuffer .= AJXP_XMLWriter::sendMessage(isset($logMessage) ? $logMessage : null, isset($errorMessage) ? $errorMessage : null, false); } if (isset($requireAuth)) { $xmlBuffer .= AJXP_XMLWriter::requireAuth(false); } if (isset($reload_current_node) && $reload_current_node == "true") { $xmlBuffer .= AJXP_XMLWriter::reloadCurrentNode(false); } if (isset($reload_dest_node) && $reload_dest_node != "") { $xmlBuffer .= AJXP_XMLWriter::reloadNode($reload_dest_node, false); } if (isset($reload_file_list)) { $xmlBuffer .= AJXP_XMLWriter::reloadFileList($reload_file_list, false); } return $xmlBuffer; }
function listingEndElement($parser, $tag) { if ($tag == "ENTRY") { if ($this->crtListingMode == "file_list" || $this->crtListingMode == "search") { if (!$this->crtElement["is_file"]) { $this->crtElement["filesize"] = "-"; } $this->crtElement["mimestring"] = Utils::mimetype($this->crtElement["filename"], "text", !$this->crtElement["is_file"]); $this->crtElement["icon"] = Utils::mimetype($this->crtElement["filename"], "image", !$this->crtElement["is_file"]); $this->crtElement["is_file"] = $this->crtElement["is_file"] ? "1" : "0"; $this->listElements[] = $this->crtElement; } else { if (!$this->crtElement["is_file"]) { $this->crtElement["icon"] = CLIENT_RESOURCES_FOLDER . "/images/foldericon.png"; $this->crtElement["openicon"] = CLIENT_RESOURCES_FOLDER . "/images/openfoldericon.png"; $this->crtElement["src"] = SERVER_ACCESS . "?dir=" . $this->crtPath . "/" . $this->crtElement["text"]; $this->crtElement["parentname"] = $this->crtPath == "/" ? "" : $this->crtPath; $this->crtElement["action"] = "javascript:ajaxplorer.getFoldersTree().clickNode(CURRENT_ID)"; $this->crtElement["is_file"] = $this->crtElement["is_file"] ? "1" : "0"; $this->listElements[] = $this->crtElement; } } } else { if ($tag == "NAME") { $this->crtElement["filename"] = $this->cdataBuffer; $this->crtElement["text"] = basename($this->cdataBuffer); } else { if ($tag == "AUTHOR" && $this->crtListingMode == "file_list") { $this->crtElement["author"] = $this->cdataBuffer; } else { if ($tag == "SIZE" && $this->crtListingMode == "file_list") { $this->crtElement["filesize"] = Utils::roundSize(intval($this->cdataBuffer)); } else { if ($tag == "DATE" && $this->crtListingMode == "file_list") { $date = $this->cdataBuffer; $split = explode("T", $date); $realDate = $split[0]; $split = explode("\\.", $split[1]); $realTime = $split[0]; $this->crtElement["modiftime"] = date("d/m/Y H:i", strtotime($realDate . " " . $realTime)); } } } } } }
function getSize($tablename) { $repo = ConfService::getRepository(); $dbname = $repo->getOption("DB_NAME"); $like = ""; $total = ""; $t = 0; if ($tablename != "") { $like = " like '{$tablename}'"; } $sql = "SHOW TABLE STATUS FROM {$dbname} {$like}"; $result = $this->execQuery($sql); if ($result) { while ($rec = mysql_fetch_array($result)) { $t += $rec['Data_length'] + $rec['Index_length']; } $total = Utils::roundSize($t); } else { $total = "Unknown"; } return $total; }
function switchAction($action, $httpVars, $fileVars) { if (!isset($this->actions[$action])) { return; } $xmlBuffer = ""; foreach ($httpVars as $getName => $getValue) { ${$getName} = Utils::securePath(SystemTextEncoding::magicDequote($getValue)); } $selection = new UserSelection(); $selection->initFromHttpVars($httpVars); if (isset($dir) && $action != "upload") { $safeDir = $dir; $dir = SystemTextEncoding::fromUTF8($dir); } if (isset($dest)) { $dest = SystemTextEncoding::fromUTF8($dest); } $mess = ConfService::getMessages(); if (class_exists("RecycleBinManager")) { $newArgs = RecycleBinManager::filterActions($action, $selection, $dir); foreach ($newArgs as $argName => $argValue) { ${$argName} = $argValue; } } switch ($action) { //------------------------------------ // DOWNLOAD, IMAGE & MP3 PROXYS //------------------------------------ case "download": case "image_proxy": case "mp3_proxy": AJXP_Logger::logAction("Download", array("files" => $selection)); $this->sendRemoteFile($selection->files[0], $action == "download"); exit(0); break; //------------------------------------ // ONLINE EDIT //------------------------------------ //------------------------------------ // ONLINE EDIT //------------------------------------ case "edit": $file_name = basename($file); $this->ftp_get_contents($file); if (isset($save) && $save == 1 && isset($code)) { // Reload "code" variable directly from POST array, do not "securePath"... $code = $_POST["code"]; AJXP_Logger::logAction("Online Edition", array("file" => SystemTextEncoding::fromUTF8($file_name))); $code = stripslashes($code); $code = str_replace("<", "<", $code); $fp = fopen("files/" . SystemTextEncoding::fromUTF8("{$file_name}"), "w"); fputs($fp, $code); fclose($fp); echo $mess[115]; ftp_put($this->connect, $this->secureFtpPath($this->getPath() . $file), "files/" . SystemTextEncoding::fromUTF8($file_name), FTP_BINARY); $this->ftpRemoveFileTmp("files/" . SystemTextEncoding::fromUTF8("{$file_name}")); $reload_current_node = true; } else { $this->readFile("files/" . SystemTextEncoding::fromUTF8($file_name), "plain"); } exit(0); break; //------------------------------------ // COPY / MOVE //------------------------------------ //------------------------------------ // COPY / MOVE //------------------------------------ case "copy": case "move": if ($selection->isEmpty()) { $errorMessage = $mess[113]; break; } $this->copyOrMove($dest, $selection->getFiles(), $error, $success, $action == "move" ? true : false); if (count($error)) { $errorMessage = join("\n", $error); } else { $logMessage = join("\n", $success); } $reload_current_node = true; if (isset($dest_node)) { $reload_dest_node = $dest_node; } $reload_file_list = true; break; //------------------------------------ // SUPPRIMER / DELETE //------------------------------------ //------------------------------------ // SUPPRIMER / DELETE //------------------------------------ case "delete": if ($selection->isEmpty()) { $errorMessage = $mess[113]; break; } $logMessages = array(); $errorMessage = $this->delete($selection->getFiles(), $logMessages, $dir); if (count($logMessages)) { $logMessage = join("\n", $logMessages); } AJXP_Logger::logAction("Delete", array("files" => $selection)); $reload_current_node = true; $reload_file_list = true; break; //------------------------------------ // RENOMMER / RENAME //------------------------------------ //------------------------------------ // RENOMMER / RENAME //------------------------------------ case "rename": $file = SystemTextEncoding::fromUTF8($file); $filename_new = SystemTextEncoding::fromUTF8($filename_new); $error = $this->rename($file, $filename_new); if ($error != null) { $errorMessage = $error; break; } $logMessage = SystemTextEncoding::toUTF8($file) . " {$mess['41']} " . SystemTextEncoding::toUTF8($filename_new); $reload_current_node = true; $reload_file_list = basename($filename_new); AJXP_Logger::logAction("Rename", array("original" => $file, "new" => $filename_new)); break; //------------------------------------ // CREER UN REPERTOIRE / CREATE DIR //------------------------------------ //------------------------------------ // CREER UN REPERTOIRE / CREATE DIR //------------------------------------ case "mkdir": $messtmp = ""; $dirname = Utils::processFileName(SystemTextEncoding::fromUTF8($dirname)); $error = $this->mkDir($dir, $dirname); if (isset($error)) { $errorMessage = $error; break; } $reload_file_list = $dirname; $messtmp .= "{$mess['38']} " . SystemTextEncoding::toUTF8($dirname) . " {$mess['39']} "; if ($dir == "") { $messtmp .= "/"; } else { $messtmp .= SystemTextEncoding::toUTF8($dir); } $logMessage = $messtmp; $reload_current_node = true; AJXP_Logger::logAction("Create Dir", array("dir" => $dir . "/" . $dirname)); break; //------------------------------------ // CREER UN FICHIER / CREATE FILE //------------------------------------ //------------------------------------ // CREER UN FICHIER / CREATE FILE //------------------------------------ case "mkfile": $messtmp = ""; $filename = Utils::processFileName(SystemTextEncoding::fromUTF8($filename)); $error = $this->createEmptyFile($dir, $filename); if (isset($error)) { $errorMessage = $error; break; } $messtmp .= "{$mess['34']} " . SystemTextEncoding::toUTF8($filename) . " {$mess['39']} "; if ($dir == "") { $messtmp .= "/"; } else { $messtmp .= SystemTextEncoding::toUTF8($dir); } $logMessage = $messtmp; $reload_file_list = $filename; AJXP_Logger::logAction("Create File", array("file" => $dir . "/" . $filename)); break; //------------------------------------ // CHANGE FILE PERMISSION //------------------------------------ //------------------------------------ // CHANGE FILE PERMISSION //------------------------------------ case "chmod": $files = $selection->getFiles(); if (@ftp_chmod($this->connect, $chmod_value, $this->getPath() . $files[0]) === false) { $error = "Error chmod"; } if (isset($error)) { $errorMessage = $error; break; } $logMessage = "Successfully changed permission to " . $chmod_value . " for " . $files[0]; $reload_file_list = $dir; AJXP_Logger::logAction("Chmod", array("dir" => $dir, "file" => $files[0])); break; //------------------------------------ // UPLOAD //------------------------------------ //------------------------------------ // UPLOAD //------------------------------------ case "upload": break; //------------------------------------ // Public URL //------------------------------------ //------------------------------------ // Public URL //------------------------------------ case "public_url": $file = SystemTextEncoding::fromUTF8($file); $url = $this->makePubliclet($file, $password, $expiration); header("Content-type:text/plain"); echo $url; exit(1); break; //------------------------------------ // XML LISTING //------------------------------------ //------------------------------------ // XML LISTING //------------------------------------ case "ls": if (!isset($dir) || $dir == "/") { $dir = ""; } $searchMode = $fileListMode = $completeMode = false; if (isset($mode)) { if ($mode == "search") { $searchMode = true; } else { if ($mode == "file_list") { $fileListMode = true; } else { if ($mode == "complete") { $completeMode = true; } } } } if (isset($skipZip) && $skipZip == "true") { $skipZip = true; } else { $skipZip = false; } if ($test = UserSelection::detectZip($dir)) { $liste = array(); $zip = $this->zipListing($test[0], $test[1], $liste); AJXP_XMLWriter::header(); $tmpDir = $this->getPath() . dirname($test[0]) . ".tmpZipExtract"; foreach ($liste as $zipEntry) { $atts = array(); if (!$fileListMode && !$zipEntry["folder"]) { continue; } $atts[] = "is_file=\"" . ($zipEntry["folder"] ? "false" : "true") . "\""; $atts[] = "text=\"" . str_replace("&", "&", basename(SystemTextEncoding::toUTF8($zipEntry["stored_filename"]))) . "\""; $atts[] = "filename=\"" . str_replace("&", "&", SystemTextEncoding::toUTF8($zipEntry["filename"])) . "\""; if ($fileListMode) { $atts[] = "filesize=\"" . Utils::roundSize($zipEntry["size"]) . "\""; $atts[] = "bytesize=\"" . $zipEntry["size"] . "\""; $atts[] = "ajxp_modiftime=\"" . $zipEntry["mtime"] . "\""; $atts[] = "mimestring=\"" . Utils::mimetype($zipEntry["stored_filename"], "mime", $zipEntry["folder"]) . "\""; $atts[] = "icon=\"" . Utils::mimetype($zipEntry["stored_filename"], "image", $zipEntry["folder"]) . "\""; $is_image = Utils::is_image(basename($zipEntry["stored_filename"])); $atts[] = "is_image=\"" . $is_image . "\""; if ($is_image) { if (!is_dir($tmpDir)) { mkdir($tmpDir); } $currentFile = $tmpDir . "/" . basename($zipEntry["stored_filename"]); $data = $zip->extract(PCLZIP_OPT_BY_NAME, $zipEntry["stored_filename"], PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_PATH, $tmpDir); list($width, $height, $type, $attr) = @getimagesize($currentFile); $atts[] = "image_type=\"" . image_type_to_mime_type($type) . "\""; $atts[] = "image_width=\"{$width}\""; $atts[] = "image_height=\"{$height}\""; unlink($currentFile); } } else { $atts[] = "icon=\"client/images/foldericon.png\""; $atts[] = "openicon=\"client/images/foldericon.png\""; $atts[] = "src=\"content.php?dir=" . urlencode(SystemTextEncoding::toUTF8($zipEntry["filename"])) . "\""; } print "<tree " . join(" ", $atts) . "/>"; if (is_dir($tmpDir)) { rmdir($tmpDir); } } AJXP_XMLWriter::close(); exit(0); } $nom_rep = $this->initName($dir); AJXP_Exception::errorToXml($nom_rep); $result = $this->listing($nom_rep, !($searchMode || $fileListMode)); $this->fileListData = $result[0]; $reps = $result[0]; AJXP_XMLWriter::header(); if (!is_array($reps)) { AJXP_XMLWriter::close(); exit(1); } foreach ($reps as $repIndex => $repName) { if (is_string($repName) && (preg_match("/\\.zip\$/", $repName) && $skipZip)) { continue; } $attributes = ""; if ($searchMode) { if (is_file($nom_rep . "/" . $repIndex)) { $attributes = "is_file=\"true\" icon=\"{$repName}\""; $repName = $repIndex; } } else { if ($fileListMode) { $currentFile = $nom_rep . "/" . $repName['name']; $atts = array(); $atts[] = "is_file=\"" . ($repName['isDir'] ? "0" : "1") . "\""; $atts[] = "is_image=\"" . Utils::is_image($currentFile) . "\""; $atts[] = "file_group=\"" . $repName['group'] . "\""; $atts[] = "file_owner=\"" . $repName['owner'] . "\""; $atts[] = "file_perms=\"" . $repName['chmod1'] . "\""; if (Utils::is_image($currentFile)) { list($width, $height, $type, $attr) = $this->getimagesize($currentFile); $atts[] = "image_type=\"" . image_type_to_mime_type($type) . "\""; $atts[] = "image_width=\"{$width}\""; $atts[] = "image_height=\"{$height}\""; } $atts[] = "mimestring=\"" . $repName['type'] . "\""; $datemodif = $repName['modifTime']; $atts[] = "ajxp_modiftime=\"" . ($datemodif ? $datemodif : "0") . "\""; $bytesize = $repName['size'] or 0; if ($bytesize < 0) { $bytesize = sprintf("%u", $bytesize); } $atts[] = "filesize=\"" . Utils::roundSize($bytesize) . "\""; $atts[] = "bytesize=\"" . $bytesize . "\""; $atts[] = "filename=\"" . str_replace("&", "&", SystemTextEncoding::toUTF8($dir . "/" . $repIndex)) . "\""; $atts[] = "icon=\"" . $repName['icon'] . "\""; $attributes = join(" ", $atts); $repName = $repIndex; } else { //Menu treeview repertoire $folderBaseName = str_replace("&", "&", $repName['name']); $link = SystemTextEncoding::toUTF8(SERVER_ACCESS . "?dir=" . $dir . "/" . $folderBaseName); $link = urlencode($link); $folderFullName = str_replace("&", "&", $dir) . "/" . $folderBaseName; $parentFolderName = $dir; $repName = $repIndex; if (!$completeMode) { $icon = CLIENT_RESOURCES_FOLDER . "/images/foldericon.png"; $openicon = CLIENT_RESOURCES_FOLDER . "/images/openfoldericon.png"; if (preg_match("/\\.zip\$/", $repName)) { $icon = $openicon = CLIENT_RESOURCES_FOLDER . "/images/crystal/actions/16/accessories-archiver.png"; } $attributes = "icon=\"{$icon}\" openicon=\"{$openicon}\" filename=\"" . SystemTextEncoding::toUTF8($folderFullName) . "\" src=\"{$link}\""; } } } print "<tree text=\"" . str_replace("&", "&", SystemTextEncoding::toUTF8($repName)) . "\" {$attributes}>"; print "</tree>"; } // ADD RECYCLE BIN TO THE LIST if ($nom_rep == $this->repository->getOption("PATH") && RecycleBinManager::recycleEnabled() && !$completeMode && !$skipZip) { $recycleBinOption = $this->repository->getOption("RECYCLE_BIN"); if ($fileListMode) { print "<tree text=\"" . Utils::xmlEntities($mess[122]) . "\" filesize=\"-\" is_file=\"0\" is_recycle=\"1\" mimestring=\"Trashcan\" ajxp_modiftime=\"\" filename=\"/" . $recycleBinOption . "\" icon=\"trashcan.png\"></tree>"; } else { print "<tree text=\"{$mess['122']}\" is_recycle=\"true\" icon=\"" . CLIENT_RESOURCES_FOLDER . "/images/crystal/mimes/16/trashcan.png\" openIcon=\"" . CLIENT_RESOURCES_FOLDER . "/images/crystal/mimes/16/trashcan.png\" filename=\"/" . $recycleBinOption . "\"/>"; } } AJXP_XMLWriter::close(); exit(1); break; } if (isset($logMessage) || isset($errorMessage)) { $xmlBuffer .= AJXP_XMLWriter::sendMessage(isset($logMessage) ? $logMessage : null, isset($errorMessage) ? $errorMessage : null, false); } if (isset($requireAuth)) { $xmlBuffer .= AJXP_XMLWriter::requireAuth(false); } if (isset($reload_current_node) && $reload_current_node == "true") { $xmlBuffer .= AJXP_XMLWriter::reloadCurrentNode(false); } if (isset($reload_dest_node) && $reload_dest_node != "") { $xmlBuffer .= AJXP_XMLWriter::reloadNode($reload_dest_node, false); } if (isset($reload_file_list)) { $xmlBuffer .= AJXP_XMLWriter::reloadFileList($reload_file_list, false); } return $xmlBuffer; }