本文整理汇总了PHP中getUserByEmail函数的典型用法代码示例。如果您正苦于以下问题:PHP getUserByEmail函数的具体用法?PHP getUserByEmail怎么用?PHP getUserByEmail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getUserByEmail函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkUserForm
/**
* Проверка формы регистрации пользователя
* @param array $post
* @return bool|string
*/
function checkUserForm(array $post)
{
if (mb_strlen($post['fio']) < 10) {
return "ФИО доджно быть не менее 10 символов.";
}
if (mb_strlen($post['phone']) < 11) {
return "Номер телефона должне быть не менее 11 цифр";
}
if (mb_strlen($post['login']) < 10) {
return "Логин должен быть не менее 10 символов";
}
if (mb_strlen($post['password']) < 10) {
return "Пароль должен быть не менее 10 символов";
}
if ($post['password'] != $post['confirm_password']) {
return "Пароли не совпадают";
}
$pattern = '/^(?!(?:(?:\\x22?\\x5C[\\x00-\\x7E]\\x22?)|(?:\\x22?[^\\x5C\\x22]\\x22?)){255,})(?!(?:(?:\\x22?\\x5C[\\x00-\\x7E]\\x22?)|(?:\\x22?[^\\x5C\\x22]\\x22?)){65,}@)(?:(?:[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2F-\\x39\\x3D\\x3F\\x5E-\\x7E]+)|(?:\\x22(?:[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x21\\x23-\\x5B\\x5D-\\x7F]|(?:\\x5C[\\x00-\\x7F]))*\\x22))(?:\\.(?:(?:[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2F-\\x39\\x3D\\x3F\\x5E-\\x7E]+)|(?:\\x22(?:[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x21\\x23-\\x5B\\x5D-\\x7F]|(?:\\x5C[\\x00-\\x7F]))*\\x22)))*@(?:(?:(?!.*[^.]{64,})(?:(?:(?:xn--)?[a-z0-9]+(?:-+[a-z0-9]+)*\\.){1,126}){1,}(?:(?:[a-z][a-z0-9]*)|(?:(?:xn--)[a-z0-9]+))(?:-+[a-z0-9]+)*)|(?:\\[(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})|(?:(?!(?:.*[a-f0-9][:\\]]){7,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?)))|(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){5}:)|(?:(?!(?:.*[a-f0-9]:){5,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3}:)?)))?(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))(?:\\.(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))){3}))\\]))$/iD';
if (preg_match($pattern, $post['email']) !== 1) {
return "Не правильный адрес почты";
}
//Если есть пользователь с такой почтой
if (!is_null(getUserByEmail($post['email']))) {
return "Указанная почта \"{$post['email']}\" уже используется другим человеком.";
}
//Если есть пользователь с таким логином
if (!is_null(getUserByLogin($post['login']))) {
return "Указанный login \"{$post['login']}\" уже используется другим человеком.";
}
//проверить остальные поля.
//если все поля заполнены корректно, функция вернет true
return true;
}
示例2: checkUserPwd
function checkUserPwd($user, $pwd)
{
global $key_pwd;
if (!($u = getUserByName($user))) {
$u = getUserByEmail($user);
}
if (dc_decrypt($u->password, $key_pwd) == $pwd) {
return $u;
} else {
return false;
}
}
示例3: getLoginInfo
function getLoginInfo($email, $password)
{
$user = getUserByEmail($email);
if ($user == null || $password != $user->password) {
return invalidLogin();
}
$eventIds = $user->sharedEvent;
$events = array();
foreach ($eventIds as $key => $value) {
$events[] = R::exportAll($value);
$dates[$key] = $value['startdate'];
}
if (count($events) > 0) {
array_multisort($dates, SORT_ASC, $events);
}
return array(ID => $user->id, USER_FNAME => $user->firstname, USER_LNAME => $user->lastname, USER_EMAIL => $user->email, USER_USEF_ID => $user->usefid, USER_EVENTS => getUserEvents($user->id, $eventIds));
//count($events) > 0 ? $events : null);
}
示例4: createAccount
function createAccount($name, $username, $email, $password)
{
if (strlen($name) > 100) {
throw new InvalidArgumentException("Name too large, maximum 100 chars.");
}
if (!preg_match("/^\\p{Lu}[\\p{L&}\\.' ]*\$/u", $name)) {
throw new InvalidArgumentException("Invalid name.");
}
$username = strtolower($username);
if (!preg_match("/^([A-z0-9]|_|-|\\.){3,30}\$/", $username)) {
throw new InvalidArgumentException("Invalid username. It must contain only alfanumeric characters and have length between 3 and 30.");
}
if (getUserByUsername($username)) {
throw new InvalidArgumentException("Username already registered. Choose a different one.");
}
if (strlen($email) > 254) {
// 254 is the maximum email address size
throw new InvalidArgumentException("Email too large, maximum 254 chars.");
}
$email = strtolower($email);
if (!preg_match("/^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,}\$/", $email)) {
throw new InvalidArgumentException("Invalid email address.");
}
if (getUserByEmail($email)) {
throw new InvalidArgumentException("Email address already registered. Choose a different one.");
}
$password_length = strlen($password);
if ($password_length < 6) {
throw new InvalidArgumentException("Password too short, minimum 6 chars.");
}
if ($password_length > 512) {
throw new InvalidArgumentException("Password too large, maximum 512 chars.");
}
$hash = password_hash($password, PASSWORD_DEFAULT);
if (!createUser($name, $username, $email, $hash)) {
throw new RuntimeException("Error inserting new user in the database.");
}
}
示例5: getUserHomeByUserType
/**
* This function loads user home templates for diffferent types of users: e.g admin/ normal user
*/
function getUserHomeByUserType($userType, $email, $al)
{
if ($userType === "") {
Errors::report("User type of user is missing.");
return false;
}
$data = getUserByEmail($email, $al->db);
if ($data === false) {
return false;
}
if (is_string($data)) {
return $data;
}
$name = $data['firstname'] . " " . $data['lastname'];
switch ($userType) {
case '0':
$title = "Welcome, {$name}";
$subtitle = "You are a normal user.";
$menuTpl = 'home_user.tpl';
$mainTpl = 'main.tpl';
break;
case '1':
$title = "Welcome, {$name}";
$subtitle = "You are an Administrator.";
$mainTpl = 'admin.tpl';
$menuTpl = 'admin_menu.tpl';
$menuBlockTpl = 'admin_menublock.tpl';
$isadmin = true;
break;
default:
Errors::report("User type of user is invalid.");
return false;
}
$al->tp->assign('title', $title);
$al->tp->assign('subtitle', $subtitle);
if ($isadmin) {
if (!$al->tp->template_exists($menuTpl)) {
Errors::report("The template file, {$menuTpl} is missing");
return false;
}
if (!$al->tp->template_exists($menuBlockTpl)) {
Errors::report("The template file, {$menuBlockTpl} is missing");
return false;
}
$body = $al->tp->fetch($menuTpl);
$body .= $al->tp->fetch($menuBlockTpl);
} else {
if (!$al->tp->template_exists($menuTpl)) {
Errors::report("The template file, {$menuTpl} is missing");
return false;
}
$body .= $al->tp->fetch($menuTpl);
}
$al->tp->assign('body', $body);
if (!$al->tp->template_exists($mainTpl)) {
Errors::report("The file, {$mainTpl} is missing");
return false;
}
$al->tp->display($mainTpl);
return true;
}
示例6: recover
function recover($email)
{
global $db;
global $mailer;
$password = generateRandomString(8);
$res = pg_query($db, "UPDATE users SET password = '" . pg_escape_string(md5($password)) . "' WHERE email = '" . pg_escape_string($email) . "'") or die("Database Error");
if (pg_affected_rows($res) == 1) {
$user = getUserByEmail($email);
if ($user) {
$bodyMessage = "You've requested for the new Password, Your new Password is : <br/><b>{$password} </b> <br/><br/> Please click the below button to login.";
$body = file_get_contents(MAIL_TEMPLATE_DIRECTORY . "recoverPasswordEmail.tpl");
$body = str_replace(array("[#BASEURL#]", "[#FIRSTNAME#]", "[#BODY#]", "[#COPYRIGHT_TEXT#]"), array(BASEURL, $user['firstname'], $bodyMessage, COPYRIGHT_TEXT), $body);
if ($mailer->send(MAIL_FROM, MAIL_FROM_NAME, $user['email'], SITE_NAME_FORMATED . " Studio - Change Your Password", $body)) {
return true;
}
}
return true;
}
return false;
}
示例7: StandardRequest
<?php
require_once __DIR__ . '/../../../carbon/core.ini.php';
require_once __DIR__ . '/../../../carbon/requests/requests.inc.php';
require_once __DIR__ . '/../../../carbon/responses/responses.inc.php';
require_once __DIR__ . '/../../../carbon/formats/formats.inc.php';
require_once __DIR__ . '/../../../src/account/account.php';
try {
$db = $config->getDefaultDatabase()->open();
$user = ['email' => Request::REQUIRED];
$request = new StandardRequest();
$user = $request->extract($user);
$user = arrayToJSONObject($user);
$response = getUserByEmail($db, $user->email);
} catch (Exception $ex) {
$response = new ExceptionResponse($ex);
}
$response = new JSONPrettyFormat($response);
$response->present();
示例8: stdClass
global $app;
$result = new stdClass();
$result->status = false;
$user = getUserByName($username);
if ($user) {
unset($user["password"]);
$result->status = true;
$result->data = $user;
}
echo json_encode($result);
});
$app->get("/email/:email", function ($email) {
global $app;
$result = new stdClass();
$result->status = false;
$user = getUserByEmail($email);
if ($user) {
unset($user["password"]);
$result->status = true;
$result->data = $user;
}
echo json_encode($result);
});
$app->post("/changeavatar", function () {
global $app;
$result = new stdClass();
$result->status = false;
$user = getUserByKey($_POST["key"]);
if ($user) {
$ext = explode('.', $_FILES['file']['name']);
$ext = $ext[count($ext) - 1];
示例9: getUserByUsername
$user_pseudo = getUserByUsername($pseudo);
if ($user_pseudo != NULL) {
$_SESSION['error_msg'] = "This username already exists.";
$_SESSION['wrong_pseudo'] = true;
header('location: /app/admin/login/?action=signup');
exit;
}
// Check if the email is valid.
if (!$email) {
$_SESSION['error_msg'] = "This email is invalid. Please type a valid email.";
$_SESSION['wrong_email'] = true;
header('location: /app/admin/login/?action=signup');
exit;
}
// Check if the email exists in the database.
$user_email = getUserByEmail($email);
if ($user_email != NULL) {
$_SESSION['error_msg'] = "This email already exists.";
$_SESSION['wrong_email'] = true;
header('location: /app/admin/login/?action=signup');
exit;
}
// Check if the password meets the requirements.
if (!$password) {
$_SESSION['error_msg'] = "Your password must contain at least 8 characters and be composed of at least 1 number, 1 uppercase letter and 1 lowercase letter.";
$_SESSION['wrong_password'] = true;
header('location: /app/admin/login/?action=signup');
exit;
}
// Check if password and verifiy match.
$hashed_password = hash_password($password);
示例10: process_registration
function process_registration()
{
// used for testing
//sleep(1);
$username = strtolower(trim($_POST['username']));
$email = trim($_POST['email']);
$password = trim($_POST['password']);
include _DOCROOT . '/inc/sql-core.php';
include _DOCROOT . '/html/pre-header.php';
include _DOCROOT . '/inc/functions.class.php';
include _DOCROOT . '/modules/site/site-data.php';
$fn = new Functions();
$err = false;
// 1. check value fields.
$email_check = $fn->checkEmail($email);
if ($email_check === false) {
$err = true;
$htmls['#email_err'] = 'Invalid format. Use something similar to username@domain.com';
}
$un_check = $fn->checkUsername($username);
if ($un_check != "") {
$err = true;
$htmls['#username_err'] = $un_check;
}
$pw_check = $fn->checkUsername($password);
if ($pw_check != "") {
$err = true;
$htmls['#password_err'] = $pw_check;
}
$existingUser = getUserByUsername($username);
if (count($existingUser) > 0) {
$err = true;
$htmls['#username_err'] = "Username already exists. Try a different name.";
}
$existingUser = getUserByEmail($email);
if (count($existingUser) > 0) {
$err = true;
$htmls['#email_err'] = "This email is already registered. Try a different one.";
}
if ($err) {
echo json_encode(array('htmls' => $htmls));
} else {
// 2. create user folder.
$fn->makeUserFolder(strtolower($username));
// 3. create salt / tokens.
$salt = md5($username . time());
$token = md5($email . $salt);
// 4. insert into database.
$sql_u = "INSERT INTO signup (\n email,\n username,\n `password`,\n token,\n salt,\n fname,\n lname,\n bday,\n created,\n lastloggedin\n ) VALUES (\n ?,?,?,?,?,?,?,?,?,?\n )";
sqlRun($sql_u, 'ssssssssii', array($email, $username, md5($password), $token, $salt, "", "", "", time(), time()));
// 5. send out email.
$to = $email;
$subject = "Your Website Registration";
$message = "Click this link to validate your email. Or, copy / paste this code";
$headers = 'From: webmaster@mypersonalwebsite.com' . "\r\n" . 'Reply-To: webmaster@mypersonalwebsite.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
//mail($to, $subject, $message, $headers);
// 6. Set session variables.
$_SESSION['site_user_username'] = $username;
$_SESSION['site_user_salt'] = $salt;
$_SESSION['site_user_token'] = $token;
// 7. display success message (check email or check email and enter verification code).
echo json_encode(array('closevbox' => true, 'redirect' => $username));
/*
echo json_encode(array(
'closevbox' => true,
'redirect' => strtolower(trim($_POST['username']))
));
*/
}
}
示例11: setcookie
if (checkUser($_POST['email'], $_POST['password'])) {
/* Cookie expires when browser closes */
$_COOKIE['email'] = $_POST['email'];
setcookie('email', $_POST['email'], false, '/');
setcookie('password', $_POST['password'], false, '/');
} else {
header('Location: login.php?e=Login%20Failed');
}
} else {
if (isset($_COOKIE['email']) && isset($_COOKIE['password']) && $_COOKIE['email'] != NULL) {
// proceed as normal
} else {
header('Location: login.php?e=Please%20Login!');
}
}
$user = getUserByEmail($_COOKIE['email']);
if (isset($_POST['create_team'])) {
$name = cleanInput($_POST['team_name']);
if (isTeamUsed($name)) {
$e = "Team name is already used!";
} else {
$teamId = createTeam($name, $user['id']);
$s = "Team " . $name . " was successfully created! Access code: " . $teamId * 7;
joinTeam($user['id'], $teamId);
$user['team_id'] = $teamId;
}
} else {
if (isset($_POST['join_team'])) {
$teamId = cleanInput($_POST['team_id']) / 7;
if (!isTeamValid($teamId)) {
$e = "Access code is not valid";
示例12: mysql_real_escape_string
if ($_POST['location'] == 'other') {
$location = mysql_real_escape_string($_POST['otherlocation']);
} else {
$location = mysql_real_escape_string($_POST['location']);
}
$password = mysql_real_escape_string(md5($_POST['password']));
$user_name = mysql_real_escape_string($_POST['user_name']);
$android_app = 'web_user';
$month_name = mysql_real_escape_string($_POST['month_name']);
$day_name = mysql_real_escape_string($_POST['day_name']);
$year_name = mysql_real_escape_string($_POST['year_name']);
$birth_date = $year_name . "-" . $month_name . "-" . $day_name;
$birth_date = date("Y-m-d", strtotime($birth_date));
$verificationcode = generateCode(1);
$activation = md5($email . time());
$user_register = getUserByEmail($email);
$user = mysql_fetch_array($user_register);
registerNewUser($name, $email, $user_name, $password, $gender, $birth_date, $location, $phone_number, $activation, $verificationcode, $android_app);
$last_users = getLastRegisterUser();
$last_user = mysql_fetch_array($last_users);
$registration_points = 5;
createUserGameCoins($last_user['id'], $registration_points);
$base_url = "http://www.maverickgame.com/activation.php?code=" . $activation;
$subject = "Registration successful, please activate email at Maverick Game";
$from = "info@maverickgame.com";
$email_server = "info@maverickgame.com";
$to = $email;
$mail_body = "Dear {$name},<br/><br/>You have embarked on a journey where your role will change along with the game you choose to play. From here onwards this portal is your abode and you are destined to achieve greatness. Greatness bigger than what you had fathomed this is your true calling. <br/> <br/> You are new here but remember you are the chosen one. Competition will be ruthless and the going will get difficult. You may win some and you may lose some. Your ranking is down low and reaching top will be difficult. It may take time for you to master the game but remember that greatness is achieved by perseverance and not just through talent.<br/><br/>So proceed to your first game and make your way to the top of leaderboard. Riches and glory await you, Chosen One.<br/><br/><a href=" . $base_url . ">.{$base_url}.'</a>' <br/><br/>Your game score gives you reward points, through which you can redeem real life products ranging from Mobile scratch card to a Mercedes Benz. Better you play more rewards you get !<br/></br>Regards,<br/><br/>Team Maverick Game<br><br>For any queries please write to us : info@maverickgame.com";
$body = wordwrap($mail_body, 2000);
//$body_user = wordwrap($mail_body_user,70);
$headers = "MIME-Version: 1.0" . "\r\n";
示例13: abs
if (empty($post['houseNum']) || preg_match('/^[0-9]+[\\/а-яА-ЯЁ]/', $post['HouseNum'])) {
$errorHouseNum = "Вы не указали дом";
}
if (mb_strlen($post['login']) < 4 || preg_match('/[^0-9a-zA-Z]/', $post['login'])) {
$errorLogin = "Логин может содержать только цифры и латинские буквы.";
}
if (mb_strlen($post['password']) < 10) {
$errorPassword = "Неверно введен пароль";
}
$pattern = '/^(?!(?:(?:\\x22?\\x5C[\\x00-\\x7E]\\x22?)|(?:\\x22?[^\\x5C\\x22]\\x22?)){255,})(?!(?:(?:\\x22?\\x5C[\\x00-\\x7E]\\x22?)|(?:\\x22?[^\\x5C\\x22]\\x22?)){65,}@)(?:(?:[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2F-\\x39\\x3D\\x3F\\x5E-\\x7E]+)|(?:\\x22(?:[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x21\\x23-\\x5B\\x5D-\\x7F]|(?:\\x5C[\\x00-\\x7F]))*\\x22))(?:\\.(?:(?:[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2F-\\x39\\x3D\\x3F\\x5E-\\x7E]+)|(?:\\x22(?:[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x21\\x23-\\x5B\\x5D-\\x7F]|(?:\\x5C[\\x00-\\x7F]))*\\x22)))*@(?:(?:(?!.*[^.]{64,})(?:(?:(?:xn--)?[a-z0-9]+(?:-+[a-z0-9]+)*\\.){1,126}){1,}(?:(?:[a-z][a-z0-9]*)|(?:(?:xn--)[a-z0-9]+))(?:-+[a-z0-9]+)*)|(?:\\[(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})|(?:(?!(?:.*[a-f0-9][:\\]]){7,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?)))|(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){5}:)|(?:(?!(?:.*[a-f0-9]:){5,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3}:)?)))?(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))(?:\\.(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))){3}))\\]))$/iD';
if (preg_match($pattern, $post['email']) !== 1) {
$errorEmail = "Не правильный адрес почты";
}
if ($currentUser['email'] != $post['email']) {
//Если (текущий логин отличается от того что ввели)
if (!is_null(getUserByEmail($post['email']))) {
//смотрим в базе есть ли такой, Если есть то ошибка
$errorEmail = "Указанная почта \"{$post['email']}\" уже используется другим человеком.";
}
}
if ($currentUser['login'] != $post['login']) {
//Если (текущий логин отличается от того что ввели)
if (!is_null(getUserByLogin($post['login']))) {
//смотрим в базе есть ли такой, Если есть то ошибка
$errorLogin = "Указанный login \"{$post['login']}\" уже используется другим человеком.";
}
}
$post['kv'] = abs((int) $post['kv']);
if ($post['kv'] == 0) {
$errorKv = "кв. должна быть > 0";
}
示例14: getUserByEmail
<section class="second">
<div class="container">
</div>
</div>
</section>
<section class="second">
<div class="container">
<div class="row">
<?php
$email = $_SESSION['email'];
$loginuser = getUserByEmail($email);
if ($loginuser > 0) {
$user = mysql_fetch_array($loginuser);
$birth_date = $user['birth_date'];
$birth_date = explode("-", $birth_date);
$birth_day = $birth_date[2];
$birth_month = $birth_date[1];
$birth_year = $birth_date[0];
}
?>
<div class="col-md-12 bgwhite" style="margin-top:50px;">
<h1 class="MOTHERINGMOM">MY PROFILE</h1>
<div class="col-md-4">
<br/>
示例15: isset
<?php
require_once 'query/message.php';
$msg = $_POST;
if (isset($msg['user'])) {
$user = $msg['user'];
}
if (isset($msg['password'])) {
$pwd = $msg['password'];
}
$rem = isset($msg['remember']);
if (getUserByName($user) || getUserByEmail($user)) {
if ($r = checkUserPwd($user, $pwd)) {
if ($rem) {
$time = time() + 3600 * 24 * 365;
} else {
$time = 0;
}
setcookie("DOJSS", DOJSS($r->id, $r->password), $time);
header("Location:/");
} else {
$error = $err['wrongPwd'];
}
} else {
$error = $err['noUser'];
}
require_once 'template/login.php';