コード例 #1
0
 public function preProcess($action, &$httpVars, &$fileVars)
 {
     if (!isset($httpVars["xhr_uploader"])) {
         return false;
     }
     AJXP_Logger::debug("SimpleUpload::preProcess", $httpVars);
     $headersCheck = isset($_SERVER['CONTENT_TYPE'], $_SERVER['CONTENT_LENGTH'], $_SERVER['HTTP_X_FILE_SIZE'], $_SERVER['HTTP_X_FILE_NAME']) && $_SERVER['CONTENT_TYPE'] === 'multipart/form-data' && $_SERVER['CONTENT_LENGTH'] === $_SERVER['HTTP_X_FILE_SIZE'];
     $fileNameH = $_SERVER['HTTP_X_FILE_NAME'];
     $fileSizeH = $_SERVER['HTTP_X_FILE_SIZE'];
     if ($headersCheck) {
         // create the object and assign property
         $fileVars["userfile_0"] = array("input_upload" => true, "name" => SystemTextEncoding::fromUTF8(basename($fileNameH)), "size" => $fileSizeH);
     } else {
         exit("Warning, missing headers!");
     }
 }
コード例 #2
0
 public function preProcess($action, &$httpVars, &$fileVars)
 {
     if (!isset($httpVars["input_stream"]) || isset($httpVars["force_post"])) {
         return false;
     }
     $headersCheck = isset($_SERVER['CONTENT_LENGTH'], $_SERVER['HTTP_X_FILE_NAME']);
     if (isset($_SERVER['HTTP_X_FILE_SIZE'])) {
         if ($_SERVER['CONTENT_LENGTH'] != $_SERVER['HTTP_X_FILE_SIZE']) {
             exit('Warning, wrong headers');
         }
     }
     $fileNameH = $_SERVER['HTTP_X_FILE_NAME'];
     $fileSizeH = $_SERVER['CONTENT_LENGTH'];
     if (dirname($httpVars["dir"]) == "/" && basename($httpVars["dir"]) == $fileNameH) {
         $httpVars["dir"] = "/";
     }
     $this->logDebug("SimpleUpload::preProcess", $httpVars);
     if ($headersCheck) {
         // create the object and assign property
         $fileVars["userfile_0"] = array("input_upload" => true, "name" => SystemTextEncoding::fromUTF8(basename($fileNameH)), "size" => $fileSizeH);
     } else {
         exit("Warning, missing headers!");
     }
 }
コード例 #3
0
 public function preProcess($action, &$httpVars, &$fileVars)
 {
     $repository = ConfService::getRepository();
     $skipDecoding = false;
     if ($repository->detectStreamWrapper(false)) {
         $plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType());
         $streamData = $plugin->detectStreamWrapper(true);
         if ($streamData["protocol"] == "ajxp.ftp" || $streamData["protocol"] == "ajxp.remotefs") {
             AJXP_Logger::debug("Skip decoding");
             $skipDecoding = true;
         }
     }
     if (isset($fileVars["Filedata"])) {
         self::$active = true;
         AJXP_Logger::debug("Dir before base64", $httpVars);
         $httpVars["dir"] = base64_decode(urldecode($httpVars["dir"]));
         if (!$skipDecoding) {
             $fileVars["Filedata"]["name"] = SystemTextEncoding::fromUTF8($fileVars["Filedata"]["name"]);
         }
         $fileVars["userfile_0"] = $fileVars["Filedata"];
         unset($fileVars["Filedata"]);
         AJXP_Logger::debug("Setting FlexProc active");
     }
 }
コード例 #4
0
ファイル: smb.php プロジェクト: rmxcc/pydio-core
 public function client($params, $purl)
 {
     //var_dump($params);
     static $regexp = array('^added interface ip=(.*) bcast=(.*) nmask=(.*)$' => 'skip', 'Anonymous login successful' => 'skip', '^Domain=\\[(.*)\\] OS=\\[(.*)\\] Server=\\[(.*)\\]$' => 'skip', '^\\tSharename[ ]+Type[ ]+Comment$' => 'shares', '^\\t---------[ ]+----[ ]+-------$' => 'skip', '^\\tServer   [ ]+Comment$' => 'servers', '^\\t---------[ ]+-------$' => 'skip', '^\\tWorkgroup[ ]+Master$' => 'workg', '^\\t(.*)[ ]+(Disk|IPC)[ ]+IPC.*$' => 'skip', '^\\tIPC\\\\$(.*)[ ]+IPC' => 'skip', '^\\t(.*)[ ]+(Disk)[ ]+(.*)$' => 'share', '^\\t(.*)[ ]+(Printer)[ ]+(.*)$' => 'skip', '([0-9]+) blocks of size ([0-9]+)\\. ([0-9]+) blocks available' => 'skip', 'Got a positive name query response from ' => 'skip', '^(session setup failed): (.*)$' => 'error', '^(.*): ERRSRV - ERRbadpw' => 'error', '^Error returning browse list: (.*)$' => 'error', '^tree connect failed: (.*)$' => 'error', '^(Connection to .* failed)$' => 'error', '^NT_STATUS_(.*) ' => 'error', '^NT_STATUS_(.*)\\$' => 'error', 'ERRDOS - ERRbadpath \\((.*).\\)' => 'error', 'cd (.*): (.*)$' => 'error', '^cd (.*): NT_STATUS_(.*)' => 'error', '^\\t(.*)$' => 'srvorwg', '^([0-9]+)[ ]+([0-9]+)[ ]+(.*)$' => 'skip', '^Job ([0-9]+) cancelled' => 'skip', '^[ ]+(.*)[ ]+([0-9]+)[ ]+(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[ ](Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[ ]+([0-9]+)[ ]+([0-9]{2}:[0-9]{2}:[0-9]{2})[ ]([0-9]{4})$' => 'files', '^message start: ERRSRV - (ERRmsgoff)' => 'error');
     if (SMB4PHP_AUTHMODE == 'env') {
         putenv("USER={$purl['user']}%{$purl['pass']}");
         $auth = '';
     } else {
         //$purl['pass'] = preg_replace('/@/', '\@', $purl['pass']);
         $auth = $purl['user'] != '' ? ' -U ' . escapeshellarg($purl['user'] . '__SEP__' . $purl['pass']) : '';
         $auth = str_replace("__SEP__", "%", $auth);
         //self::debug($auth);
     }
     if ($purl['domain'] != '') {
         $auth .= ' -W ' . escapeshellarg($purl['domain']);
     }
     $port = $purl['port'] != 139 ? ' -p ' . escapeshellarg($purl['port']) : '';
     $options = '-O ' . escapeshellarg(SMB4PHP_SMBOPTIONS);
     //self::debug($auth);
     self::debug("SMBCLIENT", " -N {$options} {$port} {$options} {$params} 2>/dev/null [auth data]");
     //self::debug("I just ran an smbclient call");
     //$output = popen (SMB4PHP_SMBCLIENT." -N {$options} {$port} {$options} {$params} 2>/dev/null {$auth}", 'r');
     $info = array();
     if (PHP_OS == "WIN32" || PHP_OS == "WINNT" || PHP_OS == "Windows") {
         $params = ConvSmbParameterToWinOs($params);
     }
     $cmd = SMB4PHP_SMBCLIENT . " -N {$options} {$port} {$options} {$params} {$auth}";
     $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "rw"));
     $env = null;
     if (defined('AJXP_LOCALE') && stripos(PHP_OS, "win") === false) {
         $env = array("LC_ALL" => AJXP_LOCALE);
     }
     $process = proc_open($cmd, $descriptorspec, $pipes, null, $env);
     if (is_resource($process)) {
         fclose($pipes[0]);
         $error = stream_get_contents($pipes[2]);
         fclose($pipes[2]);
         if ($error != "") {
             $error = strtolower($error);
             // common error
             if (strstr($error, "command not found") !== false) {
                 fclose($pipes[1]);
                 throw new Exception($error);
             } else {
                 if (strstr($error, "domain") !== false && strstr($error, "os") !== false) {
                     self::debug("Smbclient alternate stream : " . $error);
                 } else {
                     AJXP_Logger::error(__CLASS__, "Smbclient error", $error);
                 }
             }
         }
         $output = $pipes[1];
     }
     if (isset($output) && is_resource($output)) {
         while ($line = fgets($output, 4096)) {
             if (PHP_OS == "WIN32" || PHP_OS == "WINNT" || PHP_OS == "Windows") {
                 $line = SystemTextEncoding::fromUTF8($line);
             }
             list($tag, $regs, $i) = array('skip', array(), array());
             reset($regexp);
             foreach ($regexp as $r => $t) {
                 if (preg_match('/' . $r . '/', $line, $regs)) {
                     $tag = $t;
                     break;
                 }
             }
             switch ($tag) {
                 case 'skip':
                     continue;
                 case 'shares':
                     $mode = 'shares';
                     break;
                 case 'servers':
                     $mode = 'servers';
                     break;
                 case 'workg':
                     $mode = 'workgroups';
                     break;
                 case 'share':
                     list($name, $type) = array(trim(substr($line, 1, 15)), trim(strtolower(substr($line, 17, 10))));
                     $i = $type != 'disk' && preg_match('/^(.*) Disk/', $line, $regs) ? array(trim($regs[1]), 'disk') : array($name, 'disk');
                     break;
                 case 'srvorwg':
                     list($name, $master) = array(strtolower(trim(substr($line, 1, 21))), strtolower(trim(substr($line, 22))));
                     $i = $mode == 'servers' ? array($name, "server") : array($name, "workgroup", $master);
                     break;
                 case 'files':
                     list($attr, $name) = preg_match("/^(.*)[ ]+([D|A|H|S|R]+)\$/", trim($regs[1]), $regs2) ? array(trim($regs2[2]), trim($regs2[1])) : array('', trim($regs[1]));
                     list($his, $im) = array(explode(':', $regs[6]), 1 + strpos("JanFebMarAprMayJunJulAugSepOctNovDec", $regs[4]) / 3);
                     $i = $name != '.' && $name != '..' ? array($name, strpos($attr, 'D') === FALSE ? 'file' : 'folder', 'attr' => $attr, 'size' => intval($regs[2]), 'time' => mktime($his[0], $his[1], $his[2], $im, $regs[5], $regs[7])) : array();
                     break;
                 case 'error':
                     if (strstr($regs[1], "NO_SUCH_FILE") == 0) {
                         return "NOT_FOUND";
                     }
                     trigger_error($regs[1], E_USER_ERROR);
             }
             if ($i) {
                 switch ($i[1]) {
                     case 'file':
                     case 'folder':
                         $info['info'][$i[0]] = $i;
                     case 'disk':
                     case 'server':
                     case 'workgroup':
                         $info[$i[1]][] = $i[0];
                 }
             }
         }
         //pclose($output);
         fclose($output);
     }
     //self::debug(print_r($info, true));
     return $info;
     //return;
 }
コード例 #5
0
 /**
  *
  * Hooked to node.change, this will update the index
  * if $oldNode = null => create node $newNode
  * if $newNode = null => delete node $oldNode
  * Else copy or move oldNode to newNode.
  *
  * @param AJXP_Node $oldNode
  * @param AJXP_Node $newNode
  * @param Boolean $copy
  * @param bool $recursive
  */
 public function updateNodeIndex($oldNode, $newNode = null, $copy = false, $recursive = false)
 {
     if ($oldNode == null) {
         $this->loadIndex($newNode->getRepositoryId(), true, $newNode->getUser());
     } else {
         $this->loadIndex($oldNode->getRepositoryId(), true, $oldNode->getUser());
     }
     if ($oldNode != null && $copy == false) {
         $oldDocId = $this->getIndexedDocumentId($oldNode);
         if ($oldDocId != null) {
             $this->currentType->deleteById($oldDocId);
             $childrenHits = $this->getIndexedChildrenDocuments($newNode);
             if ($childrenHits != null) {
                 $childrenHits = $childrenHits->getResults();
                 foreach ($childrenHits as $hit) {
                     $this->currentType->deleteById($hit->getId());
                 }
             }
         }
     }
     if ($newNode != null) {
         // Make sure it does not already exists anyway
         $newDocId = $this->getIndexedDocumentId($newNode);
         if ($newDocId != null) {
             try {
                 $this->currentType->deleteById($newDocId);
             } catch (Elastica\Exception\NotFoundException $eEx) {
                 $this->logError(__FUNCTION__, "Trying to delete a non existing document");
             }
             $childrenHits = $this->getIndexedChildrenDocuments($newNode);
             if ($childrenHits != null) {
                 $childrenHits = $childrenHits->getResults();
                 foreach ($childrenHits as $hit) {
                     try {
                         $this->currentType->deleteById($hit->getId());
                     } catch (Elastica\Exception\NotFoundException $eEx) {
                         $this->logError(__FUNCTION__, "Trying to delete a non existing document");
                     }
                 }
             }
         }
         $this->createIndexedDocument($newNode);
         if ($recursive && $oldNode == null && is_dir($newNode->getUrl())) {
             $this->recursiveIndexation($newNode->getUrl());
         }
     }
     if ($oldNode != null && $newNode != null && is_dir($newNode->getUrl())) {
         // Copy / Move / Rename
         // Get old node children docs, and update them manually, no need to scan real directory
         $childrenHits = $this->getIndexedChildrenDocuments($oldNode);
         if ($childrenHits != null) {
             $childrenHits = $childrenHits->getResults();
             foreach ($childrenHits as $hit) {
                 $oldChildURL = $this->currentType->getDocument($hit->getId())->get("node_url");
                 if ($copy == false) {
                     $this->currentType->deleteById($hit->getId());
                 }
                 $newChildURL = str_replace(SystemTextEncoding::toUTF8($oldNode->getUrl()), SystemTextEncoding::toUTF8($newNode->getUrl()), $oldChildURL);
                 $newChildURL = SystemTextEncoding::fromUTF8($newChildURL);
                 $this->createIndexedDocument(new AJXP_Node($newChildURL));
             }
         }
     }
 }
コード例 #6
0
 function renameAction($actionName, $httpVars)
 {
     $filePath = SystemTextEncoding::fromUTF8($httpVars["file"]);
     $newFilename = SystemTextEncoding::fromUTF8($httpVars["filename_new"]);
     return $this->rename($filePath, $newFilename);
 }
コード例 #7
0
ファイル: content.php プロジェクト: projectesIF/Ateneu
}
foreach ($_POST as $getName => $getValue) {
    ${$getName} = Utils::securePath($getValue);
}
$selection = new UserSelection();
$selection->initFromHttpVars();
if (isset($action) || isset($get_action)) {
    $action = isset($get_action) ? $get_action : $action;
} else {
    $action = "";
}
if (isset($dir) && $action != "upload") {
    $dir = SystemTextEncoding::fromUTF8($dir);
}
if (isset($dest)) {
    $dest = SystemTextEncoding::fromUTF8($dest);
}
//------------------------------------------------------------
// SPECIAL HANDLING FOR FANCY UPLOADER RIGHTS FOR THIS ACTION
//------------------------------------------------------------
if (AuthService::usersEnabled()) {
    $loggedUser = AuthService::getLoggedUser();
    if ($action == "upload" && ($loggedUser == null || !$loggedUser->canWrite(ConfService::getCurrentRootDirIndex() . "")) && isset($_FILES['Filedata'])) {
        header('HTTP/1.0 ' . '410 Not authorized');
        die('Error 410 Not authorized!');
    }
}
// Look for the action in the "fixed" drivers : AjxpClient, Auth & Conf
$ajxpDriver = new AJXP_ClientDriver(ConfService::getRepository());
$ajxpDriver->applyIfExistsAndExit($action, array_merge($_GET, $_POST), $_FILES);
$authDriver = ConfService::getAuthDriverImpl();
コード例 #8
0
 public function switchAction($action, $httpVars, $filesVars)
 {
     $repository = ConfService::getRepository();
     if (!$repository->detectStreamWrapper(true)) {
         return false;
     }
     $selection = new UserSelection($repository, $httpVars);
     $selectedNode = $selection->getUniqueNode();
     $selectedNodeUrl = $selectedNode->getUrl();
     if ($action == "post_to_server") {
         // Backward compat
         if (strpos($httpVars["file"], "base64encoded:") !== 0) {
             $legacyFilePath = AJXP_Utils::decodeSecureMagic(base64_decode($httpVars["file"]));
             $selectedNode = new AJXP_Node($selection->currentBaseUrl() . $legacyFilePath);
             $selectedNodeUrl = $selectedNode->getUrl();
         }
         $target = rtrim(base64_decode($httpVars["parent_url"]), '/') . "/plugins/editor.pixlr";
         $tmp = AJXP_MetaStreamWrapper::getRealFSReference($selectedNodeUrl);
         $tmp = SystemTextEncoding::fromUTF8($tmp);
         $this->logInfo('Preview', 'Sending content of ' . $selectedNodeUrl . ' to Pixlr server.', array("files" => $selectedNodeUrl));
         AJXP_Controller::applyHook("node.read", array($selectedNode));
         $saveTarget = $target . "/fake_save_pixlr.php";
         if ($this->getFilteredOption("CHECK_SECURITY_TOKEN", $repository->getId())) {
             $saveTarget = $target . "/fake_save_pixlr_" . md5($httpVars["secure_token"]) . ".php";
         }
         $params = array("referrer" => "Pydio", "method" => "get", "loc" => ConfService::getLanguage(), "target" => $saveTarget, "exit" => $target . "/fake_close_pixlr.php", "title" => urlencode(basename($selectedNodeUrl)), "locktarget" => "false", "locktitle" => "true", "locktype" => "source");
         require_once AJXP_BIN_FOLDER . "/http_class/http_class.php";
         $arguments = array();
         $httpClient = new http_class();
         $httpClient->request_method = "POST";
         $httpClient->GetRequestArguments("https://pixlr.com/editor/", $arguments);
         $arguments["PostValues"] = $params;
         $arguments["PostFiles"] = array("image" => array("FileName" => $tmp, "Content-Type" => "automatic/name"));
         $err = $httpClient->Open($arguments);
         if (empty($err)) {
             $err = $httpClient->SendRequest($arguments);
             if (empty($err)) {
                 $response = "";
                 while (true) {
                     $header = array();
                     $error = $httpClient->ReadReplyHeaders($header, 1000);
                     if ($error != "" || $header != null) {
                         break;
                     }
                     $response .= $header;
                 }
             }
         }
         header("Location: {$header['location']}");
         //$response");
     } else {
         if ($action == "retrieve_pixlr_image") {
             $file = AJXP_Utils::decodeSecureMagic($httpVars["original_file"]);
             $selectedNode = new AJXP_Node($selection->currentBaseUrl() . $file);
             $selectedNode->loadNodeInfo();
             $this->logInfo('Edit', 'Retrieving content of ' . $file . ' from Pixlr server.', array("files" => $file));
             AJXP_Controller::applyHook("node.before_change", array(&$selectedNode));
             $url = $httpVars["new_url"];
             $urlParts = parse_url($url);
             $query = $urlParts["query"];
             if ($this->getFilteredOption("CHECK_SECURITY_TOKEN", $repository->getId())) {
                 $scriptName = basename($urlParts["path"]);
                 $token = str_replace(array("fake_save_pixlr_", ".php"), "", $scriptName);
                 if ($token != md5($httpVars["secure_token"])) {
                     throw new AJXP_Exception("Invalid Token, this could mean some security problem!");
                 }
             }
             $params = array();
             parse_str($query, $params);
             $image = $params['image'];
             $headers = get_headers($image, 1);
             $content_type = explode("/", $headers['Content-Type']);
             if ($content_type[0] != "image") {
                 throw new AJXP_Exception("Invalid File Type");
             }
             $content_length = intval($headers["Content-Length"]);
             if ($content_length != 0) {
                 AJXP_Controller::applyHook("node.before_change", array(&$selectedNode, $content_length));
             }
             $orig = fopen($image, "r");
             $target = fopen($selectedNode->getUrl(), "w");
             if (is_resource($orig) && is_resource($target)) {
                 while (!feof($orig)) {
                     fwrite($target, fread($orig, 4096));
                 }
                 fclose($orig);
                 fclose($target);
             }
             clearstatcache(true, $selectedNode->getUrl());
             $selectedNode->loadNodeInfo(true);
             AJXP_Controller::applyHook("node.change", array(&$selectedNode, &$selectedNode));
         }
     }
 }
コード例 #9
0
 public function extractExif($actionName, $httpVars, $fileVars)
 {
     $userSelection = new UserSelection();
     $userSelection->initFromHttpVars($httpVars);
     $repo = ConfService::getRepository();
     $repo->detectStreamWrapper();
     $wrapperData = $repo->streamData;
     $urlBase = $wrapperData["protocol"] . "://" . $repo->getId();
     $realFile = call_user_func(array($wrapperData["classname"], "getRealFSReference"), $urlBase . SystemTextEncoding::fromUTF8($httpVars["file"]));
     ini_set('exif.encode_unicode', 'UTF-8');
     $exifData = exif_read_data($realFile, 0, TRUE);
     if ($exifData !== false && isset($exifData["GPS"])) {
         $exifData["COMPUTED_GPS"] = $this->convertGPSData($exifData);
     }
     $excludeTags = array("componentsconfiguration", "filesource", "scenetype", "makernote");
     AJXP_XMLWriter::header("metadata", array("file" => $httpVars["file"], "type" => "EXIF"));
     foreach ($exifData as $section => $data) {
         print "<exifSection name='{$section}'>";
         foreach ($data as $key => $value) {
             if (in_array(strtolower($key), $excludeTags)) {
                 continue;
             }
             if (!is_numeric($value)) {
                 $value = $this->string_format($value);
             }
             print "<exifTag name=\"{$key}\">" . $value . "</exifTag>";
         }
         print "</exifSection>";
     }
     AJXP_XMLWriter::close("metadata");
 }
コード例 #10
0
 function crossRepositoryCopy($httpVars)
 {
     ConfService::detectRepositoryStreams(true);
     $mess = ConfService::getMessages();
     $selection = new UserSelection();
     $selection->initFromHttpVars($httpVars);
     $files = $selection->getFiles();
     $accessType = $this->repository->getAccessType();
     $repositoryId = $this->repository->getId();
     $origStreamURL = "ajxp.{$accessType}://{$repositoryId}";
     $destRepoId = $httpVars["dest_repository_id"];
     $destRepoObject = ConfService::getRepositoryById($destRepoId);
     $destRepoAccess = $destRepoObject->getAccessType();
     $destStreamURL = "ajxp.{$destRepoAccess}://{$destRepoId}";
     // Check rights
     if (AuthService::usersEnabled()) {
         $loggedUser = AuthService::getLoggedUser();
         if (!$loggedUser->canRead($repositoryId) || !$loggedUser->canWrite($destRepoId) || isset($httpVars["moving_files"]) && !$loggedUser->canWrite($repositoryId)) {
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage(null, $mess[364]);
             AJXP_XMLWriter::close();
             exit(1);
         }
     }
     $messages = array();
     foreach ($files as $file) {
         $origFile = $origStreamURL . $file;
         $destFile = $destStreamURL . SystemTextEncoding::fromUTF8($httpVars["dest"]) . "/" . basename($file);
         $origHandler = fopen($origFile, "r");
         $destHandler = fopen($destFile, "w");
         if ($origHandler === false || $destHandler === false) {
             $errorMessages[] = AJXP_XMLWriter::sendMessage(null, $mess[114] . " ({$origFile} to {$destFile})", false);
             continue;
         }
         while (!feof($origHandler)) {
             fwrite($destHandler, fread($origHandler, 4096));
         }
         fflush($destHandler);
         fclose($origHandler);
         fclose($destHandler);
         $messages[] = $mess[34] . " " . SystemTextEncoding::toUTF8(basename($origFile)) . " " . (isset($httpVars["moving_files"]) ? $mess[74] : $mess[73]) . " " . SystemTextEncoding::toUTF8($destFile);
     }
     AJXP_XMLWriter::header();
     if (count($errorMessages)) {
         AJXP_XMLWriter::sendMessage(null, join("\n", $errorMessages), true);
     }
     AJXP_XMLWriter::sendMessage(join("\n", $messages), null, true);
     AJXP_XMLWriter::close();
     exit(0);
 }
コード例 #11
0
 public function switchAction($action, $httpVars, $fileVars)
 {
     $repo = ConfService::getRepository();
     if (!isset($this->actions[$action])) {
         return;
     }
     parent::accessPreprocess($action, $httpVars, $fileVars);
     $xmlBuffer = "";
     foreach ($httpVars as $getName => $getValue) {
         ${$getName} = AJXP_Utils::securePath($getValue);
     }
     $selection = new UserSelection();
     $selection->initFromHttpVars($httpVars);
     if (isset($dir) && $action != "upload") {
         $safeDir = $dir;
         $dir = SystemTextEncoding::fromUTF8($dir);
     }
     // FILTER DIR PAGINATION ANCHOR
     if (isset($dir) && strstr($dir, "%23") !== false) {
         $parts = explode("%23", $dir);
         $dir = $parts[0];
         $page = $parts[1];
     }
     if (isset($dest)) {
         $dest = SystemTextEncoding::fromUTF8($dest);
     }
     $mess = ConfService::getMessages();
     switch ($action) {
         //------------------------------------
         //	ONLINE EDIT
         //------------------------------------
         case "edit_record":
             $isNew = false;
             if (isset($record_is_new) && $record_is_new == "true") {
                 $isNew = true;
             }
             $tableName = $_POST["table_name"];
             $pkName = $_POST["pk_name"];
             $query = "";
             $arrValues = array();
             foreach ($_POST as $key => $value) {
                 if (substr($key, 0, strlen("ajxp_mysql_")) == "ajxp_mysql_") {
                     $newKey = substr($key, strlen("ajxp_mysql_"));
                     $arrValues[$newKey] = $value;
                 }
             }
             if ($isNew) {
                 $string = "";
                 $index = 0;
                 foreach ($arrValues as $k => $v) {
                     // CHECK IF AUTO KEY!!!
                     $string .= "'" . addslashes(SystemTextEncoding::fromUTF8($v)) . "'";
                     if ($index < count($arrValues) - 1) {
                         $string .= ",";
                     }
                     $index++;
                 }
                 $query = "INSERT INTO {$tableName} VALUES ({$string})";
             } else {
                 $string = "";
                 $index = 0;
                 foreach ($arrValues as $k => $v) {
                     if ($k == $pkName) {
                         $pkValue = $v;
                     } else {
                         $string .= $k . "='" . addslashes(SystemTextEncoding::fromUTF8($v)) . "'";
                         if ($index < count($arrValues) - 1) {
                             $string .= ",";
                         }
                     }
                     $index++;
                 }
                 $query = "UPDATE {$tableName} SET {$string} WHERE {$pkName}='{$pkValue}'";
             }
             $link = $this->createDbLink();
             $res = $this->execQuery($query);
             $this->closeDbLink($link);
             if (is_a($res, "AJXP_Exception")) {
                 $errorMessage = $res->messageId;
             } else {
                 $logMessage = $query;
                 $reload_file_list = true;
             }
             break;
             //------------------------------------
             //	CHANGE COLUMNS OR CREATE TABLE
             //------------------------------------
         //------------------------------------
         //	CHANGE COLUMNS OR CREATE TABLE
         //------------------------------------
         case "edit_table":
             $link = $this->createDbLink();
             if (isset($httpVars["current_table"])) {
                 if (isset($httpVars["delete_column"])) {
                     $query = "ALTER TABLE " . $httpVars["current_table"] . " DROP COLUMN " . $httpVars["delete_column"];
                     $res = $this->execQuery($query);
                     if (is_a($res, "AJXP_Exception")) {
                         $errorMessage = $res->messageId;
                     } else {
                         $logMessage = $query;
                         $reload_file_list = true;
                     }
                     $this->closeDbLink($link);
                     break;
                 }
                 if (isset($httpVars["add_column"])) {
                     $defString = $this->makeColumnDef($httpVars, "add_field_");
                     $query = "ALTER TABLE " . $httpVars["current_table"] . " ADD COLUMN ({$defString})";
                     if (isset($httpVars["add_field_pk"]) && $httpVars["add_field_pk"] == "1") {
                         $query .= ", ADD PRIMARY KEY (" . $httpVars["add_field_name"] . ")";
                     }
                     if (isset($httpVars["add_field_index"]) && $httpVars["add_field_index"] == "1") {
                         $query .= ", ADD INDEX (" . $httpVars["add_field_name"] . ")";
                     }
                     if (isset($httpVars["add_field_uniq"]) && $httpVars["add_field_uniq"] == "1") {
                         $query .= ", ADD UNIQUE (" . $httpVars["add_field_name"] . ")";
                     }
                     $res = $this->execQuery($query);
                     if (is_a($res, "AJXP_Exception")) {
                         $errorMessage = $res->messageId;
                     } else {
                         $logMessage = $query;
                         $reload_file_list = true;
                     }
                     $this->closeDbLink($link);
                     break;
                 }
             }
             $fields = array("origname", "name", "default", "null", "size", "type", "flags", "pk", "index", "uniq");
             $rows = array();
             foreach ($httpVars as $k => $val) {
                 $split = explode("_", $k);
                 if (count($split) == 3 && $split[0] == "field" && is_numeric($split[2]) && in_array($split[1], $fields)) {
                     if (!isset($rows[intval($split[2])])) {
                         $rows[intval($split[2])] = array();
                     }
                     $rows[intval($split[2])][$split[1]] = $val;
                 } else {
                     if (count($split) == 2 && $split[0] == "field" && in_array($split[1], $fields)) {
                         if (!isset($rows[0])) {
                             $rows[0] = array();
                         }
                         $rows[0][$split[1]] = $val;
                     }
                 }
             }
             if (isset($current_table)) {
                 $qMessage = '';
                 foreach ($rows as $row) {
                     $sizeString = $row["size"] != "" ? "(" . $row["size"] . ")" : "";
                     $defString = $row["default"] != "" ? " DEFAULT " . $row["default"] . "" : "";
                     $query = "ALTER TABLE {$current_table} CHANGE " . $row["origname"] . " " . $row["name"] . " " . $row["type"] . $sizeString . $defString . " " . $row["null"];
                     $res = $this->execQuery(trim($query));
                     if (is_a($res, "AJXP_Exception")) {
                         $errorMessage = $res->messageId;
                         $this->closeDbLink($link);
                         break;
                     } else {
                         $qMessage .= $query;
                         $reload_file_list = true;
                     }
                 }
                 $logMessage = $qMessage;
             } else {
                 if (isset($new_table)) {
                     $fieldsDef = array();
                     $pks = array();
                     $indexes = array();
                     $uniqs = array();
                     foreach ($rows as $index => $row) {
                         $fieldsDef[] = $this->makeColumnDef($row);
                         // Analyse keys
                         if ($row["pk"] == "1") {
                             $pks[] = $row["name"];
                         }
                         if ($row["index"] == "1") {
                             $indexes[] = $row["name"];
                         }
                         if ($row["uniq"] == "1") {
                             $uniqs[] = $row["name"];
                         }
                     }
                     $fieldsDef = implode(",", $fieldsDef);
                     if (count($pks)) {
                         $fieldsDef .= ",PRIMARY KEY (" . implode(",", $pks) . ")";
                     }
                     if (count($indexes)) {
                         $fieldsDef .= ",INDEX (" . implode(",", $indexes) . ")";
                     }
                     if (count($uniqs)) {
                         $fieldsDef .= ",UNIQUE (" . implode(",", $uniqs) . ")";
                     }
                     $query = "CREATE TABLE {$new_table} ({$fieldsDef})";
                     $res = $this->execQuery(trim($query));
                     if (is_a($res, "AJXP_Exception")) {
                         $errorMessage = $res->messageId;
                     } else {
                         $logMessage = $query;
                         $reload_file_list = true;
                         $reload_current_node = true;
                     }
                 }
             }
             $this->closeDbLink($link);
             break;
             //------------------------------------
             //	SUPPRIMER / DELETE
             //------------------------------------
         //------------------------------------
         //	SUPPRIMER / DELETE
         //------------------------------------
         case "delete_table":
         case "delete_record":
             $dir = basename($dir);
             $link = $this->createDbLink();
             if (trim($dir) == "") {
                 // ROOT NODE => DROP TABLES
                 $tables = $selection->getFiles();
                 $query = "DROP TABLE";
                 foreach ($tables as $index => $tableName) {
                     $tables[$index] = basename($tableName);
                 }
                 $query .= " " . implode(",", $tables);
                 $res = $this->execQuery($query);
                 $reload_current_node = true;
             } else {
                 // TABLE NODE => DELETE RECORDS
                 $tableName = $dir;
                 $pks = $selection->getFiles();
                 foreach ($pks as $key => $pkString) {
                     $parts = explode(".", $pkString);
                     array_pop($parts);
                     // remove .pk extension
                     array_shift($parts);
                     // remove record prefix
                     foreach ($parts as $index => $pkPart) {
                         $parts[$index] = str_replace("__", "='", $pkPart) . "'";
                     }
                     $pks[$key] = "(" . implode(" AND ", $parts) . ")";
                 }
                 $query = "DELETE FROM {$tableName} WHERE " . implode(" OR ", $pks);
                 $res = $this->execQuery($query);
             }
             //AJXP_Exception::errorToXml($res);
             if (is_a($res, "AJXP_Exception")) {
                 $errorMessage = $res->messageId;
             } else {
                 $logMessage = $query;
                 $reload_file_list = true;
             }
             $this->closeDbLink($link);
             break;
             //------------------------------------
             //	RENOMMER / RENAME
             //------------------------------------
         //------------------------------------
         //	RENOMMER / RENAME
         //------------------------------------
         case "set_query":
             $query = $httpVars["query"];
             $_SESSION["LAST_SQL_QUERY"] = $query;
             print "<tree store=\"true\"></tree>";
             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;
                         }
                     }
                 }
             }
             $link = $this->createDbLink();
             //AJXP_Exception::errorToXml($link);
             if ($dir == "") {
                 AJXP_XMLWriter::header();
                 $tables = $this->listTables();
                 AJXP_XMLWriter::sendFilesListComponentConfig('<columns switchDisplayMode="list" switchGridMode="filelist"><column messageString="Table Name" attributeName="ajxp_label" sortType="String"/><column messageString="Byte Size" attributeName="bytesize" sortType="NumberKo"/><column messageString="Count" attributeName="count" sortType="Number"/></columns>');
                 $icon = $mode == "file_list" ? "sql_images/mimes/ICON_SIZE/table_empty.png" : "sql_images/mimes/ICON_SIZE/table_empty_tree.png";
                 foreach ($tables as $tableName) {
                     $size = $this->getSize($tableName);
                     $count = $this->getCount($tableName);
                     print "<tree is_file=\"0\" text=\"{$tableName}\" filename=\"/{$tableName}\" bytesize=\"{$size}\" count=\"{$count}\" icon=\"{$icon}\" ajxp_mime=\"table\" />";
                 }
                 print "<tree is_file=\"0\" text=\"Search Results\" ajxp_node=\"true\" filename=\"/ajxpmysqldriver_searchresults\" bytesize=\"-\" count=\"-\" icon=\"search.png\"/>";
                 AJXP_XMLWriter::close();
             } else {
                 $tableName = basename($dir);
                 if (isset($page)) {
                     $currentPage = $page;
                 } else {
                     $currentPage = 1;
                 }
                 $query = "SELECT * FROM {$tableName}";
                 $searchQuery = false;
                 if ($tableName == "ajxpmysqldriver_searchresults") {
                     if (isset($_SESSION["LAST_SQL_QUERY"])) {
                         $query = $_SESSION["LAST_SQL_QUERY"];
                         $matches = array();
                         if (preg_match("/SELECT [\\S, ]* FROM (\\S*).*/i", $query, $matches) !== false) {
                             $tableName = $matches[1];
                             $searchQuery = true;
                         } else {
                             break;
                         }
                     } else {
                         break;
                     }
                 }
                 if (isset($order_column)) {
                     $query .= " ORDER BY {$order_column} " . strtoupper($order_direction);
                     if (!isset($_SESSION["AJXP_ORDER_DATA"])) {
                         $_SESSION["AJXP_ORDER_DATA"] = array();
                     }
                     $_SESSION["AJXP_ORDER_DATA"][$this->repository->getUniqueId() . "_" . $tableName] = array("column" => $order_column, "dir" => $order_direction);
                 } else {
                     if (isset($_SESSION["AJXP_ORDER_DATA"])) {
                         if (isset($_SESSION["AJXP_ORDER_DATA"][$this->repository->getUniqueId() . "_" . $tableName])) {
                             $order_column = $_SESSION["AJXP_ORDER_DATA"][$this->repository->getUniqueId() . "_" . $tableName]["column"];
                             $order_direction = $_SESSION["AJXP_ORDER_DATA"][$this->repository->getUniqueId() . "_" . $tableName]["dir"];
                             $query .= " ORDER BY {$order_column} " . strtoupper($order_direction);
                         }
                     }
                 }
                 try {
                     $result = $this->showRecords($query, $tableName, $currentPage);
                 } catch (AJXP_Exception $ex) {
                     unset($_SESSION["LAST_SQL_QUERY"]);
                     throw $ex;
                 }
                 AJXP_XMLWriter::header();
                 $blobCols = array();
                 $columnsString = '<columns switchDisplayMode="list" switchGridMode="grid">';
                 foreach ($result["COLUMNS"] as $col) {
                     $columnsString .= "<column messageString=\"" . $col["NAME"] . "\" attributeName=\"" . $col["NAME"] . "\" field_name=\"" . $col["NAME"] . "\" field_type=\"" . $col["TYPE"] . "\" field_size=\"" . $col["LENGTH"] . "\" field_flags=\"" . $this->cleanFlagString($col["FLAGS"]) . "\" field_pk=\"" . (preg_match("/primary/", $col["FLAGS"]) ? "1" : "0") . "\" field_null=\"" . (preg_match("/not_null/", $col["FLAGS"]) ? "NOT_NULL" : "NULL") . "\" sortType=\"" . $this->sqlTypeToSortType($col["TYPE"]) . "\" field_default=\"" . $col["DEFAULT"] . "\"/>";
                     if (stristr($col["TYPE"], "blob") !== false && ($col["FLAGS"] != "" && stristr($col["FLAGS"], "binary"))) {
                         $blobCols[] = $col["NAME"];
                     }
                 }
                 $columnsString .= '</columns>';
                 AJXP_XMLWriter::sendFilesListComponentConfig($columnsString);
                 //print '<pagination total="'.$result["TOTAL_PAGES"].'" current="'.$currentPage.'" remote_order="true" currentOrderCol="'.$order_column.'" currentOrderDir="'.$order_direction.'"/>';
                 if ($result["TOTAL_PAGES"] > 1) {
                     AJXP_XMLWriter::renderPaginationData($count, $currentPage, $result["TOTAL_PAGES"]);
                 }
                 foreach ($result["ROWS"] as $arbitIndex => $row) {
                     print '<tree ';
                     $pkString = "";
                     foreach ($row as $key => $value) {
                         if (in_array($key, $blobCols)) {
                             $sizeStr = " - NULL";
                             if (strlen($value)) {
                                 $sizeStr = " - " . AJXP_Utils::roundSize(strlen($value));
                             }
                             print "{$key}=\"BLOB{$sizeStr}\" ";
                         } else {
                             $value = str_replace("\"", "", $value);
                             $value = AJXP_Utils::xmlEntities($value);
                             print $key . '="' . SystemTextEncoding::toUTF8($value) . '" ';
                             if ($result["HAS_PK"] > 0) {
                                 if (in_array($key, $result["PK_FIELDS"])) {
                                     $pkString .= $key . "__" . $value . ".";
                                 }
                             }
                         }
                     }
                     if ($result["HAS_PK"] > 0) {
                         print 'filename="record.' . $pkString . 'pk" ';
                         print 'is_file="1" ajxp_mime="pk"/>';
                     } else {
                         print 'filename="record_' . $arbitIndex . '.no_pk" ';
                         print 'is_file="1" ajxp_mime="row"/>';
                     }
                 }
                 AJXP_XMLWriter::close();
             }
             $this->closeDbLink($link);
             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" || isset($reload_file_list)) {
         $xmlBuffer .= AJXP_XMLWriter::reloadDataNode("", "", false);
     }
     return $xmlBuffer;
 }
コード例 #12
0
 public function switchAction($action, $httpVars, $filesVars)
 {
     if (!isset($this->actions[$action])) {
         return false;
     }
     $repository = ConfService::getRepository();
     if (!$repository->detectStreamWrapper(true)) {
         return false;
     }
     $streamData = $repository->streamData;
     $destStreamURL = $streamData["protocol"] . "://" . $repository->getId();
     if ($action == "post_to_server") {
         $file = base64_decode($httpVars["file"]);
         $file = SystemTextEncoding::magicDequote(AJXP_Utils::securePath($file));
         $target = base64_decode($httpVars["parent_url"]) . "/plugins/editor.pixlr";
         $tmp = call_user_func(array($streamData["classname"], "getRealFSReference"), $destStreamURL . $file);
         $tmp = SystemTextEncoding::fromUTF8($tmp);
         $fData = array("tmp_name" => $tmp, "name" => urlencode(basename($file)), "type" => "image/jpg");
         //var_dump($fData);
         $httpClient = new HttpClient("pixlr.com");
         //$httpClient->setDebug(true);
         $postData = array();
         $httpClient->setHandleRedirects(false);
         $params = array("referrer" => "AjaXplorer", "method" => "get", "loc" => ConfService::getLanguage(), "target" => $target . "/fake_save_pixlr.php", "exit" => $target . "/fake_close_pixlr.php", "title" => urlencode(basename($file)), "locktarget" => "false", "locktitle" => "true", "locktype" => "source");
         $httpClient->postFile("/editor/", $params, "image", $fData);
         $loc = $httpClient->getHeader("location");
         header("Location:{$loc}");
     } else {
         if ($action == "retrieve_pixlr_image") {
             $file = AJXP_Utils::decodeSecureMagic($httpVars["original_file"]);
             $url = $httpVars["new_url"];
             $urlParts = parse_url($url);
             $query = $urlParts["query"];
             $params = array();
             $parameters = parse_str($query, $params);
             $image = $params['image'];
             /*
             $type = $params['type'];
             $state = $params['state'];
             $filename = $params['title'];		
             */
             if (strpos($image, "pixlr.com") == 0) {
                 throw new AJXP_Exception("Invalid Referrer");
             }
             $headers = get_headers($image, 1);
             $content_type = explode("/", $headers['Content-Type']);
             if ($content_type[0] != "image") {
                 throw new AJXP_Exception("File Type");
             }
             $orig = fopen($image, "r");
             $target = fopen($destStreamURL . $file, "w");
             while (!feof($orig)) {
                 fwrite($target, fread($orig, 4096));
             }
             fclose($orig);
             fclose($target);
             header("Content-Type:text/plain");
             print $mess[115];
         }
     }
     return;
 }
コード例 #13
0
 public function unifyChunks($action, &$httpVars, &$fileVars)
 {
     $filename = SystemTextEncoding::fromUTF8($httpVars["name"]);
     $tmpName = $fileVars["file"]["tmp_name"];
     $chunk = $httpVars["chunk"];
     $chunks = $httpVars["chunks"];
     //error_log("currentChunk:".$chunk."  chunks: ".$chunks);
     $repository = ConfService::getRepository();
     if (!$repository->detectStreamWrapper(false)) {
         return false;
     }
     $plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType());
     $streamData = $plugin->detectStreamWrapper(true);
     $dir = $httpVars["dir"];
     $destStreamURL = $streamData["protocol"] . "://" . $repository->getId() . $dir . "/";
     //error_log("Directory: ".$dir);
     // Clean the fileName for security reasons
     //$filename = preg_replace('/[^\w\._]+/', '', $filename);
     // Look for the content type header
     if (isset($_SERVER["HTTP_CONTENT_TYPE"])) {
         $contentType = $_SERVER["HTTP_CONTENT_TYPE"];
     }
     if (isset($_SERVER["CONTENT_TYPE"])) {
         $contentType = $_SERVER["CONTENT_TYPE"];
     }
     // Handle non multipart uploads older WebKit versions didn't support multipart in HTML5
     if (strpos($contentType, "multipart") !== false) {
         if (isset($tmpName) && is_uploaded_file($tmpName)) {
             //error_log("tmpName: ".$tmpName);
             // Open temp file
             $out = fopen($destStreamURL . $filename, $chunk == 0 ? "wb" : "ab");
             if ($out) {
                 // Read binary input stream and append it to temp file
                 $in = fopen($tmpName, "rb");
                 if ($in) {
                     while ($buff = fread($in, 4096)) {
                         fwrite($out, $buff);
                     }
                 } else {
                     die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
                 }
                 fclose($in);
                 fclose($out);
                 @unlink($tmpName);
             } else {
                 die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
             }
         } else {
             die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}');
         }
     } else {
         // Open temp file
         $out = fopen($destStreamURL . $filename, $chunk == 0 ? "wb" : "ab");
         if ($out) {
             // Read binary input stream and append it to temp file
             $in = fopen("php://input", "rb");
             if ($in) {
                 while ($buff = fread($in, 4096)) {
                     fwrite($out, $buff);
                 }
             } else {
                 die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
             }
             fclose($in);
             fclose($out);
         } else {
             die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
         }
     }
     /* we apply the hook if we are uploading the last chunk */
     if ($chunk == $chunks - 1) {
         AJXP_Controller::applyHook("node.change", array(null, new AJXP_Node($destStreamURL . $filename), false));
     }
     // Return JSON-RPC response
     die('{"jsonrpc" : "2.0", "result" : null, "id" : "id"}');
 }
コード例 #14
0
 /**
  * @return String
  */
 function getDisplay()
 {
     if (isset($this->displayStringId)) {
         $mess = ConfService::getMessages();
         if (isset($mess[$this->displayStringId])) {
             return SystemTextEncoding::fromUTF8($mess[$this->displayStringId]);
         }
     }
     return $this->display;
 }
コード例 #15
0
ファイル: class.Repository.php プロジェクト: biggtfish/cms
 /**
  * The label of this repository
  * @return String
  */
 public function getDisplay()
 {
     if (isset($this->displayStringId)) {
         $mess = ConfService::getMessages();
         if (isset($mess[$this->displayStringId])) {
             return SystemTextEncoding::fromUTF8($mess[$this->displayStringId]);
         }
     }
     return AJXP_VarsFilter::filter($this->display);
 }
コード例 #16
0
 function makeName($param)
 {
     if (is_array($param)) {
         $retArray = array();
         foreach ($param as $item) {
             $retArray[] = $this->serverCwd . SystemTextEncoding::fromUTF8(trim($item, './'));
         }
         return $retArray;
     } else {
         $param = SystemTextEncoding::fromUTF8(trim($param, './'));
         return $this->serverCwd . $param;
     }
 }
コード例 #17
0
 public function loadUserAlerts($actionName, $httpVars, $fileVars)
 {
     if (!$this->eventStore) {
         return;
     }
     $u = AuthService::getLoggedUser();
     $userId = $u->getId();
     $repositoryFilter = null;
     if (isset($httpVars["repository_id"]) && $u->mergedRole->canRead($httpVars["repository_id"])) {
         $repositoryFilter = $httpVars["repository_id"];
     }
     if ($repositoryFilter == null) {
         $repositoryFilter = ConfService::getRepository()->getId();
     }
     $res = $this->eventStore->loadAlerts($userId, $repositoryFilter);
     if (!count($res)) {
         return;
     }
     // Recompute children notifs
     $format = $httpVars["format"];
     $skipContainingTags = isset($httpVars["skip_container_tags"]);
     $mess = ConfService::getMessages();
     if (!$skipContainingTags) {
         if ($format == "html") {
             echo "<h2>" . $mess["notification_center.3"] . "</h2>";
             echo "<ul class='notification_list'>";
         } else {
             AJXP_XMLWriter::header();
         }
     }
     $parentRepository = ConfService::getRepositoryById($repositoryFilter);
     $parentRoot = $parentRepository->getOption("PATH");
     $cumulated = array();
     foreach ($res as $notification) {
         if ($format == "html") {
             echo "<li>";
             echo $notification->getDescriptionLong(true);
             echo "</li>";
         } else {
             $node = $notification->getNode();
             $path = $node->getPath();
             $nodeRepo = $node->getRepository();
             if ($nodeRepo != null && $nodeRepo->hasParent() && $nodeRepo->getParentId() == $repositoryFilter) {
                 $currentRoot = $nodeRepo->getOption("PATH");
                 $contentFilter = $nodeRepo->getContentFilter();
                 if (isset($contentFilter)) {
                     $nodePath = $contentFilter->filterExternalPath($node->getPath());
                     if ($nodePath == "/") {
                         $k = array_keys($contentFilter->filters);
                         $nodePath = $k[0];
                     }
                 } else {
                     $nodePath = $node->getPath();
                 }
                 $relative = rtrim(substr($currentRoot, strlen($parentRoot)), "/") . rtrim($nodePath, "/");
                 $parentNodeURL = $node->getScheme() . "://" . $repositoryFilter . $relative;
                 $this->logDebug("action.share", "Recompute alert to " . $parentNodeURL);
                 $node = new AJXP_Node($parentNodeURL);
             }
             if (isset($cumulated[$path])) {
                 $cumulated[$path]->event_occurence++;
                 continue;
             }
             try {
                 $node->loadNodeInfo();
             } catch (Exception $e) {
                 if ($notification->alert_id) {
                     $this->eventStore->dismissAlertById($notification->alert_id);
                 }
                 continue;
             }
             $node->event_is_alert = true;
             $node->event_description = ucfirst($notification->getDescriptionBlock()) . " " . $mess["notification.tpl.block.user_link"] . " " . $notification->getAuthorLabel();
             $node->event_description_long = $notification->getDescriptionLong(true);
             $node->event_date = SystemTextEncoding::fromUTF8(AJXP_Utils::relativeDate($notification->getDate(), $mess));
             $node->event_type = "alert";
             $node->alert_id = $notification->alert_id;
             if ($node->getRepository() != null) {
                 $node->repository_id = '' . $node->getRepository()->getId();
                 if ($node->repository_id != $repositoryFilter && $node->getRepository()->getDisplay() != null) {
                     $node->event_repository_label = "[" . $node->getRepository()->getDisplay() . "]";
                 }
             } else {
                 $node->event_repository_label = "[N/A]";
             }
             $node->event_author = $notification->getAuthor();
             $node->event_occurence = 1;
             $cumulated[$path] = $node;
         }
     }
     $index = 1;
     foreach ($cumulated as $nodeToSend) {
         $nodeOcc = $nodeToSend->event_occurence > 1 ? "(" . $nodeToSend->event_occurence . ")" : "";
         if (isset($httpVars["merge_description"]) && $httpVars["merge_description"] == "true") {
             if (isset($httpVars["description_as_label"]) && $httpVars["description_as_label"] == "true") {
                 $nodeToSend->setLabel($nodeToSend->event_description . " " . $nodeOcc . " " . $nodeToSend->event_date);
             } else {
                 $nodeToSend->setLabel(basename($nodeToSend->getPath()) . " " . $nodeOcc . " " . " <small class='notif_desc'>" . $nodeToSend->event_description . " " . $nodeToSend->event_date . "</small>");
             }
         } else {
             $nodeToSend->setLabel(basename($nodeToSend->getPath()) . $nodeOcc);
         }
         // Replace PATH
         $nodeToSend->real_path = $path;
         //$url = parse_url($nodeToSend->getUrl());
         //$nodeToSend->setUrl($url["scheme"]."://".$url["host"]."/alert_".$index);
         $index++;
         AJXP_XMLWriter::renderAjxpNode($nodeToSend);
     }
     if (!$skipContainingTags) {
         if ($format == "html") {
             echo "</ul>";
         } else {
             AJXP_XMLWriter::close();
         }
     }
 }
コード例 #18
0
 /**
  * call fromUTF8
  * @static
  * @param string $filesystemElement
  * @return string
  */
 public static function fromPostedFileName($filesystemElement)
 {
     return SystemTextEncoding::fromUTF8(SystemTextEncoding::magicDequote($filesystemElement));
 }
コード例 #19
0
 public static function decodeSecureMagic($data)
 {
     return SystemTextEncoding::fromUTF8(AJXP_Utils::securePath(SystemTextEncoding::magicDequote($data)));
 }
コード例 #20
0
 /**
  * Perform standard urldecode, sanitization and securepath
  * @static
  * @param $data
  * @param int $sanitizeLevel
  * @return string
  */
 public static function decodeSecureMagic($data, $sanitizeLevel = AJXP_SANITIZE_HTML)
 {
     return SystemTextEncoding::fromUTF8(AJXP_Utils::sanitize(AJXP_Utils::securePath($data), $sanitizeLevel));
 }
コード例 #21
0
 function parseParameters(&$repDef, &$options, $userId = null)
 {
     $replicationGroups = array();
     foreach ($repDef as $key => $value) {
         $value = AJXP_Utils::sanitize(SystemTextEncoding::magicDequote($value));
         if (strpos($key, "DRIVER_OPTION_") !== false && strpos($key, "DRIVER_OPTION_") == 0 && strpos($key, "ajxptype") === false && strpos($key, "_replication") === false && strpos($key, "_checkbox") === false) {
             if (isset($repDef[$key . "_ajxptype"])) {
                 $type = $repDef[$key . "_ajxptype"];
                 if ($type == "boolean") {
                     $value = $value == "true" ? true : false;
                 } else {
                     if ($type == "integer") {
                         $value = intval($value);
                     } else {
                         if ($type == "array") {
                             $value = explode(",", $value);
                         } else {
                             if ($type == "password" && $userId != null) {
                                 if (trim($value != "") && function_exists('mcrypt_encrypt')) {
                                     // The initialisation vector is only required to avoid a warning, as ECB ignore IV
                                     $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
                                     // We encode as base64 so if we need to store the result in a database, it can be stored in text column
                                     $value = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($userId . "CDAFx¨op#"), $value, MCRYPT_MODE_ECB, $iv));
                                 }
                             }
                         }
                     }
                 }
                 unset($repDef[$key . "_ajxptype"]);
             }
             if (isset($repDef[$key . "_checkbox"])) {
                 $checked = $repDef[$key . "_checkbox"] == "checked";
                 unset($repDef[$key . "_checkbox"]);
                 if (!$checked) {
                     continue;
                 }
             }
             if (isset($repDef[$key . "_replication"])) {
                 $repKey = $repDef[$key . "_replication"];
                 if (!is_array($replicationGroups[$repKey])) {
                     $replicationGroups[$repKey] = array();
                 }
                 $replicationGroups[$repKey][] = $key;
             }
             $options[substr($key, strlen("DRIVER_OPTION_"))] = $value;
             unset($repDef[$key]);
         } else {
             if ($key == "DISPLAY") {
                 $value = SystemTextEncoding::fromUTF8(AJXP_Utils::securePath($value));
             }
             $repDef[$key] = $value;
         }
     }
     // DO SOMETHING WITH REPLICATED PARAMETERS?
     if (count($replicationGroups)) {
     }
 }
コード例 #22
0
 protected function replaceVars($tplString, $mess, $rich = true)
 {
     $tplString = SystemTextEncoding::fromUTF8($tplString);
     $repoId = $this->getNode()->getRepositoryId();
     if (ConfService::getRepositoryById($repoId) != null) {
         $repoLabel = ConfService::getRepositoryById($repoId)->getDisplay();
     } else {
         $repoLabel = "Repository";
     }
     $uLabel = "";
     if (array_key_exists($this->getAuthor(), self::$usersCaches)) {
         if (self::$usersCaches[$this->getAuthor()] != 'AJXP_USER_DONT_EXISTS') {
             $uLabel = self::$usersCaches[$this->getAuthor()];
         }
     } else {
         if (strstr($tplString, "AJXP_USER") !== false) {
             if (AuthService::userExists($this->getAuthor())) {
                 $obj = ConfService::getConfStorageImpl()->createUserObject($this->getAuthor());
                 $uLabel = $obj->personalRole->filterParameterValue("core.conf", "USER_DISPLAY_NAME", AJXP_REPO_SCOPE_ALL, "");
                 self::$usersCaches[$this->getAuthor()] = $uLabel;
             } else {
                 self::$usersCaches[$this->getAuthor()] = 'AJXP_USER_DONT_EXISTS';
             }
         }
     }
     if (empty($uLabel)) {
         $uLabel = $this->getAuthor();
     }
     $em = $rich ? "<em>" : "";
     $me = $rich ? "</em>" : "";
     $replaces = array("AJXP_NODE_PATH" => $em . $this->getRoot($this->getNode()->getPath()) . $me, "AJXP_NODE_LABEL" => $em . $this->getNode()->getLabel() . $me, "AJXP_PARENT_PATH" => $em . $this->getRoot(dirname($this->getNode()->getPath())) . $me, "AJXP_PARENT_LABEL" => $em . $this->getRoot(basename(dirname($this->getNode()->getPath()))) . $me, "AJXP_REPOSITORY_ID" => $em . $repoId . $me, "AJXP_REPOSITORY_LABEL" => $em . $repoLabel . $me, "AJXP_LINK" => $this->getMainLink(), "AJXP_USER" => $uLabel, "AJXP_DATE" => SystemTextEncoding::fromUTF8(AJXP_Utils::relativeDate($this->getDate(), $mess)));
     if ($replaces["AJXP_NODE_LABEL"] == $em . $me) {
         $replaces["AJXP_NODE_LABEL"] = $em . "[" . $replaces["AJXP_REPOSITORY_LABEL"] . "]" . $me;
     }
     if ($replaces["AJXP_PARENT_LABEL"] == $em . $me) {
         $replaces["AJXP_PARENT_LABEL"] = $em . "[" . $replaces["AJXP_REPOSITORY_LABEL"] . "]" . $me;
     }
     if ((strstr($tplString, "AJXP_TARGET_FOLDER") !== false || strstr($tplString, "AJXP_SOURCE_FOLDER")) && isset($this->secondaryNode)) {
         $p = $this->secondaryNode->getPath();
         if ($this->secondaryNode->isLeaf()) {
             $p = $this->getRoot(dirname($p));
         }
         $replaces["AJXP_TARGET_FOLDER"] = $replaces["AJXP_SOURCE_FOLDER"] = $em . $p . $me;
     }
     if ((strstr($tplString, "AJXP_TARGET_LABEL") !== false || strstr($tplString, "AJXP_SOURCE_LABEL") !== false) && isset($this->secondaryNode)) {
         $replaces["AJXP_TARGET_LABEL"] = $replaces["AJXP_SOURCE_LABEL"] = $em . $this->secondaryNode->getLabel() . $me;
     }
     return str_replace(array_keys($replaces), array_values($replaces), $tplString);
 }
コード例 #23
0
 function switchAction($action, $httpVars, $fileVars)
 {
     if (!isset($this->actions[$action])) {
         return;
     }
     $errorMessage = "This is a demo, all 'write' actions are disabled!";
     switch ($action) {
         //------------------------------------
         //	ONLINE EDIT
         //------------------------------------
         case "edit":
             if (isset($save) && $save == 1) {
                 $xmlBuffer .= AJXP_XMLWriter::sendMessage(null, $errorMessage, false);
             } else {
                 $this->readFile($this->getPath() . "/" . SystemTextEncoding::fromUTF8(Utils::securePath($_GET["file"])), "plain");
             }
             exit(0);
             break;
         case "public_url":
             print $errorMessage;
             exit(0);
             break;
             //------------------------------------
             //	COPY / MOVE
             //------------------------------------
         //------------------------------------
         //	COPY / MOVE
         //------------------------------------
         case "copy":
         case "move":
         case "rename":
         case "delete":
         case "mkdir":
         case "mkfile":
         case "chmod":
             return AJXP_XMLWriter::sendMessage(null, $errorMessage, false);
             break;
             //------------------------------------
             //	UPLOAD
             //------------------------------------
         //------------------------------------
         //	UPLOAD
         //------------------------------------
         case "upload":
             $fancyLoader = false;
             foreach ($fileVars as $boxName => $boxData) {
                 if ($boxName == "Filedata") {
                     $fancyLoader = true;
                 }
             }
             if ($fancyLoader) {
                 header('HTTP/1.0 ' . $errorMessage);
                 die('Error ' . $errorMessage);
             } else {
                 print "<html><script language=\"javascript\">\n";
                 print "\n if(parent.ajaxplorer.actionBar.multi_selector)parent.ajaxplorer.actionBar.multi_selector.submitNext('" . str_replace("'", "\\'", $errorMessage) . "');";
                 print "</script></html>";
             }
             exit;
             break;
         default:
             break;
     }
     return parent::switchAction($action, $httpVars, $fileVars);
 }
コード例 #24
0
 public function switchAction($action, $httpVars, $fileVars)
 {
     if (!isset($this->actions[$action])) {
         return;
     }
     $xmlBuffer = "";
     foreach ($httpVars as $getName => $getValue) {
         ${$getName} = AJXP_Utils::securePath($getValue);
     }
     if (isset($dir) && $action != "upload") {
         $dir = SystemTextEncoding::fromUTF8($dir);
     }
     $mess = ConfService::getMessages();
     switch ($action) {
         //------------------------------------
         //	SWITCH THE ROOT REPOSITORY
         //------------------------------------
         case "switch_repository":
             if (!isset($repository_id)) {
                 break;
             }
             $dirList = ConfService::getRepositoriesList();
             /** @var $repository_id string */
             if (!isset($dirList[$repository_id])) {
                 $errorMessage = "Trying to switch to an unkown repository!";
                 break;
             }
             ConfService::switchRootDir($repository_id);
             // Load try to init the driver now, to trigger an exception
             // if it's not loading right.
             ConfService::loadRepositoryDriver();
             if (AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
                 $user = AuthService::getLoggedUser();
                 $activeRepId = ConfService::getCurrentRepositoryId();
                 $user->setArrayPref("history", "last_repository", $activeRepId);
                 $user->save("user");
             }
             //$logMessage = "Successfully Switched!";
             $this->logInfo("Switch Repository", array("rep. id" => $repository_id));
             break;
             //------------------------------------
             //	SEND XML REGISTRY
             //------------------------------------
         //------------------------------------
         //	SEND XML REGISTRY
         //------------------------------------
         case "get_xml_registry":
         case "state":
             $regDoc = AJXP_PluginsService::getXmlRegistry();
             $changes = AJXP_Controller::filterRegistryFromRole($regDoc);
             if ($changes) {
                 AJXP_PluginsService::updateXmlRegistry($regDoc);
             }
             $clone = $regDoc->cloneNode(true);
             $clonePath = new DOMXPath($clone);
             $serverCallbacks = $clonePath->query("//serverCallback|hooks");
             foreach ($serverCallbacks as $callback) {
                 $callback->parentNode->removeChild($callback);
             }
             $xPath = '';
             if (isset($httpVars["xPath"])) {
                 $xPath = ltrim(AJXP_Utils::securePath($httpVars["xPath"]), "/");
             }
             if (!empty($xPath)) {
                 $nodes = $clonePath->query($xPath);
                 if ($httpVars["format"] == "json") {
                     $data = AJXP_XMLWriter::xmlToArray($nodes->item(0));
                     HTMLWriter::charsetHeader("application/json");
                     echo json_encode($data);
                 } else {
                     AJXP_XMLWriter::header("ajxp_registry_part", array("xPath" => $xPath));
                     if ($nodes->length) {
                         print AJXP_XMLWriter::replaceAjxpXmlKeywords($clone->saveXML($nodes->item(0)));
                     }
                     AJXP_XMLWriter::close("ajxp_registry_part");
                 }
             } else {
                 AJXP_Utils::safeIniSet("zlib.output_compression", "4096");
                 if ($httpVars["format"] == "json") {
                     $data = AJXP_XMLWriter::xmlToArray($clone);
                     HTMLWriter::charsetHeader("application/json");
                     echo json_encode($data);
                 } else {
                     header('Content-Type: application/xml; charset=UTF-8');
                     print AJXP_XMLWriter::replaceAjxpXmlKeywords($clone->saveXML());
                 }
             }
             break;
             //------------------------------------
             //	BOOKMARK BAR
             //------------------------------------
         //------------------------------------
         //	BOOKMARK BAR
         //------------------------------------
         case "get_bookmarks":
             $bmUser = null;
             if (AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
                 $bmUser = AuthService::getLoggedUser();
             } else {
                 if (!AuthService::usersEnabled()) {
                     $confStorage = ConfService::getConfStorageImpl();
                     $bmUser = $confStorage->createUserObject("shared");
                 }
             }
             if ($bmUser == null) {
                 AJXP_XMLWriter::header();
                 AJXP_XMLWriter::close();
             }
             $driver = ConfService::loadRepositoryDriver();
             if (!is_a($driver, "AjxpWrapperProvider")) {
                 $driver = false;
             }
             if (isset($httpVars["bm_action"]) && isset($httpVars["bm_path"])) {
                 $bmPath = AJXP_Utils::decodeSecureMagic($httpVars["bm_path"]);
                 if ($httpVars["bm_action"] == "add_bookmark") {
                     $title = "";
                     if (isset($httpVars["bm_title"])) {
                         $title = AJXP_Utils::decodeSecureMagic($httpVars["bm_title"]);
                     }
                     if ($title == "" && $bmPath == "/") {
                         $title = ConfService::getCurrentRootDirDisplay();
                     }
                     $bmUser->addBookMark($bmPath, $title);
                     if ($driver) {
                         $node = new AJXP_Node($driver->getResourceUrl($bmPath));
                         $node->setMetadata("ajxp_bookmarked", array("ajxp_bookmarked" => "true"), true, AJXP_METADATA_SCOPE_REPOSITORY, true);
                     }
                 } else {
                     if ($httpVars["bm_action"] == "delete_bookmark") {
                         $bmUser->removeBookmark($bmPath);
                         if ($driver) {
                             $node = new AJXP_Node($driver->getResourceUrl($bmPath));
                             $node->removeMetadata("ajxp_bookmarked", true, AJXP_METADATA_SCOPE_REPOSITORY, true);
                         }
                     } else {
                         if ($httpVars["bm_action"] == "rename_bookmark" && isset($httpVars["bm_title"])) {
                             $title = AJXP_Utils::decodeSecureMagic($httpVars["bm_title"]);
                             $bmUser->renameBookmark($bmPath, $title);
                         }
                     }
                 }
                 AJXP_Controller::applyHook("msg.instant", array("<reload_bookmarks/>", ConfService::getRepository()->getId()));
                 if (AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
                     $bmUser->save("user");
                     AuthService::updateUser($bmUser);
                 } else {
                     if (!AuthService::usersEnabled()) {
                         $bmUser->save("user");
                     }
                 }
             }
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::writeBookmarks($bmUser->getBookmarks(), true, isset($httpVars["format"]) ? $httpVars["format"] : "legacy");
             AJXP_XMLWriter::close();
             break;
             //------------------------------------
             //	SAVE USER PREFERENCE
             //------------------------------------
         //------------------------------------
         //	SAVE USER PREFERENCE
         //------------------------------------
         case "save_user_pref":
             $userObject = AuthService::getLoggedUser();
             $i = 0;
             while (isset($httpVars["pref_name_" . $i]) && isset($httpVars["pref_value_" . $i])) {
                 $prefName = AJXP_Utils::sanitize($httpVars["pref_name_" . $i], AJXP_SANITIZE_ALPHANUM);
                 $prefValue = AJXP_Utils::sanitize(SystemTextEncoding::magicDequote($httpVars["pref_value_" . $i]));
                 if ($prefName == "password") {
                     continue;
                 }
                 if ($prefName != "pending_folder" && $userObject == null) {
                     $i++;
                     continue;
                 }
                 $userObject->setPref($prefName, $prefValue);
                 $userObject->save("user");
                 AuthService::updateUser($userObject);
                 //setcookie("AJXP_$prefName", $prefValue);
                 $i++;
             }
             header("Content-Type:text/plain");
             print "SUCCESS";
             break;
             //------------------------------------
             //	SAVE USER PREFERENCE
             //------------------------------------
         //------------------------------------
         //	SAVE USER PREFERENCE
         //------------------------------------
         case "custom_data_edit":
         case "user_create_user":
             $data = array();
             if ($action == "user_create_user" && isset($httpVars["NEW_new_user_id"])) {
                 $updating = false;
                 AJXP_Utils::parseStandardFormParameters($httpVars, $data, null, "NEW_");
                 $original_id = AJXP_Utils::decodeSecureMagic($data["new_user_id"]);
                 $data["new_user_id"] = AJXP_Utils::decodeSecureMagic($data["new_user_id"], AJXP_SANITIZE_EMAILCHARS);
                 if ($original_id != $data["new_user_id"]) {
                     throw new Exception(str_replace("%s", $data["new_user_id"], $mess["ajxp_conf.127"]));
                 }
                 if (AuthService::userExists($data["new_user_id"], "w")) {
                     throw new Exception($mess["ajxp_conf.43"]);
                 }
                 $loggedUser = AuthService::getLoggedUser();
                 $limit = $loggedUser->personalRole->filterParameterValue("core.conf", "USER_SHARED_USERS_LIMIT", AJXP_REPO_SCOPE_ALL, "");
                 if (!empty($limit) && intval($limit) > 0) {
                     $count = count($this->getUserChildren($loggedUser->getId()));
                     if ($count >= $limit) {
                         throw new Exception($mess['483']);
                     }
                 }
                 AuthService::createUser($data["new_user_id"], $data["new_password"]);
                 $userObject = ConfService::getConfStorageImpl()->createUserObject($data["new_user_id"]);
                 $userObject->setParent($loggedUser->getId());
                 $userObject->save('superuser');
                 $userObject->personalRole->clearAcls();
                 $userObject->setGroupPath($loggedUser->getGroupPath());
                 $userObject->setProfile("shared");
             } else {
                 if ($action == "user_create_user" && isset($httpVars["NEW_existing_user_id"])) {
                     $updating = true;
                     AJXP_Utils::parseStandardFormParameters($httpVars, $data, null, "NEW_");
                     $userId = $data["existing_user_id"];
                     if (!AuthService::userExists($userId)) {
                         throw new Exception("Cannot find user");
                     }
                     $userObject = ConfService::getConfStorageImpl()->createUserObject($userId);
                     if ($userObject->getParent() != AuthService::getLoggedUser()->getId()) {
                         throw new Exception("Cannot find user");
                     }
                     if (!empty($data["new_password"])) {
                         AuthService::updatePassword($userId, $data["new_password"]);
                     }
                 } else {
                     $updating = false;
                     $userObject = AuthService::getLoggedUser();
                     AJXP_Utils::parseStandardFormParameters($httpVars, $data, null, "PREFERENCES_");
                 }
             }
             $paramNodes = AJXP_PluginsService::searchAllManifests("//server_settings/param[contains(@scope,'user') and @expose='true']", "node", false, false, true);
             $rChanges = false;
             if (is_array($paramNodes) && count($paramNodes)) {
                 foreach ($paramNodes as $xmlNode) {
                     if ($xmlNode->getAttribute("expose") == "true") {
                         $parentNode = $xmlNode->parentNode->parentNode;
                         $pluginId = $parentNode->getAttribute("id");
                         if (empty($pluginId)) {
                             $pluginId = $parentNode->nodeName . "." . $parentNode->getAttribute("name");
                         }
                         $name = $xmlNode->getAttribute("name");
                         if (isset($data[$name]) || $data[$name] === "") {
                             if ($data[$name] == "__AJXP_VALUE_SET__") {
                                 continue;
                             }
                             if ($data[$name] === "" || $userObject->parentRole == null || $userObject->parentRole->filterParameterValue($pluginId, $name, AJXP_REPO_SCOPE_ALL, "") != $data[$name] || $userObject->personalRole->filterParameterValue($pluginId, $name, AJXP_REPO_SCOPE_ALL, "") != $data[$name]) {
                                 $userObject->personalRole->setParameterValue($pluginId, $name, $data[$name]);
                                 $rChanges = true;
                             }
                         }
                     }
                 }
             }
             if ($rChanges) {
                 AuthService::updateRole($userObject->personalRole, $userObject);
                 $userObject->recomputeMergedRole();
                 if ($action == "custom_data_edit") {
                     AuthService::updateUser($userObject);
                 }
             }
             if ($action == "user_create_user") {
                 AJXP_Controller::applyHook($updating ? "user.after_update" : "user.after_create", array($userObject));
                 if (isset($data["send_email"]) && $data["send_email"] == true && !empty($data["email"])) {
                     $mailer = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("mailer");
                     if ($mailer !== false) {
                         $mess = ConfService::getMessages();
                         $link = AJXP_Utils::detectServerURL();
                         $apptitle = ConfService::getCoreConf("APPLICATION_TITLE");
                         $subject = str_replace("%s", $apptitle, $mess["507"]);
                         $body = str_replace(array("%s", "%link", "%user", "%pass"), array($apptitle, $link, $data["new_user_id"], $data["new_password"]), $mess["508"]);
                         $mailer->sendMail(array($data["email"]), $subject, $body);
                     }
                 }
                 echo "SUCCESS";
             } else {
                 AJXP_XMLWriter::header();
                 AJXP_XMLWriter::sendMessage($mess["241"], null);
                 AJXP_XMLWriter::close();
             }
             break;
         case "user_update_user":
             if (!isset($httpVars["user_id"])) {
                 throw new Exception("invalid arguments");
             }
             $userId = $httpVars["user_id"];
             if (!AuthService::userExists($userId)) {
                 throw new Exception("Cannot find user");
             }
             $userObject = ConfService::getConfStorageImpl()->createUserObject($userId);
             if ($userObject->getParent() != AuthService::getLoggedUser()->getId()) {
                 throw new Exception("Cannot find user");
             }
             $paramsString = ConfService::getCoreConf("NEWUSERS_EDIT_PARAMETERS", "conf");
             $result = array();
             $params = explode(",", $paramsString);
             foreach ($params as $p) {
                 $result[$p] = $userObject->personalRole->filterParameterValue("core.conf", $p, AJXP_REPO_SCOPE_ALL, "");
             }
             HTMLWriter::charsetHeader("application/json");
             echo json_encode($result);
             break;
             //------------------------------------
             // WEBDAV PREFERENCES
             //------------------------------------
         //------------------------------------
         // WEBDAV PREFERENCES
         //------------------------------------
         case "webdav_preferences":
             $userObject = AuthService::getLoggedUser();
             $webdavActive = false;
             $passSet = false;
             $digestSet = false;
             // Detect http/https and host
             if (ConfService::getCoreConf("WEBDAV_BASEHOST") != "") {
                 $baseURL = ConfService::getCoreConf("WEBDAV_BASEHOST");
             } else {
                 $baseURL = AJXP_Utils::detectServerURL();
             }
             $webdavBaseUrl = $baseURL . ConfService::getCoreConf("WEBDAV_BASEURI") . "/";
             $davData = $userObject->getPref("AJXP_WEBDAV_DATA");
             $digestSet = isset($davData["HA1"]);
             if (isset($httpVars["activate"]) || isset($httpVars["webdav_pass"])) {
                 if (!empty($httpVars["activate"])) {
                     $activate = $httpVars["activate"] == "true" ? true : false;
                     if (empty($davData)) {
                         $davData = array();
                     }
                     $davData["ACTIVE"] = $activate;
                 }
                 if (!empty($httpVars["webdav_pass"])) {
                     $password = $httpVars["webdav_pass"];
                     if (function_exists('mcrypt_encrypt')) {
                         $user = $userObject->getId();
                         $secret = defined("AJXP_SAFE_SECRET_KEY") ? AJXP_SAFE_SECRET_KEY : "CDAFx¨op#";
                         $password = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($user . $secret), $password, MCRYPT_MODE_ECB));
                     }
                     $davData["PASS"] = $password;
                 }
                 $userObject->setPref("AJXP_WEBDAV_DATA", $davData);
                 $userObject->save("user");
             }
             if (!empty($davData)) {
                 $webdavActive = isset($davData["ACTIVE"]) && $davData["ACTIVE"] === true;
                 $passSet = isset($davData["PASS"]);
             }
             $repoList = ConfService::getRepositoriesList();
             $davRepos = array();
             $loggedUser = AuthService::getLoggedUser();
             foreach ($repoList as $repoIndex => $repoObject) {
                 $accessType = $repoObject->getAccessType();
                 $driver = AJXP_PluginsService::getInstance()->getPluginByTypeName("access", $accessType);
                 if (is_a($driver, "AjxpWrapperProvider") && !$repoObject->getOption("AJXP_WEBDAV_DISABLED") && ($loggedUser->canRead($repoIndex) || $loggedUser->canWrite($repoIndex))) {
                     $davRepos[$repoIndex] = $webdavBaseUrl . "" . ($repoObject->getSlug() == null ? $repoObject->getId() : $repoObject->getSlug());
                 }
             }
             $prefs = array("webdav_active" => $webdavActive, "password_set" => $passSet, "digest_set" => $digestSet, "webdav_force_basic" => ConfService::getCoreConf("WEBDAV_FORCE_BASIC") === true, "webdav_base_url" => $webdavBaseUrl, "webdav_repositories" => $davRepos);
             HTMLWriter::charsetHeader("application/json");
             print json_encode($prefs);
             break;
         case "get_user_template_logo":
             $tplId = $httpVars["template_id"];
             $iconFormat = $httpVars["icon_format"];
             $repo = ConfService::getRepositoryById($tplId);
             $logo = $repo->getOption("TPL_ICON_" . strtoupper($iconFormat));
             if (isset($logo) && is_file(AJXP_DATA_PATH . "/plugins/core.conf/tpl_logos/" . $logo)) {
                 header("Content-Type: " . AJXP_Utils::getImageMimeType($logo) . "; name=\"" . $logo . "\"");
                 header("Content-Length: " . filesize(AJXP_DATA_PATH . "/plugins/core.conf/tpl_logos/" . $logo));
                 header('Pragma:');
                 header('Cache-Control: public');
                 header("Last-Modified: " . gmdate("D, d M Y H:i:s", time() - 10000) . " GMT");
                 header("Expires: " . gmdate("D, d M Y H:i:s", time() + 5 * 24 * 3600) . " GMT");
                 readfile(AJXP_DATA_PATH . "/plugins/core.conf/tpl_logos/" . $logo);
             } else {
                 $logo = "default_template_logo-" . ($iconFormat == "small" ? 16 : 22) . ".png";
                 header("Content-Type: " . AJXP_Utils::getImageMimeType($logo) . "; name=\"" . $logo . "\"");
                 header("Content-Length: " . filesize(AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/core.conf/" . $logo));
                 header('Pragma:');
                 header('Cache-Control: public');
                 header("Last-Modified: " . gmdate("D, d M Y H:i:s", time() - 10000) . " GMT");
                 header("Expires: " . gmdate("D, d M Y H:i:s", time() + 5 * 24 * 3600) . " GMT");
                 readfile(AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/core.conf/" . $logo);
             }
             break;
         case "get_user_templates_definition":
             AJXP_XMLWriter::header("repository_templates");
             $count = 0;
             $repositories = ConfService::listRepositoriesWithCriteria(array("isTemplate" => 1), $count);
             $pServ = AJXP_PluginsService::getInstance();
             foreach ($repositories as $repo) {
                 if (!$repo->isTemplate) {
                     continue;
                 }
                 if (!$repo->getOption("TPL_USER_CAN_CREATE")) {
                     continue;
                 }
                 $repoId = $repo->getId();
                 $repoLabel = $repo->getDisplay();
                 $repoType = $repo->getAccessType();
                 print "<template repository_id=\"{$repoId}\" repository_label=\"{$repoLabel}\" repository_type=\"{$repoType}\">";
                 $driverPlug = $pServ->getPluginByTypeName("access", $repoType);
                 $params = $driverPlug->getManifestRawContent("//param", "node");
                 $tplDefined = $repo->getOptionsDefined();
                 $defaultLabel = '';
                 foreach ($params as $paramNode) {
                     $name = $paramNode->getAttribute("name");
                     if (strpos($name, "TPL_") === 0) {
                         if ($name == "TPL_DEFAULT_LABEL") {
                             $defaultLabel = str_replace("AJXP_USER", AuthService::getLoggedUser()->getId(), $repo->getOption($name));
                         }
                         continue;
                     }
                     if (in_array($paramNode->getAttribute("name"), $tplDefined)) {
                         continue;
                     }
                     if ($paramNode->getAttribute('no_templates') == 'true') {
                         continue;
                     }
                     print AJXP_XMLWriter::replaceAjxpXmlKeywords($paramNode->ownerDocument->saveXML($paramNode));
                 }
                 // ADD LABEL
                 echo '<param name="DISPLAY" type="string" label="' . $mess[359] . '" description="' . $mess[429] . '" mandatory="true" default="' . $defaultLabel . '"/>';
                 print "</template>";
             }
             AJXP_XMLWriter::close("repository_templates");
             break;
         case "user_create_repository":
             $tplId = $httpVars["template_id"];
             $tplRepo = ConfService::getRepositoryById($tplId);
             $options = array();
             AJXP_Utils::parseStandardFormParameters($httpVars, $options);
             $loggedUser = AuthService::getLoggedUser();
             $newRep = $tplRepo->createTemplateChild(AJXP_Utils::sanitize($httpVars["DISPLAY"]), $options, null, $loggedUser->getId());
             $gPath = $loggedUser->getGroupPath();
             if (!empty($gPath)) {
                 $newRep->setGroupPath($gPath);
             }
             $res = ConfService::addRepository($newRep);
             AJXP_XMLWriter::header();
             if ($res == -1) {
                 AJXP_XMLWriter::sendMessage(null, $mess[426]);
             } else {
                 // Make sure we do not overwrite otherwise loaded rights.
                 $loggedUser->load();
                 $loggedUser->personalRole->setAcl($newRep->getUniqueId(), "rw");
                 $loggedUser->save("superuser");
                 $loggedUser->recomputeMergedRole();
                 AuthService::updateUser($loggedUser);
                 AJXP_XMLWriter::sendMessage($mess[425], null);
                 AJXP_XMLWriter::reloadDataNode("", $newRep->getUniqueId());
                 AJXP_XMLWriter::reloadRepositoryList();
             }
             AJXP_XMLWriter::close();
             break;
         case "user_delete_repository":
             $repoId = $httpVars["repository_id"];
             $repository = ConfService::getRepositoryById($repoId);
             if (!$repository->getUniqueUser() || $repository->getUniqueUser() != AuthService::getLoggedUser()->getId()) {
                 throw new Exception("You are not allowed to perform this operation!");
             }
             $res = ConfService::deleteRepository($repoId);
             AJXP_XMLWriter::header();
             if ($res == -1) {
                 AJXP_XMLWriter::sendMessage(null, $mess[427]);
             } else {
                 $loggedUser = AuthService::getLoggedUser();
                 // Make sure we do not override remotely set rights
                 $loggedUser->load();
                 $loggedUser->personalRole->setAcl($repoId, "");
                 $loggedUser->save("superuser");
                 AuthService::updateUser($loggedUser);
                 AJXP_XMLWriter::sendMessage($mess[428], null);
                 AJXP_XMLWriter::reloadRepositoryList();
             }
             AJXP_XMLWriter::close();
             break;
         case "user_delete_user":
             $userId = $httpVars["user_id"];
             $userObject = ConfService::getConfStorageImpl()->createUserObject($userId);
             if ($userObject == null || !$userObject->hasParent() || $userObject->getParent() != AuthService::getLoggedUser()->getId()) {
                 throw new Exception("You are not allowed to edit this user");
             }
             AuthService::deleteUser($userId);
             echo "SUCCESS";
             break;
         case "user_list_authorized_users":
             $defaultFormat = "html";
             HTMLWriter::charsetHeader();
             if (!ConfService::getAuthDriverImpl()->usersEditable()) {
                 break;
             }
             $loggedUser = AuthService::getLoggedUser();
             $crtValue = $httpVars["value"];
             $usersOnly = isset($httpVars["users_only"]) && $httpVars["users_only"] == "true";
             $existingOnly = isset($httpVars["existing_only"]) && $httpVars["existing_only"] == "true";
             if (!empty($crtValue)) {
                 $regexp = '^' . $crtValue;
             } else {
                 $regexp = null;
             }
             $skipDisplayWithoutRegexp = ConfService::getCoreConf("USERS_LIST_REGEXP_MANDATORY", "conf");
             if ($skipDisplayWithoutRegexp && $regexp == null) {
                 print "<ul></ul>";
                 break;
             }
             $limit = intval(ConfService::getCoreConf("USERS_LIST_COMPLETE_LIMIT", "conf"));
             $searchAll = ConfService::getCoreConf("CROSSUSERS_ALLGROUPS", "conf");
             $displayAll = ConfService::getCoreConf("CROSSUSERS_ALLGROUPS_DISPLAY", "conf");
             $baseGroup = "/";
             if ($regexp == null && !$displayAll || $regexp != null && !$searchAll) {
                 $baseGroup = AuthService::filterBaseGroup("/");
             }
             AuthService::setGroupFiltering(false);
             $allUsers = AuthService::listUsers($baseGroup, $regexp, 0, $limit, false);
             if (!$usersOnly) {
                 $allGroups = array();
                 $roleOrGroup = ConfService::getCoreConf("GROUP_OR_ROLE", "conf");
                 $rolePrefix = $excludeString = $includeString = null;
                 if (!is_array($roleOrGroup)) {
                     $roleOrGroup = array("group_switch_value" => $roleOrGroup);
                 }
                 $listRoleType = false;
                 if (isset($roleOrGroup["PREFIX"])) {
                     $rolePrefix = $loggedUser->mergedRole->filterParameterValue("core.conf", "PREFIX", null, $roleOrGroup["PREFIX"]);
                     $excludeString = $loggedUser->mergedRole->filterParameterValue("core.conf", "EXCLUDED", null, $roleOrGroup["EXCLUDED"]);
                     $includeString = $loggedUser->mergedRole->filterParameterValue("core.conf", "INCLUDED", null, $roleOrGroup["INCLUDED"]);
                     $listUserRolesOnly = $loggedUser->mergedRole->filterParameterValue("core.conf", "LIST_ROLE_BY", null, $roleOrGroup["LIST_ROLE_BY"]);
                     if (is_array($listUserRolesOnly) && isset($listUserRolesOnly["group_switch_value"])) {
                         switch ($listUserRolesOnly["group_switch_value"]) {
                             case "userroles":
                                 $listRoleType = true;
                                 break;
                             case "allroles":
                                 $listRoleType = false;
                                 break;
                             default:
                                 break;
                         }
                     }
                 }
                 switch (strtolower($roleOrGroup["group_switch_value"])) {
                     case 'user':
                         // donothing
                         break;
                     case 'group':
                         $authGroups = AuthService::listChildrenGroups($baseGroup);
                         foreach ($authGroups as $gId => $gName) {
                             $allGroups["AJXP_GRP_" . rtrim($baseGroup, "/") . "/" . ltrim($gId, "/")] = $gName;
                         }
                         break;
                     case 'role':
                         $allGroups = $this->getUserRoleList($loggedUser, $rolePrefix, $includeString, $excludeString, $listRoleType);
                         break;
                     case 'rolegroup':
                         $groups = array();
                         $authGroups = AuthService::listChildrenGroups($baseGroup);
                         foreach ($authGroups as $gId => $gName) {
                             $groups["AJXP_GRP_" . rtrim($baseGroup, "/") . "/" . ltrim($gId, "/")] = $gName;
                         }
                         $roles = $this->getUserRoleList($loggedUser, $rolePrefix, $includeString, $excludeString, $listRoleType);
                         empty($groups) ? $allGroups = $roles : (empty($roles) ? $allGroups = $groups : ($allGroups = array_merge($groups, $roles)));
                         //$allGroups = array_merge($groups, $roles);
                         break;
                     default:
                         break;
                 }
             }
             $users = "";
             $index = 0;
             if ($regexp != null && (!count($allUsers) || !empty($crtValue) && !array_key_exists(strtolower($crtValue), $allUsers)) && ConfService::getCoreConf("USER_CREATE_USERS", "conf") && !$existingOnly) {
                 $users .= "<li class='complete_user_entry_temp' data-temporary='true' data-label='{$crtValue}'><span class='user_entry_label'>{$crtValue} (" . $mess["448"] . ")</span></li>";
             } else {
                 if ($existingOnly && !empty($crtValue)) {
                     $users .= "<li class='complete_user_entry_temp' data-temporary='true' data-label='{$crtValue}' data-entry_id='{$crtValue}'><span class='user_entry_label'>{$crtValue}</span></li>";
                 }
             }
             $mess = ConfService::getMessages();
             if ($regexp == null && !$usersOnly) {
                 $users .= "<li class='complete_group_entry' data-group='AJXP_GRP_/' data-label='" . $mess["447"] . "'><span class='user_entry_label'>" . $mess["447"] . "</span></li>";
             }
             $indexGroup = 0;
             if (!$usersOnly && is_array($allGroups)) {
                 foreach ($allGroups as $groupId => $groupLabel) {
                     if ($regexp == null || preg_match("/{$regexp}/i", $groupLabel)) {
                         $users .= "<li class='complete_group_entry' data-group='{$groupId}' data-label='{$groupLabel}' data-entry_id='{$groupId}'><span class='user_entry_label'>" . $groupLabel . "</span></li>";
                         $indexGroup++;
                     }
                     if ($indexGroup == $limit) {
                         break;
                     }
                 }
             }
             if ($regexp == null && method_exists($this, "listUserTeams")) {
                 $teams = $this->listUserTeams();
                 foreach ($teams as $tId => $tData) {
                     $users .= "<li class='complete_group_entry' data-group='/AJXP_TEAM/{$tId}' data-label='[team] " . $tData["LABEL"] . "'><span class='user_entry_label'>[team] " . $tData["LABEL"] . "</span></li>";
                 }
             }
             foreach ($allUsers as $userId => $userObject) {
                 if ($userObject->getId() == $loggedUser->getId()) {
                     continue;
                 }
                 if (!$userObject->hasParent() && ConfService::getCoreConf("ALLOW_CROSSUSERS_SHARING", "conf") || $userObject->getParent() == $loggedUser->getId()) {
                     $userLabel = $userObject->personalRole->filterParameterValue("core.conf", "USER_DISPLAY_NAME", AJXP_REPO_SCOPE_ALL, $userId);
                     //if($regexp != null && ! (preg_match("/$regexp/i", $userId) || preg_match("/$regexp/i", $userLabel)) ) continue;
                     if (empty($userLabel)) {
                         $userLabel = $userId;
                     }
                     $userDisplay = $userLabel == $userId ? $userId : $userLabel . " ({$userId})";
                     if (ConfService::getCoreConf("USERS_LIST_HIDE_LOGIN", "conf") == true && $userLabel != $userId) {
                         $userDisplay = $userLabel;
                     }
                     $users .= "<li class='complete_user_entry' data-label='{$userLabel}' data-entry_id='{$userId}'><span class='user_entry_label'>" . $userDisplay . "</span></li>";
                     $index++;
                 }
                 if ($index == $limit) {
                     break;
                 }
             }
             if (strlen($users)) {
                 print "<ul>" . $users . "</ul>";
             }
             AuthService::setGroupFiltering(true);
             break;
         case "load_repository_info":
             $data = array();
             $repo = ConfService::getRepository();
             if ($repo != null) {
                 $users = AuthService::countUsersForRepository(ConfService::getRepository()->getId(), true);
                 $data["core.users"] = $users;
                 if (isset($httpVars["collect"]) && $httpVars["collect"] == "true") {
                     AJXP_Controller::applyHook("repository.load_info", array(&$data));
                 }
             }
             HTMLWriter::charsetHeader("application/json");
             echo json_encode($data);
             break;
         case "get_binary_param":
             if (isset($httpVars["tmp_file"])) {
                 $file = AJXP_Utils::getAjxpTmpDir() . "/" . AJXP_Utils::securePath($httpVars["tmp_file"]);
                 if (isset($file)) {
                     header("Content-Type:image/png");
                     readfile($file);
                 }
             } else {
                 if (isset($httpVars["binary_id"])) {
                     if (isset($httpVars["user_id"]) && AuthService::getLoggedUser() != null && AuthService::getLoggedUser()->isAdmin()) {
                         $context = array("USER" => $httpVars["user_id"]);
                     } else {
                         $context = array("USER" => AuthService::getLoggedUser()->getId());
                     }
                     $this->loadBinary($context, $httpVars["binary_id"]);
                 }
             }
             break;
         case "get_global_binary_param":
             if (isset($httpVars["tmp_file"])) {
                 $file = AJXP_Utils::getAjxpTmpDir() . "/" . AJXP_Utils::securePath($httpVars["tmp_file"]);
                 if (isset($file)) {
                     header("Content-Type:image/png");
                     readfile($file);
                 }
             } else {
                 if (isset($httpVars["binary_id"])) {
                     $this->loadBinary(array(), $httpVars["binary_id"]);
                 }
             }
             break;
         case "store_binary_temp":
             if (count($fileVars)) {
                 $keys = array_keys($fileVars);
                 $boxData = $fileVars[$keys[0]];
                 $err = AJXP_Utils::parseFileDataErrors($boxData);
                 if ($err != null) {
                 } else {
                     $rand = substr(md5(time()), 0, 6);
                     $tmp = $rand . "-" . $boxData["name"];
                     @move_uploaded_file($boxData["tmp_name"], AJXP_Utils::getAjxpTmpDir() . "/" . $tmp);
                 }
             }
             if (isset($tmp) && file_exists(AJXP_Utils::getAjxpTmpDir() . "/" . $tmp)) {
                 print '<script type="text/javascript">';
                 print 'parent.formManagerHiddenIFrameSubmission("' . $tmp . '");';
                 print '</script>';
             }
             break;
         default:
             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);
     }
     return $xmlBuffer;
 }
コード例 #25
0
 /**
  *
  * Hooked to node.change, this will update the index
  * if $oldNode = null => create node $newNode
  * if $newNode = null => delete node $oldNode
  * Else copy or move oldNode to newNode.
  *
  * @param AJXP_Node $oldNode
  * @param AJXP_Node $newNode
  * @param Boolean $copy
  * @param bool $recursive
  */
 public function updateNodeIndex($oldNode, $newNode = null, $copy = false, $recursive = false)
 {
     require_once "Zend/Search/Lucene.php";
     if (isset($this->currentIndex)) {
         $oldIndex = $newIndex = $this->currentIndex;
     } else {
         if ($oldNode == null) {
             $newIndex = $oldIndex = $this->loadIndex($newNode->getRepositoryId(), true, $newNode->getUser());
         } else {
             if ($newNode == null) {
                 $oldIndex = $newIndex = $this->loadIndex($oldNode->getRepositoryId(), true, $oldNode->getUser());
             } else {
                 $newId = $newNode->getRepositoryId();
                 $oldId = $oldNode->getRepositoryId();
                 if ($newId == $oldId) {
                     $newIndex = $oldIndex = $this->loadIndex($newNode->getRepositoryId(), true, $newNode->getUser());
                 } else {
                     $newIndex = $this->loadIndex($newNode->getRepositoryId(), true, $newNode->getUser());
                     $oldIndex = $this->loadIndex($oldNode->getRepositoryId(), true, $oldNode->getUser());
                 }
             }
         }
     }
     $this->setDefaultAnalyzer();
     if ($oldNode != null && $copy == false) {
         $oldDocId = $this->getIndexedDocumentId($oldIndex, $oldNode);
         if ($oldDocId != null) {
             $oldIndex->delete($oldDocId);
             if ($newNode == null) {
                 // DELETION
                 $childrenHits = $this->getIndexedChildrenDocuments($oldIndex, $oldNode);
                 foreach ($childrenHits as $hit) {
                     $oldIndex->delete($hit->id);
                 }
             }
         }
     }
     if ($newNode != null) {
         // Make sure it does not already exists anyway
         $newDocId = $this->getIndexedDocumentId($newIndex, $newNode);
         if ($newDocId != null) {
             $newIndex->delete($newDocId);
             $childrenHits = $this->getIndexedChildrenDocuments($newIndex, $newNode);
             foreach ($childrenHits as $hit) {
                 $newIndex->delete($hit->id);
             }
         }
         $this->createIndexedDocument($newNode, $newIndex);
         if ($recursive && $oldNode == null && is_dir($newNode->getUrl())) {
             $this->recursiveIndexation($newNode->getUrl());
         }
     }
     if ($oldNode != null && $newNode != null && is_dir($newNode->getUrl()) && $newIndex == $oldIndex) {
         // Copy / Move / Rename
         // Get old node children docs, and update them manually, no need to scan real directory
         $childrenHits = $this->getIndexedChildrenDocuments($oldIndex, $oldNode);
         foreach ($childrenHits as $hit) {
             $oldChildURL = $oldIndex->getDocument($hit->id)->node_url;
             if ($copy == false) {
                 $oldIndex->delete($hit->id);
             }
             $newChildURL = str_replace(SystemTextEncoding::toUTF8($oldNode->getUrl()), SystemTextEncoding::toUTF8($newNode->getUrl()), $oldChildURL);
             $newChildURL = SystemTextEncoding::fromUTF8($newChildURL);
             $this->createIndexedDocument(new AJXP_Node($newChildURL), $oldIndex);
         }
     }
     if (!isset($this->currentIndex)) {
         $oldIndex->commit();
         if ($newIndex != $oldIndex) {
             $newIndex->commit();
         }
     }
 }
コード例 #26
0
 public function deleteSelection($actionName, &$httpVars, $filesVars)
 {
     $init = $this->initDirAndSelection($httpVars, array(), true);
     if (isset($init["RECYCLE"]) && isset($init["RECYCLE"]["action"]) && $init["RECYCLE"]["action"] != "delete") {
         $httpVars["dest"] = SystemTextEncoding::fromUTF8($init["RECYCLE"]["dest"]);
         $this->copyOrMoveSelection("move", $httpVars, $filesVars);
         $userSelection = $init["ORIGINAL_SELECTION"];
         $files = $userSelection->getFiles();
         if ($actionName == "delete") {
             foreach ($files as $file) {
                 RecycleBinManager::fileToRecycle($file);
             }
         } else {
             if ($actionName == "restore") {
                 foreach ($files as $file) {
                     RecycleBinManager::deleteFromRecycle($file);
                 }
             }
         }
         $this->commitChanges($actionName, array("dir" => RecycleBinManager::getRelativeRecycle()), $filesVars);
         return;
     }
     foreach ($init["SELECTION"] as $selectedFile) {
         $res = ExecSvnCmd('svn delete', $selectedFile, '--force');
     }
     $this->commitMessageParams = "[" . implode(",", $init["SELECTION"]) . "]";
     $this->commitChanges($actionName, $httpVars, $filesVars);
     $this->logInfo("Delete (svn delegate)", array("files" => $init["SELECTION"]));
     AJXP_XMLWriter::header();
     AJXP_XMLWriter::sendMessage("The selected files/folders have been deleted (by SVN)", null);
     AJXP_XMLWriter::reloadDataNode();
     AJXP_XMLWriter::close();
 }
コード例 #27
0
 function switchAction($action, $httpVars, $fileVars)
 {
     if (!isset($this->actions[$action])) {
         return;
     }
     $xmlBuffer = "";
     foreach ($httpVars as $getName => $getValue) {
         ${$getName} = Utils::securePath($getValue);
     }
     if (isset($dir) && $action != "upload") {
         $dir = SystemTextEncoding::fromUTF8($dir);
     }
     $mess = ConfService::getMessages();
     switch ($action) {
         //------------------------------------
         //	SWITCH THE ROOT REPOSITORY
         //------------------------------------
         case "switch_root_dir":
             if (!isset($root_dir_index)) {
                 break;
             }
             $dirList = ConfService::getRootDirsList();
             if (!isset($dirList[$root_dir_index])) {
                 $errorMessage = "Trying to switch to an unkown folder!";
                 break;
             }
             ConfService::switchRootDir($root_dir_index);
             $logMessage = "Successfully Switched!";
             AJXP_Logger::logAction("Switch Repository", array("rep. id" => $root_dir_index));
             break;
             //------------------------------------
             //	GET AN HTML TEMPLATE
             //------------------------------------
         //------------------------------------
         //	GET AN HTML TEMPLATE
         //------------------------------------
         case "get_template":
             header("Content-type:text/html; charset:UTF-8");
             if (isset($template_name) && is_file(CLIENT_RESOURCES_FOLDER . "/html/" . $template_name)) {
                 if ($template_name == "gui_tpl.html") {
                     include CLIENT_RESOURCES_FOLDER . "/html/usertemplate_top.html";
                 }
                 include CLIENT_RESOURCES_FOLDER . "/html/" . $template_name;
                 if ($template_name == "gui_tpl.html") {
                     include CLIENT_RESOURCES_FOLDER . "/html/usertemplate_bottom.html";
                 }
             }
             exit(0);
             break;
             //------------------------------------
             //	GET I18N MESSAGES
             //------------------------------------
         //------------------------------------
         //	GET I18N MESSAGES
         //------------------------------------
         case "get_i18n_messages":
             header("Content-type:text/javascript");
             HTMLWriter::writeI18nMessagesClass(ConfService::getMessages());
             exit(0);
             break;
             //------------------------------------
             //	BOOKMARK BAR
             //------------------------------------
         //------------------------------------
         //	BOOKMARK BAR
         //------------------------------------
         case "get_bookmarks":
             $bmUser = null;
             if (AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
                 $bmUser = AuthService::getLoggedUser();
             } else {
                 if (!AuthService::usersEnabled()) {
                     $confStorage = ConfService::getConfStorageImpl();
                     $bmUser = $confStorage->createUserObject("shared");
                 }
             }
             if ($bmUser == null) {
                 exit(1);
             }
             if (isset($_GET["bm_action"]) && isset($_GET["bm_path"])) {
                 if ($_GET["bm_action"] == "add_bookmark") {
                     $title = "";
                     if (isset($_GET["title"])) {
                         $title = $_GET["title"];
                     }
                     if ($title == "" && $_GET["bm_path"] == "/") {
                         $title = ConfService::getCurrentRootDirDisplay();
                     }
                     $bmUser->addBookMark($_GET["bm_path"], $title);
                 } else {
                     if ($_GET["bm_action"] == "delete_bookmark") {
                         $bmUser->removeBookmark($_GET["bm_path"]);
                     } else {
                         if ($_GET["bm_action"] == "rename_bookmark" && isset($_GET["bm_title"])) {
                             $bmUser->renameBookmark($_GET["bm_path"], $_GET["bm_title"]);
                         }
                     }
                 }
             }
             if (AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
                 $bmUser->save();
                 AuthService::updateUser($bmUser);
             } else {
                 if (!AuthService::usersEnabled()) {
                     $bmUser->save();
                 }
             }
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::writeBookmarks($bmUser->getBookmarks());
             AJXP_XMLWriter::close();
             exit(1);
             break;
             //------------------------------------
             //	SAVE USER PREFERENCE
             //------------------------------------
         //------------------------------------
         //	SAVE USER PREFERENCE
         //------------------------------------
         case "save_user_pref":
             $userObject = AuthService::getLoggedUser();
             if ($userObject == null) {
                 exit(1);
             }
             $i = 0;
             while (isset($_GET["pref_name_" . $i]) && isset($_GET["pref_value_" . $i])) {
                 $prefName = $_GET["pref_name_" . $i];
                 $prefValue = $_GET["pref_value_" . $i];
                 if ($prefName != "password") {
                     $userObject->setPref($prefName, $prefValue);
                     $userObject->save();
                     AuthService::updateUser($userObject);
                     setcookie("AJXP_{$prefName}", $prefValue);
                 } else {
                     if (isset($_GET["crt"]) && AuthService::checkPassword($userObject->getId(), $_GET["crt"], false, $_GET["pass_seed"])) {
                         AuthService::updatePassword($userObject->getId(), $prefValue);
                     } else {
                         //$errorMessage = "Wrong password!";
                         header("Content-Type:text/plain");
                         print "PASS_ERROR";
                         exit(1);
                     }
                 }
                 $i++;
             }
             header("Content-Type:text/plain");
             print "SUCCESS";
             exit(1);
             break;
             //------------------------------------
             //	DISPLAY DOC
             //------------------------------------
         //------------------------------------
         //	DISPLAY DOC
         //------------------------------------
         case "display_doc":
             header("Content-type:text/html; charset:UTF-8");
             echo HTMLWriter::getDocFile(htmlentities($_GET["doc_file"]));
             exit(1);
             break;
         default:
             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;
 }
コード例 #28
0
 function switchAction($action, $httpVars, $fileVars)
 {
     if (!isset($this->actions[$action])) {
         return;
     }
     if (preg_match('/MSIE 7/', $_SERVER['HTTP_USER_AGENT']) || preg_match('/MSIE 8/', $_SERVER['HTTP_USER_AGENT'])) {
         // Force legacy theme for the moment
         $this->pluginConf["GUI_THEME"] = "oxygen";
     }
     if (!defined("AJXP_THEME_FOLDER")) {
         define("CLIENT_RESOURCES_FOLDER", AJXP_PLUGINS_FOLDER . "/gui.ajax/res");
         define("AJXP_THEME_FOLDER", CLIENT_RESOURCES_FOLDER . "/themes/" . $this->pluginConf["GUI_THEME"]);
     }
     foreach ($httpVars as $getName => $getValue) {
         ${$getName} = AJXP_Utils::securePath($getValue);
     }
     if (isset($dir) && $action != "upload") {
         $dir = SystemTextEncoding::fromUTF8($dir);
     }
     $mess = ConfService::getMessages();
     switch ($action) {
         //------------------------------------
         //	GET AN HTML TEMPLATE
         //------------------------------------
         case "get_template":
             HTMLWriter::charsetHeader();
             $folder = CLIENT_RESOURCES_FOLDER . "/html";
             if (isset($httpVars["pluginName"])) {
                 $folder = AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/" . AJXP_Utils::securePath($httpVars["pluginName"]);
                 if (isset($httpVars["pluginPath"])) {
                     $folder .= "/" . AJXP_Utils::securePath($httpVars["pluginPath"]);
                 }
             }
             $crtTheme = $this->pluginConf["GUI_THEME"];
             $thFolder = AJXP_THEME_FOLDER . "/html";
             if (isset($template_name)) {
                 if (is_file($thFolder . "/" . $template_name)) {
                     include $thFolder . "/" . $template_name;
                 } else {
                     if (is_file($folder . "/" . $template_name)) {
                         include $folder . "/" . $template_name;
                     }
                 }
             }
             break;
             //------------------------------------
             //	GET I18N MESSAGES
             //------------------------------------
         //------------------------------------
         //	GET I18N MESSAGES
         //------------------------------------
         case "get_i18n_messages":
             $refresh = false;
             if (isset($httpVars["lang"])) {
                 ConfService::setLanguage($httpVars["lang"]);
                 $refresh = true;
             }
             HTMLWriter::charsetHeader('text/javascript');
             HTMLWriter::writeI18nMessagesClass(ConfService::getMessages($refresh));
             break;
             //------------------------------------
             //	SEND XML REGISTRY
             //------------------------------------
         //------------------------------------
         //	SEND XML REGISTRY
         //------------------------------------
         case "get_xml_registry":
             $regDoc = AJXP_PluginsService::getXmlRegistry();
             $changes = AJXP_Controller::filterActionsRegistry($regDoc);
             if ($changes) {
                 AJXP_PluginsService::updateXmlRegistry($regDoc);
             }
             if (isset($_GET["xPath"])) {
                 $regPath = new DOMXPath($regDoc);
                 $nodes = $regPath->query($_GET["xPath"]);
                 AJXP_XMLWriter::header("ajxp_registry_part", array("xPath" => $_GET["xPath"]));
                 if ($nodes->length) {
                     print AJXP_XMLWriter::replaceAjxpXmlKeywords($regDoc->saveXML($nodes->item(0)));
                 }
                 AJXP_XMLWriter::close("ajxp_registry_part");
             } else {
                 AJXP_Utils::safeIniSet("zlib.output_compression", "4096");
                 header('Content-Type: application/xml; charset=UTF-8');
                 print AJXP_XMLWriter::replaceAjxpXmlKeywords($regDoc->saveXML());
             }
             break;
             //------------------------------------
             //	DISPLAY DOC
             //------------------------------------
         //------------------------------------
         //	DISPLAY DOC
         //------------------------------------
         case "display_doc":
             HTMLWriter::charsetHeader();
             echo HTMLWriter::getDocFile(AJXP_Utils::securePath(htmlentities($_GET["doc_file"])));
             break;
             //------------------------------------
             //	GET BOOT GUI
             //------------------------------------
         //------------------------------------
         //	GET BOOT GUI
         //------------------------------------
         case "get_boot_gui":
             header("X-UA-Compatible: chrome=1");
             HTMLWriter::charsetHeader();
             if (!is_file(TESTS_RESULT_FILE)) {
                 $outputArray = array();
                 $testedParams = array();
                 $passed = AJXP_Utils::runTests($outputArray, $testedParams);
                 if (!$passed && !isset($_GET["ignore_tests"])) {
                     die(AJXP_Utils::testResultsToTable($outputArray, $testedParams));
                 } else {
                     AJXP_Utils::testResultsToFile($outputArray, $testedParams);
                 }
             }
             $START_PARAMETERS = array("BOOTER_URL" => "index.php?get_action=get_boot_conf", "MAIN_ELEMENT" => "ajxp_desktop");
             if (AuthService::usersEnabled()) {
                 AuthService::preLogUser(isset($httpVars["remote_session"]) ? $httpVars["remote_session"] : "");
                 AuthService::bootSequence($START_PARAMETERS);
                 if (AuthService::getLoggedUser() != null || AuthService::logUser(null, null) == 1) {
                     if (AuthService::getDefaultRootId() == -1) {
                         AuthService::disconnect();
                     } else {
                         $loggedUser = AuthService::getLoggedUser();
                         if (!$loggedUser->canRead(ConfService::getCurrentRootDirIndex()) && AuthService::getDefaultRootId() != ConfService::getCurrentRootDirIndex()) {
                             ConfService::switchRootDir(AuthService::getDefaultRootId());
                         }
                     }
                 }
             }
             AJXP_Utils::parseApplicationGetParameters($_GET, $START_PARAMETERS, $_SESSION);
             $confErrors = ConfService::getErrors();
             if (count($confErrors)) {
                 $START_PARAMETERS["ALERT"] = implode(", ", array_values($confErrors));
             }
             $JSON_START_PARAMETERS = json_encode($START_PARAMETERS);
             $crtTheme = $this->pluginConf["GUI_THEME"];
             if (ConfService::getConf("JS_DEBUG")) {
                 if (!isset($mess)) {
                     $mess = ConfService::getMessages();
                 }
                 if (is_file(AJXP_INSTALL_PATH . "/plugins/gui.ajax/res/themes/{$crtTheme}/html/gui_debug.html")) {
                     include AJXP_INSTALL_PATH . "/plugins/gui.ajax/res/themes/{$crtTheme}/html/gui_debug.html";
                 } else {
                     include AJXP_INSTALL_PATH . "/plugins/gui.ajax/res/html/gui_debug.html";
                 }
             } else {
                 if (is_file(AJXP_INSTALL_PATH . "/plugins/gui.ajax/res/themes/{$crtTheme}/html/gui.html")) {
                     $content = file_get_contents(AJXP_INSTALL_PATH . "/plugins/gui.ajax/res/themes/{$crtTheme}/html/gui.html");
                 } else {
                     $content = file_get_contents(AJXP_INSTALL_PATH . "/plugins/gui.ajax/res/html/gui.html");
                 }
                 if (preg_match('/MSIE 7/', $_SERVER['HTTP_USER_AGENT']) || preg_match('/MSIE 8/', $_SERVER['HTTP_USER_AGENT'])) {
                     $content = str_replace("ajaxplorer_boot.js", "ajaxplorer_boot_protolegacy.js", $content);
                 }
                 $content = AJXP_XMLWriter::replaceAjxpXmlKeywords($content, false);
                 if ($JSON_START_PARAMETERS) {
                     $content = str_replace("//AJXP_JSON_START_PARAMETERS", "startParameters = " . $JSON_START_PARAMETERS . ";", $content);
                 }
                 print $content;
             }
             break;
             //------------------------------------
             //	GET CONFIG FOR BOOT
             //------------------------------------
         //------------------------------------
         //	GET CONFIG FOR BOOT
         //------------------------------------
         case "get_boot_conf":
             if (isset($_GET["server_prefix_uri"])) {
                 $_SESSION["AJXP_SERVER_PREFIX_URI"] = $_GET["server_prefix_uri"];
             }
             $config = array();
             $config["ajxpResourcesFolder"] = "plugins/gui.ajax/res";
             $config["ajxpServerAccess"] = AJXP_SERVER_ACCESS;
             $config["zipEnabled"] = ConfService::zipEnabled();
             $config["multipleFilesDownloadEnabled"] = ConfService::getCoreConf("ZIP_CREATION");
             $config["customWording"] = array("welcomeMessage" => $this->pluginConf["CUSTOM_WELCOME_MESSAGE"], "title" => ConfService::getCoreConf("APPLICATION_TITLE"), "icon" => $this->pluginConf["CUSTOM_ICON"], "iconWidth" => $this->pluginConf["CUSTOM_ICON_WIDTH"], "iconHeight" => $this->pluginConf["CUSTOM_ICON_HEIGHT"], "iconOnly" => $this->pluginConf["CUSTOM_ICON_ONLY"], "titleFontSize" => $this->pluginConf["CUSTOM_FONT_SIZE"]);
             $config["usersEnabled"] = AuthService::usersEnabled();
             $config["loggedUser"] = AuthService::getLoggedUser() != null;
             $config["currentLanguage"] = ConfService::getLanguage();
             $config["session_timeout"] = intval(ini_get("session.gc_maxlifetime"));
             if (!isset($this->pluginConf["CLIENT_TIMEOUT_TIME"]) || $this->pluginConf["CLIENT_TIMEOUT_TIME"] == "") {
                 $to = $config["session_timeout"];
             } else {
                 $to = $this->pluginConf["CLIENT_TIMEOUT_TIME"];
             }
             $config["client_timeout"] = $to;
             $config["client_timeout_warning"] = $this->pluginConf["CLIENT_TIMEOUT_WARN"];
             $config["availableLanguages"] = ConfService::getConf("AVAILABLE_LANG");
             $config["usersEditable"] = ConfService::getAuthDriverImpl()->usersEditable();
             $config["ajxpVersion"] = AJXP_VERSION;
             $config["ajxpVersionDate"] = AJXP_VERSION_DATE;
             if (stristr($_SERVER["HTTP_USER_AGENT"], "msie 6")) {
                 $config["cssResources"] = array("css/pngHack/pngHack.css");
             }
             if (!empty($this->pluginConf['GOOGLE_ANALYTICS_ID'])) {
                 $config["googleAnalyticsData"] = array("id" => $this->pluginConf['GOOGLE_ANALYTICS_ID'], "domain" => $this->pluginConf['GOOGLE_ANALYTICS_DOMAIN'], "event" => $this->pluginConf['GOOGLE_ANALYTICS_EVENT']);
             }
             $config["i18nMessages"] = ConfService::getMessages();
             $config["password_min_length"] = ConfService::getCoreConf("PASSWORD_MINLENGTH", "auth");
             $config["SECURE_TOKEN"] = AuthService::generateSecureToken();
             $config["streaming_supported"] = "true";
             $config["theme"] = $this->pluginConf["GUI_THEME"];
             header("Content-type:application/json;charset=UTF-8");
             print json_encode($config);
             break;
         default:
             break;
     }
     return false;
 }
コード例 #29
0
 /**
  * Catch exceptions, @see catchError
  * @param Exception $exception
  */
 public static function catchException($exception)
 {
     try {
         AJXP_XMLWriter::catchError($exception->getCode(), SystemTextEncoding::fromUTF8($exception->getMessage()), $exception->getFile(), $exception->getLine(), $exception);
     } catch (Exception $innerEx) {
         error_log(get_class($innerEx) . " thrown within the exception handler!");
         error_log("Original exception was: " . $innerEx->getMessage() . " in " . $innerEx->getFile() . " on line " . $innerEx->getLine());
         error_log("New exception is: " . $innerEx->getMessage() . " in " . $innerEx->getFile() . " on line " . $innerEx->getLine() . " " . $innerEx->getTraceAsString());
         print "Error";
     }
 }
コード例 #30
-1
 public function switchAction($action, $httpVars, $filesVars)
 {
     if (!isset($this->actions[$action])) {
         return false;
     }
     $repository = ConfService::getRepository();
     if (!$repository->detectStreamWrapper(true)) {
         return false;
     }
     $streamData = $repository->streamData;
     $destStreamURL = $streamData["protocol"] . "://" . $repository->getId();
     if ($action == "post_to_zohoserver") {
         $sheetExt = explode(",", "xls,xlsx,ods,sxc,csv,tsv");
         $presExt = explode(",", "ppt,pps,odp,sxi");
         $docExt = explode(",", "doc,docx,rtf,odt,sxw");
         require_once AJXP_BIN_FOLDER . "/http_class/http_class.php";
         $selection = new UserSelection($repository, $httpVars);
         // Backward compat
         if (strpos($httpVars["file"], "base64encoded:") !== 0) {
             $file = AJXP_Utils::decodeSecureMagic(base64_decode($httpVars["file"]));
         } else {
             $file = $selection->getUniqueFile();
         }
         $target = base64_decode($httpVars["parent_url"]);
         $tmp = call_user_func(array($streamData["classname"], "getRealFSReference"), $destStreamURL . $file);
         $tmp = SystemTextEncoding::fromUTF8($tmp);
         $node = new AJXP_Node($destStreamURL . $file);
         AJXP_Controller::applyHook("node.read", array($node));
         $this->logInfo('Preview', 'Posting content of ' . $file . ' to Zoho server');
         $extension = strtolower(pathinfo(urlencode(basename($file)), PATHINFO_EXTENSION));
         $httpClient = new http_class();
         $httpClient->request_method = "POST";
         $secureToken = $httpVars["secure_token"];
         $_SESSION["ZOHO_CURRENT_EDITED"] = $destStreamURL . $file;
         $_SESSION["ZOHO_CURRENT_UUID"] = md5(rand() . "-" . microtime());
         if ($this->getFilteredOption("USE_ZOHO_AGENT", $repository->getId())) {
             $saveUrl = $this->getFilteredOption("ZOHO_AGENT_URL", $repository->getId());
         } else {
             $saveUrl = $target . "/" . AJXP_PLUGINS_FOLDER . "/editor.zoho/agent/save_zoho.php";
         }
         $b64Sig = $this->signID($_SESSION["ZOHO_CURRENT_UUID"]);
         $params = array('id' => $_SESSION["ZOHO_CURRENT_UUID"], 'apikey' => $this->getFilteredOption("ZOHO_API_KEY", $repository->getId()), 'output' => 'url', 'lang' => "en", 'filename' => urlencode(basename($file)), 'persistence' => 'false', 'format' => $extension, 'mode' => 'normaledit', 'saveurl' => $saveUrl . "?signature=" . $b64Sig);
         $service = "exportwriter";
         if (in_array($extension, $sheetExt)) {
             $service = "sheet";
         } else {
             if (in_array($extension, $presExt)) {
                 $service = "show";
             } else {
                 if (in_array($extension, $docExt)) {
                     $service = "exportwriter";
                 }
             }
         }
         $arguments = array();
         $httpClient->GetRequestArguments("https://" . $service . ".zoho.com/remotedoc.im", $arguments);
         $arguments["PostValues"] = $params;
         $arguments["PostFiles"] = array("content" => array("FileName" => $tmp, "Content-Type" => "automatic/name"));
         $err = $httpClient->Open($arguments);
         if (empty($err)) {
             $err = $httpClient->SendRequest($arguments);
             if (empty($err)) {
                 $response = "";
                 while (true) {
                     $body = "";
                     $error = $httpClient->ReadReplyBody($body, 1000);
                     if ($error != "" || strlen($body) == 0) {
                         break;
                     }
                     $response .= $body;
                 }
                 $result = trim($response);
                 $matchlines = explode("\n", $result);
                 $resultValues = array();
                 foreach ($matchlines as $line) {
                     list($key, $val) = explode("=", $line, 2);
                     $resultValues[$key] = $val;
                 }
                 if ($resultValues["RESULT"] == "TRUE" && isset($resultValues["URL"])) {
                     header("Location: " . $resultValues["URL"]);
                 } else {
                     echo "Zoho API Error " . $resultValues["ERROR_CODE"] . " : " . $resultValues["WARNING"];
                     echo "<script>window.parent.setTimeout(function(){parent.hideLightBox();}, 2000);</script>";
                 }
             }
             $httpClient->Close();
         }
     } else {
         if ($action == "retrieve_from_zohoagent") {
             $targetFile = $_SESSION["ZOHO_CURRENT_EDITED"];
             $id = $_SESSION["ZOHO_CURRENT_UUID"];
             $ext = pathinfo($targetFile, PATHINFO_EXTENSION);
             $node = new AJXP_Node($targetFile);
             $node->loadNodeInfo();
             AJXP_Controller::applyHook("node.before_change", array(&$node));
             $b64Sig = $this->signID($id);
             if ($this->getFilteredOption("USE_ZOHO_AGENT", $repository->getId())) {
                 $url = $this->getFilteredOption("ZOHO_AGENT_URL", $repository->getId()) . "?ajxp_action=get_file&name=" . $id . "&ext=" . $ext . "&signature=" . $b64Sig;
                 $data = AJXP_Utils::getRemoteContent($url);
                 if (strlen($data)) {
                     file_put_contents($targetFile, $data);
                     echo "MODIFIED";
                 }
             } else {
                 if (is_file(AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/editor.zoho/agent/files/" . $id . "." . $ext)) {
                     copy(AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/editor.zoho/agent/files/" . $id . "." . $ext, $targetFile);
                     unlink(AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/editor.zoho/agent/files/" . $id . "." . $ext);
                     echo "MODIFIED";
                 }
             }
             $this->logInfo('Edit', 'Retrieved content of ' . $node->getUrl());
             AJXP_Controller::applyHook("node.change", array(null, &$node));
         }
     }
 }