merge from default

This commit is contained in:
SirCotare 2013-02-15 16:29:59 +01:00
commit 08fbdfec17
112 changed files with 50168 additions and 51188 deletions

View file

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

View file

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

View file

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

View file

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 748 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 977 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 488 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

View file

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

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!");
@ -53,6 +57,8 @@
require_once("class/XMLfile_class.php");
require_once("class/Stats_class.php");
$atom_insert = array();
$_CACHE = new ValueCache();
//new generator for API xml files.
@ -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

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

View file

@ -4,28 +4,34 @@
*/
class AchCategory extends AchList implements Tieable {
protected $ties_cult;
protected $ties_civ;
protected $ties_race;
protected $ties_align_done;
protected $ties_race_done;
protected $ties_align_open;
protected $ties_race_open;
protected $ties_race_dev;
protected $ties_cult_dev;
protected $ties_civ_dev;
protected $ties_align_dev;
protected $cult;
protected $civ;
protected $race;
protected $heroic;
protected $contest;
protected $allow_civ;
protected $allow_cult;
function AchCategory($id,$race = null,$cult = null,$civ = null) {
function AchCategory($id,$race = null,$cult = "c_neutral",$civ = "c_neutral") {
global $DBc,$_USER;
parent::__construct();
$civ = $DBc->sqlEscape($civ);
$cult = $DBc->sqlEscape($cult);
if($civ != "%") {
$civ = $DBc->sqlEscape($civ);
}
if($cult != "%") {
$cult = $DBc->sqlEscape($cult);
}
$race = $DBc->sqlEscape($race);
if($race == null) {
/*if($race == null) {
$race = $_USER->getRace();
}
@ -35,10 +41,11 @@
if($civ == null) {
$civ = $_USER->getCiv();
}
}*/
$this->cult = $cult;
$this->civ = $civ;
$this->rave = $race;
$this->id = $DBc->sqlEscape($id);
@ -56,61 +63,78 @@
}
}
$res = $DBc->sqlQuery("SELECT ac_heroic,ac_contest FROM ach_category WHERE ac_id='".$this->id."'");
$res = $DBc->sqlQuery("SELECT ac_heroic,ac_contest,ac_allow_civ,ac_allow_cult FROM ach_category WHERE ac_id='".$this->id."'");
$this->heroic = $res[0]['ac_heroic'];
$this->contest = $res[0]['ac_contest'];
$this->allow_civ = $res[0]['ac_allow_civ'];
$this->allow_cult = $res[0]['ac_allow_cult'];
//load counts for tie determination
/*$res = $DBc->sqlQuery("SELECT count(*) as anz FROM ach_achievement WHERE aa_tie_cult IS NOT NULL AND aa_category='".$this->id."' AND aa_dev='0'");
$this->ties_cult = $res[0]['anz'];
$res = $DBc->sqlQuery("SELECT count(*) as anz FROM ach_achievement WHERE aa_tie_civ IS NOT NULL AND aa_category='".$this->id."' AND aa_dev='0'");
$this->ties_civ = $res[0]['anz'];
$res = $DBc->sqlQuery("SELECT count(*) as anz FROM ach_achievement WHERE aa_tie_race IS NOT NULL AND aa_category='".$this->id."' AND aa_dev='0'");
$this->ties_race = $res[0]['anz'];
$res = $DBc->sqlQuery("SELECT count(*) as anz FROM ach_achievement WHERE aa_tie_race IS NOT NULL AND aa_category='".$this->id."'");
$this->ties_race_dev = $res[0]['anz'];
$res = $DBc->sqlQuery("SELECT count(*) as anz FROM ach_achievement WHERE aa_tie_cult IS NOT NULL AND aa_category='".$this->id."'");
$this->ties_cult_dev = $res[0]['anz'];
$res = $DBc->sqlQuery("SELECT count(*) as anz FROM ach_achievement WHERE aa_tie_civ IS NOT NULL AND aa_category='".$this->id."'");
$this->ties_civ_dev = $res[0]['anz'];*/
$iter = $this->nodes->getIterator();
$tmp = false;
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->getTieRace()) {
if($curr->hasTieRace_open() && !$curr->inDev()) {
$tmp = true;
break;
}
}
$this->ties_race = $tmp;
$this->ties_race_open = $tmp;
$iter = $this->nodes->getIterator();
$tmp = false;
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->getTieCiv()) {
if($curr->hasTieAlign_open() && !$curr->inDev()) {
$tmp = true;
break;
}
}
$this->ties_civ = $tmp;
$this->ties_align_open = $tmp;
$iter = $this->nodes->getIterator();
$tmp = false;
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->getTieCult()) {
if($curr->hasTieRace_done() && !$curr->inDev()) {
$tmp = true;
break;
}
}
$this->ties_cult = $tmp;
$this->ties_race_done = $tmp;
$iter = $this->nodes->getIterator();
$tmp = false;
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->hasTieAlign_done() && !$curr->inDev()) {
$tmp = true;
break;
}
}
$this->ties_align_done = $tmp;
$iter = $this->nodes->getIterator();
$tmp = false;
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->hasTieRaceDev()) {
$tmp = true;
break;
}
}
$this->ties_race_dev = $tmp;
$iter = $this->nodes->getIterator();
$tmp = false;
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->hasTieAlignDev()) {
$tmp = true;
break;
}
}
$this->ties_align_dev = $tmp;
}
#@override Parentum::makeChild()
@ -118,28 +142,36 @@
return new AchAchievement($a,$this);
}
function isTiedRace() {
return ($this->ties_race > 0);
function isAllowedCult() {
return ($this->allow_cult == 1);
}
function isTiedCult() {
return ($this->ties_cult > 0);
function isAllowedCiv() {
return ($this->allow_civ == 1);
}
function isTiedCiv() {
return ($this->ties_civ > 0);
function hasTieRace_open() {
return $this->ties_race_open;
}
function isTiedRaceDev() {
return ($this->ties_race_dev > 0);
function hasTieAlign_open() {
return $this->ties_align_open;
}
function isTiedCultDev() {
return ($this->ties_cult_dev > 0);
function hasTieRace_done() {
return $this->ties_race_done;
}
function isTiedCivDev() {
return ($this->ties_civ_dev > 0);
function hasTieAlign_done() {
return $this->ties_align_done;
}
function hasTieRaceDev() {
return $this->ties_race_dev;
}
function hasTieAlignDev() {
return $this->ties_align_dev;
}
function getCurrentCiv() {
@ -154,6 +186,22 @@
return $this->race;
}
function isTiedRace_open($r) {
return null;
}
function isTiedAlign_open($cult,$civ) {
return null;
}
function isTiedRace_done($r) {
return null;
}
function isTiedAlign_done($cult,$civ) {
return null;
}
function isHeroic() {
return ($this->heroic == 1);
}

View file

@ -15,7 +15,7 @@
//read all recent tasks of user
//make distinct achievement list
$res = $DBc->sqlQuery("SELECT DISTINCT aa_id,ach.*,(SELECT aal_name FROM ach_achievement_lang WHERE aal_lang='".$_USER->getLang()."' AND aal_achievement=ach.aa_id) as aal_name, (SELECT aal_template FROM ach_achievement_lang WHERE aal_lang='".$_USER->getLang()."' AND aal_achievement=ach.aa_id) as aal_template FROM ach_achievement as ach,ach_task,ach_player_task WHERE at_achievement=aa_id AND apt_player='".$_USER->getID()."' AND apt_task=at_id ORDER by apt_date DESC LIMIT 0,".$size);
$res = $DBc->sqlQuery("SELECT DISTINCT apt_date,aa_id,ach.*,(SELECT aal_name FROM ach_achievement_lang WHERE aal_lang='".$_USER->getLang()."' AND aal_achievement=ach.aa_id) as aal_name, (SELECT aal_template FROM ach_achievement_lang WHERE aal_lang='".$_USER->getLang()."' AND aal_achievement=ach.aa_id) as aal_template FROM ach_achievement as ach,ach_task,ach_player_task WHERE at_achievement=aa_id AND ach.aa_dev='0' AND apt_player='".$_USER->getID()."' AND apt_task=at_id ORDER by apt_date DESC LIMIT 0,".$size);
#echo var_export($res,true);
@ -107,6 +107,10 @@
return "c_neutral";
}
function getCurrentRace() {
return "r_matis";
}
function isHeroic() {
return false;
}
@ -114,5 +118,55 @@
function isContest() {
return false;
}
function hasTieRace_open()
{
return false;
}
function hasTieAlign_open()
{
return false;
}
function hasTieRace_done()
{
return false;
}
function hasTieAlign_done()
{
return false;
}
function hasTieRaceDev()
{
return false;
}
function hasTieAlignDev()
{
return false;
}
function isTiedRace_open($r)
{
return true;
}
function isTiedAlign_open($cult, $civ)
{
return true;
}
function isTiedRace_done($r)
{
return true;
}
function isTiedAlign_done($cult, $civ)
{
return true;
}
}
?>

View file

@ -1,5 +1,5 @@
<?php
class AchTask extends Parentum {
class AchTask extends Parentum implements Tieable {
#########################
# PHP 5.3 compatible
# InDev_trait replaces this in PHP 5.4
@ -38,8 +38,9 @@
protected $inherit_obj;
private $heritage_list;
protected $tie_race;
protected $tie_cult;
protected $tie_civ;
#protected $tie_cult;
#protected $tie_civ;
protected $tie_align;
function AchTask($data,$parent) {
global $DBc,$_USER,$_CONF;
@ -88,7 +89,7 @@
$this->tie_race[] = $res[$i]['attr_race'];
}
$res = $DBc->sqlQuery("SELECT attcult_cult FROM ach_task_tie_cult WHERE attcult_task='".$this->id."'");
/*$res = $DBc->sqlQuery("SELECT attcult_cult FROM ach_task_tie_cult WHERE attcult_task='".$this->id."'");
$sz = sizeof($res);
$this->tie_cult = array();
@ -102,6 +103,14 @@
$this->tie_civ = array();
for($i=0;$i<$sz;$i++) {
$this->tie_civ[] = $res[$i]['attciv_civ'];
}*/
$res = $DBc->sqlQuery("SELECT atta_alignment FROM ach_task_tie_align WHERE atta_task='".$this->id."'");
$sz = sizeof($res);
$this->tie_align = array();
for($i=0;$i<$sz;$i++) {
$this->tie_align[] = $res[$i]['atta_alignment'];
}
}
@ -119,6 +128,7 @@
$this->addChild($curr);
$this->heritage_list->insert($curr);
}
return true;
}
#@override Parentum::makeChild()
@ -141,36 +151,74 @@
}
function hasTieRace() {
if($this->dev == 1) {
return false;
}
return (sizeof($this->tie_race) != 0);
}
function hasTieCult() {
return (sizeof($this->tie_cult) != 0);
function hasTieAlign() {
if($this->dev == 1) {
return false;
}
return (sizeof($this->tie_align) != 0);
}
function hasTieCiv() {
return (sizeof($this->tie_civ) != 0);
function hasTieRace_open() {
return $this->hasTieRace();
}
function hasTieRace_done() {
return $this->hasTieRace();
}
function hasTieAlign_open() {
return $this->hasTieAlign();
}
function hasTieAlign_done() {
return $this->hasTieAlign();
}
function hasTieRaceDev() {
return (sizeof($this->tie_race) != 0);
}
function hasTieAlignDev() {
return (sizeof($this->tie_align) != 0);
}
function isTiedRace($r) {
if(sizeof($this->tie_race) == 0) {
return true;
}
return in_array($r,$this->race);
return in_array($r,$this->tie_race);
}
function isTiedCult($c) {
if(sizeof($this->tie_cult) == 0) {
function isTiedAlign($cult,$civ) {
if($cult == "%" || $civ == "%") {
return true;
}
return in_array($c,$this->tie_cult);
if(sizeof($this->tie_align) == 0) {
return true;
}
return in_array(($cult.'|'.$civ),$this->tie_align);
}
function isTiedCiv($c) {
if(sizeof($this->tie_civ) == 0) {
return true;
}
return in_array($c,$this->tie_civ);
function isTiedRace_open($r) {
return $this->isTiedRace($r);
}
function isTiedRace_done($r) {
return $this->isTiedRace($r);
}
function isTiedAlign_done($cult,$civ) {
return $this->isTiedAlign($cult,$civ);
}
function isTiedAlign_open($cult,$civ) {
return $this->isTiedAlign($cult,$civ);
}
function getAchievement() {

View file

@ -23,15 +23,15 @@
}
function getRace() {
return $this->data['race'];
return 'r_'.$this->data['race'];
}
function getCiv() {
return $this->data['civilization'];
return 'c_'.$this->data['civ'];
}
function getCult() {
return $this->data['cult'];
return 'c_'.$this->data['cult'];
}
function getName() {

View file

@ -6,12 +6,28 @@
on a user's cult of civ allegiance.
---------------------------*/
function isTiedCult();
function hasTieRace_open();
function isTiedCiv();
function hasTieAlign_open();
function getCurrentCiv();
function hasTieRace_done();
function getCurrentCult();
function hasTieAlign_done();
function hasTieRaceDev();
function hasTieAlignDev();
function isTiedRace_open($r);
function isTiedAlign_open($cult,$civ);
function isTiedRace_done($r);
function isTiedAlign_done($cult,$civ);
#function getCurrentCiv();
#function getCurrentCult();
}
?>

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