本文整理汇总了PHP中AuthService::updatePassword方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthService::updatePassword方法的具体用法?PHP AuthService::updatePassword怎么用?PHP AuthService::updatePassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthService
的用法示例。
在下文中一共展示了AuthService::updatePassword方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switchAction
public function switchAction($action, $httpVars, $fileVars)
{
if (!isset($this->actions[$action])) {
return;
}
$mess = ConfService::getMessages();
switch ($action) {
//------------------------------------
// CHANGE USER PASSWORD
//------------------------------------
case "pass_change":
$userObject = AuthService::getLoggedUser();
if ($userObject == null || $userObject->getId() == "guest") {
header("Content-Type:text/plain");
print "SUCCESS";
}
$oldPass = $httpVars["old_pass"];
$newPass = $httpVars["new_pass"];
$passSeed = $httpVars["pass_seed"];
if (AuthService::checkPassword($userObject->getId(), $oldPass, false, $passSeed)) {
AuthService::updatePassword($userObject->getId(), $newPass);
} else {
header("Content-Type:text/plain");
print "PASS_ERROR";
}
header("Content-Type:text/plain");
print "SUCCESS";
break;
default:
break;
}
return "";
}
示例2: switchAction
public function switchAction($action, $httpVars, $fileVars)
{
if (!isset($this->actions[$action])) {
return;
}
switch ($action) {
case "get_secure_token":
HTMLWriter::charsetHeader("text/plain");
print AuthService::generateSecureToken();
//exit(0);
break;
//------------------------------------
// CHANGE USER PASSWORD
//------------------------------------
//------------------------------------
// CHANGE USER PASSWORD
//------------------------------------
case "pass_change":
$userObject = AuthService::getLoggedUser();
if ($userObject == null || $userObject->getId() == "guest") {
header("Content-Type:text/plain");
print "SUCCESS";
break;
}
$oldPass = $httpVars["old_pass"];
$newPass = $httpVars["new_pass"];
$passSeed = $httpVars["pass_seed"];
if (strlen($newPass) < ConfService::getCoreConf("PASSWORD_MINLENGTH", "auth")) {
header("Content-Type:text/plain");
print "PASS_ERROR";
break;
}
if (AuthService::checkPassword($userObject->getId(), $oldPass, false, $passSeed)) {
AuthService::updatePassword($userObject->getId(), $newPass);
if ($userObject->getLock() == "pass_change") {
$userObject->removeLock();
$userObject->save("superuser");
}
} else {
header("Content-Type:text/plain");
print "PASS_ERROR";
break;
}
header("Content-Type:text/plain");
print "SUCCESS";
break;
default:
break;
}
return "";
}
示例3: SessionSwitcher
$result = TRUE;
}
break;
case 'delUser':
global $userName;
if (strlen($userName)) {
$newSession = new SessionSwitcher("AjaXplorer");
AuthService::deleteUser($userName);
$result = TRUE;
}
break;
case 'updateUser':
global $user;
if (is_array($user)) {
$newSession = new SessionSwitcher("AjaXplorer");
if (AuthService::updatePassword($user["name"], $user["password"])) {
//@TODO Change this to match your CMS code
if ($user["right"] == "admin") {
$userObj = getLoggedUser();
if ($user["name"] == $userObj->getId()) {
AuthService::updateAdminRights($userObj);
}
}
$result = TRUE;
} else {
$result = FALSE;
}
}
break;
case 'installDB':
global $user, $reset;
示例4: switchAction
//.........这里部分代码省略.........
$user = $loggedUser;
} else {
$confStorage = ConfService::getConfStorageImpl();
$user = $confStorage->createUserObject($userId);
}
$wallet = $user->getPref("AJXP_WALLET");
if (!is_array($wallet)) {
$wallet = array();
}
$repoID = $_GET["repository_id"];
if (!array_key_exists($repoID, $wallet)) {
$wallet[$repoID] = array();
}
$options = $wallet[$repoID];
$this->parseParameters($_GET, $options, $userId);
$wallet[$repoID] = $options;
$user->setPref("AJXP_WALLET", $wallet);
$user->save();
if ($loggedUser->getId() == $user->getId()) {
AuthService::updateUser($user);
}
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage("Saved data for user " . $_GET["user_id"], null);
AJXP_XMLWriter::close();
exit(1);
break;
case "update_user_pwd":
if (!isset($_GET["user_id"]) || !isset($_GET["user_pwd"]) || !AuthService::userExists($_GET["user_id"]) || trim($_GET["user_pwd"]) == "") {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, "Wrong Arguments!");
AJXP_XMLWriter::close();
exit(1);
}
$res = AuthService::updatePassword($_GET["user_id"], $_GET["user_pwd"]);
AJXP_XMLWriter::header();
if ($res === true) {
AJXP_XMLWriter::sendMessage("Password changed successfully for user " . $_GET["user_id"], null);
} else {
AJXP_XMLWriter::sendMessage(null, "Cannot update password : {$res}");
}
AJXP_XMLWriter::close();
exit(1);
break;
case "get_drivers_definition":
AJXP_XMLWriter::header("drivers");
print ConfService::availableDriversToXML("param");
AJXP_XMLWriter::close("drivers");
exit(1);
break;
case "create_repository":
$options = array();
$repDef = $_GET;
unset($repDef["get_action"]);
$this->parseParameters($repDef, $options);
if (count($options)) {
$repDef["DRIVER_OPTIONS"] = $options;
}
// NOW SAVE THIS REPOSITORY!
$newRep = ConfService::createRepositoryFromArray(0, $repDef);
if (is_file(INSTALL_PATH . "/server/tests/plugins/test.ajxp_" . $newRep->getAccessType() . ".php")) {
chdir(INSTALL_PATH . "/server/tests/plugins");
include INSTALL_PATH . "/server/tests/plugins/test.ajxp_" . $newRep->getAccessType() . ".php";
$className = "ajxp_" . $newRep->getAccessType();
$class = new $className();
$result = $class->doRepositoryTest($newRep);
if (!$result) {
示例5: switchAction
//.........这里部分代码省略.........
throw new Exception(str_replace("%s", $data["new_user_id"], $mess["ajxp_conf.127"]));
}
if (AuthService::userExists($data["new_user_id"], "w")) {
throw new Exception($mess["ajxp_conf.43"]);
}
$loggedUser = AuthService::getLoggedUser();
$limit = $loggedUser->personalRole->filterParameterValue("core.conf", "USER_SHARED_USERS_LIMIT", AJXP_REPO_SCOPE_ALL, "");
if (!empty($limit) && intval($limit) > 0) {
$count = count($this->getUserChildren($loggedUser->getId()));
if ($count >= $limit) {
throw new Exception($mess['483']);
}
}
AuthService::createUser($data["new_user_id"], $data["new_password"]);
$userObject = ConfService::getConfStorageImpl()->createUserObject($data["new_user_id"]);
$userObject->setParent($loggedUser->getId());
$userObject->save('superuser');
$userObject->personalRole->clearAcls();
$userObject->setGroupPath($loggedUser->getGroupPath());
$userObject->setProfile("shared");
} else {
if ($action == "user_create_user" && isset($httpVars["NEW_existing_user_id"])) {
$updating = true;
AJXP_Utils::parseStandardFormParameters($httpVars, $data, null, "NEW_");
$userId = $data["existing_user_id"];
if (!AuthService::userExists($userId)) {
throw new Exception("Cannot find user");
}
$userObject = ConfService::getConfStorageImpl()->createUserObject($userId);
if ($userObject->getParent() != AuthService::getLoggedUser()->getId()) {
throw new Exception("Cannot find user");
}
if (!empty($data["new_password"])) {
AuthService::updatePassword($userId, $data["new_password"]);
}
} else {
$updating = false;
$userObject = AuthService::getLoggedUser();
AJXP_Utils::parseStandardFormParameters($httpVars, $data, null, "PREFERENCES_");
}
}
$paramNodes = AJXP_PluginsService::searchAllManifests("//server_settings/param[contains(@scope,'user') and @expose='true']", "node", false, false, true);
$rChanges = false;
if (is_array($paramNodes) && count($paramNodes)) {
foreach ($paramNodes as $xmlNode) {
if ($xmlNode->getAttribute("expose") == "true") {
$parentNode = $xmlNode->parentNode->parentNode;
$pluginId = $parentNode->getAttribute("id");
if (empty($pluginId)) {
$pluginId = $parentNode->nodeName . "." . $parentNode->getAttribute("name");
}
$name = $xmlNode->getAttribute("name");
if (isset($data[$name]) || $data[$name] === "") {
if ($data[$name] == "__AJXP_VALUE_SET__") {
continue;
}
if ($data[$name] === "" || $userObject->parentRole == null || $userObject->parentRole->filterParameterValue($pluginId, $name, AJXP_REPO_SCOPE_ALL, "") != $data[$name] || $userObject->personalRole->filterParameterValue($pluginId, $name, AJXP_REPO_SCOPE_ALL, "") != $data[$name]) {
$userObject->personalRole->setParameterValue($pluginId, $name, $data[$name]);
$rChanges = true;
}
}
}
}
}
if ($rChanges) {
AuthService::updateRole($userObject->personalRole, $userObject);
示例6: processUserAccessPoint
public function processUserAccessPoint($action, $httpVars, $fileVars)
{
switch ($action) {
case "user_access_point":
$setUrl = ConfService::getCoreConf("SERVER_URL");
$realUri = "/";
if (!empty($setUrl)) {
$realUri = parse_url(ConfService::getCoreConf("SERVER_URL"), PHP_URL_PATH);
}
$requestURI = str_replace("//", "/", $_SERVER["REQUEST_URI"]);
$uri = trim(str_replace(rtrim($realUri, "/") . "/user", "", $requestURI), "/");
$uriParts = explode("/", $uri);
$action = array_shift($uriParts);
try {
$this->processSubAction($action, $uriParts);
$_SESSION['OVERRIDE_GUI_START_PARAMETERS'] = array("REBASE" => "../../", "USER_GUI_ACTION" => $action);
} catch (Exception $e) {
$_SESSION['OVERRIDE_GUI_START_PARAMETERS'] = array("ALERT" => $e->getMessage());
}
AJXP_Controller::findActionAndApply("get_boot_gui", array(), array());
unset($_SESSION['OVERRIDE_GUI_START_PARAMETERS']);
break;
case "reset-password-ask":
// This is a reset password request, generate a token and store it.
// Find user by id
if (AuthService::userExists($httpVars["email"])) {
// Send email
$userObject = ConfService::getConfStorageImpl()->createUserObject($httpVars["email"]);
$email = $userObject->personalRole->filterParameterValue("core.conf", "email", AJXP_REPO_SCOPE_ALL, "");
if (!empty($email)) {
$uuid = AJXP_Utils::generateRandomString(48);
ConfService::getConfStorageImpl()->saveTemporaryKey("password-reset", $uuid, AJXP_Utils::decodeSecureMagic($httpVars["email"]), array());
$mailer = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("mailer");
if ($mailer !== false) {
$mess = ConfService::getMessages();
$link = AJXP_Utils::detectServerURL() . "/user/reset-password/" . $uuid;
$mailer->sendMail(array($email), $mess["gui.user.1"], $mess["gui.user.7"] . "<a href=\"{$link}\">{$link}</a>");
} else {
echo 'ERROR: There is no mailer configured, please contact your administrator';
}
}
}
// Prune existing expired tokens
ConfService::getConfStorageImpl()->pruneTemporaryKeys("password-reset", 20);
echo "SUCCESS";
break;
case "reset-password":
ConfService::getConfStorageImpl()->pruneTemporaryKeys("password-reset", 20);
// This is a reset password
if (isset($httpVars["key"]) && isset($httpVars["user_id"])) {
$key = ConfService::getConfStorageImpl()->loadTemporaryKey("password-reset", $httpVars["key"]);
ConfService::getConfStorageImpl()->deleteTemporaryKey("password-reset", $httpVars["key"]);
$uId = $httpVars["user_id"];
if (AuthService::ignoreUserCase()) {
$uId = strtolower($uId);
}
if ($key != null && strtolower($key["user_id"]) == $uId && AuthService::userExists($uId)) {
AuthService::updatePassword($key["user_id"], $httpVars["new_pass"]);
} else {
echo 'PASS_ERROR';
break;
}
}
AuthService::disconnect();
echo 'SUCCESS';
break;
default:
break;
}
}
示例7: switchAction
//.........这里部分代码省略.........
$wallet = $user->getPref("AJXP_WALLET");
if (!is_array($wallet)) {
$wallet = array();
}
$repoID = $httpVars["repository_id"];
if (!array_key_exists($repoID, $wallet)) {
$wallet[$repoID] = array();
}
$options = $wallet[$repoID];
$existing = $options;
$this->parseParameters($httpVars, $options, $userId, false, $existing);
$wallet[$repoID] = $options;
$user->setPref("AJXP_WALLET", $wallet);
$user->save();
if ($loggedUser->getId() == $user->getId()) {
AuthService::updateUser($user);
}
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.47"] . $httpVars["user_id"], null);
AJXP_XMLWriter::close();
break;
case "update_user_pwd":
if (!isset($httpVars["user_id"]) || !isset($httpVars["user_pwd"]) || !AuthService::userExists($httpVars["user_id"]) || trim($httpVars["user_pwd"]) == "") {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.61"]);
AJXP_XMLWriter::close();
return;
}
$userId = AJXP_Utils::sanitize($httpVars["user_id"], AJXP_SANITIZE_EMAILCHARS);
$user = ConfService::getConfStorageImpl()->createUserObject($userId);
if (!AuthService::canAdministrate($user)) {
throw new Exception("Cannot update user data for " . $userId);
}
$res = AuthService::updatePassword($userId, $httpVars["user_pwd"]);
AJXP_XMLWriter::header();
if ($res === true) {
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.48"] . $userId, null);
} else {
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.49"] . " : {$res}");
}
AJXP_XMLWriter::close();
break;
case "save_user_preference":
if (!isset($httpVars["user_id"]) || !AuthService::userExists($httpVars["user_id"])) {
throw new Exception($mess["ajxp_conf.61"]);
}
$userId = AJXP_Utils::sanitize($httpVars["user_id"], AJXP_SANITIZE_EMAILCHARS);
if ($userId == $loggedUser->getId()) {
$userObject = $loggedUser;
} else {
$confStorage = ConfService::getConfStorageImpl();
$userObject = $confStorage->createUserObject($userId);
}
if (!AuthService::canAdministrate($userObject)) {
throw new Exception("Cannot update user data for " . $userId);
}
$i = 0;
while (isset($httpVars["pref_name_" . $i]) && isset($httpVars["pref_value_" . $i])) {
$prefName = AJXP_Utils::sanitize($httpVars["pref_name_" . $i], AJXP_SANITIZE_ALPHANUM);
$prefValue = AJXP_Utils::sanitize(SystemTextEncoding::magicDequote($httpVars["pref_value_" . $i]));
if ($prefName == "password") {
continue;
}
if ($prefName != "pending_folder" && $userObject == null) {
$i++;
continue;
示例8: switchAction
//.........这里部分代码省略.........
if (isset($_GET["bm_action"]) && isset($_GET["bm_path"])) {
if ($_GET["bm_action"] == "add_bookmark") {
$title = "";
if (isset($_GET["title"])) {
$title = $_GET["title"];
}
if ($title == "" && $_GET["bm_path"] == "/") {
$title = ConfService::getCurrentRootDirDisplay();
}
$bmUser->addBookMark($_GET["bm_path"], $title);
} else {
if ($_GET["bm_action"] == "delete_bookmark") {
$bmUser->removeBookmark($_GET["bm_path"]);
} else {
if ($_GET["bm_action"] == "rename_bookmark" && isset($_GET["bm_title"])) {
$bmUser->renameBookmark($_GET["bm_path"], $_GET["bm_title"]);
}
}
}
}
if (AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
$bmUser->save();
AuthService::updateUser($bmUser);
} else {
if (!AuthService::usersEnabled()) {
$bmUser->save();
}
}
AJXP_XMLWriter::header();
AJXP_XMLWriter::writeBookmarks($bmUser->getBookmarks());
AJXP_XMLWriter::close();
exit(1);
break;
//------------------------------------
// SAVE USER PREFERENCE
//------------------------------------
//------------------------------------
// SAVE USER PREFERENCE
//------------------------------------
case "save_user_pref":
$userObject = AuthService::getLoggedUser();
if ($userObject == null) {
exit(1);
}
$i = 0;
while (isset($_GET["pref_name_" . $i]) && isset($_GET["pref_value_" . $i])) {
$prefName = $_GET["pref_name_" . $i];
$prefValue = $_GET["pref_value_" . $i];
if ($prefName != "password") {
$userObject->setPref($prefName, $prefValue);
$userObject->save();
AuthService::updateUser($userObject);
setcookie("AJXP_{$prefName}", $prefValue);
} else {
if (isset($_GET["crt"]) && AuthService::checkPassword($userObject->getId(), $_GET["crt"], false, $_GET["pass_seed"])) {
AuthService::updatePassword($userObject->getId(), $prefValue);
} else {
//$errorMessage = "Wrong password!";
header("Content-Type:text/plain");
print "PASS_ERROR";
exit(1);
}
}
$i++;
}
header("Content-Type:text/plain");
print "SUCCESS";
exit(1);
break;
//------------------------------------
// DISPLAY DOC
//------------------------------------
//------------------------------------
// DISPLAY DOC
//------------------------------------
case "display_doc":
header("Content-type:text/html; charset:UTF-8");
echo HTMLWriter::getDocFile(htmlentities($_GET["doc_file"]));
exit(1);
break;
default:
break;
}
if (isset($logMessage) || isset($errorMessage)) {
$xmlBuffer .= AJXP_XMLWriter::sendMessage(isset($logMessage) ? $logMessage : null, isset($errorMessage) ? $errorMessage : null, false);
}
if (isset($requireAuth)) {
$xmlBuffer .= AJXP_XMLWriter::requireAuth(false);
}
if (isset($reload_current_node) && $reload_current_node == "true") {
$xmlBuffer .= AJXP_XMLWriter::reloadCurrentNode(false);
}
if (isset($reload_dest_node) && $reload_dest_node != "") {
$xmlBuffer .= AJXP_XMLWriter::reloadNode($reload_dest_node, false);
}
if (isset($reload_file_list)) {
$xmlBuffer .= AJXP_XMLWriter::reloadFileList($reload_file_list, false);
}
return $xmlBuffer;
}
示例9: switchAction
//.........这里部分代码省略.........
if ($userId == $loggedUser->getId()) {
$user = $loggedUser;
} else {
$confStorage = ConfService::getConfStorageImpl();
$user = $confStorage->createUserObject($userId);
}
$wallet = $user->getPref("AJXP_WALLET");
if (!is_array($wallet)) {
$wallet = array();
}
$repoID = $httpVars["repository_id"];
if (!array_key_exists($repoID, $wallet)) {
$wallet[$repoID] = array();
}
$options = $wallet[$repoID];
$this->parseParameters($httpVars, $options, $userId);
$wallet[$repoID] = $options;
$user->setPref("AJXP_WALLET", $wallet);
$user->save();
if ($loggedUser->getId() == $user->getId()) {
AuthService::updateUser($user);
}
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.47"] . $httpVars["user_id"], null);
AJXP_XMLWriter::close();
break;
case "update_user_pwd":
if (!isset($httpVars["user_id"]) || !isset($httpVars["user_pwd"]) || !AuthService::userExists($httpVars["user_id"]) || trim($httpVars["user_pwd"]) == "") {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.61"]);
AJXP_XMLWriter::close();
return;
}
$res = AuthService::updatePassword($httpVars["user_id"], $httpVars["user_pwd"]);
AJXP_XMLWriter::header();
if ($res === true) {
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.48"] . $httpVars["user_id"], null);
} else {
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.49"] . " : {$res}");
}
AJXP_XMLWriter::close();
break;
case "save_user_preference":
if (!isset($httpVars["user_id"]) || !AuthService::userExists($httpVars["user_id"])) {
throw new Exception($mess["ajxp_conf.61"]);
}
$userId = $httpVars["user_id"];
if ($userId == $loggedUser->getId()) {
$userObject = $loggedUser;
} else {
$confStorage = ConfService::getConfStorageImpl();
$userObject = $confStorage->createUserObject($userId);
}
$i = 0;
while (isset($httpVars["pref_name_" . $i]) && isset($httpVars["pref_value_" . $i])) {
$prefName = AJXP_Utils::sanitize($httpVars["pref_name_" . $i], AJXP_SANITIZE_ALPHANUM);
$prefValue = AJXP_Utils::sanitize(SystemTextEncoding::magicDequote($httpVars["pref_value_" . $i]));
if ($prefName == "password") {
continue;
}
if ($prefName != "pending_folder" && $userObject == null) {
$i++;
continue;
}
$userObject->setPref($prefName, $prefValue);
$userObject->save("user");
示例10: createSharedMinisite
/**
* @param $httpVars
* @param Repository $repository
* @param AbstractAccessDriver $accessDriver
* @return mixed An array containing the hash (0) and the generated url (1)
*/
public function createSharedMinisite($httpVars, $repository, $accessDriver)
{
$uniqueUser = null;
if (isset($httpVars["repository_id"]) && isset($httpVars["guest_user_id"])) {
$existingData = $this->getShareStore()->loadShare($httpVars["hash"]);
$existingU = "";
if (isset($existingData["PRELOG_USER"])) {
$existingU = $existingData["PRELOG_USER"];
} else {
if (isset($existingData["PRESET_LOGIN"])) {
$existingU = $existingData["PRESET_LOGIN"];
}
}
$uniqueUser = $httpVars["guest_user_id"];
if (isset($httpVars["guest_user_pass"]) && strlen($httpVars["guest_user_pass"]) && $uniqueUser == $existingU) {
//$userPass = $httpVars["guest_user_pass"];
// UPDATE GUEST USER PASS HERE
AuthService::updatePassword($uniqueUser, $httpVars["guest_user_pass"]);
} else {
if (isset($httpVars["guest_user_pass"]) && $httpVars["guest_user_pass"] == "") {
} else {
if (isset($existingData["PRESET_LOGIN"])) {
$httpVars["KEEP_PRESET_LOGIN"] = true;
}
}
}
} else {
if (isset($httpVars["create_guest_user"])) {
// Create a guest user
$userId = substr(md5(time()), 0, 12);
$pref = $this->getFilteredOption("SHARED_USERS_TMP_PREFIX", $this->repository->getId());
if (!empty($pref)) {
$userId = $pref . $userId;
}
if (!empty($httpVars["guest_user_pass"])) {
$userPass = $httpVars["guest_user_pass"];
} else {
$userPass = substr(md5(time()), 13, 24);
}
$uniqueUser = $userId;
}
}
if (isset($uniqueUser)) {
if (isset($userPass)) {
$httpVars["user_pass_0"] = $httpVars["shared_pass"] = $userPass;
}
$httpVars["user_0"] = $uniqueUser;
$httpVars["entry_type_0"] = "user";
$httpVars["right_read_0"] = isset($httpVars["simple_right_read"]) ? "true" : "false";
$httpVars["right_write_0"] = isset($httpVars["simple_right_write"]) ? "true" : "false";
$httpVars["right_watch_0"] = "false";
$httpVars["disable_download"] = isset($httpVars["simple_right_download"]) ? false : true;
if ($httpVars["right_read_0"] == "false" && !$httpVars["disable_download"]) {
$httpVars["right_read_0"] = "true";
}
if ($httpVars["right_write_0"] == "false" && $httpVars["right_read_0"] == "false") {
return "share_center.58";
}
}
$httpVars["minisite"] = true;
$httpVars["selection"] = true;
if (!isset($userSelection)) {
$userSelection = new UserSelection($repository, $httpVars);
$setFilter = false;
if ($userSelection->isUnique()) {
$node = $userSelection->getUniqueNode($this->accessDriver);
$node->loadNodeInfo();
if ($node->isLeaf()) {
$setFilter = true;
$httpVars["file"] = "/";
}
} else {
$setFilter = true;
}
$nodes = $userSelection->buildNodes($this->accessDriver);
$hasDir = false;
$hasFile = false;
foreach ($nodes as $n) {
$n->loadNodeInfo();
if ($n->isLeaf()) {
$hasFile = true;
} else {
$hasDir = true;
}
}
if ($hasDir && !$this->getAuthorization("folder", "minisite") || $hasFile && !$this->getAuthorization("file")) {
return 103;
}
if ($setFilter) {
$httpVars["filter_nodes"] = $nodes;
}
if (!isset($httpVars["repo_label"])) {
$first = $userSelection->getUniqueNode($this->accessDriver);
$httpVars["repo_label"] = SystemTextEncoding::toUTF8($first->getLabel());
//.........这里部分代码省略.........
示例11: switchAction
public function switchAction($action, $httpVars, $fileVars)
{
if (!isset($this->actions[$action])) {
return;
}
$mess = ConfService::getMessages();
switch ($action) {
case "login":
if (!AuthService::usersEnabled()) {
return;
}
$rememberLogin = "";
$rememberPass = "";
$secureToken = "";
$loggedUser = null;
include_once AJXP_BIN_FOLDER . "/class.CaptchaProvider.php";
if (AuthService::suspectBruteForceLogin() && (!isset($httpVars["captcha_code"]) || !CaptchaProvider::checkCaptchaResult($httpVars["captcha_code"]))) {
$loggingResult = -4;
} else {
$userId = isset($httpVars["userid"]) ? trim($httpVars["userid"]) : null;
$userPass = isset($httpVars["password"]) ? trim($httpVars["password"]) : null;
$rememberMe = isset($httpVars["remember_me"]) && $httpVars["remember_me"] == "true" ? true : false;
$cookieLogin = isset($httpVars["cookie_login"]) ? true : false;
$loggingResult = AuthService::logUser($userId, $userPass, false, $cookieLogin, $httpVars["login_seed"]);
if ($rememberMe && $loggingResult == 1) {
$rememberLogin = "notify";
$rememberPass = "notify";
$loggedUser = AuthService::getLoggedUser();
}
if ($loggingResult == 1) {
session_regenerate_id(true);
$secureToken = AuthService::generateSecureToken();
}
if ($loggingResult < 1 && AuthService::suspectBruteForceLogin()) {
$loggingResult = -4;
// Force captcha reload
}
}
$loggedUser = AuthService::getLoggedUser();
if ($loggedUser != null) {
$force = $loggedUser->mergedRole->filterParameterValue("core.conf", "DEFAULT_START_REPOSITORY", AJXP_REPO_SCOPE_ALL, -1);
$passId = -1;
if (isset($httpVars["tmp_repository_id"])) {
$passId = $httpVars["tmp_repository_id"];
} else {
if ($force != "" && $loggedUser->canSwitchTo($force) && !isset($httpVars["tmp_repository_id"]) && !isset($_SESSION["PENDING_REPOSITORY_ID"])) {
$passId = $force;
}
}
$res = ConfService::switchUserToActiveRepository($loggedUser, $passId);
if (!$res) {
AuthService::disconnect();
$loggingResult = -3;
}
}
if ($loggedUser != null && (AuthService::hasRememberCookie() || isset($rememberMe) && $rememberMe == true)) {
AuthService::refreshRememberCookie($loggedUser);
}
AJXP_XMLWriter::header();
AJXP_XMLWriter::loggingResult($loggingResult, $rememberLogin, $rememberPass, $secureToken);
AJXP_XMLWriter::close();
break;
//------------------------------------
// CHANGE USER PASSWORD
//------------------------------------
//------------------------------------
// CHANGE USER PASSWORD
//------------------------------------
case "pass_change":
$userObject = AuthService::getLoggedUser();
if ($userObject == null || $userObject->getId() == "guest") {
header("Content-Type:text/plain");
print "SUCCESS";
break;
}
$oldPass = $httpVars["old_pass"];
$newPass = $httpVars["new_pass"];
$passSeed = $httpVars["pass_seed"];
if (strlen($newPass) < ConfService::getCoreConf("PASSWORD_MINLENGTH", "auth")) {
header("Content-Type:text/plain");
print "PASS_ERROR";
break;
}
if (AuthService::checkPassword($userObject->getId(), $oldPass, false, $passSeed)) {
AuthService::updatePassword($userObject->getId(), $newPass);
if ($userObject->getLock() == "pass_change") {
$userObject->removeLock();
$userObject->save("superuser");
}
} else {
header("Content-Type:text/plain");
print "PASS_ERROR";
break;
}
header("Content-Type:text/plain");
print "SUCCESS";
break;
case "logout":
AuthService::disconnect();
$loggingResult = 2;
//.........这里部分代码省略.........
示例12: switchAction
//.........这里部分代码省略.........
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) {
exit(1);
}
if (isset($_GET["bm_action"]) && isset($_GET["bm_path"])) {
if ($_GET["bm_action"] == "add_bookmark") {
$title = "";
if (isset($_GET["title"])) {
$title = $_GET["title"];
}
if ($title == "" && $_GET["bm_path"] == "/") {
$title = ConfService::getCurrentRootDirDisplay();
}
$bmUser->addBookMark($_GET["bm_path"], $title);
} else {
if ($_GET["bm_action"] == "delete_bookmark") {
$bmUser->removeBookmark($_GET["bm_path"]);
} else {
if ($_GET["bm_action"] == "rename_bookmark" && isset($_GET["bm_title"])) {
$bmUser->renameBookmark($_GET["bm_path"], $_GET["bm_title"]);
}
}
}
}
if (AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
$bmUser->save();
AuthService::updateUser($bmUser);
} else {
if (!AuthService::usersEnabled()) {
$bmUser->save();
}
}
AJXP_XMLWriter::header();
AJXP_XMLWriter::writeBookmarks($bmUser->getBookmarks());
AJXP_XMLWriter::close();
exit(1);
break;
//------------------------------------
// SAVE USER PREFERENCE
//------------------------------------
//------------------------------------
// SAVE USER PREFERENCE
//------------------------------------
case "save_user_pref":
$userObject = AuthService::getLoggedUser();
if ($userObject == null) {
exit(1);
}
$i = 0;
while (isset($_GET["pref_name_" . $i]) && isset($_GET["pref_value_" . $i])) {
$prefName = $_GET["pref_name_" . $i];
$prefValue = stripslashes($_GET["pref_value_" . $i]);
if ($prefName != "password") {
$userObject->setPref($prefName, $prefValue);
$userObject->save();
AuthService::updateUser($userObject);
setcookie("AJXP_{$prefName}", $prefValue);
} else {
if (isset($_GET["crt"]) && AuthService::checkPassword($userObject->getId(), $_GET["crt"], false, $_GET["pass_seed"])) {
AuthService::updatePassword($userObject->getId(), $prefValue);
} else {
//$errorMessage = "Wrong password!";
header("Content-Type:text/plain");
print "PASS_ERROR";
exit(1);
}
}
$i++;
}
header("Content-Type:text/plain");
print "SUCCESS";
exit(1);
break;
default:
break;
}
if (isset($logMessage) || isset($errorMessage)) {
$xmlBuffer .= AJXP_XMLWriter::sendMessage(isset($logMessage) ? $logMessage : null, isset($errorMessage) ? $errorMessage : null, false);
}
if (isset($requireAuth)) {
$xmlBuffer .= AJXP_XMLWriter::requireAuth(false);
}
return $xmlBuffer;
}
示例13: switchAction
//.........这里部分代码省略.........
$user = $loggedUser;
} else {
$confStorage = ConfService::getConfStorageImpl();
$user = $confStorage->createUserObject($userId);
}
$wallet = $user->getPref("AJXP_WALLET");
if (!is_array($wallet)) {
$wallet = array();
}
$repoID = $httpVars["repository_id"];
if (!array_key_exists($repoID, $wallet)) {
$wallet[$repoID] = array();
}
$options = $wallet[$repoID];
$this->parseParameters($httpVars, $options, $userId);
$wallet[$repoID] = $options;
$user->setPref("AJXP_WALLET", $wallet);
$user->save();
if ($loggedUser->getId() == $user->getId()) {
AuthService::updateUser($user);
}
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.47"] . $httpVars["user_id"], null);
AJXP_XMLWriter::close();
exit(1);
break;
case "update_user_pwd":
if (!isset($httpVars["user_id"]) || !isset($httpVars["user_pwd"]) || !AuthService::userExists($httpVars["user_id"]) || trim($httpVars["user_pwd"]) == "") {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.61"]);
AJXP_XMLWriter::close();
exit(1);
}
$res = AuthService::updatePassword($httpVars["user_id"], $httpVars["user_pwd"]);
AJXP_XMLWriter::header();
if ($res === true) {
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.48"] . $httpVars["user_id"], null);
} else {
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.49"] . " : {$res}");
}
AJXP_XMLWriter::close();
exit(1);
break;
case "get_drivers_definition":
AJXP_XMLWriter::header("drivers");
print ConfService::availableDriversToXML("param");
AJXP_XMLWriter::close("drivers");
exit(1);
break;
case "create_repository":
$options = array();
$repDef = $httpVars;
unset($repDef["get_action"]);
$this->parseParameters($repDef, $options);
if (count($options)) {
$repDef["DRIVER_OPTIONS"] = $options;
}
// NOW SAVE THIS REPOSITORY!
$newRep = ConfService::createRepositoryFromArray(0, $repDef);
if (is_file(INSTALL_PATH . "/server/tests/plugins/test.ajxp_" . $newRep->getAccessType() . ".php")) {
chdir(INSTALL_PATH . "/server/tests/plugins");
include INSTALL_PATH . "/server/tests/plugins/test.ajxp_" . $newRep->getAccessType() . ".php";
$className = "ajxp_" . $newRep->getAccessType();
$class = new $className();
$result = $class->doRepositoryTest($newRep);
if (!$result) {
示例14: assignSharedRepositoryPermissions
/**
* @param Repository $parentRepository
* @param Repository $childRepository
* @param bool $isUpdate
* @param array $users
* @param array $groups
* @param UserSelection $selection
* @param bool|false $disableDownload
* @throws Exception
*/
public function assignSharedRepositoryPermissions($parentRepository, $childRepository, $isUpdate, $users, $groups, $selection)
{
$childRepoId = $childRepository->getId();
if ($isUpdate) {
$this->unregisterRemovedUsers($childRepoId, $users, $groups, $selection->getUniqueNode());
}
$confDriver = ConfService::getConfStorageImpl();
$loggedUser = AuthService::getLoggedUser();
foreach ($users as $userName => $userEntry) {
if (AuthService::userExists($userName, "r")) {
$userObject = $confDriver->createUserObject($userName);
if (isset($userEntry["HIDDEN"]) && isset($userEntry["UPDATE_PASSWORD"])) {
AuthService::updatePassword($userName, $userEntry["UPDATE_PASSWORD"]);
}
} else {
$mess = ConfService::getMessages();
$hiddenUserLabel = "[" . $mess["share_center.109"] . "] " . AJXP_Utils::sanitize($childRepository->getDisplay(), AJXP_SANITIZE_EMAILCHARS);
$userObject = $this->createNewUser($loggedUser, $userName, $userEntry["PASSWORD"], isset($userEntry["HIDDEN"]), $hiddenUserLabel);
}
// ASSIGN NEW REPO RIGHTS
$userObject->personalRole->setAcl($childRepoId, $userEntry["RIGHT"]);
// FORK MASK IF THERE IS ANY
$childMask = $this->forkMaskIfAny($loggedUser, $parentRepository->getId(), $selection->getUniqueNode());
if ($childMask != null) {
$userObject->personalRole->setMask($childRepoId, $childMask);
}
// CREATE A MINISITE-LIKE ROLE FOR THIS REPOSITORY
if (isset($userEntry["HIDDEN"]) && !isset($userEntry["REMOTE"])) {
$minisiteRole = $this->createRoleForMinisite($childRepoId, $userEntry["DISABLE_DOWNLOAD"], $isUpdate);
if ($minisiteRole != null) {
$userObject->addRole($minisiteRole);
}
}
// ADD "my shared files" REPO OTHERWISE SOME USER CANNOT ACCESS
if (!isset($userEntry["HIDDEN"]) && $childRepository->hasContentFilter()) {
$inboxRepo = ConfService::getRepositoryById("inbox");
$currentAcl = $userObject->mergedRole->getAcl("inbox");
if ($inboxRepo !== null && empty($currentAcl)) {
$userObject->personalRole->setAcl("inbox", "rw");
}
}
$userObject->save("superuser");
}
foreach ($groups as $group => $groupEntry) {
$r = $groupEntry["RIGHT"];
$grRole = AuthService::getRole($group, true);
$grRole->setAcl($childRepoId, $r);
AuthService::updateRole($grRole);
}
}