From 12baee2fcfd01c054f33b892f3f20b6ca4553ddd Mon Sep 17 00:00:00 2001 From: Quitta Date: Tue, 30 Jul 2013 01:46:56 +0200 Subject: [PATCH] fix for getting client working + possibly auto login for ingame part --HG-- branch : quitta-gsoc-2013 --- code/nel/src/gui/widget_manager.cpp | 1 + .../data/gamedev/interfaces_v3/help.xml | 4 +- .../ryzom_ams/ams_lib/autoload/helpers.php | 46 ++++++++++++---- .../ams_lib/ingame_templates/home.tpl | 53 +++++++++++++++++++ .../ams_lib/ingame_templates/login.tpl | 40 ++++++++++++++ .../tools/server/ryzom_ams/www/config.php | 6 +++ .../tools/server/ryzom_ams/www/html/index.php | 19 ++++--- 7 files changed, 149 insertions(+), 20 deletions(-) create mode 100644 code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/home.tpl create mode 100644 code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/login.tpl diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index 22839a8cf..363abd64d 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -3156,6 +3156,7 @@ namespace NLGUI CWidgetManager::CWidgetManager() { + LinkHack(); CStringShared::createStringMapper(); CReflectableRegister::registerClasses(); diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/help.xml b/code/ryzom/client/data/gamedev/interfaces_v3/help.xml index 39cfb1af4..7cad23b26 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/help.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/help.xml @@ -863,8 +863,10 @@ + + value="http://localhost:40917/www/html/index.php" /> template_dir = $AMS_LIB . '/ingame_templates/'; $smarty -> setConfigDir( $AMS_LIB . '/configs' ); }else{ @@ -34,17 +34,21 @@ class Helpers{ foreach ( $variables[$template] as $key => $value ){ $smarty -> assign( $key, $value ); } - if( isset($vars['permission']) && $vars['permission'] == 3 ){ - $inherited = "extends:layout_admin.tpl|"; - }else if( isset($vars['permission']) && $vars['permission'] == 2){ - $inherited = "extends:layout_mod.tpl|"; - }else if( isset($vars['permission']) && $vars['permission'] == 1){ - $inherited = "extends:layout_user.tpl|"; + if (! helpers :: check_if_game_client ()){ + if( isset($vars['permission']) && $vars['permission'] == 3 ){ + $inherited = "extends:layout_admin.tpl|"; + }else if( isset($vars['permission']) && $vars['permission'] == 2){ + $inherited = "extends:layout_mod.tpl|"; + }else if( isset($vars['permission']) && $vars['permission'] == 1){ + $inherited = "extends:layout_user.tpl|"; + }else{ + $inherited =""; + } + // extends:' . $inherited .'|register.tpl + $smarty -> display( $inherited . $template . '.tpl' ); }else{ - $inherited =""; + $smarty -> display($template . '.tpl' ); } - // extends:' . $inherited .'|register.tpl - $smarty -> display( $inherited . $template . '.tpl' ); } static public function create_folders(){ @@ -70,7 +74,7 @@ class Helpers{ static public function check_if_game_client() { // if HTTP_USER_AGENT is not set then its ryzom core - if ( !isset( $_SERVER['HTTP_USER_AGENT'] ) ){ + if ( strpos($_SERVER['HTTP_USER_AGENT'],"Ryzom") === 0){ return true; }else{ return false; @@ -113,4 +117,24 @@ class Helpers{ global $TIME_FORMAT; return date($TIME_FORMAT,strtotime($time)); } + + static public function check_login_ingame(){ + if ( helpers :: check_if_game_client () or $forcelibrender = false ){ + $dbr = new DBLayer("ring"); + if (isset($_GET['UserId']) && isset($_COOKIE['ryzomId'])){ + $id = $_GET['UserId']; + $statement = $dbr->execute("SELECT * FROM ring_users WHERE user_id=:id AND cookie =:cookie", array('id' => $id, 'cookie' => $_COOKIE['ryzomId'])); + if ($statement->rowCount() ){ + $entry = $statement->fetch(); + return array('id' => $id, 'name' => $entry['user_name']); + }else{ + return "FALSE"; + } + }else{ + return "FALSE"; + } + }else{ + return "FALSE"; + } + } } diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/home.tpl b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/home.tpl new file mode 100644 index 000000000..6198b53a1 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/home.tpl @@ -0,0 +1,53 @@ +{block name=content} + + + + +
+
+
+

{$home_title}

+
+ + + + +
+
+
+

{$home_info}

+ +
+
+
+
+{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/login.tpl b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/login.tpl new file mode 100644 index 000000000..ad6f48e0d --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/login.tpl @@ -0,0 +1,40 @@ +

 

+ +
+
+

{$login_info}

+
+
+
+

+ Username: + +

+ + +

+ Password: + +

+ +

+ Remember me: +

Remember me +

+ +

+ + +

+ +
+ + {if isset($login_error) and $login_error eq "TRUE"} +

+ {$login_error_message} +

+ {/if} +

+ {$login_register_message} {$login_register_message_here}! +

+
diff --git a/code/ryzom/tools/server/ryzom_ams/www/config.php b/code/ryzom/tools/server/ryzom_ams/www/config.php index 49f117a39..ea9b97b50 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/config.php +++ b/code/ryzom/tools/server/ryzom_ams/www/config.php @@ -25,6 +25,12 @@ $cfg['db']['shard']['name'] = 'nel'; $cfg['db']['shard']['user'] = 'shard'; $cfg['db']['shard']['pass'] = ''; +$cfg['db']['ring']['host'] = 'localhost'; +$cfg['db']['ring']['port'] = '3306'; +$cfg['db']['ring']['name'] = 'ring_open'; +$cfg['db']['ring']['user'] = 'shard'; +$cfg['db']['ring']['pass'] = ''; + //----------------------------------------------------------------------------------------- // If true= the server will add automatically unknown user in the database // (in nel.user= nel.permission= ring.ring_user and ring.characters 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 1131a953a..b14cbb40c 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/index.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/index.php @@ -6,11 +6,15 @@ require( '../../ams_lib/libinclude.php' ); session_start(); //Decide what page to load -if(isset($_SESSION['user'])){ - $page = 'home'; +if ( ! isset( $_GET["page"]) ){ + if(isset($_SESSION['user'])){ + $page = 'home'; + }else{ + //default page + $page = 'login'; + } }else{ - //default page - $page = 'login'; + $page = $_GET["page"]; } //perform an action in case one is specified @@ -18,13 +22,12 @@ if(isset($_SESSION['user'])){ if ( isset( $_POST["function"] ) ){ require( "func/" . $_POST["function"] . ".php" ); $return = $_POST["function"](); -}else if ( isset( $_GET["page"] ) ){ - $filename = 'inc/' . $_GET["page"] . '.php'; +}else{ + $filename = 'inc/' . $page . '.php'; if(is_file($filename)){ require_once($filename); - $return = $_GET["page"](); + $return = $page(); } - $page = $_GET["page"]; } //add username to the return array in case logged in.