mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-15 06:08:42 +00:00
Merge with quitta-gsoc-2013
This commit is contained in:
commit
a0bd61d63c
3 changed files with 107 additions and 79 deletions
|
@ -6,6 +6,62 @@ class Users{
|
|||
helpers :: loadtemplate( 'register', $pageElements );
|
||||
|
||||
}
|
||||
|
||||
public function check_Register(){
|
||||
// check values
|
||||
if ( isset( $_POST["Username"] ) and isset( $_POST["Password"] ) and isset( $_POST["Email"] ) ){
|
||||
$user = Users :: checkUser( $_POST["Username"] );
|
||||
$pass = Users :: checkPassword( $_POST["Password"] );
|
||||
$cpass = Users :: confirmPassword($pass);
|
||||
$email = Users :: checkEmail( $_POST["Email"] );
|
||||
}else{
|
||||
$user = "";
|
||||
$pass = "";
|
||||
$cpass = "";
|
||||
$email = "";
|
||||
}
|
||||
|
||||
if ( ( $user == "success" ) and ( $pass == "success" ) and ( $cpass == "success" ) and ( $email == "success" ) and ( isset( $_POST["TaC"] ) ) ){
|
||||
return "success";
|
||||
}else{
|
||||
$pageElements = array(
|
||||
//'GAME_NAME' => $GAME_NAME,
|
||||
// 'WELCOME_MESSAGE' => $WELCOME_MESSAGE,
|
||||
'USERNAME' => $user,
|
||||
'PASSWORD' => $pass,
|
||||
'CPASSWORD' => $cpass,
|
||||
'EMAIL' => $email
|
||||
);
|
||||
if ( $user != "success" ){
|
||||
$pageElements['USERNAME_ERROR'] = 'TRUE';
|
||||
}else{
|
||||
$pageElements['USERNAME_ERROR'] = 'FALSE';
|
||||
}
|
||||
|
||||
if ( $pass != "success" ){
|
||||
$pageElements['PASSWORD_ERROR'] = 'TRUE';
|
||||
}else{
|
||||
$pageElements['PASSWORD_ERROR'] = 'FALSE';
|
||||
}
|
||||
if ( $cpass != "success" ){
|
||||
$pageElements['CPASSWORD_ERROR'] = 'TRUE';
|
||||
}else{
|
||||
$pageElements['CPASSWORD_ERROR'] = 'FALSE';
|
||||
}
|
||||
if ( $email != "success" ){
|
||||
$pageElements['EMAIL_ERROR'] = 'TRUE';
|
||||
}else{
|
||||
$pageElements['EMAIL_ERROR'] = 'FALSE';
|
||||
}
|
||||
if ( isset( $_POST["TaC"] ) ){
|
||||
$pageElements['TAC_ERROR'] = 'FALSE';
|
||||
}else{
|
||||
$pageElements['TAC_ERROR'] = 'TRUE';
|
||||
}
|
||||
return $pageElements;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function checkUser
|
||||
|
@ -22,6 +78,9 @@ class Users{
|
|||
return "Username must be 5 or more characters.";
|
||||
}elseif ( !preg_match( '/^[a-z0-9\.]*$/', $username ) ){
|
||||
return "Username can only contain numbers and letters.";
|
||||
}elseif ( $username == "" ){
|
||||
return "You have to fill in a username";
|
||||
|
||||
/*}elseif ( sql :: db_query( "SELECT COUNT(*) FROM {users} WHERE name = :name", array(
|
||||
':name' => $username
|
||||
) ) -> fetchField() ){
|
||||
|
@ -47,6 +106,8 @@ class Users{
|
|||
return "Password must be no more than 20 characters.";
|
||||
}elseif ( strlen( $pass ) < 5 ){
|
||||
return "Password must be more than 5 characters.";
|
||||
}elseif ( $pass == ""){
|
||||
return "You have to fill in a password";
|
||||
}else{
|
||||
return "success";
|
||||
}
|
||||
|
@ -59,15 +120,19 @@ class Users{
|
|||
* @takes $pass
|
||||
* @return string Info: Verify's $_POST["Password"] is the same as $_POST["ConfirmPass"]
|
||||
*/
|
||||
public function confirmPassword()
|
||||
public function confirmPassword($pass_result)
|
||||
{
|
||||
if ( ( $_POST["Password"] ) != ( $_POST["ConfirmPass"] ) ){
|
||||
if ( ( $_POST["Password"] ) != ( $_POST["ConfirmPass"] ) ){
|
||||
return "Passwords do not match.";
|
||||
}else{
|
||||
}else if ($_POST["ConfirmPass"]==""){
|
||||
return "You have to fill in the confirmation password.";
|
||||
}else if($pass_result != "success"){
|
||||
return;
|
||||
}else{
|
||||
return "success";
|
||||
}
|
||||
return "fail";
|
||||
}
|
||||
}
|
||||
return "fail";
|
||||
}
|
||||
/**
|
||||
* Function checkEmail
|
||||
*
|
||||
|
@ -77,13 +142,16 @@ class Users{
|
|||
public function checkEmail( $email )
|
||||
{
|
||||
if ( isset( $email ) ){
|
||||
if ( !Users::validEmail( $email ) ){
|
||||
return "Email address is not valid.";
|
||||
if ( !Users::validEmail( $email ) ){
|
||||
return "Email address is not valid.";
|
||||
}else if($email == ""){
|
||||
return "You have to fill in an email address";
|
||||
}
|
||||
/*}elseif ( db_query( "SELECT COUNT(*) FROM {users} WHERE mail = :mail", array(
|
||||
':mail' => $email
|
||||
) ) -> fetchField() ){
|
||||
return "Email is in use.";*/
|
||||
}else{
|
||||
return "Email is in use.";}*/
|
||||
else{
|
||||
return "success";
|
||||
}
|
||||
}else{
|
||||
|
|
|
@ -1,70 +1,30 @@
|
|||
<?php
|
||||
|
||||
function add_user(){
|
||||
|
||||
if ( isset( $_POST["Username"] ) and isset( $_POST["Password"] ) and isset( $_POST["Email"] ) )
|
||||
{
|
||||
// check values
|
||||
$user = users :: checkUser( $_POST["Username"] );
|
||||
$pass = users :: checkPassword( $_POST["Password"] );
|
||||
$cpass = users :: confirmPassword();
|
||||
$email = users :: checkEmail( $_POST["Email"] );
|
||||
$result = Users :: check_Register();
|
||||
//print_r($result);
|
||||
// if all are good then create user
|
||||
if ( $result == "success"){
|
||||
$edit = array(
|
||||
'name' => $_POST["Username"],
|
||||
'pass' => $_POST["Password"],
|
||||
'mail' => $_POST["Email"],
|
||||
'init' => $_POST["Email"],
|
||||
'unhashpass' => $_POST["Password"],
|
||||
'status' => 1,
|
||||
'access' => REQUEST_TIME
|
||||
);
|
||||
//header( 'Location: email_sent.php' );
|
||||
write_user( $edit );
|
||||
exit;
|
||||
}else{
|
||||
$user = "";
|
||||
$pass = "";
|
||||
$cpass = "";
|
||||
$email = "";
|
||||
}
|
||||
// if all are good then create user
|
||||
if ( ( $user == "success" ) and ( $pass == "success" ) and ( $cpass == "success" ) and ( $email == "success" ) and ( isset( $_POST["TaC"] ) ) ){
|
||||
$edit = array(
|
||||
'name' => $_POST["Username"],
|
||||
'pass' => $_POST["Password"],
|
||||
'mail' => $_POST["Email"],
|
||||
'init' => $_POST["Email"],
|
||||
'unhashpass' => $_POST["Password"],
|
||||
'status' => 1,
|
||||
'access' => REQUEST_TIME
|
||||
);
|
||||
header( 'Location: email_sent.php' );
|
||||
write_user( $edit );
|
||||
exit;
|
||||
}else{
|
||||
$pageElements = array(
|
||||
//'GAME_NAME' => $GAME_NAME,
|
||||
// 'WELCOME_MESSAGE' => $WELCOME_MESSAGE,
|
||||
// 'USERNAME' => $user,
|
||||
// 'PASSWORD' => $pass,
|
||||
// 'CPASSWORD' => $cpass,
|
||||
// 'EMAIL' => $email
|
||||
);
|
||||
if ( $user != "success" ){
|
||||
$pageElements['USERNAME_ERROR'] = 'TRUE';
|
||||
}else{
|
||||
$pageElements['USERNAME_ERROR'] = 'FALSE';
|
||||
}
|
||||
|
||||
if ( $pass != "success" ){
|
||||
$pageElements['PASSWORD_ERROR'] = 'TRUE';
|
||||
}else{
|
||||
$pageElements['PASSWORD_ERROR'] = 'FALSE';
|
||||
}
|
||||
if ( $cpass != "success" ){
|
||||
$pageElements['CPASSWORD_ERROR'] = 'TRUE';
|
||||
}else{
|
||||
$pageElements['CPASSWORD_ERROR'] = 'FALSE';
|
||||
}
|
||||
if ( $email != "success" ){
|
||||
$pageElements['EMAIL_ERROR'] = 'TRUE';
|
||||
}else{
|
||||
$pageElements['EMAIL_ERROR'] = 'FALSE';
|
||||
}
|
||||
if ( isset( $_POST["TaC"] ) ){
|
||||
$pageElements['TAC_ERROR'] = 'FALSE';
|
||||
}else{
|
||||
$pageElements['TAC_ERROR'] = 'TRUE';
|
||||
}
|
||||
helpers :: loadtemplate( 'register', $pageElements );
|
||||
// pass error
|
||||
$result['prevUsername'] = $_POST["Username"];
|
||||
$result['prevPassword'] = $_POST["Password"];
|
||||
$result['prevConfirmPass'] = $_POST["ConfirmPass"];
|
||||
$result['prevEmail'] = $_POST["Email"];
|
||||
$result['no_visible_elements'] = 'TRUE';
|
||||
helpers :: loadtemplate( 'register', $result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,6 +33,6 @@ function write_user(){
|
|||
|
||||
|
||||
// add user locally here
|
||||
users :: add_user();
|
||||
print('Awesome');
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<div class="controls">
|
||||
<div class="input-prepend">
|
||||
<span class="add-on"><i class="icon-user"></i></span>
|
||||
<input type="text" class="input-xlarge" id="Username" name="Username" placeholder="{$username_default}" {if isset($Username)}value="{$Username}"{/if} rel="popover" data-content="{$username_tooltip}" data-original-title="{$username_default}">
|
||||
<input type="text" class="input-xlarge" id="Username" name="Username" placeholder="{$username_default}" {if isset($prevUsername)}value="{$prevUsername}"{/if} rel="popover" data-content="{$username_tooltip}" data-original-title="{$username_default}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -33,7 +33,7 @@
|
|||
<div class="controls">
|
||||
<div class="input-prepend">
|
||||
<span class="add-on"><i class="icon-lock"></i></span>
|
||||
<input type="Password" id="Password" class="input-xlarge" name="Password" placeholder="{$password_default}" {if isset($Password)}value="{$Password}"{/if} rel="popover" data-content="{$password_tooltip}" data-original-title="{$password_default}">
|
||||
<input type="Password" id="Password" class="input-xlarge" name="Password" placeholder="{$password_default}" {if isset($prevPassword)}value="{$prevPassword}"{/if} rel="popover" data-content="{$password_tooltip}" data-original-title="{$password_default}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -44,7 +44,7 @@
|
|||
<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} rel="popover" data-content="{$cpassword_tooltip}" data-original-title="{$cpassword_default}">
|
||||
<input type="Password" id="ConfirmPass" class="input-xlarge" name="ConfirmPass" placeholder="{$cpassword_default}" {if isset($prevConfirmPass)}value="{$prevConfirmPass}"{/if} rel="popover" data-content="{$cpassword_tooltip}" data-original-title="{$cpassword_default}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -55,7 +55,7 @@
|
|||
<div class="controls">
|
||||
<div class="input-prepend">
|
||||
<span class="add-on"><i class="icon-envelope"></i></span>
|
||||
<input type="text" class="input-xlarge" id="Email" name="Email" placeholder="{$email_default}" {if isset($Email)}value="{$Email}"{/if} rel="popover" data-content="{$email_tooltip}" data-original-title="{$email_default}">
|
||||
<input type="text" class="input-xlarge" id="Email" name="Email" placeholder="{$email_default}" {if isset($prevEmail)}value="{$prevEmail}"{/if} rel="popover" data-content="{$email_tooltip}" data-original-title="{$email_default}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -84,7 +84,7 @@
|
|||
</div>
|
||||
{/if}
|
||||
|
||||
{if isset($CPASSWORD_ERROR) and $CPASSWORD_ERROR eq "TRUE"}
|
||||
{if isset($CPASSWORD_ERROR) and $CPASSWORD_ERROR eq "TRUE" and $CPASSWORD != ""}
|
||||
<div class="alert alert-error">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
<strong>Confirmation Password Error</strong> {$CPASSWORD}
|
||||
|
|
Loading…
Reference in a new issue