#1470 re-added api

This commit is contained in:
SirCotare 2013-02-15 17:45:33 +01:00
parent 08fbdfec17
commit 7e358fe887
45 changed files with 17142 additions and 94 deletions

View file

@ -0,0 +1,47 @@
<?php
/* Copyright (C) 2009 Winch Gate Property Limited
*
* This file is part of ryzom_api.
* ryzom_api is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ryzom_api is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
*/
require_once(RYAPI_PATH.'client/config.php');
// Og (non-ryzom.com) method
function ryzom_authenticate_with_serverkey($cid, $name, $authserver, $authkey) {
}
// Ig method
function ryzom_authenticate_ingame($cid, $name, $authkey) {
if (isset($_SESSION['user']))
return true;
if (ryzom_get_param('user'))
return true;
return false;
}
// Session method
function ryzom_authenticate_with_session($name, $redirect) {
if (isset($_SESSION['user']))
return true;
if (ryzom_get_param('user'))
return true;
return false;
}
?>

View file

@ -0,0 +1,39 @@
<?php
/* Copyright (C) 2009 Winch Gate Property Limited
*
* This file is part of ryzom_api.
* ryzom_api is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ryzom_api is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
*/
function ryzom_user_get_info($cid) {
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'];
}
?>

View file

@ -0,0 +1,3 @@
<?php
?>

View file

@ -155,7 +155,4 @@ function callAction($action) {
return $c;
}
?>

View file

@ -28,11 +28,14 @@ function ryzom_app_authenticate(&$user, $ask_login=true, $welcome_message='', $w
$is_auth_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 = isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])?substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2):'en';
if ($l=='fr'||$l=='en'||$l=='de'||$l=='ru'||$l=='es')
$lang = $l;
else
$lang = 'en';
if (!isset($_SESSION['lang'])) {
$l = isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])?substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2):'en';
if ($l=='fr'||$l=='en'||$l=='de'||$l=='ru'||$l=='es')
$lang = $l;
else
$lang = 'en';
} else
$lang = $_SESSION['lang'];
}
if ($lang!='fr'&&$lang!='en'&&$lang!='de'&&$lang!='ru'&&$lang!='es')
$lang = 'en';
@ -107,13 +110,15 @@ function ryzom_app_authenticate(&$user, $ask_login=true, $welcome_message='', $w
$_SESSION['lang'] = $lang;
define('RYZOM_IG', $user['ig']);
// get user information
// get user informations
$ig = $user['ig'];
$user = ryzom_user_get_info($cid, $webprivs);
$user = ryzom_user_get_info($cid, $webprivs, RYAPI_USE_PLAYER_STATS);
if (isset($user['creation_date']))
$user['id'] = ryzom_get_user_id($cid, $user['char_name'], $user['creation_date'], $user);
$user['gender'] = ryzom_get_user_gender($user['id']);
$user['ig'] = $ig;
$user['lang'] = $_SESSION['lang'];
if (!isset($user['groups']))
@ -133,11 +138,13 @@ function ryzom_app_authenticate(&$user, $ask_login=true, $welcome_message='', $w
$user['translation_mode'] = $_SESSION['translater_mode'];
// $user['after_merge'] = $user['uid'] >= 671686;
ryzom_unset_url_param('translate_this');
if (isset($user['last_played_date']))
$_SESSION['last_played_date'] = $user['last_played_date'];
// don't send this information to external apps
// don't send this informations to external apps
unset($user['last_played_date']);
unset($user['creation_date']);
return true;

View file

@ -804,6 +804,13 @@ class bbCode extends bbCodeParser {
return $txt;
}
static function bb_lang($attr, $txt) {
if (_user()->lang == $attr)
return $txt;
else
return '';
}
static function bb_time($options, $txt) {
$time = strtotime($txt);
@ -959,6 +966,9 @@ class bbCode extends bbCodeParser {
case 'date' :
$result = self::bb_date($attr, $text);
break;
case 'lang' :
$result = self::bb_lang($attr, $text);
break;
default :
$result = $open . $text . $close;
break;

View file

@ -17,7 +17,8 @@
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
*/
define('RYAPI_MODE', 'client');
define('RYAPI_MODE', 'client');
define('RYAPI_USE_PLAYER_STATS', false);
// Url where the api is
define('RYAPI_URL', 'http://');

View file

@ -18,7 +18,7 @@
// init database table used by webig
$db = ryDB::getInstance('webig');
$db->setDbDefs('players', array('id' => SQL_DEF_INT, 'cid' => SQL_DEF_INT, 'name' => SQL_DEF_TEXT, 'creation_date' => SQL_DEF_DATE, 'deleted' => SQL_DEF_BOOLEAN, 'last_login' => SQL_DEF_TEXT));
$db->setDbDefs('players', array('id' => SQL_DEF_INT, 'cid' => SQL_DEF_INT, 'name' => SQL_DEF_TEXT, 'gender' => SQL_DEF_INT, 'creation_date' => SQL_DEF_DATE, 'deleted' => SQL_DEF_BOOLEAN, 'last_login' => SQL_DEF_TEXT, 'dev_shard' => SQL_DEF_BOOLEAN));
$db->setDbDefs('accounts', array('uid' => SQL_DEF_INT, 'web_privs' => SQL_DEF_TEXT));
?>

View file

@ -149,8 +149,10 @@ class ryDB {
if ($check)
{
$result = $this->db->query('SHOW FIELDS FROM '.$table);
if (!$result)
die("Table $table not found in database");
if (!$result) {
die("Table [$table] not found in database [$this->db_name]");
}
$fields = array_keys($defs);
while ($row = $this->db->fetch_row($result)) {

View file

@ -17,7 +17,7 @@
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
*/
function ryzom_app_render($title, $content, $style='', $javascript=array(), $homeLink=false) {
function ryzom_app_render($title, $content, $style='', $files=array(), $homeLink=false) {
$c = '';
// get Lua code
@ -51,12 +51,17 @@ function ryzom_app_render($title, $content, $style='', $javascript=array(), $hom
if (!RYZOM_IG) {
// Javascript
$js_code = '';
if (is_string($javascript))
$javascript = array($javascript);
foreach ($javascript as $js)
$js_code .= ' <script type="text/javascript" src="'.$js.'"></script>'."\n";
$c .= $js_code;
$extra_code = '';
if (is_string($files))
$files = array($files);
foreach ($files as $file) {
$sfile = explode('.', $file);
if ($sfile[count($sfile)-1] == 'js')
$extra_code .= ' <script type="text/javascript" src="'.$file.'"></script>'."\n";
else if ($sfile[count($sfile)-1] == 'css')
$extra_code .= ' <link rel="stylesheet" type="text/css" media="all" href="'.$file.'" />'."\n";
}
$c .= $extra_code;
}
$c .= ' </head>'."\n";
@ -167,7 +172,7 @@ function ryzom_render_window_begin($title, $homeLink=false) {
function ryzom_render_window_end() {
global $user;
return '</div>
<div>'.(isset( $user['groups'])?implode(':', $user['groups']):'').'</div>
<div>P_'.(isset($user['id'])?$user['id']:'GUEST').':'.(isset( $user['groups'])?implode(':', $user['groups']):'').'</div>
<div style="background-color: #000000">'.ryLogger::getInstance()->getLogs().'</div></div></div></div>
<div class="ryzom-ui-bl"><div class="ryzom-ui-br"><div class="ryzom-ui-b"></div></div></div><p class="ryzom-ui-notice">powered by <a class="ryzom-ui-notice" href="http://dev.ryzom.com/projects/ryzom-api/wiki">ryzom-api</a></p>
</div>
@ -200,6 +205,7 @@ function ryzom_render_www_begin($url='') {
<a href="'.$url.'&lang=en"><img hspace="5" border="0" src="'.RYAPI_URL.'data/img/lang/en.png" alt="English" /></a>
<a href="'.$url.'&lang=fr"><img hspace="5" border="0" src="'.RYAPI_URL.'data/img/lang/fr.png" alt="French" /></a>
<a href="'.$url.'&lang=de"><img hspace="5" border="0" src="'.RYAPI_URL.'data/img/lang/de.png" alt="German" /></a>
<a href="'.$url.'&lang=es"><img hspace="5" border="0" src="'.RYAPI_URL.'data/img/lang/es.png" alt="Spanish" /></a>
<a href="'.$url.'&lang=ru"><img hspace="5" border="0" src="'.RYAPI_URL.'data/img/lang/ru.png" alt="Russian" /></a>
<div style="'.$style2.'">
<a href="http://www.ryzom.com/"><img border="0" src="'.RYAPI_URL.'data/img/logo.gif" alt=""/></a>
@ -300,10 +306,10 @@ $ryzom_render_styles = array();
$ryzom_render_tmpls = array();
$ryzom_render_styles['main title'] = array('#222222'.$transparency, '#FFFFFF');
$ryzom_render_tmpls['main title'] = '<table width="100%" cellpadding="0" cellspacing="0"><tr bgcolor="${p[\'color1\']}"><td height="42px" valign="middle"><h1><font '.($ig?'color="${p[\'color2\']}" size="14"':'style="color:${p[\'color2\']};font-size:16pt; font-weight: bold"').'>&nbsp;${p[0]}</font></h1></td></tr></table>'."\n";
$ryzom_render_tmpls['main title'] = '<table width="100%" cellpadding="0" cellspacing="0"><tr bgcolor="${p[\'color1\']}"><td height="42px" valign="middle"><font '.($ig?'color="${p[\'color2\']}" size="14"':'style="color:${p[\'color2\']};font-size:16pt; font-weight: bold"').'>&nbsp;${p[0]}</font></td></tr></table>'."\n";
$ryzom_render_styles['section'] = array('#555555'.$transparency, '#FFFFFF');
$ryzom_render_tmpls['section'] = '<table width="100%" cellpadding="0" cellspacing="0"><tr bgcolor="${p[\'color1\']}"><td height="30px" align="left" valign="middle"><font '.($ig?'color="${p[\'color2\']}" size="12"':'style="color:${p[\'color2\']}; font-size:10pt; font-weight: bold"').'>&nbsp;${p[0]}</font></td></tr></table>'."\n";
$ryzom_render_tmpls['section'] = '<table width="100%" cellpadding="0" cellspacing="0"><tr bgcolor="${p[\'color1\']}"><td height="40px" align="left" valign="middle"><font '.($ig?'color="${p[\'color2\']}" size="12"':'style="color:${p[\'color2\']}; font-size:10pt; font-weight: bold"').'>&nbsp;${p[0]}</font></td></tr></table>'."\n";
$ryzom_render_styles['color'] = array('', '');
$ryzom_render_tmpls['color'] = ($ig?'<font color="${p[0]}">':'<font style="color:${p[0]}">').'${p[0]}</font>';
@ -347,8 +353,8 @@ $ryzom_render_tmpls['t element'] = '<font color="${p[\'color1\']}">${p[0]}</font
$ryzom_render_styles['log'] = array('#001100'.$transparency, '');
$ryzom_render_tmpls['log'] = '<div style="background-color: ${p[\'color1\']}"><pre style="width: auto">${p[0]}</pre></div>'."\n";
$ryzom_render_styles['message'] = array('#445566'.$transparency, '');
$ryzom_render_tmpls['message'] = '<table width="100%"><tr bgcolor="${p[\'color1\']}"><td align="center" valign="middle"><h3>&nbsp;${p[0]}</h3></td></tr></table>'."\n";
$ryzom_render_styles['message'] = array('#445566'.$transparency, '#FFDDAA');
$ryzom_render_tmpls['message'] = '<table width="100%" cellspacing="0" cellpadding="0"><tr bgcolor="${p[\'color1\']}"><td height="5px"></td></tr><tr bgcolor="${p[\'color1\']}"><td align="center" valign="middle"><font '.($ig?'color="${p[\'color2\']}" size="16"':'style="color:${p[\'color2\']};font-size:12pt; font-weight: bold"').'>${p[0]}</font></td></tr><tr bgcolor="${p[\'color1\']}"><td height="5px"></td></tr></table>'."\n";
$ryzom_render_styles['message warning'] = array('#AA3300'.$transparency, '');
$ryzom_render_tmpls['message warning'] = '<table width="100%"><tr bgcolor="${p[\'color1\']}"><td align="center" valign="middle"><h3>&nbsp;${p[0]}</h3></td></tr></table>'."\n";
@ -358,7 +364,7 @@ $ryzom_render_tmpls['message window'] = '<table width="100%" cellspacing="0" cel
'<tr bgcolor="${p[\'color1\']}"><td bgcolor="${p[\'color2\']}" width="3px"></td><td height="3px" bgcolor="${p[\'color2\']}"></td><td bgcolor="${p[\'color2\']}" width="3px"></td><td bgcolor="${p[\'color2\']}"></td></tr></table>'."\n";
$ryzom_render_styles['message ask'] = array('#333333'.$transparency, '');
$ryzom_render_tmpls['message ask'] = '<table width="100%"><tr bgcolor="${p[\'color1\']}"><td height="35px" align="center" valign="middle">'.($ig?'<font color="#DDAA33" size="11">':'<font style="color:#DDAA33; font-size:11pt">').'${p[0]}</font></td></tr></table>'."\n";
$ryzom_render_tmpls['message ask'] = '<table width="100%"><tr bgcolor="${p[\'color1\']}"><td valign="middle">'.($ig?'<font color="#DDAA33" size="11">':'<font style="color:#DDAA33; font-size:11pt">').'${p[0]}</font></td></tr></table>'."\n";
$ryzom_render_styles['message error'] = array('#AA2222'.$transparency, '');
$ryzom_render_tmpls['message error'] = '<table width="100%"><tr bgcolor="${p[\'color1\']}"><td height="30px" align="center" valign="middle"><h3>&nbsp;${p[0]}</h3></td></tr></table>'."\n";

View file

@ -310,7 +310,10 @@ class ryForm {
if (count($savedRyform) == 0 || $def->type != DEF_TYPE_RYFORM) {
if (is_string($def->params))
$infos = _l(_i('16/add', _t('add')), $url_params, array('new_ryform' => $def->params, 'ryform_name' => $parent_ryform_name.$deffullname.':0', 'ryform_action' => 'add'));
else if (count($def->params) == 1)
$infos = _l(_i('16/add', _t('add')), $url_params, array('new_ryform' => $def->params[0], 'ryform_name' => $parent_ryform_name.$deffullname.':0', 'ryform_action' => 'add'));
else
$infos = _l(_i('16/add', _t('add')), $url_params, array('ryform_name' => $parent_ryform_name.$deffullname.':0', 'ryform_action' => 'list'));
if ($type == DEF_TYPE_RYFORMS_ARRAY)
@ -674,5 +677,4 @@ class ryForm {
}*/
}
?>

View file

@ -37,6 +37,8 @@ define('DEF_TYPE_COMBO', 16);
define('DEF_TYPE_OPTION_FUNCTION', 17);
define('DEF_TYPE_NAMEID', 18);
define('DEF_TYPE_COMBO_FUNCTION', 19);
define('DEF_TYPE_DATE', 20);
define('DEF_TYPE_ICON_UNKNOWN', 0);
define('DEF_TYPE_ICON_SHARED', 1);
@ -91,6 +93,90 @@ function getTrad($value) {
return substr($trad, 1);
}
function setRyformSource($object, $src, $indent=0, $protecteds=array()) {
$c = '';
$src = str_replace("\r", '', $src);
$ssrc = explode("\n", $src);
$mode = 'var';
$cache = '';
$current_ryform = NULL;
foreach ($ssrc as $line) {
if (!$line)
continue;
if ($mode != 'ryform')
$c .= str_repeat("\t", $indent);
switch ($mode) {
case 'ryform':
if ($line[0] == "\t") {
$cache .= substr($line, 1)."\n";
break;
} else {
$mode = 'array';
}
case 'array':
if ($line == ')' || $line == '}') {
if ($cache && $current_ryform) {
$c .= $current_ryform->setSource($cache, $indent+1);
$c .= 'SET SOURCE ';
if ($line == ')')
$array[] = $current_ryform;
else
$array = $current_ryform;
}
if (array_key_exists($var_name, $protecteds))
call_user_func(array($object, $protecteds[$var_name]), $array);
else
$object->$var_name = $array;
$mode = 'var';
$cache = '';
continue;
} else if ($line[0] == '[') {
if ($cache && $current_ryform) {
$c .= $current_ryform->setSource($cache, $indent+1);
$array[] = $current_ryform;
$c .= 'SET SOURCE ';
}
$ryform_name = substr($line, 1, strlen($line)-2);
$c .= 'New Ryform: '.$ryform_name."\n";
$cache = '';
$current_ryform = new $ryform_name();
$mode = 'ryform';
continue;
}
break;
default:
$sep = strpos($line, '=');
if ($sep) {
$var_name = substr($line, 0, $sep-1);
$value = substr($line, $sep+2);
if ($value == '(' || $value == '{') {
$c .= $var_name.' is ARRAY'."\n";
$mode = 'array';
$array = array();
} else {
$c .= $var_name .' = '.$value."\n";
if ($value[0] == '\'' && $value[strlen($value)-1] == '\'')
$object->$var_name = str_replace('\n', "\n", substr($value, 1, -1));
else {
if (is_numeric($value))
$object->$var_name = eval('return '.$value.';');
else if ($value == 'false')
$object->$var_name = false;
else if ($value == 'true')
$object->$var_name = true;
else if ($value == 'NULL')
$object->$var_name = NULL;
}
}
}
break;
}
}
return $c;
}
interface iRyForm {
function getForm($url_params);
function setFormParams($params);
@ -132,11 +218,11 @@ class basicRyForm implements iRyForm {
public $formName = ''; // Used by Form
public $id = 0;
function __construct($name, $title) {
function __construct($name='', $title='') {
}
function getForm($url_params) {
$form = new ryForm($this->formName, $this->tools);
$form = new ryForm($this->formName);
$form_defs = $this->getFormDefs();
foreach ($form_defs as $def)
$form->addDefine($def);
@ -162,8 +248,20 @@ class basicRyForm implements iRyForm {
return array();
}
function preSerialization() {
/*function preSerialization() {
unset($this->tools);
}*/
function preSerialization() {
$all_defs = array('class_name');
$this->author = _user()->id;
foreach ($this->getFormDefs() as $def)
$all_defs[] = $def->name;
foreach (get_object_vars($this) as $name => $value) {
if (!in_array($name, $all_defs))
unset($this->$name);
}
}
function postSerialization($vars=array()) {
@ -172,6 +270,35 @@ class basicRyForm implements iRyForm {
function getTemplate() {
return '';
}
function getSource($indent=0) {
$attrs = $this->getFormDefs();
$c = str_repeat("\t", $indent-1).'['.get_class($this).']'."\n";
foreach ($attrs as $attr) {
$c .= str_repeat("\t", $indent).$attr->name.' ';
$var = $this->{$attr->name};
if (is_object($var)) {
$c .= "= {\n".substr($var->getSource($indent+1), 0, -1)."\n".str_repeat("\t", $indent).'}';
} else if (is_array($var)) {
$c .= '= ('."\n";
foreach ($var as $element) {
if (is_object($element))
$c .= $element->getSource($indent+1);
else if ($element)
$c .= '#'.str_replace("\r", '', str_replace("\n", '\\\\n', var_export($element, true)));
}
$c .= str_repeat("\t", $indent).")";
} else
$c .= '= '.str_replace("\r", '', str_replace("\n", '\\\\n', var_export($var, true)));
$c .= "\n";
}
return $c;
}
function setSource($src, $indent=0) {
$this->preSerialization();
return setRyformSource($this, $src, $indent);
}
}
?>

View file

@ -38,8 +38,16 @@ class ryUser {
function inGroup($groups) {
$groups = explode(':', $groups);
foreach ($groups as $group) {
if (in_array($group, $this->groups))
return true;
if ($group != '') {
if (in_array($group, $this->groups))
return true;
if ('P_'.$this->id == $group)
return true;
if ('G_'.$this->guild_id == $group)
return true;
if ($group == '*')
return true;
}
}
return false;
}

View file

@ -22,6 +22,15 @@ include_once('dfm.php');
define('SERVER', 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}
if (ini_get('magic_quotes_gpc') == 1) {
$_POST = stripslashes_deep($_POST);
$_GET = stripslashes_deep($_GET);
@ -306,14 +315,18 @@ function file_get_contents_cached($fn, $cache_time=300) {
return $content;
}
function ryzom_redirect($url, $group='webig', $extra_lua='') {
function ryzom_redirect($url, $group='', $extra_lua='') {
global $user;
$lua = $extra_lua."\n";
if ($user['ig']) {
if (!$group)
$lua .= 'getUI(__CURRENT_WINDOW__):browse("'.str_replace('&', '&amp;', $url).'")';
else
$lua .= 'getUI("ui:interface:'.$group.':content:html"):browse("'.str_replace('&', '&amp;', $url).'")';
else {
if (substr($group, 0, 3) == 'ui:')
$lua .= 'getUI("'.$group.'"):browse("'.str_replace('&', '&amp;', $url).'")';
else
$lua .= 'getUI("ui:interface:'.$group.':content:html"):browse("'.str_replace('&', '&amp;', $url).'")';
}
echo '<lua>'.$lua.'</lua>';
exit();
} else {
@ -409,6 +422,10 @@ function p($var, $value=pNULL, $color='#FFFF00', $level=0) {
return $ret;
}
static function text($text) {
return str_replace('"', '\"', $text);
}
static function url($base_params=null, $add_params=array()) {
return str_replace('&', '&amp;', _url($base_params, $add_params));
}
@ -446,8 +463,4 @@ END;
}
?>

View file

@ -0,0 +1,248 @@
/* Copyright (C) 2009 Winch Gate Property Limited
*
* This file is part of ryzom_api.
* ryzom_api is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ryzom_api is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
*/
html, body, form, fieldset, p, div, h1, h2, h3, h4, h5, h6 {
margin:0;
padding:0;
-webkit-text-size-adjust: none;
}
body {
font-size: 14px;
background: black;
font-family: Helvetica;
}
ul li {
padding: 0px 4px 10px 2px;
list-style: circle outside;
}
ol li {
padding: 0px 4px 10px 2px;
}
.ryzom-ui p {
padding-bottom:8px;
}
#main {
clear: both;
padding-top: 0px;
overflow:auto;
margin-left:auto;
margin-right:auto;
text-align:left
}
.error {
padding:.5em;
background:#ff5555;
color:white;
font-weight:bold
}
/*-----------------------------
ORIENTATION
-----------------------------*/
.content_wide,
.content_normal {
display:none;
}
.show_normal {
width: 320px;
}
.show_wide {
width: 480px;
}
.show_wide .content_wide,
.show_normal .content_normal {
display: block;
}
/* ---------------------- */
.ryzom-ui {
color: white;
}
.ryzom-ui input, .ryzom-ui select {
border-top: 1px solid #030403;
border-right: 1px solid #6e7f57;
border-bottom: 1px solid #889e6c;
border-left: 1px solid #272d1f;
background-color: #37402b;
color: #ddd;
font-size: 16px;
margin: 2px 0 5px 0;
}
.ryzom-ui input[type=text] {
width: 96%;
}
.ryzom-ui textarea {
width: 96%;
background-color: black;
color: white;
font-size: 16px;
font-family: Helvetica;
}
/* input[type=submit] will make IE6 to ignore whole CSS rule, so cant combine this with .ryzom-ui-button below */
input[type=submit] {
border-bottom: 1px solid #030403;
border-left: 1px solid #6e7f57;
border-top: 1px solid #889e6c;
border-right: 1px solid #272d1f;
background-color: #435120;
}
input.ryzom-ui-button, .ryzom-ui-button {
border-bottom: 1px solid #030403;
border-left: 1px solid #6e7f57;
border-top: 1px solid #889e6c;
border-right: 1px solid #272d1f;
background-color: #435120;
}
a, a:visited {color:orange}
a:hover {color:orange}
a.ryzom-ui-button, a.ryzom-ui-button:visited {
color: white;
padding: 0 .5em;
text-decoration: none;
}
a.ryzom-ui-button:hover {
background: #536130;
color: #ddd;
}
/* window without title - just borders */
.ryzom-ui-tl {
}
.ryzom-ui-tr {
}
.ryzom-ui-t {
background-image: url(skin_t.gif);
background-repeat: repeat-x;
background-position: left top;
height: 8px;
margin: 0;
}
/* window with proper header */
.ryzom-ui-header .ryzom-ui-tl {
margin: 0px 0px;
height: 32px;
}
.ryzom-ui-header .ryzom-ui-tr {
height: 32px;
}
.ryzom-ui-header .ryzom-ui-t {
background-image: url(skin_header_m.gif);
background-repeat: repeat-x;
background-position: left top;
padding: 7px 0 0 12px;
height: 32px;
text-transform: uppercase;
color: white;
border-top: 1px solid #030403;
}
/* window body */
.ryzom-ui-l {
}
.ryzom-ui-r {
}
.ryzom-ui-m {
margin: 0 0px;
padding: 0px;
background-image: url(skin_blank.png);
background-repeat: repeat;
}
.ryzom-ui-body {
background-image: url(skin_blank_inner.png);
background-repeat: repeat;
/* leave 5px room after bottom border */
margin: 0 8px 5px 2px;
padding: 5px 5px 5px 5px;
border-top: 1px solid #030403;
border-right: 1px solid #6e7f57;
border-bottom: 1px solid #889e6c;
border-left: 1px solid #272d1f;
}
/* window bottom border */
.ryzom-ui-bl {
height: 8px;
}
.ryzom-ui-br {
height: 8px;
}
.ryzom-ui-b {
height: 8px;
margin: 0 8px;
}
.ryzom-ui-notice {
margin: 0px;
padding: 0px;
color: #999;
text-align: center;
}
a.ryzom-ui-notice, a.ryzom-ui-notice:visited {
margin: 0px;
padding: 0px;
color: #BBB;
padding: 0 .5em;
text-decoration: underline;
}
a.ryzom-ui-notice:hover {
color: gray;
}
.ryzom-ui-t .ryzom-ui-text-button {
font-size: 85%;
}
a.ryzom-ui-text-button, a:visited.ryzom-ui-text-button {
color:#FFFF11;
text-decoration:none;
}
.ryzom-ui-text-button {
border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
}
.ryzom-ui-text-button {
padding: 0;margin: 0;
border-color: #ff8 #ff3 #ff3 #ff8;
border-width: 1px;
border-style: solid;
padding: 0px 4px;
color: white;
}
.ryzom-ui-wrap-ul {
float: left;
text-align: center;
padding: 0;
list-style: none;
}
.ryzom-ui-wrap-li {
float: left;
margin: 0 0 10px 5px;
width: 6.1em;
list-style: none;
height: 70px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 748 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 977 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View file

@ -0,0 +1,37 @@
if(window.addEventListener)
window.addEventListener("load", tabulation, false);
else
window.attachEvent("onload", tabulation);
function tabulation(){
var textareas = document.getElementsByTagName("textarea");
for(var i = 0, t = textareas.length; i < t; i++){
textareas[i].onkeydown = function(e){
var tab = (e || window.event).keyCode == 9;
if(tab){
var tabString = String.fromCharCode(9);
var scroll = this.scrollTop;
if(window.ActiveXObject){
var textR = document.selection.createRange();
var selection = textR.text;
textR.text = tabString + selection;
textR.moveStart("character",-selection.length);
textR.moveEnd("character", 0);
textR.select();
}
else {
var beforeSelection = this.value.substring(0, this.selectionStart);
var selection = this.value.substring(this.selectionStart, this.selectionEnd);
var afterSelection = this.value.substring(this.selectionEnd);
this.value = beforeSelection + tabString + selection + afterSelection;
this.setSelectionRange(beforeSelection.length + tabString.length, beforeSelection.length + tabString.length + selection.length);
}
this.focus();
this.scrollTop = scroll;
return false;
}
};
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

1
code/web/api/index.php Normal file
View file

@ -0,0 +1 @@
<?php echo "api"; ?>

View file

@ -68,5 +68,4 @@ require_once("common/db_lib.php");
require_once("common/db_defs.php");
require_once("common/render.php");
?>

View file

@ -40,6 +40,13 @@ function ryzom_authenticate_ingame($shardid, $cid, $name, $authkey) {
function ryzom_authenticate_with_char_and_password($character, $password, &$cid) {
$db = new ServerDatabase(RYAPI_NELDB_HOST, RYAPI_NELDB_LOGIN, RYAPI_NELDB_PASS, RYAPI_NELDB_RING);
$char = $db->escape_string($character);
$schar = explode('@', $char);
$_SESSION['dev_shard'] = 0;
if (count($schar) == 2 && $schar[1] == RYAPI_DEV_SHARD) {
$_SESSION['dev_shard'] = 1;
$char = $schar[0];
$db = new ServerDatabase(RYAPI_NELDB_HOST, RYAPI_NELDB_LOGIN, RYAPI_NELDB_PASS, RYAPI_NELDB_RING_DEV);
}
$sql = "SELECT char_id, char_name, user_id, home_mainland_session_id FROM characters WHERE char_name = '$char'";
$row = $db->query_single_row($sql);
$character = $row['char_name'];
@ -59,6 +66,7 @@ function ryzom_authenticate_with_session(&$name, &$cid, &$error_message) {
if ($action == 'logout') {
unset($_SESSION['name']);
unset($_SESSION['cid']);
unset($_SESSION['dev_shard']);
}
if (isset($_SESSION['name']) && ($name == '' || $_SESSION['name'] == $name)) {
@ -85,46 +93,6 @@ function ryzom_authenticate_with_session(&$name, &$cid, &$error_message) {
return false;
}
function ryzom_get_user_id($cid, $name, $creation_date) {
$name = strtolower($name);
$db = ryDB::getInstance('webig');
$charsWithSameName = $db->query('players', array('name' => $name, 'deleted' => 0));
foreach ($charsWithSameName as $charWithSameName) {
// Another char with same name => delete it
if (intval($cid) != intval($charWithSameName['cid'])) {
$db->update('players', array('deleted' => 1), array('id' => $charWithSameName['id']));
}
}
$charProps = $db->querySingle('players', array('cid' => intval($cid), 'deleted' => 0));
// new char => create record
if (!$charProps) {
$charProps = array('name' => $name, 'cid' => $cid, 'creation_date' => $creation_date, 'deleted' => 0);
$charProps['id'] = $db->insert('players', $charProps);
if (!$charProps['id'])
die('ryDb New Char Error');
} else {
// char deleted and recreated => change to deleted
if ($charProps['creation_date'] != $creation_date) {
if (!$db->update('players', array('deleted' => 1), array('id' => $charProps['id'])))
die('ryDb Delete char Error: '.$db->getErrors());
$charProps = array('name' => $name, 'cid' => $cid, 'creation_date' => $creation_date, 'deleted' => 0);
if (!$charProps['id'] = $db->insert('players', $charProps))
die('ryDb New Char in Slot Error');
} else {
// char renamed => update record
if ($charProps['name'] != $name)
if (!$db->update('players', array('name' => $name), array('id' => $charProps['id'])))
die('ryDb Rename Char Error');
}
}
return $charProps['id'];
}
?>

View file

@ -17,6 +17,8 @@
*/
define('RYAPI_SHARDID', '101');
define('RYAPI_DEV_SHARDID', '301');
define('RYAPI_DEV_SHARD', 'yubo');
define('RYAPI_WEBDB_HOST', 'localhost');
define('RYAPI_WEBDB_LOGIN', 'localhost');
define('RYAPI_WEBDB_PASS', 'localhost');
@ -24,12 +26,17 @@ define('RYAPI_WEBDB_PASS', 'localhost');
define('RYAPI_NELDB_HOST', 'localhost');
define('RYAPI_NELDB_LOGIN', 'shard');
define('RYAPI_NELDB_PASS', 'localhost');
define('RYAPI_NELDB_RING', 'ring_open');
if ($_GET['shardid'] == RYAPI_DEV_SHARDID || (isset($_SESSION['dev_shard']) && $_SESSION['dev_shard']))
define('RYAPI_NELDB_RING', 'ring_dev');
else
define('RYAPI_NELDB_RING', 'ring_open');
define('RYAPI_NELDB_RING_DEV', 'ring_dev');
define('RYAPI_NELDB_NEL', 'nel');
define('RYAPI_AUTH_SCRIPT', '');
define('RYAPI_COOKIE_KEY', '');
define('RYAPI_EGS_SALT', 'RyZoM'); // need be exactly same salt than egs
define('RYAPI_HMAGIC_DEBUG', false); // only :DEV: can use debug hmagic commands
?>

View file

@ -40,6 +40,7 @@ function ryzom_guild_icon($icon, $size) {
$filename = RYAPI_PATH."data/cache/guild_icons/${icon}_$size.png";
if($size != 'b' && $size != 's') die('Bad size parameter');
if($icon == '') die('icon parameter cannot be empty');
if(!file_exists($filename)) {
$command = RYAPI_PATH."server/scripts/generate_guild_icon.sh $icon $size 2>&1";

View file

@ -44,9 +44,10 @@ class ryHmagic {
$this->dfm = new ryDataFileManager(_user()->id);
}
function getWebCommand($web_app_url, $command, $is_next=false, $need_callback=false, $old_sep=false) {
function getWebCommand($web_app_url, $command, $is_next=false, $need_callback=false, $old_sep=false, $replace_space=true) {
$command = str_replace('#player', ryzom_get_param('player_eid'), $command);
$command = str_replace(' ', chr(160), $command);
if ($replace_space)
$command = str_replace(' ', chr(160), $command);
$last_connected_date = strtotime($_SESSION['last_played_date']);
$index_infos = $this->dfm->loadUserDataFromApp('hmagic.index', 'app_profile');
@ -72,11 +73,8 @@ class ryHmagic {
$eid = ryzom_get_param('datasetid');
$checksum = $web_app_url.'&'.$tid . $last_connected_date . $index_infos['index'] . $command . $eid;
$hmac = strtoupper(hash_hmac('sha1', $checksum, RYAPI_EGS_SALT));
return '
local command = \''.str_replace("'", '\\\'',str_replace('&', '&amp;', $command)).'\'
runCommand("a","webExecCommand","'.str_replace('&', '&amp;', $web_app_url).'&amp;'.$tid.'","'.$index_infos['index'].'",command,"'.$hmac.'","'.($old_sep?'1':'3').'","'.($is_next?'1':'0').'","'.($need_callback?'1':'0').'")
--runCommand("a","webExecCommand","debug", "1", command, "hmac", "2")
';
return ' local command = \''.str_replace("'", '\\\'',str_replace('&', '&amp;', $command)).'\''."\n\t".
(RYAPI_HMAGIC_DEBUG?'runCommand("a","webExecCommand","debug", "1", command, "hmac", "2","'.($is_next?'1':'0').'","'.($need_callback?'1':'0').'")':'runCommand("a","webExecCommand","'.str_replace('&', '&amp;', $web_app_url).'&amp;'.$tid.'","'.$index_infos['index'].'",command,"'.$hmac.'","'.($old_sep?'1':'3').'","'.($is_next?'1':'0').'","'.($need_callback?'1':'0').'")');
}
function validateCallback() {

View file

@ -0,0 +1,142 @@
<?php
include('../../common/db_lib.php');
//require_once('../server_functions_item.php');
$guilds_cache_timeout = 60*60;
$time = time();
$db = new ServerDatabase('localhost', 'ryzom_api', 'sg4gfgh45bgguifsd', 'ring_live');
function save_xml($filename, $xml) {
$filename = "/home/api/public_html/data/cache/guilds/$filename.xml";
$txt_xml = $xml->asXML();
// save in clear xml
file_put_contents($filename, $txt_xml);
// save in clear compressed xml
$gz = gzopen($filename.'.gz','w9');
gzwrite($gz, $txt_xml);
gzclose($gz);
}
function create_guild($out, $filename, $shard) {
global $db, $time, $guilds_cache_timeout;
$src = simplexml_load_file($filename);
echo "$filename\n";
$guild = $out->addChild('guild');
$guild->addChild('gid', $src->Id['value']);
$guild->addChild('name', $src->_Name['value']);
$guild->addChild('race', $src->Race['value']);
$guild->addChild('icon', $src->Icon['value']);
$guild->addChild('creation_date', $src->CreationDate['value']);
$desc = (string)$src->_Description['value'];
$desc = iconv("UTF-8", "ISO-8859-1", $desc);
$replace = array('&', '<', '>');
$into = array('&amp;', '&lt;', '&gt;');
$desc = str_replace($replace, $into, $desc);
$guild->addChild('description', $desc);
// create the full guild xml
$xml = simplexml_load_string('<guild/>');
$cache = $xml->addChild('cache');
$cache->addAttribute('created', $time);
$cache->addAttribute('expire', $time+$guilds_cache_timeout);
$xml->addChild('name', $src->_Name['value']);
$xml->addChild('gid', $src->Id['value']);
$xml->addChild('race', $src->Race['value']);
$xml->addChild('icon', $src->Icon['value']);
$xml->addChild('creation_date', $src->CreationDate['value']);
$xml->addChild('shard', $shard);
$xml->addChild('description', $desc);
$xml->addChild('money', $src->Money['value']);
$xml->addChild('building', $src->Building['value']);
$xml->addChild('cult', strtolower($src->DeclaredCult['value']));
$xml->addChild('civ', strtolower($src->DeclaredCiv['value']));
$motd = (string)$src->_MessageOfTheDay['value'];
$motd = iconv("UTF-8", "ISO-8859-1", $motd);
$motd = str_replace($replace, $into, $motd);
$xml->addChild('motd', $motd);
// guild members
$members = $xml->addChild('members');
$i = 0;
do {
$m = $src->Members->__Key__[$i]['value'];
if(!isset($m)) break;
$m2 = $src->Members->__Val__[$i];
$mem = $members->addChild('member');
$cid = hexdec(substr($m2->Members->Id['value'], 3, 10));
$mem->addChild('cid', $cid);
$sql = "SELECT char_name FROM characters WHERE char_id=$cid";
$result = $db->query($sql);
$name = $db->fetch_row($result);
$db->free_result($result);
$mem->addChild('name', $name[0]);
$mem->addChild('grade', $m2->Members->Grade['value']);
$mem->addChild('joined_date', $m2->Members->EnterTime['value']);
$i++;
} while(true);
// guild fame
$factions = array('fyros', 'matis', 'tryker', 'zorai', 'kami', 'karavan');
$fames = $xml->addChild('fames');
$i = 0;
do {
$f = $src->FameContainer->FameContainer->__Parent__->Entries->__Key__[$i]['value'];
if(!isset($f)) break;
$f2 = $src->FameContainer->FameContainer->__Parent__->Entries->__Val__[$i];
$fac = basename($f2->Sheet['value'], '.faction');
if(in_array($fac, $factions)) {
$fames->addChild($fac, $f2->Fame['value']);
}
$i++;
} while(true);
// guild items
/* $inventory = $xml->addChild('room');
$result = $src->xpath('/xml/GuildInventory/_Items');
while(list( , $node) = each($result)) {
ryzom_item_insert($inventory, $node);
}
*/
save_xml("guild_".$src->Id['value'], $xml);
}
function create_guilds_xml($shard) {
global $time, $guilds_cache_timeout;
$xml = simplexml_load_string('<guilds/>');
$cache = $xml->addChild('cache');
$cache->addAttribute('created', $time);
$cache->addAttribute('expire', $time+$guilds_cache_timeout);
$xml->addChild('shard', $shard);
foreach(glob("/home/api/public_html/data/cache/guilds/guild_?????.xml") as $fn) {
create_guild($xml, $fn, $shard);
}
// $dirname = "tmp/$shard";
// if ($handle = opendir($dirname)) {
// while (false !== ($file = readdir($handle))) {
// if (end(explode(".", $file)) == 'xml') {
// create_guild($xml, "$dirname/$file");
// }
// }
// closedir($handle);
// }
save_xml("guilds_$shard", $xml);
}
create_guilds_xml('atys');
?>

View file

@ -0,0 +1,39 @@
#!/bin/bash
echo $1;
let "back=($1 & 15) - 1"
let "symbol=($1 >> 4 & 63) - 1"
let "invert=$1 >> 10 & 1"
let "col1R=$1 >> 11 & 255"
let "col1G=$1 >> 19 & 255"
let "col1B=$1 >> 27 & 255"
let "col2R=$1 >> 35 & 255"
let "col2G=$1 >> 43 & 255"
let "col2B=$1 >> 51 & 255"
size="$2"
png_path='/home/api/public_html/data/ryzom/guild_png/';
final_path='/home/api/public_html/data/cache/guild_icons/';
tmp_path="$final_path/tmp";
img_back=`printf $png_path/guild_back_%s_%02d_1.png $size $back`
img_back2=`printf $png_path/guild_back_%s_%02d_2.png $size $back`
img_symbol=`printf $png_path/guild_symbol_%s_%02d.png $size $symbol`
img_final=`printf $final_path/%d_%s.png $1 $size`
convert $img_back -fill "rgb($col1R,$col1G,$col1B)" -colorize 100,100,100 $tmp_path/$1_$2_part_1.png
convert $img_back2 -fill "rgb($col2R,$col2G,$col2B)" -colorize 100,100,100 $tmp_path/$1_$2_part_2.png
convert -composite $tmp_path/$1_$2_part_1.png $tmp_path/$1_$2_part_2.png $tmp_path/$1_$2_back.png
if [[ $invert == 1 ]]
then
convert -negate $img_symbol $tmp_path/$1_$2_symb.png
composite -compose plus $tmp_path/$1_$2_back.png $tmp_path/$1_$2_symb.png $img_final
else
composite -compose multiply $tmp_path/$1_$2_back.png $img_symbol $img_final
fi
composite -compose copy-opacity $tmp_path/$1_$2_back.png $img_final $img_final
rm $tmp_path/$1_$2_*

View file

@ -0,0 +1,29 @@
#!/bin/sh
cd /home/api/public_html/server/scripts
# get guilds
rm /home/api/public_html/data/cache/guilds/*
rsync -az --rsh=ssh nevrax@shard.ryzom.com:/home/nevrax/code/ryzom/server/save_shard/live_atys/guilds/guild_*.bin /home/api/public_html/data/cache/guilds/
./pdr_util -x -s/home/app/web_hg/api/server/scripts/sheet_id.bin /home/api/public_html/data/cache/guilds/guild_*.bin
rm /home/api/public_html/data/cache/guilds/guild_*.bin
/usr/bin/php ./create_guilds_xml.php
rm /home/api/public_html/data/cache/guilds/guild_?????.xml
rm log.log
/root/bin/own.sh api /home/api/public_html/data/cache/guilds/
# get tick
rsync -az --rsh=ssh nevrax@shard.ryzom.com:/home/nevrax/code/ryzom/server/save_shard/live_atys/game_cycle.ticks /home/api/public_html/data/cache/
chown api:api /home/api/public_html/data/cache/game_cycle.ticks
cd -

View file

@ -18,11 +18,74 @@
include_once(RYAPI_PATH.'server/guilds.php');
function ryzom_user_get_info($cid, $webprivs=false) {
function ryzom_get_user_id($cid, $name, $creation_date) {
$name = strtolower($name);
$db = ryDB::getInstance('webig');
$dev_shard = ((isset($_SESSION['dev_shard']) && $_SESSION['dev_shard']) || (isset($_GET['shardid']) && $_GET['shardid'] == RYAPI_DEV_SHARDID))?1:0;
if ($dev_shard)
$_SESSION['dev_shard'] = 1;
$charsWithSameName = $db->query('players', array('name' => $name, 'deleted' => 0, 'dev_shard' => $dev_shard));
foreach ($charsWithSameName as $charWithSameName) {
// Another char with same name => delete it
if (intval($cid) != intval($charWithSameName['cid'])) {
$db->update('players', array('deleted' => 1), array('id' => $charWithSameName['id']));
}
}
$charProps = $db->querySingle('players', array('cid' => intval($cid), 'deleted' => 0, 'dev_shard' => $dev_shard));
// new char => create record
if (!$charProps) {
$charProps = array('name' => $name, 'cid' => $cid, 'creation_date' => $creation_date, 'deleted' => 0, 'dev_shard' => $dev_shard);
$charProps['id'] = $db->insert('players', $charProps);
if (!$charProps['id'])
die('ryDb New Char Error');
} else {
// char deleted and recreated => change to deleted
if ($charProps['creation_date'] != $creation_date) {
if (!$db->update('players', array('deleted' => 1), array('id' => $charProps['id'])))
die('ryDb Delete char Error: '.$db->getErrors());
$charProps = array('name' => $name, 'cid' => $cid, 'creation_date' => $creation_date, 'deleted' => 0, 'dev_shard' => $dev_shard);
if (!$charProps['id'] = $db->insert('players', $charProps))
die('ryDb New Char in Slot Error');
} else {
// char renamed => update record
if ($charProps['name'] != $name)
if (!$db->update('players', array('name' => $name), array('id' => $charProps['id'])))
die('ryDb Rename Char Error');
}
}
return $charProps['id'];
}
function ryzom_get_user_gender($id) {
$db = ryDB::getInstance('webig');
$player = $db->querySingle('players', array('id' => $id));
if ($player) {
if ($player['gender'])
return intval($player['gender']);
$cid = $player['cid'];
$xml = @simplexml_load_file(RYAPI_PATH.'data/cache/players/public/'.substr($cid, strlen($cid)-1).'/'.$cid.'.xml');
if ($xml !== false) {
$gender = (string)$xml->public->_gender;
$db->update('players', array('gender' => intval($gender)+1), array('id' => $id));
return $gender+1;
}
}
return false;
}
function ryzom_user_get_info($cid, $webprivs=false, $player_stats=false) {
// User information
global $_RYZOM_API_CONFIG;
$db = new ServerDatabase(RYAPI_NELDB_HOST, RYAPI_NELDB_LOGIN, RYAPI_NELDB_PASS, RYAPI_NELDB_RING);
if (isset($_SESSION['dev_shard']) && $_SESSION['dev_shard'])
$db = new ServerDatabase(RYAPI_NELDB_HOST, RYAPI_NELDB_LOGIN, RYAPI_NELDB_PASS, RYAPI_NELDB_RING_DEV);
else
$db = new ServerDatabase(RYAPI_NELDB_HOST, RYAPI_NELDB_LOGIN, RYAPI_NELDB_PASS, RYAPI_NELDB_RING);
$sql = "SELECT char_name, race, civilisation, cult, guild_id, creation_date, last_played_date FROM characters WHERE char_id = $cid";
$result = $db->query($sql) or die('Could not query on ryzom_user_get_info');
$found = $db->num_rows($result) >= 1;
@ -110,6 +173,8 @@ function ryzom_user_get_info($cid, $webprivs=false) {
}
$groups[] = 'PLAYER';
if (isset($_SESSION['dev_shard']) && $_SESSION['dev_shard'])
$groups[] = 'DEV_SHARD';
if ($webprivs) {
$db = new ServerDatabase(RYAPI_WEBDB_HOST, RYAPI_WEBDB_LOGIN, RYAPI_WEBDB_PASS, 'webig');
@ -122,6 +187,11 @@ function ryzom_user_get_info($cid, $webprivs=false) {
$db->free_result($result);
$groups = array_merge($groups, explode(':', $privs));
}
if ($player_stats) {
include_once(RYAPI_PATH.'server/player_stats.php');
$row['fames'] = ryzom_player_fames_array($cid);
}
$row['groups'] = $groups;
return $row;
}