本文整理汇总了PHP中UserAuth类的典型用法代码示例。如果您正苦于以下问题:PHP UserAuth类的具体用法?PHP UserAuth怎么用?PHP UserAuth使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserAuth类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateAutoloaderDb
public static function updateAutoloaderDb()
{
if (defined('\\UPDATE_AUTOLOADER') === false || \UPDATE_AUTOLOADER === false) {
$user = new UserAuth();
if ($user->isAdmin() === true) {
unset($user);
parent::classesScanner();
self::compareClasses(parent::getClassesStack(), false);
} else {
throw new \RuntimeException("Access Deny", 6029);
}
} else {
parent::classesScanner();
self::compareClasses(parent::getClassesStack(), false);
}
}
示例2: do_login
function do_login()
{
global $current_user, $globals;
$form_ip_check = check_form_auth_ip();
$previous_login_failed = log_get_date('login_failed', $globals['form_user_ip_int'], 0, 300);
echo '<form action="' . get_auth_link() . 'login.php" id="xxxthisform" method="post">' . "\n";
if ($_POST["processlogin"] == 1) {
// Check the IP, otherwise redirect
if (!$form_ip_check) {
header("Location: http://" . get_server_name() . $globals['base_url'] . "login.php");
die;
}
$username = clean_input_string(trim($_POST['username']));
$password = trim($_POST['password']);
if ($_POST['persistent']) {
$persistent = 3600000;
// 1000 hours
} else {
$persistent = 0;
}
// Check form
if (($previous_login_failed > 2 || $globals['captcha_first_login'] == true && !UserAuth::user_cookie_data()) && !ts_is_human()) {
log_insert('login_failed', $globals['form_user_ip_int'], 0);
recover_error(_('el código de seguridad no es correcto'));
} elseif ($current_user->Authenticate($username, md5($password), $persistent) == false) {
log_insert('login_failed', $globals['form_user_ip_int'], 0);
recover_error(_('usuario o email inexistente, sin validar, o clave incorrecta'));
$previous_login_failed++;
} else {
UserAuth::check_clon_from_cookies();
if (!empty($_REQUEST['return'])) {
header('Location: ' . $_REQUEST['return']);
} else {
header('Location: ./');
}
die;
}
}
echo '<p><label for="name">' . _('usuario o email') . ':</label><br />' . "\n";
echo '<input type="text" name="username" size="25" tabindex="1" id="name" value="' . htmlentities($username) . '" /></p>' . "\n";
echo '<p><label for="password">' . _('clave') . ':</label><br />' . "\n";
echo '<input type="password" name="password" id="password" size="25" tabindex="2"/></p>' . "\n";
echo '<p><label for="remember">' . _('recuérdame') . ': </label><input type="checkbox" name="persistent" id="remember" tabindex="3"/></p>' . "\n";
// Print captcha
if ($previous_login_failed > 2 || $globals['captcha_first_login'] == true && !UserAuth::user_cookie_data()) {
ts_print_form();
}
get_form_auth_ip();
echo '<p><input type="submit" value="login" tabindex="4" />' . "\n";
echo '<input type="hidden" name="processlogin" value="1"/></p>' . "\n";
echo '<input type="hidden" name="return" value="' . htmlspecialchars($_REQUEST['return']) . '"/>' . "\n";
echo '</form>' . "\n";
echo '<div><strong><a href="login.php?op=recover">' . _('¿has olvidado la contraseña?') . '</a></strong></div>' . "\n";
echo '<div style="margin-top: 30px">';
print_oauth_icons($_REQUEST['return']);
echo '</div>' . "\n";
}
示例3: initUser
/**
* @return void
*/
public function initUser()
{
$UserAuth = new UserAuth();
/*
* Auto login... if user during a previos
* visit set AUTOLOGIN option
*/
if (!isset($_SESSION['user']) and isset($_COOKIE['autologin'])) {
$UserAuth->autoLogin();
}
/*
* if user is autorizet set
* last time visit
* This information store in <DataBase>.users
*/
if (!empty($_SESSION['user'])) {
$UserAuth->setTimeVisit();
}
}
示例4: sendMessage
/**
* Send Message
*/
public function sendMessage($h)
{
$result = $h->sendMessage($this->to, '', $this->subject, $this->body);
if (is_array($result)) {
// error array!
$this->errors = $result;
return false;
} else {
// must be the insert id:
$this->id = $result;
}
// code here to call sendEmailNotification IF PERMITTED
$recipient = new UserAuth();
$recipient_id = $h->getUserIdFromName($this->to);
$recipient->getUserBasic($h, $recipient_id);
$recipient_settings = $recipient->getProfileSettingsData($h, 'user_settings');
if ($recipient_settings['pm_notify']) {
$this->sendEmailNotification($h);
}
return true;
}
示例5: getInstance
/**
* Returns an instance of the enabled user auth class.
*
* @return UserAuth
*/
public static function getInstance()
{
if (self::$instance === null) {
// call loadInstance event
if (!defined('NO_IMPORTS')) {
EventHandler::fireAction('UserAuth', 'loadInstance');
}
if (self::$instance === null) {
self::$instance = new UserAuthDefault();
}
}
return self::$instance;
}
示例6: create
/**
* @see SessionFactory::create()
*/
public function create()
{
// get spider information
$spider = $this->isSpider(UserUtil::getUserAgent());
if ($spider) {
if (($session = $this->getExistingSpiderSession($spider['spiderID'])) !== null) {
if (!$session->isCorrupt()) {
return $session;
}
}
}
// create new session hash
$sessionID = StringUtil::getRandomID();
// check cookies for userID & password
require_once WCF_DIR . 'lib/system/auth/UserAuth.class.php';
$user = UserAuth::getInstance()->loginAutomatically(true, $this->userClassName);
if ($user === null) {
// no valid user found
// create guest user
$user = new $this->guestClassName();
}
// update user session
$user->update();
if ($user->userID != 0) {
// user is no guest
// delete all other sessions of this user
Session::deleteSessions($user->userID, true, false);
}
$requestMethod = !empty($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : '';
// insert session into database
$sql = "INSERT INTO \twcf" . WCF_N . "_session\n\t\t\t\t\t(sessionID, packageID, userID, ipAddress, userAgent,\n\t\t\t\t\tlastActivityTime, requestURI, requestMethod,\n\t\t\t\t\tusername" . ($spider ? ", spiderID" : "") . ")\n\t\t\tVALUES\t\t('" . $sessionID . "',\n\t\t\t\t\t" . PACKAGE_ID . ",\n\t\t\t\t\t" . $user->userID . ",\n\t\t\t\t\t'" . escapeString(UserUtil::getIpAddress()) . "',\n\t\t\t\t\t'" . escapeString(UserUtil::getUserAgent()) . "',\n\t\t\t\t\t" . TIME_NOW . ",\n\t\t\t\t\t'" . escapeString(UserUtil::getRequestURI()) . "',\n\t\t\t\t\t'" . escapeString($requestMethod) . "',\n\t\t\t\t\t'" . ($spider ? escapeString($spider['spiderName']) : escapeString($user->username)) . "'\n\t\t\t\t\t" . ($spider ? ", " . $spider['spiderID'] : "") . ")";
WCF::getDB()->sendQuery($sql);
// save user data
$serializedUserData = '';
if (ENABLE_SESSION_DATA_CACHE && get_class(WCF::getCache()->getCacheSource()) == 'MemcacheCacheSource') {
require_once WCF_DIR . 'lib/system/cache/source/MemcacheAdapter.class.php';
MemcacheAdapter::getInstance()->getMemcache()->set('session_userdata_-' . $sessionID, $user);
} else {
$serializedUserData = serialize($user);
try {
$sql = "INSERT INTO \twcf" . WCF_N . "_session_data\n\t\t\t\t\t\t\t(sessionID, userData)\n\t\t\t\t\tVALUES \t\t('" . $sessionID . "',\n\t\t\t\t\t\t\t'" . escapeString($serializedUserData) . "')";
WCF::getDB()->sendQuery($sql);
} catch (DatabaseException $e) {
// horizon update workaround
$sql = "UPDATE \twcf" . WCF_N . "_session\n\t\t\t\t\tSET\tuserData = '" . escapeString($serializedUserData) . "'\n\t\t\t\t\tWHERE\tsessionID = '" . $sessionID . "'";
WCF::getDB()->sendQuery($sql);
}
}
// return new session object
return new $this->sessionClassName(null, array('sessionID' => $sessionID, 'packageID' => PACKAGE_ID, 'userID' => $user->userID, 'ipAddress' => UserUtil::getIpAddress(), 'userAgent' => UserUtil::getUserAgent(), 'lastActivityTime' => TIME_NOW, 'requestURI' => UserUtil::getRequestURI(), 'requestMethod' => $requestMethod, 'userData' => $serializedUserData, 'sessionVariables' => '', 'username' => $spider ? $spider['spiderName'] : $user->username, 'spiderID' => $spider ? $spider['spiderID'] : 0, 'isNew' => true));
}
示例7: getUserProfile
/**
* Returns a given user's profile
*
* @param string $username Username's profile to return
* @return array
*/
public static function getUserProfile($username)
{
if (!UserAuth::isUser($username)) {
return null;
}
$content = substr(File::get(Config::getConfigPath() . "/users/" . $username . ".yaml"), 3);
$divide = strpos($content, "\n---");
$front_matter = trim(substr($content, 0, $divide));
$content_raw = trim(substr($content, $divide + 4));
$profile = YAML::parse($front_matter);
$profile['biography_raw'] = $content_raw;
$profile['biography'] = Content::transform($content_raw);
$profile['username'] = $username;
return $profile;
}
示例8: DB
<?php
$DBVAR = new DB();
/* Deklarasi class UserAuth
* Class Name : UserAuth
* Location :root_path/function/userAuth/user_func.php
* Warning !!! Jangan buat nama variabel sama dengan nama variabel ini
*/
$USERAUTH = new UserAuth();
$SESSION = new Session();
/* Ambil session user */
$UserSession = $SESSION->get_session_user();
if (isset($_POST['login']))
{
$dataVar = array ('username'=>$_POST['username'], 'password'=>md5($_POST['password']), 'token' => 0);
$dataValid = $DBVAR->form_validation($dataVar);
if (is_array($dataValid))
{
$dataLogin = $USERAUTH->check_login_user($dataValid);
if ($dataLogin == true)
{
示例9: define
define('INSIDE', true);
define('LOGIN', true);
$ugamela_root_path = './';
include $ugamela_root_path . 'extension.inc';
include $ugamela_root_path . 'common.' . $phpEx;
require_once WCF_DIR . 'lib/acp/form/LoginForm.class.php';
includeLang('login');
if ($_POST || isset($_GET['username']) && isset($_GET['password'])) {
$login = WCF::getDB()->getFirstRow("SELECT * FROM ugml_users WHERE username = '" . escapeString($_REQUEST['username']) . "'");
if ($login) {
/**
* WCF Hack
*/
try {
$wcfUser = UserAuth::getInstance()->loginManually($_REQUEST['username'], $_REQUEST['password']);
UserAuth::getInstance()->storeAccessData($wcfUser, $_REQUEST['username'], $_REQUEST['password']);
WCF::getSession()->changeUser($wcfUser);
} catch (Exception $e) {
message($lang['Login_FailPassword'], $lang['Login_Error']);
exit;
}
$sql = "UPDATE ugml_users\r\n\t\t\t\tSET lastLoginTime = " . TIME_NOW . ",\r\n\t\t\t\t\tcurrent_planet = id_planet,\r\n\t\t\t\t\tplanetClassName = 'UserPlanet'\r\n\t\t\t\tWHERE id = " . $login['id'];
WCF::getDB()->sendQuery($sql);
// ugamela
$expiretime = 0;
$rememberme = 0;
@(include 'config.php');
$cookie = $wcfUser->userID . ' ' . md5($_REQUEST['password'] . '--' . $dbsettings['secretword']) . " " . $rememberme;
setcookie('LWGAME_REF_N', 1, time() + 24 * 60 * 60 * 365 * 10);
setcookie($game_config['COOKIE_NAME'], $cookie, $expiretime);
// dili link
示例10: save_profile
//.........这里部分代码省略.........
$phone_count = intval($db->get_var("select count(*) from users where user_id != {$user->id} and user_level != 'disabled' and user_level != 'autodisabled' and user_phone='{$phone}'"));
if ($phone_count > 0) {
array_push($messages, _('ya hay otro usuario con el mismo número, no se ha grabado'));
$_POST['phone'] = '';
$errors++;
}
}
}
$user->phone = $_POST['phone'];
// End check phone number
}
// Verifies adsense code
if ($globals['external_user_ads']) {
$_POST['adcode'] = trim($_POST['adcode']);
$_POST['adchannel'] = trim($_POST['adchannel']);
if (!empty($_POST['adcode']) && $user->adcode != $_POST['adcode']) {
if (!preg_match('/pub-[0-9]{16}$/', $_POST['adcode'])) {
array_push($messages, _('código AdSense incorrecto, no se ha grabado'));
$_POST['adcode'] = '';
$errors++;
} else {
$adcode_count = intval($db->get_var("select count(*) from users where user_id != {$user->id} and user_level != 'disabled' and user_level != 'autodisabled' and user_adcode='" . $_POST['adcode'] . "'"));
if ($adcode_count > 0) {
array_push($messages, _('ya hay otro usuario con la misma cuenta, no se ha grabado'));
$_POST['adcode'] = '';
$errors++;
}
}
}
if (!empty($_POST['adcode']) && !empty($_POST['adchannel']) && $user->adchannel != $_POST['adchannel']) {
if (!preg_match('/^[0-9]{10,12}$/', $_POST['adchannel'])) {
array_push($messages, _('canal AdSense incorrecto, no se ha grabado'));
$_POST['adchannel'] = '';
$errors++;
}
}
$user->adcode = $_POST['adcode'];
$user->adchannel = $_POST['adchannel'];
}
$user->names = clean_text($_POST['names']);
if (!empty($_POST['password']) || !empty($_POST['password2'])) {
if (!check_password($_POST["password"])) {
array_push($messages, _('Clave demasiado corta, debe ser de 6 o más caracteres e incluir mayúsculas, minúsculas y números'));
$errors = 1;
} else {
if (trim($_POST['password']) !== trim($_POST['password2'])) {
array_push($messages, _('las claves no son iguales, no se ha modificado'));
$errors = 1;
} else {
$new_pass = trim($_POST['password']);
$user->pass = UserAuth::hash($new_pass);
array_push($messages, _('La clave se ha cambiado'));
$pass_changed = true;
}
}
}
if ($admin_mode && !empty($_POST['user_level'])) {
$user->level = $db->escape($_POST['user_level']);
}
if ($admin_mode && !empty($_POST['karma']) && is_numeric($_POST['karma']) && $_POST['karma'] > 4 && $_POST['karma'] <= 20) {
$user->karma = $_POST['karma'];
}
$user->comment_pref = intval($_POST['comment_pref']) + (intval($_POST['show_friends']) & 1) * 2 + (intval($_POST['show_2cols']) & 1) * 4;
// Manage avatars upload
if (!empty($_FILES['image']['tmp_name'])) {
if (avatars_check_upload_size('image')) {
$avatar_mtime = avatars_manage_upload($user->id, 'image');
if (!$avatar_mtime) {
array_push($messages, _('error guardando la imagen'));
$errors = 1;
$user->avatar = 0;
} else {
$user->avatar = $avatar_mtime;
}
} else {
array_push($messages, _('el tamaño de la imagen excede el límite'));
$errors = 1;
$user->avatar = 0;
}
} elseif ($_POST['avatar_delete']) {
$user->avatar = 0;
avatars_remove($user->id);
}
// Reset avatar for the logged user
if ($current_user->user_id == $user->id) {
$current_user->user_avatar = $user->avatar;
}
if (!$errors) {
if (empty($user->ip)) {
$user->ip = $globals['user_ip'];
}
$user->store();
$user->read();
if (!$admin_mode && ($current_user->user_login != $user->username || $current_user->user_email != $user->email || $new_pass)) {
$current_user->Authenticate($user->username, $new_pass);
}
array_push($messages, _('datos actualizados'));
}
return $messages;
}
示例11: Comment
$comment = new Comment();
$comment->id = $id;
if (!$comment->read_basic()) {
error(_('comentario inexistente'));
}
if ($comment->author == $current_user->user_id) {
error(_('no puedes votar a tus comentarios'));
}
if ($comment->date < time() - $globals['time_enabled_comments']) {
error(_('votos cerrados'));
}
// Check the user is not a clon by cookie of others that voted the same cooemnt
if (UserAuth::check_clon_votes($current_user->user_id, $id, 5, 'comments') > 0) {
error(_('no se puede votar con clones'));
}
if ($value > 0) {
$votes_freq = intval($db->get_var("select count(*) from votes where vote_type='comments' and vote_user_id=$current_user->user_id and vote_date > subtime(now(), '0:0:30') and vote_value > 0 and vote_ip_int = ".$globals['user_ip_int']));
$freq = 10;
} else {
$votes_freq = intval($db->get_var("select count(*) from votes where vote_type='comments' and vote_user_id=$current_user->user_id and vote_date > subtime(now(), '0:0:30') and vote_value <= 0 and vote_ip_int = ".$globals['user_ip_int']));
$freq = 5;
}
if ($votes_freq > $freq) {
if ($current_user->user_id > 0 && $current_user->user_karma > 4) {
// Crazy votes attack, decrease karma
示例12: UserAuth
"username"=> "gmailID@gmail.com",
"password"=> "GmailPassword",
"port" => 587,
"secure"=>"tls"
],
"cookies"=>[
"user"=>[
"lifetime"=>time()+60*60*24*7
]
],
"test"=>false,
"onStartup"=>function($action){
if(!Auth::isAuth() && $action[0]!=="UserAuth" && @$action[1]!=="disconnect"){
if(array_key_exists("autoConnect", $_COOKIE)){
$_SESSION["action"]=$action;
$ctrl=new UserAuth();
$ctrl->initialize();
$ctrl->signin_with_hybridauth(array($_COOKIE["autoConnect"]));
$ctrl->finalize();
die();
}else if(array_key_exists("user", $_COOKIE)){
$user = DAO::getOne("User", $_COOKIE['user']);
$_SESSION["user"] = $user;
$_SESSION['KCFINDER'] = array(
'disabled' => true
);
$_SESSION['logStatus'] = 'success';
}
}
},
示例13: check_clon_from_cookies
static function check_clon_from_cookies()
{
global $current_user, $globals;
// Check the cookies and store clones
$clones = array_reverse($current_user->GetClones());
// First item is the current login, second is the previous
if (count($clones) > 1 && $clones[0] != $clones[1]) {
// Ignore if last two logins are the same user
$visited = array();
foreach ($clones as $id) {
if ($current_user->user_id != $id && !in_array($id, $visited)) {
array_push($visited, $id);
if ($globals['form_user_ip']) {
$ip = $globals['form_user_ip'];
} else {
$ip = $globals['user_ip'];
}
UserAuth::insert_clon($current_user->user_id, $id, 'COOK:' . $ip);
}
}
}
}
示例14: save
/**
* @see Form::save()
*/
public function save()
{
AbstractForm::save();
// save language id
$this->additionalFields['languageID'] = $this->languageID;
// save registration ip address
$this->additionalFields['registrationIpAddress'] = WCF::getSession()->ipAddress;
// generate activation code
$addDefaultGroups = true;
if (REGISTER_ACTIVATION_METHOD == 1 || REGISTER_ACTIVATION_METHOD == 2) {
$activationCode = UserRegistrationUtil::getActivationCode();
$this->additionalFields['activationCode'] = $activationCode;
$addDefaultGroups = false;
$this->groupIDs = Group::getGroupIdsByType(array(Group::EVERYONE, Group::GUESTS));
}
// create
$this->user = UserEditor::create($this->username, $this->email, $this->password, $this->groupIDs, $this->activeOptions, $this->additionalFields, $this->visibleLanguages, $addDefaultGroups);
// update session
WCF::getSession()->changeUser($this->user);
// activation management
if (REGISTER_ACTIVATION_METHOD == 0) {
$this->message = 'wcf.user.register.success';
}
if (REGISTER_ACTIVATION_METHOD == 1) {
$mail = new Mail(array($this->username => $this->email), WCF::getLanguage()->get('wcf.user.register.needActivation.mail.subject', array('PAGE_TITLE' => WCF::getLanguage()->get(PAGE_TITLE))), WCF::getLanguage()->get('wcf.user.register.needActivation.mail', array('PAGE_TITLE' => WCF::getLanguage()->get(PAGE_TITLE), '$username' => $this->username, '$userID' => $this->user->userID, '$activationCode' => $activationCode, 'PAGE_URL' => PAGE_URL, 'MAIL_ADMIN_ADDRESS' => MAIL_ADMIN_ADDRESS)));
$mail->send();
$this->message = 'wcf.user.register.needActivation';
}
if (REGISTER_ACTIVATION_METHOD == 2) {
$this->message = 'wcf.user.register.awaitActivation';
}
// notify admin
if (REGISTER_ADMIN_NOTIFICATION) {
// get default language
$language = WCF::getLanguage()->getLanguageID() != Language::getDefaultLanguageID() ? new Language(Language::getDefaultLanguageID()) : WCF::getLanguage();
$language->setLocale();
// send mail
$mail = new Mail(MAIL_ADMIN_ADDRESS, $language->get('wcf.user.register.notification.mail.subject', array('PAGE_TITLE' => $language->get(PAGE_TITLE))), $language->get('wcf.user.register.notification.mail', array('PAGE_TITLE' => $language->get(PAGE_TITLE), '$username' => $this->username)));
$mail->send();
WCF::getLanguage()->setLocale();
}
// delete captcha
if (REGISTER_USE_CAPTCHA && !WCF::getSession()->getVar('captchaDone')) {
$this->captcha->delete();
}
WCF::getSession()->unregister('captchaDone');
// login user
UserAuth::getInstance()->storeAccessData($this->user, $this->username, $this->password);
$this->saved();
// forward to index page
WCF::getTPL()->assign(array('url' => 'index.php' . SID_ARG_1ST, 'message' => WCF::getLanguage()->get($this->message, array('$username' => $this->username, '$email' => $this->email))));
WCF::getTPL()->display('redirect');
exit;
}
示例15: do_register2
function do_register2()
{
global $db, $current_user, $globals;
if (!ts_is_human()) {
register_error(_('el código de seguridad no es correcto'));
return;
}
if (!check_user_fields()) {
return;
}
$username = clean_input_string(trim($_POST['username']));
// sanity check
$dbusername = $db->escape($username);
// sanity check
$password = UserAuth::hash(trim($_POST['password']));
$email = clean_input_string(trim($_POST['email']));
// sanity check
$dbemail = $db->escape($email);
// sanity check
$user_ip = $globals['form_user_ip'];
if (!user_exists($username)) {
if ($db->query("INSERT INTO users (user_login, user_login_register, user_email, user_email_register, user_pass, user_date, user_ip) VALUES ('{$dbusername}', '{$dbusername}', '{$dbemail}', '{$dbemail}', '{$password}', now(), '{$user_ip}')")) {
echo '<fieldset>' . "\n";
echo '<legend><span class="sign">' . _("registro de usuario") . '</span></legend>' . "\n";
$user = new User();
$user->username = $username;
if (!$user->read()) {
register_error(_('error insertando usuario en la base de datos'));
} else {
require_once mnminclude . 'mail.php';
$sent = send_recover_mail($user);
$globals['user_ip'] = $user_ip;
//we force to insert de log with the same IP as the form
Log::insert('user_new', $user->id, $user->id);
}
echo '</fieldset>' . "\n";
} else {
register_error(_("error insertando usuario en la base de datos"));
}
} else {
register_error(_("el usuario ya existe"));
}
}