merge gsoc2012-achievements, updates

This commit is contained in:
mattraykowski 2013-02-15 12:53:17 -06:00
commit f45f8eb3b2
117 changed files with 66972 additions and 50944 deletions

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,8 +17,9 @@
* 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://');
if (!defined('RYAPI_PATH'))

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,16 +248,57 @@ 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()) {
}
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;
}
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 B

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

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

@ -18,18 +18,22 @@
require_once("include/functions_inc.php");
require_once("class/Entity_abstract.php");
$logto = "std";
if(!$_REQUEST['file']) {
$_REQUEST['file'] = $argv[1];
$logto = $argv[2];
}
if($CONF['logging'] == true) {
require_once("class/Logfile_class.php");
$log = new Logfile($CONF['logfile']);
$log = new Logfile($CONF['logfile'],$logto);
}
$log->logf("File: '".$_REQUEST['file']."'");
$log->logf("Starting up... ",false);
#$log->logf("Starting up... ",false);
if(!$_REQUEST['file']) {
$log->logf("ERROR: no file given! EXITING!");
@ -52,6 +56,8 @@
require_once("class/XMLnode_class.php");
require_once("class/XMLfile_class.php");
require_once("class/Stats_class.php");
$atom_insert = array();
$_CACHE = new ValueCache();
@ -72,7 +78,7 @@
$tmp = explode("/",$_REQUEST['file']);
$tmp2 = explode("_",$tmp[(sizeof($tmp)-1)]);
$DBc->database($CONF['char_mysql_database']);
$DBc->database($CONF['webig_mysql_database']);
$res = $DBc->sendSQL("SELECT id FROM players WHERE cid='".$DBc->mre($tmp2[1]*16+$tmp2[2])."' AND deleted='0'","ARRAY");
#$res[0]['id'] = 1;
@ -83,52 +89,66 @@
}
$cdata = array("cid"=>$res[0]['id'],"aid"=>$tmp2[1],"sid"=>$tmp2[2]);
$DBc_char = new mySQL($CONF['mysql_error']);
$DBc_char->connect($CONF['char_mysql_server'],$CONF['char_mysql_user'],$CONF['char_mysql_pass'],$CONF['char_mysql_database']);
$res = $DBc_char->sendSQL("SELECT race,civilisation,cult FROM characters WHERE char_id='".$DBc_char->mre($tmp2[1]*16+$tmp2[2])."'","ARRAY");
$cdata['race'] = $res[0]['race'];
$cdata['civ'] = $res[0]['civilisation'];
$cdata['cult'] = $res[0]['cult'];
#$cdata = array("cid"=>1,"aid"=>1,"sid"=>1);
$DBc->database($CONF['mysql_database']);
#echo var_export($cdata);
$log->logf(" done!");
#$log->logf(" done!");
$microstop = explode(' ',microtime());
$stop_time = $microstop[0] + $microstop[1];
$log->logf("Expired time: ".($stop_time - $start_time));
#$log->logf("Expired time: ".($stop_time - $start_time));
#foreach($chars as $cid) {
#STEP 1: load and register atoms
$log->logf("Processing char '".$cdata['cid']."' ...");
$log->logf("Processing char '".$cdata['cid']."' (".$cdata['race'].",".$cdata['cult'].",".$cdata['civ'].") ... ");
$log->logi("Loading and registering Atoms... ",false);
#$log->logi("Loading and registering Atoms... ",false);
$atom_list = array();
$res = $DBc->sendSQL("SELECT at_id FROM ach_task WHERE NOT EXISTS (SELECT * FROM ach_player_task WHERE apt_player='".$cdata['cid']."' AND apt_task=at_id) AND at_dev='0'","ARRAY");
foreach($res as $task) {
$tmps = 0;
#$res = $DBc->sendSQL("SELECT at_id FROM ach_task WHERE NOT EXISTS (SELECT * FROM ach_player_task WHERE apt_player='".$cdata['cid']."' AND apt_task=at_id) AND at_dev='0' AND (NOT EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id) OR EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id AND atta_alignment LIKE '".$cdata['cult'].'|'.$cdata['civ']."'))","ARRAY");
#foreach($res as $task) {
//get unfinished atoms belonging to unfinished objectives
$res2 = $DBc->sendSQL("SELECT ach_atom.* FROM ach_atom,ach_objective WHERE ao_task='".$task['at_id']."' AND ao_id=atom_objective AND NOT EXISTS (SELECT * FROM ach_player_objective WHERE apo_player='".$cdata['cid']."' AND apo_objective=ao_id)","ARRAY");
$res2 = $DBc->sendSQL("SELECT ach_atom.* FROM ach_atom,ach_objective,ach_task WHERE ao_task=at_id AND ao_id=atom_objective AND NOT EXISTS (SELECT * FROM ach_player_objective WHERE apo_player='".$cdata['cid']."' AND apo_objective=ao_id) AND NOT EXISTS (SELECT * FROM ach_player_task WHERE apt_player='".$cdata['cid']."' AND apt_task=at_id) AND at_dev='0' AND (NOT EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id) OR EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id AND atta_alignment LIKE '".$cdata['cult'].'|'.$cdata['civ']."'))","ARRAY");
foreach($res2 as $atom) {
$a = new Atom($atom,$cdata);
$atom_list[] = $a;
$atom_list[] = $a;
$a->register();
}
}
$tmps += sizeof($res2);
#}
$log->logf("loaded atoms: ".$tmps);
$statsdb = new Stats();
$statsdb->register();
$log->logf("done!");
#$log->logf("done!");
$log->logf("Memory load: ".memory_get_usage()." bytes");
#$log->logf("Memory load: ".memory_get_usage()." bytes");
$microstop = explode(' ',microtime());
$stop_time = $microstop[0] + $microstop[1];
$log->logf("Expired time: ".($stop_time - $start_time));
#$log->logf("Expired time: ".($stop_time - $start_time));
$log->logi("Driving data... ",false);
#$log->logi("Driving data... ",false);
#STEP 2: drive data
$_CACHE->setChar($cdata);
@ -140,8 +160,21 @@
$_DISPATCHER->dispatchValue("sid",$cdata['sid']);
$_DATASOURCE->drive($cdata);
$statsdb->writeData();
if(sizeof($atom_insert) > 0) {
$qry = "INSERT INTO ach_player_atom (apa_atom,apa_player,apa_date,apa_expire,apa_state,apa_value) VALUES ".implode(',',$atom_insert);
$DBc->sendSQL($qry,"NONE");
}
$log->logf("Inserting atom data: ".sizeof($atom_insert));
#$log->logf("done!");
#$log->logf("Daily stats check/save... ",false);
//save daily stats
$res = $DBc->sendSQL("SELECT COUNT(*) as anz FROM stat_daily WHERE sdm_day='".date("Y-m-d",time())."'","ARRAY");
$res = $DBc->sendSQL("SELECT COUNT(*) as anz FROM stat_daily WHERE sd_day='".date("Y-m-d",time())."'","ARRAY");
if($res[0]['anz'] == 0) {
$res = $DBc->sendSQL("SELECT SUM(sp_money) as all_money, AVG(sp_money) as avg_money, COUNT(*) as playercount FROM app_achievements.stat_players as s, webig.players as p, ring_live.characters as c, nel.user as n WHERE s.sp_char = p.id AND p.cid = c.char_id AND c.user_id = n.uid AND n.privilege=''","ARRAY");
@ -149,45 +182,48 @@
$res3 = $DBc->sendSQL("SELECT SUM(sp_yubototal) as all_yubo, AVG(sp_yubototal) as avg_yubo FROM app_achievements.stat_players as s, webig.players as p, ring_live.characters as c, nel.user as n WHERE s.sp_char = p.id AND p.cid = c.char_id AND c.user_id = n.uid AND n.privilege=''","ARRAY");
$res4 = $DBc->sendSQL("SELECT sp_yubototal FROM app_achievements.stat_players as s, webig.players as p, ring_live.characters as c, nel.user as n WHERE s.sp_char = p.id AND p.cid = c.char_id AND c.user_id = n.uid AND n.privilege='' ORDER by sp_money ASC LIMIT ".floor($res[0]['playercount']/2).",1","ARRAY");
$res4 = $DBc->sendSQL("SELECT sp_yubototal FROM app_achievements.stat_players as s, webig.players as p, ring_live.characters as c, nel.user as n WHERE s.sp_char = p.id AND p.cid = c.char_id AND c.user_id = n.uid AND n.privilege='' ORDER by sp_yubototal ASC LIMIT ".floor($res[0]['playercount']/2).",1","ARRAY");
$res5 = $DBc->sendSQL("SELECT SUM(sp_mekcount) as all_mek, AVG(sp_mekcount) as avg_mek FROM app_achievements.stat_players as s, webig.players as p, ring_live.characters as c, nel.user as n WHERE s.sp_char = p.id AND p.cid = c.char_id AND c.user_id = n.uid AND n.privilege=''","ARRAY");
$res6 = $DBc->sendSQL("SELECT sp_mekcount FROM app_achievements.stat_players as s, webig.players as p, ring_live.characters as c, nel.user as n WHERE s.sp_char = p.id AND p.cid = c.char_id AND c.user_id = n.uid AND n.privilege='' ORDER by sp_money ASC LIMIT ".floor($res[0]['playercount']/2).",1","ARRAY");
$res6 = $DBc->sendSQL("SELECT sp_mekcount FROM app_achievements.stat_players as s, webig.players as p, ring_live.characters as c, nel.user as n WHERE s.sp_char = p.id AND p.cid = c.char_id AND c.user_id = n.uid AND n.privilege='' ORDER by sp_mekcount ASC LIMIT ".floor($res[0]['playercount']/2).",1","ARRAY");
$res7 = $DBc->sendSQL("SELECT SUM(sp_maxlevel) as all_lvl, AVG(sp_maxlevel) as avg_lvl FROM app_achievements.stat_players as s, webig.players as p, ring_live.characters as c, nel.user as n WHERE s.sp_char = p.id AND p.cid = c.char_id AND c.user_id = n.uid AND n.privilege=''","ARRAY");
$res8 = $DBc->sendSQL("SELECT sp_maxlevel FROM app_achievements.stat_players as s, webig.players as p, ring_live.characters as c, nel.user as n WHERE s.sp_char = p.id AND p.cid = c.char_id AND c.user_id = n.uid AND n.privilege='' ORDER by sp_money ASC LIMIT ".floor($res[0]['playercount']/2).",1","ARRAY");
$res8 = $DBc->sendSQL("SELECT sp_maxlevel FROM app_achievements.stat_players as s, webig.players as p, ring_live.characters as c, nel.user as n WHERE s.sp_char = p.id AND p.cid = c.char_id AND c.user_id = n.uid AND n.privilege='' ORDER by sp_maxlevel ASC LIMIT ".floor($res[0]['playercount']/2).",1","ARRAY");
$res9 = $DBc->sendSQL("SELECT SUM(sp_itemcount) as all_item, AVG(sp_itemcount) as avg_item FROM app_achievements.stat_players as s, webig.players as p, ring_live.characters as c, nel.user as n WHERE s.sp_char = p.id AND p.cid = c.char_id AND c.user_id = n.uid AND n.privilege=''","ARRAY");
$res10 = $DBc->sendSQL("SELECT sp_itemcount FROM app_achievements.stat_players as s, webig.players as p, ring_live.characters as c, nel.user as n WHERE s.sp_char = p.id AND p.cid = c.char_id AND c.user_id = n.uid AND n.privilege='' ORDER by sp_money ASC LIMIT ".floor($res[0]['playercount']/2).",1","ARRAY");
$res10 = $DBc->sendSQL("SELECT sp_itemcount FROM app_achievements.stat_players as s, webig.players as p, ring_live.characters as c, nel.user as n WHERE s.sp_char = p.id AND p.cid = c.char_id AND c.user_id = n.uid AND n.privilege='' ORDER by sp_itemcount ASC LIMIT ".floor($res[0]['playercount']/2).",1","ARRAY");
$DBc->sendSQL("INSERT IGNORE INTO stat_daily (sd_day,sd_players,sd_money_avg,sd_money_total,sd_money_mean,sd_mek_total,sd_mek_avg,sd_mek_mean,sd_yubo_total,sd_yubo_avg,sd_yubo_mean,sd_lvl_total,sd_lvl_avg,sd_lvl_mean,sd_item_total,sd_item_avg,sd_item_mean) VALUES ('".date("Y-m-d",time())."','".$res[0]['playercount']."','".$res[0]['avg_money']."','".$res[0]['all_money']."','".$res2[0]['sp_money']."','".$res5[0]['all_mek']."','".$res5[0]['avg_mek']."','".$res6[0]['sp_mekcount']."','".$res3[0]['all_yubo']."','".$res3[0]['avg_yubo']."','".$res4[0]['sp_yubototal']."','".$res7[0]['all_lvl']."','".$res7[0]['avg_lvl']."','".$res8[0]['sp_maxlevel']."','".$res9[0]['all_item']."','".$res9[0]['avg_item']."','".$res102[0]['sp_itemcounty']."')","NONE");
$DBc->sendSQL("INSERT IGNORE INTO stat_daily (sd_day,sd_players,sd_money_avg,sd_money_total,sd_money_mean,sd_mek_total,sd_mek_avg,sd_mek_mean,sd_yubo_total,sd_yubo_avg,sd_yubo_mean,sd_lvl_total,sd_lvl_avg,sd_lvl_mean,sd_item_total,sd_item_avg,sd_item_mean) VALUES ('".date("Y-m-d",time())."','".$res[0]['playercount']."','".$res[0]['avg_money']."','".$res[0]['all_money']."','".$res2[0]['sp_money']."','".$res5[0]['all_mek']."','".$res5[0]['avg_mek']."','".$res6[0]['sp_mekcount']."','".$res3[0]['all_yubo']."','".$res3[0]['avg_yubo']."','".$res4[0]['sp_yubototal']."','".$res7[0]['all_lvl']."','".$res7[0]['avg_lvl']."','".$res8[0]['sp_maxlevel']."','".$res9[0]['all_item']."','".$res9[0]['avg_item']."','".$res10[0]['sp_itemcount']."')","NONE");
}
$log->logf("done!");
#$log->logf("done!");
$microstop = explode(' ',microtime());
$stop_time = $microstop[0] + $microstop[1];
$log->logf("Expired time: ".($stop_time - $start_time));
#$log->logf("Expired time: ".($stop_time - $start_time));
$log->logf("xml-gen took: ".$tmp_log_xmlgen_time);
$log->logf("Memory load: ".memory_get_usage()." bytes");
#$log->logf("Memory load: ".memory_get_usage()." bytes");
$log->logi("Writing XML export... ",false);
#$log->logi("Writing XML export... ",false);
$XMLgenerator->generate();
$log->logf("done!");
#$log->logf("done!");
$log->logf("Memory load: ".memory_get_usage()." bytes");
#$log->logf("Memory load: ".memory_get_usage()." bytes");
$microstop = explode(' ',microtime());
$stop_time = $microstop[0] + $microstop[1];
$log->logf("Expired time: ".($stop_time - $start_time));
#$log->logf("Expired time: ".($stop_time - $start_time));
for($dtrun=0;$dtrun<2;$dtrun++) {
#STEP 3: detect obj/task progression
$log->logi("Detecting Objectives... ",false);
#$log->logi("Detecting Objectives [PASS ".$dtrun."]... ",false);
#$log->logf("1... ",false);
//obj
$res = $DBc->sendSQL("SELECT ao_id FROM ach_objective WHERE ao_condition='all' AND NOT EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_player='".$cdata['cid']."') AND NOT EXISTS (SELECT * FROM ach_atom WHERE atom_objective=ao_id AND NOT EXISTS (SELECT * FROM ach_player_atom WHERE apa_atom=atom_id AND apa_state='GRANT' AND apa_player='".$cdata['cid']."')) AND EXISTS (SELECT * FROM ach_atom WHERE atom_objective=ao_id)","ARRAY");
@ -196,7 +232,7 @@
$DBc->sendSQL("INSERT INTO ach_player_objective (apo_objective,apo_player,apo_date) VALUES ('".$res[$i]['ao_id']."','".$cdata['cid']."','".time()."')","NONE");
}
$log->logf("1... ",false);
#$log->logf("2... ",false);
$res = $DBc->sendSQL("SELECT ao_id FROM ach_objective WHERE ao_condition='value' AND NOT EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_player='".$cdata['cid']."') AND ao_value<=(SELECT sum(apa_value) FROM ach_atom,ach_player_atom WHERE atom_objective=ao_id AND apa_atom=atom_id AND apa_state='GRANT' AND apa_player='".$cdata['cid']."') AND EXISTS (SELECT * FROM ach_atom WHERE atom_objective=ao_id)","ARRAY");
$sz = sizeof($res);
@ -204,7 +240,7 @@
$DBc->sendSQL("INSERT INTO ach_player_objective (apo_objective,apo_player,apo_date) VALUES ('".$res[$i]['ao_id']."','".$cdata['cid']."','".time()."')","NONE");
}
$log->logf("2... ",false);
#$log->logf("3... ",false);
$res = $DBc->sendSQL("SELECT ao_id FROM ach_objective WHERE ao_condition='any' AND NOT EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_player='".$cdata['cid']."') AND EXISTS (SELECT * FROM ach_atom WHERE atom_objective=ao_id AND EXISTS (SELECT * FROM ach_player_atom WHERE apa_atom=atom_id AND apa_state='GRANT' AND apa_player='".$cdata['cid']."')) AND EXISTS (SELECT * FROM ach_atom WHERE atom_objective=ao_id)","ARRAY");
$sz = sizeof($res);
@ -212,64 +248,63 @@
$DBc->sendSQL("INSERT INTO ach_player_objective (apo_objective,apo_player,apo_date) VALUES ('".$res[$i]['ao_id']."','".$cdata['cid']."','".time()."')","NONE");
}
$log->logf("3... ",false);
#$log->logf("4... ",false);
//meta
#$res = $DBc->sendSQL("SELECT ao_id FROM ach_objective,ach_task as t1,ach_achievement WHERE ao_display='meta' AND ao_task=t1.at_id AND t1.at_achievement=aa_id AND NOT EXISTS (SELECT * FROM ach_task as t2 WHERE t2.at_achievement=ao_metalink AND NOT EXISTS (SELECT * FROM ach_player_task WHERE apt_task=t2.at_id AND apt_player='".$cdata['cid']."'))","ARRAY");
$res = $DBc->sendSQL("SELECT ao_id FROM ach_objective WHERE ao_display='meta' AND NOT EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_player='".$cdata['cid']."') AND NOT EXISTS (SELECT * FROM ach_task WHERE ao_metalink=at_achievement AND NOT EXISTS (SELECT * FROM ach_player_task WHERE apt_task=at_id AND apt_player='".$cdata['cid']."'))","ARRAY");
$res = $DBc->sendSQL("SELECT ao_id FROM ach_objective WHERE ao_display='meta' AND NOT EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_player='".$cdata['cid']."') AND NOT EXISTS (SELECT * FROM ach_task WHERE ao_metalink=at_achievement AND NOT EXISTS (SELECT * FROM ach_player_task WHERE apt_task=at_id AND apt_player='".$cdata['cid']."') AND (EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id AND atta_alignment LIKE '".$cdata['cult'].'|'.$cdata['civ']."') OR NOT EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id)))","ARRAY");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$DBc->sendSQL("INSERT INTO ach_player_objective (apo_objective,apo_player,apo_date) VALUES ('".$res[$i]['ao_id']."','".$cdata['cid']."','".time()."')","NONE");
}
$log->logf("4... ",false);
$log->logf("done!");
#$log->logf("done!");
$microstop = explode(' ',microtime());
$stop_time = $microstop[0] + $microstop[1];
$log->logf("Expired time: ".($stop_time - $start_time));
#$log->logf("Expired time: ".($stop_time - $start_time));
$log->logi("Clearing atom data... ",false);
#$log->logi("Clearing atom data [PASS ".$dtrun."]... ",false);
//clear atom state for completed objectives
#$DBc->sendSQL("DELETE FROM ach_player_atom WHERE EXISTS (SELECT * FROM ach_player_objective,ach_atom WHERE atom_id=apa_atom AND apa_player='".$cdata['cid']."' AND atom_objective=apo_objective)");
$DBc->sendSQL("DELETE FROM ach_player_atom WHERE apa_player='".$cdata['cid']."' AND EXISTS (SELECT * FROM ach_player_objective,ach_atom WHERE atom_id=apa_atom AND apo_player='".$cdata['cid']."' AND atom_objective=apo_objective)");
$log->logf("done!");
#$log->logf("done!");
$microstop = explode(' ',microtime());
$stop_time = $microstop[0] + $microstop[1];
$log->logf("Expired time: ".($stop_time - $start_time));
#$log->logf("Expired time: ".($stop_time - $start_time));
//task
$log->logi("Detecting Tasks... ",false);
$res = $DBc->sendSQL("SELECT at_id FROM ach_task WHERE at_condition='all' AND NOT EXISTS (SELECT * FROM ach_player_task WHERE apt_task=at_id AND apt_player='".$cdata['cid']."') AND NOT EXISTS (SELECT * FROM ach_objective WHERE ao_task=at_id AND NOT EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_player='".$cdata['cid']."')) AND EXISTS (SELECT * FROM ach_objective WHERE ao_task=at_id) AND at_dev='0'","ARRAY");
#$log->logi("Detecting Tasks [PASS ".$dtrun."]... ",false);
#$log->logf("1... ",false);
$res = $DBc->sendSQL("SELECT at_id FROM ach_task WHERE at_condition='all' AND NOT EXISTS (SELECT * FROM ach_player_task WHERE apt_task=at_id AND apt_player='".$cdata['cid']."') AND NOT EXISTS (SELECT * FROM ach_objective WHERE ao_task=at_id AND NOT EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_player='".$cdata['cid']."')) AND EXISTS (SELECT * FROM ach_objective WHERE ao_task=at_id) AND at_dev='0' AND (NOT EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id) OR EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id AND atta_alignment LIKE '".$cdata['cult'].'|'.$cdata['civ']."'))","ARRAY");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$DBc->sendSQL("INSERT INTO ach_player_task (apt_task,apt_player,apt_date) VALUES ('".$res[$i]['at_id']."','".$cdata['cid']."','".time()."')","NONE");
}
$log->logf("1... ",false);
#$log->logf("2... ",false);
$res = $DBc->sendSQL("SELECT at_id FROM ach_task WHERE at_condition='value' AND NOT EXISTS (SELECT * FROM ach_player_task WHERE apt_task=at_id AND apt_player='".$cdata['cid']."') AND at_value<=(SELECT count(*) FROM ach_objective WHERE ao_task=at_id AND EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_player='".$cdata['cid']."')) AND EXISTS (SELECT * FROM ach_objective WHERE ao_task=at_id) AND at_dev='0'","ARRAY");
$res = $DBc->sendSQL("SELECT at_id FROM ach_task WHERE at_condition='value' AND NOT EXISTS (SELECT * FROM ach_player_task WHERE apt_task=at_id AND apt_player='".$cdata['cid']."') AND at_value<=(SELECT count(*) FROM ach_objective WHERE ao_task=at_id AND EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_player='".$cdata['cid']."')) AND EXISTS (SELECT * FROM ach_objective WHERE ao_task=at_id) AND at_dev='0' AND (NOT EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id) OR EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id AND atta_alignment LIKE '".$cdata['cult'].'|'.$cdata['civ']."'))","ARRAY");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$DBc->sendSQL("INSERT INTO ach_player_task (apt_task,apt_player,apt_date) VALUES ('".$res[$i]['at_id']."','".$cdata['cid']."','".time()."')","NONE");
}
$log->logf("2... ",false);
#$log->logf("3... ",false);
$res = $DBc->sendSQL("SELECT at_id FROM ach_task WHERE at_condition='any' AND NOT EXISTS (SELECT * FROM ach_player_task WHERE apt_task=at_id AND apt_player='".$cdata['cid']."') AND EXISTS (SELECT * FROM ach_objective WHERE ao_task=at_id AND EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_player='".$cdata['cid']."')) AND EXISTS (SELECT * FROM ach_objective WHERE ao_task=at_id) AND at_dev='0'","ARRAY");
$res = $DBc->sendSQL("SELECT at_id FROM ach_task WHERE at_condition='any' AND NOT EXISTS (SELECT * FROM ach_player_task WHERE apt_task=at_id AND apt_player='".$cdata['cid']."') AND EXISTS (SELECT * FROM ach_objective WHERE ao_task=at_id AND EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_player='".$cdata['cid']."')) AND EXISTS (SELECT * FROM ach_objective WHERE ao_task=at_id) AND at_dev='0' AND (NOT EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id) OR EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id AND atta_alignment LIKE '".$cdata['cult'].'|'.$cdata['civ']."'))","ARRAY");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$DBc->sendSQL("INSERT INTO ach_player_task (apt_task,apt_player,apt_date) VALUES ('".$res[$i]['at_id']."','".$cdata['cid']."','".time()."')","NONE");
}
$log->logf("3... ",false);
/*if($CONF['facebook'] == true) {
require_once("../fb/facebook.php");
@ -305,15 +340,25 @@ $log->logf("3... ",false);
}
}*/
$log->logf("done!");
#}
#$log->logf("done!");
$microstop = explode(' ',microtime());
$stop_time = $microstop[0] + $microstop[1];
#$log->logf("Expired time: ".($stop_time - $start_time));
}
//clear objective data for completed tasks
$DBc->sendSQL("DELETE FROM ach_player_objective WHERE apo_player='".$cdata['cid']."' AND EXISTS (SELECT * FROM ach_player_task,ach_objective WHERE ao_task=apt_task AND apt_player='".$cdata['cid']."' AND ao_id=apo_objective)");
$microstop = explode(' ',microtime());
$stop_time = $microstop[0] + $microstop[1];
$log->logf("Total time: ".($stop_time - $start_time));
$log->logf("SQL time: ".$DBc->sqltime." / ".$DBc->sqltime_post." / ".$DBc->DBstats['query']);
if(sizeof($DBc->longQuery) > 0) {
$log->logf("Longer queries: ".var_export($DBc->longQuery,true));
}
$log->logf("Run complete; exiting...");
#$log->logf("Run complete; exiting...");
$log->close();
exit(0);
?>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,386 @@
<?php
/*
class.Diff.php
A class containing a diff implementation
Created by Stephen Morley - http://stephenmorley.org/ - and released under the
terms of the CC0 1.0 Universal legal code:
http://creativecommons.org/publicdomain/zero/1.0/legalcode
*/
// A class containing functions for computing diffs and formatting the output.
class Diff{
// define the constants
const UNMODIFIED = 0;
const DELETED = 1;
const INSERTED = 2;
/* Returns the diff for two strings. The return value is an array, each of
* whose values is an array containing two values: a line (or character, if
* $compareCharacters is true), and one of the constants DIFF::UNMODIFIED (the
* line or character is in both strings), DIFF::DELETED (the line or character
* is only in the first string), and DIFF::INSERTED (the line or character is
* only in the second string). The parameters are:
*
* $string1 - the first string
* $string2 - the second string
* $compareCharacters - true to compare characters, and false to compare
* lines; this optional parameter defaults to false
*/
public static function compare(
$string1, $string2, $compareCharacters = false){
// initialise the sequences and comparison start and end positions
$start = 0;
if ($compareCharacters){
$sequence1 = $string1;
$sequence2 = $string2;
$end1 = strlen($string1) - 1;
$end2 = strlen($string2) - 1;
}else{
$sequence1 = preg_split('/\R/', $string1);
$sequence2 = preg_split('/\R/', $string2);
$end1 = count($sequence1) - 1;
$end2 = count($sequence2) - 1;
}
// skip any common prefix
while ($start <= $end1 && $start <= $end2
&& $sequence1[$start] == $sequence2[$start]){
$start ++;
}
// skip any common suffix
while ($end1 >= $start && $end2 >= $start
&& $sequence1[$end1] == $sequence2[$end2]){
$end1 --;
$end2 --;
}
// compute the table of longest common subsequence lengths
$table = self::computeTable($sequence1, $sequence2, $start, $end1, $end2);
// generate the partial diff
$partialDiff =
self::generatePartialDiff($table, $sequence1, $sequence2, $start);
// generate the full diff
$diff = array();
for ($index = 0; $index < $start; $index ++){
$diff[] = array($sequence1[$index], self::UNMODIFIED);
}
while (count($partialDiff) > 0) $diff[] = array_pop($partialDiff);
for ($index = $end1 + 1;
$index < ($compareCharacters ? strlen($sequence1) : count($sequence1));
$index ++){
$diff[] = array($sequence1[$index], self::UNMODIFIED);
}
// return the diff
return $diff;
}
/* Returns the diff for two files. The parameters are:
*
* $file1 - the path to the first file
* $file2 - the path to the second file
* $compareCharacters - true to compare characters, and false to compare
* lines; this optional parameter defaults to false
*/
public static function compareFiles(
$file1, $file2, $compareCharacters = false){
// return the diff of the files
return self::compare(
file_get_contents($file1),
file_get_contents($file2),
$compareCharacters);
}
/* Returns the table of longest common subsequence lengths for the specified
* sequences. The parameters are:
*
* $sequence1 - the first sequence
* $sequence2 - the second sequence
* $start - the starting index
* $end1 - the ending index for the first sequence
* $end2 - the ending index for the second sequence
*/
private static function computeTable(
$sequence1, $sequence2, $start, $end1, $end2){
// determine the lengths to be compared
$length1 = $end1 - $start + 1;
$length2 = $end2 - $start + 1;
// initialise the table
$table = array(array_fill(0, $length2 + 1, 0));
// loop over the rows
for ($index1 = 1; $index1 <= $length1; $index1 ++){
// create the new row
$table[$index1] = array(0);
// loop over the columns
for ($index2 = 1; $index2 <= $length2; $index2 ++){
// store the longest common subsequence length
if ($sequence1[$index1 + $start - 1]
== $sequence2[$index2 + $start - 1]){
$table[$index1][$index2] = $table[$index1 - 1][$index2 - 1] + 1;
}else{
$table[$index1][$index2] =
max($table[$index1 - 1][$index2], $table[$index1][$index2 - 1]);
}
}
}
// return the table
return $table;
}
/* Returns the partial diff for the specificed sequences, in reverse order.
* The parameters are:
*
* $table - the table returned by the computeTable function
* $sequence1 - the first sequence
* $sequence2 - the second sequence
* $start - the starting index
*/
private static function generatePartialDiff(
$table, $sequence1, $sequence2, $start){
// initialise the diff
$diff = array();
// initialise the indices
$index1 = count($table) - 1;
$index2 = count($table[0]) - 1;
// loop until there are no items remaining in either sequence
while ($index1 > 0 || $index2 > 0){
// check what has happened to the items at these indices
if ($index1 > 0 && $index2 > 0
&& $sequence1[$index1 + $start - 1]
== $sequence2[$index2 + $start - 1]){
// update the diff and the indices
$diff[] = array($sequence1[$index1 + $start - 1], self::UNMODIFIED);
$index1 --;
$index2 --;
}elseif ($index2 > 0
&& $table[$index1][$index2] == $table[$index1][$index2 - 1]){
// update the diff and the indices
$diff[] = array($sequence2[$index2 + $start - 1], self::INSERTED);
$index2 --;
}else{
// update the diff and the indices
$diff[] = array($sequence1[$index1 + $start - 1], self::DELETED);
$index1 --;
}
}
// return the diff
return $diff;
}
/* Returns a diff as a string, where unmodified lines are prefixed by ' ',
* deletions are prefixed by '- ', and insertions are prefixed by '+ '. The
* parameters are:
*
* $diff - the diff array
* $separator - the separator between lines; this optional parameter defaults
* to "\n"
*/
public static function toString($diff, $separator = "\n"){
// initialise the string
$string = '';
// loop over the lines in the diff
foreach ($diff as $line){
// extend the string with the line
switch ($line[1]){
#case self::UNMODIFIED : $string .= ' ' . $line[0];break;
#case self::DELETED : $string .= '- ' . $line[0];break;
case self::INSERTED : $string .= '' . $line[0];break;
}
// extend the string with the separator
$string .= $separator;
}
// return the string
return $string;
}
/* Returns a diff as an HTML string, where unmodified lines are contained
* within 'span' elements, deletions are contained within 'del' elements, and
* insertions are contained within 'ins' elements. The parameters are:
*
* $diff - the diff array
* $separator - the separator between lines; this optional parameter defaults
* to '<br>'
*/
public static function toHTML($diff, $separator = '<br>'){
// initialise the HTML
$html = '';
// loop over the lines in the diff
foreach ($diff as $line){
// extend the HTML with the line
switch ($line[1]){
case self::UNMODIFIED : $element = 'span'; break;
case self::DELETED : $element = 'del'; break;
case self::INSERTED : $element = 'ins'; break;
}
$html .=
'<' . $element . '>'
. htmlspecialchars($line[0])
. '</' . $element . '>';
// extend the HTML with the separator
$html .= $separator;
}
// return the HTML
return $html;
}
/* Returns a diff as an HTML table. The parameters are:
*
* $diff - the diff array
* $indentation - indentation to add to every line of the generated HTML; this
* optional parameter defaults to ''
* $separator - the separator between lines; this optional parameter
* defaults to '<br>'
*/
public static function toTable($diff, $indentation = '', $separator = '<br>'){
// initialise the HTML
$html = $indentation . "<table class=\"diff\">\n";
// loop over the lines in the diff
$index = 0;
while ($index < count($diff)){
// determine the line type
switch ($diff[$index][1]){
// display the content on the left and right
case self::UNMODIFIED:
$leftCell =
self::getCellContent(
$diff, $indentation, $separator, $index, self::UNMODIFIED);
$rightCell = $leftCell;
break;
// display the deleted on the left and inserted content on the right
case self::DELETED:
$leftCell =
self::getCellContent(
$diff, $indentation, $separator, $index, self::DELETED);
$rightCell =
self::getCellContent(
$diff, $indentation, $separator, $index, self::INSERTED);
break;
// display the inserted content on the right
case self::INSERTED:
$leftCell = '';
$rightCell =
self::getCellContent(
$diff, $indentation, $separator, $index, self::INSERTED);
break;
}
// extend the HTML with the new row
$html .=
$indentation
. " <tr>\n"
. $indentation
. ' <td class="diff'
. ($leftCell == $rightCell
? 'Unmodified'
: ($leftCell == '' ? 'Blank' : 'Deleted'))
. '">'
. $leftCell
. "</td>\n"
. $indentation
. ' <td class="diff'
. ($leftCell == $rightCell
? 'Unmodified'
: ($rightCell == '' ? 'Blank' : 'Inserted'))
. '">'
. $rightCell
. "</td>\n"
. $indentation
. " </tr>\n";
}
// return the HTML
return $html . $indentation . "</table>\n";
}
/* Returns the content of the cell, for use in the toTable function. The
* parameters are:
*
* $diff - the diff array
* $indentation - indentation to add to every line of the generated HTML
* $separator - the separator between lines
* $index - the current index, passes by reference
* $type - the type of line
*/
private static function getCellContent(
$diff, $indentation, $separator, &$index, $type){
// initialise the HTML
$html = '';
// loop over the matching lines, adding them to the HTML
while ($index < count($diff) && $diff[$index][1] == $type){
$html .=
'<span>'
. htmlspecialchars($diff[$index][0])
. '</span>'
. $separator;
$index ++;
}
// return the HTML
return $html;
}
}
?>

View file

@ -0,0 +1,15 @@
<?php
require_once("diff_class.php");
$microstart = explode(' ',microtime());
$start_time = $microstart[0] + $microstart[1];
echo Diff::toString(Diff::compareFiles('old_char_346.xml', 'char_346.xml', false));
$microstop = explode(' ',microtime());
$stop_time = $microstop[0] + $microstop[1];
echo "Expired time: ".($stop_time - $start_time)."<br>";
echo "Memory load: ".memory_get_usage()." bytes";
?>

File diff suppressed because it is too large Load diff

View file

@ -59,9 +59,11 @@
}
function grant($count = 1) { // grant an atom
global $DBc;
global $DBc,$atom_insert;
$DBc->sendSQL("INSERT INTO ach_player_atom (apa_atom,apa_player,apa_date,apa_expire,apa_state,apa_value) VALUES ('".$this->id."','".$this->user['cid']."','".time()."',null,'GRANT','".$count."')","NONE");
#$DBc->sendSQL("INSERT INTO ach_player_atom (apa_atom,apa_player,apa_date,apa_expire,apa_state,apa_value) VALUES ('".$this->id."','".$this->user['cid']."','".time()."',null,'GRANT','".$count."')","NONE");
$atom_insert[] = "('".$this->id."','".$this->user['cid']."','".time()."',null,'GRANT','".$count."')";
}
function deny() { // deny an atom
@ -73,6 +75,8 @@
function reset_() { // reset progress for this atom
global $DBc;
#$res = $DBc->sendSQL("SELECT * FROM ach_player_atom WHERE apa_atom='".$this->id."' AND apa_player='".$this->user['cid']."'","ARRAY");
$DBc->sendSQL("DELETE FROM ach_player_atom WHERE apa_atom='".$this->id."' AND apa_player='".$this->user['cid']."'","NONE");
}

View file

@ -0,0 +1,59 @@
<?php
/*
* Logging, logging, logging....
*/
class Logfile {
private $logfile;
function Logfile($f = false,$logto = "std") {
global $CONF,$MY_PATH;
$this->logfile = false;
if($f != false) {
$ldir = $MY_PATH.$CONF['logfile'].date("Y-m-d",time());
#$tmp = fopen($MY_PATH."/testlog.txt",'a+');
#fwrite($tmp, $ldir.'/'.date("H",time()).".txt\n");
#fclose($tmp);
if(!is_dir($ldir)) {
mkdir($ldir,0777,true);
}
$this->logfile = fopen($ldir.'/'.date("H",time()).'_'.$logto.'.txt','a+');
#echo "kk";
}
}
function logf($t,$nl = true) {
$this->write("[".date("H:i:s")."] ".$t);
if($nl == true) {
$this->write("\n");
}
}
function logi($t,$nl = true) {
#echo $t;
$this->write("[".date("H:i:s")."] > ".$t);
if($nl == true) {
$this->write("\n");
}
}
function write($txt) {
#echo $txt;
if($this->logfile != false) {
fwrite($this->logfile,$txt);
}
}
function close() {
if($this->logfile != false) {
fclose($this->logfile);
}
#echo "ii";
}
}
?>

View file

@ -1,9 +1,27 @@
<?php
class Stats {
#private $user;
private $data;
function Stats() {
global $cdata,$DBc;
#$this->user = $user;
$DBc->sendSQL("INSERT IGNORE INTO stat_players (sp_char) VALUES ('".$cdata['cid']."')","NONE");
$this->data = array();
}
function setValue($k,$v) {
global $DBc;
$this->data[] = $k."='".$DBc->mre($v)."'";
}
function writeData() {
global $DBc,$cdata;
$DBc->sendSQL("UPDATE stat_players SET ".implode(',',$this->data)." WHERE sp_char='".$cdata['cid']."'","NONE");
}
function register() { // register the stats code

View file

@ -17,7 +17,15 @@
function writeData($key,$val) { // write to cache
global $DBc;
$DBc->sendSQL("INSERT INTO ach_player_valuecache (apv_name,apv_player,apv_value,apv_date) VALUES ('".$DBc->mre($key)."','".$this->char."','".$DBc->mre($val)."','".time()."') ON DUPLICATE KEY UPDATE apv_value='".$DBc->mre($val)."', apv_date='".time()."'","NONE");
$res = $DBc->sendSQL("SELECT count(*) as anz FROM ach_player_valuecache WHERE apv_name='".$DBc->mre($key)."' AND apv_player='".$this->char."'","ARRAY");
if($res[0]['anz'] == 0) {
$DBc->sendSQL("INSERT DELAYED INTO ach_player_valuecache (apv_name,apv_player,apv_value,apv_date) VALUES ('".$DBc->mre($key)."','".$this->char."','".$DBc->mre($val)."','".time()."')","NONE");
}
else {
$DBc->sendSQL("UPDATE ach_player_valuecache SET apv_value='".$DBc->mre($val)."', apv_date='".time()."' WHERE apv_name='".$DBc->mre($key)."' AND apv_player='".$this->char."'","NONE");
}
}
function getData($key) { // read from cache

View file

@ -82,24 +82,30 @@
$xml .= "<xml>\n";
$xml .= " <cached>".time()."</cached>\n";
$xml .= " <uniqueid>".$cdata['cid']."</uniqueid>\n";
$xml .= " <accountid>".$cdata['aid']."</accountid>\n";
$xml .= " <charslotid>".$cdata['sid']."</charslotid>\n";
#$xml .= " <accountid>".$cdata['aid']."</accountid>\n";
#$xml .= " <charslotid>".$cdata['sid']."</charslotid>\n";
$xml .= $elem->generate(' ');
$xml .= "</xml>";
$cid = ($cdata['aid']*16+$cdata['sid']);
//store
$pth = $CONF['export_xml_path'].$elem->getIdent()."/".($cdata['cid']%10);
$pth = $CONF['export_xml_path'].$elem->getIdent()."/".($cid%10);
if(!is_dir($pth)) {
mkdir($pth,0777,true);
}
$f = fopen($pth."/".$cdata['cid'].".xml","w");
$f = fopen($pth."/".$cid.".xml","w");
fwrite($f,$xml);
fclose($f);
$old = umask();
chmod($pth."/".$cid.".xml", 0777);
umask($old);
}
}
}

View file

@ -7,8 +7,13 @@
private $parent = null;
function XMLNode($n = null,$v = null,$p = null) {
$this->name = $n;
$this->value = $v;
if(is_numeric($n)) {
$this->name = "_".$n;
}
else {
$this->name = $n;
}
$this->value = htmlspecialchars($v);
$this->parent = $p;
}
@ -21,11 +26,16 @@
}
function setName($n) {
$this->name = $n;
if(is_numeric($n)) {
$this->name = "_".$n;
}
else {
$this->name = $n;
}
}
function setValue($v) {
$this->value = $v;
$this->value = htmlspecialchars($v);
}
function addArg($k,$v) {

View file

@ -6,6 +6,9 @@
var $DBc;
var $DBstats;
var $cached;
var $sqltime;
var $sqltime_post;
var $longQuery;
function mre($in) { // shorter than "mysql_real_escape_string"
if(is_array($in)) {
@ -31,6 +34,9 @@
}
$this->resetStats(); // reset stats counter
$this->cached = false;
$this->sqltime = 0;
$this->sqltime_post = 0;
$this->longQuery = array();
}
function connect($ip,$user,$pass,$db=false) { // connect
@ -62,6 +68,9 @@
return false;
}
$microstart = explode(' ',microtime());
$start_time = $microstart[0] + $microstart[1];
if($buffer === false && $handling !== "PLAIN") {
$res = mysql_unbuffered_query($query,$this->DBc) or $this->error(mysql_error(),$query);
}
@ -71,6 +80,15 @@
$this->DBstats['query']++;
$microstop = explode(' ',microtime());
$stop_time = $microstop[0] + $microstop[1];
if(($stop_time - $start_time) > 0.5) {
$this->longQuery[] = array(($stop_time - $start_time),$query);
}
$this->sqltime += ($stop_time - $start_time);
if($res) {
if($handling === "INSERT") {
$tmp = mysql_insert_id($this->DBc) or $this->error(mysql_error());;
@ -83,7 +101,16 @@
return $tmp;
}
elseif($handling === "ARRAY") {
$microstart = explode(' ',microtime());
$start_time = $microstart[0] + $microstart[1];
$tmp = $this->parseSql($res);
$microstop = explode(' ',microtime());
$stop_time = $microstop[0] + $microstop[1];
$this->sqltime_post += ($stop_time - $start_time);
$this->unlinkSql($res);
return $tmp;
}

View file

@ -7,7 +7,7 @@
$CONF = array();
$CONF['logging'] = true;
$CONF['logfile'] = "/log/AchWebParser.log";
$CONF['logfile'] = "/log/";
$CONF['mysql_error'] = "LOG";
$CONF['mysql_server'] = RYAPI_WEBDB_HOST;
@ -15,13 +15,15 @@
$CONF['mysql_pass'] = RYAPI_WEBDB_PASS;
$CONF['mysql_database'] = "app_achievements";
#$CONF['char_mysql_server'] = RYAPI_NELDB_HOST;
#$CONF['char_mysql_user'] = RYAPI_NELDB_LOGIN;
#$CONF['char_mysql_pass'] = RYAPI_NELDB_PASS;
$CONF['char_mysql_database'] = "webig";
$CONF['webig_mysql_database'] = "webig";
$CONF['export_xml_path'] = RYAPI_PATH."data/cache/players/";
#$CONF['export_xml_path'] = "testxml/";
$CONF['char_mysql_server'] = RYAPI_NELDB_HOST;
$CONF['char_mysql_user'] = RYAPI_NELDB_LOGIN;
$CONF['char_mysql_pass'] = RYAPI_NELDB_PASS;
$CONF['char_mysql_database'] = RYAPI_NELDB_RING;
$CONF['export_xml_path'] = "../../../data/cache/players/";
#$CONF['export_xml_path'] = "cache/players/";
$CONF['data_source'] = array("PDRtoXMLdriver");

View file

@ -0,0 +1,5 @@
#!/bin/sh -
cd /home/api/public_html/server/scripts/achievement_script
sudo -u api nohup ./parse_new_xml.sh &

View file

@ -0,0 +1,22 @@
#!/bin/sh
cd /home/api/public_html/server/scripts/achievement_script
SRC=/home/api/public_html/server/scripts/achievement_script/new_xml
DST=/home/api/public_html/server/scripts/achievement_script/parse_xml
while true; do
FN=`inotifywait -r -e close_write --format '%w%f' $SRC`
for f in $SRC/*; do
NAME="$DST/"`basename $f`
mv -f $f $DST
echo "Processing $NAME"
php AchWebParser.php $NAME
rm -f $NAME
done
done
#cd -

View file

@ -0,0 +1,22 @@
<?php
$region = array();
$region['aeden'] = array("13780 -31556 ","13780 -33532 ","14364 -34876 ","19636 -34860 ","19996 -30660 ","19988 -29724 ","18676 -29452 ","14372 -29444 ","13780 -31556"); // Aeden Aqueous
$region['desert'] = array("15848 -23868 ","15944 -26572 ","17208 -27026 ","20280 -27020 ","20296 -26364 ","20312 -23868 ","18832 -23840 ","15848 -23868"); // Burning Desert
$region['verdant'] = array("3432 -4828 ","2920 -6076 ","2904 -7644 ","6048 -7836 ","6232 -6276 ","6176 -5436 ","5256 -3532 ","6240 -804 ","-249456 -348 ","3944 -340 ","376 -324 ","-254400 -1068 ","616 -2668 ","2744 -3100 ","3432 -4828"); // Verdant Heights
$region['witherings'] = array("6924 -968 ","6892 -2096 ","7028 -4632 ","8180 -4120 ","9628 -5176 ","12084 -5904 ","12420 -5552 ","12300 -2784 ","12460 -1464 ","11444 -984 ","9516 -1400 ","8220 -976 ","6924 -968"); // The Witherings
$region['nexus'] = array("7852 -6836 ","7860 -7156 ","8604 -8292 ","9140 -8300 ","2712 -6788 ","9724 -6564 ","9556 -6108 ","9012 -6116 ","7852 -6836"); // Nexus
$region['ichor'] = array("536 -10336 ","488 -11168 ","680 -11320 ","1592 -11320 ","2080 -3708 ","696 -9792 ","536 -10336"); // Abyss of Ichor
$region['spring'] = array("3484 -9776 ","2572 -10224 ","2620 -11008 ","3260 -11344 ","3804 -10912 ","3836 -10240 ","3484 -9776"); // Under Spring
$region['wastelands'] = array("204 -14072 ","748 -15336 ","2140 -15816 ","2988 -15704 ","2956 -13144 ","732 -13128 ","172 -13736 ","204 -14072"); // Wastelands
$region['umbra'] = array("5456 -9788 ","5440 -16936 ","7200 -16952 ","7344 -12472 ","6304 -9624 ","5456 -9788"); // Lands of Umbra
?>

View file

@ -0,0 +1,89 @@
<?php
$this->registerValue("_money","_statsdb_money");
function _statsdb_money($money,$_P,$_CB) {
global $cdata,$DBc,$statsdb;
$_IDENT = "_money";
#$DBc->sendSQL("UPDATE stat_players SET sp_money='".$money."' WHERE sp_char='".$cdata['cid']."'","NONE");
$statsdb->setValue('sp_money',$money);
$_P->unregisterValue($_IDENT,$_CB);
}
$this->registerValue("_race","_statsdb_race");
function _statsdb_race($race,$_P,$_CB) {
global $cdata,$DBc,$statsdb;
$_IDENT = "_race";
$race = "r_".strtolower($race);
#$DBc->sendSQL("UPDATE stat_players SET sp_race='".$race."' WHERE sp_char='".$cdata['cid']."'","NONE");
$statsdb->setValue('sp_race',$race);
$_P->unregisterValue($_IDENT,$_CB);
}
$this->registerValue("yubopoints","_statsdb_yubototal");
function _statsdb_yubototal($yubo,$_P,$_CB) {
global $cdata,$DBc,$statsdb;
$_IDENT = "yubopoints";
#$DBc->sendSQL("UPDATE stat_players SET sp_yubototal='".$yubo."' WHERE sp_char='".$cdata['cid']."'","NONE");
$statsdb->setValue('sp_yubototal',$yubo);
$_P->unregisterValue($_IDENT,$_CB);
}
$this->registerValue("petcount","_statsdb_mekcount");
function _statsdb_mekcount($count,$_P,$_CB) {
global $cdata,$DBc,$statsdb;
$_IDENT = "petcount";
#$DBc->sendSQL("UPDATE stat_players SET sp_mekcount='".$count."' WHERE sp_char='".$cdata['cid']."'","NONE");
$statsdb->setValue('sp_mekcount',$count);
$_P->unregisterValue($_IDENT,$_CB);
}
$this->registerEntity("skilllist","_statsdb_maxlevel");
function _statsdb_maxlevel($skills,$_P,$_CB) {
global $cdata,$DBc,$log,$statsdb;
$_IDENT = "skilllist";
#$log->logf("rcv skilllist: ".var_export($skills,true));
$lvl = 0;
foreach($skills->skills as $elem) {
if($elem->current > $lvl) {
$lvl = $elem->current;
}
}
#$DBc->sendSQL("UPDATE stat_players SET sp_maxlevel='".$lvl."' WHERE sp_char='".$cdata['cid']."'","NONE");
$statsdb->setValue('sp_maxlevel',$lvl);
$_P->unregisterEntity($_IDENT,$_CB);
}
$this->registerValue("_guildid","_statsdb_guildid");
function _statsdb_guildid($id,$_P,$_CB) {
global $cdata,$DBc,$statsdb;
$_IDENT = "_guildid";
#$DBc->sendSQL("UPDATE stat_players SET sp_guildid='".$id."' WHERE sp_char='".$cdata['cid']."'","NONE");
$statsdb->setValue('sp_guildid',$id);
$_P->unregisterValue($_IDENT,$_CB);
}
$this->registerValue("itemcount","_statsdb_itemcount");
function _statsdb_itemcount($count,$_P,$_CB) {
global $cdata,$DBc,$statsdb;
$_IDENT = "itemcount";
#$DBc->sendSQL("UPDATE stat_players SET sp_itemcount='".$count."' WHERE sp_char='".$cdata['cid']."'","NONE");
$statsdb->setValue('sp_itemcount',$count);
$_P->unregisterValue($_IDENT,$_CB);
}
?>

View file

@ -0,0 +1,29 @@
<?php
class BillingSummary extends SourceDriver {
function drive($cdata) {
/*
global $DBc_char,$_DISPATCHER;
$res = $DBc_char->sendSQL("SELECT SUM(amount) as anz, currency FROM coupons_billing WHERE iduser='".$cdata['aid']."' AND status='captured' GROUP by 'currency'","ARRAY");
$billed = 0;
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
if($res[$i]['currency'] == "USD") {
$res[$i]['anz'] = $res[$i]['anz']*0.7950;
}
if($res[$i]['currency'] == "GBP") {
$res[$i]['anz'] = $res[$i]['anz']*1.2623;
}
$billed += $res[$i]['anz'];
}
$_DISPATCHER->dispatchValue("user_billed_sum",$billed);*/
}
}
?>

View file

@ -26,6 +26,8 @@
require_once($BASE_PATH."/entity/FriendOf_entity.php");
require_once($BASE_PATH."/entity/Title_entity.php");
require_once($BASE_PATH."/entity/RespawnPoints_entity.php");
require_once($BASE_PATH."/entity/DeathPenalty_entity.php");
require_once($BASE_PATH."/entity/TPlist_entity.php");
class PDRtoXMLdriver extends SourceDriver {
private $ignore;
@ -40,12 +42,23 @@
private $petcount;
private $friendlist;
private $itemcount;
private $tplist;
private $hasChoice;
private $hasExcellent;
private $hasSupreme;
private $itemignore;
private $tracked_items;
private $tracked_items_new;
private $tool_list;
private $respawn_outer = 0; // needed to fetch respawn points due to nested tags with same name...
private $pathid = array();
function PDRtoXMLdriver() {
global $DBc,$cdata;
$this->lock = 0;
$this->open = null;
@ -60,6 +73,23 @@
$this->skills = new SkillList();
$this->mission = new MissionList();
$this->friendlist = new Friendlist();
$this->tplist = new TPlist();
$this->hasChoice = false;
$this->hasExcellent = false;
$this->hasSupreme = false;
$this->tool_list = array('itrtje.sitem','icokamtjewel_1.sitem','icokamtjewel_2.sitem','icokartjewel_1.sitem','icokartjewel_2.sitem','itjewel.sitem','itmwea.sitem','itrtmw.sitem','icokamtmwea_1.sitem','icokamtmwea_2.sitem','icokartmwea_1.sitem','icokartmwea_2.sitem','itrtfo.sitem','itforage.sitem','itforagekam_ep2_1.sitem','itforagekam_ep2_2.sitem','itforagekam_ep2_3.sitem','itforagekar_ep2_1.sitem','itforagekar_ep2_2.sitem','itforagekar_ep2_3.sitem','icokamtforage_1.sitem','icokamtforage_2.sitem','icokartforage_1.sitem','icokartforage_2.sitem','itrwea.sitem','itrtrw.sitem','icokamtrwea_1.sitem','icokamtrwea_2.sitem','icokartrwea_1.sitem','icokartrwea_2.sitem','itammo.sitem','itrtam.sitem','icokamtammo_1.sitem','icokamtammo_2.sitem','icokartammo_1.sitem','icokartammo_2.sitem','itarmor.sitem','itrtar.sitem','icokamtarmor_1.sitem','icokamtarmor_2.sitem','icokartarmor_1.sitem','icokartarmor_2.sitem');
$this->itemignore = false;
$this->tracked_items = array();
$res = $DBc->sendSQL("SELECT api_item FROM ach_player_item WHERE api_player='".$cdata['cid']."'","ARRAY");
foreach($res as $elem) {
$this->tracked_items[] = $elem['api_item'];
}
$this->tracked_items_new = array();
//these nodes are ignored, but children are processed
$this->ignore = array();
@ -84,7 +114,6 @@
$this->ignore_block[] = "_CONSUMABLEOVERDOSEENDDATES";
$this->ignore_block[] = "_MODIFIERSINDB";
$this->ignore_block[] = "_MISSIONS";
$this->ignore_block[] = "_ITEMSINSHOPSTORE";
$this->ignore_block[] = "RINGREWARDPOINTS";
$this->ignore_block[] = "_PACT";
$this->ignore_block[] = "_KNOWNPHRASES";
@ -96,12 +125,13 @@
$this->ignore_block[] = "_KNOWNBRICKS";
$this->ignore_block[] = "_BOUGHTPHRASES";
$this->ignore_block[] = "SKILLPOINTS";
$this->ignore_block[] = "SPENTSKILLPOINTS";
#$this->ignore_block[] = "SPENTSKILLPOINTS";
$this->ignore_block[] = "_LASTLOGSTATS";
$this->ignore_block[] = "FACTIONPOINTS";
}
function drive($cdata) {
global $_DISPATCHER,$MY_PATH,$log;
global $_DISPATCHER,$MY_PATH,$log,$DBc;
#$file = $this->conf['xml_dir']."account_".$uid."_".$slot."_pdr.xml";
$file = $_REQUEST['file'];
@ -129,9 +159,23 @@
#echo var_export($this->gear,true);
$_DISPATCHER->dispatchEntity($this->skills->getName(),$this->skills);
$_DISPATCHER->dispatchEntity($this->friendlist->getName(),$this->friendlist);
#$_DISPATCHER->dispatchEntity($this->skills->mission(),$this->mission);
$_DISPATCHER->dispatchEntity($this->tplist->getName(),$this->tplist);
$_DISPATCHER->dispatchValue('petcount',$this->petcount);
$_DISPATCHER->dispatchValue('itemcount',$this->itemcount);
$_DISPATCHER->dispatchValue('has_choice',$this->hasChoice);
$_DISPATCHER->dispatchValue('has_excellent',$this->hasExcellent);
$_DISPATCHER->dispatchValue('has_supreme',$this->hasSupreme);
$qry = array();
foreach($this->tracked_items_new as $elem) {
$qry[] = "('".$DBc->mre($elem)."','".$cdata['cid']."','".time()."')";
}
if(sizeof($qry) > 0) {
$DBc->sendSQL("INSERT DELAYED INTO ach_player_item (api_item,api_player,api_date) VALUES ".implode(',',$qry),"NONE");
}
$DBc->sendSQL("DELETE FROM ach_player_item WHERE api_date<'".(time()-605800)."'","NONE");
}
function startElement($parser, $name, $attrs) {
@ -154,8 +198,40 @@
return null;
}
/* has shop item */
if($name == '_ITEMSFORSALE') {
$this->lock = 1;
$this->ignore_block[] = "_ITEMSINSHOPSTORE";
$_DISPATCHER->dispatchValue('has_store',true);
}
/* death penalty */
if($name == "_DEATHPENALTIES") {
$this->open = "_DEATHPENALTIES";
$this->entity = new DeathPenalty();
return null;
}
if($this->open == "_DEATHPENALTIES") {
if($name == "_NBDEATH") {
$this->entity->NbDeath = $attrs['VALUE'];
}
if($name == "_CURRENTDEATHXP") {
$this->entity->CurrentDeathXP = $attrs['VALUE'];
}
if($name == "_DEATHXPTOGAIN") {
$this->entity->DeathXPToGain = $attrs['VALUE'];
}
if($name == "_BONUSUPDATETIME") {
$this->entity->BonusUpdateTime = $attrs['VALUE'];
}
}
/* spawn points */
if($name == "RESPAWNPOINTS" && !$attrs["VALUE"]) {
if($name == "RESPAWNPOINTS" && !$attrs['VALUE']) {
$this->open = "RESPAWNPOINTS";
$this->entity = new RespawnPoints();
return null;
@ -164,7 +240,7 @@
if($this->open == "RESPAWNPOINTS") {
if($name == "RESPAWNPOINTS") {
$this->respawn_outer = 0;
$this->entity->spawns[] = $attrs["VALUE"];
$this->entity->spawns[] = $attrs['VALUE'];
}
}
@ -177,12 +253,12 @@
if($this->open == "FACTIONPOINTS") {
if($name == "__KEY__") {
$this->entity = new FactionPoints();
$this->entity->faction = $attrs["VALUE"];
$this->entity->faction = $attrs['VALUE'];
return null;
}
if($name == "__VAL__") {
$this->entity->value = $attrs["VALUE"];
$this->entity->value = $attrs['VALUE'];
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
$this->entity = null;
return null;
@ -200,20 +276,20 @@
if($this->open == "_FAME") {
if($name == "__KEY__") {
$this->entity = new Fame();
$this->entity->faction = $attrs["VALUE"];
$this->entity->faction = $attrs['VALUE'];
return null;
}
if($name == "FAME") {
$this->entity->fame = $attrs["VALUE"];
$this->entity->fame = $attrs['VALUE'];
return null;
}
if($name == "FAMEMEMORY") {
$this->entity->famememory = $attrs["VALUE"];
$this->entity->famememory = $attrs['VALUE'];
return null;
}
if($name == "LASTFAMECHANGETREND") {
$this->entity->lastfamechangetrend = $attrs["VALUE"];
$this->entity->lastfamechangetrend = $attrs['VALUE'];
return null;
}
@ -229,15 +305,15 @@
if($this->open == "_LASTLOGSTATS") {
if($name == "LOGINTIME") {
$this->entity->logintime = $attrs["VALUE"];
$this->entity->logintime = $attrs['VALUE'];
return null;
}
if($name == "DURATION") {
$this->entity->duration = $attrs["VALUE"];
$this->entity->duration = $attrs['VALUE'];
return null;
}
if($name == "LOGOFFTIME") {
$this->entity->logofftime = $attrs["VALUE"];
$this->entity->logofftime = $attrs['VALUE'];
return null;
}
@ -253,16 +329,16 @@
if($this->open == "_MISSIONHISTORIES") {
if($name == "__KEY__") {
$this->entity = new Mission();
$this->entity->mission = $attrs["VALUE"];
$this->entity->mission = $attrs['VALUE'];
return null;
}
if($name == "SUCCESSFULL") {
$this->entity->successfull = $attrs["VALUE"];
$this->entity->successfull = $attrs['VALUE'];
return null;
}
if($name == "UTC_LASTSUCCESSDATE") {
$this->entity->utc_lastsuccessdate = $attrs["VALUE"];
$this->entity->utc_lastsuccessdate = $attrs['VALUE'];
return null;
}
@ -271,14 +347,14 @@
if($name == "_FRIENDSLIST") {
$this->entity = new Friend();
$this->entity->id = $attrs["VALUE"];
$this->entity->id = $attrs['VALUE'];
$this->friendlist->friends[] = $this->entity;
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
}
if($name == "_ISFRIENDOF") {
$this->entity = new FriendOf();
$this->entity->id = $attrs["VALUE"];
$this->entity->id = $attrs['VALUE'];
$this->friendlist->friendof[] = $this->entity;
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
}
@ -292,12 +368,12 @@
if($this->open == "SCOREPERMANENTMODIFIERS") {
if($name == "__KEY__") {
$this->entity = new PermanentMod();
$this->entity->score = $attrs["VALUE"];
$this->entity->score = $attrs['VALUE'];
return null;
}
if($name == "__VAL__") {
$this->entity->value = $attrs["VALUE"];
$this->entity->value = $attrs['VALUE'];
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
$this->entity = null;
return null;
@ -315,65 +391,65 @@
if($this->open == "_PLAYERPETS") {
if($name == "__KEY__") {
$this->entity = new Pet();
$this->entity->pet = $attrs["VALUE"];
$this->entity->pet = $attrs['VALUE'];
return null;
}
if($name == "TICKETPETSHEETID") {
$this->entity->ticketpetsheetid = $attrs["VALUE"];
$this->entity->ticketpetsheetid = $attrs['VALUE'];
return null;
}
if($name == "PETSHEETID") {
$this->entity->petsheetid = $attrs["VALUE"];
$this->entity->petsheetid = $attrs['VALUE'];
$this->petcount++;
return null;
}
if($name == "PRICE") {
$this->entity->price = $attrs["VALUE"];
$this->entity->price = $attrs['VALUE'];
return null;
}
if($name == "OWNERID") {
$this->entity->ownerid = $attrs["VALUE"];
$this->entity->ownerid = $attrs['VALUE'];
return null;
}
if($name == "STABLEALIAS") {
$this->entity->stablealias = $attrs["VALUE"];
$this->entity->stablealias = $attrs['VALUE'];
return null;
}
if($name == "LANDSCAPE_X") {
$this->entity->landscape_x = $attrs["VALUE"];
$this->entity->landscape_x = $attrs['VALUE'];
return null;
}
if($name == "LANDSCAPE_Y") {
$this->entity->landscape_y = $attrs["VALUE"];
$this->entity->landscape_y = $attrs['VALUE'];
return null;
}
if($name == "LANDSCAPE_Z") {
$this->entity->landscape_z = $attrs["VALUE"];
$this->entity->landscape_z = $attrs['VALUE'];
return null;
}
if($name == "UTC_DEATHTICK") {
$this->entity->utc_deathtick = $attrs["VALUE"];
$this->entity->utc_deathtick = $attrs['VALUE'];
return null;
}
if($name == "PETSTATUS") {
$this->entity->petstatus = $attrs["VALUE"];
$this->entity->petstatus = $attrs['VALUE'];
return null;
}
if($name == "SLOT") {
$this->entity->slot = $attrs["VALUE"];
$this->entity->slot = $attrs['VALUE'];
return null;
}
if($name == "ISTPALLOWED") {
$this->entity->istpallowed = $attrs["VALUE"];
$this->entity->istpallowed = $attrs['VALUE'];
return null;
}
if($name == "SATIETY") {
$this->entity->satiety = $attrs["VALUE"];
$this->entity->satiety = $attrs['VALUE'];
return null;
}
if($name == "CUSTOMNAME") {
$this->entity->customname = $attrs["VALUE"];
$this->entity->customname = $attrs['VALUE'];
return null;
}
@ -389,12 +465,12 @@
if($this->open == "_PHYSICALCHARACTERISTICS") {
if($name == "__KEY__") {
$this->entity = new PhysCharacs();
$this->entity->charac = $attrs["VALUE"];
$this->entity->charac = $attrs['VALUE'];
return null;
}
if($name == "__VAL__") {
$this->entity->value = $attrs["VALUE"];
$this->entity->value = $attrs['VALUE'];
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
$this->entity = null;
return null;
@ -412,32 +488,32 @@
if($this->open == "PHYSICALSCORES") {
if($name == "__KEY__") {
$this->entity = new PhysScores();
$this->entity->score = $attrs["VALUE"];
$this->entity->score = $attrs['VALUE'];
return null;
}
if($name == "CURRENT") {
$this->entity->current = $attrs["VALUE"];
$this->entity->current = $attrs['VALUE'];
return null;
}
if($name == "BASE") {
$this->entity->base = $attrs["VALUE"];
$this->entity->base = $attrs['VALUE'];
return null;
}
if($name == "MAX") {
$this->entity->max = $attrs["VALUE"];
$this->entity->max = $attrs['VALUE'];
return null;
}
if($name == "BASEREGENERATEREPOS") {
$this->entity->baseregeneraterepos = $attrs["VALUE"];
$this->entity->baseregeneraterepos = $attrs['VALUE'];
return null;
}
if($name == "BASEREGENERATEACTION") {
$this->entity->baseregenerateaction = $attrs["VALUE"];
$this->entity->baseregenerateaction = $attrs['VALUE'];
return null;
}
if($name == "CURRENTREGENERATE") {
$this->entity->currentregenerate = $attrs["VALUE"];
$this->entity->currentregenerate = $attrs['VALUE'];
return null;
}
@ -453,12 +529,12 @@
if($this->open == "SKILLPOINTS") {
if($name == "__KEY__") {
$this->entity = new SkillPoints();
$this->entity->skill = $attrs["VALUE"];
$this->entity->skill = $attrs['VALUE'];
return null;
}
if($name == "__VAL__") {
$this->entity->value = $attrs["VALUE"];
$this->entity->value = $attrs['VALUE'];
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
$this->entity = null;
return null;
@ -476,12 +552,12 @@
if($this->open == "SPENTSKILLPOINTS") {
if($name == "__KEY__") {
$this->entity = new SpentSkillPoints();
$this->entity->skill = $attrs["VALUE"];
$this->entity->skill = $attrs['VALUE'];
return null;
}
if($name == "__VAL__") {
$this->entity->value = $attrs["VALUE"];
$this->entity->value = $attrs['VALUE'];
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
$this->entity = null;
return null;
@ -499,28 +575,28 @@
if($this->open == "SKILLS") {
if($name == "__KEY__") {
$this->entity = new Skill();
$this->entity->skill = $attrs["VALUE"];
$this->entity->skill = $attrs['VALUE'];
return null;
}
if($name == "BASE") {
$this->entity->base = $attrs["VALUE"];
$this->entity->base = $attrs['VALUE'];
return null;
}
if($name == "CURRENT") {
$this->entity->current = $attrs["VALUE"];
$this->entity->current = $attrs['VALUE'];
return null;
}
if($name == "MAXLVLREACHED") {
$this->entity->maxlvlreached = $attrs["VALUE"];
$this->entity->maxlvlreached = $attrs['VALUE'];
return null;
}
if($name == "XP") {
$this->entity->xp = $attrs["VALUE"];
$this->entity->xp = $attrs['VALUE'];
return null;
}
if($name == "XPNEXTLVL") {
$this->entity->xpnextlvl = $attrs["VALUE"];
$this->entity->xpnextlvl = $attrs['VALUE'];
return null;
}
@ -536,19 +612,19 @@
if($this->open == "POSSTATE") {
if($name == "X") {
$this->entity->x = $attrs["VALUE"];
$this->entity->x = $attrs['VALUE'];
return null;
}
if($name == "Y") {
$this->entity->y = $attrs["VALUE"];
$this->entity->y = $attrs['VALUE'];
return null;
}
if($name == "Z") {
$this->entity->z = $attrs["VALUE"];
$this->entity->z = $attrs['VALUE'];
return null;
}
if($name == "HEADING") {
$this->entity->heading = $attrs["VALUE"];
$this->entity->heading = $attrs['VALUE'];
return null;
}
@ -569,99 +645,138 @@
if($this->iblock == true) {
if($name == "__KEY__") {
$this->inv = $attrs["VALUE"];
$this->inv = $attrs['VALUE'];
}
if($name == "__VAL__") {
return null;
}
}
if($name == "_ITEMS" || $name == "_ITEM") {
if($name == '_ITEMS' || $name == '_ITEM') {
#echo "i<br>";
$this->open = "_ITEM";
$this->open = '_ITEM';
$this->entity = new Item();
$this->entity->inventory = $this->inv;
$this->itemcount++;
return null;
}
if($this->open == "_ITEM") {
if($name == "_CRAFTPARAMETERS") {
if($this->open == '_ITEM') {
if($this->itemignore == true) {
return null;
}
if($name == '_CRAFTPARAMETERS') {
$this->icraft = true;
return null;
}
if($this->icraft == true) {
$this->entity->_craftparameters[strtolower($name)] = $attrs["VALUE"];
if($name == 'HPBUFF' || $name == 'SAPBUFF' || $name == 'FOCUSBUFF' || $name == 'STABUFF') {
$this->entity->_craftparameters[strtolower($name)] = $attrs['VALUE'];
}
return null;
}
if($name == "_ITEMID") {
$this->entity->_itemid = $attrs["VALUE"];
if($name == '_ITEMID') {
$this->entity->_itemid = $attrs['VALUE'];
return null;
}
if($name == "_SHEETID") {
if($attrs["VALUE"]{0} == "#") {
$tmp = str_replace("#","",$attrs["VALUE"]);
if($name == '_SHEETID') {
if($attrs['VALUE']{0} == '#') {
$tmp = str_replace("#","",$attrs['VALUE']);
$res = $DBc->sendSQL("SELECT * FROM ryzom_nimetu_sheets WHERE nsh_numid='".$tmp."'","ARRAY");
$attrs["VALUE"] = $res[0]['nsh_name']."".$res[0]['nsh_suffix'];
$attrs['VALUE'] = $res[0]['nsh_name']."".$res[0]['nsh_suffix'];
}
$this->entity->_sheetid = $attrs["VALUE"];
if(substr($attrs['VALUE'],0,3) == 'tp_') {
$this->tplist->tps[] = $attrs['VALUE'];
$this->itemignore = true;
return null;
}
if(substr($attrs['VALUE'],0,1) == 'm') {
$this->itemignore = true;
if($this->hasChoice == false || $this->hasExcellent == false || $this->hasSupreme == false) {
switch(substr($attrs['VALUE'],-9,-8)) {
case 'f':
$this->hasSupreme = true;
break;
case 'e':
$this->hasExcellent = true;
break;
case 'd':
$this->hasChoice = true;
break;
}
}
return null;
}
$this->entity->_sheetid = $attrs['VALUE'];
if($this->entity->inventory != 'bag' && in_array($this->entity->_itemid,$this->tracked_items) && !in_array($this->entity->_sheetid,$this->tool_list)) {
$this->itemignore = true;
}
$this->tracked_items_new[] = $this->entity->_itemid;
return null;
}
if($name == "_LOCSLOT") {
$this->entity->_locslot = $attrs["VALUE"];
if($name == '_LOCSLOT') {
$this->entity->_locslot = $attrs['VALUE'];
return null;
}
if($name == "_HP") {
$this->entity->_hp = $attrs["VALUE"];
if($name == '_HP') {
$this->entity->_hp = $attrs['VALUE'];
return null;
}
if($name == "_RECOMMENDED") {
$this->entity->_recommended = $attrs["VALUE"];
if($name == '_RECOMMENDED') {
$this->entity->_recommended = $attrs['VALUE'];
return null;
}
if($name == "_CREATORID") {
$this->entity->_creatorid = $attrs["VALUE"];
if($name == '_CREATORID') {
$this->entity->_creatorid = $attrs['VALUE'];
return null;
}
if($name == "_PHRASEID") {
$this->entity->_phraseid = $attrs["VALUE"];
if($name == '_PHRASEID') {
$this->entity->_phraseid = $attrs['VALUE'];
return null;
}
if($name == "_REFINVENTORYSLOT") {
$this->entity->_refinventoryslot = $attrs["VALUE"];
if($name == '_REFINVENTORYSLOT') {
$this->entity->_refinventoryslot = $attrs['VALUE'];
#if($this->entity->refinventoryid != null) {
$this->gear->items[] = $this->entity;
#}
return null;
}
if($name == "REFINVENTORYID") {
$this->entity->refinventoryid = $attrs["VALUE"];
if($name == 'REFINVENTORYID') {
$this->entity->refinventoryid = $attrs['VALUE'];
return null;
}
if($name == "_USENEWSYSTEMREQUIREMENT") {
$this->entity->_usenewsystemrequirement = $attrs["VALUE"];
if($name == '_USENEWSYSTEMREQUIREMENT') {
$this->entity->_usenewsystemrequirement = $attrs['VALUE'];
return null;
}
if($name == "_REQUIREDSKILLLEVEL") {
$this->entity->_requiredskilllevel = $attrs["VALUE"];
if($name == '_REQUIREDSKILLLEVEL') {
$this->entity->_requiredskilllevel = $attrs['VALUE'];
return null;
}
if($name == "_CUSTOMTEXT") {
$this->entity->_customtext = $attrs["VALUE"];
if($name == '_CUSTOMTEXT') {
$this->entity->_customtext = $attrs['VALUE'];
return null;
}
if($name == "_LOCKEDBYOWNER") {
$this->entity->_lockedbyowner = $attrs["VALUE"];
if($name == '_LOCKEDBYOWNER') {
$this->entity->_lockedbyowner = $attrs['VALUE'];
return null;
}
if($name == "_DROPABLE") {
$this->entity->_dropable = $attrs["VALUE"];
if($name == '_DROPABLE') {
$this->entity->_dropable = $attrs['VALUE'];
return null;
}
if($name == "STACKSIZE") {
$this->entity->stacksize = $attrs["VALUE"];
if($name == 'STACKSIZE') {
$this->entity->stacksize = $attrs['VALUE'];
return null;
}
}
@ -670,8 +785,8 @@
if($attrs["VALUE"] != "") {
$_DISPATCHER->dispatchValue(strtolower($name),$attrs["VALUE"]);
if($attrs['VALUE'] != '') {
$_DISPATCHER->dispatchValue(strtolower($name),$attrs['VALUE']);
}
}
@ -690,6 +805,15 @@
return null;
}
/* death penalty */
if($name == "_DEATHPENALTIES") {
$this->open = null;
$this->entity->DeathXPToGain = $this->entity->DeathXPToGain*min(10,$this->entity->NbDeath);
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
$this->entity = null;
return null;
}
/* respawn points */
if($name == "RESPAWNPOINTS") {
$this->respawn_outer++; // increment to track double close at end of block
@ -709,7 +833,7 @@
}
/* fame */
if($name == "__VAL__" && $this->open == "FAME") {
if($name == "__VAL__" && $this->open == "_FAME") {
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
$this->entity = null;
return null;
@ -811,23 +935,26 @@
}
/* items */
if($name == "_ITEMS" || $name == "_ITEM") {
if($name == '_ITEMS' || $name == '_ITEM') {
#echo "c<br>";
if($this->open == "_ITEM") {
if($this->open == '_ITEM') {
#echo var_export($this->entity,true);
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
if($this->itemignore == false) {
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
}
$this->itemignore = false;
$this->entity = null;
}
$this->open = null;
return null;
}
if($name == "INVENTORY") {
if($name == 'INVENTORY') {
$this->iblock = false;
return null;
}
if($name == "_CRAFTPARAMETERS") {
if($name == '_CRAFTPARAMETERS') {
$this->icraft = false;
return null;
}

View file

@ -0,0 +1,13 @@
<?php
class DeathPenalty extends Entity {
public $NbDeath;
public $CurrentDeathXP;
public $DeathXPToGain;
public $BonusUpdateTime;
function DeathPenalty() {
$this->setName("death_penalty");
}
}
?>

View file

@ -0,0 +1,14 @@
<?php
class TPlist extends Entity {
public $tps;
function TPlist() {
$this->setName("TPlist");
$this->tps = array();
}
function hasTP($tp) {
return in_array($tp,$this->tps);
}
}
?>

View file

@ -58,6 +58,7 @@ $this->def['XML/_PLAYERROOM/ROOMINVENTORY/_ITEMS/_CRAFTPARAMETERS/HEALCASTINGTIM
$this->def['XML/_PLAYERROOM/ROOMINVENTORY/_ITEMS/_CRAFTPARAMETERS/HEALPOWERFACTOR'] = array("inventory");
$this->def['XML/_PLAYERROOM/ROOMINVENTORY/_ITEMS/_CRAFTPARAMETERS/DEFENSIVEAFFLICTIONCASTINGTIMEFACTOR'] = array("inventory");
$this->def['XML/_PLAYERROOM/ROOMINVENTORY/_ITEMS/_CRAFTPARAMETERS/DEFENSIVEAFFLICTIONPOWERFACTOR'] = array("inventory");
$this->def['XML/_PLAYERROOM/ROOMINVENTORY/_ITEMS/_CRAFTPARAMETERS/_ENCHANTMENT'] = array("inventory");
$this->def['XML/_PLAYERPETS'] = array("inventory");
$this->def['XML/_PLAYERPETS/__KEY__'] = array("inventory");
$this->def['XML/_PLAYERPETS/__VAL__'] = array("inventory");
@ -125,6 +126,7 @@ $this->def['XML/INVENTORY/__VAL__/_ITEM/_CRAFTPARAMETERS/HEALCASTINGTIMEFACTOR']
$this->def['XML/INVENTORY/__VAL__/_ITEM/_CRAFTPARAMETERS/HEALPOWERFACTOR'] = array("inventory");
$this->def['XML/INVENTORY/__VAL__/_ITEM/_CRAFTPARAMETERS/DEFENSIVEAFFLICTIONCASTINGTIMEFACTOR'] = array("inventory");
$this->def['XML/INVENTORY/__VAL__/_ITEM/_CRAFTPARAMETERS/DEFENSIVEAFFLICTIONPOWERFACTOR'] = array("inventory");
$this->def['XML/INVENTORY/__VAL__/_ITEM/_CRAFTPARAMETERS/_ENCHANTMENT'] = array("inventory");
$this->def['XML/INVENTORY/__VAL__/_ITEM/_REFINVENTORYSLOT'] = array("inventory");
$this->def['XML/INVENTORY/__VAL__/_ITEM/REFINVENTORYID'] = array("inventory");

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;
}

View file

@ -1,44 +0,0 @@
<?php
/*
* Logging, logging, logging....
*/
class Logfile {
private $logfile;
function Logfile($f = false) {
global $CONF,$MY_PATH;
$this->logfile = false;
if($f != false) {
$this->logfile = fopen($MY_PATH.$CONF['logfile'].'.'.date("Ymd",time()).'.txt','a+');
#echo "kk";
}
}
function logf($t,$nl = true) {
$this->write("[".date("H:i:s")."] ".$t);
if($nl == true) {
$this->write("\n");
}
}
function logi($t,$nl = true) {
#echo $t;
$this->write("[".date("H:i:s")."] > ".$t);
if($nl == true) {
$this->write("\n");
}
}
function write($txt) {
#echo $txt;
fwrite($this->logfile,$txt);
}
function close() {
fclose($this->logfile);
#echo "ii";
}
}
?>

View file

@ -1,77 +0,0 @@
<?php
/*
* Code from:
* http://www.assemblysys.com/dataServices/php_pointinpolygon.php
*
* Probably not free to use!!!
*/
class pointLocation {
var $pointOnVertex = true; // Check if the point sits exactly on one of the vertices
function pointLocation() {
}
function pointInPolygon($point, $polygon, $pointOnVertex = true) {
$this->pointOnVertex = $pointOnVertex;
// Transform string coordinates into arrays with x and y values
$point = $this->pointStringToCoordinates($point);
$vertices = array();
foreach($polygon as $vertex) {
$vertices[] = $this->pointStringToCoordinates($vertex);
}
// Check if the point sits exactly on a vertex
if($this->pointOnVertex == true and $this->pointOnVertex($point, $vertices) == true) {
return "vertex";
}
// Check if the point is inside the polygon or on the boundary
$intersections = 0;
$vertices_count = count($vertices);
for($i=1; $i < $vertices_count; $i++) {
$vertex1 = $vertices[$i-1];
$vertex2 = $vertices[$i];
if($vertex1['y'] == $vertex2['y'] and $vertex1['y'] == $point['y'] and $point['x'] > min($vertex1['x'], $vertex2['x']) and $point['x'] < max($vertex1['x'], $vertex2['x'])) { // Check if point is on an horizontal polygon boundary
return "boundary";
}
if($point['y'] > min($vertex1['y'], $vertex2['y']) and $point['y'] <= max($vertex1['y'], $vertex2['y']) and $point['x'] <= max($vertex1['x'], $vertex2['x']) and $vertex1['y'] != $vertex2['y']) {
$xinters = ($point['y'] - $vertex1['y']) * ($vertex2['x'] - $vertex1['x']) / ($vertex2['y'] - $vertex1['y']) + $vertex1['x'];
if($xinters == $point['x']) { // Check if point is on the polygon boundary (other than horizontal)
return "boundary";
}
if($vertex1['x'] == $vertex2['x'] || $point['x'] <= $xinters) {
$intersections++;
}
}
}
// If the number of edges we passed through is even, then it's in the polygon.
if ($intersections % 2 != 0) {
return "inside";
}
else {
return "outside";
}
}
function pointOnVertex($point, $vertices) {
foreach($vertices as $vertex) {
if ($point == $vertex) {
return true;
}
}
return false;
}
function pointStringToCoordinates($pointString) {
$coordinates = explode(" ", $pointString);
return array("x" => $coordinates[0], "y" => $coordinates[1]);
}
}
?>

View file

@ -1,6 +0,0 @@
<?php
$region = array();
?>

View file

@ -1,26 +0,0 @@
<?php
$region = array();
$region['place_starting_zone_arena'] = array("10056 -11594 ","10144 -11726 ","10280 -11670 ","10308 -11558 ","10132 -11498 ","10056 -11594");
$region['region_newbieland_blight_zone'] = array("9376 -10940","9120 -11148","9048 -11780","9624 -11988","9792 -11732","9960 -11388","9376 -10940");
$region['region_newbieland_hunting_grounds'] = array("10296 -10812","10232 -11164","10080 -11484","10320 -11540","10824 -11540","11112 -11268","11080 -10804","10640 -10644","10296 -10812");
$region['kami_enclave'] = array("10416 -11654","10352 -11718","10416 -11770","10488 -11710","10416 -11654");
$region['karavan embassy'] = array("10388 -11818","10320 -11874","10404 -11922","10456 -11858","10388 -11818");
$region['region_newbieland_kitins_jungle'] = array("8184 -11076","8680 -11036","8704 -10244","8160 -10252","8184 -11076");
$region['region_newbieland_starting_zone'] = array("9968 -11346","10384 -11582","10788 -11574","10760 -11962","9892 -12014","9812 -11682","9968 -11346");
$region['place_shattered_ruins_trone'] = array("9678 -10692","9574 -10778","9668 -10846","9784 -10748","9678 -10692");
$region['place_shattered_ruins_silan'] = array("9558 -10764 ","9700 -10910 ","9616 -11008 ","9864 -11238 ","10158 -11224 ","10280 -11070 ","10166 -10982 ","9986 -10880 ","9878 -10808 ","9684 -10660 ","9558 -10764");
$region['region_newbieland_the_shattered_ruins'] = array("9472 -10562 ","9336 -10974 ","9824 -11266 ","10252 -11354 ","10328 -11182 ","10272 -11126 ","10288 -11074 ","10356 -11070 ","10308 -10746 ","9804 -10458 ","9472 -10562");
$region['region_newbieland_shining_lake'] = array("8608 -11244","8840 -11356","9288 -11044","9488 -10644","9360 -10340","8776 -10380","8624 -10676","8608 -11244");
?>

View file

@ -1,82 +0,0 @@
<?php
$this->registerValue("_money","_statsdb_money");
function _statsdb_money($money,$_P,$_CB) {
global $cdata,$DBc;
$_IDENT = "_money";
$DBc->sendSQL("INSERT INTO stat_players (sp_char,sp_money) VALUES ('".$cdata['cid']."','".$money."') ON DUPLICATE KEY UPDATE sp_money='".$money."'","NONE");
$_P->unregisterValue($_IDENT,$_CB);
}
$this->registerValue("_race","_statsdb_race");
function _statsdb_race($race,$_P,$_CB) {
global $cdata,$DBc;
$_IDENT = "_race";
$race = "r_".strtolower($race);
$DBc->sendSQL("INSERT INTO stat_players (sp_char,sp_race) VALUES ('".$cdata['cid']."','".$race."') ON DUPLICATE KEY UPDATE sp_race='".$race."'","NONE");
$_P->unregisterValue($_IDENT,$_CB);
}
$this->registerValue("yubopoints","_statsdb_yubototal");
function _statsdb_yubototal($yubo,$_P,$_CB) {
global $cdata,$DBc;
$_IDENT = "yubopoints";
$DBc->sendSQL("INSERT INTO stat_players (sp_char,sp_yubototal) VALUES ('".$cdata['cid']."','".$yubo."') ON DUPLICATE KEY UPDATE sp_yubototal='".$yubo."'","NONE");
$_P->unregisterValue($_IDENT,$_CB);
}
$this->registerValue("petcount","_statsdb_mekcount");
function _statsdb_mekcount($count,$_P,$_CB) {
global $cdata,$DBc;
$_IDENT = "petcount";
$DBc->sendSQL("INSERT INTO stat_players (sp_char,sp_mekcount) VALUES ('".$cdata['cid']."','".$count."') ON DUPLICATE KEY UPDATE sp_mekcount='".$count."'","NONE");
$_P->unregisterValue($_IDENT,$_CB);
}
$this->registerValue("skilllist","_statsdb_maxlevel");
function _statsdb_maxlevel($skills,$_P,$_CB) {
global $cdata,$DBc,$log;
$_IDENT = "skilllist";
$log->logf("rcv skilllist: ".var_export($skills,true));
$lvl = 0;
foreach($skills->skills as $elem) {
if($elem->current > $lvl) {
$lvl = $elem->current;
}
}
$DBc->sendSQL("INSERT INTO stat_players (sp_char,sp_maxlevel) VALUES ('".$cdata['cid']."','".$lvl."') ON DUPLICATE KEY UPDATE sp_maxlevel='".$lvl."'","NONE");
$_P->unregisterValue($_IDENT,$_CB);
}
$this->registerValue("_guildid","_statsdb_guildid");
function _statsdb_guildid($id,$_P,$_CB) {
global $cdata,$DBc;
$_IDENT = "_guildid";
$DBc->sendSQL("INSERT INTO stat_players (sp_char,sp_guildid) VALUES ('".$cdata['cid']."','".$id."') ON DUPLICATE KEY UPDATE sp_guildid='".$id."'","NONE");
$_P->unregisterValue($_IDENT,$_CB);
}
$this->registerValue("itemcount","_statsdb_itemcount");
function _statsdb_itemcount($count,$_P,$_CB) {
global $cdata,$DBc;
$_IDENT = "itemcount";
$DBc->sendSQL("INSERT INTO stat_players (sp_char,sp_itemcount) VALUES ('".$cdata['cid']."','".$count."') ON DUPLICATE KEY UPDATE sp_itemcount='".$count."'","NONE");
$_P->unregisterValue($_IDENT,$_CB);
}
?>

File diff suppressed because it is too large Load diff

View file

@ -1,16 +1,16 @@
-- --------------------------------------------------------
-- Host: 178.33.225.92
-- Server version: 5.5.28-0ubuntu0.12.04.2-log - (Ubuntu)
-- Server OS: debian-linux-gnu
-- HeidiSQL version: 7.0.0.4053
-- Date/time: 2012-12-10 14:52:03
-- Server Version: 5.5.28-0ubuntu0.12.04.2-log - (Ubuntu)
-- Server Betriebssystem: debian-linux-gnu
-- HeidiSQL Version: 7.0.0.4328
-- --------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET FOREIGN_KEY_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
-- Dumping structure for table app_achievements.ach_achievement
-- Exportiere Struktur von Tabelle app_achievements.ach_achievement
CREATE TABLE IF NOT EXISTS `ach_achievement` (
`aa_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`aa_category` bigint(20) unsigned NOT NULL,
@ -24,10 +24,10 @@ CREATE TABLE IF NOT EXISTS `ach_achievement` (
PRIMARY KEY (`aa_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- Data exporting was unselected.
-- Daten Export vom Benutzer nicht ausgewählt
-- Dumping structure for table app_achievements.ach_achievement_lang
-- Exportiere Struktur von Tabelle app_achievements.ach_achievement_lang
CREATE TABLE IF NOT EXISTS `ach_achievement_lang` (
`aal_achievement` bigint(20) unsigned NOT NULL,
`aal_lang` varchar(2) COLLATE utf8_bin NOT NULL,
@ -36,10 +36,10 @@ CREATE TABLE IF NOT EXISTS `ach_achievement_lang` (
PRIMARY KEY (`aal_achievement`,`aal_lang`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- Data exporting was unselected.
-- Daten Export vom Benutzer nicht ausgewählt
-- Dumping structure for table app_achievements.ach_atom
-- Exportiere Struktur von Tabelle app_achievements.ach_atom
CREATE TABLE IF NOT EXISTS `ach_atom` (
`atom_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`atom_objective` bigint(20) unsigned NOT NULL,
@ -50,10 +50,10 @@ CREATE TABLE IF NOT EXISTS `ach_atom` (
KEY `atom_objective` (`atom_objective`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- Data exporting was unselected.
-- Daten Export vom Benutzer nicht ausgewählt
-- Dumping structure for table app_achievements.ach_category
-- Exportiere Struktur von Tabelle app_achievements.ach_category
CREATE TABLE IF NOT EXISTS `ach_category` (
`ac_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`ac_parent` bigint(20) unsigned DEFAULT NULL,
@ -62,13 +62,15 @@ CREATE TABLE IF NOT EXISTS `ach_category` (
`ac_dev` tinyint(1) unsigned NOT NULL DEFAULT '0',
`ac_heroic` tinyint(1) unsigned NOT NULL,
`ac_contest` tinyint(1) unsigned NOT NULL,
`ac_allow_civ` tinyint(1) unsigned NOT NULL,
`ac_allow_cult` tinyint(1) unsigned NOT NULL,
PRIMARY KEY (`ac_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- Data exporting was unselected.
-- Daten Export vom Benutzer nicht ausgewählt
-- Dumping structure for table app_achievements.ach_category_lang
-- Exportiere Struktur von Tabelle app_achievements.ach_category_lang
CREATE TABLE IF NOT EXISTS `ach_category_lang` (
`acl_category` bigint(20) unsigned NOT NULL,
`acl_lang` varchar(2) COLLATE utf8_bin NOT NULL,
@ -76,10 +78,10 @@ CREATE TABLE IF NOT EXISTS `ach_category_lang` (
PRIMARY KEY (`acl_category`,`acl_lang`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- Data exporting was unselected.
-- Daten Export vom Benutzer nicht ausgewählt
-- Dumping structure for table app_achievements.ach_fb_token
-- Exportiere Struktur von Tabelle app_achievements.ach_fb_token
CREATE TABLE IF NOT EXISTS `ach_fb_token` (
`aft_player` bigint(20) unsigned NOT NULL,
`aft_token` varchar(255) NOT NULL,
@ -88,10 +90,10 @@ CREATE TABLE IF NOT EXISTS `ach_fb_token` (
PRIMARY KEY (`aft_player`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Data exporting was unselected.
-- Daten Export vom Benutzer nicht ausgewählt
-- Dumping structure for table app_achievements.ach_objective
-- Exportiere Struktur von Tabelle app_achievements.ach_objective
CREATE TABLE IF NOT EXISTS `ach_objective` (
`ao_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`ao_task` bigint(20) unsigned NOT NULL,
@ -103,10 +105,10 @@ CREATE TABLE IF NOT EXISTS `ach_objective` (
KEY `ao_task` (`ao_task`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- Data exporting was unselected.
-- Daten Export vom Benutzer nicht ausgewählt
-- Dumping structure for table app_achievements.ach_objective_lang
-- Exportiere Struktur von Tabelle app_achievements.ach_objective_lang
CREATE TABLE IF NOT EXISTS `ach_objective_lang` (
`aol_objective` bigint(20) unsigned NOT NULL,
`aol_lang` varchar(2) COLLATE utf8_bin NOT NULL,
@ -114,67 +116,76 @@ CREATE TABLE IF NOT EXISTS `ach_objective_lang` (
PRIMARY KEY (`aol_objective`,`aol_lang`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- Data exporting was unselected.
-- Daten Export vom Benutzer nicht ausgewählt
-- Dumping structure for table app_achievements.ach_player_atom
-- Exportiere Struktur von Tabelle app_achievements.ach_player_atom
CREATE TABLE IF NOT EXISTS `ach_player_atom` (
`apa_atom` bigint(20) unsigned NOT NULL,
`apa_player` bigint(20) unsigned NOT NULL,
`apa_atom` bigint(10) unsigned NOT NULL,
`apa_player` bigint(10) unsigned NOT NULL,
`apa_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`apa_date` bigint(20) unsigned NOT NULL,
`apa_expire` blob,
`apa_state` enum('GRANT','DENY') COLLATE utf8_bin NOT NULL,
`apa_value` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`apa_id`),
KEY `apa_atom` (`apa_atom`,`apa_player`),
KEY `apa_state` (`apa_state`),
KEY `apa_atom_2` (`apa_atom`,`apa_player`,`apa_state`),
KEY `apa_player` (`apa_player`),
KEY `apa_atom_3` (`apa_atom`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
KEY `apa_atom_2` (`apa_atom`,`apa_player`,`apa_state`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=FIXED;
-- Data exporting was unselected.
-- Daten Export vom Benutzer nicht ausgewählt
-- Dumping structure for table app_achievements.ach_player_objective
-- Exportiere Struktur von Tabelle app_achievements.ach_player_item
CREATE TABLE IF NOT EXISTS `ach_player_item` (
`api_item` varchar(32) COLLATE utf8_bin NOT NULL,
`api_player` int(10) unsigned NOT NULL,
`api_date` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`api_item`,`api_player`),
KEY `Index 2` (`api_player`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED;
-- Daten Export vom Benutzer nicht ausgewählt
-- Exportiere Struktur von Tabelle app_achievements.ach_player_objective
CREATE TABLE IF NOT EXISTS `ach_player_objective` (
`apo_objective` bigint(20) unsigned NOT NULL,
`apo_player` bigint(20) unsigned NOT NULL,
`apo_date` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`apo_objective`,`apo_player`),
KEY `apo_player` (`apo_player`),
KEY `apo_objective` (`apo_objective`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
PRIMARY KEY (`apo_objective`,`apo_player`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED;
-- Data exporting was unselected.
-- Daten Export vom Benutzer nicht ausgewählt
-- Dumping structure for table app_achievements.ach_player_task
-- Exportiere Struktur von Tabelle app_achievements.ach_player_task
CREATE TABLE IF NOT EXISTS `ach_player_task` (
`apt_task` bigint(20) unsigned NOT NULL,
`apt_player` bigint(20) unsigned NOT NULL,
`apt_date` bigint(20) unsigned NOT NULL,
`apt_fb` tinyint(1) unsigned NOT NULL,
PRIMARY KEY (`apt_task`,`apt_player`),
KEY `apt_player` (`apt_player`),
KEY `apt_task` (`apt_task`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
PRIMARY KEY (`apt_task`,`apt_player`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin DELAY_KEY_WRITE=1;
-- Data exporting was unselected.
-- Daten Export vom Benutzer nicht ausgewählt
-- Dumping structure for table app_achievements.ach_player_valuecache
-- Exportiere Struktur von Tabelle app_achievements.ach_player_valuecache
CREATE TABLE IF NOT EXISTS `ach_player_valuecache` (
`apv_name` varchar(64) COLLATE utf8_bin NOT NULL,
`apv_player` bigint(20) unsigned NOT NULL,
`apv_name` varchar(10) COLLATE utf8_bin NOT NULL,
`apv_player` bigint(10) unsigned NOT NULL,
`apv_value` varchar(255) COLLATE utf8_bin NOT NULL,
`apv_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`apv_date` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`apv_name`,`apv_player`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
PRIMARY KEY (`apv_id`),
UNIQUE KEY `key1` (`apv_name`,`apv_player`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED;
-- Data exporting was unselected.
-- Daten Export vom Benutzer nicht ausgewählt
-- Dumping structure for table app_achievements.ach_task
-- Exportiere Struktur von Tabelle app_achievements.ach_task
CREATE TABLE IF NOT EXISTS `ach_task` (
`at_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`at_achievement` bigint(20) unsigned NOT NULL,
@ -190,10 +201,10 @@ CREATE TABLE IF NOT EXISTS `ach_task` (
KEY `at_achievement` (`at_achievement`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- Data exporting was unselected.
-- Daten Export vom Benutzer nicht ausgewählt
-- Dumping structure for table app_achievements.ach_task_lang
-- Exportiere Struktur von Tabelle app_achievements.ach_task_lang
CREATE TABLE IF NOT EXISTS `ach_task_lang` (
`atl_task` bigint(20) unsigned NOT NULL,
`atl_lang` varchar(2) COLLATE utf8_bin NOT NULL,
@ -202,40 +213,113 @@ CREATE TABLE IF NOT EXISTS `ach_task_lang` (
PRIMARY KEY (`atl_task`,`atl_lang`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- Data exporting was unselected.
-- Daten Export vom Benutzer nicht ausgewählt
-- Dumping structure for table app_achievements.ach_task_tie_civ
-- Exportiere Struktur von Tabelle app_achievements.ach_task_tie_align
CREATE TABLE IF NOT EXISTS `ach_task_tie_align` (
`atta_task` bigint(20) unsigned NOT NULL DEFAULT '0',
`atta_alignment` varchar(64) NOT NULL DEFAULT '',
PRIMARY KEY (`atta_task`,`atta_alignment`),
KEY `Index 2` (`atta_task`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- Daten Export vom Benutzer nicht ausgewählt
-- Exportiere Struktur von Tabelle app_achievements.ach_task_tie_civ
CREATE TABLE IF NOT EXISTS `ach_task_tie_civ` (
`attciv_task` bigint(20) unsigned NOT NULL,
`attciv_civ` varchar(64) NOT NULL,
PRIMARY KEY (`attciv_task`,`attciv_civ`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
`attciv_task` int(10) DEFAULT NULL,
`attciv_civ` int(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- Data exporting was unselected.
-- Daten Export vom Benutzer nicht ausgewählt
-- Dumping structure for table app_achievements.ach_task_tie_cult
-- Exportiere Struktur von Tabelle app_achievements.ach_task_tie_cult
CREATE TABLE IF NOT EXISTS `ach_task_tie_cult` (
`attcult_task` bigint(20) unsigned NOT NULL,
`attcult_cult` varchar(64) NOT NULL,
PRIMARY KEY (`attcult_task`,`attcult_cult`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
`attcult_cult` int(10) DEFAULT NULL,
`attcult_task` int(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- Data exporting was unselected.
-- Daten Export vom Benutzer nicht ausgewählt
-- Dumping structure for table app_achievements.ach_task_tie_race
-- Exportiere Struktur von Tabelle app_achievements.ach_task_tie_race
CREATE TABLE IF NOT EXISTS `ach_task_tie_race` (
`attr_task` bigint(20) unsigned NOT NULL,
`attr_race` varchar(64) NOT NULL,
PRIMARY KEY (`attr_task`,`attr_race`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Data exporting was unselected.
-- Daten Export vom Benutzer nicht ausgewählt
-- Dumping structure for table app_achievements.stat_daily
-- Exportiere Struktur von Tabelle app_achievements.ryzom_nimetu_item_data
CREATE TABLE IF NOT EXISTS `ryzom_nimetu_item_data` (
`sheetid` varchar(64) COLLATE utf8_bin NOT NULL,
`type` int(10) unsigned NOT NULL,
`item_type` int(10) unsigned NOT NULL,
`race` int(10) unsigned NOT NULL,
`quality` int(10) unsigned NOT NULL,
`craftplan` varchar(32) COLLATE utf8_bin NOT NULL,
`skill` varchar(16) COLLATE utf8_bin NOT NULL,
`damage` int(10) unsigned NOT NULL,
`reach` int(10) unsigned NOT NULL,
`ecosystem` int(10) unsigned NOT NULL,
`grade` int(10) unsigned NOT NULL,
`mpft` bigint(20) unsigned NOT NULL,
`color` int(10) unsigned NOT NULL,
`is_looted` int(10) unsigned NOT NULL,
`is_mission` int(10) unsigned NOT NULL,
`index` int(10) unsigned NOT NULL,
`txt` text COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`sheetid`),
KEY `type` (`type`),
KEY `item_type` (`item_type`),
KEY `type_2` (`type`,`item_type`),
KEY `race` (`race`),
KEY `quality` (`quality`),
KEY `craftplan` (`craftplan`),
KEY `skill` (`skill`),
KEY `damage` (`damage`),
KEY `reach` (`reach`),
KEY `ecosystem` (`ecosystem`),
KEY `grade` (`grade`),
KEY `mpft` (`mpft`),
KEY `color` (`color`),
KEY `is_looted` (`is_looted`),
KEY `is_mission` (`is_mission`),
KEY `index` (`index`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- Daten Export vom Benutzer nicht ausgewählt
-- Exportiere Struktur von Tabelle app_achievements.ryzom_nimetu_sheets
CREATE TABLE IF NOT EXISTS `ryzom_nimetu_sheets` (
`nsh_numid` bigint(20) NOT NULL,
`nsh_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`nsh_suffix` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`nsh_numid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- Daten Export vom Benutzer nicht ausgewählt
-- Exportiere Struktur von Tabelle app_achievements.ryzom_title
CREATE TABLE IF NOT EXISTS `ryzom_title` (
`t_id` varchar(255) CHARACTER SET utf8 NOT NULL,
`t_lang` varchar(2) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`t_male` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`t_female` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`t_id`,`t_lang`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- Daten Export vom Benutzer nicht ausgewählt
-- Exportiere Struktur von Tabelle app_achievements.stat_daily
CREATE TABLE IF NOT EXISTS `stat_daily` (
`sd_day` date NOT NULL DEFAULT '0000-00-00',
`sd_players` bigint(20) unsigned DEFAULT NULL,
@ -257,12 +341,12 @@ CREATE TABLE IF NOT EXISTS `stat_daily` (
PRIMARY KEY (`sd_day`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- Data exporting was unselected.
-- Daten Export vom Benutzer nicht ausgewählt
-- Dumping structure for table app_achievements.stat_players
-- Exportiere Struktur von Tabelle app_achievements.stat_players
CREATE TABLE IF NOT EXISTS `stat_players` (
`sp_char` bigint(20) unsigned NOT NULL DEFAULT '0',
`sp_char` bigint(10) unsigned NOT NULL DEFAULT '0',
`sp_money` bigint(20) unsigned DEFAULT NULL,
`sp_race` enum('r_matis','r_tryker','r_fyros','r_zorai') DEFAULT NULL,
`sp_yubototal` int(10) unsigned DEFAULT NULL,
@ -271,8 +355,9 @@ CREATE TABLE IF NOT EXISTS `stat_players` (
`sp_guildid` int(10) unsigned DEFAULT NULL,
`sp_itemcount` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`sp_char`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=MyISAM DEFAULT CHARSET=utf8 DELAY_KEY_WRITE=1;
-- Data exporting was unselected.
/*!40014 SET FOREIGN_KEY_CHECKS=1 */;
-- Daten Export vom Benutzer nicht ausgewählt
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;

View file

@ -4,7 +4,7 @@
* open and done.
*/
class AchAchievement extends AchList {
class AchAchievement extends AchList implements Tieable {
#########################
# PHP 5.3 compatible
# InDev_trait replaces this in PHP 5.4
@ -44,7 +44,7 @@
protected $template;
protected $sticky;
function AchAchievement($data,$parent) {
function AchAchievement($data,&$parent) {
global $DBc,$_USER,$_CONF;
parent::__construct();
@ -68,7 +68,7 @@
$this->template = $res[0]['aal_template'];
}
$res = $DBc->sqlQuery("SELECT * FROM ach_task LEFT JOIN (ach_task_lang) ON (atl_lang='".$_USER->getLang()."' AND atl_task=at_id) LEFT JOIN (ach_player_task) ON (apt_task=at_id AND apt_player='".$_USER->getID()."') WHERE at_achievement='".$this->id."' ORDER by at_torder ASC");
$res = $DBc->sqlQuery("SELECT * FROM ach_task LEFT JOIN (ach_task_lang) ON (atl_lang='".$_USER->getLang()."' AND atl_task=at_id) LEFT JOIN (ach_player_task) ON (apt_task=at_id AND apt_player='".$_USER->getID()."') WHERE at_achievement='".$this->id."' AND (NOT EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id) OR EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id AND atta_alignment LIKE '".$parent->getCurrentCult().'|'.$parent->getCurrentCiv()."')) ORDER by at_torder ASC");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
@ -112,12 +112,64 @@
return $this->parent_id;
}
function getTieRace() {
function hasTieRace_open() {
#return $this->tie_race;
$iter = $this->child_open->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->hasTieRace_open() && !$curr->inDev()) {
return true;
}
}
return false;
}
function hasTieAlign_open() {
#return $this->tie_civ;
$iter = $this->child_open->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->hasTieAlign_open() && !$curr->inDev()) {
return true;
}
}
return false;
}
function hasTieRace_done() {
#return $this->tie_race;
$iter = $this->child_done->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->hasTieRace_done() && !$curr->inDev()) {
return true;
}
}
return false;
}
function hasTieAlign_done() {
#return $this->tie_civ;
$iter = $this->child_done->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->hasTieAlign_done() && !$curr->inDev()) {
return true;
}
}
return false;
}
function hasTieRaceDev() {
#return $this->tie_race;
$iter = $this->nodes->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->hasTieRace()) {
if($curr->hasTieRaceDev()) {
return true;
}
}
@ -125,12 +177,12 @@
return false;
}
function getTieCiv() {
function hasTieAlignDev() {
#return $this->tie_civ;
$iter = $this->nodes->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->hasTieCiv()) {
if($curr->hasTieAlignDev()) {
return true;
}
}
@ -138,25 +190,14 @@
return false;
}
function getTieCult() {
#return $this->tie_cult;
$iter = $this->nodes->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->hasTieCult()) {
return true;
}
}
return false;
}
function isTiedRace($r) {
function isTiedRace_open($r) {
#return $this->tie_race;
$iter = $this->nodes->getIterator();
$iter = $this->child_open->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->isTiedRace($r)) {
if($curr->isTiedRace_open($r)) {
return true;
}
}
@ -164,12 +205,12 @@
return false;
}
function isTiedCiv($c) {
function isTiedAlign_open($cult,$civ) {
#return $this->tie_civ;
$iter = $this->nodes->getIterator();
$iter = $this->child_open->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->isTiedCiv($c)) {
if($curr->isTiedAlign_open($cult,$civ)) {
return true;
}
}
@ -177,12 +218,12 @@
return false;
}
function isTiedCult($c) {
#return $this->tie_cult;
$iter = $this->nodes->getIterator();
function isTiedRace_done($r) {
#return $this->tie_race;
$iter = $this->child_done->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->isTiedCult($c)) {
if($curr->isTiedRace_done($r)) {
return true;
}
}
@ -190,6 +231,20 @@
return false;
}
function isTiedAlign_done($cult,$civ) {
#return $this->tie_civ;
$iter = $this->child_done->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->isTiedAlign_done($cult,$civ)) {
return true;
}
}
return false;
}
function getImage() {
return $this->image;
}

Some files were not shown because too many files have changed in this diff Show more