本文整理汇总了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.");
示例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']);
}