本文整理汇总了PHP中usernameExists函数的典型用法代码示例。如果您正苦于以下问题:PHP usernameExists函数的具体用法?PHP usernameExists怎么用?PHP usernameExists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了usernameExists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clearUser
function clearUser()
{
if (isset($_POST['user']) && $_POST['user'] !== null && $_POST['user'] !== '') {
$username = $_POST['user'];
// lookup userid from db
//echo "received Username: " . $username;
if (isset($_POST['pass']) && $_POST['pass'] !== "") {
// if user/password exists, check it, otherwise add new user
if (usernameExists($username)) {
$userId = getUserId($username);
$pass = getPass($userId);
// get pass from db
if ($_POST['pass'] === $pass) {
return "user cleared.";
} else {
return "invalid combination.";
}
} else {
if (addUser($username, $_POST['pass'])) {
return "user cleared.";
} else {
return "error creating new user.";
}
}
} else {
return "password cannot be empty.";
}
} else {
return "username cannot be empty.";
}
}
示例2: __construct
function __construct($user, $display, $pass, $email, $colist, $contact)
{
//Used for display only
$this->displayname = $display;
//Sanitize
$this->clean_email = sanitize($email);
$this->clean_password = trim($pass);
$this->username = sanitize($user);
$this->colist_agent = $colist;
$this->contact_person = $contact;
if (usernameExists($this->username)) {
$this->username_taken = true;
} else {
if (displayNameExists($this->displayname)) {
$this->displayname_taken = true;
} else {
if (emailExists($this->clean_email)) {
$this->email_taken = true;
} else {
//No problems have been found.
$this->status = true;
}
}
}
}
示例3: login
function login($username, $password, $ref)
{
//A function that attempts to login the user (set the session variables), and if it fails, it'll
//throw errors as an echo;
global $root;
$responseArray = array("ref" => $ref, "userErrorMsg" => "", "loginStatus" => false);
$userData = fetchJSON($root . "/users.json");
if (usernameExists($username)) {
for ($i = 0; $i < count($userData); $i++) {
if ($userData[$i]->username === $username && $userData[$i]->password === $password) {
$_SESSION["loggedIn"] = true;
$_SESSION["username"] = $username;
$_SESSION["userID"] = $userData[$i]->id;
$responseArray["loginStatus"] = true;
break;
}
if ($i === count($userData) - 1) {
$responseArray["userErrorMsg"] = "Incorrect password!";
$responseArray["loginStatus"] = false;
break;
}
}
} else {
$responseArray["userErrorMsg"] = "That username doesn't exist!";
$responseArray["loginStatus"] = false;
}
return $responseArray;
}
示例4: __construct
function __construct($user, $display, $pass, $email, $pin, $location, $about)
{
//Used for display only
$this->displayname = $display;
//Sanitize
$this->clean_email = sanitize($email);
$this->clean_password = trim($pass);
$this->username = sanitize($user);
$this->clean_pin = trim($pin);
$this->location = trim($location);
$this->about = trim($about);
if (usernameExists($this->username)) {
$this->username_taken = true;
} else {
if (displayNameExists($this->displayname)) {
$this->displayname_taken = true;
} else {
if (emailExists($this->clean_email)) {
$this->email_taken = true;
} else {
//No problems have been found.
$this->status = true;
}
}
}
}
示例5: __construct
function __construct($user, $display, $pass, $email, $country, $state, $city, $address, $zip, $phone)
{
//Used for display only
$this->displayname = $display;
//Sanitize
$this->clean_email = sanitize($email);
$this->clean_password = trim($pass);
$this->username = sanitize($user);
$this->user_country = sanitize($country);
$this->user_state = sanitize($state);
$this->user_city = sanitize($city);
$this->user_address = sanitize($address);
$this->user_zip = sanitize($zip);
$this->user_phone = sanitize($phone);
if (usernameExists($this->username)) {
$this->username_taken = true;
} else {
if (displayNameExists($this->displayname)) {
$this->displayname_taken = true;
} else {
if (emailExists($this->clean_email)) {
$this->email_taken = true;
} else {
//No problems have been found.
$this->status = true;
}
}
}
}
示例6: validate_username
public function validate_username($value)
{
if (minMaxRange(4, 16, $value)) {
$this->set_specific_error('username', lang("ACCOUNT_USER_CHAR_LIMIT", array(4, 16)));
} else {
if (usernameExists($value)) {
$this->set_specific_error('username', lang("ACCOUNT_USERNAME_IN_USE", array($value)));
}
}
}
示例7: validateUserName
function validateUserName($username, $conn)
{
$erroList = [];
if (usernameExists($username, $conn)) {
array_push($erroList, "Username already exists");
}
if (strlen($username) == 0) {
array_push($erroList, "Please supply username");
}
return $erroList;
}
示例8: __construct
function __construct($user, $pass, $email, $group_id = 2)
{
//Used for display only
$this->unclean_username = $user;
//Sanitize
$this->clean_email = sanitize($email);
$this->clean_password = trim($pass);
$this->group_id = trim($group_id);
$this->clean_username = sanitize($user);
if (usernameExists($this->clean_username)) {
$this->username_taken = true;
} elseif (emailExists($this->clean_email)) {
$this->email_taken = true;
} else {
//No problems have been found.
$this->status = true;
}
}
示例9: CorrectUserInputs
function CorrectUserInputs($userDetails)
{
$nameRegex = '/^[a-z]+[a-z ]*$/i';
$usernameRegex = '/^[A-Z0-9_]+$/i';
$passwordRegex = '/^[^ ]*$/';
if (usernameExists($userDetails['username'])) {
return false;
}
if (!preg_match($nameRegex, $userDetails['firstname']) || !preg_match($nameRegex, $userDetails['lastname']) || !preg_match($usernameRegex, $userDetails['username']) || !preg_match($passwordRegex, $userDetails['password'])) {
return false;
}
if (!($userDetails['gender'] == 'Female' && in_array($userDetails['salutation'], ['Miss', 'Ms', 'Mrs', 'Madame', 'Majesty', 'Seniora'])) && !($userDetails['gender'] == 'Male' && in_array($userDetails['salutation'], ['Mr', 'Sir', 'Senior', 'Count']))) {
return false;
}
if (strtotime($userDetails['birthdate']) > strtotime('-18 years')) {
return false;
}
return true;
}
示例10: shoutboxBanUser
/**
* Ban user
* @param $input
*/
function shoutboxBanUser($input)
{
global $lang, $db, $mybb, $cache;
$lang->load('dvz_reports');
//Validate XSRF token
if (verify_post_check($input['my_post_key'])) {
//Validate if weve got a username
if (!$input['username']) {
redirect('modcp.php?action=shoutbox_ban', $lang->invalid_username);
}
//Validate existance
if (!($uid = (int) usernameExists($input['username']))) {
redirect('modcp.php?action=shoutbox_ban', $lang->invalid_username);
}
//User already banned
if (isBanned($uid)) {
redirect('modcp.php?action=shoutbox_ban', $lang->already_banned);
}
if ($input['reason'] == 'different') {
if (!$input['reason_input']) {
redirect('modcp.php?action=shoutbox_ban', $lang->no_reason);
} else {
$reason = $input['reason_input'];
}
} else {
$reason = $input['reason'];
}
$data = array('uid' => $db->escape_string($uid), 'reason' => $db->escape_string($reason), 'unbantime' => getUnban($input['length']), 'banned_by' => $db->escape_string($mybb->user['uid']));
//Insert new ban
$db->insert_query('dvz_reports_banned', $data);
//Log action
$logdata = array('uid' => $uid, 'username' => $mybb->input['username']);
log_moderator_action($logdata, $lang->banned_user);
//Redirect
redirect('modcp.php?action=shoutbox_ban', $lang->ban_succesfull);
}
}
示例11: sanitize
if (!empty($_POST)) {
$email = $_POST["email"];
$username = sanitize($_POST["username"]);
//Perform some validation
//Feel free to edit / change as required
if (trim($email) == "") {
$errors[] = lang("ACCOUNT_SPECIFY_EMAIL");
} else {
if (!isValidEmail($email) || !emailExists($email)) {
$errors[] = lang("ACCOUNT_INVALID_EMAIL");
}
}
if (trim($username) == "") {
$errors[] = lang("ACCOUNT_SPECIFY_USERNAME");
} else {
if (!usernameExists($username)) {
$errors[] = lang("ACCOUNT_INVALID_USERNAME");
}
}
if (count($errors) == 0) {
//Check that the username / email are associated to the same account
if (!emailUsernameLinked($email, $username)) {
$errors[] = lang("ACCOUNT_USER_OR_EMAIL_INVALID");
} else {
//Check if the user has any outstanding lost password requests
$userdetails = fetchUserDetails($username);
if ($userdetails["lost_password_request"] == 1) {
$errors[] = lang("FORGOTPASS_REQUEST_EXISTS");
} else {
//Email the user asking to confirm this change password request
//We can use the template builder here
示例12: index
public function index()
{
/*
UserCake (Via CupCake) Version: 2.0.2
http://usercake.com
*/
global $baseURL;
$baseURL = getcwd();
require_once "{$baseURL}/application/third_party/user_cake/models/config.php";
if (!securePage($_SERVER['PHP_SELF'])) {
die;
}
//Forms posted
if (!empty($_POST) && $emailActivation) {
$email = $_POST["email"];
$username = $_POST["username"];
//Perform some validation
//Feel free to edit / change as required
if (trim($email) == "") {
$errors[] = lang("ACCOUNT_SPECIFY_EMAIL");
} else {
if (!isValidEmail($email) || !emailExists($email)) {
$errors[] = lang("ACCOUNT_INVALID_EMAIL");
}
}
if (trim($username) == "") {
$errors[] = lang("ACCOUNT_SPECIFY_USERNAME");
} else {
if (!usernameExists($username)) {
$errors[] = lang("ACCOUNT_INVALID_USERNAME");
}
}
if (count($errors) == 0) {
//Check that the username / email are associated to the same account
if (!emailUsernameLinked($email, $username)) {
$errors[] = lang("ACCOUNT_USER_OR_EMAIL_INVALID");
} else {
$userdetails = fetchUserDetails($username);
//See if the user's account is activation
if ($userdetails["active"] == 1) {
$errors[] = lang("ACCOUNT_ALREADY_ACTIVE");
} else {
if ($resend_activation_threshold == 0) {
$hours_diff = 0;
} else {
$last_request = $userdetails["last_activation_request"];
$hours_diff = round((time() - $last_request) / (3600 * $resend_activation_threshold), 0);
}
if ($resend_activation_threshold != 0 && $hours_diff <= $resend_activation_threshold) {
$errors[] = lang("ACCOUNT_LINK_ALREADY_SENT", array($resend_activation_threshold));
} else {
//For security create a new activation url;
$new_activation_token = generateActivationToken();
if (!updateLastActivationRequest($new_activation_token, $username, $email)) {
$errors[] = lang("SQL_ERROR");
} else {
$mail = new userCakeMail();
$activation_url = $websiteUrl . "activate-account.php?token=" . $new_activation_token;
//Setup our custom hooks
$hooks = array("searchStrs" => array("#ACTIVATION-URL", "#USERNAME#"), "subjectStrs" => array($activation_url, $userdetails["display_name"]));
if (!$mail->newTemplateMsg("resend-activation.txt", $hooks)) {
$errors[] = lang("MAIL_TEMPLATE_BUILD_ERROR");
} else {
if (!$mail->sendMail($userdetails["email"], "Activate your " . $websiteName . " Account")) {
$errors[] = lang("MAIL_ERROR");
} else {
//Success, user details have been updated in the db now mail this information out.
$successes[] = lang("ACCOUNT_NEW_ACTIVATION_SENT");
}
}
}
}
}
}
}
}
//Prevent the user visiting the logged in page if he/she is already logged in
if (isUserLoggedIn()) {
header("Location: " . str_replace('index.php/', '', site_url('account')));
die;
}
$this->load->view('resend_activation');
}
示例13: ini_set
ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);
include '/home/jayme/firephp-core/lib/FirePHPCore/fb.php';
require 'scripts/dbConnect.php';
require 'scripts/selectQueries.php';
include 'scripts/sessions.php';
// Validate the fields upon submission.
if ($_POST) {
$loginUsername = trim($_POST["loginUsername"], " \t\n\r\v");
// Remove trailing whitespace from the field.
$loginPassword = $_POST["loginPassword"];
$errorMsg = "";
// OPENING DATABASE CONNECTION.
$dbConn = dbConnect();
// Check that the username exists in the database.
$userFound = usernameExists($dbConn, strtolower($loginUsername));
FB::log('User found status: ' . ($userFound ? 'True' : 'False'));
if ($userFound) {
// Check that the password is correct for the user.
$isValid = passwordExists($dbConn, $loginUsername, $loginPassword);
FB::log('Login valid? ' . ($isValid ? 'True' : 'False'));
if ($isValid) {
//TODO Creating PHP sessions for managing user login.
FB::log('Login success! Setting session variables...');
$_SESSION['LoggedIn'] = true;
$_SESSION['Username'] = $loginUsername;
$_SESSION['UserId'] = getUserId($dbConn, $loginUsername);
FB::info('LoggedIn: ' . $_SESSION['LoggedIn'] . ', Username: ' . $_SESSION['Username'] . ', UserId: ' . $_SESSION['UserId']);
} else {
$errorMsg = "<b>Your password is incorrect. Please try again.</b>";
}
示例14: flagLostPasswordRequest
function flagLostPasswordRequest($user_name, $value)
{
if (!usernameExists($user_name)) {
addAlert("danger", "Invalid username specified.");
return false;
}
try {
global $db_table_prefix;
$db = pdoConnect();
$sqlVars = array();
$query = "UPDATE " . $db_table_prefix . "users\n\t\tSET lost_password_request = :value\n\t\tWHERE\n\t\tuser_name = :user_name\n\t\tLIMIT 1";
$stmt = $db->prepare($query);
$sqlVars['value'] = $value;
$sqlVars['user_name'] = $user_name;
if (!$stmt->execute($sqlVars)) {
// Error: column does not exist
return false;
}
return true;
} catch (PDOException $e) {
addAlert("danger", "Oops, looks like our database encountered an error.");
error_log("Error in " . $e->getFile() . " on line " . $e->getLine() . ": " . $e->getMessage());
return false;
} catch (ErrorException $e) {
addAlert("danger", "Oops, looks like our server might have goofed. If you're an admin, please check the PHP error logs.");
return false;
} catch (RuntimeException $e) {
addAlert("danger", "Oops, looks like our server might have goofed. If you're an admin, please check the PHP error logs.");
error_log("Error in " . $e->getFile() . " on line " . $e->getLine() . ": " . $e->getMessage());
return false;
}
}
示例15: lang
$errors[] = lang("ACCOUNT_SPECIFY_USERNAME");
}
} else {
if ($username == "") {
$errors[] = lang("ACCOUNT_SPECIFY_USERNAME");
}
}
if ($password == "") {
$errors[] = lang("ACCOUNT_SPECIFY_PASSWORD");
}
if (count($errors) == 0) {
//A security note here, never tell the user which credential was incorrect
if ($email == 1) {
$existsVar = !emailExists($email_address);
} else {
$existsVar = !usernameExists($username);
}
if ($existsVar) {
$errors[] = lang("ACCOUNT_USER_OR_PASS_INVALID");
} else {
if ($email == 1) {
$userdetails = fetchUserAuthByEmail($email_address);
} elseif ($email == 0) {
$userdetails = fetchUserAuthByUserName($username);
}
//See if the user's account is activated
if ($userdetails["active"] == 0) {
$errors[] = lang("ACCOUNT_INACTIVE");
} else {
if ($userdetails["enabled"] == 0) {
$errors[] = lang("ACCOUNT_DISABLED");