From fa7afa87fd5fbbd01b2cd2937e7cc5860537c384 Mon Sep 17 00:00:00 2001 From: Quitta Date: Tue, 25 Jun 2013 20:57:10 +0200 Subject: [PATCH] Loging in match searching seems to work :) --- .../ryzom_ams/ams_lib/autoload/helpers.php | 5 ++- .../ryzom_ams/ams_lib/autoload/users.php | 36 +++++++++++++++ .../tools/server/ryzom_ams/www/html/index.php | 5 --- .../tools/server/ryzom_ams/www/html/login.php | 44 ------------------- .../ryzom_ams/www/html/templates/login.tpl | 5 ++- .../ryzom_ams/www/html/templates/register.tpl | 1 - 6 files changed, 42 insertions(+), 54 deletions(-) delete mode 100644 code/ryzom/tools/server/ryzom_ams/www/html/login.php diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/helpers.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/helpers.php index 2712e0aee..bedd1e2b8 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/helpers.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/helpers.php @@ -60,7 +60,7 @@ class Helpers{ global $SITEBASE; $arr = array( $AMS_LIB . '/ingame_templates/', $AMS_LIB . '/configs', - $AMS_LIB . '/cache', + //$AMS_LIB . '/cache', $SITEBASE . '/cache/', $SITEBASE . '/templates/', $SITEBASE . '/templates_c/', @@ -68,7 +68,8 @@ class Helpers{ ); foreach ( $arr as & $value ){ if ( !file_exists( $value ) ){ - mkdir( $value ); + echo $value; + mkdir( $value); } } 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 2bd042f74..c0d956d46 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 @@ -312,6 +312,42 @@ class Users{ } } + + public function login($params){ + $webhost = $params["webhost"]; + $webport = $params["webport"]; + $webdbname = $params["webdbname"]; + $webusername = $params["webusername"]; + $webpassword = $params["webpassword"]; + + try{ + $dbw = new PDO("mysql:host=$webhost;port=$webport;dbname=$webdbname", $webusername, $webpassword); + $dbw->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $statement = $dbw->prepare("SELECT * FROM ams_user WHERE Login=:user"); + $statement->execute(array('user' => $params['name'])); + $count = $statement->rowCount(); + + if ($count==1) { + $row = $statement->fetch(); + $salt = substr($row['Password'],0,2); + $hashed_input_pass = crypt($params["pass"], $salt); + if($hashed_input_pass == $row['Password']){ + //handle successful login + print("nice welcome!"); + return "success"; + }else{ + //handle login failure + print("Login failed"); + return "failure"; + } + } + }catch (PDOException $e) { + //go to error page or something, because can't access website db + print_r($e); + exit; + } + } } diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/index.php b/code/ryzom/tools/server/ryzom_ams/www/html/index.php index eada82bb2..e63155170 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/index.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/index.php @@ -10,11 +10,6 @@ $page = 'login'; if ( isset( $_POST["function"] ) ){ require( "inc/" . $_POST["function"] . ".php" ); $tempReturn = $_POST["function"](); - /*$functionReturn = array_merge($tempReturn,$_POST); - if ( isset($_POST["callBack"])){ - $page = $_POST["callBack"]; - - }*/ } function loadpage ( $page ){ diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/login.php b/code/ryzom/tools/server/ryzom_ams/www/html/login.php deleted file mode 100644 index 9bb640c2c..000000000 --- a/code/ryzom/tools/server/ryzom_ams/www/html/login.php +++ /dev/null @@ -1,44 +0,0 @@ - - -
- -
- -
- -
- diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/login.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/login.tpl index 2c36c3ce3..fdf5c2d2c 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/login.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/login.tpl @@ -15,12 +15,12 @@
- +
- +
@@ -30,6 +30,7 @@

+

diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/register.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/register.tpl index bd5e92788..5a154bb92 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/register.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/register.tpl @@ -106,7 +106,6 @@ {/if} -