From afd473aaff7b6139f4935bee1d8da3bac8543d32 Mon Sep 17 00:00:00 2001 From: Quitta Date: Thu, 27 Jun 2013 04:54:41 +0200 Subject: [PATCH 01/12] Syncing basics, need refactoring though --HG-- branch : quitta-gsoc-2013 --- .../ryzom_ams/ams_lib/autoload/sync.php | 65 +++++++++++++++++++ .../ryzom_ams/ams_lib/autoload/users.php | 4 +- .../ryzom_ams/ams_lib/cron/sync_cron.php | 6 ++ 3 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php create mode 100644 code/ryzom/tools/server/ryzom_ams/ams_lib/cron/sync_cron.php diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php new file mode 100644 index 000000000..302d4dc14 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php @@ -0,0 +1,65 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $statement = $dbl->prepare("SELECT * FROM ams_querycache"); + $statement->execute(); + $rows = $statement->fetchAll(); + + $dbs = new PDO("mysql:host=$SHARDDBHOST;port=$SHARDDBPORT;dbname=$SHARDDBNAME", $SHARDDBUSERNAME, $SHARDDBPASSWORD); + $dbs->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + foreach ($rows as $record) { + + switch($record['type']) { + case 'createPermissions': + case 'user_edit': + case 'createUser': + $query = json_decode($record['query']); + //make connection with and put into shard db + $statement = $dbs->prepare("INSERT INTO user (Login, Password, Email) VALUES (?, ?, ?)"); + $statement->execute($query); + + $statement = $dbl->prepare("DELETE FROM ams_querycache WHERE SID=:SID"); + $query = array('SID' => $record['SID']); + $statement->execute($query); + + + } + } + print('Syncing completed'); + } + catch (PDOException $e) { + print('Something went wrong!'); + print_r($e); + } + + } +} 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 876f8d285..1d6c62177 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 @@ -236,7 +236,7 @@ class Users{ return $salt; } - function create_Server_User($params) + /*function create_Server_User($params) { try { $hostname = 'localhost'; @@ -254,7 +254,7 @@ class Users{ return "fail"; } // createPermissions(array($login)); - } + }*/ function createUser($values){ diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/cron/sync_cron.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/cron/sync_cron.php new file mode 100644 index 000000000..477b139d4 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/cron/sync_cron.php @@ -0,0 +1,6 @@ + Date: Thu, 27 Jun 2013 18:06:09 +0200 Subject: [PATCH 02/12] dblayer + refactored the db parts --HG-- branch : quitta-gsoc-2013 --- .../ryzom_ams/ams_lib/autoload/dblayer.php | 32 +++++++++++++++ .../ryzom_ams/ams_lib/autoload/sync.php | 38 +++++------------- .../ryzom_ams/ams_lib/autoload/users.php | 27 ++++--------- .../tools/server/ryzom_ams/www/config.php | 33 +++++++--------- .../ryzom_ams/www/html/inc/add_user.php | 39 +++---------------- .../server/ryzom_ams/www/html/inc/login.php | 13 ++----- 6 files changed, 71 insertions(+), 111 deletions(-) create mode 100644 code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php new file mode 100644 index 000000000..d323dc4e4 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php @@ -0,0 +1,32 @@ + PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC + ); + $this->PDO = new PDO($dsn,$db['user'],$db['pass'], $opt); + } + + public function executeWithoutParams($query){ + $statement = $this->PDO->prepare($query); + $statement->execute(); + return $statement; + } + + public function execute($query,$params){ + $statement = $this->PDO->prepare($query); + $statement->execute($params); + return $statement; + } + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php index 302d4dc14..170a1c4bf 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php @@ -14,44 +14,24 @@ class Sync{ */ static public function syncdata () { - global $LIBDBHOST; - global $LIBDBPORT; - global $LIBDBNAME; - global $LIBDBUSERNAME; - global $LIBDBPASSWORD; - - global $SHARDDBHOST; - global $SHARDDBPORT; - global $SHARDDBNAME; - global $SHARDDBUSERNAME; - global $SHARDDBPASSWORD; + global $cfg; try { - $dbl = new PDO("mysql:host=$LIBDBHOST;port=$LIBDBPORT;dbname=$LIBDBNAME", $LIBDBUSERNAME, $LIBDBPASSWORD); - $dbl->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $statement = $dbl->prepare("SELECT * FROM ams_querycache"); - $statement->execute(); + $dbl = new DBLayer($cfg['db']['lib']); + $statement = $dbl->executeWithoutParams("SELECT * FROM ams_querycache"); $rows = $statement->fetchAll(); - - $dbs = new PDO("mysql:host=$SHARDDBHOST;port=$SHARDDBPORT;dbname=$SHARDDBNAME", $SHARDDBUSERNAME, $SHARDDBPASSWORD); - $dbs->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - + $dbs = new DBLayer($cfg['db']['shard']); foreach ($rows as $record) { switch($record['type']) { case 'createPermissions': case 'user_edit': case 'createUser': - $query = json_decode($record['query']); - //make connection with and put into shard db - $statement = $dbs->prepare("INSERT INTO user (Login, Password, Email) VALUES (?, ?, ?)"); - $statement->execute($query); - - $statement = $dbl->prepare("DELETE FROM ams_querycache WHERE SID=:SID"); - $query = array('SID' => $record['SID']); - $statement->execute($query); - - + $decode = json_decode($record['query']); + $query = array('login' => $decode[0], 'pass' => $decode[1], 'mail' => $decode[2] ); + //make connection with and put into shard db & delete from the lib + $dbs->execute("INSERT INTO user (Login, Password, Email) VALUES (:login, :pass, :mail)",$query); + $dbl->execute("DELETE FROM ams_querycache WHERE SID=:SID",array('SID' => $record['SID'])); } } print('Syncing completed'); 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 1d6c62177..fab797681 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 @@ -258,34 +258,21 @@ class Users{ function createUser($values){ - $libhost = $values["libhost"]; - $libport = $values["libport"]; - $libdbname = $values["libdbname"]; - $libusername = $values["libusername"]; - $libpassword = $values["libpassword"]; - - $shardhost = $values["shardhost"]; - $shardport = $values["shardport"]; - $sharddbname = $values["sharddbname"]; - $shardusername = $values["shardusername"]; - $shardpassword = $values["shardpassword"]; + $libdb = $values['db']['lib']; + $sharddb = $values['db']['shard']; try { //make connection with and put into shard db - $dbs = new PDO("mysql:host=$shardhost;port=$shardport;dbname=$sharddbname", $shardusername, $shardpassword); - $dbs->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $statement = $dbs->prepare("INSERT INTO user (Login, Password, Email) VALUES (:name, :pass, :mail)"); - $statement->execute($values["params"]); + $dbs = new DBLayer($sharddb); + $dbs->execute("INSERT INTO user (Login, Password, Email) VALUES (:name, :pass, :mail)",$values["params"]); return "ok"; } catch (PDOException $e) { //oh noooz, the shard is offline! Put in query queue at ams_lib db! try { - $dbl = new PDO("mysql:host=$libhost;port=$libport;dbname=$libdbname", $libusername, $libpassword); - $dbl->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $params = array("type" => "createUser","query" => json_encode(array($values["params"]["name"],$values["params"]["pass"],$values["params"]["mail"]))); - $statement = $dbl->prepare("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)"); - $statement->execute($params); + $dbl = new DBLayer($libdb); + $dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "createUser", + "query" => json_encode(array($values["params"]["name"],$values["params"]["pass"],$values["params"]["mail"])))); return "shardoffline"; }catch (PDOException $e) { print_r($e); diff --git a/code/ryzom/tools/server/ryzom_ams/www/config.php b/code/ryzom/tools/server/ryzom_ams/www/config.php index 747ae8414..b896879a9 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/config.php +++ b/code/ryzom/tools/server/ryzom_ams/www/config.php @@ -7,26 +7,23 @@ // where we can find the mysql database //----------------------------------------------------------------------------------------- -//the www db -$WEBDBHOST = 'localhost'; -$WEBDBPORT = '3306'; -$WEBDBNAME = 'ryzom_ams'; -$WEBDBUSERNAME = 'root'; -$WEBDBPASSWORD = 'lol123' ; +$cfg['db']['web']['host'] = 'localhost'; +$cfg['db']['web']['port'] = '3306'; +$cfg['db']['web']['name'] = 'ryzom_ams'; +$cfg['db']['web']['user'] = 'root'; +$cfg['db']['web']['pass'] = 'lol123'; -//the ams_lib db -$LIBDBHOST = 'localhost'; -$LIBDBPORT = '3306'; -$LIBDBNAME = 'ryzom_ams_lib'; -$LIBDBUSERNAME = 'root'; -$LIBDBPASSWORD = 'lol123' ; +$cfg['db']['lib']['host'] = 'localhost'; +$cfg['db']['lib']['port'] = '3306'; +$cfg['db']['lib']['name'] = 'ryzom_ams_lib'; +$cfg['db']['lib']['user'] = 'root'; +$cfg['db']['lib']['pass'] = 'lol123'; -//the shard db -$SHARDDBHOST = 'localhost' ; -$SHARDDBPORT = '3306'; -$SHARDDBNAME = 'nel' ; -$SHARDDBUSERNAME = 'shard' ; -$SHARDDBPASSWORD = '' ; +$cfg['db']['shard']['host'] = 'localhost'; +$cfg['db']['shard']['port'] = '3306'; +$cfg['db']['shard']['name'] = 'nel'; +$cfg['db']['shard']['user'] = 'shard'; +$cfg['db']['shard']['pass'] = ''; //----------------------------------------------------------------------------------------- // If true= the server will add automatically unknown user in the database 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 64733ddb2..8f3a25d27 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 @@ -37,23 +37,7 @@ function add_user(){ function write_user($newUser){ //get the db specifics out of the config file - global $WEBDBHOST; - global $WEBDBPORT; - global $WEBDBNAME; - global $WEBDBUSERNAME; - global $WEBDBPASSWORD; - - global $LIBDBHOST; - global $LIBDBPORT; - global $LIBDBNAME; - global $LIBDBUSERNAME; - global $LIBDBPASSWORD; - - global $SHARDDBHOST; - global $SHARDDBPORT; - global $SHARDDBNAME; - global $SHARDDBUSERNAME; - global $SHARDDBPASSWORD; + global $cfg; //create salt here, because we want it to be the same on the web/server $hashpass = crypt($newUser["pass"], Users::generateSALT()); @@ -67,29 +51,16 @@ function write_user($newUser){ //print_r($params); //make a $values array for passing all data to the Users::createUser() function. $values["params"] = $params; - $values["libhost"] = $LIBDBHOST; - $values["libport"] = $LIBDBPORT; - $values["libdbname"] = $LIBDBNAME; - $values["libusername"] = $LIBDBUSERNAME; - $values["libpassword"] = $LIBDBPASSWORD ; - - $values["shardhost"] = $SHARDDBHOST; - $values["shardport"] = $SHARDDBPORT; - $values["sharddbname"] = $SHARDDBNAME; - $values["shardusername"] = $SHARDDBUSERNAME; - $values["shardpassword"] = $SHARDDBPASSWORD; - + $values["db"] = $cfg['db']; //Create the user on the shard + in case shard is offline put copy of query in query db - //returns ok, shardoffline or liboffline + //returns: ok, shardoffline or liboffline $result = Users :: createUser($values); try{ //make connection with web db and put it in there - $dbw = new PDO("mysql:host=$WEBDBHOST;port=$WEBDBPORT;dbname=$WEBDBNAME", $WEBDBUSERNAME, $WEBDBPASSWORD); - $dbw->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $statement = $dbw->prepare("INSERT INTO ams_user (Login, Password, Email) VALUES (:name, :pass, :mail)"); - $statement->execute($params); + $dbw = new DBLayer($cfg['db']['web']); + $dbw->execute("INSERT INTO ams_user (Login, Password, Email) VALUES (:name, :pass, :mail)",$params); }catch (PDOException $e) { //go to error page or something, because can't access website db 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 index c2368747d..055ea442a 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/login.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/login.php @@ -2,18 +2,11 @@ function login(){ - global $WEBDBHOST; - global $WEBDBPORT; - global $WEBDBNAME; - global $WEBDBUSERNAME; - global $WEBDBPASSWORD; + global $cfg; try{ - $dbw = new PDO("mysql:host=$WEBDBHOST;port=$WEBDBPORT;dbname=$WEBDBNAME", $WEBDBUSERNAME, $WEBDBPASSWORD); - $dbw->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - - $statement = $dbw->prepare("SELECT * FROM ams_user WHERE Login=:user"); - $statement->execute(array('user' => $_POST['Username'])); + $dbw = new DBLayer($cfg['db']['web']); + $statement = $dbw->execute("SELECT * FROM ams_user WHERE Login=:user", array('user' => $_POST['Username'])); $row = $statement->fetch(); $salt = substr($row['Password'],0,2); From fe70ca714bf21efceb33bd0cf75f5bfd3c9a44ca Mon Sep 17 00:00:00 2001 From: Quitta Date: Thu, 27 Jun 2013 20:18:36 +0200 Subject: [PATCH 03/12] small test to check if ajax works on the pages, it still seems to work :) --HG-- branch : quitta-gsoc-2013 --- .../ryzom_ams/ams_lib/autoload/users.php | 21 +----------------- .../ryzom_ams/ams_lib/translations/en.ini | 2 ++ .../ryzom_ams/www/html/templates/layout.tpl | 3 ++- .../www/html/templates/layout_user.tpl | 3 ++- .../ryzom_ams/www/html/templates/userlist.tpl | 22 +++++++++++++++++++ 5 files changed, 29 insertions(+), 22 deletions(-) create mode 100644 code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl 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 fab797681..f1b0c877b 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 @@ -236,26 +236,7 @@ class Users{ return $salt; } - /*function create_Server_User($params) - { - try { - $hostname = 'localhost'; - $port = '3306'; - $dbname = 'nel'; - $username = 'shard'; - $password = ''; - $dbh = new PDO("mysql:host=$hostname;port=$port;dbname=$dbname", $username, $password); - $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $statement = $dbh->prepare("INSERT INTO user (Login, Password, Email) VALUES (?, ?, ?)"); - $statement->execute($params); - return "success"; - } - catch (PDOException $e) { - return "fail"; - } - // createPermissions(array($login)); - }*/ - + function createUser($values){ $libdb = $values['db']['lib']; 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 e9923a45f..eafb7df63 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 @@ -3,6 +3,8 @@ [home] +[userlist] + [login] login_info = "Please login with your Username and Password." login_error_message = "The filled in username/password were not correct!" diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl index 16d032be1..075190b64 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl @@ -118,7 +118,8 @@ - + + 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 24ba25093..7809f829a 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 @@ -1,7 +1,8 @@ {extends file="layout.tpl"} {block name=menu} -
  • Dashboard
  • +
  • Dashboard
  • +
  • Userlist
  • Login Page
  • Logout
  • diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl new file mode 100644 index 000000000..53d46ddd6 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl @@ -0,0 +1,22 @@ +{block name=content} + +
    +
    +
    +

    User List

    +
    + + + + +
    +
    +
    +

    The shard/lib/web db user list You are about to see it here!

    + +
    +
    +
    +
    +{/block} + From 3b58c56d5be511a54d7f6c9ea71fc92ad34699e5 Mon Sep 17 00:00:00 2001 From: Quitta Date: Thu, 27 Jun 2013 20:50:32 +0200 Subject: [PATCH 04/12] Language stuff supports cookies now and in case a not specified language is given, then it uses the default --HG-- branch : quitta-gsoc-2013 --- .../ryzom_ams/ams_lib/autoload/helpers.php | 39 ++++++++++++------- .../ryzom_ams/ams_lib/translations/fr.ini | 39 ++++++++++++++++--- 2 files changed, 60 insertions(+), 18 deletions(-) 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 bedd1e2b8..0bc4197b3 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 @@ -25,21 +25,34 @@ class Helpers{ $smarty -> setConfigDir( $SITEBASE . '/configs' ); } - foreach ( $vars as $key => $value ){ + foreach ( $vars as $key => $value ){ $smarty -> assign( $key, $value ); } - if ( isset( $_GET["language"] ) ){ - $language = $_GET["language"]; - if ( file_exists( $AMS_TRANS . '/' . $language . '.ini' ) ){ - - }else{ - global $DEFAULT_LANGUAGE; - $language = $DEFAULT_LANGUAGE; - } - }else{ - global $DEFAULT_LANGUAGE; - $language = $DEFAULT_LANGUAGE; - } + + global $DEFAULT_LANGUAGE; + //if language get param is given = set cookie + //else if no get param is given and a cookie is set, use that language, else use default. + if ( isset( $_GET['language'] ) ) { + //check if the language is supported + if ( file_exists( $AMS_TRANS . '/' . $_GET['language'] . '.ini' ) ){ + //if it's supported, set cookie! + setcookie( 'language',$_GET['language'], time() + 60*60*24*30 ); + $language = $_GET['language']; + }else{ + //the language is not supported, use the default. + $language = $DEFAULT_LANGUAGE; + } + }else{ + //if no get param is given, check if a cookie value for language is set + if ( isset( $_COOKIE['language'] ) ) { + $language = $_COOKIE['language']; + } + //else use the default + else{ + $language = $DEFAULT_LANGUAGE; + } + } + $variables = parse_ini_file( $AMS_TRANS . '/' . $language . '.ini', true ); foreach ( $variables[$template] as $key => $value ){ $smarty -> assign( $key, $value ); diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini index 2c00c81ef..1e186ec0f 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini @@ -1,21 +1,50 @@ ; This is a sample configuration file ; Comments start with ';', as in php.ini +[home] + +[userlist] + +[login] +login_info = "S'il vous plait vous connecter avec votre nom d'utilisateur et mot de passe." +login_error_message = "Le remplie nom d'utilisateur / mot de passe ne sont pas correctes!" + +[logout] +logout_message = "Vous avez été déconnecté avec succès!" +login_title = "Identifier" +login_timer = "Vous serez redirigé vers la page de connexion à " +login_text = "Ou cliquez ici si vous ne voulez pas attendre!" + +[register_feedback] +status_ok = "Vous vous êtes inscrit comme un patron!" +status_shardoffline = "Il semble que le shard est déconnecté, vous pouvez utiliser le web-compte, mais vous devrez attendre pour le tesson." +status_liboffline = "Vous ne pouvez pas enregistrer un compte à l'heure actuelle" +login_title = "Identifier" +login_timer = "Vous serez redirigé vers la page de connexion à " +login_text = "Ou cliquez ici si vous ne voulez pas attendre!" + [register] title = "RYZOM base dans ENREGISTREMENT DU JEU" -welcome_message = "Bienvenue! S'il vous plaît remplissez les champs ci-dessous pour obtenir votre nouveau compte de base de Ryzom:" +welcome_message = "Bienvenue! S'il vous plait remplissez les champs ci-dessous pour obtenir votre nouveau compte de base de Ryzom:" -username_tag = "Nom d'utilisateur désiré:" +username_tag = "Nom d'utilisateur desire:" username_tooltip = "5-12 caractères et de chiffres minuscules. Le login (nom d'utilisateur) que vous créez ici sera votre nom de connexion. Le nom de vos personnages de jeu sera choisi plus tard." +username_default = "Nom d'utilisateur" -password_tag = "désiré Mot de passe:" +password_tag = "desire Mot de passe:" +password_tooltip = "Prendre un mot de passe dificille, il faut etre 5-20 caracteres" password_message = "mot de passe doit être 5-20 caractères." +password_default = "Mot de passe" cpassword_tag = "Confirmer le mot de passe:" cpassword_message = "Retapez votre mot de passe" +cpassword_tooltip = "Retapez votre mot de passe" +cpassword_default = "Re-entrer mot de passe" -email_tag = "Adresse de courriel (pour qui un email de confirmation vous sera envoyé):" +email_tag= "email adresse" +email_tooltip = "Adresse de courriel (pour qui un email de confirmation vous sera envoyé):" email_message = "Veuillez vérifier que l'adresse e-mail que vous entrez ici est valable et restera valable à l'avenir. Elle ne sera utilisée que pour gérer votre compte de base de Ryzom." +email_default = "email" tac_tag = "OUI, j'accepte les termes de service." -tac_message = "Vous devez accepter les Conditions d'utilisation." +tac_message = "Vous devez accepter les Conditions d'utilisation." \ No newline at end of file From 4755b7478f1491144bbdde90f7190fe783af18bb Mon Sep 17 00:00:00 2001 From: Quitta Date: Fri, 28 Jun 2013 06:18:23 +0200 Subject: [PATCH 05/12] messing around and fixing throwing of exceptions in DBLayer --HG-- branch : quitta-gsoc-2013 --- .../ryzom_ams/ams_lib/autoload/dblayer.php | 46 ++++--- .../ryzom_ams/ams_lib/autoload/users.php | 124 ++++++++++-------- .../ryzom_ams/www/html/inc/add_user.php | 15 +-- 3 files changed, 105 insertions(+), 80 deletions(-) diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php index d323dc4e4..240eda426 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php @@ -5,28 +5,40 @@ class DBLayer{ function __construct($db) { - $dsn = "mysql:"; - $dsn .= "host=". $db['host'].";"; - $dsn .= "dbname=". $db['name'].";"; - $dsn .= "port=". $db['port'].";"; - - $opt = array( - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC - ); - $this->PDO = new PDO($dsn,$db['user'],$db['pass'], $opt); + try{ + $dsn = "mysql:"; + $dsn .= "host=". $db['host'].";"; + $dsn .= "dbname=". $db['name'].";"; + $dsn .= "port=". $db['port'].";"; + + $opt = array( + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC + ); + $this->PDO = new PDO($dsn,$db['user'],$db['pass'], $opt); + }catch (PDOException $e) { + throw $e; + } } - public function executeWithoutParams($query){ - $statement = $this->PDO->prepare($query); - $statement->execute(); - return $statement; + public function executeWithoutParams($query){ + try{ + $statement = $this->PDO->prepare($query); + $statement->execute(); + return $statement; + }catch (PDOException $e) { + throw $e; + } } public function execute($query,$params){ - $statement = $this->PDO->prepare($query); - $statement->execute($params); - return $statement; + try{ + $statement = $this->PDO->prepare($query); + $statement->execute($params); + return $statement; + }catch (PDOException $e) { + throw $e; + } } } \ No newline at end of file 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 f1b0c877b..bdc6f32a7 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 @@ -1,19 +1,19 @@ 12 ){ - return "Username must be no more than 12 characters."; - }elseif ( strlen( $username ) < 5 ){ - 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() ){ - return "Username " . $username . " is in use.";*/ - }else{ - return "success"; - } - }else{ - return "success"; - } - return "fail"; - } + { + if ( isset( $username ) ){ + if ( strlen( $username ) > 12 ){ + return "Username must be no more than 12 characters."; + }else if ( strlen( $username ) < 5 ){ + return "Username must be 5 or more characters."; + }else if ( !preg_match( '/^[a-z0-9\.]*$/', $username ) ){ + return "Username can only contain numbers and letters."; + }else if ( $username == "" ){ + return "You have to fill in a username"; + /*}elseif ($this->dbs->execute("SELECT * FROM user WHERE Login = :name",array('name' => $username))->rowCount()){ + return "Username " . $username . " is in use.";*/ + }else{ + return "success"; + } + } + return "fail"; + } + + /** * Function checkPassword * @@ -114,6 +111,8 @@ class Users{ } return "fail"; } + + /** * Function confirmPassword * @@ -133,6 +132,8 @@ class Users{ } return "fail"; } + + /** * Function checkEmail * @@ -146,20 +147,23 @@ class Users{ return "Email address is not valid."; }else if($email == ""){ return "You have to fill in an email address"; + /*}elseif ( $this->dbs->execute("SELECT * FROM user WHERE Email = :email",array('email' => $email))->rowCount()){ + return "Email is in use.";*/} + else{ + return "success"; } - /*}elseif ( db_query( "SELECT COUNT(*) FROM {users} WHERE mail = :mail", array( - ':mail' => $email - ) ) -> fetchField() ){ - return "Email is in use.";}*/ - else{ - return "success"; - } - }else{ - return "success"; - } - return "fail"; - } + } + return "fail"; + } + + + /** + * Function validEmail + * + * @takes $email + * @return true or false depending on if its a valid email format. + */ public function validEmail( $email ){ $isValid = true; $atIndex = strrpos( $email, "@" ); @@ -203,6 +207,14 @@ class Users{ return $isValid; } + + + /** + * Function generateSALT + * + * @takes $length, which is by default 2 + * @return a random salt of 2 chars + */ public function generateSALT( $length = 2 ) { // start with a blank salt @@ -237,21 +249,25 @@ class Users{ } - function createUser($values){ - - $libdb = $values['db']['lib']; - $sharddb = $values['db']['shard']; - + + /** + * Function create + * + * @takes $array with name,pass and mail + * @return ok if it's get correctly added to the shard, else return lib offline and put in libDB, if libDB is also offline return liboffline. + */ + function createUser($values){ try { //make connection with and put into shard db - $dbs = new DBLayer($sharddb); + global $cfg; + $dbs = new DBLayer($cfg['db']['shard']); $dbs->execute("INSERT INTO user (Login, Password, Email) VALUES (:name, :pass, :mail)",$values["params"]); return "ok"; } catch (PDOException $e) { //oh noooz, the shard is offline! Put in query queue at ams_lib db! try { - $dbl = new DBLayer($libdb); + $dbl = new DBLayer($cfg['db']['lib']); $dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "createUser", "query" => json_encode(array($values["params"]["name"],$values["params"]["pass"],$values["params"]["mail"])))); return "shardoffline"; 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 8f3a25d27..46dfea6b4 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,8 +1,10 @@ $_POST["Username"], 'Password' => $_POST["Password"], 'Email' => $_POST["Email"]); + $result = Users::check_Register($params); + // if all are good then create user if ( $result == "success"){ $edit = array( @@ -14,10 +16,8 @@ function add_user(){ 'status' => 1, 'access' => $_SERVER['REQUEST_TIME'] ); - //header( 'Location: email_sent.php' ); $status = write_user( $edit ); $pageElements['status'] = $status; - //TODO: perhaps send email! $pageElements['no_visible_elements'] = 'TRUE'; helpers :: loadtemplate( 'register_feedback', $pageElements); exit; @@ -36,9 +36,6 @@ function add_user(){ function write_user($newUser){ - //get the db specifics out of the config file - global $cfg; - //create salt here, because we want it to be the same on the web/server $hashpass = crypt($newUser["pass"], Users::generateSALT()); @@ -51,14 +48,14 @@ function write_user($newUser){ //print_r($params); //make a $values array for passing all data to the Users::createUser() function. $values["params"] = $params; - $values["db"] = $cfg['db']; //Create the user on the shard + in case shard is offline put copy of query in query db //returns: ok, shardoffline or liboffline - $result = Users :: createUser($values); + $result = Users::createUser($values); try{ //make connection with web db and put it in there + global $cfg; $dbw = new DBLayer($cfg['db']['web']); $dbw->execute("INSERT INTO ams_user (Login, Password, Email) VALUES (:name, :pass, :mail)",$params); From 76e46c9fc48aac935f56c2402ea47d66a55bb740 Mon Sep 17 00:00:00 2001 From: Quitta Date: Fri, 28 Jun 2013 18:10:02 +0200 Subject: [PATCH 06/12] add language flags + js for activating them --HG-- branch : quitta-gsoc-2013 --- .../ryzom_ams/ams_lib/autoload/users.php | 40 ++++++++++++++---- .../ryzom_ams/ams_lib/translations/en.ini | 1 + .../ryzom_ams/ams_lib/translations/fr.ini | 1 + .../server/ryzom_ams/www/html/css/custom.css | 7 +++ .../server/ryzom_ams/www/html/img/en.png | Bin 0 -> 725 bytes .../server/ryzom_ams/www/html/img/fr.png | Bin 0 -> 675 bytes .../ryzom_ams/www/html/templates/layout.tpl | 8 +++- .../ryzom_ams/www/html/templates/userlist.tpl | 2 +- 8 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 code/ryzom/tools/server/ryzom_ams/www/html/img/en.png create mode 100644 code/ryzom/tools/server/ryzom_ams/www/html/img/fr.png 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 bdc6f32a7..c99e8567d 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 @@ -69,7 +69,7 @@ class Users{ * @takes $username * @return string Info: Returns a string based on if the username is valid, if valid then "success" is returned */ - public function checkUser( $username ) + private function checkUser( $username ) { if ( isset( $username ) ){ if ( strlen( $username ) > 12 ){ @@ -89,6 +89,31 @@ class Users{ return "fail"; } + /** + * Function checkUserAlreadyExists + * + * @takes $username + * @return string Info: Returns true or false if the user is in the lib+shard db. + * + private function checkUserAlreadyExists( $username ) + { + global $cfg; + $dbl = new DBLayer($cfg['db']['lib']); + $dbs = new DBLayer($cfg['db']['shard']); + try{ + if ($this->dbl->execute("SELECT * FROM user WHERE Login = :name",array('name' => $username))->rowCount()){ + return true; + } + if ($this->dbs->execute("SELECT * FROM user WHERE Login = :name",array('name' => $username))->rowCount()){ + return true; + } + return false; + }catch (PDOException $e) { + //in case one of them is offline let it be hanled lateron with the + return true; + } + }*/ + /** * Function checkPassword @@ -96,7 +121,7 @@ class Users{ * @takes $pass * @return string Info: Returns a string based on if the password is valid, if valid then "success" is returned */ - public function checkPassword( $pass ) + private function checkPassword( $pass ) { if ( isset( $pass ) ){ if ( strlen( $pass ) > 20 ){ @@ -119,7 +144,7 @@ class Users{ * @takes $pass * @return string Info: Verify's $_POST["Password"] is the same as $_POST["ConfirmPass"] */ - public function confirmPassword($pass_result) + private function confirmPassword($pass_result) { if ( ( $_POST["Password"] ) != ( $_POST["ConfirmPass"] ) ){ return "Passwords do not match."; @@ -140,7 +165,7 @@ class Users{ * @takes $email * @return */ - public function checkEmail( $email ) + private function checkEmail( $email ) { if ( isset( $email ) ){ if ( !Users::validEmail( $email ) ){ @@ -164,7 +189,7 @@ class Users{ * @takes $email * @return true or false depending on if its a valid email format. */ - public function validEmail( $email ){ + private function validEmail( $email ){ $isValid = true; $atIndex = strrpos( $email, "@" ); if ( is_bool( $atIndex ) && !$atIndex ){ @@ -256,7 +281,7 @@ class Users{ * @takes $array with name,pass and mail * @return ok if it's get correctly added to the shard, else return lib offline and put in libDB, if libDB is also offline return liboffline. */ - function createUser($values){ + public function createUser($values){ try { //make connection with and put into shard db global $cfg; @@ -277,8 +302,7 @@ class Users{ } } - } - + } } 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 eafb7df63..c60e5a621 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,6 +4,7 @@ [home] [userlist] +userlist_info = "welcome to the userlist" [login] login_info = "Please login with your Username and Password." diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini index 1e186ec0f..432845f91 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini @@ -4,6 +4,7 @@ [home] [userlist] +userlist_info = "bienvenue sur le userlist page!" [login] login_info = "S'il vous plait vous connecter avec votre nom d'utilisateur et mot de passe." diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/css/custom.css b/code/ryzom/tools/server/ryzom_ams/www/html/css/custom.css index d4688a89d..28e29141f 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/css/custom.css +++ b/code/ryzom/tools/server/ryzom_ams/www/html/css/custom.css @@ -19,3 +19,10 @@ .navbar { border-bottom: 0px; } + +.flags { + display: block; + position:relative; + left:290px; + top:28px; +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/img/en.png b/code/ryzom/tools/server/ryzom_ams/www/html/img/en.png new file mode 100644 index 0000000000000000000000000000000000000000..6505dc41bf7b149e23135b89b37db9a6855e9163 GIT binary patch literal 725 zcmV;`0xJE9P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02*{fSaefwW^{L9 za%BKeVQFr3E>1;MAa*k@H7+qQF!XYv0006+Nkl5XaAB54}i*g%3Ri z#in6wrGhMGhJp#znkkE}X@-ba=0jv{?xq!f;a4Au8k%94r5UM#nX)Nak)p0qDj^YU z5Oh`+EYoH;$8{e$lk!7q}Mj zWT;A1Q}*gv-4nV-AoJ~D6tC)^vo)vzqqz&QDF<=j#1rm!`KJEIYTjRAJJ$3j4b`-hxrIO`E7_x%|p~3${;$sm4MxiY}{GPh8`8G5hlTTO_q3;r}vuS^V*ThRO#h^RC|200000NkvXX Hu0mjfj3!K^ literal 0 HcmV?d00001 diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/img/fr.png b/code/ryzom/tools/server/ryzom_ams/www/html/img/fr.png new file mode 100644 index 0000000000000000000000000000000000000000..60ed561d4f39c3520239d77c1dd948e22977796e GIT binary patch literal 675 zcmV;U0$lxxP)pF8gxZibW?9;ba!ELWdKlNX>N2bPDNB8 zb~7$DE-^4L^m3s900JLLL_t(IPsNixPg7wShR@~?aPS8>JG$!N;74LG8XFMdmp{4D1dEOUGNE|yj z+~ajU_w&4Y6+mexZNXx&a`S0~?dg9KB9TZCi^YgWqlCj@0)YU*U=U-cLV1TmK~cz= z$(WIX&yk{xFQoG^SfJT#(r7ef>h(IcT8(P8N^|THjnNS{9^R$)V3_2VAY5eri^|+` zj(5Hc#bOa%*C`YVflw@`@31cH$+?tMkDyX>k^(Z;kQd^%H^_z zw@Wgaj0yK(^mS9|wO|Yn@Jk48JPxrG(3tsT!i#BMEhH(GN}DZY0}WMG5dx#nN~Py4 zrS2}uL%l?Wz&5gq_gmhCe=}*qFFk7*h9O%BiAZaevQ5C9=;w}6ymf_$5LoZ8@cygH zBW?Jyfqx2I4@kWt!HdWM165Y{n`aIo5h4rp_=O~3&H-&9`>Ghv8QXA-5syl zb&5MMGwXCRH8q99;b44xT<$Dti^&3(f_6TV{0skG@CO0`4|2m%YCr%0002ov JPDHLkV1mp}FXI3J literal 0 HcmV?d00001 diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl index 075190b64..bfa20ee41 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl @@ -101,10 +101,14 @@
  • Logout
  • +
    +
    + + +
    +
    {/if} - - diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl index 53d46ddd6..59cb17574 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl @@ -3,7 +3,7 @@
    -

    User List

    +

    {$userlist_info}

    From 4034c833821f0c7e8401378752c26de347b04e89 Mon Sep 17 00:00:00 2001 From: Quitta Date: Sat, 29 Jun 2013 05:02:54 +0200 Subject: [PATCH 07/12] webUsers derived from Users, with www dependent functionality to check if username already in use or email already in use --HG-- branch : quitta-gsoc-2013 --- .../ryzom_ams/ams_lib/autoload/users.php | 64 ++++++++++--------- .../ryzom_ams/www/html/autoload/webusers.php | 29 +++++++++ .../ryzom_ams/www/html/inc/add_user.php | 7 +- .../ryzom_ams/www/html/templates/layout.tpl | 3 +- .../ryzom_ams/www/html/templates/userlist.tpl | 1 + 5 files changed, 69 insertions(+), 35 deletions(-) create mode 100644 code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php 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 c99e8567d..f8494b6a0 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 @@ -10,10 +10,10 @@ class Users{ public function check_Register($values){ // check values if ( isset( $values["Username"] ) and isset( $values["Password"] ) and isset( $values["Email"] ) ){ - $user = Users :: checkUser( $values["Username"] ); - $pass = Users :: checkPassword( $values["Password"] ); - $cpass = Users :: confirmPassword($pass); - $email = Users :: checkEmail( $values["Email"] ); + $user = Users::checkUser( $values["Username"] ); + $pass = Users::checkPassword( $values["Password"] ); + $cpass = Users::confirmPassword($pass); + $email = Users::checkEmail( $values["Email"] ); }else{ $user = ""; $pass = ""; @@ -62,6 +62,9 @@ class Users{ } } + + + /** * Function checkUser @@ -80,8 +83,8 @@ class Users{ return "Username can only contain numbers and letters."; }else if ( $username == "" ){ return "You have to fill in a username"; - /*}elseif ($this->dbs->execute("SELECT * FROM user WHERE Login = :name",array('name' => $username))->rowCount()){ - return "Username " . $username . " is in use.";*/ + }elseif ($this->checkUserNameExists($username)){ + return "Username " . $username . " is in use."; }else{ return "success"; } @@ -90,29 +93,16 @@ class Users{ } /** - * Function checkUserAlreadyExists + * Function checkUserNameExists * * @takes $username - * @return string Info: Returns true or false if the user is in the lib+shard db. - * - private function checkUserAlreadyExists( $username ) - { - global $cfg; - $dbl = new DBLayer($cfg['db']['lib']); - $dbs = new DBLayer($cfg['db']['shard']); - try{ - if ($this->dbl->execute("SELECT * FROM user WHERE Login = :name",array('name' => $username))->rowCount()){ - return true; - } - if ($this->dbs->execute("SELECT * FROM user WHERE Login = :name",array('name' => $username))->rowCount()){ - return true; - } - return false; - }catch (PDOException $e) { - //in case one of them is offline let it be hanled lateron with the - return true; - } - }*/ + * @return string Info: Returns true or false if the user is in the www db. + */ + protected function checkUserNameExists($username){ + //You should overwrite this method with your own version! + print('this is the base class!'); + + } /** @@ -172,9 +162,9 @@ class Users{ return "Email address is not valid."; }else if($email == ""){ return "You have to fill in an email address"; - /*}elseif ( $this->dbs->execute("SELECT * FROM user WHERE Email = :email",array('email' => $email))->rowCount()){ - return "Email is in use.";*/} - else{ + }else if ($this->checkEmailExists($email)){ + return "Email is in use."; + }else{ return "success"; } } @@ -182,7 +172,19 @@ class Users{ } - + /** + * Function checkEmailExists + * + * @takes $username + * @return string Info: Returns true or false if the user is in the www db. + */ + protected function checkEmailExists($email){ + //TODO: You should overwrite this method with your own version! + print('this is the base class!'); + + } + + /** * Function validEmail * diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php b/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php new file mode 100644 index 000000000..48b6a1f94 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php @@ -0,0 +1,29 @@ +execute("SELECT * FROM ams_user WHERE Login = :name",array('name' => $username))->rowCount(); + } + + + /** + * Function checkEmailExists + * + * @takes $username + * @return string Info: Returns true or false if the user is in the www db. + */ + protected function checkEmailExists($email){ + global $cfg; + $dbw = new DBLayer($cfg['db']['web']); + return $dbw->execute("SELECT * FROM ams_user WHERE Email = :email",array('email' => $email))->rowCount(); + } +} \ No newline at end of file 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 46dfea6b4..bd10fb1e4 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 @@ -3,7 +3,8 @@ function add_user(){ $params = Array('Username' => $_POST["Username"], 'Password' => $_POST["Password"], 'Email' => $_POST["Email"]); - $result = Users::check_Register($params); + $webUser = new WebUsers; + $result = $webUser->check_Register($params); // if all are good then create user if ( $result == "success"){ @@ -37,7 +38,7 @@ function add_user(){ function write_user($newUser){ //create salt here, because we want it to be the same on the web/server - $hashpass = crypt($newUser["pass"], Users::generateSALT()); + $hashpass = crypt($newUser["pass"], WebUsers::generateSALT()); $params = array( 'name' => $newUser["name"], @@ -51,7 +52,7 @@ function write_user($newUser){ //Create the user on the shard + in case shard is offline put copy of query in query db //returns: ok, shardoffline or liboffline - $result = Users::createUser($values); + $result = WebUsers::createUser($values); try{ //make connection with web db and put it in there diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl index bfa20ee41..3ef43941d 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl @@ -101,13 +101,13 @@
  • Logout
  • + {/if}
    - {/if}
    @@ -245,6 +245,7 @@ +
    diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl index 59cb17574..d5e076161 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl @@ -13,6 +13,7 @@

    The shard/lib/web db user list You are about to see it here!

    +
    lolbol
    From a3b3dbd59c45cc0420c97e2b6783e6d5eb6f9855 Mon Sep 17 00:00:00 2001 From: Quitta Date: Sat, 29 Jun 2013 05:23:38 +0200 Subject: [PATCH 08/12] Changed the way index handles page requests, also made a folder func, for when a form is submitted and requires a function to be performed and inc for pages that want to perform php code but without a form --HG-- branch : quitta-gsoc-2013 --- .../www/html/css/bootstrap-cerulean.css | 1 + .../www/html/{inc => func}/add_user.php | 0 .../www/html/{inc => func}/login.php | 0 .../www/html/{autoload => inc}/logout.php | 0 .../tools/server/ryzom_ams/www/html/index.php | 26 ++++++++++--------- .../ryzom_ams/www/html/templates/userlist.tpl | 1 - 6 files changed, 15 insertions(+), 13 deletions(-) rename code/ryzom/tools/server/ryzom_ams/www/html/{inc => func}/add_user.php (100%) rename code/ryzom/tools/server/ryzom_ams/www/html/{inc => func}/login.php (100%) rename code/ryzom/tools/server/ryzom_ams/www/html/{autoload => inc}/logout.php (100%) diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/css/bootstrap-cerulean.css b/code/ryzom/tools/server/ryzom_ams/www/html/css/bootstrap-cerulean.css index 82037d419..57716d2f7 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/css/bootstrap-cerulean.css +++ b/code/ryzom/tools/server/ryzom_ams/www/html/css/bootstrap-cerulean.css @@ -4451,3 +4451,4 @@ i[class^="icon-"] { .invisible { visibility: hidden; } + diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/add_user.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/add_user.php similarity index 100% rename from code/ryzom/tools/server/ryzom_ams/www/html/inc/add_user.php rename to code/ryzom/tools/server/ryzom_ams/www/html/func/add_user.php diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/login.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/login.php similarity index 100% rename from code/ryzom/tools/server/ryzom_ams/www/html/inc/login.php rename to code/ryzom/tools/server/ryzom_ams/www/html/func/login.php diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/autoload/logout.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/logout.php similarity index 100% rename from code/ryzom/tools/server/ryzom_ams/www/html/autoload/logout.php rename to code/ryzom/tools/server/ryzom_ams/www/html/inc/logout.php 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 dfd194049..50d519157 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/index.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/index.php @@ -5,14 +5,6 @@ require( '../config.php' ); require( '../../ams_lib/libinclude.php' ); session_start(); -//print_r($_SESSION); - -//perform an action in case one is specified -if ( isset( $_POST["function"] ) ){ - require( "inc/" . $_POST["function"] . ".php" ); - $return = $_POST["function"](); -} - //Decide what page to load if(isset($_SESSION['user'])){ $page = 'home'; @@ -22,18 +14,28 @@ if(isset($_SESSION['user'])){ $page = 'login'; } -if ( isset( $_GET["page"] ) ){ - $page = $_GET["page"]; +//perform an action in case one is specified +//else check if a php page is included in the inc folder, else just set page to the get param +if ( isset( $_POST["function"] ) ){ + require( "func/" . $_POST["function"] . ".php" ); + $return = $_POST["function"](); +}else if ( isset( $_GET["page"] ) ){ + $filename = 'inc/' . $_GET["page"] . '.php'; + if(is_file($filename)){ + require_once($filename); } + $page = $_GET["page"]; +} -function loadpage ( $page ){ + +/*function loadpage ( $page ){ $filename = 'autoload/' . $page . '.php'; if(is_file($filename)){ require_once($filename); } } -loadpage($page); +loadpage($page);*/ //Set permission if(isset($_SESSION['permission'])){ diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl index d5e076161..59cb17574 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl @@ -13,7 +13,6 @@

    The shard/lib/web db user list You are about to see it here!

    -
    lolbol
    From 4f82afa5d0cf4b1523afe62f80f88decb4b89fbf Mon Sep 17 00:00:00 2001 From: Quitta Date: Sat, 29 Jun 2013 06:46:10 +0200 Subject: [PATCH 09/12] added libuserlist page, that shows entire list of users in the lib db, admins can remove entry of it and perform manual syncing. Still needs some work though --HG-- branch : quitta-gsoc-2013 --- .../ryzom_ams/ams_lib/translations/en.ini | 2 + .../tools/server/ryzom_ams/www/config.php | 2 +- .../ryzom_ams/www/html/inc/libuserlist.php | 50 +++++++++++++++++++ .../www/html/templates/libuserlist.tpl | 26 ++++++++++ 4 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 code/ryzom/tools/server/ryzom_ams/www/html/inc/libuserlist.php create mode 100644 code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl 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 c60e5a621..71bcdb9fe 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 @@ -3,6 +3,8 @@ [home] +[libuserlist] + [userlist] userlist_info = "welcome to the userlist" diff --git a/code/ryzom/tools/server/ryzom_ams/www/config.php b/code/ryzom/tools/server/ryzom_ams/www/config.php index b896879a9..5141359cc 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/config.php +++ b/code/ryzom/tools/server/ryzom_ams/www/config.php @@ -19,7 +19,7 @@ $cfg['db']['lib']['name'] = 'ryzom_ams_lib'; $cfg['db']['lib']['user'] = 'root'; $cfg['db']['lib']['pass'] = 'lol123'; -$cfg['db']['shard']['host'] = 'localhost'; +$cfg['db']['shard']['host'] = 'localhosti'; $cfg['db']['shard']['port'] = '3306'; $cfg['db']['shard']['name'] = 'nel'; $cfg['db']['shard']['user'] = 'shard'; diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/libuserlist.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/libuserlist.php new file mode 100644 index 000000000..5d6128f09 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/libuserlist.php @@ -0,0 +1,50 @@ +executeWithoutParams("SELECT * FROM ams_querycache")->rowCount(); + +//This is the number of results displayed per page +$page_rows = 2; + +//This tells us the page number of our last page +$last = ceil($rows/$page_rows); + +//this makes sure the page number isn't below one, or more than our maximum pages +if ($pagenum < 1) +{ + $pagenum = 1; +}else if ($pagenum > $last) { + $pagenum = $last; +} + +//This sets the range to display in our query +$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; + +//This is your query again, the same one... the only difference is we add $max into it +$data = $dbl->executeWithoutParams("SELECT * FROM ams_querycache $max"); + +//This is where we put the results in a resultArray to be sent to smarty + +$pageResult['liblist'] = Array(); +$i = 0; +while($row = $data->fetch(PDO::FETCH_ASSOC)){ + $decode = json_decode($row['query']); + $pageResult['liblist'][$i]['id'] = $row['SID']; + $pageResult['liblist'][$i]['type'] = $row['type']; + $pageResult['liblist'][$i]['name'] = $decode[0]; + $pageResult['liblist'][$i]['mail'] = $decode[2]; + $i++; +} +$pageResult['permission'] = 1; +$pageResult['no_visible_elements'] = 'FALSE'; +helpers :: loadtemplate( 'libuserlist', $pageResult); +exit(); diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl new file mode 100644 index 000000000..4cf8f99a4 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl @@ -0,0 +1,26 @@ +{block name=content} + +
    +
    +
    +

    The users in the libDB

    +
    + + + + +
    +
    +
    + + + {foreach from=$liblist item=element} + + {/foreach} +
    IDtypeuseremailremove
    {$element.id}{$element.type}{$element.name}{$element.mail}Delete
    +
    +
    +
    +
    +{/block} + From 8ff40bb6199ed8e815d1e615f9368f191ba25eec Mon Sep 17 00:00:00 2001 From: Quitta Date: Sat, 29 Jun 2013 19:05:54 +0200 Subject: [PATCH 10/12] added initial admin/admin account when sql/install is executed, also added the admin's functionality: libuserlist --HG-- branch : quitta-gsoc-2013 --- .../ryzom_ams/ams_lib/autoload/users.php | 4 +- .../ryzom_ams/ams_lib/translations/en.ini | 5 + .../tools/server/ryzom_ams/www/config.php | 2 +- .../ryzom_ams/www/html/func/add_user.php | 6 +- .../ryzom_ams/www/html/inc/libuserlist.php | 104 ++++++++++-------- .../tools/server/ryzom_ams/www/html/index.php | 14 +-- .../server/ryzom_ams/www/html/sql/install.php | 44 +++++--- .../www/html/templates/layout_admin.tpl | 14 +-- .../www/html/templates/layout_user.tpl | 5 +- .../www/html/templates/libuserlist.tpl | 61 ++++++++-- 10 files changed, 160 insertions(+), 99 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 f8494b6a0..69a04ed89 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 @@ -287,7 +287,7 @@ class Users{ try { //make connection with and put into shard db global $cfg; - $dbs = new DBLayer($cfg['db']['shard']); + $dbs = new DBLayer($cfg['db']['shard']); $dbs->execute("INSERT INTO user (Login, Password, Email) VALUES (:name, :pass, :mail)",$values["params"]); return "ok"; } @@ -296,7 +296,7 @@ class Users{ try { $dbl = new DBLayer($cfg['db']['lib']); $dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "createUser", - "query" => json_encode(array($values["params"]["name"],$values["params"]["pass"],$values["params"]["mail"])))); + "query" => json_encode(array($values["name"],$values["pass"],$values["mail"])))); return "shardoffline"; }catch (PDOException $e) { print_r($e); 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 71bcdb9fe..dd83a5cfe 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,6 +4,11 @@ [home] [libuserlist] +libuserlist_title = "LibDB-Query List" +libuserlist_info = "Here you can see the entire list of elements in the LibDB-Query table. You can easily remove elements and by pressing 'Synchronize' you can start the syncing process manually!" +libuserlist_sync = "Synchronize" +shard_online = "The shard seems to be online, manually syncing is possible: " +shard_offline = "The shard seems to be offline, manually syncing is not possible!" [userlist] userlist_info = "welcome to the userlist" diff --git a/code/ryzom/tools/server/ryzom_ams/www/config.php b/code/ryzom/tools/server/ryzom_ams/www/config.php index 5141359cc..b896879a9 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/config.php +++ b/code/ryzom/tools/server/ryzom_ams/www/config.php @@ -19,7 +19,7 @@ $cfg['db']['lib']['name'] = 'ryzom_ams_lib'; $cfg['db']['lib']['user'] = 'root'; $cfg['db']['lib']['pass'] = 'lol123'; -$cfg['db']['shard']['host'] = 'localhosti'; +$cfg['db']['shard']['host'] = 'localhost'; $cfg['db']['shard']['port'] = '3306'; $cfg['db']['shard']['name'] = 'nel'; $cfg['db']['shard']['user'] = 'shard'; diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/add_user.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/add_user.php index bd10fb1e4..8fc6f311b 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/func/add_user.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/add_user.php @@ -46,13 +46,9 @@ function write_user($newUser){ 'mail' => $newUser["mail"] ); - //print_r($params); - //make a $values array for passing all data to the Users::createUser() function. - $values["params"] = $params; - //Create the user on the shard + in case shard is offline put copy of query in query db //returns: ok, shardoffline or liboffline - $result = WebUsers::createUser($values); + $result = WebUsers::createUser($params); try{ //make connection with web db and put it in there diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/libuserlist.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/libuserlist.php index 5d6128f09..cf50dad36 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/libuserlist.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/libuserlist.php @@ -1,50 +1,60 @@ executeWithoutParams("SELECT * FROM ams_querycache")->rowCount(); - -//This is the number of results displayed per page -$page_rows = 2; - -//This tells us the page number of our last page -$last = ceil($rows/$page_rows); - -//this makes sure the page number isn't below one, or more than our maximum pages -if ($pagenum < 1) -{ - $pagenum = 1; -}else if ($pagenum > $last) { - $pagenum = $last; -} - -//This sets the range to display in our query -$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; - -//This is your query again, the same one... the only difference is we add $max into it -$data = $dbl->executeWithoutParams("SELECT * FROM ams_querycache $max"); - -//This is where we put the results in a resultArray to be sent to smarty - -$pageResult['liblist'] = Array(); -$i = 0; -while($row = $data->fetch(PDO::FETCH_ASSOC)){ - $decode = json_decode($row['query']); - $pageResult['liblist'][$i]['id'] = $row['SID']; - $pageResult['liblist'][$i]['type'] = $row['type']; - $pageResult['liblist'][$i]['name'] = $decode[0]; - $pageResult['liblist'][$i]['mail'] = $decode[2]; - $i++; -} -$pageResult['permission'] = 1; -$pageResult['no_visible_elements'] = 'FALSE'; -helpers :: loadtemplate( 'libuserlist', $pageResult); -exit(); +function libuserlist(){ + + //This checks to see if there is a page number. If not, it will set it to page 1 + if (!(isset($_GET['pagenum']))){ + $pagenum = 1; + }else{ + $pagenum = $_GET['pagenum']; + } + + //Here we count the number of results + global $cfg; + $dbl = new DBLayer($cfg['db']['lib']); + $rows = $dbl->executeWithoutParams("SELECT * FROM ams_querycache")->rowCount(); + if($rows > 0){ + //This is the number of results displayed per page + $page_rows = 2; + + //This tells us the page number of our last page + $last = ceil($rows/$page_rows); + + //this makes sure the page number isn't below one, or more than our maximum pages + if ($pagenum < 1) + { + $pagenum = 1; + }else if ($pagenum > $last) { + $pagenum = $last; + } + + //This sets the range to display in our query + $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; + + //This is your query again, the same one... the only difference is we add $max into it + $data = $dbl->executeWithoutParams("SELECT * FROM ams_querycache $max"); + + //This is where we put the results in a resultArray to be sent to smarty + + $pageResult['liblist'] = Array(); + $i = 0; + while($row = $data->fetch(PDO::FETCH_ASSOC)){ + $decode = json_decode($row['query']); + $pageResult['liblist'][$i]['id'] = $row['SID']; + $pageResult['liblist'][$i]['type'] = $row['type']; + $pageResult['liblist'][$i]['name'] = $decode[0]; + $pageResult['liblist'][$i]['mail'] = $decode[2]; + $i++; + } + } + + //check if shard is online + try{ + $dbs = new DBLayer($cfg['db']['shard']); + $pageResult['shard'] = "online"; + }catch(PDOException $e) { + $pageResult['shard'] = "offline"; + } + return $pageResult; +} \ 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 50d519157..d7f234d0d 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/index.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/index.php @@ -8,7 +8,6 @@ session_start(); //Decide what page to load if(isset($_SESSION['user'])){ $page = 'home'; - $return['username'] = $_SESSION['user']; }else{ //default page $page = 'login'; @@ -23,19 +22,18 @@ if ( isset( $_POST["function"] ) ){ $filename = 'inc/' . $_GET["page"] . '.php'; if(is_file($filename)){ require_once($filename); + $return = $_GET["page"](); } $page = $_GET["page"]; } - -/*function loadpage ( $page ){ - $filename = 'autoload/' . $page . '.php'; - if(is_file($filename)){ - require_once($filename); - } +//add username to the return array in case logged in. +if(isset($_SESSION['user'])){ + $return['username'] = $_SESSION['user']; } + + -loadpage($page);*/ //Set permission if(isset($_SESSION['permission'])){ diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php b/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php index 09ba63d54..e9e3ecac1 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php @@ -1,21 +1,15 @@ setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $dbw = new DBLayer($cfg['db']['web']); $sql = " CREATE DATABASE IF NOT EXISTS `ryzom_ams`; USE `ryzom_ams`; @@ -32,12 +26,10 @@ ); "; - $statement = $dbw->prepare($sql); - $statement->execute(); + $dbw->executeWithoutParams($sql); //SETUP THE AMS_LIB DB - $dbl = new PDO("mysql:host=$LIBDBHOST;", $LIBDBUSERNAME, $LIBDBPASSWORD); - $dbl->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $dbl = new DBLayer($cfg['db']['lib']); $sql = " CREATE DATABASE IF NOT EXISTS `ryzom_ams_lib`; USE `ryzom_ams_lib`; @@ -49,16 +41,34 @@ `query` VARCHAR( 512 ) NOT NULL ); "; - $statement = $dbl->prepare($sql); - $statement->execute(); - print('Install completed successful!'); + $dbl->executeWithoutParams($sql); + print "The Lib & Web database were correctly installed!
    "; + + //Now create an admin account! + $hashpass = crypt("admin", Users::generateSALT()); + $params = array( + 'name' => "admin", + 'pass' => $hashpass, + 'mail' => "admin@admin.com", + ); + Users::createUser($params); + try{ + $params['permission'] = 2; + $dbw = new DBLayer($cfg['db']['web']); + $dbw->execute("INSERT INTO ams_user (Login, Password, Email, Permission) VALUES (:name, :pass, :mail, :permission)",$params); + print "The admin account is created, you can login with id: admin, pass: admin!"; + }catch (PDOException $e){ + print "There was an error while creating the admin account! "; + } + + }catch (PDOException $e) { //go to error page or something, because can't access website db - print('There was an error while installing'); + print "There was an error while installing"; print_r($e); } diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_admin.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_admin.tpl index 73cddd510..daa8906ad 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_admin.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_admin.tpl @@ -1,15 +1,11 @@ {extends file="layout.tpl"} {block name=menu} -
  • Dashboard
  • -
  • Settings
  • -
  • Logout
  • +
  • Dashboard
  • -
  • UserList
  • -
  • BanList
  • - -
  • General Queue
  • -
  • Personal Queue
  • -
  • Ticket Archive
  • +
  • Liblist
  • + +
  • Logout
  • + {/block} 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 7809f829a..4d305b323 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 @@ -2,9 +2,8 @@ {block name=menu}
  • Dashboard
  • -
  • Userlist
  • - -
  • Login Page
  • +
  • Demo Userlist
  • +
  • Logout
  • {/block} diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl index 4cf8f99a4..cb40121b8 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl @@ -3,7 +3,7 @@
    -

    The users in the libDB

    +

    {$libuserlist_title}

    @@ -12,15 +12,62 @@
    - - - {foreach from=$liblist item=element} - - {/foreach} -
    IDtypeuseremailremove
    {$element.id}{$element.type}{$element.name}{$element.mail}Delete
    +
    +

    {$libuserlist_info}

    + {if $shard eq "online"} +
    + {$shard_online}{$libuserlist_sync} +
    + {else} +
    + {$shard_offline} +
    + {/if} +
    +
    +
    +
    +

    Members

    +
    + + + +
    +
    +
    + + + + + + + + + + + + {foreach from=$liblist item=element} + + + + + + + + + {/foreach} + + +
    IDTypeNameEmailAction
    {$element.id}{$element.type}{$element.name}{$element.mail} + Delete +
    +
    +
    + +
    {/block} From 40d6617216dc0c799526b905fdbdfe8181742443 Mon Sep 17 00:00:00 2001 From: Quitta Date: Sat, 29 Jun 2013 20:46:38 +0200 Subject: [PATCH 11/12] added flags to inlog/logout etc, + added some base translations --HG-- branch : quitta-gsoc-2013 --- .../ryzom_ams/ams_lib/translations/en.ini | 11 ++++++++++ .../ryzom_ams/ams_lib/translations/fr.ini | 17 +++++++++++++++ .../server/ryzom_ams/www/html/css/custom.css | 7 +++++++ .../ryzom_ams/www/html/inc/libuserlist.php | 4 +++- .../server/ryzom_ams/www/html/js/help.js | 1 + .../ryzom_ams/www/html/templates/home.tpl | 4 ++-- .../ryzom_ams/www/html/templates/layout.tpl | 9 ++++++++ .../www/html/templates/libuserlist.tpl | 21 ++++++++++++------- .../ryzom_ams/www/html/templates/login.tpl | 3 +-- 9 files changed, 65 insertions(+), 12 deletions(-) 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 dd83a5cfe..32424d073 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 @@ -2,6 +2,8 @@ ; Comments start with ';', as in php.ini [home] +home_title = "Introduction" +home_info = "Welcome to the Ryzom Core - Account Management System" [libuserlist] libuserlist_title = "LibDB-Query List" @@ -9,6 +11,13 @@ libuserlist_info = "Here you can see the entire list of elements in the LibDB-Qu libuserlist_sync = "Synchronize" shard_online = "The shard seems to be online, manually syncing is possible: " shard_offline = "The shard seems to be offline, manually syncing is not possible!" +members = "Members" +id = "ID" +type = "Type" +name = "Name" +email = "Email" +action = "Action" + [userlist] userlist_info = "welcome to the userlist" @@ -16,6 +25,8 @@ userlist_info = "welcome to the userlist" [login] login_info = "Please login with your Username and Password." login_error_message = "The filled in username/password were not correct!" +login_register_message ="RegisterIf you dont have an account yet, create one" +login_register_message_here = "here" [logout] logout_message = "You've been logged out successfully!" diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini index 432845f91..e44f38aad 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini @@ -2,6 +2,21 @@ ; Comments start with ';', as in php.ini [home] +home_title = "Presentation" +home_info = "Bienvenue sur le Ryzom Core - Account Management System" + +[libuserlist] +libuserlist_title = "LibDB-Query Liste" +libuserlist_info = "Ici vous pouvez voir la liste complete des elements dans le tableau libdb-Query. Vous pouvez facilement supprimer des elements et appuyant sur 'Synchroniser', vous pouvez commencer le processus de synchronisation manuellement!" +libuserlist_sync = "Synchroniser" +shard_online = "Le shard semble etre ligne , la synchronisation manuellement est possible: " +shard_offline = "Le shard semble etre deconnecte , la synchronisation manuellement n' est pas possible!" +members = "Membres" +id = "ID" +type = "Categorie" +name = "Nom" +email = "Email" +action = "Action" [userlist] userlist_info = "bienvenue sur le userlist page!" @@ -9,6 +24,8 @@ userlist_info = "bienvenue sur le userlist page!" [login] login_info = "S'il vous plait vous connecter avec votre nom d'utilisateur et mot de passe." login_error_message = "Le remplie nom d'utilisateur / mot de passe ne sont pas correctes!" +login_register_message =" Inscrivez-vous Si vous n'avez pas encore de compte, creez-en un" +login_register_message_here = "ici" [logout] logout_message = "Vous avez été déconnecté avec succès!" diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/css/custom.css b/code/ryzom/tools/server/ryzom_ams/www/html/css/custom.css index 28e29141f..2e94ade39 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/css/custom.css +++ b/code/ryzom/tools/server/ryzom_ams/www/html/css/custom.css @@ -25,4 +25,11 @@ position:relative; left:290px; top:28px; +} + +.flags_no_visible_elements{ + display: block; + position:relative; + left:67%; + top:210px; } \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/libuserlist.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/libuserlist.php index cf50dad36..3bb43d39e 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/libuserlist.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/libuserlist.php @@ -14,6 +14,9 @@ function libuserlist(){ global $cfg; $dbl = new DBLayer($cfg['db']['lib']); $rows = $dbl->executeWithoutParams("SELECT * FROM ams_querycache")->rowCount(); + + //the array hat will contain all users + $pageResult['liblist'] = Array(); if($rows > 0){ //This is the number of results displayed per page $page_rows = 2; @@ -37,7 +40,6 @@ function libuserlist(){ //This is where we put the results in a resultArray to be sent to smarty - $pageResult['liblist'] = Array(); $i = 0; while($row = $data->fetch(PDO::FETCH_ASSOC)){ $decode = json_decode($row['query']); diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/js/help.js b/code/ryzom/tools/server/ryzom_ams/www/html/js/help.js index 60a9980aa..3c1fad7b3 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/js/help.js +++ b/code/ryzom/tools/server/ryzom_ams/www/html/js/help.js @@ -25,3 +25,4 @@ function show_help(help_tip) } +$("#sync").click(function() {alert("Handler for .click() called.");}); \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/home.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/home.tpl index fb14ba5ba..6198b53a1 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/home.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/home.tpl @@ -34,7 +34,7 @@
    -

    Introduction

    +

    {$home_title}

    @@ -43,7 +43,7 @@
    -

    Welcome to the Ryzom Core - Account Management System

    +

    {$home_info}

    diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl index 3ef43941d..c15e668cb 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl @@ -138,6 +138,15 @@
    {/if} + + {if isset($no_visible_elements) and $no_visible_elements eq "TRUE"} + +
    + + +
    + + {/if} {block name=content}{/block} diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl index cb40121b8..e8dee32fd 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl @@ -16,7 +16,14 @@

    {$libuserlist_info}

    {if $shard eq "online"}
    - {$shard_online}{$libuserlist_sync} + {$shard_online}{$libuserlist_sync} +
    {else}
    @@ -31,7 +38,7 @@
    -

    Members

    +

    {$members}

    @@ -42,11 +49,11 @@ - - - - - + + + + + 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 a31bfe6c7..2fbde3b50 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 @@ -43,8 +43,7 @@ {/if}
    - Register - If you dont have an account yet, create one here! + {$login_register_message} {$login_register_message_here}!
    From a769a985d9552452971b4d96b6b9cab7c39abd3e Mon Sep 17 00:00:00 2001 From: Quitta Date: Sun, 30 Jun 2013 05:53:31 +0200 Subject: [PATCH 12/12] template for changing the settings added, still needs quite some work --HG-- branch : quitta-gsoc-2013 --- .../ryzom_ams/ams_lib/translations/en.ini | 2 + .../ryzom_ams/ams_lib/translations/fr.ini | 2 + .../server/ryzom_ams/www/html/inc/logout.php | 9 +- .../ryzom_ams/www/html/templates/settings.tpl | 400 ++++++++++++++++++ .../ryzom_ams/www/html/templates/userlist.tpl | 2 +- 5 files changed, 409 insertions(+), 6 deletions(-) create mode 100644 code/ryzom/tools/server/ryzom_ams/www/html/templates/settings.tpl 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 32424d073..56c07761f 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 @@ -5,6 +5,8 @@ home_title = "Introduction" home_info = "Welcome to the Ryzom Core - Account Management System" +[settings] + [libuserlist] libuserlist_title = "LibDB-Query List" libuserlist_info = "Here you can see the entire list of elements in the LibDB-Query table. You can easily remove elements and by pressing 'Synchronize' you can start the syncing process manually!" diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini index e44f38aad..56c07b555 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini @@ -5,6 +5,8 @@ home_title = "Presentation" home_info = "Bienvenue sur le Ryzom Core - Account Management System" +[settings] + [libuserlist] libuserlist_title = "LibDB-Query Liste" libuserlist_info = "Ici vous pouvez voir la liste complete des elements dans le tableau libdb-Query. Vous pouvez facilement supprimer des elements et appuyant sur 'Synchroniser', vous pouvez commencer le processus de synchronisation manuellement!" diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/logout.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/logout.php index a52172d5a..83ed2080d 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/logout.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/logout.php @@ -1,7 +1,6 @@ +
    +
    +

    Settings

    +
    + + +
    +
    +
    + + +
    +
    +
    + Change Password + +
    + +
    +
    + + +
    +
    +
    + +
    + +
    +
    + + +
    +
    +
    + +
    + +
    +
    + + +
    +
    +
    + + + +
    + +
    + +
    +
    + +
    +
    +
    + Change Email +
    + +
    +
    + + +
    +
    +
    + +
    + +
    + +
    +
    + +
    +
    +
    + Change Info + +
    + +
    +
    + + +
    +
    +
    + +
    + +
    +
    + + +
    +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    + +
    + +
    +
    + + + +
    + +
    + +
    +
    + +
    +
    +
    +
    + +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl index 59cb17574..891bbd04b 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl @@ -3,7 +3,7 @@
    -

    {$userlist_info}

    +

    {$userlist_info}

    IDTypeNameEmailAction{$id}{$type}{$name}{$email}{$action}