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 f2820f468..876f8d285 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 @@ -295,44 +295,6 @@ 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!"); - $_SESSION['user'] = $params['name']; - $_SESSION['permission'] = $row['Permission']; - print( $_SESSION['user']); - 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/ams_lib/translations/en.ini b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini index 24d3dc845..e9923a45f 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini @@ -4,13 +4,22 @@ [home] [login] +login_info = "Please login with your Username and Password." +login_error_message = "The filled in username/password were not correct!" + +[logout] +logout_message = "You've been logged out successfully!" +login_title = "Login" +login_timer = "You will be redirected to the login page in " +login_text = "Or click here if you don't want to wait!" [register_feedback] status_ok = "You registered like a baws!" status_shardoffline = "It seems the shard is offline, you can use the web-account, but you will need to wait for the shard." status_liboffline = "You can't register an account at this time" -login_title = "Next step: Login" -login_text = "Click here if you want to log in!" +login_title = "Login" +login_timer = "You will be redirected to the login page in " +login_text = "Or click here if you don't want to wait!" [register] title = "RYZOM CORE INGAME REGISTRATION" diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/autoload/logout.php b/code/ryzom/tools/server/ryzom_ams/www/html/autoload/logout.php new file mode 100644 index 000000000..a52172d5a --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/autoload/logout.php @@ -0,0 +1,7 @@ + $_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' => $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'; - } - if ( helpers :: check_if_game_client() ){ - helpers :: loadtemplate( 'register', $pageElements ); - }else{ - helpers :: loadtemplate( 'register', $pageElements ); - } - } diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/login.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/login.php new file mode 100644 index 000000000..c2368747d --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/login.php @@ -0,0 +1,43 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $statement = $dbw->prepare("SELECT * FROM ams_user WHERE Login=:user"); + $statement->execute(array('user' => $_POST['Username'])); + + $row = $statement->fetch(); + $salt = substr($row['Password'],0,2); + $hashed_input_pass = crypt($_POST["Password"], $salt); + if($hashed_input_pass == $row['Password']){ + //handle successful login + $_SESSION['user'] = $_POST["Username"]; + $_SESSION['permission'] = $row['Permission']; + //go back to the index page. + header( 'Location: index.php' ); + exit; + }else{ + //handle login failure + $result['login_error'] = 'TRUE'; + $result['no_visible_elements'] = 'TRUE'; + helpers :: loadtemplate( 'login', $result); + exit; + } + + + }catch (PDOException $e) { + //go to error page or something, because can't access website db + print_r($e); + exit; + } + +} \ No newline at end of file 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 b3749e8a6..e09d3a0f3 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/index.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/index.php @@ -27,9 +27,14 @@ if ( isset( $_POST["function"] ) ){ function loadpage ( $page ){ - require_once( 'autoload/' . $page . '.php' ); + $filename = 'autoload/' . $page . '.php'; + if(is_file($filename)){ + require_once($filename); + } } +loadpage($page); + //Set permission if(isset($_SESSION['permission'])){ $return['permission'] = $_SESSION['permission']; @@ -40,7 +45,7 @@ if(isset($_SESSION['permission'])){ //hide sidebar + topbar in case of login/register -if($page == 'login' || $page == 'register'){ +if($page == 'login' || $page == 'register' || $page == 'logout'){ $return['no_visible_elements'] = 'TRUE'; }else{ $return['no_visible_elements'] = 'FALSE'; diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_user.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_user.tpl index 5c5c25689..24ba25093 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_user.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_user.tpl @@ -4,5 +4,6 @@
  • Dashboard
  • Login Page
  • +
  • Logout
  • {/block} 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 fdf5c2d2c..29dea8036 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 @@ -8,38 +8,45 @@
    -
    -
    - Please login with your Username and Password. -
    -
    -
    -
    - -
    -
    + -
    +
    + +
    +
    + +

    + + +

    + + + + {if isset($login_error) and $login_error eq "TRUE"} +
    + + {$login_error_message} +
    + {/if} +
    + Register + If you dont have an account yet, create one here! +
    +
    + {/block} diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/logout.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/logout.tpl new file mode 100644 index 000000000..a238c4606 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/logout.tpl @@ -0,0 +1,40 @@ +{extends file="layout.tpl"} +{block name=content} + +
    +
    + +
    +
    + +
    +
    +
    + {$logout_message} +
    + + +
    + {$login_title} +

    {$login_timer}5

    +

    {$login_text}

    +
    + + +
    +
    +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/register_feedback.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/register_feedback.tpl index 43a227eac..90c40b232 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/register_feedback.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/register_feedback.tpl @@ -8,26 +8,42 @@
    -
    - {if isset($status) and $status eq "ok"} -
    - {$status_ok} -
    - {else if isset($status) and $status eq "shardoffline"} -
    - {$status_shardoffline} -
    - {else if isset($status) and $status eq "liboffline"} -
    - {$status_liboffline} -
    - {/if} - -
    - {$login_title} - {$login_text} -
    -
    +
    + {if isset($status) and $status eq "ok"} +
    + {$status_ok}
    + {else if isset($status) and $status eq "shardoffline"} +
    + {$status_shardoffline} +
    + {else if isset($status) and $status eq "liboffline"} +
    + {$status_liboffline} +
    + {/if} + +
    + {$login_title} +

    {$login_timer}5

    +

    {$login_text}

    +
    + + +
    +
    {/block}