public function loadChannel($channelName, $create = false) { if (isset($this->channels) && is_array($this->channels[$channelName])) { return; } if (is_file($this->getPluginWorkDir() . "/queues/channel-{$channelName}")) { if (!isset($this->channels)) { $this->channels = array(); } $data = AJXP_Utils::loadSerialFile($this->getPluginWorkDir() . "/queues/channel-{$channelName}"); if (is_array($data)) { if (!is_array($data["MESSAGES"])) { $data["MESSAGES"] = array(); } if (!is_array($data["CLIENTS"])) { $data["CLIENTS"] = array(); } $this->channels[$channelName] = $data; return; } } if ($create) { if (!isset($this->channels)) { $this->channels = array(); } $this->channels[$channelName] = array("CLIENTS" => array(), "MESSAGES" => array()); } }
private static function loadCounters() { if (!isset(self::$counters)) { self::$counters = AJXP_Utils::loadSerialFile(ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER") . "/.ajxp_publiclet_counters.ser"); } return self::$counters; }
function listUsers() { $users = AJXP_Utils::loadSerialFile($this->usersSerFile); if (AuthService::ignoreUserCase()) { $users = array_combine(array_map("strtolower", array_keys($users)), array_values($users)); } return $users; }
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); return $users; }
/** * Initialize the driver. * * Gives the driver a chance to set up it's connection / file resource etc.. * * @param Array $options array of options specific to the logger driver. * @access public */ public function init($options) { parent::init($options); $this->sqlDriver = AJXP_Utils::cleanDibiDriverParameters($options["SQL_DRIVER"]); try { dibi::connect($this->sqlDriver); } catch (DibiException $e) { echo get_class($e), ': ', $e->getMessage(), "\n"; exit(1); } $this->queries = AJXP_Utils::loadSerialFile($this->getBaseDir() . "/queries.json", false, "json"); }
public function listUsers() { //Remote user list for admins. if ($this->isAdmin()) { $users = $this->getRemoteUsers(); AJXP_Utils::saveSerialFile($this->usersSerFile, $users); } else { $users = AJXP_Utils::loadSerialFile($this->usersSerFile); } if (AuthService::ignoreUserCase()) { $users = array_combine(array_map("strtolower", array_keys($users)), array_values($users)); } ksort($users); return $users; }
/** * Get Temporary Data. * Implementation uses serialised files because of the overhead incurred with a full db implementation. * * @param $key String key of data to retrieve * @return Requested value */ function getTemporaryData($key) { $dirPath = $this->storage->getOption("USERS_DIRPATH"); if ($dirPath == "") { $dirPath = AJXP_INSTALL_PATH . "/data/users"; AJXP_Logger::logAction("getTemporaryData", array("Warning" => "The conf.sql driver is missing a mandatory option USERS_DIRPATH!")); } return AJXP_Utils::loadSerialFile($dirPath . "/" . $this->getId() . "-temp-" . $key . ".ser"); }
public function getTemporaryData($key) { $fastCheck = $this->storage->getOption("FAST_CHECKS"); $fastCheck = $fastCheck == "true" || $fastCheck == true; return AJXP_Utils::loadSerialFile($this->getStoragePath() . "/" . $key . ".ser", $fastCheck); }
/** * Serial specific method : indexes repositories by slugs, for better performances */ function updateAliasesIndex($repositoryId, $repositorySlug) { $data = AJXP_Utils::loadSerialFile($this->aliasesIndexFile); $byId = array_flip($data); $byId[$repositoryId] = $repositorySlug; AJXP_Utils::saveSerialFile($this->aliasesIndexFile, array_flip($byId)); }
public function listUsers($baseGroup = "/", $recursive = true) { $users = AJXP_Utils::loadSerialFile($this->usersSerFile); if (AuthService::ignoreUserCase()) { $users = array_combine(array_map("strtolower", array_keys($users)), array_values($users)); } ksort($users); return $users; }
/** * Get Temporary Data. * Implementation uses serialised files because of the overhead incurred with a full db implementation. * * @param $key String key of data to retrieve * @return Requested value */ public function getTemporaryData($key) { $dirPath = $this->storage->getOption("USERS_DIRPATH"); if ($dirPath == "") { $dirPath = AJXP_INSTALL_PATH . "/data/users"; AJXP_Logger::info(__CLASS__, "getTemporaryData", array("Warning" => "The conf.sql driver is missing a mandatory option USERS_DIRPATH!")); } $id = AuthService::ignoreUserCase() ? strtolower($this->getId()) : $this->getId(); return AJXP_Utils::loadSerialFile($dirPath . "/" . $id . "/temp-" . $key . ".ser"); }
/** * @param String $pluginId * @param String $options */ public function _savePluginConfig($pluginId, $options) { $jsonPath = $this->getPluginWorkDir(true) . "/bootstrap.json"; $jsonData = AJXP_Utils::loadSerialFile($jsonPath, false, "json"); if (!is_array($jsonData)) { $jsonData = array(); } $jsonData[$pluginId] = $options; if ($pluginId == "core.conf" || $pluginId == "core.auth") { $testKey = $pluginId == "core.conf" ? "UNIQUE_INSTANCE_CONFIG" : "MASTER_INSTANCE_CONFIG"; $current = array(); $this->_loadPluginConfig($pluginId, $current); if (isset($current[$testKey]["instance_name"]) && $current[$testKey]["instance_name"] != $options[$testKey]["instance_name"]) { $forceDisconnexion = $pluginId; } } if (file_exists($jsonPath)) { copy($jsonPath, $jsonPath . ".bak"); } AJXP_Utils::saveSerialFile($jsonPath, $jsonData, true, false, "json", true); if (isset($forceDisconnexion)) { if ($pluginId == "core.conf") { // DISCONNECT AuthService::disconnect(); } else { if ($pluginId == "core.auth") { // DELETE admin_counted file and DISCONNECT @unlink(AJXP_CACHE_DIR . "/admin_counted"); } } } }
function listUsers() { return AJXP_Utils::loadSerialFile($this->usersSerFile); }
function getTemporaryData($key) { return AJXP_Utils::loadSerialFile($this->storage->getOption("USERS_DIRPATH") . "/" . $this->getId() . "/" . $key . ".ser"); }
/** * Check if group already exists * @param string $groupPath * @return boolean */ public function groupExists($groupPath) { $groups = AJXP_Utils::loadSerialFile(AJXP_VarsFilter::filter($this->getOption("USERS_DIRPATH")) . "/groups.ser"); $reverse = array_flip($groups); if (isset($reverse[$groupPath])) { return true; } return false; }
function getTokens($repositoryId) { return AJXP_Utils::loadSerialFile(AJXP_DATA_PATH . "/plugins/access.dropbox/" . $repositoryId . "_tokens"); }
public function handleTasks($action, $httpVars, $fileVars) { $tasks = AJXP_Utils::loadSerialFile($this->getDbFile(), false, "json"); switch ($action) { case "scheduler_addTask": if (isset($httpVars["task_id"])) { foreach ($tasks as $index => $task) { if ($task["task_id"] == $httpVars["task_id"]) { $data = $task; $theIndex = $index; } } } if (!isset($theIndex)) { $data = array(); $data["task_id"] = substr(md5(time()), 0, 16); } $data["label"] = $httpVars["label"]; $data["schedule"] = $httpVars["schedule"]; $data["action_name"] = $httpVars["action_name"]; $data["repository_id"] = $httpVars["repository_id"]; $i = 1; while (array_key_exists("repository_id_" . $i, $httpVars)) { $data["repository_id"] .= "," . $httpVars["repository_id_" . $i]; $i++; } $data["user_id"] = $httpVars["user_id"]; $data["PARAMS"] = array(); if (!empty($httpVars["param_name"]) && !empty($httpVars["param_value"])) { $data["PARAMS"][$httpVars["param_name"]] = $httpVars["param_value"]; } foreach ($httpVars as $key => $value) { if (preg_match('/^param_name_/', $key)) { $paramIndex = str_replace("param_name_", "", $key); if (preg_match('/ajxptype/', $paramIndex)) { continue; } if (preg_match('/replication/', $paramIndex)) { continue; } if (isset($httpVars["param_value_" . $paramIndex])) { $data["PARAMS"][$value] = $httpVars["param_value_" . $paramIndex]; } } } if (isset($theIndex)) { $tasks[$theIndex] = $data; } else { $tasks[] = $data; } AJXP_Utils::saveSerialFile($this->getDbFile(), $tasks, true, false, "json"); AJXP_XMLWriter::header(); AJXP_XMLWriter::sendMessage("Successfully added/edited task", null); AJXP_XMLWriter::reloadDataNode(); AJXP_XMLWriter::close(); break; case "scheduler_removeTask": $this->removeTask($httpVars["task_id"]); AJXP_XMLWriter::header(); AJXP_XMLWriter::sendMessage("Successfully removed task", null); AJXP_XMLWriter::reloadDataNode(); AJXP_XMLWriter::close(); break; case "scheduler_loadTask": $found = false; foreach ($tasks as $task) { if ($task["task_id"] == $httpVars["task_id"]) { $index = 0; $found = true; foreach ($task["PARAMS"] as $pName => $pValue) { if ($index == 0) { $task["param_name"] = $pName; $task["param_value"] = $pValue; } else { $task["param_name_" . $index] = $pName; $task["param_value_" . $index] = $pValue; } $index++; } unset($task["PARAMS"]); if (strpos($task["repository_id"], ",") !== false) { $ids = explode(",", $task["repository_id"]); $task["repository_id"] = $ids[0]; for ($i = 1; $i < count($ids); $i++) { $task["repository_id_" . $i] = $ids[$i]; } } break; } } if ($found) { HTMLWriter::charsetHeader("application/json"); echo json_encode($task); } break; default: break; } //var_dump($tasks); }
function getTemporaryData($key) { return AJXP_Utils::loadSerialFile(INSTALL_PATH . "/server/users/" . $this->getId() . "-temp-" . $key . ".ser"); }
/** * Load the cache, check that all registered plugins * are known by the cache, and in that case sort the array. * * @param array $sortedPlugins * @return mixed */ private function loadPlugCache($sortedPlugins) { if (!AJXP_PLUGINS_CACHE_FILE) { return false; } $cache = AJXP_Utils::loadSerialFile(AJXP_PLUGINS_CACHE_FILE); if (!count($cache)) { return false; } // Break if one plugin is not present in cache foreach ($sortedPlugins as $index => $plugin) { if (!in_array($plugin->getId(), $cache)) { return false; } } $sorted = array(); foreach ($cache as $id => $plugId) { // Walk the cache and add the plugins in right order. if (isset($sortedPlugins[$plugId])) { $sorted[] = $sortedPlugins[$plugId]; } } return $sorted; }
/** * Delete a repository, given its unique ID. * * @param String $repositoryId */ function deleteRepository($repositoryId) { $repositories = AJXP_Utils::loadSerialFile($this->repoSerialFile); $newList = array(); foreach ($repositories as $repo) { if ($repo->getUniqueId() != $repositoryId) { $newList[$repo->getUniqueId()] = $repo; } } AJXP_Utils::saveSerialFile($this->repoSerialFile, $newList); }
public function storeToPluginQueriesCache($key, $value) { if (AJXP_SKIP_CACHE) { return; } $test = AJXP_Utils::loadSerialFile(AJXP_PLUGINS_QUERIES_CACHE); if (!is_array($test)) { $test = array(); } $test[$key] = $value; AJXP_Utils::saveSerialFile(AJXP_PLUGINS_QUERIES_CACHE, $test); }
public function getTokens() { if ($this->repository->getOption("DROPBOX_OAUTH_TOKENS") !== null && is_array($this->repository->getOption("DROPBOX_OAUTH_TOKENS"))) { return $this->repository->getOption("DROPBOX_OAUTH_TOKENS"); } $repositoryId = $this->repository->getId(); if (AuthService::usersEnabled()) { $u = AuthService::getLoggedUser(); $userId = $u->getId(); if ($u->getResolveAsParent()) { $userId = $u->getParent(); } } else { $userId = "shared"; } return AJXP_Utils::loadSerialFile(AJXP_DATA_PATH . "/plugins/access.dropbox/" . $repositoryId . "_" . $userId . "_tokens"); }
/** * @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); }
public static function getBootstrapConf() { return AJXP_Utils::loadSerialFile(self::_getBootstrapFilePath(), false, "json"); }