本文整理汇总了PHP中user_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP user_exists函数的具体用法?PHP user_exists怎么用?PHP user_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user_exists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registra_usuario
function registra_usuario($username, $password, $email)
{
global $db;
if (user_exists($username)) {
$mensaje_de_error = "El usuario " . $username . " ya existe";
} else {
if (check_email($email) == 0) {
$mensaje_de_error = "El mail no es válido";
} else {
if (email_exists($email)) {
$mensaje_de_error = "El mail " . $email . " ya existe";
} else {
$SELECT = "INSERT INTO usuarios ( usuario_login, usuario_password, usuario_email, usuario_nombre )";
$SELECT .= " VALUES ( '" . $username . "', '" . md5($password) . "', '" . $email . "', '" . $username . "' )";
$result = $db->get_results($SELECT);
logea("registro " . $username, "", $_SESSION["usuario"]);
//Creamos el ranking con un día atrás para que no obtenga beneficios de 60000 al actualizar el ranking hoy
$SELECT = "INSERT INTO ranking ( ranking_usuario, ranking_saldo, ranking_invertido, ranking_total, ranking_beneficio_hoy, ranking_fecha ) ";
$SELECT .= " VALUES ( '" . $username . "', '60000', '0', '60000', '0', CURDATE()-INTERVAL 1 DAY )";
$result = $db->get_results($SELECT);
}
}
}
return $mensaje_de_error;
}
示例2: mci_account_get_array_by_id
/**
* Get username, realname and email from for a given user id
* @param integer $p_user_id A valid user identifier.
* @return array
*/
function mci_account_get_array_by_id($p_user_id)
{
$t_result = array();
$t_result['id'] = $p_user_id;
if (user_exists($p_user_id)) {
$t_current_user_id = auth_get_current_user_id();
$t_access_level = user_get_field($t_current_user_id, 'access_level');
$t_can_manage = access_has_global_level(config_get('manage_user_threshold')) && access_has_global_level($t_access_level);
# this deviates from the behaviour of view_user_page.php, but it is more intuitive
$t_is_same_user = $t_current_user_id === $p_user_id;
$t_can_see_realname = access_has_project_level(config_get('show_user_realname_threshold'));
$t_can_see_email = access_has_project_level(config_get('show_user_email_threshold'));
$t_result['name'] = user_get_field($p_user_id, 'username');
if ($t_is_same_user || $t_can_manage || $t_can_see_realname) {
$t_realname = user_get_realname($p_user_id);
if (!empty($t_realname)) {
$t_result['real_name'] = $t_realname;
}
}
if ($t_is_same_user || $t_can_manage || $t_can_see_email) {
$t_email = user_get_email($p_user_id);
if (!empty($t_email)) {
$t_result['email'] = $t_email;
}
}
}
return $t_result;
}
示例3: checkLogin
function checkLogin($u, $p)
{
global $seed;
// global because $seed is declared in the header.php file
if (!valid_username($u) || !valid_password($p) || !user_exists($u)) {
return false;
// the name was not valid, or the password, or the username did not exist
}
//Now let us look for the user in the database.
$query = sprintf("\n\t\tSELECT loginid \n\t\tFROM login \n\t\tWHERE \n\t\tusername = '%s' AND password = '%s' \n\t\tAND disabled = 0 AND activated = 1 \n\t\tLIMIT 1;", mysql_real_escape_string($u), mysql_real_escape_string(sha1($p . $seed)));
$result = mysql_query($query);
// If the database returns a 0 as result we know the login information is incorrect.
// If the database returns a 1 as result we know the login was correct and we proceed.
// If the database returns a result > 1 there are multple users
// with the same username and password, so the login will fail.
if (mysql_num_rows($result) != 1) {
return false;
} else {
// Login was successfull
$row = mysql_fetch_array($result);
// Save the user ID for use later
$_SESSION['loginid'] = $row['loginid'];
// Save the username for use later
$_SESSION['username'] = $u;
// Now we show the userbox
return true;
}
return false;
}
示例4: prepare_user_name
/**
* prepares the name of the user given the id. also makes it an email link.
* @param int $p_user_id
* @return string
*/
function prepare_user_name($p_user_id)
{
# Catch a user_id of NO_USER (like when a handler hasn't been assigned)
if (NO_USER == $p_user_id) {
return '';
}
$t_username = user_get_name($p_user_id);
if (user_exists($p_user_id) && user_get_field($p_user_id, 'enabled')) {
$t_username = string_display_line($t_username);
// WK/BFE: Original-Zeile auskommentiert: , LB/BFE 2015
// return '<a href="' . string_sanitize_url( 'view_user_page.php?id=' . $p_user_id, true ) . '">' . $t_username . '</a>';
// ersetzt durch: (Link auf view_user_page nur wenn globale Rolle mindestens $g_manage_user_threshold
if (user_is_administrator(auth_get_current_user_id())) {
return '<a href="' . string_sanitize_url('view_user_page.php?id=' . $p_user_id, true) . '">' . $t_username . '</a>';
} else {
return $t_username;
}
// WK/BFE: Ende der Modifikation
} else {
$t_result = '<font STYLE="text-decoration: line-through">';
$t_result .= string_display_line($t_username);
$t_result .= '</font>';
return $t_result;
}
}
示例5: register
/**
* @param $in
* @return array
*
* @code
* $ php index.php "route=user.Controller.register&username=abc&password=1234&email=abc@def.com"
* @endcode
*
*/
public function register($in)
{
if (!isset($in['username'])) {
sys()->log("Username is empty.");
return ERROR(-111, "Username is empty.");
}
if (!isset($in['password'])) {
return ERROR(-1121, "Password is empty.");
}
if (!isset($in['email'])) {
return ERROR(-113, "Email is empty.");
}
if (user_exists($in['username'])) {
return ERROR(-121, "User: {$in['username']} exists.");
}
if (user_email_exists($in['email'])) {
return ERROR(-121, "User email: {$in['email']} exists.");
}
$sets = array();
$sets['username'] = $in['username'];
$sets['password'] = password_encrypt($in['password']);
$sets['email'] = $in['email'];
$sets['first_name'] = hi('first_name', '');
$sets['middle_name'] = hi('middle_name', '');
$sets['last_name'] = hi('last_name');
$sets['mobile'] = hi('mobile', '');
$sets['landline'] = hi('landline', '');
$sets['address'] = hi('address');
$re = user()->create()->sets($sets)->save();
if ($re) {
return SUCCESS();
} else {
return ERROR(-4, 'Failed on saving user information.');
}
}
示例6: getData
function getData()
{
parent::getData();
$this->wop = value_from_POST_GET(FMWK_PARAM_OP, 'sign');
if (empty($this->asked_app)) {
$this->asked_app = value_from_POST('asked_app', Null);
}
$op = $this->wop;
$siteuser = $this->site->username();
$this->user_signed = isset($siteuser);
if ($this->user_signed) {
$this->wusername = $siteuser;
} else {
$this->wusername = value_from_POST('username', Null);
$this->wpassword = value_from_POST('password', Null);
}
switch ($op) {
case 'logout':
$auth = $this->site->auth;
$auth->logoutUser($this->wusername);
$this->site->redirectToApp($this->asked_app);
exit;
break;
case 'login':
if ($this->user_signed) {
$this->message .= "Already authentificated in";
$this->wop = 'info';
} else {
$is_ok = FALSE;
if (!empty($this->wusername)) {
$auth = $this->site->auth;
if (isset($auth)) {
$is_ok = $auth->loginUser($this->wusername, $this->wpassword);
}
}
if ($is_ok) {
require_once INC_DIR . "users.inc";
if (user_exists($auth->signed_username)) {
$this->message .= "Welcome";
$this->wop = 'login';
$this->site->redirectToApp($this->asked_app);
} else {
$this->message .= "Sorry your account is not configured yet.<br/>";
$auth->logoutUser();
$this->wop = 'sign';
}
} else {
$this->message .= "Invalid login or password";
$this->wop = 'sign';
}
}
break;
default:
$this->wop = 'info';
break;
}
}
示例7: adduser
function adduser($username, $password, $level, $email = "", $realname = "", $can_modify_passwd = '1', $description = "")
{
if (!user_exists($username)) {
$encrypted = crypt($password, '$1$' . generateSalt(8) . '$');
return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'descr' => $description), 'users');
} else {
return FALSE;
}
}
示例8: __construct
function __construct($Username, $key)
{
if (!user_exists($Username)) {
return false;
}
$this->username = $Username;
$this->rehash();
$_SESSION['user'] =& $this;
$this->decryptionKey = $key;
}
示例9: adduser
function adduser($username, $password, $level, $email = '', $realname = '', $can_modify_passwd = '1')
{
if (!user_exists($username)) {
$hasher = new PasswordHash(8, false);
$encrypted = $hasher->HashPassword($password);
return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname), 'users');
} else {
return false;
}
}
示例10: adduser
function adduser($username, $password, $level, $email = "", $realname = "", $can_modify_passwd = 1, $description = "", $twofactor = 0)
{
if (!user_exists($username)) {
$hasher = new PasswordHash(8, FALSE);
$encrypted = $hasher->HashPassword($password);
return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'descr' => $description, 'twofactor' => $twofactor), 'users');
} else {
return FALSE;
}
}
示例11: pass_check
function pass_check($user, $pass)
{
if (user_exists($user)) {
$hpass = sha1(sha1($pass));
$q = "SELECT COUNT(*) FROM users WHERE user='" . sqlite_escape_string($user) . "' AND pass='" . $hpass . "'";
$res = db_fetch_array(db_query($q), SQLITE_NUM);
return $res['0']['0'];
} else {
return FALSE;
}
}
示例12: update_user
private function update_user()
{
$fb_response = $this->facebook->api('/me');
$this->display_name = $fb_response['name'];
global $db;
if (user_exists($this)) {
$this->updated = time();
$db->query('UPDATE users SET display_name = "' . $this->display_name . '", updated = ' . $this->updated . ' WHERE uid = ' . $this->uid);
} else {
create_user($this);
}
}
示例13: authenticate
function authenticate($username, $password)
{
global $config;
if (isset($_SERVER['REMOTE_USER'])) {
$_SESSION['username'] = mres($_SERVER['REMOTE_USER']);
if (user_exists($_SESSION['username'])) {
return 1;
}
$_SESSION['username'] = $config['http_auth_guest'];
return 1;
}
return 0;
}
示例14: verify_password
function verify_password($pseudo, $password)
{
$error = false;
//Pseudo pas existant
if (!user_exists(array('pseudo' => $pseudo, 'password' => sha1(md5($password))))) {
$_SESSION['connexion_error'][] = 'Le mot de passe entré n\'est pas le bon.';
$error = true;
}
if (!$error) {
return true;
}
return false;
}
示例15: generate_request
function generate_request($email, &$db)
{
//echo "generate request function called. <br><br>";
$user_confirmed = user_exists($email, $db);
if ($user_confirmed[0]) {
$requestkey = mt_rand(10000000, mt_getrandmax());
$time = time();
//echo "user confirmed to exist; request key generated: $requestkey <br><br>";
try {
$sql = 'INSERT INTO password_reset_requests
(email, requestkey, time)
VALUES (:email, :requestkey, :time)';
$stmt = $db->prepare($sql);
$stmt->bindValue(':email', $email);
$stmt->bindValue(':requestkey', $requestkey);
$stmt->bindValue(':time', $time);
$stmt->execute();
$errorInfo = $stmt->errorInfo();
if (isset($errorInfo[2])) {
$error = $errorInfo[2];
}
} catch (Exception $e) {
$error = $e->getMessage();
}
if (isset($error)) {
//echo "database error in request insertion: $error <br><br>";
return [false, $error];
}
$requestid = $db->lastInsertId();
if (!isset($requestid)) {
//echo "error: no request id returned by db. <br><br>";
return [false, 'Error: Could not add request to database.'];
} else {
//echo "made it! have a request id: $requestid <br><br>";
$key = $requestid . '-' . $requestkey;
//echo "about to generate an email with address $email and key $key <br><br>";
if (generate_email($email, $key)) {
//echo "email sent. <br><br>";
return [true];
} else {
//echo "email not sent. <br><br>";
return [false, "Error: email could not be sent."];
}
}
} else {
//echo "user does not exist. <br><br>";
return $user_confirmed;
// already in the form [false, error]
}
}