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 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(); }
protected function getAuthorized() { if (self::$loadedQuota != null) { return self::$loadedQuota; } $q = $this->getFilteredOption("DEFAULT_QUOTA"); self::$loadedQuota = AJXP_Utils::convertBytes($q); return self::$loadedQuota; }
private function getAuthorized() { if (self::$loadedQuota != null) { return self::$loadedQuota; } $q = $this->options["DEFAULT_QUOTA"]; if (!empty($this->options["CUSTOM_DATA_FIELD"])) { $cdField = $this->options["CUSTOM_DATA_FIELD"]; $t = AuthService::getLoggedUser()->getPref("CUSTOM_PARAMS"); if (is_array($t) && array_key_exists($cdField, $t)) { $q = $t[$cdField]; } } self::$loadedQuota = AJXP_Utils::convertBytes($q); return self::$loadedQuota; }
public function testFrameworkLoads() { $this->assertEquals(\AJXP_Utils::convertBytes("2M"), 2097152); }
/** * this function initializes max size of the scanned file */ public function setScanMaxSize() { $this->scan_max_size = AJXP_Utils::convertBytes($this->getFilteredOption("SIZE")); return; }
/** * @param String $query * @return String mixed */ protected function filterSearchRangesKeywords($query) { if (strpos($query, "AJXP_SEARCH_RANGE_TODAY") !== false) { $t1 = date("Ymd"); $t2 = date("Ymd"); $query = str_replace("AJXP_SEARCH_RANGE_TODAY", "[{$t1} TO {$t2}]", $query); } else { if (strpos($query, "AJXP_SEARCH_RANGE_YESTERDAY") !== false) { $t1 = date("Ymd", mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'))); $t2 = date("Ymd", mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'))); $query = str_replace("AJXP_SEARCH_RANGE_YESTERDAY", "[{$t1} TO {$t2}]", $query); } else { if (strpos($query, "AJXP_SEARCH_RANGE_LAST_WEEK") !== false) { $t1 = date("Ymd", mktime(0, 0, 0, date('m'), date('d') - 7, date('Y'))); $t2 = date("Ymd", mktime(0, 0, 0, date('m'), date('d'), date('Y'))); $query = str_replace("AJXP_SEARCH_RANGE_LAST_WEEK", "[{$t1} TO {$t2}]", $query); } else { if (strpos($query, "AJXP_SEARCH_RANGE_LAST_MONTH") !== false) { $t1 = date("Ymd", mktime(0, 0, 0, date('m') - 1, date('d'), date('Y'))); $t2 = date("Ymd", mktime(0, 0, 0, date('m'), date('d'), date('Y'))); $query = str_replace("AJXP_SEARCH_RANGE_LAST_MONTH", "[{$t1} TO {$t2}]", $query); } else { if (strpos($query, "AJXP_SEARCH_RANGE_LAST_YEAR") !== false) { $t1 = date("Ymd", mktime(0, 0, 0, date('m'), date('d'), date('Y') - 1)); $t2 = date("Ymd", mktime(0, 0, 0, date('m'), date('d'), date('Y'))); $query = str_replace("AJXP_SEARCH_RANGE_LAST_YEAR", "[{$t1} TO {$t2}]", $query); } } } } } $split = array_map("trim", explode("AND", $query)); foreach ($split as $s) { list($k, $v) = explode(":", $s, 2); if ($k == "ajxp_bytesize") { //list($from, $to) = sscanf($v, "[%s TO %s]"); preg_match('/\\[(.*) TO (.*)\\]/', $v, $matches); $oldSize = $s; $newSize = "ajxp_bytesize:[" . intval(AJXP_Utils::convertBytes($matches[1])) . " TO " . intval(AJXP_Utils::convertBytes($matches[2])) . "]"; } } if (isset($newSize) && isset($oldSize)) { $query = str_replace($oldSize, $newSize, $query); } return $query; }
function switchAction($action, $httpVars, $fileVars) { if (!isset($this->actions[$action])) { return; } 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 = "plugins/" . $httpVars["pluginName"]; if (isset($httpVars["pluginPath"])) { $folder .= "/" . $httpVars["pluginPath"]; } } if (isset($template_name) && is_file($folder . "/" . $template_name)) { include $folder . "/" . $template_name; } break; //------------------------------------ // GET I18N MESSAGES //------------------------------------ //------------------------------------ // GET I18N MESSAGES //------------------------------------ case "get_i18n_messages": HTMLWriter::charsetHeader('text/javascript'); HTMLWriter::writeI18nMessagesClass(ConfService::getMessages()); break; //------------------------------------ // SEND XML REGISTRY //------------------------------------ //------------------------------------ // SEND XML REGISTRY //------------------------------------ case "get_xml_registry": $regDoc = AJXP_PluginsService::getXmlRegistry(); 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 { 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(htmlentities($_GET["doc_file"])); break; //------------------------------------ // CHECK UPDATE //------------------------------------ //------------------------------------ // CHECK UPDATE //------------------------------------ case "check_software_update": $content = @file_get_contents(SOFTWARE_UPDATE_SITE . "ajxp.version"); $message = $mess["345"]; if (isset($content) && $content != "") { if (strstr($content, "::URL::") !== false) { list($version, $downloadUrl) = explode("::URL::", $content); } else { $version = $content; $downloadUrl = "http://www.ajaxplorer.info/"; } $compare = version_compare(AJXP_VERSION, $content); if ($compare >= 0) { $message = $mess["346"]; } else { $link = '<a target="_blank" href="' . $downloadUrl . '">' . $downloadUrl . '</a>'; $message = sprintf($mess["347"], $version, $link); } } HTMLWriter::charsetHeader("text/plain"); print $message; 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"] = AJXP_THEME_FOLDER; $config["ajxpServerAccess"] = SERVER_ACCESS; $config["zipEnabled"] = ConfService::zipEnabled(); $config["multipleFilesDownloadEnabled"] = !DISABLE_ZIP_CREATION; $config["flashUploaderEnabled"] = ConfService::getConf("UPLOAD_ENABLE_FLASH"); $welcomeCustom = ConfService::getConf("WELCOME_CUSTOM_MSG"); if ($welcomeCustom != "") { $config["customWelcomeMessage"] = $welcomeCustom; } if (!ConfService::getConf("UPLOAD_ENABLE_FLASH")) { $UploadMaxSize = AJXP_Utils::convertBytes(ini_get('upload_max_filesize')); $confMaxSize = ConfService::getConf("UPLOAD_MAX_FILE"); if ($confMaxSize != 0 && $confMaxSize < $UploadMaxSize) { $UploadMaxSize = $confMaxSize; } $confTotalNumber = ConfService::getConf("UPLOAD_MAX_NUMBER"); $config["htmlMultiUploaderOptions"] = array("282" => $UploadMaxSize, "284" => $confTotalNumber); } $config["usersEnabled"] = AuthService::usersEnabled(); $config["loggedUser"] = AuthService::getLoggedUser() != null; $config["currentLanguage"] = ConfService::getLanguage(); $config["session_timeout"] = intval(ini_get("session.gc_maxlifetime")); $config["client_timeout"] = ConfService::getConf("CLIENT_TIMEOUT_TIME"); $config["client_timeout_warning"] = ConfService::getConf("CLIENT_TIMEOUT_WARNING"); $config["availableLanguages"] = ConfService::getConf("AVAILABLE_LANG"); $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 (defined("GOOGLE_ANALYTICS_ID") && GOOGLE_ANALYTICS_ID != "") { $config["googleAnalyticsData"] = array("id" => GOOGLE_ANALYTICS_ID, "domain" => GOOGLE_ANALYTICS_DOMAIN, "event" => GOOGLE_ANALYTICS_EVENT); } $config["i18nMessages"] = ConfService::getMessages(); $config["password_min_length"] = defined('AJXP_PASSWORD_MINLENGTH') ? AJXP_PASSWORD_MINLENGTH : 8; $config["SECURE_TOKEN"] = AuthService::generateSecureToken(); header("Content-type:application/json;charset=UTF-8"); print json_encode($config); break; default: break; } return false; }
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) { //------------------------------------ // GET AN HTML TEMPLATE //------------------------------------ case "get_template": HTMLWriter::charsetHeader(); $folder = CLIENT_RESOURCES_FOLDER . "/html"; if (isset($httpVars["pluginName"])) { $folder = "plugins/" . $httpVars["pluginName"]; if (isset($httpVars["pluginPath"])) { $folder .= "/" . $httpVars["pluginPath"]; } } if (isset($template_name) && is_file($folder . "/" . $template_name)) { include $folder . "/" . $template_name; } exit(0); break; //------------------------------------ // GET I18N MESSAGES //------------------------------------ //------------------------------------ // GET I18N MESSAGES //------------------------------------ case "get_i18n_messages": HTMLWriter::charsetHeader('text/javascript'); HTMLWriter::writeI18nMessagesClass(ConfService::getMessages()); exit(0); break; //------------------------------------ // SEND XML REGISTRY //------------------------------------ //------------------------------------ // SEND XML REGISTRY //------------------------------------ case "get_xml_registry": $regDoc = AJXP_PluginsService::getXmlRegistry(); 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 { header('Content-Type: application/xml; charset=UTF-8'); print AJXP_XMLWriter::replaceAjxpXmlKeywords($regDoc->saveXML()); } exit(0); break; //------------------------------------ // DISPLAY DOC //------------------------------------ //------------------------------------ // DISPLAY DOC //------------------------------------ case "display_doc": HTMLWriter::charsetHeader(); echo HTMLWriter::getDocFile(htmlentities($_GET["doc_file"])); exit(1); break; //------------------------------------ // CHECK UPDATE //------------------------------------ //------------------------------------ // CHECK UPDATE //------------------------------------ case "check_software_update": $content = @file_get_contents(SOFTWARE_UPDATE_SITE . "last_version.txt"); $message = $mess["345"]; if (isset($content) && $content != "") { $last_version = floatval($content); $currrent_version = floatval(AJXP_VERSION); if ($last_version == $currrent_version) { $message = $mess["346"]; } else { if ($last_version > $currrent_version) { $message = sprintf($mess["347"], $content, '<a href="http://www.ajaxplorer.info/">http://www.ajaxplorer.info/</a>'); } } } HTMLWriter::charsetHeader("text/plain"); print $message; exit(1); 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"] = AJXP_THEME_FOLDER; $config["ajxpServerAccess"] = SERVER_ACCESS; $config["zipEnabled"] = ConfService::zipEnabled(); $config["multipleFilesDownloadEnabled"] = !DISABLE_ZIP_CREATION; $config["flashUploaderEnabled"] = ConfService::getConf("UPLOAD_ENABLE_FLASH"); $welcomeCustom = ConfService::getConf("WELCOME_CUSTOM_MSG"); if ($welcomeCustom != "") { $config["customWelcomeMessage"] = $welcomeCustom; } if (!ConfService::getConf("UPLOAD_ENABLE_FLASH")) { $UploadMaxSize = AJXP_Utils::convertBytes(ini_get('upload_max_filesize')); $confMaxSize = ConfService::getConf("UPLOAD_MAX_FILE"); if ($confMaxSize != 0 && $confMaxSize < $UploadMaxSize) { $UploadMaxSize = $confMaxSize; } $confTotalNumber = ConfService::getConf("UPLOAD_MAX_NUMBER"); $config["htmlMultiUploaderOptions"] = array("282" => $UploadMaxSize, "284" => $confTotalNumber); } $config["usersEnabled"] = AuthService::usersEnabled(); $config["loggedUser"] = AuthService::getLoggedUser() != null; $config["currentLanguage"] = ConfService::getLanguage(); $config["userChangePassword"] = AuthService::changePasswordEnabled(); $config["availableLanguages"] = ConfService::getConf("AVAILABLE_LANG"); $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 (defined("GOOGLE_ANALYTICS_ID") && GOOGLE_ANALYTICS_ID != "") { $config["googleAnalyticsData"] = array("id" => GOOGLE_ANALYTICS_ID, "domain" => GOOGLE_ANALYTICS_DOMAIN, "event" => GOOGLE_ANALYTICS_EVENT); } $config["i18nMessages"] = ConfService::getMessages(); header("Content-type:application/json;charset=UTF-8"); print json_encode($config); 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; }