/** * Initialize the stream from the given path. * Concretely, transform ajxp.smb:// into smb:// * * @param string $path * @return mixed Real path or -1 if currentListing contains the listing : original path converted to real path */ protected static function initPath($path, $streamType, $storeOpenContext = false, $skipZip = false) { $url = parse_url($path); $repoId = $url["host"]; $repoObject = ConfService::getRepositoryById($repoId); if (!isset($repoObject)) { throw new Exception("Cannot find repository with id " . $repoId); } $path = $url["path"]; // Fix if the host is defined as //MY_HOST/path/to/folder $host = str_replace("//", "", $repoObject->getOption("HOST")); $credentials = ""; $safeCreds = AJXP_Safe::tryLoadingCredentialsFromSources($url, $repoObject); if ($safeCreds["user"] != "" && $safeCreds["password"] != "") { $login = $safeCreds["user"]; $pass = $safeCreds["password"]; $_SESSION["AJXP_SESSION_REMOTE_PASS"] = $pass; $credentials = "{$login}:{$pass}@"; $domain = $repoObject->getOption("DOMAIN"); if ($domain != "") { $credentials = $domain . "/" . $credentials; } } $basePath = $repoObject->getOption("PATH"); $fullPath = "smb://" . $credentials . $host . "/"; //.$basePath."/".$path; if ($basePath != "") { $fullPath .= trim($basePath, "/\\"); } if ($path != "") { $fullPath .= ($path[0] == "/" ? "" : "/") . $path; } return $fullPath; }
public function toggleDisclaimer($actionName, $httpVars, $fileVars) { $u = AuthService::getLoggedUser(); $u->personalRole->setParameterValue("action.disclaimer", "DISCLAIMER_ACCEPTED", $httpVars["validate"] == "true" ? "yes" : "no", AJXP_REPO_SCOPE_ALL); if ($httpVars["validate"] == "true") { $u->removeLock(); $u->save("superuser"); AuthService::updateUser($u); ConfService::switchUserToActiveRepository($u); $force = $u->mergedRole->filterParameterValue("core.conf", "DEFAULT_START_REPOSITORY", AJXP_REPO_SCOPE_ALL, -1); $passId = -1; if ($force != "" && $u->canSwitchTo($force) && !isset($httpVars["tmp_repository_id"]) && !isset($_SESSION["PENDING_REPOSITORY_ID"])) { $passId = $force; } $res = ConfService::switchUserToActiveRepository($u, $passId); if (!$res) { AuthService::disconnect(); AJXP_XMLWriter::header(); AJXP_XMLWriter::requireAuth(true); AJXP_XMLWriter::close(); } ConfService::getInstance()->invalidateLoadedRepositories(); } else { $u->setLock("validate_disclaimer"); $u->save("superuser"); AuthService::disconnect(); AJXP_XMLWriter::header(); AJXP_XMLWriter::requireAuth(true); AJXP_XMLWriter::close(); } }
public function unifyChunks($action, $httpVars, $fileVars) { $repository = ConfService::getRepository(); if (!$repository->detectStreamWrapper(false)) { return false; } $plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType()); $streamData = $plugin->detectStreamWrapper(true); $dir = AJXP_Utils::decodeSecureMagic($httpVars["dir"]); $destStreamURL = $streamData["protocol"] . "://" . $repository->getId() . $dir . "/"; $filename = AJXP_Utils::decodeSecureMagic($httpVars["file_name"]); $chunks = array(); $index = 0; while (isset($httpVars["chunk_" . $index])) { $chunks[] = AJXP_Utils::decodeSecureMagic($httpVars["chunk_" . $index]); $index++; } $newDest = fopen($destStreamURL . $filename, "w"); for ($i = 0; $i < count($chunks); $i++) { $part = fopen($destStreamURL . $chunks[$i], "r"); while (!feof($part)) { fwrite($newDest, fread($part, 4096)); } fclose($part); unlink($destStreamURL . $chunks[$i]); } fclose($newDest); }
function ajxp_gluecode_updateRole($loginData, &$userObject) { $authPlug = ConfService::getAuthDriverImpl(); if (property_exists($authPlug, "drivers") && is_array($authPlug->drivers) && $authPlug->drivers["remote"]) { $authPlug = $authPlug->drivers["remote"]; } $rolesMap = $authPlug->getOption("ROLES_MAP"); if (!isset($rolesMap) || strlen($rolesMap) == 0) { return; } // String like {key:value,key2:value2,key3:value3} $rolesMap = explode(",", $rolesMap); $newMap = array(); foreach ($rolesMap as $value) { $parts = explode(":", trim($value)); $roleId = trim($parts[1]); $roleObject = AuthService::getRole($roleId); if ($roleObject != null) { $newMap[trim($parts[0])] = $roleObject; $userObject->removeRole($roleId); } } $rolesMap = $newMap; if (isset($loginData["roles"]) && is_array($loginData["roles"])) { foreach ($loginData["roles"] as $role) { if (isset($rolesMap[$role])) { $userObject->addRole($rolesMap[$role]); } } } }
function buildPublicHtaccessContent() { $downloadFolder = ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER"); $dlURL = ConfService::getCoreConf("PUBLIC_DOWNLOAD_URL"); if ($dlURL != "") { $url = rtrim($dlURL, "/"); } else { $fullUrl = AJXP_Utils::detectServerURL(true); $url = str_replace("\\", "/", rtrim($fullUrl, "/") . rtrim(str_replace(AJXP_INSTALL_PATH, "", $downloadFolder), "/")); } $htaccessContent = "Order Deny,Allow\nAllow from all\n"; $htaccessContent .= "\n<Files \".ajxp_*\">\ndeny from all\n</Files>\n"; $path = parse_url($url, PHP_URL_PATH); $htaccessContent .= ' <IfModule mod_rewrite.c> RewriteEngine on RewriteBase ' . $path . ' RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-zA-Z0-9_-]+)\\.php$ share.php?hash=$1 [QSA] RewriteRule ^([a-zA-Z0-9_-]+)--([a-z]+)$ share.php?hash=$1&lang=$2 [QSA] RewriteRule ^([a-zA-Z0-9_-]+)$ share.php?hash=$1 [QSA] </IfModule> '; return $htaccessContent; }
public function switchActions($actionName, $httpVars, $fileVars) { switch ($actionName) { case "accept_invitation": $remoteShareId = \AJXP_Utils::sanitize($httpVars["remote_share_id"], AJXP_SANITIZE_ALPHANUM); $store = new SQLStore(); $remoteShare = $store->remoteShareById($remoteShareId); if ($remoteShare !== null) { $client = new OCSClient(); $client->acceptInvitation($remoteShare); $remoteShare->setStatus(OCS_INVITATION_STATUS_ACCEPTED); $store->storeRemoteShare($remoteShare); } break; case "reject_invitation": $remoteShareId = \AJXP_Utils::sanitize($httpVars["remote_share_id"], AJXP_SANITIZE_ALPHANUM); $store = new SQLStore(); $remoteShare = $store->remoteShareById($remoteShareId); if ($remoteShare !== null) { $client = new OCSClient(); $client->declineInvitation($remoteShare); $store->deleteRemoteShare($remoteShare); \ConfService::getInstance()->invalidateLoadedRepositories(); } break; default: break; } return null; }
public function checkPassword($login, $pass, $seed) { require_once AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/access.smb/smb.php"; $_SESSION["AJXP_SESSION_REMOTE_PASS"] = $pass; $repoId = $this->options["REPOSITORY_ID"]; $repoObject = ConfService::getRepositoryById($repoId); if (!isset($repoObject)) { throw new Exception("Cannot find repository with id " . $repoId); } $path = ""; $basePath = $repoObject->getOption("PATH", true); $basePath = str_replace("AJXP_USER", $login, $basePath); $host = $repoObject->getOption("HOST"); $url = "smb://{$login}:{$pass}@" . $host . "/" . $basePath . "/"; try { if (!is_dir($url)) { $this->logDebug("SMB Login failure"); $_SESSION["AJXP_SESSION_REMOTE_PASS"] = ''; unset($_SESSION["COUNT"]); unset($_SESSION["disk"]); return false; } AJXP_Safe::storeCredentials($login, $pass); } catch (Exception $e) { return false; } return true; }
public function initRepository() { if (is_array($this->pluginConf)) { $this->driverConf = $this->pluginConf; } else { $this->driverConf = array(); } if (!function_exists('ssh2_connect')) { throw new Exception("You must have the php ssh2 extension active!"); } ConfService::setConf("PROBE_REAL_SIZE", false); $path = $this->repository->getOption("PATH"); $recycle = $this->repository->getOption("RECYCLE_BIN"); $this->detectStreamWrapper(true); $this->urlBase = "pydio://" . $this->repository->getId(); restore_error_handler(); if (!file_exists($this->urlBase)) { if ($this->repository->getOption("CREATE")) { $test = @mkdir($this->urlBase); if (!$test) { throw new AJXP_Exception("Cannot create path ({$path}) for your repository! Please check the configuration."); } } else { throw new AJXP_Exception("Cannot find base path ({$path}) for your repository! Please check the configuration!"); } } if ($recycle != "") { RecycleBinManager::init($this->urlBase, "/" . $recycle); } }
public function __construct() { $storage = \ConfService::getConfStorageImpl(); if ($storage->getId() == "conf.sql") { $this->storage = $storage; } }
public function switchAction($action, $httpVars, $fileVars) { if (!isset($this->actions[$action])) { return; } $mess = ConfService::getMessages(); switch ($action) { //------------------------------------ // CHANGE USER PASSWORD //------------------------------------ case "pass_change": $userObject = AuthService::getLoggedUser(); if ($userObject == null || $userObject->getId() == "guest") { header("Content-Type:text/plain"); print "SUCCESS"; } $oldPass = $httpVars["old_pass"]; $newPass = $httpVars["new_pass"]; $passSeed = $httpVars["pass_seed"]; if (AuthService::checkPassword($userObject->getId(), $oldPass, false, $passSeed)) { AuthService::updatePassword($userObject->getId(), $newPass); } else { header("Content-Type:text/plain"); print "PASS_ERROR"; } header("Content-Type:text/plain"); print "SUCCESS"; break; default: break; } return ""; }
public function postProcess($action, $httpVars, $postProcessData) { if (self::$skipDecoding) { } if (!isset($httpVars["partitionRealName"])) { return; } $repository = ConfService::getRepository(); if (!$repository->detectStreamWrapper(false)) { return false; } $plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType()); $streamData = $plugin->detectStreamWrapper(true); $destStreamURL = $streamData["protocol"] . "://" . $repository->getId() . $httpVars["dir"] . "/"; $count = intval($httpVars["partitionCount"]); $index = intval($httpVars["partitionIndex"]); $fileId = $httpVars["fileId"]; $clientId = $httpVars["clientId"]; AJXP_Logger::debug("Should now rebuild file!", $httpVars); $newDest = fopen($destStreamURL . $httpVars["partitionRealName"], "w"); for ($i = 0; $i < $count; $i++) { $part = fopen($destStreamURL . "{$clientId}.{$fileId}.{$i}", "r"); while (!feof($part)) { fwrite($newDest, fread($part, 4096)); } fclose($part); unlink($destStreamURL . "{$clientId}.{$fileId}.{$i}"); } fclose($newDest); }
/** * Initialize the stream from the given path. * Concretely, transform ajxp.webdav:// into webdav:// * * @param string $path * @return mixed Real path or -1 if currentListing contains the listing : original path converted to real path */ protected static function initPath($path, $streamType, $storeOpenContext = false, $skipZip = false) { $url = parse_url($path); $repoId = $url["host"]; $repoObject = ConfService::getRepositoryById($repoId); if (!isset($repoObject)) { throw new Exception("Cannot find repository with id " . $repoId); } $path = $url["path"]; $host = $repoObject->getOption("HOST"); $host = str_replace(array("http", "https"), array("webdav", "webdavs"), $host); // MAKE SURE THERE ARE NO // OR PROBLEMS LIKE THAT... $basePath = $repoObject->getOption("PATH"); if ($basePath[strlen($basePath) - 1] == "/") { $basePath = substr($basePath, 0, -1); } if ($basePath[0] != "/") { $basePath = "/{$basePath}"; } $path = AJXP_Utils::securePath($path); if ($path[0] == "/") { $path = substr($path, 1); } // SHOULD RETURN webdav://host_server/uri/to/webdav/folder return $host . $basePath . "/" . $path; }
public function doTest() { $this->testedParams["Users enabled"] = AuthService::usersEnabled(); $this->testedParams["Guest enabled"] = ConfService::getCoreConf("ALLOW_GUEST_BROWSING", "auth"); $this->failedLevel = "info"; return FALSE; }
/** * @return Repository */ public function getRepository() { if (!isset($this->repository)) { $this->repository = ConfService::getRepositoryById($this->repositoryId); } return $this->repository; }
public function doTest() { $tmpDir = ini_get("upload_tmp_dir"); if (!$tmpDir) { $tmpDir = realpath(sys_get_temp_dir()); } if (ConfService::getCoreConf("AJXP_TMP_DIR") != "") { $tmpDir = ConfService::getCoreConf("AJXP_TMP_DIR"); } if (defined("AJXP_TMP_DIR") && AJXP_TMP_DIR != "") { $tmpDir = AJXP_TMP_DIR; } $this->testedParams["Upload Tmp Dir Writeable"] = @is_writable($tmpDir); $this->testedParams["PHP Upload Max Size"] = $this->returnBytes(ini_get("upload_max_filesize")); $this->testedParams["PHP Post Max Size"] = $this->returnBytes(ini_get("post_max_size")); foreach ($this->testedParams as $paramName => $paramValue) { $this->failedInfo .= "\n{$paramName}={$paramValue}"; } if (!$this->testedParams["Upload Tmp Dir Writeable"]) { $this->failedLevel = "error"; $this->failedInfo = "The temporary folder used by PHP to upload files is either incorrect or not writeable! Upload will not work. Please check : " . ini_get("upload_tmp_dir"); $this->failedInfo .= "<p class='suggestion'><b>Suggestion</b> : Set the AJXP_TMP_DIR parameter in the <i>conf/bootstrap_conf.php</i> file</p>"; return FALSE; } $this->failedLevel = "info"; return FALSE; }
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(AJXP_Utils::decodeSecureMagic($httpVars["file"])); $target = base64_decode($httpVars["parent_url"]) . "/plugins/editor.pixlr"; $tmp = call_user_func(array($streamData["classname"], "getRealFSReference"), $destStreamURL . $file); $fData = array("tmp_name" => $tmp, "name" => urlencode(basename($file)), "type" => "image/jpg"); $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; }
public function switchAction($action, $httpVars, $filesVars) { if (!isset($this->actions[$action])) { return false; } $repository = ConfService::getRepository(); if (!$repository->detectStreamWrapper(true)) { return false; } if (!isset($this->pluginConf)) { $this->pluginConf = array("GENERATE_THUMBNAIL" => false); } $streamData = $repository->streamData; $this->streamData = $streamData; $destStreamURL = $streamData["protocol"] . "://" . $repository->getId(); if ($action == "preview_data_proxy") { $file = AJXP_Utils::decodeSecureMagic($httpVars["file"]); if (!file_exists($destStreamURL . $file)) { header("Content-Type: " . AJXP_Utils::getImageMimeType(basename($file)) . "; name=\"" . basename($file) . "\""); header("Content-Length: 0"); return; } if (isset($httpVars["get_thumb"]) && $this->getFilteredOption("GENERATE_THUMBNAIL", $repository->getId())) { $dimension = 200; if (isset($httpVars["dimension"]) && is_numeric($httpVars["dimension"])) { $dimension = $httpVars["dimension"]; } $this->currentDimension = $dimension; $cacheItem = AJXP_Cache::getItem("diaporama_" . $dimension, $destStreamURL . $file, array($this, "generateThumbnail")); $data = $cacheItem->getData(); $cId = $cacheItem->getId(); header("Content-Type: " . AJXP_Utils::getImageMimeType(basename($cId)) . "; name=\"" . basename($cId) . "\""); header("Content-Length: " . strlen($data)); header('Cache-Control: public'); header("Pragma:"); 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"); print $data; } else { //$filesize = filesize($destStreamURL.$file); $node = new AJXP_Node($destStreamURL . $file); $fp = fopen($destStreamURL . $file, "r"); $stat = fstat($fp); $filesize = $stat["size"]; header("Content-Type: " . AJXP_Utils::getImageMimeType(basename($file)) . "; name=\"" . basename($file) . "\""); header("Content-Length: " . $filesize); header('Cache-Control: public'); header("Pragma:"); 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"); $class = $streamData["classname"]; $stream = fopen("php://output", "a"); call_user_func(array($streamData["classname"], "copyFileInStream"), $destStreamURL . $file, $stream); fflush($stream); fclose($stream); AJXP_Controller::applyHook("node.read", array($node)); } } }
protected function setUp() { $pServ = AJXP_PluginsService::getInstance(); ConfService::init(); $confPlugin = ConfService::getInstance()->confPluginSoftLoad($pServ); $pServ->loadPluginsRegistry(AJXP_INSTALL_PATH . "/plugins", $confPlugin); ConfService::start(); }
function tryToLogUser(&$httpVars, $isLast = false) { if (!isset($httpVars["get_action"]) || $httpVars["get_action"] != "login") { return false; } $rememberLogin = ""; $rememberPass = ""; $secureToken = ""; $loggedUser = null; include_once AJXP_BIN_FOLDER . "/class.CaptchaProvider.php"; if (AuthService::suspectBruteForceLogin() && (!isset($httpVars["captcha_code"]) || !CaptchaProvider::checkCaptchaResult($httpVars["captcha_code"]))) { $loggingResult = -4; } else { $userId = isset($httpVars["userid"]) ? AJXP_Utils::sanitize($httpVars["userid"], AJXP_SANITIZE_EMAILCHARS) : null; $userPass = isset($httpVars["password"]) ? trim($httpVars["password"]) : null; $rememberMe = isset($httpVars["remember_me"]) && $httpVars["remember_me"] == "true" ? true : false; $cookieLogin = isset($httpVars["cookie_login"]) ? true : false; $loggingResult = AuthService::logUser($userId, $userPass, false, $cookieLogin, $httpVars["login_seed"]); if ($rememberMe && $loggingResult == 1) { $rememberLogin = "******"; $rememberPass = "******"; } if ($loggingResult == 1) { session_regenerate_id(true); $secureToken = AuthService::generateSecureToken(); } if ($loggingResult < 1 && AuthService::suspectBruteForceLogin()) { $loggingResult = -4; // Force captcha reload } } $loggedUser = AuthService::getLoggedUser(); if ($loggedUser != null) { $force = $loggedUser->mergedRole->filterParameterValue("core.conf", "DEFAULT_START_REPOSITORY", AJXP_REPO_SCOPE_ALL, -1); $passId = -1; if (isset($httpVars["tmp_repository_id"])) { $passId = $httpVars["tmp_repository_id"]; } else { if ($force != "" && $loggedUser->canSwitchTo($force) && !isset($httpVars["tmp_repository_id"]) && !isset($_SESSION["PENDING_REPOSITORY_ID"])) { $passId = $force; } } $res = ConfService::switchUserToActiveRepository($loggedUser, $passId); if (!$res) { AuthService::disconnect(); $loggingResult = -3; } } if ($loggedUser != null && (AuthService::hasRememberCookie() || isset($rememberMe) && $rememberMe == true)) { AuthService::refreshRememberCookie($loggedUser); } AJXP_XMLWriter::header(); AJXP_XMLWriter::loggingResult($loggingResult, $rememberLogin, $rememberPass, $secureToken); AJXP_XMLWriter::close(); if ($loggingResult > 0 || $isLast) { exit; } }
public function switchActions($actionName, $httpVars, $fileVars) { //$urlBase = $this->accessDriver $repository = ConfService::getRepository(); if (!$repository->detectStreamWrapper(true)) { return false; } if (!isset($this->pluginConf)) { $this->pluginConf = array("GENERATE_THUMBNAIL" => false); } $streamData = $repository->streamData; $this->streamData = $streamData; $destStreamURL = $streamData["protocol"] . "://" . $repository->getId(); switch ($actionName) { case "filehasher_signature": $file = AJXP_Utils::decodeSecureMagic($httpVars["file"]); if (!file_exists($destStreamURL . $file)) { break; } $cacheItem = AJXP_Cache::getItem("signatures", $destStreamURL . $file, array($this, "generateSignature")); $data = $cacheItem->getData(); header("Content-Type:application/octet-stream"); header("Content-Length", strlen($data)); echo $data; break; case "filehasher_delta": case "filehasher_patch": // HANDLE UPLOAD DATA if (!isset($fileVars) && !is_array($fileVars["userfile_0"])) { throw new Exception("These action should find uploaded data"); } $uploadedData = tempnam(AJXP_Utils::getAjxpTmpDir(), $actionName . "-sig"); move_uploaded_file($fileVars["userfile_0"]["tmp_name"], $uploadedData); $fileUrl = $destStreamURL . AJXP_Utils::decodeSecureMagic($httpVars["file"]); $file = call_user_func(array($this->streamData["classname"], "getRealFSReference"), $fileUrl, true); if ($actionName == "filehasher_delta") { $signatureFile = $uploadedData; $deltaFile = tempnam(AJXP_Utils::getAjxpTmpDir(), $actionName . "-delta"); rsync_generate_delta($signatureFile, $file, $deltaFile); header("Content-Type:application/octet-stream"); header("Content-Length:" . filesize($deltaFile)); readfile($deltaFile); unlink($signatureFile); unlink($deltaFile); } else { $patched = $file . ".rdiff_patched"; $deltaFile = $uploadedData; rsync_patch_file($file, $deltaFile, $patched); rename($patched, $file); header("Content-Type:text/plain"); unlink($deltaFile); echo md5_file($file); } break; } }
public function switchAction($action, $httpVars, $postProcessData) { if (!isset($this->actions[$action])) { return false; } $repository = ConfService::getRepository(); if (!$repository->detectStreamWrapper(false)) { return false; } $plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType()); $streamData = $plugin->detectStreamWrapper(true); $destStreamURL = $streamData["protocol"] . "://" . $repository->getId() . "/"; if ($action == "audio_proxy") { $file = AJXP_Utils::decodeSecureMagic(base64_decode($httpVars["file"])); $cType = "audio/" . array_pop(explode(".", $file)); $localName = basename($file); header("Content-Type: " . $cType . "; name=\"" . $localName . "\""); header("Content-Length: " . filesize($destStreamURL . $file)); $stream = fopen("php://output", "a"); call_user_func(array($streamData["classname"], "copyFileInStream"), $destStreamURL . $file, $stream); fflush($stream); fclose($stream); $node = new AJXP_Node($destStreamURL . $file); AJXP_Controller::applyHook("node.read", array($node)); //exit(1); } else { if ($action == "ls") { if (!isset($httpVars["playlist"])) { // This should not happen anyway, because of the applyCondition. AJXP_Controller::passProcessDataThrough($postProcessData); return; } // We transform the XML into XSPF $xmlString = $postProcessData["ob_output"]; $xmlDoc = new DOMDocument(); $xmlDoc->loadXML($xmlString); $xElement = $xmlDoc->documentElement; header("Content-Type:application/xspf+xml;charset=UTF-8"); print '<?xml version="1.0" encoding="UTF-8"?>'; print '<playlist version="1" xmlns="http://xspf.org/ns/0/">'; print "<trackList>"; foreach ($xElement->childNodes as $child) { $isFile = $child->getAttribute("is_file") == "true"; $label = $child->getAttribute("text"); $ar = explode(".", $label); $ext = strtolower(end($ar)); if (!$isFile || $ext != "mp3") { continue; } print "<track><location>" . AJXP_SERVER_ACCESS . "?secure_token=" . AuthService::getSecureToken() . "&get_action=audio_proxy&file=" . base64_encode($child->getAttribute("filename")) . "</location><title>" . $label . "</title></track>"; } print "</trackList>"; AJXP_XMLWriter::close("playlist"); } } }
public function listUsers($baseGroup = "/") { $users = AJXP_Utils::loadSerialFile($this->usersSerFile); if (AuthService::ignoreUserCase()) { $users = array_combine(array_map("strtolower", array_keys($users)), array_values($users)); } ConfService::getConfStorageImpl()->filterUsersByGroup($users, $baseGroup, false); ksort($users); return $users; }
/** * @return AbstractConfDriver */ public function getConfImpl() { if (!isset(self::$confImpl) || isset($this->pluginConf["UNIQUE_INSTANCE_CONFIG"]["instance_name"]) && self::$confImpl->getId() != $this->pluginConf["UNIQUE_INSTANCE_CONFIG"]["instance_name"]) { if (isset($this->pluginConf["UNIQUE_INSTANCE_CONFIG"])) { self::$confImpl = ConfService::instanciatePluginFromGlobalParams($this->pluginConf["UNIQUE_INSTANCE_CONFIG"], "AbstractConfDriver"); AJXP_PluginsService::getInstance()->setPluginUniqueActiveForType("conf", self::$confImpl->getName()); } } return self::$confImpl; }
function bookmarkBar($allBookmarks) { //echo '<div id="bmbar_title">MyBookmarks </div>'; $mess = ConfService::getMessages(); foreach (array_reverse($allBookmarks) as $path) { if (is_array($path)) { $path = $path["PATH"]; } echo '<div class="bm" onmouseover="this.className=\'bm_hover\';" onmouseout="this.className=\'bm\';"><img width="16" height="16" src="' . CLIENT_RESOURCES_FOLDER . '/images/crystal/mimes/16/folder.png" border="0" align="ABSMIDDLE" style="float:left;"><a href="#" class="disabled" title="' . $mess[146] . '" onclick="ajaxplorer.actionBar.removeBookmark(\'' . $path . '\'); return false;" onmouseover="$(this).addClassName(\'enabled\');" onmouseout="$(this).removeClassName(\'enabled\');"><img width="16" height="16" src="' . CLIENT_RESOURCES_FOLDER . '/images/crystal/actions/16/delete_bookmark.png" border="0" align="ABSMIDDLE" alt="' . $mess[146] . '"></a> <a href="#" onclick="ajaxplorer.goTo(\'' . $path . '\'); return false;" class="bookmark_button">' . $path . '</a></div>'; } }
public function getDropBg($action, $httpVars, $fileVars) { $lang = ConfService::getLanguage(); $img = INSTALL_PATH . "/plugins/uploader.html/i18n/{$lang}-dropzone.png"; if (!is_file($img)) { $img = INSTALL_PATH . "/plugins/uploader.html/i18n/en-dropzone.png"; } header("Content-Type: image/png; name=\"dropzone.png\""); header("Content-Length: " . filesize($img)); header('Cache-Control: public'); readfile($img); }
public function AJXP_Exception($messageString, $messageId = false) { if ($messageId !== false && class_exists("ConfService")) { $messages = ConfService::getMessages(); if (array_key_exists($messageId, $messages)) { $messageString = $messages[$messageId]; } else { $messageString = $messageId; } } parent::__construct($messageString); }
/** * @return AjxpWebdavProvider * @throws ezcBaseFileNotFoundException */ protected function getAccessDriver() { if (!isset($this->accessDriver)) { $confDriver = ConfService::getConfStorageImpl(); $this->accessDriver = ConfService::loadRepositoryDriver(); if (!$this->accessDriver instanceof AjxpWebdavProvider) { throw new ezcBaseFileNotFoundException($this->repository->getUniqueId()); } $wrapperData = $this->accessDriver->detectStreamWrapper(true); $this->wrapperClassName = $wrapperData["classname"]; } return $this->accessDriver; }
public function generateDirectoryIndex($path) { $html = parent::generateDirectoryIndex($path); $html = str_replace("image/vnd.microsoft.icon", "image/png", $html); $title = ConfService::getCoreConf("APPLICATION_TITLE"); $html = preg_replace("/<title>(.*)<\\/title>/i", '<title>' . $title . '</title>', $html); $repoString = "</h1>"; if (!empty($this->repositoryLabel)) { $repoString = " - " . $this->repositoryLabel . "</h1><h2>Index of " . $this->escapeHTML($path) . "/</h2>"; } $html = preg_replace("/<h1>(.*)<\\/h1>/i", "<h1>" . $title . $repoString, $html); $html = str_replace("h1 { font-size: 150% }", "h1 { font-size: 150% } \n h2 { font-size: 115% }", $html); return $html; }
public function initMeta($accessDriver) { $this->accessDriver = $accessDriver; $messages = ConfService::getMessages(); $def = $this->getMetaDefinition(); $cdataHead = '<div> <div class="panelHeader infoPanelGroup" colspan="2">' . $messages["meta.serial.1"] . '</div> <table class="infoPanelTable" cellspacing="0" border="0" cellpadding="0">'; $cdataFoot = '</table></div>'; $cdataParts = ""; $selection = $this->xPath->query('registry_contributions/client_configs/component_config[@className="FilesList"]/columns'); $contrib = $selection->item(0); $even = false; $searchables = array(); foreach ($def as $key => $label) { $col = $this->manifestDoc->createElement("additional_column"); $col->setAttribute("messageString", $label); $col->setAttribute("attributeName", $key); $col->setAttribute("sortType", "String"); if ($key == "stars_rate") { $col->setAttribute("modifier", "MetaCellRenderer.prototype.starsRateFilter"); $col->setAttribute("sortType", "CellSorterValue"); } else { if ($key == "css_label") { $col->setAttribute("modifier", "MetaCellRenderer.prototype.cssLabelsFilter"); $col->setAttribute("sortType", "CellSorterValue"); } else { $searchables[$key] = $label; } } $contrib->appendChild($col); $trClass = $even ? " class=\"even\"" : ""; $even = !$even; $cdataParts .= '<tr' . $trClass . '><td class="infoPanelLabel">' . $label . '</td><td class="infoPanelValue" id="ip_' . $key . '">#{' . $key . '}</td></tr>'; } $selection = $this->xPath->query('registry_contributions/client_configs/component_config[@className="InfoPanel"]/infoPanelExtension'); $contrib = $selection->item(0); $contrib->setAttribute("attributes", implode(",", array_keys($def))); if (isset($def["stars_rate"]) || isset($def["css_label"])) { $contrib->setAttribute("modifier", "MetaCellRenderer.prototype.infoPanelModifier"); } $htmlSel = $this->xPath->query('html', $contrib); $html = $htmlSel->item(0); $cdata = $this->manifestDoc->createCDATASection($cdataHead . $cdataParts . $cdataFoot); $html->appendChild($cdata); $selection = $this->xPath->query('registry_contributions/client_configs/template_part[@ajxpClass="SearchEngine"]'); $tag = $selection->item(0); $tag->setAttribute("ajxpOptions", json_encode(count($searchables) ? array("metaColumns" => $searchables) : array())); parent::init($this->options); }
protected function updateMetaShort($file, $shortUrl) { $metaStore = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("metastore"); if ($metaStore !== false) { $driver = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("access"); $metaStore->initMeta($driver); $streamData = $driver->detectStreamWrapper(false); $baseUrl = $streamData["protocol"] . "://" . ConfService::getRepository()->getId(); $node = new AJXP_Node($baseUrl . $file); $metadata = $metaStore->retrieveMetadata($node, "ajxp_shared", true, AJXP_METADATA_SCOPE_REPOSITORY); $metadata["short_form_url"] = $shortUrl; $metaStore->setMetadata($node, "ajxp_shared", $metadata, true, AJXP_METADATA_SCOPE_REPOSITORY); } }