當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserFactory::CreateFromCredentials方法代碼示例

本文整理匯總了PHP中UserFactory::CreateFromCredentials方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserFactory::CreateFromCredentials方法的具體用法?PHP UserFactory::CreateFromCredentials怎麽用?PHP UserFactory::CreateFromCredentials使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserFactory的用法示例。


在下文中一共展示了UserFactory::CreateFromCredentials方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: db_escape

 if (isset($_POST['question']) && $_POST['question'] == "10") {
     $email = db_escape(purify(trim(Charset::Utf8ToDB($_POST['email']))));
     $creds = LoginUtils::HashToCredentials(db_escape($_POST['hash']));
     $username = db_escape(purify(trim(Charset::Utf8ToDB($creds['username']))));
     $password = db_escape(purify(trim(Charset::Utf8ToDB($creds['password']))));
     // Username libero?
     if (!DB::FindOne("SELECT 1 FROM users WHERE user = \"{$username}\"")) {
         // Legacy: Un timestamp sarebbe stato meglio, ma non dobbiamo fare nulla con questo dato, quindi va bene cosi'
         $data = date("d/m/Y G:i");
         $description = "Normal User";
         $md5 = LoginUtils::Md5FromCredentials($username, $password);
         // Tutto a posto
         exequery(sprintf('INSERT INTO users (user, mail, ip, os_browser, date, description, permission, verified, md5, last_login_timestamp, last_login_ip, newsletter)
               VALUES ("%s", "%s", "%s", "%s", "%s", "%s", %s, %s, "%s", %s, "%s", %s)', $username, $email, get_ip(), db_escape(purify($_SERVER["HTTP_USER_AGENT"])), $data, $description, User::PERMISSION_USER, 1, $md5, time(), get_ip(), 1));
         // Logga l'utente
         $currentUser = UserFactory::CreateFromCredentials($username, $password);
         if ($currentUser->isLogged()) {
             $response->setSuccess(true);
             // Logga
             Log::Info(sprintf("%s si e' registrato", $currentUser['username']));
             $_SESSION['login_hash'] = $currentUser['md5'];
             setcookie('login_hash', $currentUser['md5'], time() + 60 * 60 * 24 * 7, '/');
         } else {
             // Questo non dovrebbe succedere
             $response->setError("E' successo un imprevisto durante la registrazione. Per favore segnala questo incidente ad un amministratore.");
         }
     } else {
         $response->setError("L'username e' stato gia' preso. Scegline un'altro.");
     }
 } else {
     $response->setError("Captcha non valido.");
開發者ID:pierotofy,項目名稱:pierotofy.it,代碼行數:31,代碼來源:register.php

示例2: CreateFromLoginHash

 public static function CreateFromLoginHash($hash)
 {
     $creds = LoginUtils::HashToCredentials($hash);
     //et voila! user e pass pronti all'uso
     return UserFactory::CreateFromCredentials($creds['username'], $creds['password']);
 }
開發者ID:pierotofy,項目名稱:pierotofy.it,代碼行數:6,代碼來源:UserFactory.php


注:本文中的UserFactory::CreateFromCredentials方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。