diff --git a/code/web/api/client/auth.php b/code/web/api/client/auth.php
index cab8a5886..f47dbd634 100644
--- a/code/web/api/client/auth.php
+++ b/code/web/api/client/auth.php
@@ -20,30 +20,28 @@ require_once(RYAPI_PATH.'client/config.php');
// Og (non-ryzom.com) method
function ryzom_authenticate_with_serverkey($cid, $name, $authserver, $authkey) {
- global $_RYZOM_API_CONFIG;
- $fn = $_RYZOM_API_CONFIG['auth_script'].'?name='.$name.'&cid='.$cid.'&authkey='.$authkey.'&authserver='.$authserver;
-
- $res = file_get_contents($fn);
- return $res == '1';
}
// Ig method
function ryzom_authenticate_ingame($cid, $name, $authkey) {
- global $_RYZOM_API_CONFIG;
- $fn = $_RYZOM_API_CONFIG['auth_script'].'?name='.$name.'&cid='.$cid.'&authkey='.$authkey.'&ig=1';
+ if (isset($_SESSION['user']))
+ return true;
- $res = file_get_contents($fn);
- echo $res;
- return $res == '1';
+ if (ryzom_get_param('user'))
+ return true;
+
+ return false;
}
// Session method
function ryzom_authenticate_with_session($name, $redirect) {
- global $_RYZOM_API_CONFIG;
- $fn = $_RYZOM_API_CONFIG['auth_script'].'?name='.$name;
+ if (isset($_SESSION['user']))
+ return true;
- $res = file_get_contents($fn);
- return $res == '1';
+ if (ryzom_get_param('user'))
+ return true;
+
+ return false;
}
?>
diff --git a/code/web/api/client/user.php b/code/web/api/client/user.php
index de526dcca..b6e906b2c 100644
--- a/code/web/api/client/user.php
+++ b/code/web/api/client/user.php
@@ -17,7 +17,23 @@
*/
function ryzom_user_get_info($cid) {
- return Array();
+ if (isset($_SESSION['user']))
+ return $_SESSION['user'];
+
+ $user = unserialize(base64_decode(ryzom_get_param('user')));
+ $_SESSION['user'] = $user;
+ return $user;
}
+function ryzom_get_user_id($cid, $name, $creation_date) {
+ if (isset($_SESSION['user']))
+ return $_SESSION['user']['id'];
+
+ $user = unserialize(base64_decode(ryzom_get_param('user')));
+ $_SESSION['user'] = $user;
+
+ return $user['id'];
+}
+
+
?>
diff --git a/code/web/api/common/auth.php b/code/web/api/common/auth.php
index b6bcdd799..1d52c5d8e 100644
--- a/code/web/api/common/auth.php
+++ b/code/web/api/common/auth.php
@@ -5,7 +5,8 @@ function ryzom_app_authenticate(&$user, $ask_login=true, $welcome_message='') {
$authserver = ryzom_get_param('authserver');
$authkey = ryzom_get_param('authkey');
$lang = ryzom_get_param('lang');
-
+ $cid = ryzom_get_param('cid', '');
+ $is_ingame = false;
// we have to set the $user['lang'] even for anonymous user or we cannot display the test in the right langage
if($lang == '') {
$l = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
@@ -14,15 +15,20 @@ function ryzom_app_authenticate(&$user, $ask_login=true, $welcome_message='') {
else
$lang = 'en';
}
+ $user['message'] = '';
$user['lang'] = $lang;
-
- if (RYZOM_IG || ryzom_get_param('ig')) {
+ $user['ig'] = false;
+
+ if ((isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Ryzom')) || ryzom_get_param('ig')) {
+ $user['ig'] = true;
// Ingame
- $cid = ryzom_get_param('cid');
- if (!ryzom_authenticate_ingame($cid, $name, $authkey))
+ $shardid = ryzom_get_param('shardid');
+ if (!ryzom_authenticate_ingame($shardid, $cid, $name, $authkey))
return false;
+ $is_ingame = true;
} else {
// Outgame : Use session
+ $error_message = '';
if (!ryzom_authenticate_with_session($name, $cid, $error_message)) {
if ($ask_login) {
$c = '';
@@ -47,8 +53,12 @@ function ryzom_app_authenticate(&$user, $ask_login=true, $welcome_message='') {
// get user informations
$user = ryzom_user_get_info($cid);
$user['lang'] = $_SESSION['lang'];
-
- $user['id'] = ryzom_get_user_id($cid, $user['char_name'], $user['creation_date']);
+ if (isset($user['creation_date']))
+ $user['id'] = ryzom_get_user_id($cid, $user['char_name'], $user['creation_date']);
+ if ($is_ingame && $user['last_played_date'] != '0')
+ $user['ig'] = true;
+ else
+ $user['ig'] = false;
unset($user['last_played_date']);
unset($user['creation_date']);
return true;
diff --git a/code/web/api/common/logger.php b/code/web/api/common/logger.php
index f4909e721..1e5106b54 100644
--- a/code/web/api/common/logger.php
+++ b/code/web/api/common/logger.php
@@ -33,7 +33,7 @@ class ryLogger {
function getLogs() {
$ret = '';
if ($this->logs && $this->enable)
- $ret = "Debug\n".implode("\n", $this->logs);
+ $ret = "Debug\n\n".implode("\n", $this->logs);
$this->logs = array();
return $ret;
}
diff --git a/code/web/api/common/render.php b/code/web/api/common/render.php
index a2ec31795..60b101d38 100644
--- a/code/web/api/common/render.php
+++ b/code/web/api/common/render.php
@@ -16,7 +16,7 @@
* along with ryzom_api. If not, see
'.$debug.' |