本文整理汇总了PHP中validateUsername函数的典型用法代码示例。如果您正苦于以下问题:PHP validateUsername函数的具体用法?PHP validateUsername怎么用?PHP validateUsername使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validateUsername函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 <[email protected]> (2003-2009)
* @author Froxlor team <[email protected]> (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;
}
开发者ID:Git-Host,项目名称:Froxlor,代码行数:29,代码来源:function.checkUsername.php
示例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;
}
}
}
开发者ID:ansidev,项目名称:maya-notes-web,代码行数:14,代码来源:site.class.php
示例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;
}
}
}
开发者ID:renduples,项目名称:alibtob,代码行数:15,代码来源:SignIn.php
示例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 [email protected]";
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;
}
}
开发者ID:Atsumoriso,项目名称:Various-Tasks,代码行数:46,代码来源:save_user_info.php
示例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;
}
开发者ID:AlexandrosKal,项目名称:mylib,代码行数:24,代码来源:validation_functions.php
示例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]);
}
//.........这里部分代码省略.........
开发者ID:jprice,项目名称:EHCP,代码行数:101,代码来源:advanced_ftpserver.inc.php
示例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();
开发者ID:patrickglasgow,项目名称:HonsProject,代码行数:31,代码来源:index.php
示例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>
开发者ID:m2345,项目名称:tvstalkers,代码行数:31,代码来源:index.php
示例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']);
开发者ID:AlexandrosKal,项目名称:mylib,代码行数:31,代码来源:registerValidator.php
示例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);
}
开发者ID:albertlast,项目名称:SMF2.1,代码行数:45,代码来源:Subs-Auth.php
示例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();
}
开发者ID:Ralkage,项目名称:Elkarte,代码行数:18,代码来源:Register.controller.php
示例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']);
开发者ID:johnsonj561,项目名称:Web-Based-User-Management,代码行数:31,代码来源:register.php
示例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);
}
开发者ID:KeiroD,项目名称:Elkarte,代码行数:57,代码来源:Auth.subs.php
示例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';
开发者ID:HobbyNToys,项目名称:SysCP,代码行数:31,代码来源:admin_customers.php
示例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;
}
}
开发者ID:karlosjota,项目名称:sqlinjection,代码行数:37,代码来源:registro.php
示例16: registerMember
/**
* Registers a member to the forum.
*
* What it does:
* - Allows two types of interface: 'guest' and 'admin'. The first
* - includes hammering protection, the latter can perform the registration silently.
* - The strings used in the options array are assumed to be escaped.
* - Allows to perform several checks on the input, e.g. reserved names.
* - The function will adjust member statistics.
* - If an error is detected will fatal error on all errors unless return_errors is true.
*
* @package Members
* @uses Auth.subs.php
* @uses Mail.subs.php
* @param mixed[] $regOptions
* @param string $error_context
* @return integer the ID of the newly created member
*/
function registerMember(&$regOptions, $error_context = 'register')
{
global $scripturl, $txt, $modSettings, $user_info;
$db = database();
loadLanguage('Login');
// We'll need some external functions.
require_once SUBSDIR . '/Auth.subs.php';
require_once SUBSDIR . '/Mail.subs.php';
// Put any errors in here.
$reg_errors = Error_Context::context($error_context, 0);
// Registration from the admin center, let them sweat a little more.
if ($regOptions['interface'] == 'admin') {
is_not_guest();
isAllowedTo('moderate_forum');
} elseif ($regOptions['interface'] == 'guest') {
// You cannot register twice...
if (empty($user_info['is_guest'])) {
redirectexit();
}
// Make sure they didn't just register with this session.
if (!empty($_SESSION['just_registered']) && empty($modSettings['disableRegisterCheck'])) {
fatal_lang_error('register_only_once', false);
}
}
// What method of authorization are we going to use?
if (empty($regOptions['auth_method']) || !in_array($regOptions['auth_method'], array('password', 'openid'))) {
if (!empty($regOptions['openid'])) {
$regOptions['auth_method'] = 'openid';
} else {
$regOptions['auth_method'] = 'password';
}
}
// Spaces and other odd characters are evil...
$regOptions['username'] = trim(preg_replace('~[\\t\\n\\r \\x0B\\0\\x{A0}\\x{AD}\\x{2000}-\\x{200F}\\x{201F}\\x{202F}\\x{3000}\\x{FEFF}]+~u', ' ', $regOptions['username']));
// Valid emails only
require_once SUBSDIR . '/DataValidator.class.php';
if (!Data_Validator::is_valid($regOptions, array('email' => 'valid_email|required|max_length[255]'), array('email' => 'trim'))) {
$reg_errors->addError('bad_email');
}
validateUsername(0, $regOptions['username'], $error_context, !empty($regOptions['check_reserved_name']));
// Generate a validation code if it's supposed to be emailed.
$validation_code = '';
if ($regOptions['require'] == 'activation') {
$validation_code = generateValidationCode();
}
// If you haven't put in a password generate one.
if ($regOptions['interface'] == 'admin' && $regOptions['password'] == '' && $regOptions['auth_method'] == 'password') {
mt_srand(time() + 1277);
$regOptions['password'] = generateValidationCode();
$regOptions['password_check'] = $regOptions['password'];
} elseif ($regOptions['password'] != $regOptions['password_check'] && $regOptions['auth_method'] == 'password') {
$reg_errors->addError('passwords_dont_match');
}
// That's kind of easy to guess...
if ($regOptions['password'] == '') {
if ($regOptions['auth_method'] == 'password') {
$reg_errors->addError('no_password');
} else {
$regOptions['password'] = sha1(mt_rand());
}
}
// Now perform hard password validation as required.
if (!empty($regOptions['check_password_strength']) && $regOptions['password'] != '') {
$passwordError = validatePassword($regOptions['password'], $regOptions['username'], array($regOptions['email']));
// Password isn't legal?
if ($passwordError != null) {
$reg_errors->addError('profile_error_password_' . $passwordError);
}
}
// You may not be allowed to register this email.
if (!empty($regOptions['check_email_ban'])) {
isBannedEmail($regOptions['email'], 'cannot_register', $txt['ban_register_prohibited']);
}
// Check if the email address is in use.
$request = $db->query('', '
SELECT id_member
FROM {db_prefix}members
WHERE email_address = {string:email_address}
OR email_address = {string:username}
LIMIT 1', array('email_address' => $regOptions['email'], 'username' => $regOptions['username']));
if ($db->num_rows($request) != 0) {
$reg_errors->addError(array('email_in_use', array(htmlspecialchars($regOptions['email'], ENT_COMPAT, 'UTF-8'))));
//.........这里部分代码省略.........
开发者ID:Ralkage,项目名称:Elkarte,代码行数:101,代码来源:Members.subs.php
示例17: session_start
<?php
session_start();
require_once "php/database.php";
require_once "php/validation.php";
require_once "php/security.php";
require_once "php/storedprocedures.php";
require_once "php/error.php";
$db = connectToDatabase();
if ($db) {
$username = $_POST["username"];
$displayName = $_POST["displayname"];
$rawPassword = $_POST["password"];
$usernameValid = validateUsername($username);
$displaynameValid = validateDisplayname($displayName);
$passwordValid = validatePassword($rawPassword);
if ($usernameValid && $displaynameValid && $passwordValid) {
$hashedPass = hashPassword($rawPassword);
$salt = substr($hashedPass, 7, 22);
$results = registerUser($db, $username, $hashedPass, $salt, $displayName);
switch ($results[SP::ERROR]) {
case ERR::OK:
// It worked, try to log in.
$results = login($db, $username, $hashedPass);
switch ($results[SP::ERROR]) {
case ERR::OK:
$_SESSION['token'] = $results[SP::TOKEN];
$_SESSION['id'] = $results[USER::ID];
$_SESSION['permission'] = $results[PERMISSION::LEVEL];
// Give them a default avatar
copy("avatar/default.jpg", "avatar/" . $results[USER::ID] . ".jpg");
开发者ID:Blackdeathhh,项目名称:WDAAss2,代码行数:31,代码来源:createaccount.php
示例18: net2ftp_module_printBody
function net2ftp_module_printBody()
{
// --------------
// This function prints the login screen
// --------------
// -------------------------------------------------------------------------
// Global variables
// -------------------------------------------------------------------------
global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result;
if (isset($_POST["input_admin_username"]) == true) {
$input_admin_username = htmlEncode2(validateGenericInput($_POST["input_admin_username"]));
} else {
$input_admin_username = "";
}
if (isset($_POST["input_admin_password"]) == true) {
$input_admin_password = htmlEncode2(validateGenericInput($_POST["input_admin_password"]));
} else {
$input_admin_password = "";
}
if (isset($_POST["dbusername2"]) == true) {
$dbusername2 = validateUsername($_POST["dbusername2"]);
} else {
$dbusername2 = "";
}
if (isset($_POST["dbpassword2"]) == true) {
$dbpassword2 = validatePassword($_POST["dbpassword2"]);
} else {
$dbpassword2 = "";
}
if (isset($_POST["dbname2"]) == true) {
$dbname2 = validateGenericInput($_POST["dbname2"]);
} else {
$dbname2 = "";
}
if (isset($_POST["dbserver2"]) == true) {
$dbserver2 = validateGenericInput($_POST["dbserver2"]);
} else {
$dbserver2 = "";
}
$dbusername2_html = htmlEncode2($dbusername2);
$dbpassword2_html = htmlEncode2($dbpassword2);
$dbname2_html = htmlEncode2($dbname2);
$dbserver2_html = htmlEncode2($dbserver2);
if ($dbserver2 == "") {
$dbserver2 = "localhost";
}
// -------------------------------------------------------------------------
// Variables for all screens
// -------------------------------------------------------------------------
// Output variable
$net2ftp_output["admin_createtables"][] = "";
// Title
$title = __("Admin functions");
// Form name
$formname = "AdminForm";
// Read the SQL file
$filename = glueDirectories($net2ftp_globals["application_rootdir"], "create_tables.sql");
$handle = fopen($filename, "rb");
// Open the file for reading only
if ($handle == false) {
$net2ftp_output["admin_createtables"][] = __("The handle of file %1\$s could not be opened.", $filename);
}
clearstatcache();
// for filesize
$sqlquerystring = fread($handle, filesize($filename));
if ($sqlquerystring == false) {
$net2ftp_output["admin_createtables"][] = __("The file %1\$s could not be opened.", $filename);
}
$result1 = fclose($handle);
if ($result1 == false) {
$net2ftp_output["admin_createtables"][] = __("The handle of file %1\$s could not be closed.", $filename);
}
// Split the SQL file in individual queries
$sqlquerypieces = explode("\n", $sqlquerystring);
// -------------------------------------------------------------------------
// Variables for screen 1
// -------------------------------------------------------------------------
if ($net2ftp_globals["screen"] == 1) {
// Next screen
$nextscreen = 2;
// Back and forward buttons
$back_onclick = "document.forms['" . $formname . "'].state.value='admin';document.forms['" . $formname . "'].screen.value='1';document.forms['" . $formname . "'].submit();";
$forward_onclick = "document.forms['" . $formname . "'].submit();";
} elseif ($net2ftp_globals["screen"] == 2) {
// Next screen
$nextscreen = 1;
// Back and forward buttons
$back_onclick = "document.forms['" . $formname . "'].state.value='admin';document.forms['" . $formname . "'].screen.value='1';document.forms['" . $formname . "'].submit();";
$dbpassword2_length = strlen($dbpassword2);
// ------------------------------------
// Connect
// ------------------------------------
$mydb = mysql_connect($dbserver2, $dbusername2, $dbpassword2);
if ($mydb == false) {
$net2ftp_output["admin_createtables"][] = __("The connection to the server <b>%1\$s</b> could not be set up. Please check the database settings you've entered.", $dbserver2_html) . "\n";
}
// ------------------------------------
// Select
// ------------------------------------
if ($mydb != false) {
//.........这里部分代码省略.........
开发者ID:jamiebatch452,项目名称:Open-Game-Panel,代码行数:101,代码来源:admin_createtables.inc.php
示例19: net2ftp_module_printBody
function net2ftp_module_printBody()
{
// --------------
// This function prints the copy/move/delete screen
// --------------
// -------------------------------------------------------------------------
// Global variables
// -------------------------------------------------------------------------
global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result, $net2ftp_output;
if (isset($_POST["list"]) == true) {
$list = getSelectedEntries($_POST["list"]);
} else {
$list = "";
}
if (isset($_POST["ftpserver2"]) == true) {
$net2ftp_globals["ftpserver2"] = validateFtpserver($_POST["ftpserver2"]);
} else {
$net2ftp_globals["ftpserver2"] = "";
}
if (isset($_POST["ftpserverport2"]) == true) {
$net2ftp_globals["ftpserverport2"] = validateFtpserverport($_POST["ftpserverport2"]);
} else {
$net2ftp_globals["ftpserverport2"] = "";
}
if (isset($_POST["username2"]) == true) {
|
请发表评论