本文整理汇总了PHP中AuthService::getLoggedUser方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthService::getLoggedUser方法的具体用法?PHP AuthService::getLoggedUser怎么用?PHP AuthService::getLoggedUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthService
的用法示例。
在下文中一共展示了AuthService::getLoggedUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticate
public function authenticate(Sabre\DAV\Server $server, $realm)
{
//AJXP_Logger::debug("Try authentication on $realm", $server);
try {
$success = parent::authenticate($server, $realm);
} catch (Exception $e) {
$success = 0;
$errmsg = $e->getMessage();
if ($errmsg != "No digest authentication headers were found") {
$success = false;
}
}
if ($success) {
$res = AuthService::logUser($this->currentUser, null, true);
if ($res < 1) {
throw new Sabre\DAV\Exception\NotAuthenticated();
}
$this->updateCurrentUserRights(AuthService::getLoggedUser());
if (ConfService::getCoreConf("SESSION_SET_CREDENTIALS", "auth")) {
$webdavData = AuthService::getLoggedUser()->getPref("AJXP_WEBDAV_DATA");
AJXP_Safe::storeCredentials($this->currentUser, $this->_decodePassword($webdavData["PASS"], $this->currentUser));
}
} else {
if ($success === false) {
AJXP_Logger::warning(__CLASS__, "Login failed", array("user" => $this->currentUser, "error" => "Invalid WebDAV user or password"));
}
throw new Sabre\DAV\Exception\NotAuthenticated($errmsg);
}
ConfService::switchRootDir($this->repositoryId);
return true;
}
示例2: toggleDisclaimer
public function toggleDisclaimer($actionName, $httpVars, $fileVars)
{
$u = AuthService::getLoggedUser();
$u->personalRole->setParameterValue("action.disclaimer", "DISCLAIMER_ACCEPTED", $httpVars["validate"] == "true" ? "yes" : "no", AJXP_REPO_SCOPE_ALL);
if ($httpVars["validate"] == "true") {
$u->removeLock();
$u->save("superuser");
AuthService::updateUser($u);
ConfService::switchUserToActiveRepository($u);
$force = $u->mergedRole->filterParameterValue("core.conf", "DEFAULT_START_REPOSITORY", AJXP_REPO_SCOPE_ALL, -1);
$passId = -1;
if ($force != "" && $u->canSwitchTo($force) && !isset($httpVars["tmp_repository_id"]) && !isset($_SESSION["PENDING_REPOSITORY_ID"])) {
$passId = $force;
}
$res = ConfService::switchUserToActiveRepository($u, $passId);
if (!$res) {
AuthService::disconnect();
AJXP_XMLWriter::header();
AJXP_XMLWriter::requireAuth(true);
AJXP_XMLWriter::close();
}
ConfService::getInstance()->invalidateLoadedRepositories();
} else {
$u->setLock("validate_disclaimer");
$u->save("superuser");
AuthService::disconnect();
AJXP_XMLWriter::header();
AJXP_XMLWriter::requireAuth(true);
AJXP_XMLWriter::close();
}
}
示例3: getUserId
protected function getUserId()
{
if (AuthService::usersEnabled()) {
return AuthService::getLoggedUser()->getId();
}
return "shared";
}
示例4: filter
/**
* Filter the very basic keywords from the XML : AJXP_USER, AJXP_INSTALL_PATH, AJXP_DATA_PATH
* Calls the vars.filter hooks.
* @static
* @param $value
* @return mixed|string
*/
public static function filter($value)
{
if (is_string($value) && strpos($value, "AJXP_USER") !== false) {
if (AuthService::usersEnabled()) {
$loggedUser = AuthService::getLoggedUser();
if ($loggedUser != null) {
$loggedUser = $loggedUser->getId();
$value = str_replace("AJXP_USER", $loggedUser, $value);
} else {
return "";
}
} else {
$value = str_replace("AJXP_USER", "shared", $value);
}
}
if (is_string($value) && strpos($value, "AJXP_INSTALL_PATH") !== false) {
$value = str_replace("AJXP_INSTALL_PATH", AJXP_INSTALL_PATH, $value);
}
if (is_string($value) && strpos($value, "AJXP_DATA_PATH") !== false) {
$value = str_replace("AJXP_DATA_PATH", AJXP_DATA_PATH, $value);
}
$tab = array(&$value);
AJXP_Controller::applyIncludeHook("vars.filter", $tab);
return $value;
}
示例5: filter
/**
* Filter the very basic keywords from the XML : AJXP_USER, AJXP_INSTALL_PATH, AJXP_DATA_PATH
* Calls the vars.filter hooks.
* @static
* @param $value
* @param AbstractAjxpUser|String $resolveUser
* @return mixed|string
*/
public static function filter($value, $resolveUser = null)
{
if (is_string($value) && strpos($value, "AJXP_USER") !== false) {
if (AuthService::usersEnabled()) {
if ($resolveUser != null) {
if (is_string($resolveUser)) {
$resolveUserId = $resolveUser;
} else {
$resolveUserId = $resolveUser->getId();
}
$value = str_replace("AJXP_USER", $resolveUserId, $value);
} else {
$loggedUser = AuthService::getLoggedUser();
if ($loggedUser != null) {
if ($loggedUser->hasParent() && $loggedUser->getResolveAsParent()) {
$loggedUserId = $loggedUser->getParent();
} else {
$loggedUserId = $loggedUser->getId();
}
$value = str_replace("AJXP_USER", $loggedUserId, $value);
} else {
return "";
}
}
} else {
$value = str_replace("AJXP_USER", "shared", $value);
}
}
if (is_string($value) && strpos($value, "AJXP_GROUP_PATH") !== false) {
if (AuthService::usersEnabled()) {
if ($resolveUser != null) {
if (is_string($resolveUser) && AuthService::userExists($resolveUser)) {
$loggedUser = ConfService::getConfStorageImpl()->createUserObject($resolveUser);
} else {
$loggedUser = $resolveUser;
}
} else {
$loggedUser = AuthService::getLoggedUser();
}
if ($loggedUser != null) {
$gPath = $loggedUser->getGroupPath();
$value = str_replace("AJXP_GROUP_PATH_FLAT", str_replace("/", "_", trim($gPath, "/")), $value);
$value = str_replace("AJXP_GROUP_PATH", $gPath, $value);
} else {
return "";
}
} else {
$value = str_replace(array("AJXP_GROUP_PATH", "AJXP_GROUP_PATH_FLAT"), "shared", $value);
}
}
if (is_string($value) && strpos($value, "AJXP_INSTALL_PATH") !== false) {
$value = str_replace("AJXP_INSTALL_PATH", AJXP_INSTALL_PATH, $value);
}
if (is_string($value) && strpos($value, "AJXP_DATA_PATH") !== false) {
$value = str_replace("AJXP_DATA_PATH", AJXP_DATA_PATH, $value);
}
$tab = array(&$value);
AJXP_Controller::applyIncludeHook("vars.filter", $tab);
return $value;
}
示例6: preProcess
public function preProcess($action, $httpVars, $fileVars)
{
if (!is_array($this->pluginConf) || !isset($this->pluginConf["TO"])) {
throw new Exception("Cannot find configuration for plugin notify.phpmail-lite! Make sur the .inc file was dropped inside the /server/conf/ folder!");
}
require "lib/class.phpmailer-lite.php";
$mail = new PHPMailerLite(true);
$mail->Mailer = $this->pluginConf["MAILER"];
$mail->SetFrom($this->pluginConf["FROM"]["address"], $this->pluginConf["FROM"]["name"]);
foreach ($this->pluginConf["TO"] as $address) {
$mail->AddAddress($address["address"], $address["name"]);
}
$mail->WordWrap = 50;
// set word wrap to 50 characters
$mail->IsHTML(true);
// set email format to HTML
$mail->Subject = $this->pluginConf["SUBJECT"];
$mail->Body = str_replace("%user", AuthService::getLoggedUser()->getId(), $this->pluginConf["BODY"]);
$mail->AltBody = strip_tags($mail->Body);
if (!$mail->Send()) {
$message = "Message could not be sent. <p>";
$message .= "Mailer Error: " . $mail->ErrorInfo;
throw new Exception($message);
}
}
示例7: tryToLogUser
function tryToLogUser(&$httpVars, $isLast = false)
{
if (!isset($httpVars["get_action"]) || $httpVars["get_action"] != "login") {
return false;
}
$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"]) ? AJXP_Utils::sanitize($httpVars["userid"], AJXP_SANITIZE_EMAILCHARS) : 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";
}
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();
if ($loggingResult > 0 || $isLast) {
exit;
}
}
示例8: getUserId
protected function getUserId($private)
{
if (!$private) {
return AJXP_METADATA_SHAREDUSER;
}
if (AuthService::usersEnabled()) {
return AuthService::getLoggedUser()->getId();
}
return "shared";
}
示例9: getTreeName
private function getTreeName()
{
$base = AJXP_SHARED_CACHE_DIR . "/trees/tree-" . ConfService::getRepository()->getId();
$secuScope = ConfService::getRepository()->securityScope();
if ($secuScope == "USER") {
$base .= "-" . AuthService::getLoggedUser()->getId();
} else {
if ($secuScope == "GROUP") {
$base .= "-" . str_replace("/", "_", AuthService::getLoggedUser()->getGroupPath());
}
}
return $base . "-full.xml";
}
示例10: put
/**
* Updates the data
*
* The data argument is a readable stream resource.
*
* After a succesful put operation, you may choose to return an ETag. The
* etag must always be surrounded by double-quotes. These quotes must
* appear in the actual string you're returning.
*
* Clients may use the ETag from a PUT request to later on make sure that
* when they update the file, the contents haven't changed in the mean
* time.
*
* If you don't plan to store the file byte-by-byte, and you return a
* different object on a subsequent GET you are strongly recommended to not
* return an ETag, and just return null.
*
* @param resource $data
* @return string|null
*/
public function put($data)
{
// Warning, passed by ref
$p = $this->path;
if (!AuthService::getLoggedUser()->canWrite($this->repository->getId())) {
throw new \Sabre\DAV\Exception\Forbidden();
}
$this->getAccessDriver()->nodeWillChange($p, intval($_SERVER["CONTENT_LENGTH"]));
$stream = fopen($this->getUrl(), "w");
stream_copy_to_stream($data, $stream);
fclose($stream);
$toto = null;
$this->getAccessDriver()->nodeChanged($toto, $p);
return $this->getETag();
}
示例11: getRegistryContributions
public function getRegistryContributions()
{
$logged = AuthService::getLoggedUser();
if (AuthService::usersEnabled()) {
if ($logged == null) {
return $this->registryContributions;
} else {
$xmlString = AJXP_XMLWriter::getUserXml($logged, false);
}
} else {
$xmlString = AJXP_XMLWriter::getUserXml(null, false);
}
$dom = new DOMDocument();
$dom->loadXML($xmlString);
$this->registryContributions[] = $dom->documentElement;
return $this->registryContributions;
}
示例12: getChildren
public function getChildren()
{
$this->children = array();
$u = AuthService::getLoggedUser();
if ($u != null) {
$repos = ConfService::getAccessibleRepositories($u);
// Refilter to make sure the driver is an AjxpWebdavProvider
foreach ($repos as $repository) {
$accessType = $repository->getAccessType();
$driver = AJXP_PluginsService::getInstance()->getPluginByTypeName("access", $accessType);
if (is_a($driver, "AjxpWrapperProvider") && $repository->getOption("AJXP_WEBDAV_DISABLED") !== true) {
$this->children[$repository->getSlug()] = new Sabre\DAV\SimpleCollection($repository->getSlug());
}
}
}
return $this->children;
}
示例13: formatMessage
/**
* formats the error message in representable manner
*
* For the SQL driver we will normalise the information into our table row format.
*
* @param $message String this is the message to be formatted
* @param $severity Severity level of the message: one of LOG_LEVEL_* (DEBUG,INFO,NOTICE,WARNING,ERROR)
* @return String the formatted message.
*/
function formatMessage($message, $severity)
{
// Get the user if it exists
$user = "No User";
if (AuthService::usersEnabled()) {
$logged = AuthService::getLoggedUser();
if ($logged != null) {
$user = $logged->getId();
} else {
$user = "shared";
}
}
$message_parts = explode("\t", $message);
$severity = strtoupper((string) $severity);
$log_row = array('logdate' => $this->toMysqlDateTime(strtotime('NOW')), 'remote_ip' => $this->inet_ptod($_SERVER['REMOTE_ADDR']), 'severity' => $severity, 'user' => $user, 'message' => $message_parts[0], 'params' => $message_parts[1]);
return $log_row;
}
示例14: computeIdForNode
/**
* @param AJXP_Node $node
* @param string $cacheType
* @param string $details
* @return string
*/
public static function computeIdForNode($node, $cacheType, $details = '')
{
$repo = $node->getRepository();
if ($repo == null) {
return "failed-id";
}
$scope = $repo->securityScope();
$additional = "";
if ($scope === "USER") {
$additional = AuthService::getLoggedUser()->getId() . "@";
} else {
if ($scope == "GROUP") {
$additional = ltrim(str_replace("/", "__", AuthService::getLoggedUser()->getGroupPath()), "__") . "@";
}
}
$scheme = parse_url($node->getUrl(), PHP_URL_SCHEME);
return str_replace($scheme . "://", $cacheType . "://" . $additional, $node->getUrl()) . ($details ? "##" . $details : "");
}
示例15: filterUsersPref
function filterUsersPref($action, $httpVars, $fileVars)
{
if ($action != "save_user_pref") {
return;
}
$loggedUser = AuthService::getLoggedUser()->getId();
if ($loggedUser != "demo") {
return;
}
$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") {
throw new Exception("You are not allowed to change the password");
}
$i++;
}
}