From 33a416cd62a851ddb92ed35faad11bf5ebcaa175 Mon Sep 17 00:00:00 2001 From: Botanic Date: Tue, 18 Jun 2013 10:48:54 -0700 Subject: [PATCH] add_user example --- .../ryzom_ams/ams_lib/autoload/users.php | 70 +--------------- .../ryzom_ams/www/html/autoload/register.php | 4 +- .../ryzom_ams/www/html/inc/add_user.php | 79 +++++++++++++++++-- 3 files changed, 78 insertions(+), 75 deletions(-) diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php index 3d500af69..2d28119f7 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php @@ -2,71 +2,9 @@ class Users{ public function add_user(){ - // check if values exist - 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"] ); - }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 - ); - //user_save( NULL, $edit ); - header( 'Location: email_sent.php' ); - exit; - }else{ - $pageElements = array( - //'GAME_NAME' => variable_get( 'ryzommanage_game-name', '' ), - //'WELCOME_MESSAGE' => variable_get( 'ryzommanage_register-welcome', '' ), - '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; - } + helpers :: loadtemplate( 'register', $pageElements ); + } /** @@ -153,7 +91,7 @@ class Users{ } return "fail"; } - + public function validEmail( $email ){ $isValid = true; $atIndex = strrpos( $email, "@" ); @@ -196,7 +134,7 @@ class Users{ } return $isValid; } - + public function generateSALT( $length = 2 ) { // start with a blank salt diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/autoload/register.php b/code/ryzom/tools/server/ryzom_ams/www/html/autoload/register.php index 668b6a7a5..e25b8b244 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/autoload/register.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/autoload/register.php @@ -64,8 +64,8 @@ if ( ( $user == "success" ) and ( $pass == "success" ) and ( $cpass == "success" $pageElements['TAC_ERROR'] = 'TRUE'; } if ( helpers :: check_if_game_client() ){ - helpers :: loadtemplate( '../../ams_lib/ingame_templates/register.phtml', $pageElements ); + helpers :: loadtemplate( 'register', $pageElements ); }else{ - helpers :: loadtemplate( 'templates/register.phtml', $pageElements ); + helpers :: loadtemplate( 'register', $pageElements ); } } diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/add_user.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/add_user.php index 0fedc2aba..f0611058e 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/add_user.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/add_user.php @@ -1,13 +1,78 @@ $_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 ); + } +} + + +function write_user(){ + + // add user locally here - $return = users :: add_user(); - return $return; + users :: add_user(); } -function checkUser(){ - - - }