mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 09:19:01 +00:00
Damn its early in the morning :D Oh well! Register works with a callback function. shows which fields are correctly filled in and which not yet. It runs quite smooth. Off to bed now!
--HG-- branch : quitta-gsoc-2013
This commit is contained in:
parent
79e7b18bc8
commit
8ee559e662
5 changed files with 102 additions and 75 deletions
|
@ -84,10 +84,10 @@ class Users{
|
||||||
return "Username must be 5 or more characters.";
|
return "Username must be 5 or more characters.";
|
||||||
}elseif ( !preg_match( '/^[a-z0-9\.]*$/', $username ) ){
|
}elseif ( !preg_match( '/^[a-z0-9\.]*$/', $username ) ){
|
||||||
return "Username can only contain numbers and letters.";
|
return "Username can only contain numbers and letters.";
|
||||||
}elseif ( sql :: db_query( "SELECT COUNT(*) FROM {users} WHERE name = :name", array(
|
/*}elseif ( sql :: db_query( "SELECT COUNT(*) FROM {users} WHERE name = :name", array(
|
||||||
':name' => $username
|
':name' => $username
|
||||||
) ) -> fetchField() ){
|
) ) -> fetchField() ){
|
||||||
return "Username " . $username . " is in use.";
|
return "Username " . $username . " is in use.";*/
|
||||||
}else{
|
}else{
|
||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
||||||
|
@ -139,12 +139,12 @@ class Users{
|
||||||
public function checkEmail( $email )
|
public function checkEmail( $email )
|
||||||
{
|
{
|
||||||
if ( isset( $email ) ){
|
if ( isset( $email ) ){
|
||||||
if ( !validEmail( $email ) ){
|
if ( !Users::validEmail( $email ) ){
|
||||||
return "Email address is not valid.";
|
return "Email address is not valid.";
|
||||||
}elseif ( db_query( "SELECT COUNT(*) FROM {users} WHERE mail = :mail", array(
|
/*}elseif ( db_query( "SELECT COUNT(*) FROM {users} WHERE mail = :mail", array(
|
||||||
':mail' => $email
|
':mail' => $email
|
||||||
) ) -> fetchField() ){
|
) ) -> fetchField() ){
|
||||||
return "Email is in use.";
|
return "Email is in use.";*/
|
||||||
}else{
|
}else{
|
||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
||||||
|
@ -153,49 +153,50 @@ class Users{
|
||||||
}
|
}
|
||||||
return "fail";
|
return "fail";
|
||||||
}
|
}
|
||||||
public function validEmail( $email )
|
|
||||||
{
|
public function validEmail( $email ){
|
||||||
$isValid = true;
|
$isValid = true;
|
||||||
$atIndex = strrpos( $email, "@" );
|
$atIndex = strrpos( $email, "@" );
|
||||||
if ( is_bool( $atIndex ) && !$atIndex ){
|
if ( is_bool( $atIndex ) && !$atIndex ){
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}else{
|
}else{
|
||||||
$domain = substr( $email, $atIndex + 1 );
|
$domain = substr( $email, $atIndex + 1 );
|
||||||
$local = substr( $email, 0, $atIndex );
|
$local = substr( $email, 0, $atIndex );
|
||||||
$localLen = strlen( $local );
|
$localLen = strlen( $local );
|
||||||
$domainLen = strlen( $domain );
|
$domainLen = strlen( $domain );
|
||||||
if ( $localLen < 1 || $localLen > 64 ){
|
if ( $localLen < 1 || $localLen > 64 ){
|
||||||
// local part length exceeded
|
// local part length exceeded
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}else if ( $domainLen < 1 || $domainLen > 255 ){
|
}else if ( $domainLen < 1 || $domainLen > 255 ){
|
||||||
// domain part length exceeded
|
// domain part length exceeded
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}else if ( $local[0] == '.' || $local[$localLen - 1] == '.' ){
|
}else if ( $local[0] == '.' || $local[$localLen - 1] == '.' ){
|
||||||
// local part starts or ends with '.'
|
// local part starts or ends with '.'
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}else if ( preg_match( '/\\.\\./', $local ) ){
|
}else if ( preg_match( '/\\.\\./', $local ) ){
|
||||||
// local part has two consecutive dots
|
// local part has two consecutive dots
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}else if ( !preg_match( '/^[A-Za-z0-9\\-\\.]+$/', $domain ) ){
|
}else if ( !preg_match( '/^[A-Za-z0-9\\-\\.]+$/', $domain ) ){
|
||||||
// character not valid in domain part
|
// character not valid in domain part
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}else if ( preg_match( '/\\.\\./', $domain ) ){
|
}else if ( preg_match( '/\\.\\./', $domain ) ){
|
||||||
// domain part has two consecutive dots
|
// domain part has two consecutive dots
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}else if ( !preg_match( '/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace( "\\\\", "", $local ) ) ){
|
}else if ( !preg_match( '/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace( "\\\\", "", $local ) ) ){
|
||||||
// character not valid in local part unless
|
// character not valid in local part unless
|
||||||
// local part is quoted
|
// local part is quoted
|
||||||
if ( !preg_match( '/^"(\\\\"|[^"])+"$/', str_replace( "\\\\", "", $local ) ) ){
|
if ( !preg_match( '/^"(\\\\"|[^"])+"$/', str_replace( "\\\\", "", $local ) ) ){
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( $isValid && !( checkdnsrr( $domain, "MX" ) || checkdnsrr( $domain, "A" ) ) ){
|
if ( $isValid && !( checkdnsrr( $domain, "MX" ) || checkdnsrr( $domain, "A" ) ) ){
|
||||||
// domain not found in DNS
|
// domain not found in DNS
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $isValid;
|
return $isValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateSALT( $length = 2 )
|
public function generateSALT( $length = 2 )
|
||||||
{
|
{
|
||||||
// start with a blank salt
|
// start with a blank salt
|
||||||
|
|
|
@ -11,19 +11,23 @@ welcome_message = "Welcome! Please fill in the following fields to get your new
|
||||||
|
|
||||||
username_tag = "Desired Username"
|
username_tag = "Desired Username"
|
||||||
username_tooltip = "5-12 lower-case characters and numbers. The login (username) you create here will be your login name. The name of your game characters will be chosen later on."
|
username_tooltip = "5-12 lower-case characters and numbers. The login (username) you create here will be your login name. The name of your game characters will be chosen later on."
|
||||||
|
username_default = "Username"
|
||||||
|
|
||||||
password_tag = "Desired Password"
|
password_tag = "Desired Password"
|
||||||
password_tooltip = "Pick a hard to guess password (5-20 characters)."
|
password_tooltip = "Pick a hard to guess password (5-20 characters)."
|
||||||
password_message = "Password must be 5-20 characters."
|
password_message = "Password must be 5-20 characters."
|
||||||
|
password_default = "Password"
|
||||||
|
|
||||||
cpassword_tag = "Confirm Password"
|
cpassword_tag = "Confirm Password"
|
||||||
cpassword_tooltip = "Retype your Password"
|
cpassword_tooltip = "Retype your Password"
|
||||||
cpassword_message = "Retype your Password"
|
cpassword_message = "Retype your Password"
|
||||||
|
cpassword_default = "Re-enter Password"
|
||||||
|
|
||||||
email_tag = "Email Address"
|
email_tag = "Email Address"
|
||||||
email_tooltip = "Email Address to which a confirmation email will be sent."
|
email_tooltip = "Email Address to which a confirmation email will be sent."
|
||||||
email_message = "Please verify that the e-mail address you enter here is valid and will remain valid in the future. It will only be used to manage your Ryzom Core account."
|
email_message = "Please verify that the e-mail address you enter here is valid and will remain valid in the future. It will only be used to manage your Ryzom Core account."
|
||||||
|
email_default = "Email"
|
||||||
|
|
||||||
tac_tag = "YES, I agree to the terms of service."
|
tac_tag = "YES, I agree to the <a href="toc.php">terms of service.</a>"
|
||||||
tac_message = "You must accept the Terms of Service."
|
tac_message = "You must accept the Terms of Service."
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
require( '../../../ams_lib/libinclude.php' );
|
|
||||||
|
|
||||||
|
|
||||||
function add_user(){
|
function add_user(){
|
||||||
|
|
|
@ -2,17 +2,24 @@
|
||||||
|
|
||||||
require( '../config.php' );
|
require( '../config.php' );
|
||||||
require( '../../ams_lib/libinclude.php' );
|
require( '../../ams_lib/libinclude.php' );
|
||||||
|
//default page
|
||||||
|
$page = 'login';
|
||||||
|
|
||||||
|
|
||||||
if ( isset( $_POST["function"] ) ){
|
if ( isset( $_POST["function"] ) ){
|
||||||
require( "inc/" . $_POST["function"] . ".php" );
|
require( "inc/" . $_POST["function"] . ".php" );
|
||||||
$return = $_POST["function"]();
|
$tempReturn = $_POST["function"]();
|
||||||
|
$functionReturn = array_merge($tempReturn,$_POST);
|
||||||
|
if ( isset($_POST["callBack"])){
|
||||||
|
$page = $_POST["callBack"];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function loadpage ( $page ){
|
function loadpage ( $page ){
|
||||||
require_once( 'autoload/' . $page . '.php' );
|
require_once( 'autoload/' . $page . '.php' );
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = 'login';
|
|
||||||
if ( isset( $_GET["page"] ) ){
|
if ( isset( $_GET["page"] ) ){
|
||||||
$page = $_GET["page"];
|
$page = $_GET["page"];
|
||||||
}
|
}
|
||||||
|
@ -21,7 +28,12 @@ if ( isset( $_GET["page"] ) ){
|
||||||
if($page == 'login' || $page == 'register'){
|
if($page == 'login' || $page == 'register'){
|
||||||
$no_visible_elements = 'TRUE';
|
$no_visible_elements = 'TRUE';
|
||||||
}
|
}
|
||||||
// temporary set permission to 2 which = admin mode
|
|
||||||
$return = array( 'permission' => 1, 'no_visible_elements' => $no_visible_elements );
|
if ( isset($functionReturn) ){
|
||||||
|
$return = array_merge(array( 'permission' => 1, 'no_visible_elements' => $no_visible_elements ),$functionReturn);
|
||||||
|
}else{
|
||||||
|
$return = array( 'permission' => 1, 'no_visible_elements' => $no_visible_elements );
|
||||||
|
}
|
||||||
|
//print_r($return);
|
||||||
|
|
||||||
helpers :: loadTemplate( $page , $return );
|
helpers :: loadTemplate( $page , $return );
|
||||||
|
|
|
@ -12,63 +12,74 @@
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-info">
|
||||||
{$welcome_message}
|
{$welcome_message}
|
||||||
</div>
|
</div>
|
||||||
<form id="signup" class="form-vertical" method="post" action="users::add_user()">
|
<form id="signup" class="form-vertical" method="post" action="index.php">
|
||||||
<legend>Register Account</legend>
|
<legend>{$title}</legend>
|
||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group {if isset($USERNAME_ERROR) and $USERNAME_ERROR eq "TRUE"}error{else if
|
||||||
<label class="control-label">Username</label>
|
isset($USERNAME) and $USERNAME eq "success"}success{else}{/if}">
|
||||||
|
<label class="control-label">{$username_tag}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<div class="input-prepend">
|
<div class="input-prepend">
|
||||||
<span class="add-on"><i class="icon-user"></i></span>
|
<span class="add-on"><i class="icon-user"></i></span>
|
||||||
<input type="text" class="input-xlarge" id="Username" name="Username" placeholder="Username">
|
<input type="text" class="input-xlarge" id="Username" name="Username" placeholder="{$username_default}" {if isset($Username)}value="{$Username}"{/if}>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group {if isset($PASSWORD_ERROR) and $PASSWORD_ERROR eq "TRUE"}error{else if
|
||||||
<label class="control-label">Password</label>
|
isset($PASSWORD) and $PASSWORD eq "success"}success{else}{/if}">
|
||||||
|
<label class="control-label">{$password_tag}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<div class="input-prepend">
|
<div class="input-prepend">
|
||||||
<span class="add-on"><i class="icon-lock"></i></span>
|
<span class="add-on"><i class="icon-lock"></i></span>
|
||||||
<input type="Password" id="Password" class="input-xlarge" name="Password" placeholder="Password">
|
<input type="Password" id="Password" class="input-xlarge" name="Password" placeholder="{$password_default}" {if isset($Password)}value="{$Password}"{/if}>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="control-group">
|
|
||||||
<label class="control-label">Confirm Password</label>
|
|
||||||
<div class="controls">
|
|
||||||
<div class="input-prepend">
|
|
||||||
<span class="add-on"><i class="icon-lock"></i></span>
|
|
||||||
<input type="Password" id="ConfirmPass" class="input-xlarge" name="ConfirmPass" placeholder="Re-enter Password">
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group {if isset($CPASSWORD_ERROR) and $CPASSWORD_ERROR eq "TRUE"}error{else if
|
||||||
<label class="control-label">Email</label>
|
isset($CPASSWORD) and $CPASSWORD eq "success"}success{else}{/if}">
|
||||||
|
<label class="control-label">{$cpassword_tag}</label>
|
||||||
|
<div class="controls">
|
||||||
|
<div class="input-prepend">
|
||||||
|
<span class="add-on"><i class="icon-lock"></i></span>
|
||||||
|
<input type="Password" id="ConfirmPass" class="input-xlarge" name="ConfirmPass" placeholder="{$cpassword_default}" {if isset($ConfirmPass)}value="{$ConfirmPass}"{/if}>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="control-group {if isset($EMAIL_ERROR) and $EMAIL_ERROR eq "TRUE"}error{else if
|
||||||
|
isset($EMAIL) and $EMAIL eq "success"}success{else}{/if}">
|
||||||
|
<label class="control-label">{$email_tag}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<div class="input-prepend">
|
<div class="input-prepend">
|
||||||
<span class="add-on"><i class="icon-envelope"></i></span>
|
<span class="add-on"><i class="icon-envelope"></i></span>
|
||||||
<input type="text" class="input-xlarge" id="Email" name="Email" placeholder="Email">
|
<input type="text" class="input-xlarge" id="Email" name="Email" placeholder="{$email_default}" {if isset($Email)}value="{$Email}"{/if}>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group {if isset($TAC_ERROR) and $TAC_ERROR eq "TRUE"}error{else if
|
||||||
|
isset($TAC) and $TAC eq "success"}success{else}{/if}">
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<div class="input-prepend">
|
<div class="input-prepend">
|
||||||
<input type="checkbox" class="input-xlarge" id="TaC" name="TaC" placeholder="Email">{$tac_tag}
|
<input type="checkbox" class="input-xlarge" id="TaC" name="TaC" placeholder="Email">{$tac_tag}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<input type="hidden" name="function" value="add_user">
|
||||||
|
<input type="hidden" name="callBack" value="register">
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label"></label>
|
<label class="control-label"></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<button type="submit" class="btn btn-large btn-primary" >Create My Account</button>
|
<button type="submit" class="btn btn-large btn-primary" >Create My Account</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue