public function switchAction($action, $httpVars, $filesVars)
 {
     if (!isset($this->actions[$action])) {
         return false;
     }
     $repository = ConfService::getRepository();
     if (!$repository->detectStreamWrapper(true)) {
         return false;
     }
     if (!isset($this->pluginConf)) {
         $this->pluginConf = array("GENERATE_THUMBNAIL" => false);
     }
     $streamData = $repository->streamData;
     $destStreamURL = $streamData["protocol"] . "://" . $repository->getId();
     if ($action == "preview_data_proxy") {
         $file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
         if (isset($httpVars["get_thumb"]) && $this->pluginConf["GENERATE_THUMBNAIL"]) {
             require_once INSTALL_PATH . "/plugins/editor.diaporama/PThumb.lib.php";
             $pThumb = new PThumb($this->pluginConf["THUMBNAIL_QUALITY"]);
             if (!$pThumb->isError()) {
                 $pThumb->remote_wrapper = $streamData["classname"];
                 $pThumb->use_cache = $this->pluginConf["USE_THUMBNAIL_CACHE"];
                 $pThumb->cache_dir = $this->pluginConf["THUMBNAIL_CACHE_DIR"];
                 $pThumb->fit_thumbnail($destStreamURL . $file, 200);
                 if ($pThumb->isError()) {
                     print_r($pThumb->error_array);
                     AJXP_Logger::logAction("error", $pThumb->error_array);
                 }
                 //exit(0);
             } else {
                 print_r($pThumb->error_array);
                 AJXP_Logger::logAction("error", $pThumb->error_array);
             }
         } else {
             $filesize = filesize($destStreamURL . $file);
             $fp = fopen($destStreamURL . $file, "r");
             header("Content-Type: " . AJXP_Utils::getImageMimeType(basename($file)) . "; name=\"" . basename($file) . "\"");
             header("Content-Length: " . $filesize);
             header('Cache-Control: public');
             $class = $streamData["classname"];
             $stream = fopen("php://output", "a");
             call_user_func(array($streamData["classname"], "copyFileInStream"), $destStreamURL . $file, $stream);
             fflush($stream);
             fclose($stream);
             //exit(1);
         }
     }
 }
 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("&lt;", "<", $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;
 }
Beispiel #3
0
 public function generateThumbnail($masterFile, $targetFile)
 {
     $size = $this->currentDimension;
     require_once AJXP_INSTALL_PATH . "/plugins/editor.diaporama/PThumb.lib.php";
     $pThumb = new PThumb($this->getFilteredOption("THUMBNAIL_QUALITY"));
     if (!$pThumb->isError()) {
         $pThumb->remote_wrapper = $this->streamData["classname"];
         //$this->logDebug("Will fit thumbnail");
         $sizes = $pThumb->fit_thumbnail($masterFile, $size, -1, 1, true);
         //$this->logDebug("Will print thumbnail");
         $pThumb->print_thumbnail($masterFile, $sizes[0], $sizes[1], false, false, $targetFile);
         //$this->logDebug("Done");
         if ($pThumb->isError()) {
             print_r($pThumb->error_array);
             $this->logError("ImagePreviewer", $pThumb->error_array);
             return false;
         }
     } else {
         print_r($pThumb->error_array);
         $this->logError("ImagePreviewer", $pThumb->error_array);
         return false;
     }
 }
 /**
  * Enrich node metadata
  * @param AJXP_Node $ajxpNode
  */
 public function extractImageMetadata(&$ajxpNode)
 {
     $currentPath = $ajxpNode->getUrl();
     $wrapperClassName = $ajxpNode->wrapperClassName;
     $isImage = AJXP_Utils::is_image($currentPath);
     $ajxpNode->is_image = $isImage;
     if (!$isImage) {
         return;
     }
     $setRemote = false;
     $remoteWrappers = $this->getFilteredOption("META_EXTRACTION_REMOTEWRAPPERS");
     if (is_string($remoteWrappers)) {
         $remoteWrappers = explode(",", $remoteWrappers);
     }
     $remoteThreshold = $this->getFilteredOption("META_EXTRACTION_THRESHOLD");
     if (in_array($wrapperClassName, $remoteWrappers)) {
         if ($remoteThreshold != 0 && isset($ajxpNode->bytesize)) {
             $setRemote = $ajxpNode->bytesize > $remoteThreshold;
         } else {
             $setRemote = true;
         }
     }
     if ($isImage) {
         if ($setRemote) {
             $ajxpNode->image_type = "N/A";
             $ajxpNode->image_width = "N/A";
             $ajxpNode->image_height = "N/A";
             $ajxpNode->readable_dimension = "";
         } else {
             $realFile = $ajxpNode->getRealFile();
             list($width, $height, $type, $attr) = @getimagesize($realFile);
             if ($this->getFilteredOption("EXIF_ROTATION")) {
                 require_once AJXP_INSTALL_PATH . "/plugins/editor.diaporama/PThumb.lib.php";
                 $pThumb = new PThumb($this->getFilteredOption["THUMBNAIL_QUALITY"], $this->getFilteredOption("EXIF_ROTATION"));
                 $orientation = $pThumb->exiforientation($realFile, false);
                 if ($pThumb->rotationsupported($orientation)) {
                     $ajxpNode->image_exif_orientation = $orientation;
                     if ($orientation > 4) {
                         $tmp = $height;
                         $height = $width;
                         $width = $tmp;
                     }
                 }
             }
             $ajxpNode->image_type = image_type_to_mime_type($type);
             $ajxpNode->image_width = $width;
             $ajxpNode->image_height = $height;
             $ajxpNode->readable_dimension = $width . "px X " . $height . "px";
         }
     }
     //$this->logDebug("CURRENT NODE IN EXTRACT IMAGE METADATA ", $ajxpNode);
 }
 public function generateThumbnail($masterFile, $targetFile)
 {
     $size = $this->currentDimension;
     require_once AJXP_INSTALL_PATH . "/plugins/editor.diaporama/PThumb.lib.php";
     $pThumb = new PThumb($this->pluginConf["THUMBNAIL_QUALITY"]);
     if (!$pThumb->isError()) {
         $pThumb->remote_wrapper = $this->streamData["classname"];
         $sizes = $pThumb->fit_thumbnail($masterFile, $size, -1, 1, true);
         $pThumb->print_thumbnail($masterFile, $sizes[0], $sizes[1], false, false, $targetFile);
         if ($pThumb->isError()) {
             print_r($pThumb->error_array);
             AJXP_Logger::logAction("error", $pThumb->error_array);
             return false;
         }
     } else {
         print_r($pThumb->error_array);
         AJXP_Logger::logAction("error", $pThumb->error_array);
         return false;
     }
 }