<?php
/**
* Checks a password with a supplied username.
*
* @param string The username of the user.
* @param string The plain-text password.
* @return boolean|array False when no match, array with user info when match.
*/
function validate_password_from_username($username, $password)
{
global $db;
$query = $db->simple_select("users", "uid,username,password,salt,loginkey,coppauser,usergroup", "LOWER(username)='".$db->escape_string(my_strtolower($username))."'", array('limit' => 1));
$user = $db->fetch_array($query);
if(!$user['uid'])
{
return false;
}
else
{
return validate_password_from_uid($user['uid'], $password, $user);
}
}
<?php
/**
* Checks a password with a supplied username.
*
* @param string The username of the user.
* @param string The plain-text password.
* @return boolean|array False when no match, array with user info when match.
*/
function validate_password_from_username($username, $password)
{
global $db;
$query = $db->simple_select("users", "uid,username,email,password,salt,loginkey,coppauser,usergroup", "LOWER(email)='".$db->escape_string(my_strtolower($username))."'", array('limit' => 1));
$user = $db->fetch_array($query);
if(!$user['uid'])
{
return false;
}
else
{
return validate_password_from_uid($user['uid'], $password, $user);
}
}
<?php
/**
* Checks a password with a supplied username.
*
* @param string The username of the user.
* @param string The plain-text password.
* @return boolean|array False when no match, array with user info when match.
*/
function validate_password_from_username($username, $password)
{
global $db;
$query = $db->simple_select("users", "uid,username,password,salt,loginkey,coppauser,usergroup", "LOWER(username)='".$db->escape_string(my_strtolower($username))."'", array('limit' => 1));
$user = $db->fetch_array($query);
if(!$user['uid'])
{
return false;
}
else
{
return validate_password_from_uid($user['uid'], $password, $user);
}
}
<?php
/**
* Checks a password with a supplied username.
*
* @param string The username of the user.
* @param string The plain-text password.
* @return boolean|array False when no match, array with user info when match.
*/
function validate_password_from_username($username, $password)
{
global $db;
$query = $db->simple_select("users", "uid,username,email,password,salt,loginkey,coppauser,usergroup", "LOWER(username)='".$db->escape_string(my_strtolower($username))."' OR LOWER(email)='".$db->escape_string(my_strtolower($username))."'", array('limit' => 1));
$user = $db->fetch_array($query);
if(!$user['uid'])
{
return false;
}
else
{
return validate_password_from_uid($user['uid'], $password, $user);
}
}
<?php
/**
* Checks if $username already exists in the database.
*
* @param string The username for check for.
* @return boolean True when exists, false when not.
*/
function username_exists($username)
{
global $db;
$query = $db->simple_select("users", "COUNT(*) as user", "LOWER(username)='".$db->escape_string(my_strtolower($username))."'", array('limit' => 1));
if($db->fetch_field($query, 'user') == 1)
{
return true;
}
else
{
return false;
}
}
<?php
/**
* Checks if $username already exists in the database.
*
* @param string The username for check for.
* @return boolean True when exists, false when not.
*/
function username_exists($username)
{
global $db;
$query = $db->simple_select("users", "COUNT(*) as user,email,username", "LOWER(username)='".$db->escape_string(my_strtolower($username))."' OR LOWER(email)='".$db->escape_string(my_strtolower($username))."'", array('limit' => 1));
if($db->fetch_field($query, 'user') == 1)
{
return true;
}
else
{
return false;
}
}
(16 Oct, 2011, 12:02 pm)Cluster escribió: Para ambas
En tu inc/functions_user.php busca:
Código PHP:<?php
/**
* Checks if $username already exists in the database.
*
* @param string The username for check for.
* @return boolean True when exists, false when not.
*/
function username_exists($username)
{
global $db;
$query = $db->simple_select("users", "COUNT(*) as user", "LOWER(username)='".$db->escape_string(my_strtolower($username))."'", array('limit' => 1));
if($db->fetch_field($query, 'user') == 1)
{
return true;
}
else
{
return false;
}
}
<?php
/**
* Checks if $username already exists in the database.
*
* @param string The username for check for.
* @return boolean True when exists, false when not.
*/
function username_exists($username)
{
global $db;
$query = $db->simple_select("users", "COUNT(*) as user,email,username", "LOWER(username)='".$db->escape_string(my_strtolower($username))."' OR LOWER(email)='".$db->escape_string(my_strtolower($username))."'", array('limit' => 1));
if($db->fetch_field($query, 'user') == 1)
{
return true;
}
else
{
return false;
}
}