本文整理汇总了PHP中validateUsername函数的典型用法代码示例。如果您正苦于以下问题:PHP validateUsername函数的具体用法?PHP validateUsername怎么用?PHP validateUsername使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validateUsername函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkUsername
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function checkUsername($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
{
if (!isset($allnewfieldvalues['customer_mysqlprefix'])) {
$allnewfieldvalues['customer_mysqlprefix'] = Settings::Get('customer.mysqlprefix');
}
$returnvalue = array();
if (validateUsername($newfieldvalue, Settings::Get('panel.unix_names'), 14 - strlen($allnewfieldvalues['customer_mysqlprefix'])) === true) {
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_OK);
} else {
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'accountprefixiswrong');
}
return $returnvalue;
}
示例2: UserSignUp
function UserSignUp()
{
if (isset($_POST['su-btn-submit'])) {
if (isset($_POST['email']) && isset($_POST['username']) && isset($_POST['password']) && isset($_POST['confirm-password']) && isset($_POST['tos-checkbox'])) {
//Get submitted values
$email = validateEmail($_POST['email']) ? 1 : 0;
$user = validateUsername($_POST['username']) ? 1 : 0;
$password = validatePassword($_POST['password']) ? 1 : 0;
$password_hash = password_hash($_POST['password'], PASSWORD_DEFAULT);
$cf_pass = password_verify($_POST['confirm-password'], $password_hash) ? 1 : 0;
$tos_cb = $_POST['tos-checkbox'] ? 1 : 0;
}
}
}
示例3: validate
public function validate($retType)
{
parent::validate($retType);
copyArray($_POST, $fv, 'username');
if (validateUsername($fv['username']) == false) {
$rets[] = array('msg' => '<br/>Invalid username!', 'field' => 'username');
}
if (isset($rets)) {
if (isset($retType) && $retType == RT_JSON) {
return outputJson($rets);
} else {
return $rets;
}
}
}
示例4: checkingFormAndSaveNewUser
/**
* Functions for checking & validating form
*/
function checkingFormAndSaveNewUser()
{
include_once 'validate.php';
if (isset($_POST['username']) && isset($_POST['email']) && isset($_POST['password']) && isset($_POST['confirm_password']) && isset($_POST['agree'])) {
$username = cleanInput($_POST['username']);
$email = cleanInput($_POST['email']);
$password = cleanInput($_POST['password']);
$confirm_password = cleanInput($_POST['confirm_password']);
$agree = $_POST['agree'];
if (validateUsername($username) == false) {
echo "Name should contain capitals and lower case, not less than 2 symbols";
exit;
}
$email = filter_var($email, FILTER_SANITIZE_EMAIL);
if (validateEmail($email) == false) {
echo "E-mail should be in the format of name@example.com";
exit;
}
if (validateLength($password, 6) == false) {
echo "Password should contain not less than 6 symbols";
exit;
}
if (validateConfirm($password, $confirm_password) == false) {
echo "Passwords do not match";
exit;
}
//$password_hash=password_hash($password, PASSWORD_DEFAULT); //PHP 5 >= 5.5.0
$password_hash = md5($password);
$dir_for_saved_users = "./user/";
if (!is_dir($dir_for_saved_users)) {
mkdir($dir_for_saved_users, 0777, true);
}
chmod('./user/', 0777);
$filename = $dir_for_saved_users . "user_info";
$new_user_info = $username . ":" . $email . ":" . $password_hash . "\n";
file_put_contents($filename, $new_user_info, FILE_APPEND);
//$_SESSION['name'] = $username;
echo "You have signed up successfully! <a href='index.php'>Log in</a>";
} else {
echo "All fields are required. Please fill in all the fields.";
exit;
}
}
示例5: getDataErrors
function getDataErrors($data)
{
$messages = [];
if (empty($data['first_name']) || empty($data['last_name']) || empty($data['username']) || empty($data['password'])) {
$messages[] = 'Παρακαλούμε συμπληρώστε όλα τα πεδία';
return $messages;
}
if (!validateName($data['first_name'])) {
$messages[] = 'Το όνομα σας περιέχει μη επιτρεπτούς χαρακτήρες. Παρακαλούμε εισάγετε μόνο γράμματα της αλφαβήτας';
}
if (!validateName($data['last_name'])) {
$messages[] = 'Το επώνυμό σας περιέχει μη επιτρεπτούς χαρακτήρες. Παρακαλούμε εισάγετε μόνο γράμματα της αλφαβήτας';
}
if (!validateUsername($data['username'])) {
$messages[] = 'Το username σας περιέχει μη πετρεπτούς χαρακτήρες. Παρακαλούμε εισάγετε μόνο λατινικούς χαρακτήρες και αριθμούς';
}
if (!validateEmail($data['email'])) {
$messages[] = 'Το e-mail σας δεν είναι έγκυρο. Παρακούμε εισάγετε ένα έγκυρο e-mail.';
}
if (!validatePassword($data['password'])) {
$messages[] = 'Μη επιτρεπτός κωδικός. Ο κωδικός σας πρέπει να περιλαμβάνει τουλάχιστον 8 ψηφία.';
}
return $messages;
}
示例6: net2ftp_module_printBody
function net2ftp_module_printBody()
{
// --------------
// This function prints the login screen
// --------------
// -------------------------------------------------------------------------
// Global variables
// -------------------------------------------------------------------------
global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result, $net2ftp_output;
if (isset($_POST["troubleshoot_ftpserver"]) == true) {
$troubleshoot_ftpserver = validateFtpserver($_POST["troubleshoot_ftpserver"]);
} else {
$troubleshoot_ftpserver = "";
}
if (isset($_POST["troubleshoot_ftpserverport"]) == true) {
$troubleshoot_ftpserverport = validateFtpserverport($_POST["troubleshoot_ftpserverport"]);
} else {
$troubleshoot_ftpserverport = "";
}
if (isset($_POST["troubleshoot_username"]) == true) {
$troubleshoot_username = validateUsername($_POST["troubleshoot_username"]);
} else {
$troubleshoot_username = "";
}
if (isset($_POST["troubleshoot_password"]) == true) {
$troubleshoot_password = validatePassword($_POST["troubleshoot_password"]);
} else {
$troubleshoot_password = "";
}
if (isset($_POST["troubleshoot_directory"]) == true) {
$troubleshoot_directory = validateDirectory($_POST["troubleshoot_directory"]);
} else {
$troubleshoot_directory = "";
}
if (isset($_POST["troubleshoot_passivemode"]) == true) {
$troubleshoot_passivemode = validatePassivemode($_POST["troubleshoot_passivemode"]);
} else {
$troubleshoot_passivemode = "";
}
$troubleshoot_ftpserver_html = htmlEncode2($troubleshoot_ftpserver);
$troubleshoot_ftpserverport_html = htmlEncode2($troubleshoot_ftpserverport);
$troubleshoot_username_html = htmlEncode2($troubleshoot_username);
$troubleshoot_directory_html = htmlEncode2($troubleshoot_directory);
$troubleshoot_passivemode_html = htmlEncode2($troubleshoot_passivemode);
// -------------------------------------------------------------------------
// Variables for all screens
// -------------------------------------------------------------------------
// Title
$title = __("Troubleshoot an FTP server");
// Form name
$formname = "AdvancedForm";
// -------------------------------------------------------------------------
// Variables for screen 1
// -------------------------------------------------------------------------
if ($net2ftp_globals["screen"] == 1) {
// Next screen
$nextscreen = 2;
// Back and forward buttons
$back_onclick = "document.forms['" . $formname . "'].state.value='advanced';document.forms['" . $formname . "'].screen.value='1';document.forms['" . $formname . "'].submit();";
$forward_onclick = "document.forms['" . $formname . "'].submit();";
} elseif ($net2ftp_globals["screen"] == 2) {
// Back and forward buttons
$back_onclick = "document.forms['" . $formname . "'].state.value='advanced_ftpserver'; document.forms['" . $formname . "'].submit();";
// Initial checks
if ($troubleshoot_passivemode != "yes") {
$troubleshoot_passivemode = "no";
}
// Connect
setStatus(1, 10, __("Connecting to the FTP server"));
$conn_id = ftp_connect("{$troubleshoot_ftpserver}", $troubleshoot_ftpserverport);
// Login with username and password
setStatus(2, 10, __("Logging into the FTP server"));
$ftp_login_result = ftp_login($conn_id, $troubleshoot_username, $troubleshoot_password);
// Passive mode
if ($troubleshoot_passivemode == "yes") {
setStatus(3, 10, __("Setting the passive mode"));
$ftp_pasv_result = ftp_pasv($conn_id, TRUE);
} else {
$ftp_pasv_result = true;
}
// Get the FTP system type
setStatus(4, 10, __("Getting the FTP system type"));
$ftp_systype_result = ftp_systype($conn_id);
// Change the directory
setStatus(5, 10, __("Changing the directory"));
$ftp_chdir_result = ftp_chdir($conn_id, $troubleshoot_directory);
// Get the current directory from the FTP server
setStatus(6, 10, __("Getting the current directory"));
$ftp_pwd_result = ftp_pwd($conn_id);
// Try to get a raw list
setStatus(7, 10, __("Getting the list of directories and files"));
$ftp_rawlist_result = ftp_rawlist($conn_id, "-a");
if (sizeof($ftp_rawlist_result) <= 1) {
$ftp_rawlist_result = ftp_rawlist($conn_id, "");
}
// Parse the list
setStatus(8, 10, __("Parsing the list of directories and files"));
for ($i = 0; $i < sizeof($ftp_rawlist_result); $i++) {
$parsedlist[$i] = ftp_scanline($troubleshoot_directory, $ftp_rawlist_result[$i]);
}
//.........这里部分代码省略.........
示例7: function
require 'emailConf.php';
include 'addUser.php';
include 'login.php';
include 'logout.php';
include 'activation.php';
include 'notConfirmed.php';
\Slim\Slim::registerAutoloader();
$app = new Slim\Slim();
// start it up and declare our routes
$app->get('/activate/:activation', 'activation');
$app->get('/notConfirmed/resend', 'nc_resendActivation');
$app->get('/notConfirmed/change/:email', 'nc_changeEmail');
$app->get('/notConfirmed/delete', 'nc_deleteAccount');
$app->post('/user/register/', 'addUser');
$app->post('/user/login/', 'login');
$app->get('/user/logout/', 'logOut');
$app->get('/user/register/validate/email', function () use($app) {
validateEmail($app->request()->get('email'));
});
$app->get('/user/register/validate/username', function () use($app) {
validateUsername($app->request()->get('username'));
});
$app->post('/user/resetPassword/set', function () use($app) {
include 'resetPassword.php';
resetPassword();
});
$app->post('/user/resetPassword/request', function () use($app) {
include 'resetPassword.php';
sendResetPassword();
});
$app->run();
示例8:
</aside>
<section id="main_section"><!-- meet of the website-->
<div>
<h3>My Info</h3>
<div id="result" style="padding:5px; color:red">
<?php
if (isset($_POST['email'])) {
if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$result = $user->setEmail($_POST['email']);
echo $result;
} else {
echo "invalid email";
}
} else {
if (isset($_POST['username'])) {
if (validateUsername($_POST['username'])) {
//continue
$res = $user->setUsername($_POST['username']);
echo $res;
} else {
echo "Username already taken.";
}
} else {
if (isset($_POST['aboutMe'])) {
$res2 = $user->setAboutMe($_POST['aboutMe']);
echo $res2;
}
}
}
?>
</div>
示例9: switch
<?php
require 'models/validation_functions.php';
if (!empty($_POST['value'])) {
switch ($_POST['field']) {
case 1:
$res = validateUsername($_POST['value']);
if (!$res) {
echo 'Το username σας περιέχει μη πετρεπτούς χαρακτήρες. Παρακαλούμε εισάγετε μόνο λατινικούς χαρακτήρες και αριθμούς';
}
break;
case 2:
$res = validateName($_POST['value']);
if (!$res) {
echo 'Το όνομα σας περιέχει μη επιτρεπτούς χαρακτήρες. Παρακαλούμε εισάγετε μόνο γράμματα της αλφαβήτας';
}
break;
case 3:
$res = validateName($_POST['value']);
if (!$res) {
echo 'Το επώνυμο σας περιέχει μη επιτρεπτούς χαρακτήρες. Παρακαλούμε εισάγετε μόνο γράμματα της αλφαβήτας';
}
break;
case 4:
$res = validateEmail($_POST['value']);
if (!$res) {
echo 'Το e-mail σας δεν είναι έγκυρο. Παρακούμε εισάγετε ένα έγκυρο e-mail.';
}
break;
case 5:
$res = validatePassword($_POST['value']);
示例10: resetPassword
/**
* Generates a random password for a user and emails it to them.
* - called by Profile.php when changing someone's username.
* - checks the validity of the new username.
* - generates and sets a new password for the given user.
* - mails the new password to the email address of the user.
* - if username is not set, only a new password is generated and sent.
*
* @param int $memID
* @param string $username = null
*/
function resetPassword($memID, $username = null)
{
global $scripturl, $context, $txt, $sourcedir, $modSettings, $smcFunc, $language;
// Language... and a required file.
loadLanguage('Login');
require_once $sourcedir . '/Subs-Post.php';
// Get some important details.
$request = $smcFunc['db_query']('', '
SELECT member_name, email_address, lngfile
FROM {db_prefix}members
WHERE id_member = {int:id_member}', array('id_member' => $memID));
list($user, $email, $lngfile) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
if ($username !== null) {
$old_user = $user;
$user = trim($username);
}
// Generate a random password.
$newPassword = substr(preg_replace('/\\W/', '', md5(mt_rand())), 0, 10);
$newPassword_sha1 = sha1(strtolower($user) . $newPassword);
// Do some checks on the username if needed.
if ($username !== null) {
validateUsername($memID, $user);
// Update the database...
updateMemberData($memID, array('member_name' => $user, 'passwd' => $newPassword_sha1));
} else {
updateMemberData($memID, array('passwd' => $newPassword_sha1));
}
call_integration_hook('integrate_reset_pass', array($old_user, $user, $newPassword));
$replacements = array('USERNAME' => $user, 'PASSWORD' => $newPassword);
$emaildata = loadEmailTemplate('change_password', $replacements, empty($lngfile) || empty($modSettings['userLanguage']) ? $language : $lngfile);
// Send them the email informing them of the change - then we're done!
sendmail($email, $emaildata['subject'], $emaildata['body'], null, null, false, 0);
}
示例11: _registerCheckUsername
/**
* See if a username already exists.
*/
private function _registerCheckUsername()
{
global $context;
// This is XML!
loadTemplate('Xml');
$context['sub_template'] = 'check_username';
$context['checked_username'] = isset($_GET['username']) ? un_htmlspecialchars($_GET['username']) : '';
$context['valid_username'] = true;
// Clean it up like mother would.
$context['checked_username'] = preg_replace('~[\\t\\n\\r \\x0B\\0\\x{A0}\\x{AD}\\x{2000}-\\x{200F}\\x{201F}\\x{202F}\\x{3000}\\x{FEFF}]+~u', ' ', $context['checked_username']);
$errors = Error_Context::context('valid_username', 0);
require_once SUBSDIR . '/Auth.subs.php';
validateUsername(0, $context['checked_username'], 'valid_username', true, false);
$context['valid_username'] = !$errors->hasErrors();
}
示例12: strip_tags
<?php
require_once 'connect.php';
//flag used to represent successful registration and valid username
$isValidPassword = false;
$isValidUsername = false;
//make sure username isn't already being used
//set $isValid to false if username is not valid
$username = strip_tags($_POST['username']);
if (validateUsername($username, $link)) {
$isValidUsername = true;
}
//crypt password to create hash for safe DB storage
$salt = "X1K\$6B8";
$password1 = strip_tags($_POST['password1']);
$password2 = strip_tags($_POST['password2']);
$password1 = crypt($password1, $salt);
$password2 = crypt($password2, $salt);
//make sure passwords match
if (validatePasswords($password1, $password2)) {
$isValidPassword = true;
}
//If username is valid and passwords match - update database!
if ($isValidUsername && $isValidPassword) {
//collect user info
$firstName = strip_tags($_POST['firstName']);
$lastName = strip_tags($_POST['lastName']);
$street = strip_tags($_POST['street']);
$city = strip_tags($_POST['city']);
$state = strip_tags($_POST['state']);
$zip = strip_tags($_POST['zip']);
示例13: resetPassword
/**
* Generates a random password for a user and emails it to them.
*
* What it does:
* - called by ProfileOptions controller when changing someone's username.
* - checks the validity of the new username.
* - generates and sets a new password for the given user.
* - mails the new password to the email address of the user.
* - if username is not set, only a new password is generated and sent.
*
* @package Authorization
* @param int $memID
* @param string|null $username = null
*/
function resetPassword($memID, $username = null)
{
global $modSettings, $language, $user_info;
// Language... and a required file.
loadLanguage('Login');
require_once SUBSDIR . '/Mail.subs.php';
// Get some important details.
require_once SUBSDIR . '/Members.subs.php';
$result = getBasicMemberData($memID, array('preferences' => true));
$user = $result['member_name'];
$email = $result['email_address'];
$lngfile = $result['lngfile'];
if ($username !== null) {
$old_user = $user;
$user = trim($username);
}
// Generate a random password.
require_once EXTDIR . '/PasswordHash.php';
$t_hasher = new PasswordHash(8, false);
$newPassword = substr(preg_replace('/\\W/', '', md5(mt_rand())), 0, 10);
$newPassword_sha256 = hash('sha256', strtolower($user) . $newPassword);
$db_hash = $t_hasher->HashPassword($newPassword_sha256);
// Do some checks on the username if needed.
if ($username !== null) {
$errors = Error_Context::context('reset_pwd', 0);
validateUsername($memID, $user, 'reset_pwd');
// If there are "important" errors and you are not an admin: log the first error
// Otherwise grab all of them and don't log anything
$error_severity = $errors->hasErrors(1) && !$user_info['is_admin'] ? 1 : null;
foreach ($errors->prepareErrors($error_severity) as $error) {
fatal_error($error, $error_severity === null ? false : 'general');
}
// Update the database...
updateMemberData($memID, array('member_name' => $user, 'passwd' => $db_hash));
} else {
updateMemberData($memID, array('passwd' => $db_hash));
}
call_integration_hook('integrate_reset_pass', array($old_user, $user, $newPassword));
$replacements = array('USERNAME' => $user, 'PASSWORD' => $newPassword);
$emaildata = loadEmailTemplate('change_password', $replacements, empty($lngfile) || empty($modSettings['userLanguage']) ? $language : $lngfile);
// Send them the email informing them of the change - then we're done!
sendmail($email, $emaildata['subject'], $emaildata['body'], null, null, false, 0);
}
示例14: intval
$accountnumber = intval($settings['system']['lastaccountnumber']);
$loginname = validate($_POST['loginname'], 'loginname', '/^[a-z0-9\\-_]+$/i');
// Accounts which match systemaccounts are not allowed, filtering them
if (preg_match('/^' . preg_quote($settings['customer']['accountprefix'], '/') . '([0-9]+)/', $loginname)) {
standard_error('loginnameissystemaccount', $settings['customer']['accountprefix']);
}
} else {
$accountnumber = intval($settings['system']['lastaccountnumber']) + 1;
$loginname = $settings['customer']['accountprefix'] . $accountnumber;
}
// Check if the account already exists
$loginname_check = $db->query_first("SELECT `loginname` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `loginname` = '" . $db->escape($loginname) . "'");
$loginname_check_admin = $db->query_first("SELECT `loginname` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `loginname` = '" . $db->escape($loginname) . "'");
if (strtolower($loginname_check['loginname']) == strtolower($loginname) || strtolower($loginname_check_admin['loginname']) == strtolower($loginname)) {
standard_error('loginnameexists', $loginname);
} elseif (!validateUsername($loginname, $settings['panel']['unix_names'], 14 - strlen($settings['customer']['mysqlprefix']))) {
standard_error('loginnameiswrong', $loginname);
}
$guid = intval($settings['system']['lastguid']) + 1;
$documentroot = makeCorrectDir($settings['system']['documentroot_prefix'] . '/' . $loginname);
if ($service_active == 1) {
$service_active = '1';
if (!isset($servicestart_date) || $servicestart_date == '0000-00-00') {
$servicestart_date = date('Y-m-d');
}
} else {
$service_active = '0';
$servicestart_date = '0000-00-00';
}
if ($calc_tax != '1') {
$calc_tax = '0';
示例15: register
function register($db)
{
//Primero obtenemos las entradas de la forma
$user = mysql_real_escape_string($_POST['user']);
//usamos un string absoluto para evitar sqlinjection
$password = sha1($_POST['password']);
//encriptamos el password
$rpassword = sha1($_POST['rpassword']);
//encriptamos la confirmación del password
//Ahora validamos, si la validación es correcta procedemos a ejecutar la inserción en la DB
if (validateInputs($user, $password, $rpassword)) {
//ya hemos validado los inputs, ahora comprobemos que el usuario este libre
if (!validateUsername($db, $user)) {
//ahora creamos nuestra query
$query = "INSERT INTO users(user,password) values('{$user}','{$password}')";
try {
$db->beginTransaction();
//iniciamos transacción DBO
$db->exec($query);
//ejecutamos la inserción de datos y el registro
$db->commit();
//terminamos la conexión exitosamente
echo "Registro completado\n su usuario:{$user} y su password:{$_POST['password']}" . "\n Entre <a href=\"bienvenido.php\">Aqui</a> para ir a la pagina de bienvenida";
} catch (Exception $e) {
$db->rollBack();
//Si falla la conexión, tiramos la conexión
echo "<p>Ocurrio un error, el registro no pudo ser completado</p>";
}
} else {
echo "<p>El nombre de usuario ya existe, por lo que no se pudo completar el registro.</p>";
}
} else {
echo "<p>Los datos de registro son invalidos, intente de nuevo.</p>";
$db = null;
die;
}
}