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}