public function doTest() { $checks = array(); $checks[] = AJXP_CACHE_DIR; $checks[] = AJXP_DATA_PATH; $checked = array(); $success = true; foreach ($checks as $check) { $w = false; $check = AJXP_VarsFilter::filter($check); if (!is_dir($check)) { // Check parent $check = dirname($check); } $w = is_writable($check); $checked[basename($check)] = "<b>" . basename($check) . "</b>:" . ($w ? 'true' : 'false'); $success = $success & $w; } $this->testedParams["Writeable Folders"] = "[" . implode(',<br> ', array_values($checked)) . "]"; if (!$success) { $this->failedInfo .= implode(",", $checks); return FALSE; } $this->failedLevel = "info"; $this->failedInfo = "[" . implode(',<br>', array_values($checked)) . "]"; return FALSE; }
function init($options) { parent::init($options); $this->repoSerialFile = AJXP_VarsFilter::filter($options["REPOSITORIES_FILEPATH"]); $this->usersSerialDir = AJXP_VarsFilter::filter($options["USERS_DIRPATH"]); $this->rolesSerialFile = AJXP_VarsFilter::filter($options["ROLES_FILEPATH"]); $this->aliasesIndexFile = dirname($this->repoSerialFile) . "/aliases.ser"; $this->pluginsConfigsFile = dirname($this->repoSerialFile) . "/plugins_configs.ser"; }
public function init($options) { parent::init($options); if (AJXP_Utils::searchIncludePath('Auth/Yubico.php')) { require_once 'Auth/Yubico.php'; } $this->usersSerFile = AJXP_VarsFilter::filter($this->getOption("USERS_FILEPATH")); $this->yubico_secret_key = AJXP_VarsFilter::filter($this->getOption("YUBICO_SECRET_KEY")); $this->yubico_client_id = AJXP_VarsFilter::filter($this->getOption("YUBICO_CLIENT_ID")); }
public function init($options) { //parent::init($options); $this->options = $options; set_include_path(get_include_path() . PATH_SEPARATOR . AJXP_INSTALL_PATH . "/plugins/index.lucene"); if (!empty($this->options["index_meta_fields"])) { $this->metaFields = explode(",", $this->options["index_meta_fields"]); } if (!empty($this->options["repository_specific_keywords"])) { $this->specificId = "-" . str_replace(",", "-", AJXP_VarsFilter::filter($this->options["repository_specific_keywords"])); } $this->indexContent = $this->options["index_content"] == true; }
public function init($options) { parent::init($options); set_include_path(get_include_path() . PATH_SEPARATOR . AJXP_INSTALL_PATH . "/plugins/index.lucene"); $metaFields = $this->getFilteredOption("index_meta_fields"); $specKey = $this->getFilteredOption("repository_specific_keywords"); if (!empty($metaFields)) { $this->metaFields = explode(",", $metaFields); } if (!empty($specKey)) { $this->specificId = "-" . str_replace(array(",", "/"), array("-", "__"), AJXP_VarsFilter::filter($specKey)); } $this->indexContent = $this->getFilteredOption("index_content") == true; }
public function doTest() { //include(AJXP_CONF_PATH."/bootstrap_plugins.php"); $checks = array(); /* if (isSet($PLUGINS["CONF_DRIVER"])) { $confDriver = $PLUGINS["CONF_DRIVER"]; if (isSet($confDriver["OPTIONS"]) && isSet($confDriver["OPTIONS"]["REPOSITORIES_FILEPATH"])) { $checks[] = dirname($confDriver["OPTIONS"]["REPOSITORIES_FILEPATH"]); } if (isSet($confDriver["OPTIONS"]) && isSet($confDriver["OPTIONS"]["USERS_DIRPATH"])) { $checks[] = $confDriver["OPTIONS"]["REPOSITORIES_FILEPATH"]; } } if (isset($PLUGINS["AUTH_DRIVER"])) { $authDriver = $PLUGINS["AUTH_DRIVER"]; if (isset($authDriver["OPTIONS"]) && isSet($authDriver["OPTIONS"]["USERS_FILEPATH"])) { $checks[] = dirname($authDriver["OPTIONS"]["USERS_FILEPATH"]); } } if (isset($PLUGINS["LOG_DRIVER"])) { if (isset($PLUGINS["LOG_DRIVER"]["OPTIONS"]) && isSet($PLUGINS["LOG_DRIVER"]["OPTIONS"]["LOG_PATH"])) { $checks[] = $PLUGINS["LOG_DRIVER"]["OPTIONS"]["LOG_PATH"]; } } */ $checks[] = AJXP_CACHE_DIR; $checks[] = AJXP_DATA_PATH; $checked = array(); $success = true; foreach ($checks as $check) { $w = false; $check = AJXP_VarsFilter::filter($check); if (!is_dir($check)) { // Check parent $check = dirname($check); } $w = is_writable($check); $checked[basename($check)] = "<b>" . basename($check) . "</b>:" . ($w ? 'true' : 'false'); $success = $success & $w; } $this->testedParams["Writeable Folders"] = "[" . implode(',<br> ', array_values($checked)) . "]"; if (!$success) { $this->failedInfo .= implode(",", $checks); return FALSE; } $this->failedLevel = "info"; $this->failedInfo = "[" . implode(',<br>', array_values($checked)) . "]"; return FALSE; }
public function init($options) { parent::init($options); $metaFields = $this->getFilteredOption("index_meta_fields"); $specKey = $this->getFilteredOption("repository_specific_keywords"); if (!empty($metaFields)) { $this->metaFields = explode(",", $metaFields); } if (!empty($specKey)) { $this->specificId = "-" . str_replace(array(",", "/"), array("-", "__"), AJXP_VarsFilter::filter($specKey)); } /* Connexion to Elastica Client with the default parameters */ $this->client = new Elastica\Client(array("host" => $this->getFilteredOption("ELASTICSEARCH_HOST"), "port" => $this->getFilteredOption("ELASTICSEARCH_PORT"))); $this->indexContent = $this->getFilteredOption("index_content") == true; }
protected function getOption($name, $user = "", $pass = "", $escapePass = true) { $opt = $this->options[$name]; $opt = str_replace("AJXP_USER", $user, $opt); if ($escapePass) { $opt = str_replace("AJXP_PASS", "'{$pass}'", $opt); } else { $opt = str_replace("AJXP_PASS", $pass, $opt); } $opt = str_replace("AJXP_SERVER_UID", posix_getuid(), $opt); $opt = str_replace("AJXP_SERVER_GID", posix_getgid(), $opt); if (stristr($opt, "AJXP_REPOSITORY_PATH") !== false) { $repo = ConfService::getRepository(); $path = $repo->getOption("PATH"); $opt = str_replace("AJXP_REPOSITORY_PATH", $path, $opt); } $opt = AJXP_VarsFilter::filter($opt); return $opt; }
/** * Initialise the text log driver. * * Sets the user defined options. * Makes sure that the folder and file exist, and makes them if they don't. * * @param Array $options array of options specific to the logger driver. * @access public * @return null */ public function init($options) { parent::init($options); $this->severityDescription = 0; $this->stack = array(); $this->fileHandle = false; $this->storageDir = isset($this->options['LOG_PATH']) ? $this->options['LOG_PATH'] : ""; $this->storageDir = AJXP_VarsFilter::filter($this->storageDir); $this->storageDir = rtrim($this->storageDir) . "/"; $this->logFileName = isset($this->options['LOG_FILE_NAME']) ? $this->options['LOG_FILE_NAME'] : 'log_' . date('m-d-y') . '.txt'; $this->USER_GROUP_RIGHTS = isset($this->options['LOG_CHMOD']) ? $this->options['LOG_CHMOD'] : 0770; if (preg_match("/(.*)date\\('(.*)'\\)(.*)/i", $this->logFileName, $matches)) { $this->logFileName = $matches[1] . date($matches[2]) . $matches[3]; } $this->initStorage(); }
/** * Initialise the text log driver. * * Sets the user defined options. * Makes sure that the folder and file exist, and makes them if they don't. * * @param Array $options array of options specific to the logger driver. * @access public * @return null */ function init($options) { $this->severityDescription = 0; $this->stack = array(); $this->fileHandle = false; $this->storageDir = isset($options['LOG_PATH']) ? $options['LOG_PATH'] : ""; $this->storageDir = AJXP_VarsFilter::filter($this->storageDir); $this->logFileName = isset($options['LOG_FILE_NAME']) ? $options['LOG_FILE_NAME'] : 'log_' . date('m-d-y') . '.txt'; $this->USER_GROUP_RIGHTS = isset($options['LOG_CHMOD']) ? $options['LOG_CHMOD'] : 0770; $this->initStorage(); }
public function load() { $groups = AJXP_Utils::loadSerialFile(AJXP_VarsFilter::filter($this->storage->getOption("USERS_DIRPATH")) . "/groups.ser"); if (isset($groups[$this->getId()])) { $this->groupPath = $groups[$this->getId()]; } $this->create = false; $this->rights = AJXP_Utils::loadSerialFile($this->getStoragePath() . "/rights.ser"); if (count($this->rights) == 0) { $this->create = true; } $this->prefs = AJXP_Utils::loadSerialFile($this->getStoragePath() . "/prefs.ser"); $this->bookmarks = AJXP_Utils::loadSerialFile($this->getStoragePath() . "/bookmarks.ser"); if (isset($this->rights["ajxp.admin"]) && $this->rights["ajxp.admin"] === true) { $this->setAdmin(true); } if (isset($this->rights["ajxp.parent_user"])) { //$this->setParent($this->rights["ajxp.parent_user"]); parent::setParent($this->rights["ajxp.parent_user"]); } if (isset($this->rights["ajxp.group_path"])) { $this->setGroupPath($this->rights["ajxp.group_path"]); } if (isset($this->rights["ajxp.children_pointer"])) { $this->childrenPointer = $this->rights["ajxp.children_pointer"]; } // LOAD ROLES $rolesToLoad = array(); if (isset($this->rights["ajxp.roles"])) { $rolesToLoad = array_keys($this->rights["ajxp.roles"]); } if ($this->groupPath != null) { $base = ""; $exp = explode("/", $this->groupPath); foreach ($exp as $pathPart) { if (empty($pathPart)) { continue; } $base = $base . "/" . $pathPart; $rolesToLoad[] = "AJXP_GRP_" . $base; } } // Load roles if (count($rolesToLoad)) { $allRoles = AuthService::getRolesList($rolesToLoad); foreach ($rolesToLoad as $roleId) { if (isset($allRoles[$roleId])) { $this->roles[$roleId] = $allRoles[$roleId]; $this->rights["ajxp.roles"][$roleId] = true; } else { if (is_array($this->rights["ajxp.roles"]) && isset($this->rights["ajxp.roles"][$roleId])) { unset($this->rights["ajxp.roles"][$roleId]); } } } } // LOAD USR ROLE LOCALLY $personalRole = AJXP_Utils::loadSerialFile($this->getStoragePath() . "/role.ser"); if (is_a($personalRole, "AJXP_Role")) { $this->personalRole = $personalRole; $this->roles["AJXP_USR_" . "/" . $this->id] = $personalRole; } else { // MIGRATE NOW ! $changes = $this->migrateRightsToPersonalRole(); if ($changes) { AJXP_Utils::saveSerialFile($this->getStoragePath() . "/role.ser", $this->personalRole, true); AJXP_Utils::saveSerialFile($this->getStoragePath() . "/rights.ser", $this->rights, true); } } $this->recomputeMergedRole(); }
public function testSQLConnexion($httpVars) { $p = AJXP_Utils::cleanDibiDriverParameters($httpVars["SQL_CUSTOM_DRIVER"]); if ($p["driver"] == "sqlite3") { $dbFile = AJXP_VarsFilter::filter($p["database"]); if (!file_exists(dirname($dbFile))) { mkdir(dirname($dbFile), 0755, true); } } // Should throw an exception if there was a problem. dibi::connect($p); $cTableName = $httpVars["SQL_CUSTOM_TABLE"]; $cUserField = $httpVars["SQL_CUSTOM_TABLE_USER_FIELD"]; $cUserValue = $httpVars["SQL_CUSTOM_TABLE_TEST_USER"]; $res = dibi::query("SELECT COUNT(*) FROM [" . $cTableName . "] WHERE [" . $cUserField . "]=%s", $cUserValue); $found = intval($res->fetchSingle()) > 0; if (!$found) { throw new Exception("Could connect to the DB but could not find user " . $cUserValue); } dibi::disconnect(); echo "SUCCESS:Connexion established and user {$cUserValue} found in DB"; }
/** * The label of this repository * @return String */ public function getDisplay() { if (isset($this->displayStringId)) { $mess = ConfService::getMessages(); if (isset($mess[$this->displayStringId])) { return $mess[$this->displayStringId]; } } return AJXP_VarsFilter::filter($this->display); }
/** * 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; }
public function init($options) { parent::init($options); $this->url = AJXP_VarsFilter::filter($this->getOption("GITLAB_URL")); $this->usersSerFile = $options["USERS_FILEPATH"]; }
/** * Get config from the core.$coreType plugin * @static * @param string $varName * @param string $coreType * @return mixed|null|string */ public static function getCoreConf($varName, $coreType = "ajaxplorer") { $coreP = AJXP_PluginsService::getInstance()->findPlugin("core", $coreType); if ($coreP === false) { return null; } $confs = $coreP->getConfigs(); $confs = AuthService::filterPluginParameters("core." . $coreType, $confs); return isset($confs[$varName]) ? AJXP_VarsFilter::filter($confs[$varName]) : null; }
public function init($options) { parent::init($options); $this->usersSerFile = AJXP_VarsFilter::filter($this->getOption("USERS_FILEPATH")); }
/** * * Try to reapply correct permissions * @param oct $mode * @param Repository $repoObject * @param Function $remoteDetectionCallback */ public static function fixPermissions(&$stat, $repoObject, $remoteDetectionCallback = null) { $fixPermPolicy = $repoObject->getOption("FIX_PERMISSIONS"); $loggedUser = AuthService::getLoggedUser(); if ($loggedUser == null) { return; } $sessionKey = md5($repoObject->getId() . "-" . $loggedUser->getId() . "-fixPermData"); if (!isset($_SESSION[$sessionKey])) { if ($fixPermPolicy == "detect_remote_user_id" && $remoteDetectionCallback != null) { list($uid, $gid) = call_user_func($remoteDetectionCallback, $repoObject); if ($uid != null && $gid != null) { $_SESSION[$sessionKey] = array("uid" => $uid, "gid" => $gid); } } else { if (substr($fixPermPolicy, 0, strlen("file:")) == "file:") { $filePath = AJXP_VarsFilter::filter(substr($fixPermPolicy, strlen("file:"))); if (file_exists($filePath)) { // GET A GID/UID FROM FILE $lines = file($filePath); foreach ($lines as $line) { $res = explode(":", $line); if ($res[0] == $loggedUser->getId()) { $uid = $res[1]; $gid = $res[2]; $_SESSION[$sessionKey] = array("uid" => $uid, "gid" => $gid); break; } } } } } // If not set, set an empty anyway if (!isset($_SESSION[$sessionKey])) { $_SESSION[$sessionKey] = array(null, null); } } else { $data = $_SESSION[$sessionKey]; if (!empty($data)) { if (isset($data["uid"])) { $uid = $data["uid"]; } if (isset($data["gid"])) { $gid = $data["gid"]; } } } $p = $stat["mode"]; $st = sprintf("%07o", $p & 7777770); AJXP_Logger::debug("FIX PERM DATA ({$fixPermPolicy}, {$st})" . $p, sprintf("%o", $p & 0777)); if ($p != NULL) { $isdir = $p & 040000 ? true : false; $changed = false; if (isset($uid) && $stat["uid"] == $uid || $fixPermPolicy == "user") { AJXP_Logger::debug("upgrading abit to ubit"); $changed = true; $p = $p & 7777770; if ($p & 0x100) { $p += 04; } if ($p & 0x80) { $p += 02; } if ($p & 0x40) { $p += 01; } } else { if (isset($gid) && $stat["gid"] == $gid || $fixPermPolicy == "group") { AJXP_Logger::debug("upgrading abit to gbit"); $changed = true; $p = $p & 7777770; if ($p & 0x20) { $p += 04; } if ($p & 0x10) { $p += 02; } if ($p & 0x8) { $p += 01; } } } if ($isdir && $changed) { $p += 040000; } $stat["mode"] = $stat[2] = $p; AJXP_Logger::debug("FIXED PERM DATA ({$fixPermPolicy})", sprintf("%o", $p & 0777)); } }
/** * The label of this repository * @return String */ public function getDisplay() { if (isset($this->displayStringId)) { $mess = ConfService::getMessages(); if (isset($mess[$this->displayStringId])) { return SystemTextEncoding::fromUTF8($mess[$this->displayStringId]); } } return AJXP_VarsFilter::filter($this->display); }
/** * @param String $repositoryId * @param String $userId * @return string */ protected function buildSpecificId($repositoryId, $userId = null) { $specificId = ""; $specKey = $this->getFilteredOption("repository_specific_keywords"); if (!empty($specKey)) { $specificId = "-" . str_replace(array(",", "/"), array("-", "__"), AJXP_VarsFilter::filter($specKey, $userId)); } return $repositoryId . $specificId; }
/** * @param $repositoryId * @param null $resolveUserId * @return string */ protected function getIndexPath($repositoryId, $resolveUserId = null) { $mainCacheDir = defined('AJXP_SHARED_CACHE_DIR') ? AJXP_SHARED_CACHE_DIR : AJXP_CACHE_DIR; $specificId = $this->specificId; if ($resolveUserId != null) { $specKey = $this->getFilteredOption("repository_specific_keywords"); if (!empty($specKey)) { $specKey = str_replace("AJXP_USER", $resolveUserId, $specKey); $specificId = "-" . str_replace(array(",", "/"), array("-", "__"), AJXP_VarsFilter::filter($specKey)); } } if (!is_dir($mainCacheDir . "/indexes")) { mkdir($mainCacheDir . "/indexes", 0755, true); } $iPath = $mainCacheDir . "/indexes/index-{$repositoryId}" . $specificId; return $iPath; }
public function getLogoutRedirect() { return AJXP_VarsFilter::filter($this->getOption("LOGOUT_URL")); }
public static function cleanDibiDriverParameters($params) { if (!is_array($params)) { return $params; } $value = $params["group_switch_value"]; if (isset($value)) { if (isset(self::$_dibiParamClean[$value])) { return self::$_dibiParamClean[$value]; } if ($value == "core") { $bootStorage = ConfService::getBootConfStorageImpl(); $configs = $bootStorage->loadPluginConfig("core", "conf"); $params = $configs["DIBI_PRECONFIGURATION"]; if (!is_array($params)) { throw new Exception("Empty SQL default connexion, there is something wrong with your setup! You may have switch to an SQL-based plugin without defining a connexion."); } } else { unset($params["group_switch_value"]); } foreach ($params as $k => $v) { $explode = explode("_", $k, 2); $params[array_pop($explode)] = AJXP_VarsFilter::filter($v); unset($params[$k]); } } switch ($params["driver"]) { case "sqlite": case "sqlite3": $params["formatDateTime"] = "'Y-m-d H:i:s'"; $params["formatDate"] = "'Y-m-d'"; break; } if (isset($value)) { self::$_dibiParamClean[$value] = $params; } return $params; }
/** * Stores an Array as a serialized string inside a file. * * @param String $filePath Full path to the file * @param Array $value The value to store * @param Boolean $createDir Whether to create the parent folder or not, if it does not exist. * @param bool $silent Silently write the file, are throw an exception on problem. */ static function saveSerialFile($filePath, $value, $createDir = true, $silent = false, $format = "ser") { $filePath = AJXP_VarsFilter::filter($filePath); if ($createDir && !is_dir(dirname($filePath))) { if (!is_writeable(dirname(dirname($filePath)))) { if ($silent) { return; } else { throw new Exception("[AJXP_Utils::saveSerialFile] Cannot write into " . dirname(dirname($filePath))); } } mkdir(dirname($filePath)); } try { $fp = fopen($filePath, "w"); if ($format == "ser") { $content = serialize($value); } else { if ($format == "json") { $content = json_encode($value); } } fwrite($fp, $content); fclose($fp); } catch (Exception $e) { if ($silent) { return; } else { throw $e; } } }
/** * Static function for deleting a user * * @param String $userId * @param Array $deletedSubUsers */ static function deleteUser($userId, &$deletedSubUsers) { $storage = ConfService::getConfStorageImpl(); $serialDir = AJXP_VarsFilter::filter($storage->getOption("USERS_DIRPATH")); $files = glob($serialDir . "/" . $userId . "/*.ser"); if (is_array($files) && count($files)) { foreach ($files as $file) { unlink($file); } } if (is_dir($serialDir . "/" . $userId)) { rmdir($serialDir . "/" . $userId); } $authDriver = ConfService::getAuthDriverImpl(); $confDriver = ConfService::getConfStorageImpl(); $users = $authDriver->listUsers(); foreach (array_keys($users) as $id) { $object = $confDriver->createUserObject($id); if ($object->hasParent() && $object->getParent() == $userId) { AJXP_User::deleteUser($id, $deletedSubUsers); $deletedSubUsers[] = $id; } } }
/** * Get the repository options, filtered in various maners * @param string $oName * @param bool $safe Do not filter * @return mixed|string */ function getOption($oName, $safe = false) { if (isset($this->options[$oName])) { $value = $this->options[$oName]; if (!$safe) { $value = AJXP_VarsFilter::filter($value); } return $value; } if ($this->inferOptionsFromParent) { if (!isset($this->parentTemplateObject)) { $this->parentTemplateObject = ConfService::getRepositoryById($this->parentId); } if (isset($this->parentTemplateObject)) { return $this->parentTemplateObject->getOption($oName, $safe); } } return ""; }
/** * Helpers to test SQL connection and send a test email. * @param $action * @param $httpVars * @param $fileVars * @throws Exception */ public function testConnexions($action, $httpVars, $fileVars) { $data = array(); AJXP_Utils::parseStandardFormParameters($httpVars, $data, null, "DRIVER_OPTION_"); if ($action == "boot_test_sql_connexion") { $p = AJXP_Utils::cleanDibiDriverParameters($data["db_type"]); if ($p["driver"] == "sqlite3") { $dbFile = AJXP_VarsFilter::filter($p["database"]); if (!file_exists(dirname($dbFile))) { mkdir(dirname($dbFile), 0755, true); } } // Should throw an exception if there was a problem. dibi::connect($p); dibi::disconnect(); echo 'SUCCESS:Connexion established!'; } else { if ($action == "boot_test_mailer") { $mailerPlug = AJXP_PluginsService::findPluginById("mailer.phpmailer-lite"); $mailerPlug->loadConfigs(array("MAILER" => $data["MAILER_ENABLE"]["MAILER_SYSTEM"])); $mailerPlug->sendMail(array("adress" => $data["MAILER_ENABLE"]["MAILER_ADMIN"]), "Pydio Test Mail", "Body of the test", array("adress" => $data["MAILER_ENABLE"]["MAILER_ADMIN"])); echo 'SUCCESS:Mail sent to the admin adress, please check it is in your inbox!'; } } }
/** * @param String $pluginId * @param Repository $repository * @param String $optionName * @param bool $safe * @return Mixed */ public static function getFilteredRepositoryOption($pluginId, $repository, $optionName, $safe = false) { $logged = self::getLoggedUser(); $test = null; if ($logged != null) { $test = $logged->mergedRole->filterParameterValue($pluginId, $optionName, $repository->getId(), null); if (!empty($test) && !$safe) { $test = AJXP_VarsFilter::filter($test); } } if (empty($test)) { return $repository->getOption($optionName, $safe); } else { return $test; } }
/** * Function for deleting a user * * @param String $userId * @param Array $deletedSubUsers */ public function deleteUser($userId, &$deletedSubUsers) { $user = $this->createUserObject($userId); $files = glob($user->getStoragePath() . "/*.ser"); if (is_array($files) && count($files)) { foreach ($files as $file) { unlink($file); } } if (is_dir($user->getStoragePath())) { rmdir($user->getStoragePath()); } // DELETE CHILDREN USING POINTER IF POSSIBLE $users = $this->getUserChildren($userId); // $authDriver->listUsers(); foreach (array_keys($users) as $id) { $object = $this->createUserObject($id); if ($object->hasParent() && $object->getParent() == $userId) { $this->deleteUser($id, $deletedSubUsers); $deletedSubUsers[] = $id; } } // CLEAR PARENT POINTER IF NECESSARY if ($user->hasParent()) { $parentObject = $this->createUserObject($user->getParent()); $pointer = $parentObject->getChildrenPointer(); if ($pointer !== null) { unset($pointer[$userId]); $parentObject->setChildrenPointer($pointer); $parentObject->save("superuser"); if (AuthService::getLoggedUser() != null && AuthService::getLoggedUser()->getId() == $parentObject->getId()) { AuthService::updateUser($parentObject); } } } $groups = AJXP_Utils::loadSerialFile(AJXP_VarsFilter::filter($user->storage->getOption("USERS_DIRPATH")) . "/groups.ser"); if (isset($groups[$userId])) { unset($groups[$userId]); AJXP_Utils::saveSerialFile(AJXP_VarsFilter::filter($user->storage->getOption("USERS_DIRPATH")) . "/groups.ser", $groups); } }
/** * * Try to reapply correct permissions * @param array $stat * @param Repository $repoObject * @param callable $remoteDetectionCallback * @internal param \oct $mode */ public static function fixPermissions(&$stat, $repoObject, $remoteDetectionCallback = null) { $fixPermPolicy = $repoObject->getOption("FIX_PERMISSIONS"); $loggedUser = AuthService::getLoggedUser(); if ($loggedUser == null) { return; } $sessionKey = md5($repoObject->getId() . "-" . $loggedUser->getId() . "-fixPermData"); if (!isset($_SESSION[$sessionKey])) { if ($fixPermPolicy == "detect_remote_user_id" && $remoteDetectionCallback != null) { list($uid, $gid) = call_user_func($remoteDetectionCallback, $repoObject); if ($uid != null && $gid != null) { $_SESSION[$sessionKey] = array("uid" => $uid, "gid" => $gid); } } else { if (substr($fixPermPolicy, 0, strlen("file:")) == "file:") { $filePath = AJXP_VarsFilter::filter(substr($fixPermPolicy, strlen("file:"))); if (file_exists($filePath)) { // GET A GID/UID FROM FILE $lines = file($filePath); foreach ($lines as $line) { $res = explode(":", $line); if ($res[0] == $loggedUser->getId()) { $uid = $res[1]; $gid = $res[2]; $_SESSION[$sessionKey] = array("uid" => $uid, "gid" => $gid); break; } } } } } // If not set, set an empty anyway if (!isset($_SESSION[$sessionKey])) { $_SESSION[$sessionKey] = array(null, null); } } else { $data = $_SESSION[$sessionKey]; if (!empty($data)) { if (isset($data["uid"])) { $uid = $data["uid"]; } if (isset($data["gid"])) { $gid = $data["gid"]; } } } $p = $stat["mode"]; //$st = sprintf("%07o", ($p & 7777770)); //AJXP_Logger::debug("FIX PERM DATA ($fixPermPolicy, $st)".$p,sprintf("%o", ($p & 000777))); if ($p != NULL) { /* decoct returns a string, it's more convenient to manipulate as we know the structure of the octal form of stat["mode"] - first two or three chars => file type (dir: 40, file: 100, symlink: 120) - three remaining characters => file permissions (1st char: user, 2nd char: group, 3rd char: others) */ $p = decoct($p); $lastInd = intval($p[0]) == 4 ? 4 : 5; $otherPerms = decbin(intval($p[$lastInd])); $actualPerms = $otherPerms; if (isset($uid) && $stat["uid"] == $uid || $fixPermPolicy == "user") { AJXP_Logger::debug(__CLASS__, __FUNCTION__, "upgrading abit to ubit"); $userPerms = decbin(intval($p[$lastInd - 2])); $actualPerms |= $userPerms; } else { if (isset($gid) && $stat["gid"] == $gid || $fixPermPolicy == "group") { AJXP_Logger::debug(__CLASS__, __FUNCTION__, "upgrading abit to gbit"); $groupPerms = decbin(intval($p[$lastInd - 1])); $actualPerms |= $groupPerms; } } $test = bindec($actualPerms); $p[$lastInd] = $test; $stat["mode"] = $stat[2] = octdec($p); //AJXP_Logger::debug(__CLASS__,__FUNCTION__,"FIXED PERM DATA ($fixPermPolicy)",sprintf("%o", ($p & 000777))); } }