本文整理汇总了PHP中UserDB类的典型用法代码示例。如果您正苦于以下问题:PHP UserDB类的具体用法?PHP UserDB怎么用?PHP UserDB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserDB类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkAuth
function checkAuth($action, &$options)
{
if ($action == 'login' or $action == 'logout') {
$options['custom'] = 'basicAuth';
unset($_SERVER['PHP_AUTH_USER']);
unset($_SERVER['PHP_AUTH_PW']);
return 0;
}
if (isset($_SERVER['PHP_AUTH_USER']) and $_SERVER['PHP_AUTH_PW']) {
$id = $_SERVER['PHP_AUTH_USER'];
$userdb = new UserDB($this->DB);
$user = new WikiUser();
# get from COOKIE VARS
if ($user->id == $id) {
return 1;
}
if ($userdb->_exists($id)) {
$user = $userdb->getUser($id);
# check password
if ($user->checkPasswd($_SERVER['PHP_AUTH_PW']) === true) {
$dummy = $user->setCookie();
$dummy = $userdb->saveUser($user);
return 1;
}
}
}
unset($_SERVER['PHP_AUTH_USER']);
unset($_SERVER['PHP_AUTH_PW']);
return 0;
}
示例2: Security_htaccesslogin
function Security_htaccesslogin($DB = "")
{
$this->DB = $DB;
# BEGIN LOGIN
$id = getenv('REMOTE_USER');
if ($id != "") {
$userdb = new UserDB($DB);
$user = new WikiUser();
# get from COOKIE VARS
if ($userdb->_exists($id)) {
# login
$user = $userdb->getUser($id);
$options['id'] = $user->id;
$options['login_id'] = $user->id;
$dummy = $user->setCookie();
$dummy = $userdb->saveUser($user);
} else {
# create account
$user->id = $id;
$options['id'] = $user->id;
#$ticket=md5(time().$user->id.$options['email']);
#$user->info['eticket']='';
$dummy = $user->setCookie();
$dummy = $userdb->addUser($user);
}
}
# END LOGIN
}
示例3: addComment
public function addComment($parent_id, $article_id, $text)
{
$comment = new CommentDB();
if (!$this->auth_user) {
return false;
}
$comment->article_id = $article_id;
$comment->user_id = $this->auth_user->id;
$comment->parent_id = $parent_id;
$comment->text = $text;
try {
$comment->save();
/*не верно*/
$comment_parent = new CommentDB();
$comment_parent->load($parent_id);
if ($comment_parent->isSaved() && $comment_parent->user_id != $this->auth_user->id) {
$user = new UserDB();
$user->load($comment_parent->user_id);
$this->mail->send($user->email, array("user" => $user, "link" => $comment_parent->link), "comment_subscribe");
}
return json_encode(array("id" => $comment->id, "parent_id" => $comment->parent_id, "user_id" => $this->auth_user->id, "name" => $this->auth_user->name, "avatar" => $this->auth_user->avatar, "text" => $comment->text, "date" => $comment->date));
} catch (Exception $e) {
return false;
}
}
示例4: login
public function login(UserDB $user)
{
session_regenerate_id();
if ($user) {
$this->user_id = $_SESSION['user_id'] = $user->id;
$_SESSION['logged_in'] = true;
$this->logged_in = true;
$user->update_last_login();
}
}
示例5: loginCheck
public function loginCheck($num, $password)
{
$userdb = new UserDB();
$u = $userdb->login($num, $password);
if ($u) {
$d = array("id" => $u[0], "num" => $u[1], "username" => $u[2]);
return $d;
} else {
return false;
}
}
示例6: testAuthorizeUser
function testAuthorizeUser()
{
$info = new UserInfo($this->data);
$store = new UserDB();
$store->updateUser($info);
$result = $store->authorizeUser($info);
$this->assertEquals($info->userid, $result->userid);
$this->assertEquals($info->username, $result->username);
$fake = new UserInfo(array('username' => 'test', 'password' => 1111));
$result = $store->authorizeUser($fake);
$this->assertEquals(null, $result);
}
示例7: User_nforge
function User_nforge($id = '')
{
if ($id) {
$this->setID($id);
$u =& user_get_object_by_name($id);
} else {
$u =& user_get_object(user_getid());
if ($u and is_object($u) and !$u->isError()) {
global $DBInfo;
$id = $u->getUnixName();
}
if (!empty($id)) {
$this->setID($id);
$udb = new UserDB($DBInfo);
$tmp = $udb->getUser($id);
// get timezone and make timezone offset
$tz_offset = date('Z');
$update = 0;
if ($tz_offset != $tmp->info['tz_offset']) {
$update = 1;
}
if (!empty($DBInfo->use_homepage_url) and empty($tmp->info['home']) or $update or empty($tmp->info['nick']) or $tmp->info['nick'] != $u->data_array['realname']) {
// register user
$tmp->info['tz_offset'] = $tz_offset;
$tmp->info['nick'] = $u->data_array['realname'];
if (!empty($DBInfo->use_homepage_url)) {
$tmp->info['home'] = util_make_url_u($u->getID(), true);
}
$udb->saveUser($tmp);
}
} else {
$id = 'Anonymous';
$this->setID('Anonymous');
}
}
$this->css = isset($_COOKIE['MONI_CSS']) ? $_COOKIE['MONI_CSS'] : '';
$this->theme = isset($_COOKIE['MONI_THEME']) ? $_COOKIE['MONI_THEME'] : '';
$this->bookmark = isset($_COOKIE['MONI_BOOKMARK']) ? $_COOKIE['MONI_BOOKMARK'] : '';
$this->trail = isset($_COOKIE['MONI_TRAIL']) ? _stripslashes($_COOKIE['MONI_TRAIL']) : '';
$this->tz_offset = isset($_COOKIE['MONI_TZ']) ? _stripslashes($_COOKIE['MONI_TZ']) : '';
$this->nick = isset($_COOKIE['MONI_NICK']) ? _stripslashes($_COOKIE['MONI_NICK']) : '';
if ($this->tz_offset == '') {
$this->tz_offset = date('Z');
}
if (!empty($id) and $id != 'Anonymous') {
global $DBInfo;
$udb = new UserDB($DBInfo);
if (!$udb->_exists($id)) {
$dummy = $udb->saveUser($this);
}
}
}
示例8: get
public static function get()
{
$page = new Page();
$page->data['title'] = 'Geld beheren';
//Redirect if user is not set
if (!isset($_GET['user'])) {
header('Location: manageuser', true, 303);
} else {
try {
$_SESSION['Stippers']['ManageUserMoney']['user'] = UserDB::getFullUserById($_GET['user']);
ManageUserMoneyController::buildEnterTransactionView($page, false);
} catch (UserDBException $ex) {
if ($ex->getCode() == UserDBException::NOUSERFORCARDNUMER) {
$page->data['ErrorMessageNoDescriptionWithLinkView']['errorTitle'] = 'Er is geen gebruiker met deze id';
} else {
$page->data['ErrorMessageNoDescriptionWithLinkView']['errorTitle'] = 'Kan gegevens niet ophalen uit de database';
}
$page->data['ErrorMessageNoDescriptionWithLinkView']['tryAgainUrl'] = $_SERVER['REQUEST_URI'];
$page->addView('error/ErrorMessageNoDescriptionWithLinkView');
} catch (Exception $ex) {
$page->data['ErrorMessageNoDescriptionWithLinkView']['errorTitle'] = 'Kan gegevens niet ophalen uit de database';
$page->data['ErrorMessageNoDescriptionWithLinkView']['tryAgainUrl'] = $_SERVER['REQUEST_URI'];
$page->addView('error/ErrorMessageNoDescriptionWithLinkView');
}
$page->showWithMenu();
}
}
示例9: usersLogin
public function usersLogin()
{
Logger::debug('main', 'USERSGROUP::usersLogin (for id=' . $this->getUniqueID() . ')');
$logins = array();
$prefs = Preferences::getInstance();
if (!$prefs) {
Logger::critical('main', 'USERSGROUP::usersLogin (for id=' . $this->getUniqueID() . ') get prefs failed');
die_error('get Preferences failed', __FILE__, __LINE__);
}
$user_default_group = $prefs->get('general', 'user_default_group');
if ($user_default_group === $this->getUniqueID()) {
// it's the default group -> we add all users
$userdb = UserDB::getInstance();
$users = $userdb->getList();
foreach ($users as $a_user) {
$logins[] = $a_user->getAttribute('login');
}
} else {
$ls = Abstract_Liaison::load('UsersGroup', NULL, $this->getUniqueID());
if (is_array($ls)) {
foreach ($ls as $l) {
$logins[] = $l->element;
}
}
}
return $logins;
}
示例10: makeLDAPconfig
public function makeLDAPconfig($config_ = NULL)
{
if (is_null($config_) === false) {
return $config_;
} else {
$userDBAD = UserDB::getInstance();
if (method_exists($userDBAD, 'makeLDAPconfig') === false) {
Logger::error('main', 'UserGroupDB::ldap_posix::makeLDAPconfig makeLDAPconfig is not avalaible');
return NULL;
}
$configLDAP = $userDBAD->makeLDAPconfig();
$configLDAP['match'] = array();
if (array_key_exists('match', $this->preferences)) {
$configLDAP['match'] = $this->preferences['match'];
}
$configLDAP['userbranch'] = '';
if (array_key_exists('group_dn', $this->preferences)) {
$configLDAP['userbranch'] = $this->preferences['group_dn'];
}
if (array_key_exists('filter', $this->preferences)) {
$configLDAP['filter'] = $this->preferences['filter'];
}
return $configLDAP;
}
}
示例11: get_login
public function get_login()
{
$userDB = UserDB::getInstance();
if (!is_object($userDB)) {
return NULL;
}
$prefs = Preferences::getInstance();
$config = $prefs->get('AuthMethod', 'Auto');
if (array_key_exists('login', $_POST) && array_key_exists('uselogin', $config) && $config['uselogin'] == '1') {
$this->login = $_POST['login'];
} else {
$this->login = 'u' . gen_unique_string();
}
$u = new User();
$u->setAttribute('login', $this->login);
$u->setAttribute('password', $u->getAttribute('login'));
$u->setAttribute('displayname', 'user ' . $u->getAttribute('login'));
if ($userDB->add($u)) {
$user = $userDB->import($u->getAttribute('login'));
} else {
Logger::error('main', 'AuthMethod::Auto::get_login failed to add user ' . $u->getAttribute('login'));
return NULL;
}
if (!is_object($user)) {
return NULL;
}
$this->login = $user->getAttribute('login');
return $this->login;
}
示例12: post
public static function post()
{
$page = new Page();
$page->data['title'] = 'Kassa';
if (isset($_POST['to_enter_transaction_view'])) {
$errMsgs = CashRegisterEnterCardViewValidator::validate($_POST);
if (empty($errMsgs)) {
try {
$_SESSION['Stippers']['CashRegister']['user'] = UserDB::getFullUserByCardNumber($_POST['card_number']);
if (!$_SESSION['Stippers']['CashRegister']['user']) {
CashRegisterController::buildEnterCardView($page, true);
$page->data['CashRegisterEnterCardView']['errMsgs']['global'] = '<h2 class="error_message" id="enter_card_form_error_message">Dit kaartnummer is niet gekoppeld aan een gebruiker.</h2>';
} else {
CashRegisterController::buildEnterTransactionView($page, false);
}
} catch (Exception $ex) {
CashRegisterController::buildEnterCardView($page, true);
$page->data['CashRegisterEnterCardView']['errMsgs']['global'] = '<h2 class="error_message" id="enter_card_form_error_message">Kan gebruiker niet ophalen, probeer opnieuw.</h2>';
}
} else {
CashRegisterController::buildEnterCardView($page, true);
$page->data['CashRegisterEnterCardView']['errMsgs'] = array_merge($page->data['CashRegisterEnterCardView']['errMsgs'], $errMsgs);
}
} elseif (isset($_POST['register_transaction'])) {
$errMsgs = CashRegisterEnterTransactionViewValidator::validate($_POST);
if (empty($errMsgs)) {
try {
$decrMoney = $_POST['decrease_money'] == '' ? 0 : SafeMath::getCentsFromString($_POST['decrease_money']);
$executingBrowserName = BrowserDB::getBrowserById($_SESSION['Stippers']['browser']->browserId)->name;
$trans = new MoneyTransaction(null, $_SESSION['Stippers']['CashRegister']['user']->userId, $_SESSION['Stippers']['CashRegister']['user']->balance, 0, $decrMoney, MoneyTransactionConfig::DEFAULT_DISCOUNT_PERC, false, null, $executingBrowserName, null);
if ($trans->getBalAfter() < 0) {
$page->data['ErrorMessageWithDescriptionWithLinkView']['tryAgainUrl'] = $_SERVER['REQUEST_URI'];
$page->data['ErrorMessageWithDescriptionWithLinkView']['errorTitle'] = 'Saldo te laag';
$page->data['ErrorMessageWithDescriptionWithLinkView']['errorDescription'] = 'Het saldo de kaart is te laag.<br>Je komt onder nul uit.';
$page->addView('error/ErrorMessageWithDescriptionWithLinkView');
} else {
MoneyTransactionDB::addTransaction($_SESSION['Stippers']['CashRegister']['user'], $trans);
$page->data['CashRegisterTransactionResultView']['balBefore'] = $trans->getBalBefore() / 100;
$page->data['CashRegisterTransactionResultView']['balAfter'] = $trans->getBalAfter() / 100;
$page->data['CashRegisterTransactionResultView']['discount'] = $trans->getDiscount() / 100;
$page->data['CashRegisterTransactionResultView']['decrMoney'] = $trans->getDecrMoney() / 100;
$page->addView('cashRegister/CashRegisterTransactionResultView');
}
} catch (Exception $ex) {
CashRegisterController::buildEnterTransactionView($page, true);
$page->data['CashRegisterEnterTransactionView']['errMsgs']['global'] = '<h2 class="error_message" id="enter_transaction_form_error_message">Kan transactie niet registreren, probeer opnieuw.</h2>';
}
} else {
CashRegisterController::buildEnterTransactionView($page, true);
$page->data['CashRegisterEnterTransactionView']['errMsgs'] = array_merge($page->data['CashRegisterEnterTransactionView']['errMsgs'], $errMsgs);
}
}
$page->showWithMenu();
}
示例13: post
public static function post()
{
//If required data is not in session go to search page
if (!isset($_SESSION['Stippers']['ManageUserSearch']['inputData']['values'])) {
header('Location: manageuser', TRUE, 303);
} else {
$page = new Page();
$page->data['title'] = 'E-mail versturen naar gebruikers';
$errMsgs = SendEmailToUsersViewValidator::validate($_POST);
if (empty($errMsgs)) {
try {
//Get search users
$select = ['email' => true, 'firstName' => true, 'lastName' => true];
$users = array_column(UserDB::getSearchUsers($select, $_SESSION['Stippers']['ManageUserSearch']['inputData']['values'], null), 'user');
//Send email
$failedAddresses = Email::sendEmails($_POST['email_file'], $_POST['subject'], EmailConfig::FROM_ADDRESS, $users, null);
//Check if some emails failed
if (empty($failedAddresses)) {
$page->date['SuccessMessageNoDescriptionWithLinkView']['successTitle'] = 'E-mails succesvol verzonden';
$page->date['SuccessMessageNoDescriptionWithLinkView']['redirectUrl'] = 'manageuser';
$page->addView('success/SuccessMessageNoDescriptionWithLinkView');
} else {
$page->data['ErrorMessageWithDescriptionNoLinkView']['errorTitle'] = 'Kan niet alle e-mails verzenden';
$page->data['ErrorMessageWithDescriptionNoLinkView']['errorDescription'] = 'Het verzenden van de e-mail naar onderstaande addressen is mislukt.';
$page->addView('error/ErrorMessageWithDescriptionNoLinkView');
$page->data['FailedEmailListView']['addresses'] = $failedAddresses;
$page->data['FailedEmailListView']['redirectUrl'] = 'manageuser';
$page->addView('sendEmailToUsers/FailedEmailListView');
}
} catch (UserDBException $ex) {
$page->data['ErrorMessageNoDescriptionWithLinkView']['errorTitle'] = 'Kan gebruikers niet ophalen';
$page->data['ErrorMessageNoDescriptionWithLinkView']['tryAgainUrl'] = $_SERVER['REQUEST_URI'];
$page->addView('error/ErrorMessageNoDescriptionWithLinkView');
} catch (EmailException $ex) {
if ($ex->getCode() == EmailException::CANNOTREADEMAILFILE) {
$page->data['ErrorMessageNoDescriptionWithLinkView']['errorTitle'] = 'Kan e-mailbestand niet lezen';
} else {
$page->data['ErrorMessageNoDescriptionWithLinkView']['errorTitle'] = 'Kan e-mails niet verzenden';
}
$page->data['ErrorMessageNoDescriptionWithLinkView']['tryAgainUrl'] = $_SERVER['REQUEST_URI'];
$page->addView('error/ErrorMessageNoDescriptionWithLinkView');
} catch (Exception $ex) {
$page->data['ErrorMessageNoDescriptionWithLinkView']['errorTitle'] = 'Kan e-mails niet verzenden';
$page->data['ErrorMessageNoDescriptionWithLinkView']['tryAgainUrl'] = $_SERVER['REQUEST_URI'];
$page->addView('error/ErrorMessageNoDescriptionWithLinkView');
}
} else {
$page->addView('sendEmailToUsers/SendEmailToUsersTitleView');
SendEmailToUsersController::buildSendEmailToUsersFormView($page, true);
$page->data['SendEmailToUsersFormView']['errMsgs'] = array_merge($page->data['SendEmailToUsersFormView']['errMsgs'], $errMsgs);
}
$page->showWithMenu();
}
}
示例14: search
function search()
{
$userDB = UserDB::getInstance();
list($this->result, $nb) = $userDB->getUsersContains($this->search_item, $this->search_fields, $this->search_limit + 1);
if ($nb || count($this->result) > $this->search_limit) {
array_pop($this->result);
$this->partial_result = true;
} else {
$this->partial_result = false;
}
return $this->result;
}
示例15: post
public static function post()
{
$page = new Page();
$page->data['title'] = 'Wachtwoord resetten';
$errMsgs = ResetPasswordViewValidator::validate($_POST);
if (empty($errMsgs)) {
try {
//Get the user's password salt and calculate password hash
$passwordSalt = UserDB::getPasswordSaltByEmail($_POST['email']);
$newPassword = Random::getPassword();
$newPasswordHash = hash_pbkdf2('sha256', $newPassword, $passwordSalt, SecurityConfig::N_PASSWORD_HASH_ITERATIONS);
//Get user from database and reset password.
$user = UserDB::getBasicUserByEmail($_POST['email']);
UserDB::resetPassword($_POST['email'], $newPasswordHash);
//Show success message
$page->data['ResetSuccessfulView']['redirectUrl'] = 'login';
$page->addView('resetPassword/ResetSuccessfulView');
//Send email with password
$failedEmails = Email::sendEmails('ResetPassword.html', 'JH De Stip - Wachtwoord reset', EmailConfig::FROM_ADDRESS, [$user], array($user->userId => array('newPassword' => $newPassword)));
//If failedEmails is not empty the mail was not sent
if (!empty($failedEmails)) {
$page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] = 'Kan e-mail met nieuwe wachtwoord niet verzenden.';
$page->addView('error/ErrorMessageNoDescriptionNoLinkView');
}
} catch (UserDBException $ex) {
$page->data['ResetPasswordView']['reset_password_formAction'] = $_SERVER['REQUEST_URI'];
$page->data['ResetPasswordView']['email'] = $_POST['email'];
$page->data['ResetPasswordView']['errMsgs'] = ResetPasswordViewValidator::initErrMsgs();
if ($ex->getCode() == UserDBException::NOUSERFOREMAIL) {
$page->data['ResetPasswordView']['errMsgs']['global'] = '<h2 class="error_message" id="reset_password_form_error_message">Er is geen gebruiker met dit e-mailadres.</h2>';
} else {
$page->data['ResetPasswordView']['errMsgs']['global'] = '<h2 class="error_message" id="reset_password_form_error_message">Kan wachtwoord niet resetten, probeer het opnieuw.</h2>';
}
$page->addView('resetPassword/ResetPasswordView');
} catch (EmailException $ex) {
$page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] = 'Kan e-mail met nieuwe wachtwoord niet verzenden.';
$page->addView('error/ErrorMessageNoDescriptionNoLinkView');
} catch (Exception $ex) {
$page->data['ResetPasswordView']['reset_password_formAction'] = $_SERVER['REQUEST_URI'];
$page->data['ResetPasswordView']['email'] = $_POST['email'];
$page->data['ResetPasswordView']['errMsgs']['global'] = '<h2 class="error_message" id="reset_password_form_error_message">Kan wachtwoord niet resetten, probeer het opnieuw.</h2>';
$page->addView('resetPassword/ResetPasswordView');
}
} else {
$page->data['ResetPasswordView']['reset_password_formAction'] = $_SERVER['REQUEST_URI'];
$page->data['ResetPasswordView']['email'] = $_POST['email'];
$page->data['ResetPasswordView']['errMsgs'] = ResetPasswordViewValidator::initErrMsgs();
$page->data['ResetPasswordView']['errMsgs'] = array_merge($page->data['ResetPasswordView']['errMsgs'], $errMsgs);
$page->addView('resetPassword/ResetPasswordView');
}
$page->showWithMenu();
}