本文整理汇总了PHP中userExists函数的典型用法代码示例。如果您正苦于以下问题:PHP userExists函数的具体用法?PHP userExists怎么用?PHP userExists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了userExists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: activate
public function activate($code, $userId)
{
$rs = array('status' => '', 'note' => '');
if (!userExists($userId)) {
$rs['status'] = 'Fail';
$rs['note'] = 'User does not exists';
return $rs;
}
$activated = DI()->notorm->User->select('activated')->where('id', $userId);
$activated = $activated['activated'];
if ($activated == 1) {
$rs['status'] = 'Fail';
$rs['note'] = 'Already Activated';
return $rs;
}
$ac = DI()->notorm->User->select('activationCode')->where('id', $userId);
$ac = $ac['activationCode'];
if ($code == $ac) {
$rs['status'] = 'Success';
return $rs;
} else {
$rs['status'] = 'Fail';
$rs['note'] = 'Activation does not match';
return $rs;
}
}
示例2: checkForm
function checkForm()
{
global $first_name, $last_name, $login, $password1, $password2, $email;
try {
$secret = filter_input(INPUT_POST, 'secret');
if (empty($last_name) || empty($first_name) || empty($login) || empty($password1) || empty($password2) || empty($email) || empty($secret)) {
throw new Exception('Нужно заполнить все поля');
}
if (!validLogin($login)) {
throw new Exception('Логин должен состоять из не мене 3-х букв латинского алфавиа цыфр и подчерка');
}
if (!validEmail($email)) {
throw new Exception('Неправильный email');
}
if ($password1 != $password1) {
throw new Exception('Пароли не совпадают');
}
if (!validUserName($first_name, $last_name)) {
throw new Exception('Имя и фамилия могут состоять только из букв');
}
if (userExists($login, $email)) {
throw new Exception('Такой логин или email уже существует.');
}
if ($secret != $_SESSION['secret']) {
throw new Exception('Неверно указано число с картинки');
}
} catch (Exception $exc) {
return $exc->getMessage();
}
}
示例3: addNewUser
function addNewUser()
{
// globals
global $DB;
global $MySelf;
global $MB_EMAIL;
// Sanitize the input.
$USERNAME = $MySelf->getUsername;
$NEW_USER = strtolower(sanitize($_POST[username]));
// supplied new username.
if (!ctypeAlnum($NEW_USER)) {
makeNotice("Only characters a-z, A-Z and 0-9 are allowed as username.", "error", "Invalid Username");
}
/* Password busines */
if ($_POST[pass1] != $_POST[pass2]) {
makeNotice("The passwords did not match!", "warning", "Passwords invalid", "index.php?action=newuser", "[retry]");
}
$PASSWORD = encryptPassword("{$_POST['pass1']}");
$PASSWORD_ENC = $PASSWORD;
/* lets see if the users (that is logged in) has sufficient
* rights to create even the most basic miner. Level 3+ is
* needed.
*/
if (!$MySelf->canAddUser()) {
makeNotice("You are not authorized to do that!", "error", "Forbidden");
}
// Lets prevent adding multiple users with the same name.
if (userExists($NEW_USER) >= 1) {
makeNotice("User already exists!", "error", "Duplicate User", "index.php?action=newuser", "[Cancel]");
}
// So we have an email address?
if (empty($_POST[email])) {
// We dont!
makeNotice("You need to supply an email address!", "error", "Account not created");
} else {
// We do. Clean it.
$NEW_EMAIL = sanitize($_POST[email]);
}
// Inser the new user into the database!
$DB->query("insert into users (username, password, email, addedby, confirmed) " . "values (?, ?, ?, ?, ?)", array("{$NEW_USER}", "{$PASSWORD_ENC}", "{$NEW_EMAIL}", $MySelf->getUsername(), "1"));
// Were we successfull?
if ($DB->affectedRows() == 0) {
makeNotice("Could not create user!", "error");
} else {
// Write the user an email.
global $SITENAME;
$mail = getTemplate("newuser", "email");
$mail = str_replace('{{USERNAME}}', "{$NEW_USER}", $mail);
$mail = str_replace('{{PASSWORD}}', "{$PASSWORD}", $mail);
$mail = str_replace('{{SITE}}', "http://" . $_SERVER['HTTP_HOST'] . "/", $mail);
$mail = str_replace('{{CORP}}', "{$SITENAME}", $mail);
$mail = str_replace('{{CREATOR}}', "{$USERNAME}", $mail);
$to = $NEW_EMAIL;
$DOMAIN = $_SERVER['HTTP_HOST'];
$subject = "Welcome to MiningBuddy";
$headers = "From:" . $MB_EMAIL;
mail($to, $subject, $mail, $headers);
makeNotice("User added and confirmation email sent.", "notice", "Account created", "index.php?action=editusers");
}
}
示例4: _base_verifInfo
/**
* Function called before changing user attributes
* @param $FH FormHandler of the page
* @param $mode add or edit mode
*/
function _base_verifInfo($FH, $mode)
{
global $error;
$base_errors = "";
$uid = $FH->getPostValue("uid");
$pass = $FH->getPostValue("pass");
$confpass = $FH->getPostValue("confpass");
$homedir = $FH->getPostValue("homeDirectory");
$primary = $FH->getPostValue("primary");
$firstname = $FH->getPostValue("givenName");
$lastname = $FH->getPostValue("sn");
if (!preg_match("/^[a-zA-Z0-9][A-Za-z0-9_.-]*\$/", $uid)) {
$base_errors .= _("User's name invalid !") . "<br/>";
setFormError("uid");
}
if ($mode == "add" && $uid && userExists($uid)) {
$base_errors .= sprintf(_("The user %s already exists."), $uid) . "<br/>";
setFormError("uid");
}
if ($mode == "add" && $pass == '') {
$base_errors .= _("Password is empty.") . "<br/>";
setFormError("pass");
}
if ($mode == "add" && $lastname == '') {
$base_errors .= _("Last name is empty.") . "<br/>";
setFormError("sn");
}
if ($mode == "add" && $firstname == '') {
$base_errors .= _("First name is empty.") . "<br/>";
setFormError("givenName");
}
if ($pass != $confpass) {
$base_errors .= _("The confirmation password does not match the new password.") . " <br/>";
setFormError("pass");
setFormError("confpass");
}
/* Check that the primary group name exists */
if (!strlen($primary)) {
$base_errors .= _("The primary group field can't be empty.") . "<br />";
setFormError("primary");
} else {
if (!existGroup($primary)) {
$base_errors .= sprintf(_("The group %s does not exist, and so can't be set as primary group."), $primary) . "<br />";
setFormError("primary");
}
}
/* Check that the homeDir does not exists */
if ($mode == "add") {
if ($FH->getPostValue("createHomeDir") == "on" && $FH->getPostValue("ownHomeDir") != "on" && $uid) {
getHomeDir($uid, $FH->getValue("homeDirectory"));
}
} else {
/* If we want to move the userdir check the destination */
if ($FH->isUpdated("homeDirectory")) {
getHomeDir($uid, $FH->getValue("homeDirectory"));
}
}
$error .= $base_errors;
return $base_errors ? 1 : 0;
}
示例5: isFieldsEmpty
function isFieldsEmpty($loginDetails, $errorMsg)
{
if (isEmpty($loginDetails)) {
userExists($loginDetails, $errorMsg);
} else {
$errorMsg = "Username and/or password fields cannot be left blank";
errorMessage($errorMsg);
}
}
示例6: userAdd
function userAdd($userData)
{
$user = $userData['user'];
$password = $userData['password'];
$password = md5($password);
if (userExists($user)) {
return false;
}
$query = "INSERT INTO `user` (`user`,`password`) VALUES ('{$user}','{$password}')";
$result = userQuery($query);
return $result != null;
}
示例7: login
function login()
{
if (isset($_POST['username'])) {
$db = new mysqli('localhost', 'root', 'root', 'gurucodertutorial_login');
$username = $db->real_escape_string($_POST['username']);
$password = $db->real_escape_string($_POST['password']);
if (userExists($username)) {
if (verifyPassword($username, $password)) {
header('Location: /GuruCoder-Tutorials/login.php?message=Successfully logged in');
} else {
header('Location: /GuruCoder-Tutorials/login.php?message=Incorrect password');
}
} else {
header('Location: /GuruCoder-Tutorials/login.php?message=No user exists');
}
}
}
示例8: doLogin
function doLogin()
{
if (!isset($_POST['username']) || !isset($_POST['password'])) {
return 'Du hast ein Feld vergessen zu senden!';
}
$username = $_POST['username'];
$password = $_POST['password'];
if (!userExists($username)) {
return 'Dieser Benuzter existiert nicht!';
}
$userid = isUserPasswordCorrect($username, $password);
if ($userid === false) {
return 'Dein Passwort stimmt nicht!';
} else {
login($username, $userid);
$info = getUserInfo($userid);
$_SESSION['userinfo'] = $info;
return true;
}
}
示例9: insertUser
public static function insertUser($name, $surname, $email, $password, $address, $city)
{
if (!userExists($email)) {
$name = mysql_real_escape_string($name);
$surname = mysql_real_escape_string($surname);
$email = mysql_real_escape_string($email);
$password = mysql_real_escape_string($password);
$address = mysql_real_escape_string($address);
$city = mysql_real_escape_string($city);
$query = "INSERT INTO users(first_name, last_name, email, password, address, city) VALUES \\\n (" . $name . "," . $surname . "," . $email . "," . $password . "," . $address . "," . $city . ")";
$result = Database::getInstance()->doInsert($query);
if ($result) {
header("location:../public/contest.html");
} else {
header("location:../public/register.html");
}
} else {
header("location:../public/register.html");
}
}
示例10: isValidUsername
function isValidUsername($username)
{
if (userExists($username) or strlen($username) < 3) {
return false;
} else {
$valid_chars = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
$string = strtolower($username);
$nsize = strlen($string);
$x = 0;
$found = false;
while ($x < $nsize) {
if (in_array($string[$x], $valid_chars)) {
} else {
$found = true;
}
$x++;
}
if ($found) {
return false;
} else {
return true;
}
}
}
示例11: header
<?php
header('Content-type: application/json');
chdir("..");
chdir("database");
require_once "users.php";
if (isset($_GET["email"]) and isset($_GET["password"]) and userExists((string) $_GET["email"]) and getUserStatus((string) $_GET["email"]) == "active") {
$email = (string) $_GET["email"];
$password = (string) $_GET["password"];
if (checkUserLogin($email, $password)) {
echo json_encode(array("result" => "ok"));
} else {
echo json_encode(array("result" => "invalidLogin"));
}
} else {
echo json_encode(array("result" => "missingParams"));
}
示例12: header
header('Content-type: application/json');
chdir("../..");
chdir("database");
require_once "users.php";
chdir("..");
require_once "configuration.php";
/**
* DESCRIPTION: Sets the user space
* PARAMETERS: /api/users/setUserSpace.php <apikey> <user> <space>
*/
if (isset($_GET['apikey']) and isset($_GET['user']) and isset($_GET['space'])) {
$auth = (string) $_GET['apikey'];
$user = (string) $_GET['user'];
$space = intval($_GET['space']);
if ($auth != $apikey) {
echo json_encode(array("result" => "permissionDenied"));
} else {
if (!userExists($user)) {
echo json_encode(array("result" => "invalidUser"));
} else {
$valid = updateUserSpaceUsed($user, $space);
if ($valid) {
echo json_encode(array("result" => "ok"));
} else {
echo json_encode(array("result" => "notEnoughSpace"));
}
}
}
} else {
return json_encode(array("result" => "missingParams"));
}
示例13: htmlspecialchars
<?php
require "init.php";
require_once 'CamsDatabase.php';
require_once 'users.php';
if (!empty($_POST)) {
$username = htmlspecialchars($_POST['userid']);
$password = htmlspecialchars($_POST['password']);
if (empty($username) || empty($password)) {
$_SESSION["login_error"] = 'User Name and Password cannot be blank';
} else {
if (!userExists($username)) {
$_SESSION["login_error"] = 'User Does not exist.';
} else {
$user = userLogin($username, $password);
if (!$user) {
$_SESSION["login_error"] = 'incorrect password';
} else {
$_SESSION['FirstName'] = $user['FirstName'];
$_SESSION['LastName'] = $user['LastName'];
$_SESSION['userid'] = $user['userid'];
$_SESSION['Email'] = $user['Email'];
$_SESSION['Empno'] = $user['Empno'];
$_SESSION['Phone'] = $user['Phone'];
$_SESSION['Role'] = $user['Role'];
$_SESSION['Agy'] = $user['Agy'];
$_SESSION['Dpt'] = $user['Dpt'];
}
}
}
header('Location: ../index.php');
示例14: require_login
function require_login($wanted = "")
{
$username = null;
$password = null;
if (isset($_SERVER["PHP_AUTH_USER"])) {
$username = $_SERVER["PHP_AUTH_USER"];
$password = $_SERVER["PHP_AUTH_PW"];
}
if (is_null($username)) {
headauth("Voce precisa fazer login para continuar!");
} else {
if (!userExists($username)) {
headauth("Esse usuario nao existe!");
}
if ($username !== $wanted && $wanted != "") {
headauth("Esse login nao e o correto!");
}
if (!isright($username, $password)) {
headauth("Senha incorreta!");
}
}
}
示例15: clean
if ($mode == "SEND") {
$pid = clean($_POST['pid']);
$uid = clean($_POST['uid']);
$ident = clean($_POST['ident']);
$to = clean($_POST['to']);
$from = clean($_POST['from']);
$message = clean($_POST['message']);
$pluginname = "xMail";
if (isset($_POST['pluginOwner'])) {
$pluginname = clean($_POST['pluginOwner']);
}
$attachments = "";
// Check API key
check_key($ip, $mode, $key, $from);
if (valid($pid) && valid($uid) && valid($ident) && valid($to) && valid($from) && valid($message) && valid($pluginname)) {
if (userExists($to)) {
if ($ident == "S") {
if (!isSpam($to, $from, $message)) {
if (!$debug) {
mysql_query("INSERT INTO `mail` (`to`, `from`, `message`, `unread`, `complex`, `sent`, `sent_from`, `pluginname`) VALUES ('{$to}', '{$from}', '{$message}', '1', '0', '{$now}', '{$ip}', '{$pluginname}')") or die(mysql_error());
}
onSend($to, $from, $message);
echo json_encode(array("message" => "Message sent!", "status" => "OK"));
} else {
echo json_encode(array("message" => "Spam", "status" => "ERROR"));
}
} else {
if ($ident == "C") {
$message = str_replace("&", "&", $message);
$message = str_replace("§", "?", $message);
$parts = explode(";", $message);