本文整理汇总了PHP中AuthService::updateRole方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthService::updateRole方法的具体用法?PHP AuthService::updateRole怎么用?PHP AuthService::updateRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthService
的用法示例。
在下文中一共展示了AuthService::updateRole方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgradeRootRoleForWelcome
function upgradeRootRoleForWelcome()
{
$rootRole = AuthService::getRole("ROOT_ROLE");
if (!empty($rootRole)) {
echo '<br>Upgrading Root Role to let users access the new welcome page<br>';
$rootRole->setAcl("ajxp_home", "rw");
$rootRole->setParameterValue("core.conf", "DEFAULT_START_REPOSITORY", "ajxp_home");
AuthService::updateRole($rootRole);
}
}
示例2: testRolesStorage
public function testRolesStorage()
{
$r = new \AJXP_Role("phpunit_temporary_role");
$r->setAcl(0, "rw");
\AuthService::updateRole($r);
$r1 = \AuthService::getRole("phpunit_temporary_role");
$this->assertTrue(is_a($r1, "AJXP_Role"));
$this->assertEquals("rw", $r1->getAcl(0));
\AuthService::deleteRole("phpunit_temporary_role");
$r2 = \AuthService::getRole("phpunit_temporary_role");
$this->assertFalse($r2);
}
示例3: switchAction
//.........这里部分代码省略.........
AJXP_XMLWriter::reloadDataNode();
AJXP_XMLWriter::close();
break;
case "create_group":
if (isset($httpVars["group_path"])) {
$basePath = AJXP_Utils::forwardSlashDirname($httpVars["group_path"]);
if (empty($basePath)) {
$basePath = "/";
}
$gName = AJXP_Utils::sanitize(AJXP_Utils::decodeSecureMagic(basename($httpVars["group_path"])), AJXP_SANITIZE_ALPHANUM);
} else {
$basePath = substr($httpVars["dir"], strlen("/data/users"));
$gName = AJXP_Utils::sanitize(SystemTextEncoding::magicDequote($httpVars["group_name"]), AJXP_SANITIZE_ALPHANUM);
}
$gLabel = AJXP_Utils::decodeSecureMagic($httpVars["group_label"]);
AuthService::createGroup($basePath, $gName, $gLabel);
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.124"], null);
AJXP_XMLWriter::reloadDataNode();
AJXP_XMLWriter::close();
break;
case "create_role":
$roleId = AJXP_Utils::sanitize(SystemTextEncoding::magicDequote($httpVars["role_id"]), AJXP_SANITIZE_HTML_STRICT);
if (!strlen($roleId)) {
throw new Exception($mess[349]);
}
if (AuthService::getRole($roleId) !== false) {
throw new Exception($mess["ajxp_conf.65"]);
}
$r = new AJXP_Role($roleId);
if (AuthService::getLoggedUser() != null && AuthService::getLoggedUser()->getGroupPath() != null) {
$r->setGroupPath(AuthService::getLoggedUser()->getGroupPath());
}
AuthService::updateRole($r);
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.66"], null);
AJXP_XMLWriter::reloadDataNode("", $httpVars["role_id"]);
AJXP_XMLWriter::close();
break;
case "edit_role":
$roleId = SystemTextEncoding::magicDequote($httpVars["role_id"]);
$roleGroup = false;
$userObject = null;
$groupLabel = null;
if (strpos($roleId, "AJXP_GRP_") === 0) {
$groupPath = substr($roleId, strlen("AJXP_GRP_"));
$filteredGroupPath = AuthService::filterBaseGroup($groupPath);
$groups = AuthService::listChildrenGroups(AJXP_Utils::forwardSlashDirname($groupPath));
$key = "/" . basename($groupPath);
if (!array_key_exists($key, $groups)) {
throw new Exception("Cannot find group with this id!");
}
$roleId = "AJXP_GRP_" . $filteredGroupPath;
$groupLabel = $groups[$key];
$roleGroup = true;
}
if (strpos($roleId, "AJXP_USR_") === 0) {
$usrId = str_replace("AJXP_USR_/", "", $roleId);
$userObject = ConfService::getConfStorageImpl()->createUserObject($usrId);
if (!AuthService::canAdministrate($userObject)) {
throw new Exception("Cant find user!");
}
$role = $userObject->personalRole;
} else {
$role = AuthService::getRole($roleId, $roleGroup);
}
示例4: bootSequence
/**
* Specific operations to perform at boot time
* @static
* @param array $START_PARAMETERS A HashTable of parameters to send back to the client
* @return void
*/
public static function bootSequence(&$START_PARAMETERS)
{
if (AJXP_Utils::detectApplicationFirstRun()) {
return;
}
if (file_exists(AJXP_CACHE_DIR . "/admin_counted")) {
return;
}
$rootRole = AuthService::getRole("ROOT_ROLE", false);
if ($rootRole === false) {
$rootRole = new AJXP_Role("ROOT_ROLE");
$rootRole->setLabel("Root Role");
$rootRole->setAutoApplies(array("standard", "admin"));
$dashId = "";
foreach (ConfService::getRepositoriesList("all") as $repositoryId => $repoObject) {
if ($repoObject->isTemplate) {
continue;
}
if ($repoObject->getAccessType() == "ajxp_user") {
$dashId = $repositoryId;
}
$gp = $repoObject->getGroupPath();
if (empty($gp) || $gp == "/") {
if ($repoObject->getDefaultRight() != "") {
$rootRole->setAcl($repositoryId, $repoObject->getDefaultRight());
}
}
}
if (!empty($dashId)) {
$rootRole->setParameterValue("core.conf", "DEFAULT_START_REPOSITORY", $dashId);
}
$paramNodes = AJXP_PluginsService::searchAllManifests("//server_settings/param[@scope]", "node", false, false, true);
if (is_array($paramNodes) && count($paramNodes)) {
foreach ($paramNodes as $xmlNode) {
$default = $xmlNode->getAttribute("default");
if (empty($default)) {
continue;
}
$parentNode = $xmlNode->parentNode->parentNode;
$pluginId = $parentNode->getAttribute("id");
if (empty($pluginId)) {
$pluginId = $parentNode->nodeName . "." . $parentNode->getAttribute("name");
}
$rootRole->setParameterValue($pluginId, $xmlNode->getAttribute("name"), $default);
}
}
AuthService::updateRole($rootRole);
}
$miniRole = AuthService::getRole("MINISITE", false);
if ($miniRole === false) {
$rootRole = new AJXP_Role("MINISITE");
$rootRole->setLabel("Minisite Users");
$actions = array("access.fs" => array("ajxp_link", "chmod", "purge"), "meta.watch" => array("toggle_watch"), "conf.serial" => array("get_bookmarks"), "conf.sql" => array("get_bookmarks"), "index.lucene" => array("index"), "action.share" => array("share"), "gui.ajax" => array("bookmark"), "auth.serial" => array("pass_change"), "auth.sql" => array("pass_change"));
foreach ($actions as $pluginId => $acts) {
foreach ($acts as $act) {
$rootRole->setActionState($pluginId, $act, AJXP_REPO_SCOPE_SHARED, false);
}
}
AuthService::updateRole($rootRole);
}
$miniRole = AuthService::getRole("MINISITE_NODOWNLOAD", false);
if ($miniRole === false) {
$rootRole = new AJXP_Role("MINISITE_NODOWNLOAD");
$rootRole->setLabel("Minisite Users - No Download");
$actions = array("access.fs" => array("download", "download_chunk", "prepare_chunk_dl", "download_all"));
foreach ($actions as $pluginId => $acts) {
foreach ($acts as $act) {
$rootRole->setActionState($pluginId, $act, AJXP_REPO_SCOPE_SHARED, false);
}
}
AuthService::updateRole($rootRole);
}
$miniRole = AuthService::getRole("GUEST", false);
if ($miniRole === false) {
$rootRole = new AJXP_Role("GUEST");
$rootRole->setLabel("Guest user role");
$actions = array("access.fs" => array("purge"), "meta.watch" => array("toggle_watch"), "index.lucene" => array("index"));
$rootRole->setAutoApplies(array("guest"));
foreach ($actions as $pluginId => $acts) {
foreach ($acts as $act) {
$rootRole->setActionState($pluginId, $act, AJXP_REPO_SCOPE_ALL);
}
}
AuthService::updateRole($rootRole);
}
$adminCount = AuthService::countAdminUsers();
if ($adminCount == 0) {
$authDriver = ConfService::getAuthDriverImpl();
$adminPass = ADMIN_PASSWORD;
if ($authDriver->getOption("TRANSMIT_CLEAR_PASS") !== true) {
$adminPass = md5(ADMIN_PASSWORD);
}
AuthService::createUser("admin", $adminPass, true);
if (ADMIN_PASSWORD == INITIAL_ADMIN_PASSWORD) {
//.........这里部分代码省略.........
示例5: createSharedRepository
//.........这里部分代码省略.........
$options["META_SOURCES"][$index]["ENCODED_CREDENTIALS"] = AJXP_Safe::getEncodedCredentialString();
}
}
}
$newRepo = $repository->createSharedChild($label, $options, $repository->id, $loggedUser->id, null);
$gPath = $loggedUser->getGroupPath();
if (!empty($gPath) && !ConfService::getCoreConf("CROSSUSERS_ALLGROUPS", "conf")) {
$newRepo->setGroupPath($gPath);
}
$newRepo->setDescription($description);
ConfService::addRepository($newRepo);
}
$file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
if (isset($editingRepo)) {
$currentRights = $this->computeSharedRepositoryAccessRights($httpVars["repository_id"], false, $this->urlBase . $file);
$originalUsers = array_keys($currentRights["USERS"]);
$removeUsers = array_diff($originalUsers, $users);
if (count($removeUsers)) {
foreach ($removeUsers as $user) {
if (AuthService::userExists($user)) {
$userObject = $confDriver->createUserObject($user);
$userObject->personalRole->setAcl($newRepo->getUniqueId(), "");
$userObject->save("superuser");
}
}
}
$originalGroups = array_keys($currentRights["GROUPS"]);
$removeGroups = array_diff($originalGroups, $groups);
if (count($removeGroups)) {
foreach ($removeGroups as $groupId) {
$role = AuthService::getRole("AJXP_GRP_" . AuthService::filterBaseGroup($groupId));
if ($role !== false) {
$role->setAcl($newRepo->getUniqueId(), "");
AuthService::updateRole($role);
}
}
}
}
foreach ($users as $userName) {
if (AuthService::userExists($userName, "r")) {
// check that it's a child user
$userObject = $confDriver->createUserObject($userName);
} else {
if (ConfService::getAuthDriverImpl()->getOption("TRANSMIT_CLEAR_PASS")) {
$pass = $uPasses[$userName];
} else {
$pass = md5($uPasses[$userName]);
}
$limit = $loggedUser->personalRole->filterParameterValue("core.conf", "USER_SHARED_USERS_LIMIT", AJXP_REPO_SCOPE_ALL, "");
if (!empty($limit) && intval($limit) > 0) {
$count = count(ConfService::getConfStorageImpl()->getUserChildren($loggedUser->getId()));
if ($count >= $limit) {
$mess = ConfService::getMessages();
throw new Exception($mess['483']);
}
}
AuthService::createUser($userName, $pass);
$userObject = $confDriver->createUserObject($userName);
$userObject->personalRole->clearAcls();
$userObject->setParent($loggedUser->id);
$userObject->setGroupPath($loggedUser->getGroupPath());
$userObject->setProfile("shared");
if (isset($httpVars["minisite"])) {
$mess = ConfService::getMessages();
$userObject->personalRole->setParameterValue("core.conf", "USER_DISPLAY_NAME", "[" . $mess["share_center.109"] . "] " . $newRepo->getDisplay());
}
示例6: switchAction
function switchAction($action, $httpVars, $fileVars)
{
if (!isset($this->actions[$action])) {
return;
}
parent::accessPreprocess($action, $httpVars, $fileVars);
$loggedUser = AuthService::getLoggedUser();
if (AuthService::usersEnabled() && !$loggedUser->isAdmin()) {
return;
}
if ($action == "edit") {
if (isset($httpVars["sub_action"])) {
$action = $httpVars["sub_action"];
}
}
$mess = ConfService::getMessages();
switch ($action) {
//------------------------------------
// BASIC LISTING
//------------------------------------
case "ls":
$rootNodes = array("data" => array("LABEL" => $mess["ajxp_conf.110"], "ICON" => "user.png", "CHILDREN" => array("repositories" => array("LABEL" => $mess["ajxp_conf.3"], "ICON" => "hdd_external_unmount.png", "LIST" => "listRepositories"), "users" => array("LABEL" => $mess["ajxp_conf.2"], "ICON" => "user.png", "LIST" => "listUsers"), "roles" => array("LABEL" => $mess["ajxp_conf.69"], "ICON" => "yast_kuser.png", "LIST" => "listRoles"))), "config" => array("LABEL" => $mess["ajxp_conf.109"], "ICON" => "preferences_desktop.png", "CHILDREN" => array("core" => array("LABEL" => $mess["ajxp_conf.98"], "ICON" => "preferences_desktop.png", "LIST" => "listPlugins"), "plugins" => array("LABEL" => $mess["ajxp_conf.99"], "ICON" => "folder_development.png", "LIST" => "listPlugins"))), "admin" => array("LABEL" => $mess["ajxp_conf.111"], "ICON" => "toggle_log.png", "CHILDREN" => array("logs" => array("LABEL" => $mess["ajxp_conf.4"], "ICON" => "toggle_log.png", "LIST" => "listLogFiles"), "files" => array("LABEL" => $mess["ajxp_shared.3"], "ICON" => "html.png", "LIST" => "listSharedFiles"), "diagnostic" => array("LABEL" => $mess["ajxp_conf.5"], "ICON" => "susehelpcenter.png", "LIST" => "printDiagnostic"))));
AJXP_Controller::applyHook("ajxp_conf.list_config_nodes", array(&$rootNodes));
$dir = trim(AJXP_Utils::decodeSecureMagic(isset($httpVars["dir"]) ? $httpVars["dir"] : ""), " /");
if ($dir != "") {
$splits = explode("/", $dir);
$root = array_shift($splits);
if (count($splits)) {
$child = $splits[0];
if (strstr(urldecode($child), "#") !== false) {
list($child, $hash) = explode("#", urldecode($child));
}
if (isset($rootNodes[$root]["CHILDREN"][$child])) {
$callback = $rootNodes[$root]["CHILDREN"][$child]["LIST"];
if (is_string($callback) && method_exists($this, $callback)) {
AJXP_XMLWriter::header();
call_user_func(array($this, $callback), implode("/", $splits), $root, $hash);
AJXP_XMLWriter::close();
} else {
if (is_array($callback)) {
call_user_func($callback, implode("/", $splits), $root, $hash);
}
}
return;
}
} else {
$parentName = "/" . $root . "/";
$nodes = $rootNodes[$root]["CHILDREN"];
}
} else {
$parentName = "/";
$nodes = $rootNodes;
}
if (isset($nodes)) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendFilesListComponentConfig('<columns switchGridMode="filelist"><column messageId="ajxp_conf.1" attributeName="ajxp_label" sortType="String"/></columns>');
foreach ($nodes as $key => $data) {
print '<tree text="' . AJXP_Utils::xmlEntities($data["LABEL"]) . '" icon="' . $data["ICON"] . '" filename="' . $parentName . $key . '"/>';
}
AJXP_XMLWriter::close();
}
break;
case "stat":
header("Content-type:application/json");
print '{"mode":true}';
return;
break;
case "create_role":
$roleId = AJXP_Utils::sanitize(SystemTextEncoding::magicDequote($httpVars["role_id"]), AJXP_SANITIZE_HTML_STRICT);
if (!strlen($roleId)) {
throw new Exception($mess[349]);
}
if (AuthService::getRole($roleId) !== false) {
throw new Exception($mess["ajxp_conf.65"]);
}
AuthService::updateRole(new AjxpRole($roleId));
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.66"], null);
AJXP_XMLWriter::reloadDataNode("", $httpVars["role_id"]);
AJXP_XMLWriter::close();
break;
case "edit_role":
$roleId = SystemTextEncoding::magicDequote($httpVars["role_id"]);
$role = AuthService::getRole($roleId);
if ($role === false) {
throw new Exception("Cant find role! ");
}
AJXP_XMLWriter::header("admin_data");
print AJXP_XMLWriter::writeRoleRepositoriesData($role);
AJXP_XMLWriter::close("admin_data");
break;
case "update_role_right":
if (!isset($httpVars["role_id"]) || !isset($httpVars["repository_id"]) || !isset($httpVars["right"])) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.61"]);
print "<update_checkboxes user_id=\"" . $httpVars["role_id"] . "\" repository_id=\"" . $httpVars["repository_id"] . "\" read=\"old\" write=\"old\"/>";
AJXP_XMLWriter::close();
return;
}
$role = AuthService::getRole($httpVars["role_id"]);
//.........这里部分代码省略.........
示例7: createSharedRepository
//.........这里部分代码省略.........
$newRepo->setContentFilter(new ContentFilter($httpVars["filter_nodes"]));
}
ConfService::addRepository($newRepo);
if (!isset($httpVars["minisite"])) {
$this->getShareStore()->storeShare($repository->getId(), array("REPOSITORY" => $newRepo->getUniqueId(), "OWNER_ID" => $loggedUser->getId()), "repository");
}
}
$sel = new UserSelection($this->repository, $httpVars);
$file = $sel->getUniqueFile();
$newRepoUniqueId = $newRepo->getUniqueId();
if (isset($editingRepo)) {
$currentRights = $this->computeSharedRepositoryAccessRights($httpVars["repository_id"], false, $this->urlBase . $file);
$originalUsers = array_keys($currentRights["USERS"]);
$removeUsers = array_diff($originalUsers, $users);
if (count($removeUsers)) {
foreach ($removeUsers as $user) {
if (AuthService::userExists($user)) {
$userObject = $confDriver->createUserObject($user);
$userObject->personalRole->setAcl($newRepoUniqueId, "");
$userObject->save("superuser");
}
if ($this->watcher !== false) {
$this->watcher->removeWatchFromFolder(new AJXP_Node($this->urlBase . $file), $user, true);
}
}
}
$originalGroups = array_keys($currentRights["GROUPS"]);
$removeGroups = array_diff($originalGroups, $groups);
if (count($removeGroups)) {
foreach ($removeGroups as $groupId) {
$role = AuthService::getRole($groupId);
if ($role !== false) {
$role->setAcl($newRepoUniqueId, "");
AuthService::updateRole($role);
}
}
}
}
foreach ($users as $userName) {
if (AuthService::userExists($userName, "r")) {
// check that it's a child user
$userObject = $confDriver->createUserObject($userName);
} else {
if (ConfService::getAuthDriverImpl()->getOptionAsBool("TRANSMIT_CLEAR_PASS")) {
$pass = $uPasses[$userName];
} else {
$pass = md5($uPasses[$userName]);
}
if (!isset($httpVars["minisite"])) {
// This is an explicit user creation - check possible limits
AJXP_Controller::applyHook("user.before_create", array($userName, null, false, false));
$limit = $loggedUser->personalRole->filterParameterValue("core.conf", "USER_SHARED_USERS_LIMIT", AJXP_REPO_SCOPE_ALL, "");
if (!empty($limit) && intval($limit) > 0) {
$count = count(ConfService::getConfStorageImpl()->getUserChildren($loggedUser->getId()));
if ($count >= $limit) {
$mess = ConfService::getMessages();
throw new Exception($mess['483']);
}
}
}
AuthService::createUser($userName, $pass, false, isset($httpVars["minisite"]));
$userObject = $confDriver->createUserObject($userName);
$userObject->personalRole->clearAcls();
$userObject->setParent($loggedUser->id);
$userObject->setGroupPath($loggedUser->getGroupPath());
$userObject->setProfile("shared");
示例8: createUsers
/**
* Create the users based on the installer form results.
* @param array $data Parsed form results
* @param bool $loginIsEmail Whether to use the login as primary email.
* @throws Exception
*/
public function createUsers($data, $loginIsEmail = false)
{
$newConfigPlugin = ConfService::getConfStorageImpl();
require_once $newConfigPlugin->getUserClassFileName();
$adminLogin = AJXP_Utils::sanitize($data["ADMIN_USER_LOGIN"], AJXP_SANITIZE_EMAILCHARS);
$adminName = $data["ADMIN_USER_NAME"];
$adminPass = $data["ADMIN_USER_PASS"];
AuthService::createUser($adminLogin, $adminPass, true);
$uObj = $newConfigPlugin->createUserObject($adminLogin);
if ($loginIsEmail) {
$uObj->personalRole->setParameterValue("core.conf", "email", $data["ADMIN_USER_LOGIN"]);
} else {
if (isset($data["MAILER_ADMIN"])) {
$uObj->personalRole->setParameterValue("core.conf", "email", $data["MAILER_ADMIN"]);
}
}
$uObj->personalRole->setParameterValue("core.conf", "USER_DISPLAY_NAME", $adminName);
$repos = ConfService::getRepositoriesList("all", false);
foreach ($repos as $repo) {
$uObj->personalRole->setAcl($repo->getId(), "rw");
}
AuthService::updateRole($uObj->personalRole);
$loginP = "USER_LOGIN";
$i = 0;
while (isset($data[$loginP]) && !empty($data[$loginP])) {
$pass = $data[str_replace("_LOGIN", "_PASS", $loginP)];
$name = $data[str_replace("_LOGIN", "_NAME", $loginP)];
$mail = $data[str_replace("_LOGIN", "_MAIL", $loginP)];
$saniLogin = AJXP_Utils::sanitize($data[$loginP], AJXP_SANITIZE_EMAILCHARS);
AuthService::createUser($saniLogin, $pass);
$uObj = $newConfigPlugin->createUserObject($saniLogin);
$uObj->personalRole->setParameterValue("core.conf", "email", $mail);
$uObj->personalRole->setParameterValue("core.conf", "USER_DISPLAY_NAME", $name);
AuthService::updateRole($uObj->personalRole);
$i++;
$loginP = "USER_LOGIN_" . $i;
}
}
示例9: applyInstallerForm
//.........这里部分代码省略.........
}
$oldBoot = $this->getPluginWorkDir(true) . "/bootstrap.json";
if (is_file($oldBoot)) {
copy($oldBoot, $oldBoot . ".bak");
unlink($oldBoot);
}
$newBootstrap = array("core.conf" => $coreConf, "core.auth" => $coreAuth);
AJXP_Utils::saveSerialFile($oldBoot, $newBootstrap, true, false, "json", true);
// Write new bootstrap and reload conf plugin!
if ($storageType == "db") {
$coreConf["UNIQUE_INSTANCE_CONFIG"]["SQL_DRIVER"] = $coreConf["DIBI_PRECONFIGURATION"];
$coreAuth["MASTER_INSTANCE_CONFIG"]["SQL_DRIVER"] = $coreConf["DIBI_PRECONFIGURATION"];
}
$newConfigPlugin = ConfService::instanciatePluginFromGlobalParams($coreConf["UNIQUE_INSTANCE_CONFIG"], "AbstractConfDriver");
$newAuthPlugin = ConfService::instanciatePluginFromGlobalParams($coreAuth["MASTER_INSTANCE_CONFIG"], "AbstractAuthDriver");
if ($data["ENCODING"] != (defined('AJXP_LOCALE') ? AJXP_LOCALE : SystemTextEncoding::getEncoding())) {
file_put_contents($this->getPluginWorkDir() . "/encoding.php", "<?php \$ROOT_ENCODING='" . $data["ENCODING"] . "';");
}
$tpl = file_get_contents($this->getBaseDir() . "/htaccess.tpl");
if (!empty($data["SERVER_URI"]) && $data["SERVER_URI"] != "/") {
$htContent = str_replace('${APPLICATION_ROOT}', $data["SERVER_URI"], $tpl);
} else {
$htContent = str_replace('${APPLICATION_ROOT}/', "/", $tpl);
$htContent = str_replace('${APPLICATION_ROOT}', "/", $htContent);
}
if (is_writeable(AJXP_INSTALL_PATH . "/.htaccess")) {
file_put_contents(AJXP_INSTALL_PATH . "/.htaccess", $htContent);
} else {
$htAccessToUpdate = AJXP_INSTALL_PATH . "/.htaccess";
}
if ($storageType == "db") {
$sqlPlugs = array("core.notifications/UNIQUE_FEED_INSTANCE" => "feed.sql", "core.log/UNIQUE_PLUGIN_INSTANCE" => "log.sql", "core.mq/UNIQUE_MS_INSTANCE" => "mq.sql");
$data["ENABLE_NOTIF"] = $data["STORAGE_TYPE"]["notifications"];
}
// Prepare plugins configs
$direct = array("APPLICATION_TITLE" => "core.ajaxplorer/APPLICATION_TITLE", "APPLICATION_LANGUAGE" => "core.ajaxplorer/DEFAULT_LANGUAGE", "ENABLE_NOTIF" => "core.notifications/USER_EVENTS", "APPLICATION_WELCOME" => "gui.ajax/CUSTOM_WELCOME_MESSAGE");
$mailerEnabled = $data["MAILER_ENABLE"]["status"];
if ($mailerEnabled == "yes") {
// Enable core.mailer
$data["MAILER_SYSTEM"] = $data["MAILER_ENABLE"]["MAILER_SYSTEM"];
$data["MAILER_ADMIN"] = $data["MAILER_ENABLE"]["MAILER_ADMIN"];
$direct = array_merge($direct, array("MAILER_SYSTEM" => "mailer.phpmailer-lite/MAILER", "MAILER_ADMIN" => "core.mailer/FROM"));
}
foreach ($direct as $key => $value) {
list($pluginId, $param) = explode("/", $value);
$options = array();
$newConfigPlugin->_loadPluginConfig($pluginId, $options);
$options[$param] = $data[$key];
$newConfigPlugin->_savePluginConfig($pluginId, $options);
}
if (isset($sqlPlugs)) {
foreach ($sqlPlugs as $core => $value) {
list($pluginId, $param) = explode("/", $core);
$options = array();
$newConfigPlugin->_loadPluginConfig($pluginId, $options);
$options[$param] = array("instance_name" => $value, "group_switch_value" => $value, "SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core"));
$newConfigPlugin->_savePluginConfig($pluginId, $options);
}
}
ConfService::setTmpStorageImplementations($newConfigPlugin, $newAuthPlugin);
require_once $newConfigPlugin->getUserClassFileName();
$adminLogin = AJXP_Utils::sanitize($data["ADMIN_USER_LOGIN"], AJXP_SANITIZE_EMAILCHARS);
$adminName = $data["ADMIN_USER_NAME"];
$adminPass = $data["ADMIN_USER_PASS"];
$adminPass2 = $data["ADMIN_USER_PASS2"];
AuthService::createUser($adminLogin, $adminPass, true);
$uObj = $newConfigPlugin->createUserObject($adminLogin);
if (isset($data["MAILER_ADMIN"])) {
$uObj->personalRole->setParameterValue("core.conf", "email", $data["MAILER_ADMIN"]);
}
$uObj->personalRole->setParameterValue("core.conf", "USER_DISPLAY_NAME", $adminName);
$uObj->personalRole->setAcl('ajxp_conf', 'rw');
AuthService::updateRole($uObj->personalRole);
$loginP = "USER_LOGIN";
$i = 0;
while (isset($data[$loginP]) && !empty($data[$loginP])) {
$pass = $data[str_replace("_LOGIN", "_PASS", $loginP)];
$pass2 = $data[str_replace("_LOGIN", "_PASS2", $loginP)];
$name = $data[str_replace("_LOGIN", "_NAME", $loginP)];
$mail = $data[str_replace("_LOGIN", "_MAIL", $loginP)];
$saniLogin = AJXP_Utils::sanitize($data[$loginP], AJXP_SANITIZE_EMAILCHARS);
AuthService::createUser($saniLogin, $pass);
$uObj = $newConfigPlugin->createUserObject($saniLogin);
$uObj->personalRole->setParameterValue("core.conf", "email", $mail);
$uObj->personalRole->setParameterValue("core.conf", "USER_DISPLAY_NAME", $name);
AuthService::updateRole($uObj->personalRole);
$i++;
$loginP = "USER_LOGIN_" . $i;
}
AJXP_PluginsService::clearPluginsCache();
AJXP_Utils::setApplicationFirstRunPassed();
if (isset($htAccessToUpdate)) {
HTMLWriter::charsetHeader("application/json");
echo json_encode(array('file' => $htAccessToUpdate, 'content' => $htContent));
} else {
session_destroy();
HTMLWriter::charsetHeader("text/plain");
echo 'OK';
}
}
示例10: rename
<?php
// FORCE bootstrap_repositories copy
if (is_file(AJXP_INSTALL_PATH . "/conf/bootstrap_repositories.php" . ".new-" . date("Ymd"))) {
rename(AJXP_INSTALL_PATH . "/conf/bootstrap_repositories.php", AJXP_INSTALL_PATH . "/conf/bootstrap_repositories.php.pre-update");
rename(AJXP_INSTALL_PATH . "/conf/bootstrap_repositories.php" . ".new-" . date("Ymd"), AJXP_INSTALL_PATH . "/conf/bootstrap_repositories.php");
}
// Add new repo to root role
$rootRole = AuthService::getRole("AJXP_GRP_/");
$rootRole->setAcl("inbox", "rw");
AuthService::updateRole($rootRole);
示例11: checkGooglePass
public function checkGooglePass($loginId, $codeOTP, $userToken, $userInvalid)
{
$userToken = $this->base32ToHex($userToken);
$now = time();
$totpSkew = 2;
// how many tokens in either side we should check. 2 means +-1 min
$tokenTimer = 30;
// google authenticator support just 30s
$earliest = $now - $totpSkew * $tokenTimer;
$latest = $now + $totpSkew * $tokenTimer;
$st = (int) ($earliest / $tokenTimer);
$en = (int) ($latest / $tokenTimer);
$valid = 0;
$this->logDebug(__CLASS__, __FUNCTION__, "codeOTP " . $codeOTP);
for ($i = $st; $i <= $en && $valid == 0; $i++) {
if ($i > $userInvalid) {
$stest = $this->oath_hotp($userToken, $i);
$this->logDebug(__CLASS__, __FUNCTION__, "stest " . $stest);
if ($codeOTP == $stest) {
$valid = 1;
// save google_last
$confStorage = ConfService::getConfStorageImpl();
$userObject = $confStorage->createUserObject($loginId);
$role = $userObject->personalRole;
if ($role === false) {
throw new Exception("Cant find role! ");
}
$role->setParameterValue("authfront.otp", "google_last", $i);
AuthService::updateRole($role, $userObject);
return true;
}
}
}
return false;
//return ( AJXP_Utils::pbkdf2_validate_password($pass, $userStoredPass) && $valid == 1);
}
示例12: actionUnshare
protected function actionUnshare($remoteId, $token, $parameters)
{
$token = \AJXP_Utils::sanitize($token, AJXP_SANITIZE_ALPHANUM);
$remoteId = \AJXP_Utils::sanitize($remoteId, AJXP_SANITIZE_ALPHANUM);
$store = new SQLStore();
$remoteShare = $store->remoteShareForOcsRemoteId($remoteId);
if (empty($remoteShare)) {
throw new InvalidArgumentsException();
}
if ($token !== $remoteShare->getOcsToken()) {
throw new InvalidArgumentsException();
}
$targetUser = $remoteShare->getUser();
$store->deleteRemoteShare($remoteShare);
$response = $this->buildResponse("ok", 200, "Successfully removed share.");
$this->sendResponse($response, $this->getFormat($parameters));
$userRole = \AuthService::getRole("AJXP_USR_/" . $targetUser);
if ($userRole !== false) {
// Artificially "touch" user role
// to force repositories reload if he is logged in
\AuthService::updateRole($userRole);
}
}
示例13: listRoles
public function listRoles($root, $child, $hashValue = null, $returnNodes = false)
{
$allNodes = array();
if (!$returnNodes) {
AJXP_XMLWriter::sendFilesListComponentConfig('<columns switchGridMode="filelist" template_name="ajxp_conf.roles">
<column messageId="ajxp_conf.6" attributeName="ajxp_label" sortType="String"/>
<column messageId="ajxp_conf.114" attributeName="is_default" sortType="String"/>
<column messageId="ajxp_conf.62" attributeName="rights_summary" sortType="String"/>
</columns>');
}
if (!AuthService::usersEnabled()) {
return array();
}
$roles = AuthService::getRolesList(array(), !$this->listSpecialRoles);
ksort($roles);
if (!$this->listSpecialRoles && !$this->getName() == "ajxp_admin") {
$rootGroupRole = AuthService::getRole("AJXP_GRP_/", true);
if ($rootGroupRole->getLabel() == "AJXP_GRP_/") {
$mess = ConfService::getMessages();
$rootGroupRole->setLabel($mess["ajxp_conf.151"]);
AuthService::updateRole($rootGroupRole);
}
array_unshift($roles, $rootGroupRole);
}
foreach ($roles as $roleObject) {
//if(strpos($roleId, "AJXP_GRP_") === 0 && !$this->listSpecialRoles) continue;
$r = array();
if (!AuthService::canAdministrate($roleObject)) {
continue;
}
$count = 0;
$repos = ConfService::listRepositoriesWithCriteria(array("role" => $roleObject), $count);
foreach ($repos as $repoId => $repository) {
if ($repository->getAccessType() == "ajxp_shared") {
continue;
}
if (!$roleObject->canRead($repoId) && !$roleObject->canWrite($repoId)) {
continue;
}
$rs = $roleObject->canRead($repoId) ? "r" : "";
$rs .= $roleObject->canWrite($repoId) ? "w" : "";
$r[] = $repository->getDisplay() . " (" . $rs . ")";
}
$rightsString = implode(", ", $r);
$nodeKey = "/data/roles/" . $roleObject->getId();
$meta = array("icon" => "user-acl.png", "rights_summary" => $rightsString, "is_default" => implode(",", $roleObject->listAutoApplies()), "ajxp_mime" => "role", "role_id" => $roleObject->getId(), "text" => $roleObject->getLabel());
if (in_array($nodeKey, $this->currentBookmarks)) {
$meta = array_merge($meta, array("ajxp_bookmarked" => "true", "overlay_icon" => "bookmark.png"));
}
$xml = AJXP_XMLWriter::renderNode($nodeKey, $roleObject->getId(), true, $meta, true, false);
if (!$returnNodes) {
echo $xml;
} else {
$allNodes[$nodeKey] = $xml;
}
}
return $allNodes;
}
示例14: applyInstallerForm
/**
* Transmit to the ajxp_conf load_plugin_manifest action
* @param $action
* @param $httpVars
* @param $fileVars
*/
public function applyInstallerForm($action, $httpVars, $fileVars)
{
$data = array();
AJXP_Utils::parseStandardFormParameters($httpVars, $data, null, "");
// Create a custom bootstrap.json file
$coreConf = array();
$coreAuth = array();
$this->_loadPluginConfig("core.conf", $coreConf);
$this->_loadPluginConfig("core.auth", $coreAuth);
if (!isset($coreConf["UNIQUE_INSTANCE_CONFIG"])) {
$coreConf["UNIQUE_INSTANCE_CONFIG"] = array();
}
if (!isset($coreAuth["MASTER_INSTANCE_CONFIG"])) {
$coreAuth["MASTER_INSTANCE_CONFIG"] = array();
}
$storageType = $data["STORAGE_TYPE"]["type"];
$coreConfLIVECONFIG = array();
if ($storageType == "db") {
// REWRITE BOOTSTRAP.JSON
$coreConf["DIBI_PRECONFIGURATION"] = $data["STORAGE_TYPE"]["db_type"];
if (isset($coreConf["DIBI_PRECONFIGURATION"]["sqlite3_driver"])) {
$dbFile = AJXP_VarsFilter::filter($coreConf["DIBI_PRECONFIGURATION"]["sqlite3_database"]);
if (!file_exists(dirname($dbFile))) {
mkdir(dirname($dbFile), 0755, true);
}
}
$coreConf["UNIQUE_INSTANCE_CONFIG"] = array_merge($coreConf["UNIQUE_INSTANCE_CONFIG"], array("instance_name" => "conf.sql", "group_switch_value" => "conf.sql", "SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core")));
$coreAuth["MASTER_INSTANCE_CONFIG"] = array_merge($coreAuth["MASTER_INSTANCE_CONFIG"], array("instance_name" => "auth.sql", "group_switch_value" => "auth.sql", "SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core")));
// INSTALL ALL SQL TABLES
$sqlPlugs = array("conf.sql", "auth.sql", "feed.sql", "log.sql", "mq.sql");
foreach ($sqlPlugs as $plugId) {
$plug = AJXP_PluginsService::findPluginById($plugId);
$plug->installSQLTables(array("SQL_DRIVER" => $data["STORAGE_TYPE"]["db_type"]));
}
} else {
$coreConf["UNIQUE_INSTANCE_CONFIG"] = array_merge($coreConf["UNIQUE_INSTANCE_CONFIG"], array("instance_name" => "conf.serial", "group_switch_value" => "conf.serial"));
$coreAuth["MASTER_INSTANCE_CONFIG"] = array_merge($coreAuth["MASTER_INSTANCE_CONFIG"], array("instance_name" => "auth.serial", "group_switch_value" => "auth.serial"));
}
$oldBoot = $this->getPluginWorkDir(true) . "/bootstrap.json";
if (is_file($oldBoot)) {
copy($oldBoot, $oldBoot . ".bak");
unlink($oldBoot);
}
$newBootstrap = array("core.conf" => $coreConf, "core.auth" => $coreAuth);
AJXP_Utils::saveSerialFile($oldBoot, $newBootstrap, true, false, "json", true);
// Write new bootstrap and reload conf plugin!
if ($storageType == "db") {
$coreConf["UNIQUE_INSTANCE_CONFIG"]["SQL_DRIVER"] = $coreConf["DIBI_PRECONFIGURATION"];
$coreAuth["MASTER_INSTANCE_CONFIG"]["SQL_DRIVER"] = $coreConf["DIBI_PRECONFIGURATION"];
}
$newConfigPlugin = ConfService::instanciatePluginFromGlobalParams($coreConf["UNIQUE_INSTANCE_CONFIG"], "AbstractConfDriver");
$newAuthPlugin = ConfService::instanciatePluginFromGlobalParams($coreAuth["MASTER_INSTANCE_CONFIG"], "AbstractAuthDriver");
if ($storageType == "db") {
$sqlPlugs = array("core.notifications/UNIQUE_FEED_INSTANCE" => "feed.sql", "core.log/UNIQUE_PLUGIN_INSTANCE" => "log.sql", "core.mq/UNIQUE_MS_INSTANCE" => "mq.sql");
$data["ENABLE_NOTIF"] = $data["STORAGE_TYPE"]["notifications"];
}
// Prepare plugins configs
$direct = array("APPLICATION_TITLE" => "core.ajaxplorer/APPLICATION_TITLE", "APPLICATION_LANGUAGE" => "core.ajaxplorer/DEFAULT_LANGUAGE", "ENABLE_NOTIF" => "core.notifications/USER_EVENTS", "APPLICATION_WELCOME" => "gui.ajax/CUSTOM_WELCOME_MESSAGE");
$mailerEnabled = $data["MAILER_ENABLE"]["status"];
if ($mailerEnabled == "yes") {
// Enable core.mailer
$data["MAILER_SYSTEM"] = $data["MAILER_ENABLE"]["MAILER_SYSTEM"];
$data["MAILER_ADMIN"] = $data["MAILER_ENABLE"]["MAILER_ADMIN"];
$direct = array_merge($direct, array("MAILER_SYSTEM" => "mailer.phpmailer-lite/MAILER", "MAILER_ADMIN" => "core.mailer/FROM"));
}
foreach ($direct as $key => $value) {
list($pluginId, $param) = explode("/", $value);
$options = array();
$newConfigPlugin->_loadPluginConfig($pluginId, $options);
$options[$param] = $data[$key];
$newConfigPlugin->_savePluginConfig($pluginId, $options);
}
if (isset($sqlPlugs)) {
foreach ($sqlPlugs as $core => $value) {
list($pluginId, $param) = explode("/", $core);
$options = array();
$newConfigPlugin->_loadPluginConfig($pluginId, $options);
$options[$param] = array("instance_name" => $value, "group_switch_value" => $value, "SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core"));
$newConfigPlugin->_savePluginConfig($pluginId, $options);
}
}
ConfService::setTmpStorageImplementations($newConfigPlugin, $newAuthPlugin);
require_once $newConfigPlugin->getUserClassFileName();
$adminLogin = AJXP_Utils::sanitize($data["ADMIN_USER_LOGIN"], AJXP_SANITIZE_EMAILCHARS);
$adminName = $data["ADMIN_USER_NAME"];
$adminPass = $data["ADMIN_USER_PASS"];
$adminPass2 = $data["ADMIN_USER_PASS2"];
AuthService::createUser($adminLogin, $adminPass, true);
$uObj = $newConfigPlugin->createUserObject($adminLogin);
if (isset($data["MAILER_ADMIN"])) {
$uObj->personalRole->setParameterValue("core.conf", "email", $data["MAILER_ADMIN"]);
}
$uObj->personalRole->setParameterValue("core.conf", "USER_DISPLAY_NAME", $adminName);
AuthService::updateRole($uObj->personalRole);
//.........这里部分代码省略.........
示例15: switchAction
function switchAction($action, $httpVars, $fileVars)
{
if (!isset($this->actions[$action])) {
return;
}
parent::accessPreprocess($action, $httpVars, $fileVars);
$loggedUser = AuthService::getLoggedUser();
if (ENABLE_USERS && !$loggedUser->isAdmin()) {
return;
}
if ($action == "edit") {
if (isset($httpVars["sub_action"])) {
$action = $httpVars["sub_action"];
}
}
$mess = ConfService::getMessages();
switch ($action) {
//------------------------------------
// BASIC LISTING
//------------------------------------
case "ls":
$rootNodes = array("repositories" => array("LABEL" => $mess["ajxp_conf.3"], "ICON" => "folder_red.png"), "users" => array("LABEL" => $mess["ajxp_conf.2"], "ICON" => "yast_kuser.png"), "roles" => array("LABEL" => $mess["ajxp_conf.69"], "ICON" => "user_group_new.png"), "files" => array("LABEL" => $mess["ajxp_shared.3"], "ICON" => "html.png"), "logs" => array("LABEL" => $mess["ajxp_conf.4"], "ICON" => "toggle_log.png"), "diagnostic" => array("LABEL" => $mess["ajxp_conf.5"], "ICON" => "susehelpcenter.png"));
$dir = isset($httpVars["dir"]) ? $httpVars["dir"] : "";
$splits = explode("/", $dir);
if (count($splits)) {
if ($splits[0] == "") {
array_shift($splits);
}
if (count($splits)) {
$strippedDir = strtolower(urldecode($splits[0]));
} else {
$strippedDir = "";
}
}
if (array_key_exists($strippedDir, $rootNodes)) {
AJXP_XMLWriter::header();
if ($strippedDir == "users") {
$this->listUsers();
} else {
if ($strippedDir == "roles") {
$this->listRoles();
} else {
if ($strippedDir == "repositories") {
$this->listRepositories();
} else {
if ($strippedDir == "logs") {
$this->listLogFiles($dir);
} else {
if ($strippedDir == "diagnostic") {
$this->printDiagnostic();
} else {
if ($strippedDir == "files") {
$this->listSharedFiles();
}
}
}
}
}
}
AJXP_XMLWriter::close();
exit(1);
} else {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendFilesListComponentConfig('<columns switchGridMode="filelist"><column messageId="ajxp_conf.1" attributeName="ajxp_label" sortType="String"/></columns>');
foreach ($rootNodes as $key => $data) {
$src = '';
if ($key == "logs") {
$src = 'src="content.php?get_action=ls&dir=' . $key . '"';
}
print '<tree text="' . $data["LABEL"] . '" icon="' . $data["ICON"] . '" filename="/' . $key . '" parentname="/" ' . $src . ' />';
}
AJXP_XMLWriter::close();
exit(1);
}
break;
case "stat":
header("Content-type:application/json");
print '{"mode":true}';
exit(1);
break;
case "create_role":
$roleId = $httpVars["role_id"];
if (AuthService::getRole($roleId) !== false) {
throw new Exception($mess["ajxp_conf.65"]);
}
AuthService::updateRole(new AjxpRole($roleId));
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.66"], null);
AJXP_XMLWriter::reloadDataNode("", $httpVars["role_id"]);
AJXP_XMLWriter::close();
break;
case "edit_role":
$roleId = $httpVars["role_id"];
$role = AuthService::getRole($roleId);
AJXP_XMLWriter::header("admin_data");
print AJXP_XMLWriter::writeRoleRepositoriesData($role);
AJXP_XMLWriter::close("admin_data");
break;
case "update_role_right":
if (!isset($httpVars["role_id"]) || !isset($httpVars["repository_id"]) || !isset($httpVars["right"])) {
//.........这里部分代码省略.........