当前位置: 首页>>代码示例>>PHP>>正文


PHP AuthService::createUser方法代码示例

本文整理汇总了PHP中AuthService::createUser方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthService::createUser方法的具体用法?PHP AuthService::createUser怎么用?PHP AuthService::createUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AuthService的用法示例。


在下文中一共展示了AuthService::createUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: tryToLogUser

 function tryToLogUser(&$httpVars, $isLast = false)
 {
     $localHttpLogin = $_SERVER["REMOTE_USER"];
     $localHttpPassw = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : "";
     if (!isset($localHttpLogin)) {
         return false;
     }
     if (!AuthService::userExists($localHttpLogin) && $this->pluginConf["CREATE_USER"] === true) {
         AuthService::createUser($localHttpLogin, $localHttpPassw, isset($this->pluginConf["AJXP_ADMIN"]) && $this->pluginConf["AJXP_ADMIN"] == $localHttpLogin);
     }
     $res = AuthService::logUser($localHttpLogin, $localHttpPassw, true);
     if ($res > 0) {
         return true;
     }
     return false;
 }
开发者ID:thermalpaste,项目名称:pydio-core,代码行数:16,代码来源:class.ServerHttpAuthFrontend.php

示例2: SessionSwitcher

             }
             $userObject->save("superuser");
         }
     }
     break;
 case 'logout':
     $newSession = new SessionSwitcher("AjaXplorer");
     global $_SESSION;
     $_SESSION = array();
     $result = TRUE;
     break;
 case 'addUser':
     $user = $AJXP_GLUE_GLOBALS["user"];
     if (is_array($user)) {
         $isAdmin = isset($user["right"]) && $user["right"] == "admin";
         AuthService::createUser($user["name"], $user["password"], $isAdmin);
         $result = TRUE;
     }
     break;
 case 'delUser':
     $userName = $AJXP_GLUE_GLOBALS["userName"];
     if (strlen($userName)) {
         AuthService::deleteUser($userName);
         $result = TRUE;
     }
     break;
 case 'updateUser':
     $user = $AJXP_GLUE_GLOBALS["user"];
     if (is_array($user)) {
         if (AuthService::updatePassword($user["name"], $user["password"])) {
             $isAdmin = isset($user["right"]) && $user["right"] == "admin";
开发者ID:crodriguezn,项目名称:administrator-files,代码行数:31,代码来源:glueCode.php

示例3: 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) {
//.........这里部分代码省略.........
开发者ID:biggtfish,项目名称:cms,代码行数:101,代码来源:class.AuthService.php

示例4: tryToLogUser


//.........这里部分代码省略.........
                     phpCAS::setNoCasServerValidation();
                 }
                 /**
                  * Debug
                  */
                 if ($this->cas_debug_mode) {
                     // logfile name by date:
                     $today = getdate();
                     $file_path = AJXP_DATA_PATH . '/logs/phpcas_' . $today['year'] . '-' . $today['month'] . '-' . $today['mday'] . '.txt';
                     empty($this->cas_debug_file) ? $file_path : ($file_path = $this->cas_debug_file);
                     phpCAS::setDebug($file_path);
                 }
                 phpCAS::forceAuthentication();
             } else {
                 AJXP_Logger::error(__FUNCTION__, "Could not start phpCAS mode CLIENT, please verify the configuration", "");
                 return false;
             }
             break;
         case PHPCAS_MODE_PROXY:
             /**
              * If in login page, user click on login via CAS, the page will be reload with manuallyredirectocas is set.
              * Or force redirect to cas login page even the force redirect is set in configuration of this module
              *
              */
             if ($this->checkConfigurationForProxyMode()) {
                 AJXP_Logger::info(__FUNCTION__, "Start phpCAS mode Proxy: ", "sucessfully");
                 /**
                  * init phpCAS in mode proxy
                  */
                 phpCAS::proxy(CAS_VERSION_2_0, $this->cas_server, $this->cas_port, $this->cas_uri, false);
                 if (!empty($this->cas_certificate_path)) {
                     phpCAS::setCasServerCACert($this->cas_certificate_path);
                 } else {
                     phpCAS::setNoCasServerValidation();
                 }
                 /**
                  * Debug
                  */
                 if ($this->cas_debug_mode) {
                     // logfile name by date:
                     $today = getdate();
                     $file_path = AJXP_DATA_PATH . '/logs/phpcas_' . $today['year'] . '-' . $today['month'] . '-' . $today['mday'] . '.txt';
                     empty($this->cas_debug_file) ? $file_path : ($file_path = $this->cas_debug_file);
                     phpCAS::setDebug($file_path);
                 }
                 if (!empty($this->cas_setFixedCallbackURL)) {
                     phpCAS::setFixedCallbackURL($this->cas_setFixedCallbackURL);
                 }
                 //
                 /**
                  * PTG storage
                  */
                 $this->setPTGStorage();
                 phpCAS::forceAuthentication();
                 /**
                  * Get proxy ticket (PT) for SAMBA to authentication at CAS via pam_cas
                  * In fact, we can use any other service. Of course, it should be enabled in CAS
                  *
                  */
                 $err_code = null;
                 $serviceURL = $this->cas_proxied_service;
                 AJXP_Logger::debug(__FUNCTION__, "Try to get proxy ticket for service: ", $serviceURL);
                 $res = phpCAS::serviceSMB($serviceURL, $err_code);
                 if (!empty($res)) {
                     $_SESSION['PROXYTICKET'] = $res;
                     AJXP_Logger::info(__FUNCTION__, "Get Proxy ticket successfully ", "");
                 } else {
                     AJXP_Logger::info(__FUNCTION__, "Could not get Proxy ticket. ", "");
                 }
                 break;
             } else {
                 AJXP_Logger::error(__FUNCTION__, "Could not start phpCAS mode PROXY, please verify the configuration", "");
                 return false;
             }
         default:
             return false;
             break;
     }
     AJXP_Logger::debug(__FUNCTION__, "Call phpCAS::getUser() after forceAuthentication ", "");
     $cas_user = phpCAS::getUser();
     if (!AuthService::userExists($cas_user) && $this->is_AutoCreateUser) {
         AuthService::createUser($cas_user, openssl_random_pseudo_bytes(20));
     }
     if (AuthService::userExists($cas_user)) {
         $res = AuthService::logUser($cas_user, "", true);
         if ($res > 0) {
             AJXP_Safe::storeCredentials($cas_user, $_SESSION['PROXYTICKET']);
             $_SESSION['LOGGED_IN_BY_CAS'] = true;
             if (!empty($this->cas_additional_role)) {
                 $userObj = ConfService::getConfStorageImpl()->createUserObject($cas_user);
                 $roles = $userObj->getRoles();
                 $cas_RoleID = $this->cas_additional_role;
                 $userObj->addRole(AuthService::getRole($cas_RoleID, true));
                 AuthService::updateUser($userObj);
             }
             return true;
         }
     }
     return false;
 }
开发者ID:floffel03,项目名称:pydio-core,代码行数:101,代码来源:class.CasAuthFrontend.php

示例5: logUser

 function logUser($user_id, $pwd, $bypass_pwd = false, $cookieLogin = false, $returnSeed = "")
 {
     $confDriver = ConfService::getConfStorageImpl();
     if ($user_id == null) {
         if (isset($_SESSION["AJXP_USER"]) && is_object($_SESSION["AJXP_USER"])) {
             return 1;
         }
         if (ALLOW_GUEST_BROWSING) {
             $authDriver = ConfService::getAuthDriverImpl();
             if (!$authDriver->userExists("guest")) {
                 AuthService::createUser("guest", "");
                 $guest = $confDriver->createUserObject("guest");
                 $guest->save();
             }
             AuthService::logUser("guest", null);
             return 1;
         }
         return 0;
     }
     $authDriver = ConfService::getAuthDriverImpl();
     // CHECK USER PASSWORD HERE!
     $loginAttempt = AuthService::getBruteForceLoginArray();
     $bruteForceLogin = AuthService::checkBruteForceLogin($loginAttempt);
     AuthService::setBruteForceLoginArray($loginAttempt);
     if ($bruteForceLogin === FALSE) {
         return -1;
     }
     if (!$authDriver->userExists($user_id)) {
         return 0;
     }
     if (!$bypass_pwd) {
         if (!AuthService::checkPassword($user_id, $pwd, $cookieLogin, $returnSeed)) {
             return -1;
         }
     }
     // Successful login attempt
     unset($loginAttempt[$_SERVER["REMOTE_ADDR"]]);
     AuthService::setBruteForceLoginArray($loginAttempt);
     $user = $confDriver->createUserObject($user_id);
     if ($authDriver->isAjxpAdmin($user_id)) {
         $user->setAdmin(true);
     }
     if ($user->isAdmin()) {
         $user = AuthService::updateAdminRights($user);
     }
     $_SESSION["AJXP_USER"] = $user;
     if ($authDriver->autoCreateUser() && !$user->storageExists()) {
         $user->save();
     }
     AJXP_Logger::logAction("Log In");
     return 1;
 }
开发者ID:bloveing,项目名称:openulteo,代码行数:52,代码来源:class.AuthService.php

示例6: createSharedRepository


//.........这里部分代码省略.........
         $index++;
     }
     $label = AJXP_Utils::sanitize(AJXP_Utils::securePath($httpVars["repo_label"]), AJXP_SANITIZE_HTML);
     $description = AJXP_Utils::sanitize(AJXP_Utils::securePath($httpVars["repo_description"]), AJXP_SANITIZE_HTML);
     if (isset($httpVars["repository_id"])) {
         $editingRepo = ConfService::getRepositoryById($httpVars["repository_id"]);
     }
     // CHECK USER & REPO DOES NOT ALREADY EXISTS
     if ($this->getFilteredOption("AVOID_SHARED_FOLDER_SAME_LABEL", $this->repository->getId()) == true) {
         $count = 0;
         $similarLabelRepos = ConfService::listRepositoriesWithCriteria(array("display" => $label), $count);
         if ($count && !isset($editingRepo)) {
             return 101;
         }
         if ($count && isset($editingRepo)) {
             foreach ($similarLabelRepos as $slr) {
                 if ($slr->getUniqueId() != $editingRepo->getUniqueId()) {
                     return 101;
                 }
             }
         }
         /*
         $repos = ConfService::getRepositoriesList();
         foreach ($repos as $obj) {
             if ($obj->getDisplay() == $label && (!isSet($editingRepo) || $editingRepo != $obj)) {
             }
         }
         */
     }
     $confDriver = ConfService::getConfStorageImpl();
     foreach ($users as $userName) {
         if (AuthService::userExists($userName)) {
             // check that it's a child user
             $userObject = $confDriver->createUserObject($userName);
             if (ConfService::getCoreConf("ALLOW_CROSSUSERS_SHARING", "conf") != true && (!$userObject->hasParent() || $userObject->getParent() != $loggedUser->id)) {
                 return 102;
             }
         } else {
             if ($httpVars["create_guest_user"] != "true" && !ConfService::getCoreConf("USER_CREATE_USERS", "conf") || AuthService::isReservedUserId($userName)) {
                 return 102;
             }
             if (!isset($httpVars["shared_pass"]) || $httpVars["shared_pass"] == "") {
                 return 100;
             }
         }
     }
     // CREATE SHARED OPTIONS
     $options = $accessDriver->makeSharedRepositoryOptions($httpVars, $repository);
     $customData = array();
     foreach ($httpVars as $key => $value) {
         if (substr($key, 0, strlen("PLUGINS_DATA_")) == "PLUGINS_DATA_") {
             $customData[substr($key, strlen("PLUGINS_DATA_"))] = $value;
         }
     }
     if (count($customData)) {
         $options["PLUGINS_DATA"] = $customData;
     }
     if (isset($editingRepo)) {
         $this->getShareStore()->testUserCanEditShare($editingRepo->getOwner());
         $newRepo = $editingRepo;
         $replace = false;
         if ($editingRepo->getDisplay() != $label) {
             $newRepo->setDisplay($label);
             $replace = true;
         }
         if ($editingRepo->getDescription() != $description) {
开发者ID:thermalpaste,项目名称:pydio-core,代码行数:67,代码来源:class.ShareCenter.php

示例7: switchAction

 function switchAction($action, $httpVars, $fileVars)
 {
     if (!isset($this->actions[$action])) {
         return;
     }
     $loggedUser = AuthService::getLoggedUser();
     if (ENABLE_USERS && !$loggedUser->isAdmin()) {
         return;
     }
     if ($action == "edit") {
         if (isset($httpVars["sub_action"])) {
             $action = $httpVars["sub_action"];
         }
     }
     switch ($action) {
         //------------------------------------
         //	BASIC LISTING
         //------------------------------------
         case "ls":
             $rootNodes = array("users" => array("LABEL" => "Users", "ICON" => "yast_kuser.png"), "repositories" => array("LABEL" => "Repositories", "ICON" => "folder_red.png"), "logs" => array("LABEL" => "Logs", "ICON" => "toggle_log.png"), "diagnostic" => array("LABEL" => "Diagnostic", "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 == "repositories") {
                         $this->listRepositories();
                     } else {
                         if ($strippedDir == "logs") {
                             $this->listLogFiles($dir);
                         } else {
                             if ($strippedDir == "diagnostic") {
                                 $this->printDiagnostic();
                             }
                         }
                     }
                 }
                 AJXP_XMLWriter::close();
                 exit(1);
             } else {
                 AJXP_XMLWriter::header();
                 print '<columns switchGridMode="filelist"><column messageString="Configuration Data" attributeName="ajxp_label" sortType="String"/></columns>';
                 foreach ($rootNodes as $key => $data) {
                     $src = '';
                     if ($key == "logs") {
                         $src = 'src="content.php?dir=' . $key . '"';
                     }
                     print '<tree text="' . $data["LABEL"] . '" icon="' . $data["ICON"] . '" filename="/' . $key . '" parentname="/" ' . $src . ' />';
                 }
                 AJXP_XMLWriter::close();
                 exit(1);
             }
             break;
         case "edit_user":
             $confStorage = ConfService::getConfStorageImpl();
             $userId = $httpVars["user_id"];
             $userObject = $confStorage->createUserObject($userId);
             //print_r($userObject);
             AJXP_XMLWriter::header("admin_data");
             AJXP_XMLWriter::sendUserData($userObject, true);
             // Add WALLET DATA : DEFINITIONS AND VALUES
             print "<drivers>";
             print ConfService::availableDriversToXML("user_param");
             print "</drivers>";
             $wallet = $userObject->getPref("AJXP_WALLET");
             if (is_array($wallet) && count($wallet) > 0) {
                 print "<user_wallet>";
                 foreach ($wallet as $repoId => $options) {
                     foreach ($options as $optName => $optValue) {
                         print "<wallet_data repo_id=\"{$repoId}\" option_name=\"{$optName}\" option_value=\"{$optValue}\"/>";
                     }
                 }
                 print "</user_wallet>";
             }
             $editPass = $userId != "guest" ? "1" : "0";
             $authDriver = ConfService::getAuthDriverImpl();
             if (!$authDriver->passwordsEditable()) {
                 $editPass = "0";
             }
             print "<edit_options edit_pass=\"" . $editPass . "\" edit_admin_right=\"" . ($userId != "guest" && $userId != $loggedUser->getId() ? "1" : "0") . "\" edit_delete=\"" . ($userId != "guest" && $userId != $loggedUser->getId() && $authDriver->usersEditable() ? "1" : "0") . "\"/>";
             AJXP_XMLWriter::close("admin_data");
             exit(1);
             break;
         case "create_user":
             if (!isset($_GET["new_user_login"]) || $_GET["new_user_login"] == "" || !isset($_GET["new_user_pwd"]) || $_GET["new_user_pwd"] == "") {
                 AJXP_XMLWriter::header();
                 AJXP_XMLWriter::sendMessage(null, "Wrong Arguments!");
                 AJXP_XMLWriter::close();
//.........这里部分代码省略.........
开发者ID:skdong,项目名称:nfs-ovd,代码行数:101,代码来源:class.ajxp_confAccessDriver.php

示例8: switchAction


//.........这里部分代码省略.........
                     echo json_encode($data);
                 } else {
                     AJXP_XMLWriter::header("ajxp_registry_part", array("xPath" => $xPath));
                     if ($nodes->length) {
                         print AJXP_XMLWriter::replaceAjxpXmlKeywords($clone->saveXML($nodes->item(0)));
                     }
                     AJXP_XMLWriter::close("ajxp_registry_part");
                 }
             } else {
                 AJXP_Utils::safeIniSet("zlib.output_compression", "4096");
                 if ($httpVars["format"] == "json") {
                     $data = AJXP_XMLWriter::xmlToArray($clone);
                     HTMLWriter::charsetHeader("application/json");
                     echo json_encode($data);
                 } else {
                     header('Content-Type: application/xml; charset=UTF-8');
                     print AJXP_XMLWriter::replaceAjxpXmlKeywords($clone->saveXML());
                 }
             }
             break;
             //------------------------------------
             //	BOOKMARK BAR
             //------------------------------------
         //------------------------------------
         //	BOOKMARK BAR
         //------------------------------------
         case "get_bookmarks":
             $bmUser = null;
             if (AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
                 $bmUser = AuthService::getLoggedUser();
             } else {
                 if (!AuthService::usersEnabled()) {
                     $confStorage = ConfService::getConfStorageImpl();
                     $bmUser = $confStorage->createUserObject("shared");
                 }
             }
             if ($bmUser == null) {
                 AJXP_XMLWriter::header();
                 AJXP_XMLWriter::close();
             }
             $driver = ConfService::loadRepositoryDriver();
             if (!is_a($driver, "AjxpWrapperProvider")) {
                 $driver = false;
             }
             if (isset($httpVars["bm_action"]) && isset($httpVars["bm_path"])) {
                 $bmPath = AJXP_Utils::decodeSecureMagic($httpVars["bm_path"]);
                 if ($httpVars["bm_action"] == "add_bookmark") {
                     $title = "";
                     if (isset($httpVars["bm_title"])) {
                         $title = AJXP_Utils::decodeSecureMagic($httpVars["bm_title"]);
                     }
                     if ($title == "" && $bmPath == "/") {
                         $title = ConfService::getCurrentRootDirDisplay();
                     }
                     $bmUser->addBookMark($bmPath, $title);
                     if ($driver) {
                         $node = new AJXP_Node($driver->getResourceUrl($bmPath));
                         $node->setMetadata("ajxp_bookmarked", array("ajxp_bookmarked" => "true"), true, AJXP_METADATA_SCOPE_REPOSITORY, true);
                     }
                 } else {
                     if ($httpVars["bm_action"] == "delete_bookmark") {
                         $bmUser->removeBookmark($bmPath);
                         if ($driver) {
                             $node = new AJXP_Node($driver->getResourceUrl($bmPath));
                             $node->removeMetadata("ajxp_bookmarked", true, AJXP_METADATA_SCOPE_REPOSITORY, true);
                         }
开发者ID:rcmarotz,项目名称:pydio-core,代码行数:67,代码来源:class.AbstractConfDriver.php

示例9: createSharedRepository

 function createSharedRepository($httpVars)
 {
     // ERRORS
     // 100 : missing args
     // 101 : repository label already exists
     // 102 : user already exists
     // 103 : current user is not allowed to share
     // SUCCESS
     // 200
     if (!isset($httpVars["repo_label"]) || !isset($httpVars["repo_rights"]) || !isset($httpVars["shared_user"])) {
         return 100;
     }
     $loggedUser = AuthService::getLoggedUser();
     $actRights = $loggedUser->getSpecificActionsRights($this->repository->id);
     if (isset($actRights["public_url"]) && $actRights["public_url"] === false) {
         return 103;
     }
     $dir = AJXP_Utils::decodeSecureMagic($httpVars["dir"]);
     $userName = $httpVars["shared_user"];
     $label = SystemTextEncoding::fromUTF8($httpVars["repo_label"]);
     $rights = $httpVars["repo_rights"];
     if ($rights != "r" && $rights != "rw") {
         return 100;
     }
     // CHECK USER & REPO DOES NOT ALREADY EXISTS
     $repos = ConfService::getRepositoriesList();
     foreach ($repos as $obj) {
         if ($obj->getDisplay() == $label) {
             return 101;
         }
     }
     $confDriver = ConfService::getConfStorageImpl();
     if (AuthService::userExists($userName)) {
         // check that it's a child user
         $userObject = $confDriver->createUserObject($userName);
         if (!$userObject->hasParent() || $userObject->getParent() != $loggedUser->id) {
             return 102;
         }
     } else {
         if (!isset($httpVars["shared_pass"]) || $httpVars["shared_pass"] == "") {
             return 100;
         }
         AuthService::createUser($userName, md5($httpVars["shared_pass"]));
         $userObject = $confDriver->createUserObject($userName);
         $userObject->clearRights();
         $userObject->setParent($loggedUser->id);
     }
     // CREATE SHARED OPTIONS
     $newRepo = $this->repository->createSharedChild($label, $this->makeSharedRepositoryOptions($httpVars), $this->repository->id, $loggedUser->id, $userName);
     ConfService::addRepository($newRepo);
     // CREATE USER WITH NEW REPO RIGHTS
     $userObject->setRight($newRepo->getUniqueId(), $rights);
     $userObject->setSpecificActionRight($newRepo->getUniqueId(), "public_url", false);
     $userObject->save();
     return 200;
 }
开发者ID:pussbb,项目名称:CI_DEV_CMS,代码行数:56,代码来源:class.AbstractAccessDriver.php

示例10: 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';
     }
 }
开发者ID:rcmarotz,项目名称:pydio-core,代码行数:101,代码来源:class.BootConfLoader.php

示例11: md5

if (AuthService::usersEnabled()) {
    AuthService::preLogUser(isset($_GET["remote_session"]) ? $_GET["remote_session"] : "");
    if (!is_readable(USERS_DIR)) {
        $BEGIN_MESSAGE = "Warning, the users directory is not readable!";
    } else {
        if (!is_writeable(USERS_DIR)) {
            $BEGIN_MESSAGE = "Warning, the users directory is not writeable!";
        }
    }
    if (AuthService::countAdminUsers() == 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) {
            $BEGIN_MESSAGE .= "Warning! User 'admin' was created with the initial common password 'admin'. \\nPlease log in as admin and change the password now!";
        }
    } else {
        if (AuthService::countAdminUsers() == -1) {
            // Here we may come from a previous version! Check the "admin" user and set its right as admin.
            $confStorage = ConfService::getConfStorageImpl();
            $adminUser = $confStorage->createUserObject("admin");
            $adminUser->setAdmin(true);
            $adminUser->save();
            $BEGIN_MESSAGE .= "You may come from a previous version. Now any user can have the administration rights, \\n your 'admin' user was set with the admin rights. Please check that this suits your security configuration.";
        }
    }
    $USERS_ENABLED = "true";
    if (AuthService::getLoggedUser() != null || AuthService::logUser(null, null) == 1) {
开发者ID:projectesIF,项目名称:Ateneu,代码行数:31,代码来源:index.php

示例12: 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);
//.........这里部分代码省略.........
开发者ID:biggtfish,项目名称:cms,代码行数:101,代码来源:class.BootConfLoader.php

示例13: switchAction


//.........这里部分代码省略.........
             AJXP_XMLWriter::sendMessage($mess["ajxp_conf.64"] . $httpVars["role_id"], null);
             print "<update_checkboxes user_id=\"" . $httpVars["role_id"] . "\" repository_id=\"" . $httpVars["repository_id"] . "\" read=\"" . $role->canRead($httpVars["repository_id"]) . "\" write=\"" . $role->canWrite($httpVars["repository_id"]) . "\"/>";
             //AJXP_XMLWriter::reloadRepositoryList();
             AJXP_XMLWriter::close();
             //exit(1);
             break;
         case "update_role_actions":
             if (!isset($httpVars["role_id"]) || !isset($httpVars["disabled_actions"])) {
                 AJXP_XMLWriter::header();
                 AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.61"]);
                 AJXP_XMLWriter::close();
                 return;
             }
             $role = AuthService::getRole($httpVars["role_id"]);
             $actions = array_map("trim", explode(",", $httpVars["disabled_actions"]));
             // Clear and reload actions
             foreach ($role->getSpecificActionsRights("ajxp.all") as $actName => $actValue) {
                 $role->setSpecificActionRight("ajxp.all", $actName, true);
             }
             foreach ($actions as $action) {
                 if ($action == "") {
                     continue;
                 }
                 $role->setSpecificActionRight("ajxp.all", $action, false);
             }
             AuthService::updateRole($role);
             AJXP_XMLWriter::header("admin_data");
             print AJXP_XMLWriter::writeRoleRepositoriesData($role);
             AJXP_XMLWriter::close("admin_data");
             break;
         case "edit_user":
             $confStorage = ConfService::getConfStorageImpl();
             $userId = $httpVars["user_id"];
             $userObject = $confStorage->createUserObject($userId);
             //print_r($userObject);
             AJXP_XMLWriter::header("admin_data");
             AJXP_XMLWriter::sendUserData($userObject, true);
             // Add WALLET DATA : DEFINITIONS AND VALUES
             print "<drivers>";
             print ConfService::availableDriversToXML("user_param");
             print "</drivers>";
             $wallet = $userObject->getPref("AJXP_WALLET");
             if (is_array($wallet) && count($wallet) > 0) {
                 print "<user_wallet>";
                 foreach ($wallet as $repoId => $options) {
                     foreach ($options as $optName => $optValue) {
                         print "<wallet_data repo_id=\"{$repoId}\" option_name=\"{$optName}\" option_value=\"{$optValue}\"/>";
                     }
                 }
                 print "</user_wallet>";
             }
             $editPass = $userId != "guest" ? "1" : "0";
             $authDriver = ConfService::getAuthDriverImpl();
             if (!$authDriver->passwordsEditable()) {
                 $editPass = "0";
             }
             print "<edit_options edit_pass=\"" . $editPass . "\" edit_admin_right=\"" . ($userId != "guest" && $userId != $loggedUser->getId() ? "1" : "0") . "\" edit_delete=\"" . ($userId != "guest" && $userId != $loggedUser->getId() && $authDriver->usersEditable() ? "1" : "0") . "\"/>";
             print "<ajxp_roles>";
             foreach (AuthService::getRolesList() as $roleId => $roleObject) {
                 print "<role id=\"{$roleId}\"/>";
             }
             print "</ajxp_roles>";
             AJXP_XMLWriter::close("admin_data");
             exit(1);
             break;
         case "create_user":
开发者ID:pussbb,项目名称:CI_DEV_CMS,代码行数:67,代码来源:class.ajxp_confAccessDriver.php

示例14: createSharedRepository

 function createSharedRepository($httpVars, $repository, $accessDriver)
 {
     // ERRORS
     // 100 : missing args
     // 101 : repository label already exists
     // 102 : user already exists
     // 103 : current user is not allowed to share
     // SUCCESS
     // 200
     if (!isset($httpVars["repo_label"]) || $httpVars["repo_label"] == "" || !isset($httpVars["repo_rights"]) || $httpVars["repo_rights"] == "") {
         return 100;
     }
     $loggedUser = AuthService::getLoggedUser();
     $actRights = $loggedUser->getSpecificActionsRights($repository->id);
     if (isset($actRights["share"]) && $actRights["share"] === false) {
         return 103;
     }
     $users = array();
     if (isset($httpVars["shared_user"]) && !empty($httpVars["shared_user"])) {
         $users = array_filter(array_map("trim", explode(",", str_replace("\n", ",", $httpVars["shared_user"]))), array("AuthService", "userExists"));
     }
     if (isset($httpVars["new_shared_user"]) && !empty($httpVars["new_shared_user"])) {
         $newshareduser = AJXP_Utils::decodeSecureMagic($httpVars["new_shared_user"], AJXP_SANITIZE_ALPHANUM);
         if (!empty($this->pluginConf["SHARED_USERS_TMP_PREFIX"]) && strpos($newshareduser, $this->pluginConf["SHARED_USERS_TMP_PREFIX"]) !== 0) {
             $newshareduser = $this->pluginConf["SHARED_USERS_TMP_PREFIX"] . $newshareduser;
         }
         if (!AuthService::userExists($newshareduser)) {
             array_push($users, $newshareduser);
         } else {
             throw new Exception("User already exists, please choose another name.");
         }
     }
     //$userName = AJXP_Utils::decodeSecureMagic($httpVars["shared_user"], AJXP_SANITIZE_ALPHANUM);
     $label = AJXP_Utils::decodeSecureMagic($httpVars["repo_label"]);
     $rights = $httpVars["repo_rights"];
     if ($rights != "r" && $rights != "w" && $rights != "rw") {
         return 100;
     }
     if (isset($httpVars["repository_id"])) {
         $editingRepo = ConfService::getRepositoryById($httpVars["repository_id"]);
     }
     // CHECK USER & REPO DOES NOT ALREADY EXISTS
     $repos = ConfService::getRepositoriesList();
     foreach ($repos as $obj) {
         if ($obj->getDisplay() == $label && (!isset($editingRepo) || $editingRepo != $obj)) {
             return 101;
         }
     }
     $confDriver = ConfService::getConfStorageImpl();
     foreach ($users as $userName) {
         if (AuthService::userExists($userName)) {
             // check that it's a child user
             $userObject = $confDriver->createUserObject($userName);
             if (ConfService::getCoreConf("ALLOW_CROSSUSERS_SHARING") != true && (!$userObject->hasParent() || $userObject->getParent() != $loggedUser->id)) {
                 return 102;
             }
         } else {
             if (AuthService::isReservedUserId($userName)) {
                 return 102;
             }
             if (!isset($httpVars["shared_pass"]) || $httpVars["shared_pass"] == "") {
                 return 100;
             }
         }
     }
     // CREATE SHARED OPTIONS
     $options = $accessDriver->makeSharedRepositoryOptions($httpVars, $repository);
     $customData = array();
     foreach ($httpVars as $key => $value) {
         if (substr($key, 0, strlen("PLUGINS_DATA_")) == "PLUGINS_DATA_") {
             $customData[substr($key, strlen("PLUGINS_DATA_"))] = $value;
         }
     }
     if (count($customData)) {
         $options["PLUGINS_DATA"] = $customData;
     }
     if (isset($editingRepo)) {
         $newRepo = $editingRepo;
         $newRepo->setDisplay($label);
         $newRepo->options = array_merge($newRepo->options, $options);
         ConfService::replaceRepository($httpVars["repository_id"], $newRepo);
     } else {
         if ($repository->getOption("META_SOURCES")) {
             $options["META_SOURCES"] = $repository->getOption("META_SOURCES");
             foreach ($options["META_SOURCES"] as $index => $data) {
                 if (isset($data["USE_SESSION_CREDENTIALS"]) && $data["USE_SESSION_CREDENTIALS"] === true) {
                     $options["META_SOURCES"][$index]["ENCODED_CREDENTIALS"] = AJXP_Safe::getEncodedCredentialString();
                 }
             }
         }
         $newRepo = $repository->createSharedChild($label, $options, $repository->id, $loggedUser->id, null);
         ConfService::addRepository($newRepo);
     }
     if (isset($httpVars["original_users"])) {
         $originalUsers = explode(",", $httpVars["original_users"]);
         $removeUsers = array_diff($originalUsers, $users);
         if (count($removeUsers)) {
             foreach ($removeUsers as $user) {
                 if (AuthService::userExists($user)) {
                     $userObject = $confDriver->createUserObject($user);
//.........这里部分代码省略.........
开发者ID:crodriguezn,项目名称:administrator-files,代码行数:101,代码来源:class.ShareCenter.php

示例15: switchAction


//.........这里部分代码省略.........
             }
             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);
             }
             if ($role === false) {
                 throw new Exception("Cant find role! ");
             }
             if (isset($httpVars["format"]) && $httpVars["format"] == "json") {
                 HTMLWriter::charsetHeader("application/json");
                 $roleData = $role->getDataArray(true);
                 $allReps = ConfService::getRepositoriesList("all", false);
                 $repos = array();
                 if (!empty($userObject)) {
                     // USER
                     foreach ($allReps as $repositoryId => $repositoryObject) {
                         if (!AuthService::canAssign($repositoryObject, $userObject) || $repositoryObject->isTemplate || $repositoryObject->getAccessType() == "ajxp_conf" && !$userObject->isAdmin() || $repositoryObject->getUniqueUser() != null && $repositoryObject->getUniqueUser() != $userObject->getId()) {
                             continue;
                         }
                         $repos[$repositoryId] = SystemTextEncoding::toUTF8($repositoryObject->getDisplay());
                     }
                 } else {
                     foreach ($allReps as $repositoryId => $repositoryObject) {
                         if (!AuthService::canAdministrate($repositoryObject)) {
                             continue;
                         }
                         $repos[$repositoryId] = SystemTextEncoding::toUTF8($repositoryObject->getDisplay());
                     }
                 }
                 // Make sure it's utf8
开发者ID:rcmarotz,项目名称:pydio-core,代码行数:67,代码来源:class.ajxp_confAccessDriver.php


注:本文中的AuthService::createUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。