/** * 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; }
function initFromArray($array) { if (!is_array($array)) { return; } if (isset($array[$this->varPrefix]) && $array[$this->varPrefix] != "") { $this->files[] = AJXP_Utils::securePath(SystemTextEncoding::fromPostedFileName($array[$this->varPrefix])); $this->isUnique = true; //return ; } if (isset($array[$this->varPrefix . "_0"])) { $index = 0; while (isset($array[$this->varPrefix . "_" . $index])) { $this->files[] = AJXP_Utils::securePath(SystemTextEncoding::fromPostedFileName($array[$this->varPrefix . "_" . $index])); $index++; } $this->isUnique = false; if (count($this->files) == 1) { $this->isUnique = true; } //return ; } if (isset($array[$this->dirPrefix])) { $this->dir = AJXP_Utils::securePath($array[$this->dirPrefix]); if ($test = $this->detectZip($this->dir)) { $this->inZip = true; $this->zipFile = $test[0]; $this->localZipPath = $test[1]; } } }
function isEnabled() { if (AJXP_Utils::detectApplicationFirstRun()) { return false; } return parent::isEnabled(); }
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; }
/** * Initialize an empty mask, or from a serializedForm. * @param array|null $serializedForm */ function __construct($serializedForm = null) { if ($serializedForm != null) { foreach ($serializedForm as $path => $permissionValue) { $path = AJXP_Utils::sanitize(AJXP_Utils::securePath($path), AJXP_SANITIZE_DIRNAME); if (!is_array($permissionValue) || $permissionValue["children"]) { continue; } $perm = new AJXP_Permission(); if ($permissionValue["read"]) { $perm->setRead(); } if ($permissionValue["write"]) { $perm->setWrite(); } if ($permissionValue["deny"]) { $perm->setDeny(); } if ($perm->isEmpty()) { continue; } $this->updateBranch($path, $perm); } } }
/** * Load the boostrap_* files and their configs * @return void */ public function initInst() { include AJXP_CONF_PATH . "/bootstrap_plugins.php"; // INIT AS GLOBAL $this->configs["AVAILABLE_LANG"] = self::listAvailableLanguages(); if (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on") { $this->configs["USE_HTTPS"] = true; } if (isset($this->configs["USE_HTTPS"])) { AJXP_Utils::safeIniSet("session.cookie_secure", true); } $this->configs["JS_DEBUG"] = AJXP_CLIENT_DEBUG; $this->configs["SERVER_DEBUG"] = AJXP_SERVER_DEBUG; if (isset($PLUGINS)) { $this->configs["PLUGINS"] = $PLUGINS; } else { /* OLD SYNTAX */ $this->configs["AUTH_DRIVER_DEF"] = $AUTH_DRIVER; $this->configs["LOG_DRIVER_DEF"] = $LOG_DRIVER; $this->configs["CONF_PLUGINNAME"] = $CONF_STORAGE["NAME"]; $this->configs["PLUGINS"] = array("CONF_DRIVER" => $CONF_STORAGE, "AUTH_DRIVER" => $AUTH_DRIVER, "LOG_DRIVER" => $LOG_DRIVER); } if (is_file(AJXP_CONF_PATH . "/bootstrap_repositories.php")) { include AJXP_CONF_PATH . "/bootstrap_repositories.php"; $this->configs["DEFAULT_REPOSITORIES"] = $REPOSITORIES; } else { $this->configs["DEFAULT_REPOSITORIES"] = array(); } }
public function postProcess($action, $httpVars, $params) { $jsonData = json_decode($params["ob_output"], true); if ($jsonData != false) { $url = $jsonData["publiclet_link"]; $elementId = $jsonData["element_id"]; } else { $url = $params["ob_output"]; $elementId = -1; } $BITLY_USER = $this->getFilteredOption("BITLY_USER"); $BITLY_APIKEY = $this->getFilteredOption("BITLY_APIKEY"); if (empty($BITLY_USER) || empty($BITLY_APIKEY)) { print $url; $this->logError("Config", "Bitly Shortener : you must drop the conf.shorten.bitly.inc file inside conf.php and set the login/api key!"); return; } $bitly_login = $BITLY_USER; $bitly_api = $BITLY_APIKEY; $format = 'json'; $version = '2.0.1'; $bitly = 'http://api.bit.ly/shorten?version=' . $version . '&longUrl=' . urlencode($url) . '&login='******'&apiKey=' . $bitly_api . '&format=' . $format; $response = AJXP_Utils::getRemoteContent($bitly); $json = json_decode($response, true); if (isset($json['results'][$url]['shortUrl'])) { print $json['results'][$url]['shortUrl']; $this->updateMetaShort($httpVars["file"], $elementId, $json['results'][$url]['shortUrl']); } else { print $url; } }
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 static function saveBootstrapConf($jsonData) { $jsonPath = self::_getBootstrapFilePath(); if (file_exists($jsonPath)) { copy($jsonPath, $jsonPath . ".bak"); } AJXP_Utils::saveSerialFile($jsonPath, $jsonData, true, false, "json", true); }
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; } }
private function filterData(&$data) { $confMaxSize = AJXP_Utils::convertBytes($data["UPLOAD_MAX_SIZE"]); $UploadMaxSize = min(AJXP_Utils::convertBytes(ini_get('upload_max_filesize')), AJXP_Utils::convertBytes(ini_get('post_max_size'))); if (intval($confMaxSize) != 0) { $UploadMaxSize = min($UploadMaxSize, $confMaxSize); } $data["UPLOAD_MAX_SIZE"] = $UploadMaxSize; }
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 __destruct() { if (isset($this->channels) && is_array($this->channels)) { foreach ($this->channels as $channelName => $data) { if (is_array($data)) { AJXP_Utils::saveSerialFile($this->getPluginWorkDir() . "/queues/channel-{$channelName}", $data); } } } }
public function performChecks() { if (AJXP_Utils::userAgentIsIOS() && !isset($_GET["skipIOS"]) && !isset($_COOKIE["SKIP_IOS"])) { return; } if (AJXP_Utils::userAgentIsAndroid() && !isset($_GET["skipANDROID"]) && !isset($_COOKIE["SKIP_ANDROID"])) { return; } throw new Exception("Active only when mobile user agent detected."); }
public function processUserAccessPoint($action, $httpVars, $fileVars) { switch ($action) { case "user_access_point": $uri = explode("/", trim($_SERVER["REQUEST_URI"], "/")); array_shift($uri); $action = array_shift($uri); $this->processSubAction($action, $uri); $_SESSION['OVERRIDE_GUI_START_PARAMETERS'] = array("REBASE" => "../../", "USER_GUI_ACTION" => $action); AJXP_Controller::findActionAndApply("get_boot_gui", array(), array()); unset($_SESSION['OVERRIDE_GUI_START_PARAMETERS']); break; case "reset-password-ask": // This is a reset password request, generate a token and store it. // Find user by id if (AuthService::userExists($httpVars["email"])) { // Send email $userObject = ConfService::getConfStorageImpl()->createUserObject($httpVars["email"]); $email = $userObject->personalRole->filterParameterValue("core.conf", "email", AJXP_REPO_SCOPE_ALL, ""); if (!empty($email)) { $uuid = AJXP_Utils::generateRandomString(48); ConfService::getConfStorageImpl()->saveTemporaryKey("password-reset", $uuid, AJXP_Utils::decodeSecureMagic($httpVars["email"]), array()); $mailer = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("mailer"); if ($mailer !== false) { $mess = ConfService::getMessages(); $link = AJXP_Utils::detectServerURL() . "/user/reset-password/" . $uuid; $mailer->sendMail(array($email), $mess["gui.user.1"], $mess["gui.user.7"] . "<a href=\"{$link}\">{$link}</a>"); } else { echo 'ERROR: There is no mailer configured, please contact your administrator'; } } } // Prune existing expired tokens ConfService::getConfStorageImpl()->pruneTemporaryKeys("password-reset", 20); echo "SUCCESS"; break; case "reset-password": ConfService::getConfStorageImpl()->pruneTemporaryKeys("password-reset", 20); // This is a reset password if (isset($httpVars["key"]) && isset($httpVars["user_id"])) { $key = ConfService::getConfStorageImpl()->loadTemporaryKey("password-reset", $httpVars["key"]); if ($key != null && $key["user_id"] == $httpVars["user_id"] && AuthService::userExists($key["user_id"])) { AuthService::updatePassword($key["user_id"], $httpVars["new_pass"]); } ConfService::getConfStorageImpl()->deleteTemporaryKey("password-reset", $httpVars["key"]); } AuthService::disconnect(); echo 'SUCCESS'; break; default: break; } }
public function performChecks() { if (isset($_SESSION["CURRENT_MINISITE"])) { throw new Exception("Disabled for minisites"); } if (AJXP_Utils::userAgentIsIOS() && !isset($_GET["skipIOS"]) && !isset($_COOKIE["SKIP_IOS"])) { return; } if (AJXP_Utils::userAgentIsAndroid() && !isset($_GET["skipANDROID"]) && !isset($_COOKIE["SKIP_ANDROID"])) { return; } throw new Exception("Active only when mobile user agent detected."); }
public function initInst($confFile) { include $confFile; // INIT AS GLOBAL if (!isset($langue) || $langue == "") { $langue = $default_language; } $this->configs["LANGUE"] = $langue; if (isset($available_languages)) { $this->configs["AVAILABLE_LANG"] = $available_languages; } else { $this->configs["AVAILABLE_LANG"] = self::listAvailableLanguages(); } $this->configs["USE_HTTPS"] = $use_https; if (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on") { $this->configs["USE_HTTPS"] = true; } if ($this->configs["USE_HTTPS"]) { ini_set("session.cookie_secure", true); } $this->configs["WM_EMAIL"] = $webmaster_email; $this->configs["MAX_CHAR"] = $max_caracteres; $this->configs["JS_DEBUG"] = $AJXP_JS_DEBUG; $this->configs["SERVER_DEBUG"] = $AJXP_SERVER_DEBUG or false; $this->configs["SESSION_SET_CREDENTIALS"] = $AJXP_SESSION_SET_CREDENTIALS or false; $this->configs["UPLOAD_MAX_NUMBER"] = $upload_max_number; $this->configs["UPLOAD_ENABLE_FLASH"] = $upload_enable_flash; $this->configs["UPLOAD_MAX_FILE"] = AJXP_Utils::convertBytes($upload_max_size_per_file); $this->configs["UPLOAD_MAX_TOTAL"] = AJXP_Utils::convertBytes($upload_max_size_total); $this->configs["PROBE_REAL_SIZE"] = $allowRealSizeProbing; $this->configs["WELCOME_CUSTOM_MSG"] = $welcomeCustomMessage; $this->configs["CLIENT_TIMEOUT_TIME"] = defined('AJXP_CLIENT_TIMEOUT_TIME') ? AJXP_CLIENT_TIMEOUT_TIME : ini_get("session.gc_maxlifetime"); $this->configs["CLIENT_TIMEOUT_WARNING"] = defined('AJXP_CLIENT_TIMEOUT_WARN_BEFORE') ? AJXP_CLIENT_TIMEOUT_WARN_BEFORE : 3; if (isset($PLUGINS)) { $this->configs["PLUGINS"] = $PLUGINS; } else { /* OLD SYNTAX */ $this->configs["AUTH_DRIVER_DEF"] = $AUTH_DRIVER; $this->configs["LOG_DRIVER_DEF"] = $LOG_DRIVER; $this->configs["CONF_PLUGINNAME"] = $CONF_STORAGE["NAME"]; $this->configs["ACTIVE_PLUGINS"] = $ACTIVE_PLUGINS; $this->configs["PLUGINS"] = array("CONF_DRIVER" => $CONF_STORAGE, "AUTH_DRIVER" => $AUTH_DRIVER, "LOG_DRIVER" => $LOG_DRIVER, "ACTIVE_PLUGINS" => $ACTIVE_PLUGINS); } $this->initUniquePluginImplInst("CONF_DRIVER", "conf"); $this->initUniquePluginImplInst("AUTH_DRIVER", "auth"); $this->configs["DEFAULT_REPOSITORIES"] = $REPOSITORIES; $this->configs["REPOSITORIES"] = $this->initRepositoriesListInst($this->configs["DEFAULT_REPOSITORIES"]); $this->switchRootDirInst(); }
/** * 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)) { $e = new Exception("Cannot find repository with id " . $repoId); self::$lastException = $e; throw $e; } $path = $url["path"]; $host = $repoObject->getOption("HOST"); $hostParts = parse_url($host); if ($hostParts["scheme"] == "https" && !extension_loaded("openssl")) { $e = new Exception("Warning you must have the openssl PHP extension loaded to connect an https server!"); self::$lastException = $e; throw $e; } $credentials = AJXP_Safe::tryLoadingCredentialsFromSources($hostParts, $repoObject); $user = $credentials["user"]; $password = $credentials["password"]; if ($user != null && $password != null) { $host = ($hostParts["scheme"] == "https" ? "webdavs" : "webdav") . "://{$user}:{$password}@" . $hostParts["host"]; if (isset($hostParts["port"])) { $host .= ":" . $hostParts["port"]; } } else { $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 AJXP_Logger::debug($host . $basePath . "/" . $path); return $host . $basePath . "/" . $path; }
/** * Load the boostrap_* files and their configs * @return void */ public function initInst() { // INIT AS GLOBAL $this->configs["AVAILABLE_LANG"] = self::listAvailableLanguages(); if (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on") { $this->configs["USE_HTTPS"] = true; } if (isset($this->configs["USE_HTTPS"])) { AJXP_Utils::safeIniSet("session.cookie_secure", true); } $this->configs["JS_DEBUG"] = AJXP_CLIENT_DEBUG; $this->configs["SERVER_DEBUG"] = AJXP_SERVER_DEBUG; if (is_file(AJXP_CONF_PATH . "/bootstrap_repositories.php")) { include AJXP_CONF_PATH . "/bootstrap_repositories.php"; $this->configs["DEFAULT_REPOSITORIES"] = $REPOSITORIES; } else { $this->configs["DEFAULT_REPOSITORIES"] = array(); } }
public function switchAction($action, $httpVars, $fileVars) { switch ($action) { case "get_js_source": $jsName = AJXP_Utils::decodeSecureMagic($httpVars["object_name"]); $jsType = $httpVars["object_type"]; // class or interface? $fName = "class." . strtolower($jsName) . ".js"; if ($jsName == "Splitter") { $fName = "splitter.js"; } if (!defined("CLIENT_RESOURCES_FOLDER")) { define("CLIENT_RESOURCES_FOLDER", AJXP_PLUGINS_FOLDER . "/gui.ajax/res"); } // Locate the file class.ClassName.js if ($jsType == "class") { $searchLocations = array(CLIENT_RESOURCES_FOLDER . "/js/ajaxplorer", CLIENT_RESOURCES_FOLDER . "/js/lib", AJXP_INSTALL_PATH . "/plugins/"); } else { if ($jsType == "interface") { $searchLocations = array(CLIENT_RESOURCES_FOLDER . "/js/ajaxplorer/interfaces"); } } foreach ($searchLocations as $location) { $dir_iterator = new RecursiveDirectoryIterator($location); $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST); // could use CHILD_FIRST if you so wish $break = false; foreach ($iterator as $file) { if (strtolower(basename($file->getPathname())) == $fName) { HTMLWriter::charsetHeader("text/plain", "utf-8"); echo file_get_contents($file->getPathname()); $break = true; break; } } if ($break) { break; } } break; } }
public function makeZip($src, $dest, $basedir) { @set_time_limit(0); require_once AJXP_BIN_FOLDER . "/pclzip.lib.php"; $filePaths = array(); foreach ($src as $item) { $realFile = call_user_func(array($this->wrapperClassName, "getRealFSReference"), $this->urlBase . ($item[0] == "/" ? "" : "/") . AJXP_Utils::securePath($item)); $basedir = trim(dirname($realFile)) . "/"; $filePaths[] = array(PCLZIP_ATT_FILE_NAME => $realFile, PCLZIP_ATT_FILE_NEW_SHORT_NAME => basename($item)); } $this->logDebug("Pathes", $filePaths); $this->logDebug("Basedir", array($basedir)); self::$filteringDriverInstance = $this; $archive = new PclZip($dest); $vList = $archive->create($filePaths, PCLZIP_OPT_REMOVE_PATH, $basedir, PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_ADD_TEMP_FILE_ON); if (!$vList) { throw new Exception("Zip creation error : ({$dest}) " . $archive->errorInfo(true)); } self::$filteringDriverInstance = null; return $vList; }
public function postProcess($action, $httpVars, $params) { $url = $params["ob_output"]; if (!isset($this->pluginConf["BITLY_USER"]) || !isset($this->pluginConf["BITLY_APIKEY"])) { print $url; AJXP_Logger::logAction("error", "Bitly Shortener : you must drop the conf.shorten.bitly.inc file inside conf.php and set the login/api key!"); return; } $bitly_login = $this->pluginConf["BITLY_USER"]; $bitly_api = $this->pluginConf["BITLY_APIKEY"]; $format = 'json'; $version = '2.0.1'; $bitly = 'http://api.bit.ly/shorten?version=' . $version . '&longUrl=' . urlencode($url) . '&login='******'&apiKey=' . $bitly_api . '&format=' . $format; $response = AJXP_Utils::getRemoteContent($bitly); $json = json_decode($response, true); if (isset($json['results'][$url]['shortUrl'])) { print $json['results'][$url]['shortUrl']; $this->updateMetaShort($httpVars["file"], $json['results'][$url]['shortUrl']); } else { print $url; } }
function updateBaseHtaccessContent() { $uri = $_SERVER["REQUEST_URI"]; if (strpos($uri, '.php') !== false) { $uri = AJXP_Utils::safeDirname($uri); } if (empty($uri)) { $uri = "/"; } $tpl = file_get_contents(AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/boot.conf/htaccess.tpl"); if ($uri == "/") { $htContent = str_replace('${APPLICATION_ROOT}/', "/", $tpl); $htContent = str_replace('${APPLICATION_ROOT}', "/", $htContent); } else { $htContent = str_replace('${APPLICATION_ROOT}', $uri, $tpl); } if (is_writeable(AJXP_INSTALL_PATH . "/.htaccess")) { echo '<br>Updating Htaccess'; file_put_contents(AJXP_INSTALL_PATH . "/.htaccess", $htContent); } else { echo '<br>Cannot write htaccess file, please copy and paste the code below: <br><pre>' . $htContent . '</pre>'; } }
public function switchActions($actionName, $httpVars, $fileVars) { //$urlBase = $this->accessDriver $repository = $this->accessDriver->repository; if (!$repository->detectStreamWrapper(true)) { return false; } $selection = new UserSelection($repository, $httpVars); switch ($actionName) { case "filehasher_signature": $file = $selection->getUniqueNode(); if (!file_exists($file->getUrl())) { break; } $cacheItem = AJXP_Cache::getItem("signatures", $file->getUrl(), 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 $this->logDebug("Received signature file, should compute delta now"); if (!isset($fileVars) && !is_array($fileVars["userfile_0"])) { throw new Exception("These action should find uploaded data"); } $signature_delta_file = $fileVars["userfile_0"]["tmp_name"]; $fileUrl = $selection->getUniqueNode()->getUrl(); $file = AJXP_MetaStreamWrapper::getRealFSReference($fileUrl, true); if ($actionName == "filehasher_delta") { $deltaFile = tempnam(AJXP_Utils::getAjxpTmpDir(), $actionName . "-delta"); $this->logDebug("Received signature file, should compute delta now"); rsync_generate_delta($signature_delta_file, $file, $deltaFile); $this->logDebug("Computed delta file, size is " . filesize($deltaFile)); header("Content-Type:application/octet-stream"); header("Content-Length:" . filesize($deltaFile)); readfile($deltaFile); unlink($deltaFile); } else { $patched = $file . ".rdiff_patched"; rsync_patch_file($file, $signature_delta_file, $patched); rename($patched, $file); $node = $selection->getUniqueNode(); AJXP_Controller::applyHook("node.change", array($node, $node, false)); header("Content-Type:text/plain"); echo md5_file($file); } break; case "stat_hash": clearstatcache(); header("Content-type:application/json"); if ($selection->isUnique()) { $node = $selection->getUniqueNode(); $stat = @stat($node->getUrl()); if (!$stat || !is_readable($node->getUrl())) { print '{}'; } else { if (is_file($node->getUrl())) { if (isset($_SERVER["HTTP_RANGE"])) { $fullSize = floatval($stat['size']); $ranges = explode('=', $_SERVER["HTTP_RANGE"]); $offsets = explode('-', $ranges[1]); $offset = floatval($offsets[0]); $length = floatval($offsets[1]) - $offset; if (!$length) { $length = $fullSize - $offset; } if ($length + $offset > $fullSize || $length < 0) { $length = $fullSize - $offset; } $hash = $this->getPartialHash($node, $offset, $length); } else { $hash = $this->getFileHash($selection->getUniqueNode()); } } else { $hash = 'directory'; } $stat[13] = $stat["hash"] = $hash; print json_encode($stat); } } else { $files = $selection->getFiles(); print '{'; foreach ($files as $index => $path) { $node = new AJXP_Node($selection->currentBaseUrl() . $path); $stat = @stat($selection->currentBaseUrl() . $path); if (!$stat || !is_readable($node->getUrl())) { $stat = '{}'; } else { if (!is_dir($node->getUrl())) { $hash = $this->getFileHash($node); } else { $hash = 'directory'; } $stat[13] = $stat["hash"] = $hash; $stat = json_encode($stat); } print json_encode(SystemTextEncoding::toUTF8($path)) . ':' . $stat . ($index < count($files) - 1 ? "," : ""); } print '}'; } break; break; } }
/** * @abstract * @param String $keyType * @param String $expiration * @return null */ public function pruneTemporaryKeys($keyType, $expiration) { $storage = $this->getPluginWorkDir() . "/temporary_keys"; $list = AJXP_Utils::loadSerialFile($storage, false, "ser"); foreach ($list as $type => &$keys) { foreach ($keys as $key => $data) { if ($data["date"] < time() - $expiration * 60) { unset($keys[$key]); } } if (count($keys) == 0) { unset($list[$type]); } } AJXP_Utils::saveSerialFile($storage, $list); }
<?php define('AJXP_EXEC', true); require_once '../../core/classes/class.AJXP_Utils.php'; $AJXP_FILE_URL = AJXP_Utils::securePath(AJXP_Utils::sanitize($_GET["file"], 5)); $parts = explode("/", AJXP_Utils::securePath($_GET["file"])); foreach ($parts as $i => $part) { $parts[$i] = AJXP_Utils::sanitize($part, AJXP_SANITIZE_FILENAME); } $AJXP_FILE_URL = implode("/", $parts); ?> <html> <head> <script src="webodf/webodf.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript" charset="utf-8"> function init() { var odfelement = document.getElementById("odf"); window.odfcanvas = new odf.OdfCanvas(odfelement); window.odfcanvas.load("../../" + window.parent.ajxpServerAccessPath + "&get_action=download&file=<?php echo $AJXP_FILE_URL; ?> "); //window.odfcanvas.setEditable(true); /* odfcanvas.odfContainer().save(function(err){ console.log(err); }); */ } window.setTimeout(init, 0);
public function copyOrMoveSelection($actionName, &$httpVars, $filesVars) { if ($actionName != "rename") { $init = $this->initDirAndSelection($httpVars, array("DEST_DIR" => AJXP_Utils::decodeSecureMagic($httpVars["dest"]))); $this->commitMessageParams = "To:" . $httpVars["dest"] . ";items:"; } else { $init = $this->initDirAndSelection($httpVars, array(), true); } $this->logDebug("Entering SVN MAnager for action {$actionName}", $init); $action = 'copy'; if ($actionName == "move" || $actionName == "rename") { $action = 'move'; } foreach ($init["SELECTION"] as $selectedFile) { if ($actionName == "rename") { $destFile = dirname($selectedFile) . "/" . AJXP_Utils::decodeSecureMagic($httpVars["filename_new"]); $this->commitMessageParams = "To:" . $httpVars["filename_new"] . ";item:" . $httpVars["file"]; } else { $destFile = $init["DEST_DIR"] . "/" . basename($selectedFile); } $this->addIfNotVersionned(str_replace($init["DIR"], "", $selectedFile), $selectedFile); $res = ExecSvnCmd("svn {$action}", array($selectedFile, $destFile), ''); } if ($actionName != "rename") { $this->commitMessageParams .= "[" . implode(",", $init["SELECTION"]) . "]"; } $this->commitChanges($actionName, $httpVars, $filesVars); if ($actionName != "rename") { $this->commitChanges($actionName, array("dir" => $httpVars["dest"]), $filesVars); } $this->logInfo("CopyMove/Rename (svn delegate)", array("files" => $init["SELECTION"])); AJXP_XMLWriter::header(); AJXP_XMLWriter::sendMessage("The selected files/folders have been copied/moved (by SVN)", null); AJXP_XMLWriter::reloadDataNode(); AJXP_XMLWriter::close(); }
public function installSQLTables($param) { $p = AJXP_Utils::cleanDibiDriverParameters(isset($param) && isset($param["SQL_DRIVER"]) ? $param["SQL_DRIVER"] : $this->sqlDriver); return AJXP_Utils::runCreateTablesQuery($p, $this->getBaseDir() . "/create.sql"); }
/** * Save Temporary Data. * Implementation uses serialised files because of the overhead incurred with a full db implementation. * * @param $key String key of data to save. * @param $value Value to save */ public function saveTemporaryData($key, $value) { $dirPath = $this->storage->getOption("USERS_DIRPATH"); if ($dirPath == "") { $dirPath = AJXP_INSTALL_PATH . "/data/users"; AJXP_Logger::info(__CLASS__, "setTemporaryData", array("Warning" => "The conf.sql driver is missing a mandatory option USERS_DIRPATH!")); } $id = AuthService::ignoreUserCase() ? strtolower($this->getId()) : $this->getId(); AJXP_Utils::saveSerialFile($dirPath . "/" . $id . "/temp-" . $key . ".ser", $value); }
/** * @param AJXP_Node $ajxpNode */ public function hideExtension(&$ajxpNode) { if ($ajxpNode->hasExtension("pad")) { $baseName = AJXP_Utils::safeBasename($ajxpNode->getPath()); $ajxpNode->setLabel(str_replace(".pad", "", $baseName)); } }