本文整理汇总了PHP中checkUsername函数的典型用法代码示例。如果您正苦于以下问题:PHP checkUsername函数的具体用法?PHP checkUsername怎么用?PHP checkUsername使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了checkUsername函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addUser
public function addUser()
{
$username = I('post.username', 0);
$password = I('post.password', 0);
($username === 0 || $password === 0) && $this->error("大哥别瞎搞!");
$username = checkUsername($username);
if (!$username) {
$this->ajaxReturn("大哥别瞎注册!");
exit;
}
$user = M('user');
$queryResult = $user->where("username = '%s'", $username)->find();
if ($queryResult) {
$this->ajaxReturn("user_exist");
exit;
}
$data = array('id' => "", 'username' => $username, 'password' => pwEncrypt($username, $password), 'lasttime' => time(), 'lastip' => get_client_ip());
$result = $user->add($data);
if ($result) {
$this->ajaxReturn("ok");
exit;
} else {
$this->ajaxReturn("注册失败!");
exit;
}
}
示例2: createUser
function createUser($data)
{
if ($obs = json_decode($data, true)) {
$user = htmlentities(preg_replace("/[^a-zA-Z]*/", "", $obs['u']), ENT_QUOTES, "utf-8");
$pw = htmlentities(preg_replace("/[^a-zA-Z]*/", "", $obs['p']), ENT_QUOTES, "utf-8");
$cp = htmlentities(preg_replace("/[^a-zA-Z]*/", "", $obs['cp']), ENT_QUOTES, "utf-8");
if (strlen($user) < 6 || strlen($pw) < 6 || strlen($user) > 20 || strlen($pw) > 20) {
return -1;
}
if ($pw != $cp) {
return -1;
} elseif (checkUsername($user) > 0) {
return -1;
} else {
$cPass = hashPass($pw);
if (!storeNewUser($user, $cPass)) {
return -1;
} else {
//account successfully created, so we will automatically log them in
if (login(json_encode(array("n" => $user, "p" => $pw)), $_SERVER['REMOTE_ADDR']) == 1) {
return 1;
} else {
return -1;
}
}
}
} else {
return -1;
}
}
示例3: verifyUserPass
function verifyUserPass($username, $password, $redirect)
{
$config = getConfig();
if (checkUsername($username, $config->username) && checkPassword($password, $config->password)) {
if (loadConfig($config)) {
$_SESSION["loggedIn"] = true;
}
header("Location: " . $redirect);
} else {
return false;
}
}
示例4: check
function check()
{
global $error;
global $CONST;
if (isset($_POST["usernamesignup"]) && isset($_POST["anweshasignup"]) && isset($_POST["passwordsignup"]) && isset($_POST['6_letters_code'])) {
} else {
$error["msg"] = 'Incomplete request';
$error['component'] = 'username';
return;
}
$user = $_POST["usernamesignup"];
$anw = $_POST["anweshasignup"];
$pass = $_POST["passwordsignup"];
/**
* validating captcha
*/
if (empty($_SESSION['6_letters_code']) || $_SESSION['6_letters_code'] != $_POST['6_letters_code']) {
$error["msg"] = "The captcha code does not match!";
$error["component"] = "captcha";
return;
}
/**
* getting the status of login in anwesha website
*/
$url = 'http://2016.anwesha.info/login/';
$data = array('username' => $anw, 'password' => $pass);
$data = http_build_query($data);
$reply = do_post_request($url, $data);
$res = (array) json_decode($reply);
/**
* getting the login status
*/
if (!$res['status']) {
$error["msg"] = "Authentication failed. You entered an incorrect Anwesha ID or password.";
$error["component"] = "anwesha";
return;
}
$hash = sha1($pass);
if (!checkUsername($user)) {
$error["msg"] = "Username already taken.";
$error["component"] = "username";
return;
}
if (!filter_var($user, FILTER_VALIDATE_REGEXP, array("options" => array('regexp' => '/^[\\w]{5,15}$/')))) {
$error["msg"] = "Inappropriate username (5 to 15 alphanumeric characters needed)";
$error["component"] = "username";
return;
}
// var_dump($CONT);
}
示例5: procDeleteUser
/**
* procDeleteUser - If the submitted username is correct,
* the user is deleted from the database.
*/
function procDeleteUser()
{
global $session, $database, $form;
/* Username error checking */
$subuser = checkUsername("deluser");
$database->REGISTRAR("USUARIO_ELIMINAR", "Se eliminó un usuario.", "Usuario afectado: {$subuser}");
/* Errors exist, have user correct them */
if ($form->num_errors > 0) {
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $form->getErrorArray();
header("Location: ../?accion=gestionar+clientes");
} else {
$q = "DELETE FROM " . TBL_USERS . " WHERE codigo = '{$subuser}'";
$database->query($q);
header("Location: ../?accion=gestionar+clientes");
}
}
示例6: hash
if (!$passwordError && isset($_POST['newPass']) && !empty($_POST['newPass'])) {
try {
$stmt = $db->prepare("update `users` set password=:password where id=:id");
$stmt->bindParam(":password", hash("sha512", $_POST['newPass']));
$stmt->bindParam(":id", $_SESSION['user_id']);
$stmt->execute();
$passwordChanged = 1;
} catch (PDOException $e) {
$passwordError = -1;
}
}
// Basic data check
$phoneError = $addressError = $emailError = $dateError = $usernameError = 0;
$phoneChanged = $addressChanged = $emailChanged = $dateChanged = $usernameChanged = 0;
if (isset($_POST['username']) && !empty($_POST['username']) && addslashes($_POST['username']) != $_SESSION['username']) {
$usernameError = checkUsername($_POST['username']);
if ($usernameError == 0) {
try {
$stmt = $db->prepare("select * from `users` where username=:username");
$stmt->bindParam(":username", addslashes($_POST['username']));
$stmt->execute();
if ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$usernameError = 3;
}
} catch (PDOException $e) {
echo "Database error";
}
}
$basicChanged = 1;
$usernameChanged = 1;
}
示例7: register
if (password_verify($password, $password_hashed)) {
echo "You logged in with user: " . $row['userName'] . " that has the ID: " . $row['userID'];
} else {
echo 'Invalid password.';
}
} else {
if ($form_page == 'register') {
//die("Function isn't added yet");
$username = $_POST['username'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$email = $_POST['email'];
register($username, $password, $email);
} else {
if ($form_page == 'usernameCheck') {
//die("Function isn't added yet");
$username = $_POST['username'];
$array = checkUsername($username);
echo json_encode($array);
} else {
if ($form_page == 'emailCheck') {
//die("Function isn't added yet");
$email = $_POST['email'];
$array = checkEmail($email);
echo json_encode($array);
} else {
die('Something went wrong');
}
}
}
}
示例8: chmod
if (!$fileError && !$nameError) {
if (!file_exists($filepath)) {
if (!is_uploaded_file($_FILES['fileChoose']['tmp_name']) || !copy($_FILES['fileChoose']['tmp_name'], $filepath)) {
$fileError = 2;
} else {
chmod($filepath, 776);
}
} else {
$fileError = 4;
}
}
}
} else {
if (isset($_POST['name']) && !empty($_POST['name'])) {
$name = trim($_POST['name']);
$nameError = checkUsername($name);
if (!$nameError) {
if (isset($_SESSION['location']) && !empty($_SESSION['location'])) {
$filepath = $_SESSION['location'] . '/' . $name . '.txt';
} else {
$filepath = "data/" . $_SESSION['user_id'] . "/home/" . $name . ".txt";
}
if (!file_exists($filepath)) {
$file = fopen($filepath, "w");
if ($file) {
fclose($file);
} else {
$fileError = 2;
}
} else {
$fileError = 4;
示例9: header
header('Location: registration.php?error=5');
}
// verify password meets complexity -- complexity = min. 12 characters, etc
if (strlen($password1) < 12) {
header('Location: registration.php?error=4');
}
$hasUpperCase = preg_match("/[A-Z]/", $password1);
$hasLowerCase = preg_match("/[a-z]/", $password1);
$hasNumbers = preg_match("/[0-9]/", $password1);
$hasNonalphas = preg_match("/[!#\$%&\\?_ ]/", $password1);
if ($hasUpperCase + $hasLowerCase + $hasNumbers + $hasNonalphas < 3) {
$_SESSION['error'] = true;
header('Location: registration.php?error=4');
}
return 1;
}
// end functions
// Validation:
$validationResult = checkToken($sToken, $_SESSION['token']) + checkUsername($username, $conn) + checkEmail($email, $vemail, $conn) + checkPasswd($password1, $password2);
// This is being called when it should not be called when the email validation fails
// Behavior:
// When email fails to validate, the INSERT SQL statement is still running and creating a new entry in the user table
if ($validationResult == 4) {
$salt = createSalt();
$password = hash('sha256', $salt . $hash);
$username = mysqli_real_escape_string($conn, $username);
$query = "INSERT INTO member ( username, password, email, salt)\n\t VALUES ( '{$username}', '{$password}', '{$email}', '{$salt}');";
$result = mysqli_query($conn, $query);
// echo "query sucess <br>";
// Redirect to page thanking the user for registering
}
示例10: passwordManager
*
* You should have received a copy of the GNU General Public License
* along with Loquacity; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
include_once "../config.php";
include_once 'charsets.php';
include_once 'taglines.php';
require_once "validation/passwordManager.class.php";
$myPasswdMgr =& new passwordManager($loq->_adb);
$loq->template_dir = LOQ_APP_ROOT . 'includes/admin_templates';
$loq->assign('sidemsg', 'Loquacity Password Recovery');
$_SESSION['username'] = $_POST['username'];
$_SESSION['answer'] = $_POST['answer'];
// if a username in the post is entered, and that username exists in the database,
if (isset($_SESSION['username']) && $_SESSION['username'] == checkUsername($_SESSION['username'])) {
// get the secret question for the user
$secQuestion = $myPasswdMgr->getQuestion($_SESSION['username']);
$loq->assign('question', $secQuestion);
$_SESSION['answer'] = $_POST['answer'];
$template = 'askquestion.html';
// Now check if we have an answer or not, and compare them.
// psudo: if (checkAnswers(pw1,pw2) where pw1 = getAnswer(username)
if ($myPasswdMgr->checkAnswers($myPasswdMgr->getAnswer($_SESSION['username']), $_SESSION['answer'])) {
// success! reset password and send the email.
setPassword($_SESSION['username'], $_SESSION['answer']);
sendEmail($user, $email, $passwd);
$template = 'status.html';
} else {
$loq->assign('title', 'Please answer your question');
$template = 'askquestion.html';
示例11: error
error("Fields must not be empty!");
}
}
function checkUsername($username)
{
$len = strlen($username);
for ($i = 0; $i < $len; $i++) {
if ($username[$i] < 'a' || $username[$i] > 'z') {
error("Only english letters allowed");
}
}
}
assertPost("tid");
assertPost("password");
$id = strtolower($_POST["tid"]);
checkUsername($id);
$password = $_POST["password"];
$cid = $contest["cid"];
$sql = "SELECT * FROM team WHERE cid='{$cid}' AND id='{$id}'";
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0) {
error("User name already exists");
}
$sql = "INSERT team (id, password, cid, date) VALUES ('{$id}', '{$password}', '{$cid}', Now())";
$result = mysql_query($sql);
$tid = mysql_insert_id();
$_SESSION["tid"] = $tid;
print "team id is {$tid} <br />";
$sql = "INSERT contestant (tid) VALUES ('{$tid}')";
for ($i = 0; $i < 3; $i++) {
mysql_query($sql);
示例12: header
require_once 'php/recaptchalib.php';
require_once 'php/email.php';
if ($loggedin) {
header('Location: summary.php');
exit;
}
$errors = array();
$name = $email = "";
if (isset($_POST['name']) || isset($_POST['email']) || isset($_POST['p']) || isset($_POST['pLength'])) {
if (!isset($_POST['name']) || !sanityCheck($_POST['name'], 'string', 3, 25)) {
$errors[] = $tr["ERR_USERNAME_LENGTH"];
} else {
if (SQL("SELECT 1 FROM accounts WHERE username = ?;", $_POST['name']) != null) {
$errors[] = $tr["ERR_USERNAME_EXITS"];
} else {
if (!checkUsername($_POST['name'])) {
$errors[] = $tr["ERR_USERNAME_FORMAT"];
} else {
$name = xssafe($_POST['name']);
}
}
}
if (!isset($_POST['email']) || !sanityCheck($_POST['email'], 'string', 7, 50) || !checkEmail($_POST['email'])) {
$errors[] = $tr["ERR_EMAIL"];
} else {
$email = $_POST['email'];
}
if (!isset($_POST['pLength']) || !sanityCheck($_POST['pLength'], 'numeric', 0, 3)) {
$errors[] = $tr["ERR_PASSWORD_LENGTH"];
} else {
$pLength = intval($_POST['pLength']);
示例13:
<?php
include 'db.php';
include 'functions.php';
?>
<?php
if (trim($_POST['username']) != "" && trim($_POST['email']) != "" && trim($_POST['password']) != "") {
if (checkUsername($_POST['username'])) {
?>
<?php
include 'webTop.php';
?>
<?php
echo "Error: el nombre de usuario ya está en uso.";
?>
<?php
include 'webBottom.php';
?>
<?php
} else {
if (checkEmail($_POST['email'])) {
?>
<?php
include 'webTop.php';
?>
<?php
echo "Error: el email ya está en uso.";
?>
<?php
include 'webBottom.php';
示例14: isset
<?php
require_once '../../config.php';
//Verify if admin is logged in
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : "";
switch ($action) {
case 'checkUsername':
checkUsername($_REQUEST['strUsername'], $con);
break;
default:
break;
}
function checkUsername($strUsername, $con)
{
//Query to check if username already exist
$strSql = "select vchr_username from tbl_student where vchr_username='{$strUsername}'";
$rstResult = mysqli_query($con, $strSql);
if (mysqli_num_rows($rstResult) == 1) {
//Set error messege to give a javascript alert as username already exist
$strResult = "Username already exist! Please change the username";
} else {
$strResult = "";
}
echo $strResult;
}
示例15: checkUsername
<?php
include "ShopAnytimeMVC.php";
if (isset($_GET['username'])) {
$user = checkUsername($_GET['username']);
if (count($user) < 1) {
print "valid";
} else {
print "invalid";
}
}
if ($_POST) {
$fname = $_POST['firstnameRegister'];
$lname = $_POST['lastnameRegister'];
$add = $_POST['addressRegister'];
$uname = $_POST['usernameRegister'];
$pwd = $_POST['passwordRegister'];
createAccount($fname, $lname, $add, $uname, $pwd);
header("Location: /eio/Assignment6/ShopAnytimeHome.php?Register='success'");
exit;
}
?>