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..240eda426 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php @@ -0,0 +1,44 @@ + 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){ + try{ + $statement = $this->PDO->prepare($query); + $statement->execute(); + return $statement; + }catch (PDOException $e) { + throw $e; + } + } + + public function execute($query,$params){ + 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/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/autoload/sync.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php new file mode 100644 index 000000000..170a1c4bf --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php @@ -0,0 +1,45 @@ +executeWithoutParams("SELECT * FROM ams_querycache"); + $rows = $statement->fetchAll(); + $dbs = new DBLayer($cfg['db']['shard']); + foreach ($rows as $record) { + + switch($record['type']) { + case 'createPermissions': + case 'user_edit': + case 'createUser': + $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'); + } + 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..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 @@ -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"; - } + private function checkUser( $username ) + { + 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->checkUserNameExists($username)){ + return "Username " . $username . " is in use."; + }else{ + return "success"; + } + } + return "fail"; + } + + /** + * Function checkUserNameExists + * + * @takes $username + * @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!'); + + } + + /** * Function checkPassword * * @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 ){ @@ -114,13 +126,15 @@ class Users{ } return "fail"; } + + /** * Function confirmPassword * * @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."; @@ -133,34 +147,51 @@ class Users{ } return "fail"; } + + /** * Function checkEmail * * @takes $email * @return */ - public function checkEmail( $email ) + private function checkEmail( $email ) { if ( isset( $email ) ){ if ( !Users::validEmail( $email ) ){ return "Email address is not valid."; }else if($email == ""){ return "You have to fill in an email address"; + }else if ($this->checkEmailExists($email)){ + 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"; + } - public function validEmail( $email ){ + + /** + * 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 + * + * @takes $email + * @return true or false depending on if its a valid email format. + */ + private function validEmail( $email ){ $isValid = true; $atIndex = strrpos( $email, "@" ); if ( is_bool( $atIndex ) && !$atIndex ){ @@ -203,6 +234,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 @@ -236,56 +275,28 @@ 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){ - - $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"]; - + + + /** + * 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. + */ + public function createUser($values){ 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"]); + 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 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($cfg['db']['lib']); + $dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "createUser", + "query" => json_encode(array($values["name"],$values["pass"],$values["mail"])))); return "shardoffline"; }catch (PDOException $e) { print_r($e); @@ -293,8 +304,7 @@ class Users{ } } - } - + } } 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 @@ +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" [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 2c00c81ef..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 @@ -1,21 +1,70 @@ ; This is a sample configuration file ; Comments start with ';', as in php.ini +[home] +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!" +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!" + +[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!" +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 diff --git a/code/ryzom/tools/server/ryzom_ams/www/config.php b/code/ryzom/tools/server/ryzom_ams/www/config.php index 2ecaa7eaa..d68ac18de 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 = '' ; +$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'] = ''; -//the ams_lib db -$LIBDBHOST = 'localhost'; -$LIBDBPORT = '3306'; -$LIBDBNAME = 'ryzom_ams_lib'; -$LIBDBUSERNAME = 'root'; -$LIBDBPASSWORD = '' ; +$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'] = ''; -//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/autoload/logout.php b/code/ryzom/tools/server/ryzom_ams/www/html/autoload/logout.php deleted file mode 100644 index a52172d5a..000000000 --- a/code/ryzom/tools/server/ryzom_ams/www/html/autoload/logout.php +++ /dev/null @@ -1,7 +0,0 @@ -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/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/css/custom.css b/code/ryzom/tools/server/ryzom_ams/www/html/css/custom.css index d4688a89d..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 @@ -19,3 +19,17 @@ .navbar { border-bottom: 0px; } + +.flags { + display: block; + 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/func/add_user.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/add_user.php new file mode 100644 index 000000000..8fc6f311b --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/add_user.php @@ -0,0 +1,67 @@ + $_POST["Username"], 'Password' => $_POST["Password"], 'Email' => $_POST["Email"]); + $webUser = new WebUsers; + $result = $webUser->check_Register($params); + + // if all are good then create user + if ( $result == "success"){ + $edit = array( + 'name' => $_POST["Username"], + 'pass' => $_POST["Password"], + 'mail' => $_POST["Email"], + 'init' => $_POST["Email"], + 'unhashpass' => $_POST["Password"], + 'status' => 1, + 'access' => $_SERVER['REQUEST_TIME'] + ); + $status = write_user( $edit ); + $pageElements['status'] = $status; + $pageElements['no_visible_elements'] = 'TRUE'; + helpers :: loadtemplate( 'register_feedback', $pageElements); + exit; + }else{ + // pass error + $result['prevUsername'] = $_POST["Username"]; + $result['prevPassword'] = $_POST["Password"]; + $result['prevConfirmPass'] = $_POST["ConfirmPass"]; + $result['prevEmail'] = $_POST["Email"]; + $result['no_visible_elements'] = 'TRUE'; + helpers :: loadtemplate( 'register', $result); + exit; + } +} + + +function write_user($newUser){ + + //create salt here, because we want it to be the same on the web/server + $hashpass = crypt($newUser["pass"], WebUsers::generateSALT()); + + $params = array( + 'name' => $newUser["name"], + 'pass' => $hashpass, + 'mail' => $newUser["mail"] + ); + + //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($params); + + 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); + + }catch (PDOException $e) { + //go to error page or something, because can't access website db + print_r($e); + exit; + } + + return $result; + +} 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 63% 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 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/func/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); 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 000000000..6505dc41b Binary files /dev/null and b/code/ryzom/tools/server/ryzom_ams/www/html/img/en.png differ 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 000000000..60ed561d4 Binary files /dev/null and b/code/ryzom/tools/server/ryzom_ams/www/html/img/fr.png differ 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 deleted file mode 100644 index 64733ddb2..000000000 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/add_user.php +++ /dev/null @@ -1,102 +0,0 @@ - $_POST["Username"], - 'pass' => $_POST["Password"], - 'mail' => $_POST["Email"], - 'init' => $_POST["Email"], - 'unhashpass' => $_POST["Password"], - '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; - }else{ - // pass error - $result['prevUsername'] = $_POST["Username"]; - $result['prevPassword'] = $_POST["Password"]; - $result['prevConfirmPass'] = $_POST["ConfirmPass"]; - $result['prevEmail'] = $_POST["Email"]; - $result['no_visible_elements'] = 'TRUE'; - helpers :: loadtemplate( 'register', $result); - exit; - } -} - - -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; - - //create salt here, because we want it to be the same on the web/server - $hashpass = crypt($newUser["pass"], Users::generateSALT()); - - $params = array( - 'name' => $newUser["name"], - 'pass' => $hashpass, - 'mail' => $newUser["mail"] - ); - - //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; - - - //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); - - 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); - - }catch (PDOException $e) { - //go to error page or something, because can't access website db - print_r($e); - exit; - } - - return $result; - -} 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..3bb43d39e --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/libuserlist.php @@ -0,0 +1,62 @@ +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; + + //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 + + $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/inc/logout.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/logout.php new file mode 100644 index 000000000..83ed2080d --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/logout.php @@ -0,0 +1,6 @@ +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/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 16d032be1..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 @@ -102,9 +102,13 @@
{/if} +
+
+ + +
+
- -
@@ -118,7 +122,8 @@ - + + @@ -133,6 +138,15 @@
{/if} + + {if isset($no_visible_elements) and $no_visible_elements eq "TRUE"} + +
+ + +
+ + {/if} {block name=content}{/block} @@ -240,6 +254,7 @@ +
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 24ba25093..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 @@ -1,9 +1,9 @@ {extends file="layout.tpl"} {block name=menu} -
  • Dashboard
  • - -
  • Login Page
  • +
  • Dashboard
  • +
  • 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 new file mode 100644 index 000000000..e8dee32fd --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl @@ -0,0 +1,80 @@ +{block name=content} + +
    +
    +
    +

    {$libuserlist_title}

    +
    + + + + +
    +
    +
    +
    +

    {$libuserlist_info}

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

    {$members}

    +
    + + + +
    +
    +
    + + + + + + + + + + + + {foreach from=$liblist item=element} + + + + + + + + + {/foreach} + + +
    {$id}{$type}{$name}{$email}{$action}
    {$element.id}{$element.type}{$element.name}{$element.mail} + Delete +
    +
    +
    + +
    +{/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 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}!
    diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/settings.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/settings.tpl new file mode 100644 index 000000000..213620fe9 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/settings.tpl @@ -0,0 +1,400 @@ +{block name=content} +
    +
    +
    +

    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 new file mode 100644 index 000000000..891bbd04b --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl @@ -0,0 +1,22 @@ +{block name=content} + +
    +
    +
    +

    {$userlist_info}

    +
    + + + + +
    +
    +
    +

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

    + +
    +
    +
    +
    +{/block} +