#1470 monday's update :)

This commit is contained in:
SirCotare 2012-07-09 19:10:44 +02:00
parent ae1b00ea18
commit 6f84c47ac1
29 changed files with 1805 additions and 287 deletions

View file

@ -8,18 +8,21 @@
require_once("class/mySQL_class.php");
require_once("conf.php");
require_once("inlcude/functions_inc.php");
require_once("include/functions_inc.php");
$logfile = false;
$_REQUEST['file'] = $argv[1];
/*$logfile = false;
if($CONF['logging'] == true) {
require_once("class/Logfile_class.php");
#$logfile = fopen($CONF['logfile'].'.'.date("Ymd",time()).'.txt','a');
$logfile = new Logfile($CONF['logfile']);
}
$logfile = new Logfile($CONF['logfile']);#!! MUST HAVE ONE LOGFILE PER RUN!!
}*/
//set mode: cron || single with given cid
#MISSING: conf to allow external calls; whitelist ips
$MODE = "CRON";
/*$MODE = "CRON";
if($_REQUEST["cid"] > 0 || $_REQUEST["invoke"] == "TRUE") {
if($_REQUEST["cid"] > 0 && $_REQUEST["invoke"] == "TRUE") {
$MODE = "SINGLE";
@ -30,52 +33,39 @@
logf($e);
die($e);
}
}
}*/
//create database connection
$DBc = new mySQL($CONF['mysql_error']);
$DBc->connect($CONF['mysql_server'],$CONF['mysql_user'],$CONF['mysql_pass'],$CONF['mysql_database']);
if($MODE == "CRON") {
$RID = $DBc->sendSQL("INSERT INTO ach_monitor_state (ams_start,ams_end) VALUES ('".time()."','0')","INSERT"); // insert run into monitoring table
}
#if($MODE == "CRON") {
# $RID = $DBc->sendSQL("INSERT INTO ach_monitor_state (ams_start,ams_end) VALUES ('".time()."','0')","INSERT"); // insert run into monitoring table
#}
require_once("class/DataDispatcher_class.php");
require_once("class/DataSourceHandler_class.php");
require_once("class/DataSource_abstract.php");
require_once("class/SourceDriver_abstract.php");
require_once("class/Callback_class.php");
require_once("class/ValueCache_class.php");
require_once("class/Atom_class.php");
#MISSING: static ValueCache!
$_CACHE = new ValueCache();
//create datasource handler
$_DATA = new DataSourceHandler();
$_DISPATCHER = new DataDispatcher();
$_DATASOURCE = new DataSourceHandler();
foreach($CONF['data_source'] as $elem) { //populate
require_once("source/".$elem."/".$elem."_class.php");
eval('$tmp = new '.$elem.'();');
$_DATA->registerDataSource($tmp);
}
//synch chars from ring_open character table
if($CONF['synch_chars'] == true) {
$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']);
$DBc->sendSQL("UPDATE ach_monitor_character SET amc_confirmed='0'","NONE");
$res = $DBc_char->sendSQL("SELECT char_id,last_played_date FROM characters","ARRAY");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$DBc->sendSQL("INSERT INTO ach_monitor_character (amc_character,amc_last_import,amc_last_login,amc_confirmed) VALUES ('".$res[$i]['char_id']."','0','".dateTime_to_timestamp($res[$i]['last_played_date'])."','1') ON DUPLICATE KEY UPDATE amc_confirmed='1', amc_last_login='".dateTime_to_timestamp($res[$i]['last_played_date'])."'","NONE");
}
$DBc->sendSQL("DELETE FROM ach_monitor_character WHERE amc_confirmed='0'","NONE"); //remove deleted characters
//remove data for deleted chars
$DBc->sendSQL("DELETE FROM ach_player_atom WHERE NOT EXISTS (SELECT * FROM ach_monitor_character WHERE amc_character='apa_player')","NONE");
$DBc->sendSQL("DELETE FROM ach_player_objective WHERE NOT EXISTS (SELECT * FROM ach_monitor_character WHERE amc_character='apo_player')","NONE");
$DBc->sendSQL("DELETE FROM ach_player_perk WHERE NOT EXISTS (SELECT * FROM ach_monitor_character WHERE amc_character='app_player')","NONE");
$DBc->sendSQL("DELETE FROM ach_player_valuecache WHERE NOT EXISTS (SELECT * FROM ach_monitor_character WHERE amc_character='apv_player')","NONE");
$_DATASOURCE->addSource($tmp);
}
// fetch candidates
if($MODE == "SINGLE") {
/*if($MODE == "SINGLE") {
$chars = array();
$chars[] = array('amc_character',$CID);
}
@ -87,118 +77,74 @@
$DBc->sendSQL("UPDATE ach_monitor_character SET amc_working='".$RID."' WHERE amc_last_login>amc_last_import AND amc_working='0'","NONE");
$chars = $DBc->sendSQL("SELECT amc_character FROM ach_monitor_character WHERE amc_working='".$RID."'","ARRAY");
}
}*/
$tmp = explode("/",$_REQUEST['file']);
$tmp2 = explode("_",$tmp[(sizeof($tmp)-1)]);
//fork if enabled in conf
if($CONF['fork'] == true && $MODE == "CRON") {
require_once("class/ParallelCURL_class.php");
$chars = array(($tmp2[1]*16+$tmp2[2]));
foreach($chars as $cid) {
#STEP 1: load and register atoms
$max_requests = 0;
$curl_options = array(
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_SSL_VERIFYHOST => FALSE,
CURLOPT_USERAGENT, 'Ryzom - Achievement Tracker',
);
$_CURL = new ParallelCurl($max_requests, $curl_options);
foreach($chars as $elem) {
$_CURL->startRequest("http://".$CONF['self_host']."/".$CONF['self_path']."?invoke=TRUE&cid=".$elem['amc_character'], 'received_char',null);
}
}
else {
$atom_list = array();
foreach($chars as $elem) {
$_DATA->freeData($elem['amc_character']);
#STEP 1: evaluate atoms
//get unfinished perks which have no parent or complete parent
$res = $DBc->sendSQL("SELECT ap_id FROM ach_perk WHERE (ap_parent IS NULL OR EXISTS (SELECT * FROM ach_player_perk WHERE app_player='".$elem['amc_character']."' AND app_perk=ap_parent)) AND (NOT EXISTS (SELECT * FROM ach_player_perk WHERE app_player='".$elem['amc_character']."' AND app_perk=ap_id))","ARRAY");
foreach($res as $perk) {
//get unfinished atoms belonging to unfinished objectives
$res = $DBc->sendSQL("SELECT ach_atom.* FROM ach_atom,ach_objective WHERE ao_perk='".$perk['ap_id']."' AND ao_id=atom_objective AND NOT EXISTS (SELECT * FROM ach_player_objective WHERE apo_player='".$elem['amc_character']."' AND apo_objective=ao_id)","ARRAY");
foreach($res2 as $atom) {
if(!isset($atom_list[$atom['atom_id']])) { // only load if not already cached
$atom_list[$atom['atom_id']] = new Atom($atom);
}
$atom_list[$atom['atom_id']]->evalRuleset($elem['amc_character']);
}
}
$_DATA->freeData($elem['amc_character']);
$DBc->sendSQL("UPDATE ach_monitor_character SET amc_last_import='".time()."', amc_working='0' WHERE amc_character='".$elem['amc_character']."' AND amc_working='".$RID."'","NONE");
#STEP 2: detect obj/perk progression
//obj
$res = $DBc->sendSQL("SELECT ao_id FROM ach_objective WHERE ao_condition='all' 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='".$elem['amc_character']."'))","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']."','".$elem['amc_character']."','".time()."')","NONE");
}
$res = $DBc->sendSQL("SELECT ao_id FROM ach_objective WHERE ao_condition='value' AND ao_value<=(SELECT count(*) 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='".$elem['amc_character']."'))","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']."','".$elem['amc_character']."','".time()."')","NONE");
}
$res = $DBc->sendSQL("SELECT ao_id FROM ach_objective WHERE ao_condition='any' 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='".$elem['amc_character']."'))","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']."','".$elem['amc_character']."','".time()."')","NONE");
}
//perk
$res = $DBc->sendSQL("SELECT ap_id FROM ach_perk WHERE ap_condition='all' AND NOT EXISTS (SELECT * FROM ach_objective WHERE ao_perk=ap_id AND NOT EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_state!='GRANT' AND apo_player='".$elem['amc_character']."'))","ARRAY");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$DBc->sendSQL("INSERT INTO ach_player_perk (app_objective,app_player,app_date) VALUES ('".$res[$i]['ap_id']."','".$elem['amc_character']."','".time()."')","NONE");
}
$res = $DBc->sendSQL("SELECT ap_id FROM ach_perk WHERE ap_condition='value' AND ap_value<=(SELECT count(*) FROM ach_objective WHERE ao_perk=ap_id AND EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_state='GRANT' AND apo_player='".$elem['amc_character']."'))","ARRAY");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$DBc->sendSQL("INSERT INTO ach_player_perk (app_objective,app_player,app_date) VALUES ('".$res[$i]['ap_id']."','".$elem['amc_character']."','".time()."')","NONE");
}
$res = $DBc->sendSQL("SELECT ap_id FROM ach_perk WHERE ap_condition='any' AND EXISTS (SELECT * FROM ach_objective WHERE ao_perk=ap_id AND EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_state='GRANT' AND apo_player='".$elem['amc_character']."'))","ARRAY");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$DBc->sendSQL("INSERT INTO ach_player_perk (app_objective,app_player,app_date) VALUES ('".$res[$i]['ap_id']."','".$elem['amc_character']."','".time()."')","NONE");
$res = $DBc->sendSQL("SELECT ap_id FROM ach_perk WHERE NOT EXISTS (SELECT * FROM ach_player_perk WHERE app_player='".$cid."' AND app_perk=ap_id)","ARRAY");
foreach($res as $perk) {
//get unfinished atoms belonging to unfinished objectives
$res2 = $DBc->sendSQL("SELECT ach_atom.* FROM ach_atom,ach_objective WHERE ao_perk='".$perk['ap_id']."' AND ao_id=atom_objective AND NOT EXISTS (SELECT * FROM ach_player_objective WHERE apo_player='".$cid."' AND apo_objective=ao_id)","ARRAY");
foreach($res2 as $atom) {
$a = new Atom($atom,$cid);
$atom_list[] = $a;
$a->register();
}
}
}
#STEP 2: drive data
$_CACHE->setChar($cid);
$_DATASOURCE->drive($cid);
if($CONF['sleep_time'] != false) {
sleep($CONF['sleep_time']);
}
//self call if cron mode is on
if($MODE == "CRON" && $CONF['enable_selfcall'] == true) {
$DBc->sendSQL("UPDATE ach_monitor_state SET ams_end='".time()."' WHERE ams_id='".$RID."'","NONE");
$fp = fsockopen($CONF['self_host'], 80, $errno, $errstr, 30);
if(!$fp) {
logf("ERROR: self call; socket: ".$errstr." (."$errno.")");
#STEP 3: detect obj/perk progression
//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='".$cid."') AND NOT 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='".$cid."'))","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']."','".$cid."','".time()."')","NONE");
}
else {
$out = "GET ".$CONF['self_path']." HTTP/1.1\r\n";
$out .= "Host: ".$CONF['self_host']."\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
fclose($fp);
$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='".$cid."') AND ao_value<=(SELECT count(*) 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='".$cid."'))","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']."','".$cid."','".time()."')","NONE");
}
$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='".$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='".$cid."'))","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']."','".$cid."','".time()."')","NONE");
}
//perk
$res = $DBc->sendSQL("SELECT ap_id FROM ach_perk WHERE ap_condition='all' AND NOT EXISTS (SELECT * FROM ach_player_perk WHERE app_perk=ap_id AND app_player='".$cid."') AND NOT EXISTS (SELECT * FROM ach_objective WHERE ao_perk=ap_id AND NOT EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_player='".$cid."'))","ARRAY");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$DBc->sendSQL("INSERT INTO ach_player_perk (app_perk,app_player,app_date) VALUES ('".$res[$i]['ap_id']."','".$cid."','".time()."')","NONE");
}
$res = $DBc->sendSQL("SELECT ap_id FROM ach_perk WHERE ap_condition='value' AND NOT EXISTS (SELECT * FROM ach_player_perk WHERE app_perk=ap_id AND app_player='".$cid."') AND ap_value<=(SELECT count(*) FROM ach_objective WHERE ao_perk=ap_id AND EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_player='".$cid."'))","ARRAY");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$DBc->sendSQL("INSERT INTO ach_player_perk (app_perk,app_player,app_date) VALUES ('".$res[$i]['ap_id']."','".$cid."','".time()."')","NONE");
}
$res = $DBc->sendSQL("SELECT ap_id FROM ach_perk WHERE ap_condition='any' AND NOT EXISTS (SELECT * FROM ach_player_perk WHERE app_perk=ap_id AND app_player='".$cid."') AND EXISTS (SELECT * FROM ach_objective WHERE ao_perk=ap_id AND EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_player='".$cid."'))","ARRAY");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$DBc->sendSQL("INSERT INTO ach_player_perk (app_perk,app_player,app_date) VALUES ('".$res[$i]['ap_id']."','".$cid."','".time()."')","NONE");
}
}
if($logfile) {
$logfile->write();
}
exit(0);
?>

View file

@ -0,0 +1,207 @@
<?php
error_reporting(E_ALL ^ E_NOTICE);
ini_set("display_errors","1");
if(file_exists("parser.stop")) {
exit(0);
}
require_once("class/mySQL_class.php");
require_once("conf.php");
require_once("inlcude/functions_inc.php");
$logfile = false;
if($CONF['logging'] == true) {
require_once("class/Logfile_class.php");
#$logfile = fopen($CONF['logfile'].'.'.date("Ymd",time()).'.txt','a');
$logfile = new Logfile($CONF['logfile']);
}
//set mode: cron || single with given cid
#MISSING: conf to allow external calls; whitelist ips
$MODE = "CRON";
if($_REQUEST["cid"] > 0 || $_REQUEST["invoke"] == "TRUE") {
if($_REQUEST["cid"] > 0 && $_REQUEST["invoke"] == "TRUE") {
$MODE = "SINGLE";
$CID = $DBc->mre($_REQUEST["cid"]);
}
else {
$e = "Failed to start SINGLE mode; cid=".$_REQUEST["cid"];
logf($e);
die($e);
}
}
//create database connection
$DBc = new mySQL($CONF['mysql_error']);
$DBc->connect($CONF['mysql_server'],$CONF['mysql_user'],$CONF['mysql_pass'],$CONF['mysql_database']);
if($MODE == "CRON") {
$RID = $DBc->sendSQL("INSERT INTO ach_monitor_state (ams_start,ams_end) VALUES ('".time()."','0')","INSERT"); // insert run into monitoring table
}
require_once("class/DataSourceHandler_class.php");
require_once("class/DataSource_abstract.php");
require_once("class/Atom_class.php");
//create datasource handler
$_DATA = new DataSourceHandler();
foreach($CONF['data_source'] as $elem) { //populate
require_once("source/".$elem."/".$elem."_class.php");
eval('$tmp = new '.$elem.'();');
$_DATA->registerDataSource($tmp);
}
//synch chars from ring_open character table
if($CONF['synch_chars'] == true) {
$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']);
$DBc->sendSQL("UPDATE ach_monitor_character SET amc_confirmed='0'","NONE");
$res = $DBc_char->sendSQL("SELECT char_id,last_played_date FROM characters","ARRAY");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$DBc->sendSQL("INSERT INTO ach_monitor_character (amc_character,amc_last_import,amc_last_login,amc_confirmed) VALUES ('".$res[$i]['char_id']."','0','".dateTime_to_timestamp($res[$i]['last_played_date'])."','1') ON DUPLICATE KEY UPDATE amc_confirmed='1', amc_last_login='".dateTime_to_timestamp($res[$i]['last_played_date'])."'","NONE");
}
$DBc->sendSQL("DELETE FROM ach_monitor_character WHERE amc_confirmed='0'","NONE"); //remove deleted characters
//remove data for deleted chars
$DBc->sendSQL("DELETE FROM ach_player_atom WHERE NOT EXISTS (SELECT * FROM ach_monitor_character WHERE amc_character='apa_player')","NONE");
$DBc->sendSQL("DELETE FROM ach_player_objective WHERE NOT EXISTS (SELECT * FROM ach_monitor_character WHERE amc_character='apo_player')","NONE");
$DBc->sendSQL("DELETE FROM ach_player_perk WHERE NOT EXISTS (SELECT * FROM ach_monitor_character WHERE amc_character='app_player')","NONE");
$DBc->sendSQL("DELETE FROM ach_player_valuecache WHERE NOT EXISTS (SELECT * FROM ach_monitor_character WHERE amc_character='apv_player')","NONE");
}
// fetch candidates
if($MODE == "SINGLE") {
$chars = array();
$chars[] = array('amc_character',$CID);
}
else {
#$chars = array();
$DBc->sendSQL("UPDATE ach_monitor_character SET amc_working='0' WHERE amc_last_import<'".(time()-60*60)."'"); // unlock if something went wrong
$DBc->sendSQL("UPDATE ach_monitor_character SET amc_working='".$RID."' WHERE amc_last_login>amc_last_import AND amc_working='0'","NONE");
$chars = $DBc->sendSQL("SELECT amc_character FROM ach_monitor_character WHERE amc_working='".$RID."'","ARRAY");
}
//fork if enabled in conf
if($CONF['fork'] == true && $MODE == "CRON") {
require_once("class/ParallelCURL_class.php");
$max_requests = 0;
$curl_options = array(
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_SSL_VERIFYHOST => FALSE,
CURLOPT_USERAGENT, 'Ryzom - Achievement Tracker',
);
$_CURL = new ParallelCurl($max_requests, $curl_options);
foreach($chars as $elem) {
$_CURL->startRequest("http://".$CONF['self_host']."/".$CONF['self_path']."?invoke=TRUE&cid=".$elem['amc_character'], 'received_char',null);
}
}
else {
$atom_list = array();
foreach($chars as $elem) {
$_DATA->freeData($elem['amc_character']);
#STEP 1: evaluate atoms
//get unfinished perks which have no parent or complete parent
#$res = $DBc->sendSQL("SELECT ap_id FROM ach_perk WHERE (ap_parent IS NULL OR EXISTS (SELECT * FROM ach_player_perk WHERE app_player='".$elem['amc_character']."' AND app_perk=ap_parent)) AND (NOT EXISTS (SELECT * FROM ach_player_perk WHERE app_player='".$elem['amc_character']."' AND app_perk=ap_id))","ARRAY");
//get all unfinished perks since perks my not directly inherit objectives...
$res = $DBc->sendSQL("SELECT ap_id FROM ach_perk WHERE NOT EXISTS (SELECT * FROM ach_player_perk WHERE app_player='".$elem['amc_character']."' AND app_perk=ap_id)","ARRAY");
foreach($res as $perk) {
//get unfinished atoms belonging to unfinished objectives
$res = $DBc->sendSQL("SELECT ach_atom.* FROM ach_atom,ach_objective WHERE ao_perk='".$perk['ap_id']."' AND ao_id=atom_objective AND NOT EXISTS (SELECT * FROM ach_player_objective WHERE apo_player='".$elem['amc_character']."' AND apo_objective=ao_id)","ARRAY");
foreach($res2 as $atom) {
if(!isset($atom_list[$atom['atom_id']])) { // only load if not already cached
$atom_list[$atom['atom_id']] = new Atom($atom);
}
$atom_list[$atom['atom_id']]->evalRuleset($elem['amc_character']);
}
}
$_DATA->freeData($elem['amc_character']);
$DBc->sendSQL("UPDATE ach_monitor_character SET amc_last_import='".time()."', amc_working='0' WHERE amc_character='".$elem['amc_character']."' AND amc_working='".$RID."'","NONE");
#STEP 2: detect obj/perk progression
//obj
$res = $DBc->sendSQL("SELECT ao_id FROM ach_objective WHERE ao_condition='all' 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='".$elem['amc_character']."'))","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']."','".$elem['amc_character']."','".time()."')","NONE");
}
$res = $DBc->sendSQL("SELECT ao_id FROM ach_objective WHERE ao_condition='value' AND ao_value<=(SELECT count(*) 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='".$elem['amc_character']."'))","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']."','".$elem['amc_character']."','".time()."')","NONE");
}
$res = $DBc->sendSQL("SELECT ao_id FROM ach_objective WHERE ao_condition='any' 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='".$elem['amc_character']."'))","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']."','".$elem['amc_character']."','".time()."')","NONE");
}
//perk
$res = $DBc->sendSQL("SELECT ap_id FROM ach_perk WHERE ap_condition='all' AND NOT EXISTS (SELECT * FROM ach_objective WHERE ao_perk=ap_id AND NOT EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_state!='GRANT' AND apo_player='".$elem['amc_character']."'))","ARRAY");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$DBc->sendSQL("INSERT INTO ach_player_perk (app_objective,app_player,app_date) VALUES ('".$res[$i]['ap_id']."','".$elem['amc_character']."','".time()."')","NONE");
}
$res = $DBc->sendSQL("SELECT ap_id FROM ach_perk WHERE ap_condition='value' AND ap_value<=(SELECT count(*) FROM ach_objective WHERE ao_perk=ap_id AND EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_state='GRANT' AND apo_player='".$elem['amc_character']."'))","ARRAY");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$DBc->sendSQL("INSERT INTO ach_player_perk (app_objective,app_player,app_date) VALUES ('".$res[$i]['ap_id']."','".$elem['amc_character']."','".time()."')","NONE");
}
$res = $DBc->sendSQL("SELECT ap_id FROM ach_perk WHERE ap_condition='any' AND EXISTS (SELECT * FROM ach_objective WHERE ao_perk=ap_id AND EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_state='GRANT' AND apo_player='".$elem['amc_character']."'))","ARRAY");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$DBc->sendSQL("INSERT INTO ach_player_perk (app_objective,app_player,app_date) VALUES ('".$res[$i]['ap_id']."','".$elem['amc_character']."','".time()."')","NONE");
}
}
}
if($CONF['sleep_time'] != false) {
sleep($CONF['sleep_time']);
}
//self call if cron mode is on
if($MODE == "CRON" && $CONF['enable_selfcall'] == true) {
$DBc->sendSQL("UPDATE ach_monitor_state SET ams_end='".time()."' WHERE ams_id='".$RID."'","NONE");
$fp = fsockopen($CONF['self_host'], 80, $errno, $errstr, 30);
if(!$fp) {
logf("ERROR: self call; socket: ".$errstr." (."$errno.")");
}
else {
$out = "GET ".$CONF['self_path']." HTTP/1.1\r\n";
$out .= "Host: ".$CONF['self_host']."\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
fclose($fp);
}
}
if($logfile) {
$logfile->write();
}
exit(0);
?>

View file

@ -3,66 +3,86 @@
private $ruleset;
private $id;
private $objective;
private $user;
function Atom(&$data) {
function Atom(&$data,$user) {
$this->ruleset = $data['atom_ruleset_parsed'];
$this->id = $data['atom_id'];
$this->objective = $data['atom_objective'];
$this->user = $user;
}
function evalRuleset($user) {
function register() {
global $DBc,$_DATA;
echo "register<br>";
try {
return eval($this->ruleset);
}
catch(Exception $e) {
return $e->getMessage()
echo $e->getMessage();
}
}
private function grant($user,$condition) {
global $DBc;
$DBc->sendSQL("INSERT INTO ach_player_atom (apa_atom,apa_player,apa_date,apa_expire,apa_state) VALUES ('".$this->id."','".$user."','".date()."','".$DBc->mre($condition)."','GRANT')","NONE");
function registerValue($name,$func) {
global $_DISPATCHER;
$tmp = new Callback($this,$func);
$_DISPATCHER->registerValue($name,$tmp);
}
private function deny($user,$condition) {
global $DBc;
function unregisterValue($name,$callback) {
global $_DISPATCHER;
$DBc->sendSQL("INSERT INTO ach_player_atom (apa_atom,apa_player,apa_date,apa_expire,apa_state) VALUES ('".$this->id."','".$user."','".date()."','".$DBc->mre($condition)."','DENY')","NONE");
$_DISPATCHER->unregisterValue($name,$callback);
}
private function reset_($user) {
function grant() {
global $DBc;
$DBc->sendSQL("DELETE FROM ach_player_atom WHERE apa_atom='".$this->id."' AND apa_player='".$user."'","NONE");
echo "G<br>";
$DBc->sendSQL("INSERT INTO ach_player_atom (apa_atom,apa_player,apa_date,apa_expire,apa_state) VALUES ('".$this->id."','".$this->user."','".time()."',null,'GRANT')","NONE");
}
private function reset_all($user) {
function deny() {
global $DBc;
$DBc->sendSQL("INSERT INTO ach_player_atom (apa_atom,apa_player,apa_date,apa_expire,apa_state) VALUES ('".$this->id."','".$this->user."','".time()."',null,'DENY')","NONE");
}
function reset_() {
global $DBc;
$DBc->sendSQL("DELETE FROM ach_player_atom WHERE apa_atom='".$this->id."' AND apa_player='".$this->user."'","NONE");
}
function reset_all() {
global $DBc;
$res = $DBc->sendSQL("SELECT atom_id FROM ach_atom WHERE atom_objective='".$this->objective."'","ARRAY");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$DBc->sendSQL("DELETE FROM ach_player_atom WHERE apa_atom='".$res[$i]['atom_id']."' AND apa_player='".$user."'","NONE");
$DBc->sendSQL("DELETE FROM ach_player_atom WHERE apa_atom='".$res[$i]['atom_id']."' AND apa_player='".$this->user."'","NONE");
}
}
private function unlock($user) {
function unlock() {
global $DBc;
$DBc->sendSQL("DELETE FROM ach_player_atom WHERE apa_atom='".$this->id."' AND apa_player='".$user."' AND apa_state='DENY'","NONE");
$DBc->sendSQL("DELETE FROM ach_player_atom WHERE apa_atom='".$this->id."' AND apa_player='".$this->user."' AND apa_state='DENY'","NONE");
}
private function unlock_all($user) {
function unlock_all() {
global $DBc;
$res = $DBc->sendSQL("SELECT atom_id FROM ach_atom WHERE atom_objective='".$this->objective."'","ARRAY");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$DBc->sendSQL("DELETE FROM ach_player_atom WHERE apa_atom='".$res[$i]['atom_id']."' AND apa_player='".$user."' AND apa_state='DENY'","NONE");
$DBc->sendSQL("DELETE FROM ach_player_atom WHERE apa_atom='".$res[$i]['atom_id']."' AND apa_player='".$this->user."' AND apa_state='DENY'","NONE");
}
}

View file

@ -0,0 +1,15 @@
<?php
class Callback {
private $who;
private $func;
function Callback($who,$func) {
$this->who = $who;
$this->func = $func;
}
function call($what) {
eval(''.$this->func.'($what,$this->who,$this);');
}
}
?>

View file

@ -0,0 +1,80 @@
<?php
class DataDispatcher {
private $value;
private $entity;
private $event;
function DataDispatcher() {
$this->value = array();
$this->entity = array();
$this->event = array();
}
function registerValue($name,$callback) {
if(!is_array($this->value[$name])) {
$this->value[$name] = array();
}
$this->value[$name][] = $callback;
}
function registerEntity($name,$callback) {
if(!is_array($this->entity[$name])) {
$this->entity[$name] = array();
}
$this->entity[$name][] = $callback;
}
function registerEvent($name,$callback) {
if(!is_array($this->event[$name])) {
$this->event[$name] = array();
}
$this->event[$name][] = $callback;
}
function unregisterValue($name,$callback) {
$res = array_search($callback,$this->value[$name],true);
if($res !== false) {
unset($this->value[$name][$res]);
}
}
function unregisterEntity($name,$callback) {
$res = array_search($callback,$this->entity[$name],true);
if($res !== false) {
unset($this->entity[$name][$res]);
}
}
function unregisterEvent($name,$callback) {
$res = array_search($callback,$this->event[$name],true);
if($res !== false) {
unset($this->event[$name][$res]);
}
}
function dispatchValue($key,$val) {
echo "dispatching: $key=>$val<br>";
if(is_array($this->value[$key])) {
foreach($this->value[$key] as $callback) {
$callback->call($val);
}
}
}
function dispatchEntity($key,$val) {
if(is_array($this->entity[$key])) {
foreach($this->entity[$key] as $callback) {
$callback->call($val);
}
}
}
function dispatchEvent($key,$val) {
if(is_array($this->event[$key])) {
foreach($this->event[$key] as $callback) {
$callback->call($val);
}
}
}
}
?>

View file

@ -1,71 +1,20 @@
<?php
class DataSourceHandler {
private $source;
private $alloc;
function DataSourceHandler() {
$this->source = array();
$this->alloc = array();
}
function registerDataSource($src) {
$i = sizeof($this->source);
$this->source[$i] = $src;
foreach($src->getTypes() as $elem) {
//add to list
$this->alloc[$elem] = $i;
function addSource($src) {
$this->source[] = $src;
}
function drive($cid) {
foreach($this->source as $elem) {
$elem->drive($cid);
}
}
function freeData($ident) {
foreach($source as $elem) {
$elem->freeData($ident);
}
}
function getData($ident,$query) { // SELECT ? FROM c_items WHERE q>='300'
$matches = array();
preg_match("#SELECT (\?|\*) FROM ([^ ]+) WHERE ([.]*)#", $query, $matches);
$mode = $matches[1];
$type = $matches[2];
$cond = $matches[3];
$tmp = $this->getDataSource($type);
if($tmp == false) { // no datasource available for this ident
return false;
}
return $tmp->getData($ident,$type,$mode,$cond);
}
function writeData($ident,$query) { // INSERT INTO c_cache () VALUES ()
$matches = array();
preg_match("#INSERT INTO ([^ ]+) \(([^\)]*)\) VALUES \(([^\)]*)\)#", $query, $matches);
$type = $matches[1];
$keys = $matches[2];
$data = $matches[3];
$tmp = $this->getDataSource($type);
if($tmp == false) { // no datasource available for this ident
return false;
}
if(!$tmp->isWriteable()) { // can't write here
return false;
}
return $tmp->writeData($ident,$type,$keys,$data);
}
private function getDataSource(&$ident) {
if(!$this->alloc[$ident]) {
return false; //unknown type
}
return $this->source[$this->alloc[$ident]];
}
}
?>

View file

@ -0,0 +1,5 @@
<?php
abstract class SourceDriver {
abstract function drive($cid);
}
?>

View file

@ -0,0 +1,27 @@
<?php
class ValueCache {
private $char;
function ValueCache() {
$this->char = false;
}
function setChar($c) {
$this->char = $c;
}
function writeData($key,$val) {
global $DBc;
$DBc->sendSQL("INSERT INTO ach_player_valuecache (apv_name,apv_player,apv_value,apv_date) VALUES ('".$this->user."','".$DBc->mre($key)."','".$DBc->mre($val)."','".time()."') ON DUPLICATE KEY UPDATE apv_value='".$DBc->mre($val)."', apv_date='".time()."'","NONE");
}
function getData($key) {
global $DBc;
$res = $DBc->sendSQL("SELECT apv_value as value, apv_date as date FROM ach_player_valuecache WHERE apv_name='".$DBc->mre($key)."' AND apv_player='".$this->char."'","ARRAY");
return $res[0];
}
}
?>

View file

@ -4,19 +4,19 @@
$CONF['logging'] = true;
$CONF['logfile'] = "log/AchWebParser.log";
$CONF['mysql_error'] = "";
$CONF['mysql_error'] = "PRINT";
$CONF['mysql_server'] = "localhost";
$CONF['mysql_user'] = "root";
$CONF['mysql_pass'] = "";
$CONF['mysql_database'] = "app_achievements";
$CONF['data_source'] = array();
$CONF['data_source'] = array("PDRtoXMLdriver");
$CONF['synch_chars'] = true
/*$CONF['synch_chars'] = true;
$CONF['char_mysql_server'] = "localhost";
$CONF['char_mysql_user'] = "root";
$CONF['char_mysql_pass'] = "";
$CONF['char_mysql_database'] = "ring_open";
$CONF['char_mysql_database'] = "ring_open";*/
$CONF['fork'] = true;
@ -25,7 +25,7 @@
$CONF['sleep_time'] = 1500;
$CONF['enable_selfcall'] = true
$CONF['enable_selfcall'] = true;
$CONF['timeout'] = 60*60;
?>

View file

@ -0,0 +1,99 @@
<?php
class PDRtoXMLdriver extends SourceDriver {
private $conf;
private $ignore;
private $ignore_block;
private $lock;
function PDRtoXMLdriver() {
require_once("conf.php");
$this->conf = $_CONF;
$this->lock = 0;
$this->ignore = array();
$this->ignore[] = "XML";
$this->ignore[] = "ENTITYBASE";
$this->ignore[] = "NORMALPOSITIONS";
$this->ignore[] = "_VEC";
$this->ignore[] = "SESSIONID";
$this->ignore[] = "POSSTATE";
$this->ignore[] = "_PLAYERROOM";
$this->ignore[] = "_INVENTORYID";
$this->ignore[] = "_PHYSCHARACS";
$this->ignore[] = "_PHYSSCORES";
$this->ignore[] = "_SKILLS";
$this->ignore[] = "_FAMES";
$this->ignore_block = array();
$this->ignore_block[] = "_MEMORIZEDPHRASES";
$this->ignore_block[] = "_FORBIDPOWERDATES";
$this->ignore_block[] = "_INEFFECTIVEAURAS";
$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";
$this->ignore_block[] = "STARTINGCHARACTERISTICVALUES";
$this->ignore_block[] = "_ENCYCLOCHAR";
$this->ignore_block[] = "_GAMEEVENT";
$this->ignore_block[] = "_ENTITYPOSITION";
}
function drive($cid) {
global $CONF;
echo "kk";
#$uid = floor($cid/16);
#$slot = ($cid%16);
#$file = $this->conf['xml_dir']."account_".$uid."_".$slot."_pdr.xml";
$file = $_REQUEST['file'];
$xml_parser = xml_parser_create();
xml_set_object($xml_parser,$this);
xml_set_element_handler($xml_parser, "startElement", "endElement");
if(!xml_parse($xml_parser, file_get_contents($file))) {
#error
echo "error";
}
xml_parser_free($xml_parser);
}
function startElement($parser, $name, $attrs) {
global $_DISPATCHER;
if($this->lock == 1) {
return null;
}
if(in_array($name,$this->ignore)) {
return null;
}
if(in_array($name,$this->ignore_block)) {
$this->lock = 1;
return null;
}
if($attrs["VALUE"] != "") {
echo "dispatching";
$_DISPATCHER->dispatchValue(strtolower($name),$attrs["VALUE"]);
}
}
function endElement($parser, $name) {
if(in_array($name,$this->ignore_block)) {
$this->lock = 0;
}
}
}
?>

View file

@ -0,0 +1,6 @@
<?php
$_CONF = array();
$_CONF['xml_dir'] = ".";
?>

View file

@ -1,6 +1,29 @@
<?php
class AchAchievement extends AchList {
use InDev;
protected $dev;
function inDev() {
return ($this->dev == 1);
}
function getDev() {
return $this->dev;
}
function setInDev($tf) {
if($tf == true) {
$this->setDev(1);
}
else {
$this->setDev(0);
}
$this->update();
}
function setDev($d) {
$this->dev = $d;
}
protected $parent_id;
protected $category;

View file

@ -15,9 +15,9 @@
parent::__construct();
$civ = mysql_real_escape_string($civ);
$cult = mysql_real_escape_string($cult);
$race = mysql_real_escape_string($race);
$civ = $DBc->sqlEscape($civ);
$cult = $DBc->sqlEscape($cult);
$race = $DBc->sqlEscape($race);
if($race == null) {
$race = $_USER->getRace();
@ -34,7 +34,7 @@
$this->cult = $cult;
$this->civ = $civ;
$this->id = mysql_real_escape_string($id);
$this->id = $DBc->sqlEscape($id);
$res = $DBc->sqlQuery("SELECT * FROM ach_achievement LEFT JOIN (ach_achievement_lang) ON (aal_lang='".$_USER->getLang()."' AND aal_achievement=aa_id) WHERE aa_category='".$this->id."' AND (aa_parent IS NULL OR NOT EXISTS (SELECT * FROM ach_perk WHERE ap_achievement=aa_id AND NOT EXISTS (SELECT * FROM ach_player_perk WHERE app_player='".$_USER->getID()."' AND app_perk=ap_id))) AND (aa_tie_race IS NULL OR aa_tie_race LIKE '".$race."') AND (aa_tie_cult IS NULL OR aa_tie_cult LIKE '".$cult."') AND (aa_tie_civ IS NULL OR aa_tie_civ LIKE '".$civ."') ORDER by aal_name ASC");

View file

@ -34,14 +34,14 @@
return ($this->child_done->getSize() != 0);
}
final function addOpen($data) {
$this->child_open->addNode($data);
$this->addChild($data); #Parentum::addChild()
final function addOpen($data,$b = null) {
$this->child_open->addNode($data,$b);
$this->addChild($data,$b); #Parentum::addChild()
}
final function addDone($data) {
$this->child_done->addNode($data);
$this->addChild($data); #Parentum::addChild()
final function addDone($data,$b = null) {
$this->child_done->addNode($data,$b);
$this->addChild($data,$b); #Parentum::addChild()
}
final function setChildDone($id) {

View file

@ -1,6 +1,29 @@
<?php
class AchMenuNode extends Parentum {
use InDev;
protected $dev;
function inDev() {
return ($this->dev == 1);
}
function getDev() {
return $this->dev;
}
function setInDev($tf) {
if($tf == true) {
$this->setDev(1);
}
else {
$this->setDev(0);
}
$this->update();
}
function setDev($d) {
$this->dev = $d;
}
protected $parent_id;
protected $name;

View file

@ -1,6 +1,29 @@
<?php
class AchPerk extends Parentum {
use InDev;
protected $dev;
function inDev() {
return ($this->dev == 1);
}
function getDev() {
return $this->dev;
}
function setInDev($tf) {
if($tf == true) {
$this->setDev(1);
}
else {
$this->setDev(0);
}
$this->update();
}
function setDev($d) {
$this->dev = $d;
}
protected $achievement;
protected $value;
@ -94,12 +117,5 @@
function getParentID() {
return $this->parent_id;
}
function setParentID($p) {
if($this->parent_id != null) {
}
$this->parent_id = $p;
}
}
?>

View file

@ -61,6 +61,10 @@
$tmp->setChild($n);
}
}
else {
$this->addNode($data);
return null;
}
}
if($this->first == null) {

View file

@ -22,8 +22,8 @@
return $this->nodes->isEmpty();
}
function addChild($data) {
$this->nodes->addNode($data);
function addChild($data,$b = null) {
$this->nodes->addNode($data,$b);
}
function removeChild($id) {

View file

@ -7,7 +7,7 @@
}
function getID() {
return $this->data["id"];
return $this->data["cid"];
}
function getLang() {

View file

@ -266,7 +266,7 @@
}
if($perk->getName() != null) {
$html .= "<tr><td><font color='#999999' size='12px'><b>".$perk->getName()."</b></font></td></tr><tr><td>&nbsp;</td></tr>";
$html .= "<tr><td><font color='#999999' size='12px'><b>".$perk->getDisplayName()."</b></font></td></tr><tr><td>&nbsp;</td></tr>";
}
if($perk->objDrawable()) {
$html .= "<tr><td>".ach_render_obj_list($perk->getIterator())."</td></tr>";
@ -288,7 +288,7 @@
if($perk->inDev()) {
continue;
}
$html .= "<tr><td><font color='#66CC00'><b>".$perk->getName()."</b></font> ( ".date('d.m.Y',$perk->getDone())." ) <img src='".$_CONF['image_url']."pic/yubo_done_small.png' /> ".$perk->getValue()."</td></tr>";
$html .= "<tr><td><font color='#66CC00'><b>".$perk->getDisplayName()."</b></font> ( ".date('d.m.Y',$perk->getDone())." ) <img src='".$_CONF['image_url']."pic/yubo_done_small.png' /> ".$perk->getValue()."</td></tr>";
}
return $html;
@ -359,7 +359,7 @@
$html .= "<img src='".$_CONF['image_url']."pic/pending.png' height='10px' />&nbsp;<font color='#999999;'>";
}
$html .= $obj->getName()."</font>";
$html .= $obj->getDisplayName()."</font>";
return $html;
}
@ -379,7 +379,7 @@
return "<table cellspacing='0' cellpadding='0'>
<tr>
<td><img src='".$_CONF['image_url']."pic/icon/".$grey."small/".$obj->getMetaImage()."' /></td>
<td><font color='".$col."'>&nbsp;".$obj->getName()."</font></td>
<td><font color='".$col."'>&nbsp;".$obj->getDisplayName()."</font></td>
</tr>
</table>";
}
@ -393,7 +393,7 @@
else {
$col = "#999999";
}
$html .= "<font color='".$col."'>".$obj->getName()."</font>";
$html .= "<font color='".$col."'>".$obj->getDisplayName()."</font>";
}
$html .= ach_render_progressbar($obj->getProgress(),$obj->getValue(),250);

View file

@ -24,7 +24,7 @@
$open = $menu->getOpenCat();
if($open != 0) {
$cat = new AchCategory($open,'matis',$_REQUEST['cult'],$_REQUEST['civ']);
$cat = new AchCategory($open,null,$_REQUEST['cult'],$_REQUEST['civ']);
}
else {
$cat = new AchSummary($menu,8);
@ -305,7 +305,7 @@
}
if($perk->getName() != null) {
$html .= "<span style='color:#999999;font-weight:bold;display:block;'>".$perk->getName()."</span>";
$html .= "<span style='color:#999999;font-weight:bold;display:block;'>".$perk->getDisplayName()."</span>";
}
if($perk->objDrawable()) {
$html .= ach_render_obj_list($perk->getIterator());
@ -326,7 +326,7 @@
if($perk->inDev()) {
continue;
}
$html .= "<div style='display:block;'><span style='color:#66CC00;font-weight:bold;'>".$perk->getName()."</span> ( ".date('d.m.Y',$perk->getDone())." ) <img src='".$_CONF['image_url']."pic/yubo_done.png' width='15px' /> ".$perk->getValue()."</div>";
$html .= "<div style='display:block;'><span style='color:#66CC00;font-weight:bold;'>".$perk->getDisplayName()."</span> ( ".date('d.m.Y',$perk->getDone())." ) <img src='".$_CONF['image_url']."pic/yubo_done.png' width='15px' /> ".$perk->getValue()."</div>";
}
return $html;
@ -396,7 +396,7 @@
$html .= "<img src='".$_CONF['image_url']."pic/pending.png' height='10px' />&nbsp;<span style='color:#999999;'>";
}
$html .= $obj->getName()."</span>";
$html .= $obj->getDisplayName()."</span>";
return $html;
}
@ -416,7 +416,7 @@
return "<table cellspacing='0' cellpadding='0'>
<tr>
<td><img src='".$_CONF['image_url']."pic/icon/".$grey.$obj->getMetaImage()."' width='20px' /></td>
<td valign='middle'><span style='color:".$col.";'>&nbsp;".$obj->getName()."</span></td>
<td valign='middle'><span style='color:".$col.";'>&nbsp;".$obj->getDisplayName()."</span></td>
</tr>
</table>";
}
@ -430,7 +430,7 @@
else {
$col = "#999999";
}
$html .= "<div style='color:".$col.";display:block;'>".$obj->getName()."</div>";
$html .= "<div style='color:".$col.";display:block;'>".$obj->getDisplayName()."</div>";
}
$html .= ach_render_progressbar($obj->getProgress(),$obj->getValue(),350);

View file

@ -13,8 +13,11 @@ require_once('conf.php');
// Ask to authenticate user (using ingame or session method) and fill $user with all information
ryzom_app_authenticate($user, false);
#$user['id'] = $user['char_id'];
#$user['name'] = $user['char_name'];
$user = array();
$user['id'] = 1;
$user['id'] = 16;
$user['lang'] = 'en';
$user['name'] = 'Talvela';
$user['race'] = "r_matis";
@ -35,7 +38,7 @@ else {
require_once("include/ach_render_common.php");
require_once("class/DLL_class.php");
require_once("class/InDev_trait.php");
#require_once("class/InDev_trait.php");
require_once("class/Node_abstract.php");
require_once("class/AVLTree_class.php");
require_once("class/Parentum_abstract.php");
@ -55,6 +58,7 @@ require_once("class/AchObjective_class.php");
// Update user acces on Db
#$DBc = ryDB::getInstance(APP_NAME."_test");
$DBc = ryDB::getInstance(APP_NAME);
#$DBc = ryDB::getInstance("ahufler");

View file

@ -80,5 +80,15 @@
function setTemplate($t) {
$this->template = $t;
}
function orderPerks() {
$iter = $this->getIterator();
$i = 0;
while($iter->hasNext()) {
$curr = $iter->getNext();
$curr->setPorder($i);
}
}
}
?>

View file

@ -59,11 +59,72 @@
}
private function parse() {
/*VALUE _money AS $money {
CACHE blach AS $test
}
if($money >= 10000 && $test == 0) {
GRANT
FINAL
}
else {
CACHE blach SET $money
}
}
function setInDev($tf) {
$res = $this->ruleset;
#VALUE ([^ ]+) AS ([^ ]+) {#
$match = array();
preg_match_all("#VALUE ([^ ]+) AS ([^ ]+) {#",$this->ruleset,$match);
foreach($match[0] as $key=>$elem) {
$func = "_".md5(microtime());
$tmp = '$this->registerValue("'.$match[1][$key].'","'.$func.'");
function '.$func.'('.$match[2][$key].',$_P,$_CB) {
$_IDENT = "'.$match[1][$key].'";';
//replace
$res = str_replace($elem,$tmp,$res);
}
#ENTITY ([^ ]+) AS ([^ ]+) {#
$match = array();
preg_match_all("#ENTITY ([^ ]+) AS ([^ ]+) {#",$this->ruleset,$match);
foreach($match[0] as $key=>$elem) {
$func = "_".md5(microtime());
$tmp = '$this->registerEntity("'.$match[1][$key].'","'.$func.'");
function '.$func.'('.$match[2][$key].',$_P,$_CB) {
$_IDENT = "'.$match[1][$key].'";';
//replace
$res = str_replace($elem,$tmp,$res);
}
#EVENT ([^ ]+) AS ([^ ]+) {#
$match = array();
preg_match_all("#EVENT ([^ ]+) AS ([^ ]+) {#",$this->ruleset,$match);
foreach($match[0] as $key=>$elem) {
$func = "_".md5(microtime());
$tmp = '$this->registerEvent("'.$match[1][$key].'","'.$func.'");
function '.$func.'('.$match[2][$key].',$_P,$_CB) {
$_IDENT = "'.$match[1][$key].'";';
//replace
$res = str_replace($elem,$tmp,$res);
}
#CACHE ([^ ]+) AS ([^ ]+)#
#GRANT#
#FINAL#
#CACHE ([^ ]+) SET ([^ ]+)#*/
}
}
?>

View file

@ -35,7 +35,7 @@
function update() {
global $DBc;
$DBc->sqlQuery("UPDATE ach_objective SET ao_condition='".mysql_real_escape_string($this->getCondition())."',ao_value=".mre($this->getValue()).",ao_display='".mysql_real_escape_string($this->getDisplay())."',ao_metalink=".mkn($this->getMetalink())." WHERE ao_id='".$this->getID()."'");
$DBc->sqlQuery("UPDATE ach_objective SET ao_condition='".mysql_real_escape_string($this->getCondition())."',ao_value=".mkn($this->getValue()).",ao_display='".mysql_real_escape_string($this->getDisplay())."',ao_metalink=".mkn($this->getMetaImage())." WHERE ao_id='".$this->getID()."'");
$DBc->sqlQuery("INSERT INTO ach_objective_lang (aol_objective,aol_lang,aol_name) VALUES ('".$this->getID()."','en','".mysql_real_escape_string($this->getName())."') ON DUPLICATE KEY UPDATE aol_name='".mysql_real_escape_string($this->getName())."'");
}
@ -43,15 +43,35 @@
function insert() {
global $DBc;
$DBc->sqlQuery("INSERT INTO ach_objective (ao_perk,ao_condition,ao_value,ao_display,ao_metalink) VALUES ('".$this->getPerk()."','".mysql_real_escape_string($this->getCondition())."',".mre($this->getValue()).",'".mysql_real_escape_string($this->getDisplay())."',".mkn($this->getMetalink()).")");
$DBc->sqlQuery("INSERT INTO ach_objective (ao_perk,ao_condition,ao_value,ao_display,ao_metalink) VALUES ('".$this->getPerk()."','".mysql_real_escape_string($this->getCondition())."',".mkn($this->getValue()).",'".mysql_real_escape_string($this->getDisplay())."',".mkn($this->getMetaImage()).")");
$id = mysql_insert_id();
$this->setID($id);
$DBc->sqlQuery("INSERT INTO ach_objective_lang (aol_objective,aol_lang,aopl_name) VALUES ('".$this->getID()."','en','".mysql_real_escape_string($this->getName())."')");
$DBc->sqlQuery("INSERT INTO ach_objective_lang (aol_objective,aol_lang,aol_name) VALUES ('".$this->getID()."','en','".mysql_real_escape_string($this->getName())."')");
}
function setCondition($c) {
$this->condition = $c;
}
function setDisplay($d) {
$this->display = $d;
}
function setName($n) {
$this->name = $n;
}
function setValue($v) {
$this->value = $v;
}
function setMetalink($m) {
$this->meta_image = $m;
}
function setPerk($p) {
$this->perk = $p;
}
}
?>

View file

@ -4,12 +4,14 @@
protected $condition;
protected $condition_value;
protected $porder;
function AdmPerk($data,$parent) {
parent::__construct($data,$parent);
$this->condition = $data["ap_condition"];
$this->condition_value = $data["ap_condition_value"];
$this->porder = $data["ap_porder"];
}
protected function makeChild($d) {
@ -33,7 +35,7 @@
function update() {
global $DBc;
$DBc->sqlQuery("UPDATE ach_perk SET ap_parent=NULL,ap_value='".mysql_real_escape_string($this->getValue())."',ap_condition='".mysql_real_escape_string($this->getCondition())."',ap_condition_value=".mkn($this->getConditionValue()).",ap_dev='".$this->getDev()."' WHERE ap_id='".$this->getID()."'");
$DBc->sqlQuery("UPDATE ach_perk SET ap_parent=".mkn($this->getParentID()).",ap_value='".mysql_real_escape_string($this->getValue())."',ap_condition='".mysql_real_escape_string($this->getCondition())."',ap_condition_value=".mkn($this->getConditionValue()).",ap_dev='".$this->getDev()."',ap_porder='".$this->porder."' WHERE ap_id='".$this->getID()."'");
$DBc->sqlQuery("INSERT INTO ach_perk_lang (apl_perk,apl_lang,apl_name,apl_template) VALUES ('".$this->getID()."','en','".mysql_real_escape_string($this->getName())."',".mkn($this->getTemplate()).") ON DUPLICATE KEY UPDATE apl_name='".mysql_real_escape_string($this->getName())."',apl_template=".mkn($this->getTemplate())."");
}
@ -43,7 +45,7 @@
$this->dev = 1;
$DBc->sqlQuery("INSERT INTO ach_perk (ap_achievement,ap_parent,ap_value,ap_condition,ap_condition_value,ap_dev) VALUES ('".$this->getAchievement()."',NULL,'".mysql_real_escape_string($this->getValue())."','".mysql_real_escape_string($this->getCondition())."',".mkn($this->getConditionValue()).",'1')");
$DBc->sqlQuery("INSERT INTO ach_perk (ap_achievement,ap_parent,ap_value,ap_condition,ap_condition_value,ap_dev,ap_porder) VALUES ('".$this->getAchievement()."',".mkn($this->getParentID()).",'".mysql_real_escape_string($this->getValue())."','".mysql_real_escape_string($this->getCondition())."',".mkn($this->getConditionValue()).",'1','".$this->porder."')");
$id = mysql_insert_id();
$this->setID($id);
@ -81,5 +83,39 @@
function setConditionValue($v) {
$this->condition_value = $v;
}
function getPorder() {
return $this->porder;
}
function setPorder($p) {
$this->porder = $p;
}
function setParentID($p) { #!! CUTTING KILLS NODES! HAVE TO BE REROUTED!
if($p == null || $p == "null") {
//remove from ach list; insert as first!
$this->parent_id = null;
$this->parent->removeChild($this->id);
$iter = $this->parent->getIterator();
$this->parent->addOpen($this,$iter->getNext());
}
else {
//remove from ach list; insert after parent
echo "--".$p."<br>";
$this->parent_id = $p;
$this->parent->removeChild($this->id);
$item = $this->parent->getChildByID($this->parent_id);
$tmp = $item->getChild();
if($tmp != null) {
$this->parent->addOpen($this,$tmp->getID());
}
else {
$this->parent->addOpen($this,null);
}
}
}
}
?>

View file

@ -137,8 +137,8 @@
<td>
<select name='ap_condition'>
<option value='all' selected='selected'>all</option>
<option value='any' selected='selected'>any</option>
<option value='value' selected='selected'>by value</option>
<option value='any'>any</option>
<option value='value'>by value</option>
</select>
</td>
</tr>
@ -310,7 +310,7 @@
</div>";
$html .= "<div id='new_perk_".$ach->getID()."' style='margin-bottom:3px;margin-top:3px;display:none;color:#000000;background-color:#FFFFFF;'>
<form method='post' action=''>
<form method='post' action='?mode=ach&cat=".$_REQUEST['cat']."&id=".$ach->getID()."&act=perk_insert'>
<fieldset>
<legend>add new perk</legend>
<table>
@ -345,8 +345,8 @@
<td>
<select name='ap_condition'>
<option value='all' selected='selected'>all</option>
<option value='any' selected='selected'>any</option>
<option value='value' selected='selected'>by value</option>
<option value='any'>any</option>
<option value='value'>by value</option>
</select>
</td>
</tr>
@ -442,21 +442,21 @@
</td></tr></table>";
$html .= "<div id='edit_perk_".$perk->getID()."' style='margin-bottom:3px;margin-top:3px;display:none;color:#000000;background-color:#FFFFFF;'>
<form method='post' action=''>
<form method='post' action='?mode=ach&cat=".$_REQUEST['cat']."&id=".$perk->getPathID()."&act=perk_update'>
<fieldset>
<legend>edit perk</legend>
<table>
<tr>
<td>name:</td>
<td><input type='text' name='apl_name' /></td>
<td><input type='text' name='apl_name' value='".$perk->getName()."' /></td>
</tr>
<tr>
<td>naming template:</td>
<td><input type='text' name='apl_template' /></td>
<td><input type='text' name='apl_template' value=\"".$perk->getTemplate()."\" /></td>
</tr>
<tr>
<td>yubopoints:</td>
<td><input type='text' name='ap_value' /></td>
<td><input type='text' name='ap_value' value='".$perk->getValue()."' /></td>
</tr>
<tr>
<td>parent:</td>
@ -467,7 +467,15 @@
$iter = $par->getOpen();
while($iter->hasNext()) {
$curr = $iter->getNext();
$html .= "<option value='".$curr->getID()."'>".$curr->getName()."</option>";
if($curr->getID() == $perk->getID()) {
continue;
}
$html .= "<option value='".$curr->getID()."'";
if($curr->getID() == $perk->getParentID()) {
$html .= " selected='selected'";
}
$html .= ">".$curr->getName()."</option>";
}
$html .= "</select>
@ -477,18 +485,18 @@
<td>condition:</td>
<td>
<select name='ap_condition'>
<option value='all' selected='selected'>all</option>
<option value='any' selected='selected'>any</option>
<option value='value' selected='selected'>by value</option>
<option value='all'"; if($perk->getCondition() == "all") { $html .= " selected='selected'"; } $html .= ">all</option>
<option value='any'"; if($perk->getCondition() == "any") { $html .= " selected='selected'"; } $html .= ">any</option>
<option value='value'"; if($perk->getCondition() == "value") { $html .= " selected='selected'"; } $html .= ">by value</option>
</select>
</td>
</tr>
<tr>
<td>condition value:</td>
<td><input type='text' name='ap_condition_value' /></td>
<td><input type='text' name='ap_condition_value' value='".$perk->getConditionValue()."' /></td>
</tr>
<tr>
<td colspan='2'><input type='submit' value='add' /></td>
<td colspan='2'><input type='submit' value='save' /></td>
</tr>
</table>
</fieldset>
@ -496,7 +504,7 @@
</div>";
$html .= "<div id='new_obj_".$perk->getID()."' style='margin-bottom:3px;margin-top:3px;display:none;color:#000000;background-color:#FFFFFF;'>
<form method='post' action=''>
<form method='post' action='?mode=ach&cat=".$_REQUEST['cat']."&id=".$perk->getPathID()."&act=obj_insert'>
<fieldset>
<legend>add new objective</legend>
<table>
@ -507,7 +515,7 @@
<tr>
<td>type:</td>
<td>
<select name='ao_type'>
<select name='ao_display'>
<option value='simple' selected='selected'>simple</option>
<option value='hidden'>hidden</option>
<option value='value'>value / progressbar</option>
@ -518,7 +526,7 @@
<tr>
<td>trigger condition:</td>
<td>
<select name='ap_condition'>
<select name='ao_condition'>
<option value='simple' selected='selected'>require all</option>
<option value='hidden'>require any</option>
<option value='value'>value / progressbar</option>
@ -606,13 +614,61 @@
break;
}
$html .= "<td style='background-color:#FFFFFF;padding:3px;'><nobr><a href='javascript:hs(\"edit_perk_".$elem->getID()."\",\"block\");'><img src='pic/icon_edit.gif'></a>";
$html .= "<td style='background-color:#FFFFFF;padding:3px;'><nobr><a href='javascript:hs(\"edit_obj_".$elem->getID()."\",\"block\");'><img src='pic/icon_edit.gif'></a>";
$html .= "&nbsp;<a href='javascript:hs(\"new_obj_".$elem->getID()."\",\"block\");'><img src='pic/b_insrow.png'></a>";
#$html .= "&nbsp;<a href='javascript:hs(\"edit_obj_".$elem->getID()."\",\"block\");'><img src='pic/b_insrow.png'></a>";
$html .= "&nbsp;&nbsp;&nbsp;<a href='?mode=ach&cat=".$_REQUEST['cat']."&confirm=delete&id=".$elem->getPathID()."'><img src='pic/b_drop.png'></a></nobr></td>
</td></tr></table>";
#$perk = $elem->getParent();
$html .= "<div id='edit_obj_".$elem->getID()."' style='margin-bottom:3px;margin-top:3px;display:none;color:#000000;background-color:#FFFFFF;'>
<form method='post' action='?mode=ach&cat=".$_REQUEST['cat']."&id=".$elem->getPathID()."&act=obj_update'>
<fieldset>
<legend>edit objective</legend>
<table>
<tr>
<td>name:</td>
<td><input type='text' name='aol_name' value='".$elem->getName()."' /></td>
</tr>
<tr>
<td>type:</td>
<td>
<select name='ao_display'>
<option value='simple'"; if($elem->getDisplay() == "simple") { $html .= " selected='selected'"; } $html .= ">simple</option>
<option value='hidden'"; if($elem->getDisplay() == "hidden") { $html .= " selected='selected'"; } $html .= ">hidden</option>
<option value='value'"; if($elem->getDisplay() == "value") { $html .= " selected='selected'"; } $html .= ">value / progressbar</option>
<option value='meta'"; if($elem->getDisplay() == "meta") { $html .= " selected='selected'"; } $html .= ">meta</option>
</select>
</td>
</tr>
<tr>
<td>trigger condition:</td>
<td>
<select name='ao_condition'>
<option value='simple'"; if($elem->getCondition() == "simple") { $html .= " selected='selected'"; } $html .= ">require all</option>
<option value='hidden'"; if($elem->getCondition() == "hidden") { $html .= " selected='selected'"; } $html .= ">require any</option>
<option value='value'"; if($elem->getCondition() == "value") { $html .= " selected='selected'"; } $html .= ">value / progressbar</option>
</select>
</td>
</tr>
<tr>
<td>trigger value:</td>
<td><input type='text' name='ao_value' value='".$elem->getValue()."' /></td>
</tr>
<tr>
<td>metalink:</td>
<td></td>
</tr>
<tr>
<td colspan='2'><input type='submit' value='save' /></td>
</tr>
</table>
</fieldset>
</form>
</div>";
#if(($i%2) == 1) {
$html .= "</td></tr>";
#}

View file

@ -0,0 +1,856 @@
<?php
function adm_render_menu(&$menu,$sub = 0) {
$html = "<style>
.ach_menu {
display:block;
padding:2px;
border:1px solid #000000;
margin-bottom:2px;
color:#FFFFFF;
}
.ach_menu:hover {
color:orange;
}
.ach_mspan a {
text-decoration:none;
}
</style>";
return $html.adm_render_mnode($menu,$sub);
}
function adm_render_mnode(&$menu,$sub) {
global $_CONF;
$iter = $menu->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
#$sz = $menu->getSize();
#for($i=0;$i<$sz;$i++) {
# $curr = $menu->getChild($i);
if($curr->inDev()) {
#continue;
}
$html .= "<span class='ach_mspan'><a href='?mode=ach&cat=".$curr->getID()."'><table class='ach_menu'>
<tr>";
if($sub == 0) {
$html .= "<td><img src='".$_CONF['image_url']."pic/menu/".$curr->getImage()."' /></td>";
}
$html .= "<td style='font-size:".(20-$sub)."px;font-weight:bold;";
if($curr->isOpen()) {
$html .= "color:orange;";
}
$html .= "'>".$curr->getName()."</td>
</tr>
</table></a></span>";
if($curr->hasOpenCat() != 0) {
$html .= "<div style='display:block;margin-left:25px;'>".adm_render_mnode($curr,($sub+4))."</div>";
}
}
return $html;
}
function adm_render_category(&$cat) {
$html = "";
if($_REQUEST['confirm'] == "delete") {
$tmp = $cat->getElementByPath($_REQUEST['id']);
if($tmp != null) {
$html .= "<div style='display:block;background-color:#FFFFFF;padding:3px;margin-bottom:5px;color:#000000;'>
<fieldset>
<legend>Delete</legend>
Are you sure you want to delete <b>".$tmp->getName()."</b><p>
<b>Any nested Perks/Objective/Atoms will be removed, as well as any player progress connected!</b>
<p>
<a href='?mode=ach&cat=".$_REQUEST['cat']."&act=delete&id=".$_REQUEST['id']."'><b>delete</b></a>
</fieldset>
</div>";
}
}
$html .= "<div style='display:block;background-color:#FFFFFF;padding:3px;margin-bottom:5px;color:#000000;'>
<div style='display:block;text-align:right;'>
<a href='javascript:hs(\"new_ach\",\"block\");'>
<img src='pic/b_insrow.png'>
</a>
</div>
<div id='new_ach' style='display: none;'>
<form method='post' action='?mode=ach&cat=".$_REQUEST['cat']."&act=ach_insert'>
<fieldset>
<legend>add new achievement</legend>
<table>
<tr>
<td>name:</td>
<td><input type='text' name='aal_name' /></td>
</tr>
<tr>
<td>naming template:</td>
<td><input type='text' name='aal_template' /></td>
</tr>
<tr>
<td>cult:</td>
<td>
<select name='aa_tie_cult'>
<option value='null' selected='selected'>any</option>
<option value='c_neutral'>neutral</option>
<option value='c_kami'>Kami</option>
<option value='c_karavan'>Karavan</option>
</select>
</td>
</tr>
<tr>
<td>civilization:</td>
<td>
<select name='aa_tie_civ'>
<option value='null' selected='selected'>any</option>
<option value='c_neutral'>neutral</option>
<option value='c_fyros'>Fyros</option>
<option value='c_matis'>Matis</option>
<option value='c_tryker'>Tryker</option>
<option value='c_zorai'>Zorai</option>
</select>
</td>
</tr>
<tr>
<td>image:</td>
<td><input type='text' name='aa_image' /></td>
</tr>
<tr>
<td colspan='2'><hr /></td>
</tr>
<tr>
<td>perk name:</td>
<td><input type='text' name='apl_name' /></td>
</tr>
<tr>
<td>naming template:</td>
<td><input type='text' name='apl_template' /></td>
</tr>
<tr>
<td>perk yubopoints:</td>
<td><input type='text' name='ap_value' /></td>
</tr>
<tr>
<td>condition:</td>
<td>
<select name='ap_condition'>
<option value='all' selected='selected'>all</option>
<option value='any'>any</option>
<option value='value'>by value</option>
</select>
</td>
</tr>
<tr>
<td>condition value:</td>
<td><input type='text' name='ap_condition_value' /></td>
</tr>
<tr>
<td colspan='2'><input type='submit' value='create' /></td>
</tr>
</table>
</fieldset>
</form>
</div>
</div>";
if($cat->isTiedCultDev() || $cat->isTiedCivDev()) {
$html .= ach_render_tiebar($cat->getCurrentCult(),$cat->getCurrentCiv(),$cat);
}
/*$iter = $cat->getDone();
while($iter->hasNext()) {
$curr = $cat->getChildByIdx($iter->getNext());
#$sz = sizeof($tmp);
#for($i=0;$i<$sz;$i++) {
#echo "A";
if($curr->inDev()) {
continue;
}
$html .= ach_render_achievement_done($curr);
}*/
$iter = $cat->getOpen();
while($iter->hasNext()) {
$curr = $iter->getNext();
#$sz = sizeof($tmp);
#for($i=0;$i<$sz;$i++) {
#echo "B";
if($curr->inDev()) {
#continue;
}
$html .= ach_render_achievement_open($curr);
}
return $html;
}
function ach_render_achievement_done(&$ach) {
global $_CONF;
$html = '<div style="display: block; margin-bottom: 5px;"><table cellpadding="0" cellspacing="0" width="100%">
<tbody><tr>
<td width="3px"><img src="'.$_CONF['image_url'].'pic/bar_done_ul.png"></td>
<td style="background-image: url('.$_CONF['image_url'].'pic/bar_done_u.png);"></td>
<td width="3px"><img src="'.$_CONF['image_url'].'pic/bar_done_ur.png"></td>
</tr>
<tr>
<td style="background-image: url('.$_CONF['image_url'].'pic/bar_done_l.png);"></td>
<td style="background-image: url('.$_CONF['image_url'].'pic/bar_done_bg.png);">
<center><table width="100%" cellspacing="0" cellpadding="0">
<tbody><tr>
<td rowspan="2" valign="top"><img src="'.$_CONF['image_url'].'pic/icon/'.$ach->getImage().'"></td>
<td width="100%"><center><span style="font-weight:bold;font-size:24px;color:#000000;">'.$ach->getName().'</span></center></td>
<td rowspan="2" valign="top" style="font-weight: bold; text-align: center; font-size: 30px;color:#000000;padding-right:10px;">
'.$ach->getValueDone().'<br><img src="'.$_CONF['image_url'].'pic/yubo_done.png">
</td>
</tr><tr><td align="center" valign="top">';
$html .= ach_render_perk_done($ach);
$html .= '</td></tr></tbody></table></center>
</td>
<td style="background-image: url('.$_CONF['image_url'].'pic/bar_done_r.png);"></td>
</tr>
<tr>
<td><img src="'.$_CONF['image_url'].'pic/bar_done_bl.png"></td>
<td style="background-image: url('.$_CONF['image_url'].'pic/bar_done_b.png);"></td>
<td><img src="'.$_CONF['image_url'].'pic/bar_done_br.png"></td>
</tr>
</tbody></table></div>';
return $html;
}
function ach_render_achievement_open(&$ach) {
global $_CONF,$menu;
$html = '<div style="display: block; margin-bottom: 5px;"><table cellpadding="0" cellspacing="0" width="100%">
<tbody><tr>
<td width="3px"><img src="'.$_CONF['image_url'].'pic/bar_pending_ul.png"></td>
<td style="background-image: url('.$_CONF['image_url'].'pic/bar_pending_u.png);"></td>
<td width="3px"><img src="'.$_CONF['image_url'].'pic/bar_pending_ur.png"></td>
</tr>
<tr>
<td style="background-image: url('.$_CONF['image_url'].'pic/bar_pending_l.png);"></td>
<td>
<center><table width="100%" cellspacing="0" cellpadding="0">
<tbody><tr>
<td rowspan="2" valign="top"><img src="'.$_CONF['image_url'].'pic/icon/grey/'.$ach->getImage().'"></td>
<td width="100%"><center><table><tr><td><span style="font-weight:bold;font-size:24px;color:#FFFFFF;">[ach:]'.$ach->getName().'</span></td>';
$html .= "<td style='background-color:#FFFFFF;padding:3px;'><nobr><a href='?mode=ach&cat=".$_REQUEST['cat']."&act=dev&state=".$ach->getDev()."&id=".$ach->getPathID()."'><img src='pic/";
if($ach->inDev()) {
$html .= "red";
}
else {
$html .= "green";
}
$html .= ".gif' /></a>&nbsp;<a href='javascript:hs(\"edit_ach_".$ach->getID()."\",\"block\");'><img src='pic/icon_edit.gif'></a>";
$html .= "&nbsp;<a href='javascript:hs(\"new_perk_".$ach->getID()."\",\"block\");'><img src='pic/b_insrow.png'></a>";
$html .= "&nbsp;<a href='javascript:hs(\"opts_ach_".$ach->getID()."\",\"block\");'><img src='pic/b_tblops.png'></a>";
$html .= "&nbsp;&nbsp;&nbsp;<a href='?mode=ach&cat=".$_REQUEST['cat']."&confirm=delete&id=".$ach->getPathID()."'><img src='pic/b_drop.png'></a></nobr></td>
</td></tr></table>";
$html .= '</center></td><td rowspan="2" valign="top" style="font-weight: bold; text-align: center; font-size: 30px;color:#FFFFFF;padding-right:10px;"><!--
'.$ach->getValueOpen().'<br> --><img src="'.$_CONF['image_url'].'pic/yubo_pending.png">
</td>
</tr><tr><td align="center" valign="top">';
$html .= "<div id='edit_ach_".$ach->getID()."' style='margin-bottom:3px;margin-top:3px;display:none;color:#000000;background-color:#FFFFFF;'>
<form method='post' action='?mode=ach&cat=".$_REQUEST['cat']."&id=".$ach->getID()."&act=ach_update'>
<fieldset>
<legend>edit achievement</legend>
<table>
<tr>
<td>name:</td>
<td><input type='text' name='aal_name' value=\"".$ach->getName()."\" /></td>
</tr>
<tr>
<td>naming template:</td>
<td><input type='text' name='aal_template' value=\"".$ach->getTemplate()."\" /></td>
</tr>
<tr>
<td>cult:</td>
<td>
<select name='aa_tie_cult'>
<option value='null'"; if($ach->getTieCult() == null) { $html .= " selected='selected'"; } $html .= ">any</option>
<option value='c_neutral'"; if($ach->getTieCult() == "c_neutral") { $html .= " selected='selected'"; } $html .= ">neutral</option>
<option value='c_kami'"; if($ach->getTieCult() == "c_kami") { $html .= " selected='selected'"; } $html .= ">Kami</option>
<option value='c_karavan'"; if($ach->getTieCult() == "c_karavan") { $html .= " selected='selected'"; } $html .= ">Karavan</option>
</select>
</td>
</tr>
<tr>
<td>civilization:</td>
<td>
<select name='aa_tie_civ'>
<option value='null'"; if($ach->getTieCiv() == null) { $html .= " selected='selected'"; } $html .= ">any</option>
<option value='c_neutral'"; if($ach->getTieCiv() == "c_neutral") { $html .= " selected='selected'"; } $html .= ">neutral</option>
<option value='c_fyros'"; if($ach->getTieCiv() == "c_fyros") { $html .= " selected='selected'"; } $html .= ">Fyros</option>
<option value='c_matis'"; if($ach->getTieCiv() == "c_matis") { $html .= " selected='selected'"; } $html .= ">Matis</option>
<option value='c_tryker'"; if($ach->getTieCiv() == "c_tryker") { $html .= " selected='selected'"; } $html .= ">Tryker</option>
<option value='c_zorai'"; if($ach->getTieCiv() == "c_zorai") { $html .= " selected='selected'"; } $html .= ">Zorai</option>
</select>
</td>
</tr>
<tr>
<td>image:</td>
<td><input type='text' name='aa_image' value='".$ach->getImage()."' /></td>
</tr>
<tr>
<td colspan='2'><input type='submit' value='save' /></td>
</tr>
</table>
</fieldset>
</form>
</div>";
$html .= "<div id='new_perk_".$ach->getID()."' style='margin-bottom:3px;margin-top:3px;display:none;color:#000000;background-color:#FFFFFF;'>
<form method='post' action='?mode=ach&cat=".$_REQUEST['cat']."&id=".$ach->getID()."&act=perk_insert'>
<fieldset>
<legend>add new perk</legend>
<table>
<tr>
<td>name:</td>
<td><input type='text' name='apl_name' /></td>
</tr>
<tr>
<td>naming template:</td>
<td><input type='text' name='apl_template' /></td>
</tr>
<tr>
<td>yubopoints:</td>
<td><input type='text' name='ap_value' /></td>
</tr>
<tr>
<td>parent:</td>
<td>
<select name='ap_parent'>
<option value='null' selected='selected'>[set as main perk]</option>";
$iter = $ach->getOpen();
while($iter->hasNext()) {
$curr = $iter->getNext();
$html .= "<option value='".$curr->getID()."'>".$curr->getName()."</option>";
}
$html .= "</select>
</td>
</tr>
<tr>
<td>condition:</td>
<td>
<select name='ap_condition'>
<option value='all' selected='selected'>all</option>
<option value='any'>any</option>
<option value='value'>by value</option>
</select>
</td>
</tr>
<tr>
<td>condition value:</td>
<td><input type='text' name='ap_condition_value' /></td>
</tr>
<tr>
<td colspan='2'><input type='submit' value='add' /></td>
</tr>
</table>
</fieldset>
</form>
</div>";
$html .= "<div id='opts_ach_".$ach->getID()."' style='margin-bottom:3px;margin-top:3px;display:none;color:#000000;background-color:#FFFFFF;'>
<form method='post' action='?mode=ach&cat=".$_REQUEST['cat']."&id=".$ach->getID()."&act=ach_move'>
<fieldset>
<legend>move achievement</legend>
<table>
<tr>
<td>new category:</td>
<td>
<select name='new_cat'>";
$iter = $menu->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
$html .= "<option value='".$curr->getID()."'>".$curr->getName()."</option>";
$iter2 = $curr->getIterator();
while($iter2->hasNext()) {
$curr2 = $iter2->getNext();
$html .= "<option value='".$curr2->getID()."'>&nbsp;&nbsp;&nbsp;&nbsp;".$curr2->getName()."</option>";
}
}
$html .= "</select>
</td>
</tr>
<tr>
<td colspan='2'><input type='submit' value='move' /></td>
</tr>
</table>
</fieldset>
</form>
</div>";
$html .= ach_render_perk_open($ach);
$html .= '</td></tr></tbody></table></center>
</td>
<td style="background-image: url('.$_CONF['image_url'].'pic/bar_pending_r.png);"></td>
</tr>
<tr>
<td><img src="'.$_CONF['image_url'].'pic/bar_pending_bl.png"></td>
<td style="background-image: url('.$_CONF['image_url'].'pic/bar_pending_b.png);"></td>
<td><img src="'.$_CONF['image_url'].'pic/bar_pending_br.png"></td>
</tr>
</tbody></table></div>';
return $html;
}
function ach_render_perk_open(&$ach) {
#echo var_export($perk_list,true);
$html = "";
$perk_list = $ach->getOpen();
while($perk_list->hasNext()) {
$perk = $perk_list->getNext();
#$perk = $ach->getChild($perk_list[0]);
if($perk->inDev()) {
#return $html;
}
#if($perk->getName() != null) {
$html .= "<table><tr><td><span style='color:#999999;font-weight:bold;display:block;'>[perk:]".$perk->getDisplayName()."</span></td>";
$html .= "<td style='background-color:#FFFFFF;padding:3px;'><nobr><a href='?mode=ach&cat=".$_REQUEST['cat']."&act=dev&state=".$perk->getDev()."&id=".$perk->getPathID()."'><img src='pic/";
if($perk->inDev()) {
$html .= "red";
}
else {
$html .= "green";
}
$html .= ".gif' /></a>&nbsp;<a href='javascript:hs(\"edit_perk_".$perk->getID()."\",\"block\");'><img src='pic/icon_edit.gif'></a>";
$html .= "&nbsp;<a href='javascript:hs(\"new_obj_".$perk->getID()."\",\"block\");'><img src='pic/b_insrow.png'></a>";
$html .= "&nbsp;&nbsp;&nbsp;<a href='?mode=ach&cat=".$_REQUEST['cat']."&confirm=delete&id=".$perk->getPathID()."'><img src='pic/b_drop.png'></a></nobr></td>
</td></tr></table>";
$html .= "<div id='edit_perk_".$perk->getID()."' style='margin-bottom:3px;margin-top:3px;display:none;color:#000000;background-color:#FFFFFF;'>
<form method='post' action='?mode=ach&cat=".$_REQUEST['cat']."&id=".$perk->getPathID()."&act=perk_update'>
<fieldset>
<legend>edit perk</legend>
<table>
<tr>
<td>name:</td>
<td><input type='text' name='apl_name' value='".$perk->getName()."' /></td>
</tr>
<tr>
<td>naming template:</td>
<td><input type='text' name='apl_template' value=\"".$perk->getTemplate()."\" /></td>
</tr>
<tr>
<td>yubopoints:</td>
<td><input type='text' name='ap_value' value='".$perk->getValue()."' /></td>
</tr>
<tr>
<td>parent:</td>
<td>
<select name='ap_parent'>
<option value='null' selected='selected'>[set as main perk]</option>";
$par = $perk->getParent();
$iter = $par->getOpen();
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->getID() == $perk->getID()) {
continue;
}
$html .= "<option value='".$curr->getID()."'";
if($curr->getID() == $perk->getParentID()) {
$html .= " selected='selected'";
}
$html .= ">".$curr->getName()."</option>";
}
$html .= "</select>
</td>
</tr>
<tr>
<td>condition:</td>
<td>
<select name='ap_condition'>
<option value='all'"; if($perk->getCondition() == "all") { $html .= " selected='selected'"; } $html .= ">all</option>
<option value='any'"; if($perk->getCondition() == "any") { $html .= " selected='selected'"; } $html .= ">any</option>
<option value='value'"; if($perk->getCondition() == "value") { $html .= " selected='selected'"; } $html .= ">by value</option>
</select>
</td>
</tr>
<tr>
<td>condition value:</td>
<td><input type='text' name='ap_condition_value' value='".$perk->getConditionValue()."' /></td>
</tr>
<tr>
<td colspan='2'><input type='submit' value='save' /></td>
</tr>
</table>
</fieldset>
</form>
</div>";
$html .= "<div id='new_obj_".$perk->getID()."' style='margin-bottom:3px;margin-top:3px;display:none;color:#000000;background-color:#FFFFFF;'>
<form method='post' action='?mode=ach&cat=".$_REQUEST['cat']."&id=".$perk->getPathID()."&act=obj_insert'>
<fieldset>
<legend>add new objective</legend>
<table>
<tr>
<td>name:</td>
<td><input type='text' name='aol_name' /></td>
</tr>
<tr>
<td>type:</td>
<td>
<select name='ao_display'>
<option value='simple' selected='selected'>simple</option>
<option value='hidden'>hidden</option>
<option value='value'>value / progressbar</option>
<option value='meta'>meta</option>
</select>
</td>
</tr>
<tr>
<td>trigger condition:</td>
<td>
<select name='ao_condition'>
<option value='simple' selected='selected'>require all</option>
<option value='hidden'>require any</option>
<option value='value'>value / progressbar</option>
</select>
</td>
</tr>
<tr>
<td>trigger value:</td>
<td><input type='text' name='ao_value' /></td>
</tr>
<tr>
<td>metalink:</td>
<td></td>
</tr>
<tr>
<td colspan='2'><input type='submit' value='add' /></td>
</tr>
</table>
</fieldset>
</form>
</div>";
#}
#if($perk->objDrawable()) {
$html .= ach_render_obj_list($perk->getIterator());
#}
}
return $html;
}
function ach_render_perk_done(&$ach) {
global $_CONF;
$html = "";
$perk_list = $ach->getDone();
while($perk_list->hasNext()) {
$perk = $perk_list->getNext();
#foreach($perk_list as $elem) {
#$perk = $ach->getChild($elem);
if($perk->inDev()) {
continue;
}
$html .= "<div style='display:block;'><span style='color:#66CC00;font-weight:bold;'>".$perk->getName()."</span> ( ".date('d.m.Y',$perk->getDone())." ) <img src='".$_CONF['image_url']."pic/yubo_done.png' width='15px' /> ".$perk->getValue()."</div>";
}
return $html;
}
function ach_render_obj_list($obj) {
$html = "<center><table width='90%'>";
#$i = 0;
#$skip = false;
while($obj->hasNext()) {
#foreach($obj as $elem) {
$elem = $obj->getNext();
#if(($i%2) == 0) {
$html .= "<tr><td><table><tr>";
#}
switch($elem->getDisplay()) {
case "meta":
$html .= "<td>".ach_render_obj_meta($elem)."<td>";
break;
case "value":
#if(($i%2) == 1) {
# $html .= "</tr><tr>";
#}
$html .= "<td>".ach_render_obj_value($elem)."</td>";
#$i++;
break;
case "simple":
$html .= "<td>".ach_render_obj_simple($elem)."</td>";
break;
case "hidden":
default:
//do nothing
#$skip = true;
#if(($i%2) == 1) {
# $html .= "</tr><tr>";
#}
$html .= "<td>".ach_render_obj_hidden($elem)."</td>";
#$i++;
break;
}
$html .= "<td style='background-color:#FFFFFF;padding:3px;'><nobr><a href='javascript:hs(\"edit_obj_".$elem->getID()."\",\"block\");'><img src='pic/icon_edit.gif'></a>";
#$html .= "&nbsp;<a href='javascript:hs(\"edit_obj_".$elem->getID()."\",\"block\");'><img src='pic/b_insrow.png'></a>";
$html .= "&nbsp;&nbsp;&nbsp;<a href='?mode=ach&cat=".$_REQUEST['cat']."&confirm=delete&id=".$elem->getPathID()."'><img src='pic/b_drop.png'></a></nobr></td>
</td></tr></table>";
#$perk = $elem->getParent();
$html .= "<div id='edit_obj_".$elem->getID()."' style='margin-bottom:3px;margin-top:3px;display:none;color:#000000;background-color:#FFFFFF;'>
<form method='post' action='?mode=ach&cat=".$_REQUEST['cat']."&id=".$elem->getPathID()."&act=obj_update'>
<fieldset>
<legend>edit objective</legend>
<table>
<tr>
<td>name:</td>
<td><input type='text' name='aol_name' value='".$elem->getName()."' /></td>
</tr>
<tr>
<td>type:</td>
<td>
<select name='ao_display'>
<option value='simple'"; if($elem->getDisplay() == "simple") { $html .= " selected='selected'"; } $html .= ">simple</option>
<option value='hidden'"; if($elem->getDisplay() == "hidden") { $html .= " selected='selected'"; } $html .= ">hidden</option>
<option value='value'"; if($elem->getDisplay() == "value") { $html .= " selected='selected'"; } $html .= ">value / progressbar</option>
<option value='meta'"; if($elem->getDisplay() == "meta") { $html .= " selected='selected'"; } $html .= ">meta</option>
</select>
</td>
</tr>
<tr>
<td>trigger condition:</td>
<td>
<select name='ao_condition'>
<option value='simple'"; if($elem->getCondition() == "simple") { $html .= " selected='selected'"; } $html .= ">require all</option>
<option value='hidden'"; if($elem->getCondition() == "hidden") { $html .= " selected='selected'"; } $html .= ">require any</option>
<option value='value'"; if($elem->getCondition() == "value") { $html .= " selected='selected'"; } $html .= ">value / progressbar</option>
</select>
</td>
</tr>
<tr>
<td>trigger value:</td>
<td><input type='text' name='ao_value' value='".$elem->getValue()."' /></td>
</tr>
<tr>
<td>metalink:</td>
<td></td>
</tr>
<tr>
<td colspan='2'><input type='submit' value='save' /></td>
</tr>
</table>
</fieldset>
</form>
</div>";
#if(($i%2) == 1) {
$html .= "</td></tr>";
#}
#if(!$skip) {
# $i++;
#}
#$skip = false;
}
#if(($i%2) == 1) {
# $html .= "</tr>";
#}
$html .= "</table></center>";
return $html;
}
function ach_render_obj_simple(&$obj) {
global $_CONF;
$html = "";
if($obj->isdone()) {
$html .= "<img src='".$_CONF['image_url']."pic/check.png' height='10px' />&nbsp;<span style='color:#71BE02;'>";
}
else {
$html .= "<img src='".$_CONF['image_url']."pic/pending.png' height='10px' />&nbsp;<span style='color:#999999;'>";
}
$html .= "[obj:]".$obj->getDisplayName()."</span>";
return $html;
}
function ach_render_obj_meta(&$obj) {
global $_CONF;
$html = "";
if($obj->isdone()) {
$col = "#71BE02";
$grey = "";
}
else {
$col = "#999999";
$grey = "grey/";
}
return "<table cellspacing='0' cellpadding='0'>
<tr>
<td><img src='".$_CONF['image_url']."pic/icon/".$grey.$obj->getMetaImage()."' width='20px' /></td>
<td valign='middle'><span style='color:".$col.";'>&nbsp;[obj:]".$obj->getDisplayName()."</span></td>
</tr>
</table>";
}
function ach_render_obj_value(&$obj) {
$html = "";
#if($obj->getName() != null) {
if($obj->isdone()) {
$col = "#71BE02";
}
else {
$col = "#999999";
}
$html .= "<div style='color:".$col.";display:block;'>[obj:]".$obj->getDisplayName()."</div>";
#}
$html .= ach_render_progressbar($obj->getProgress(),$obj->getValue(),350);
return $html;
}
function ach_render_obj_hidden(&$obj) {
$html = "";
#if($obj->getName() != null) {
if($obj->isdone()) {
$col = "#71BE02";
}
else {
$col = "#999999";
}
$html .= "<div style='color:".$col.";display:block;'>[obj: untitled]</div>";
#}
#$html .= ach_render_progressbar($obj->getProgress(),$obj->getValue(),350);
return $html;
}
function ach_render_progressbar($prog,$val,$width) {
$val = max(1,$val);
$left = floor($width*(100*($prog/$val))/100);
$html = "
<table width='".$width."px' cellspacing='0' cellpadding='0' style='border:1px solid #FFFFFF;color:#000000;'>
<tr>
<td bgcolor='#66CC00' width='".$left."px' align='right'>";
if(($prog/$val) > 0.85) {
$html .= "&nbsp;".nf($prog)." / ".nf($val)."&nbsp;";
}
$html .= "</td>
<td align='left' style='color:#FFFFFF;'>";
if(($prog/$val) <= 0.85) {
$html .= "&nbsp;".nf($prog)." / ".nf($val)."&nbsp;";
}
$html .= "</td>
</tr>
</table>";
return $html;
}
function ach_render_tiebar($cult = "c_neutral", $civ = "c_neutral",&$cat) {
global $_USER,$_CONF;
$html = "<style>
.o {
color:orange;
}
</style>
<div style='display:block;text-align:center;'><form method='post' action='?cat=".$cat->getID()."' id='cc_form'>
<table>
<tr>";
if($cat->isTiedCult()) {
$html.= "<td>
<select name='cult' onchange='document.getElementById(\"cc_form\").submit();'>
<option value='c_neutral'"; if($cult == "c_neutral") { $html.= " selected='selected'"; } $html .= ">".get_translation('ach_c_neutral',$_USER->getLang())."</option>
<option value='c_kami'"; if($cult == "c_kami") { $html.= " selected='selected'"; } $html .= ">Kami</option>
<option value='c_karavan'"; if($cult == "c_karavan") { $html.= " selected='selected'"; } $html .= ">Karavan</option>
</select>
</td>";
}
if($cat->isTiedCiv()) {
$html.= "<td>
<select name='civ' onchange='document.getElementById(\"cc_form\").submit();'>
<option value='c_neutral'"; if($civ == "c_neutral") { $html.= " selected='selected'"; } $html .= ">".get_translation('ach_c_neutral',$_USER->getLang())."</option>
<option value='c_fyros'"; if($civ == "c_fyros") { $html.= " selected='selected'"; } $html .= ">Fyros</option>
<option value='c_matis'"; if($civ == "c_matis") { $html.= " selected='selected'"; } $html .= ">Matis</option>
<option value='c_tryker'"; if($civ == "c_tryker") { $html.= " selected='selected'"; } $html .= ">Tryker</option>
<option value='c_zorai'"; if($civ == "c_zorai") { $html.= " selected='selected'"; } $html .= ">Zorai</option>
</select>
</td>";
}
$html.= "</tr>
</table>
</form></div>
<div style='display:block;font-weight:bold;font-size:20px;color:#FFFFFF;text-align:center;margin-bottom:5px;'>";
if($cat->isTiedCult() && !$cat->isTiedCiv() && $cult == "c_neutral") { // neutral / xx
#While being of neutral allegiance with the higher powers
$html .= get_translation('ach_allegiance_neutral_cult',$_USER->getLang(),array("<span class='o'>".get_translation('ach_c_neutral',$_USER->getLang())."</span>"));
}
elseif($cat->isTiedCiv() && !$cat->isTiedCult() && $civ == "c_neutral") { // xx / neutral
#While being of neutral allegiance with the homin civilizations
$html .= get_translation('ach_allegiance_neutral_civ',$_USER->getLang(),array("<span class='o'>".get_translation('ach_c_neutral',$_USER->getLang())."</span>"));
}
elseif($cat->isTiedCiv() && $cat->isTiedCult() && $cult == "c_neutral" && $civ == "c_neutral") { // neutral / neutral
#While being of neutral allegiance
$html .= get_translation('ach_allegiance_neutral',$_USER->getLang(),array("<span class='o'>".get_translation('ach_c_neutral',$_USER->getLang())."</span>"));
}
else { //other
#While being aligned with the
$html .= get_translation('ach_allegiance_start',$_USER->getLang());
if($cat->isTiedCult() && $cult != "c_neutral") {
#CULT
$html .= "<span class='o'>".ach_translate_cc($cult)."</span>";
if($cat->isTiedCiv() && $civ != "c_neutral") {
#and the CIV
$html .= get_translation('ach_allegiance_and',$_USER->getLang())." <span class='o'>".ach_translate_cc($civ)."</span>";
}
}
elseif($cat->isTiedCiv() && $civ != "c_neutral") {
#CIV
$html .= "<span class='o'>".ach_translate_cc($civ)."</span>";
}
}
#, accomplish the following achievements:
$html .= get_translation('ach_allegiance_end',$_USER->getLang())."</div>";
return $html;
}
?>

View file

@ -71,7 +71,7 @@ require_once("class/CSRPerk_class.php");
require_once("class/CSRObjective_class.php");
require_once("class/CSRAtom_class.php");
$DBc = ryDB::getInstance("app_achievements");
$DBc = ryDB::getInstance("app_achievements_test");
#$DBc = ryDB::getInstance("ahufler");
function mkn($x) {
@ -120,6 +120,7 @@ $c = "<script type='text/javascript'>
<ul>
<li><a href='?mode=menu'>menu settings</a></li>
<li><a href='?mode=ach'>achievement settings</a></li>
<li><a href='?mode=atom'>trigger settings</a></li>
</ul><p />";
}
if($_ADMIN->isCSR()) {
@ -135,6 +136,51 @@ $c = "<script type='text/javascript'>
$c .= "</div></td>
<td valign='top'>";
if($_REQUEST['mode'] == "atom" && $_ADMIN->isAdmin()) {
$c .= "<h1>Tigger Settings</h1>";
$user = array();
$user['id'] = 0;
$user['lang'] = 'en';
$user['name'] = 'Talvela';
$user['race'] = "r_matis";
$user['civilization'] = "c_neutral";
$user['cult'] = "c_neutral";
$_USER = new RyzomUser($user);
//menu
require_once("include/adm_render_atom.php");
$menu = new AdmMenu($_REQUEST['cat']);
$c .= "<center><table>
<tr>
<td valign='top'><div style='width:230px;font-weight:bold;font-size:14px;'>";
$c .= adm_render_menu($menu);
$c .= "</div></td>
<td width='645px' valign='top'>";
$open = $menu->getOpenCat();
if($open != 0) {
$cat = new AdmCategory($open,'%','%','%');
$c .= atom_render_category($cat);
}
#a:p:o:a
$c .= "</td>
</tr>
</table></center>";
}
if($_REQUEST['mode'] == "menu" && $_ADMIN->isAdmin()) {
$c .= "<h1>Menu Settings</h1>";
@ -209,7 +255,7 @@ $c .= "</div></td>
$open = $menu->getOpenCat();
if($open != 0) {
$cat = new AdmCategory($open,'',$_REQUEST['cult'],$_REQUEST['civ']);
$cat = new AdmCategory($open,$_REQUEST['race'],$_REQUEST['cult'],$_REQUEST['civ']);
if($_REQUEST['act'] == "ach_move") {
$ach = $cat->getChildDataByID($_REQUEST['id']);
@ -236,6 +282,8 @@ $c .= "</div></td>
$perk->setName($_REQUEST['apl_name']);
$perk->setTemplate($_REQUEST['apl_name']);
$perk->setValue($_REQUEST['ap_value']);
$perk->setCondition($_REQUEST['ap_condition']);
$perk->setConditionValue($_REQUEST['ap_condition_value']);
$ach->insertNode($perk);
}
@ -260,13 +308,16 @@ $c .= "</div></td>
$perk = new AdmPerk(array(),$ach);
$perk->setAchievement($ach->getID());
$perk->setName($_REQUEST['apl_name']);
$perk->setTemplate($_REQUEST['apl_name']);
$perk->setTemplate($_REQUEST['apl_template']);
$perk->setValue($_REQUEST['ap_value']);
#MISSING: parent
#$perk->setCondition($_REQUEST['ap_condition']);
#$perk->setConditionValue($_REQUEST['ap_condition_value']);
$perk->setParentID($_REQUEST['ap_parent']);
$perk->setCondition($_REQUEST['ap_condition']);
$perk->setConditionValue($_REQUEST['ap_condition_value']);
$ach->insertNode($perk);
$ach->orderPerks();
$perk->update();
}
}
@ -277,10 +328,13 @@ $c .= "</div></td>
$perk->setName($_REQUEST['apl_name']);
$perk->setTemplate($_REQUEST['apl_template']);
$perk->setValue($_REQUEST['ap_value']);
#$perk->setParentID($_REQUEST['ap_parent']);
$perk->setParentID($_REQUEST['ap_parent']);
$perk->setCondition($_REQUEST['ap_condition']);
$perk->setConditionValue($_REQUEST['ap_condition_value']);
$ach = $perk->getParent();
$ach->orderPerks();
$perk->update();
}
}
@ -295,6 +349,7 @@ $c .= "</div></td>
$obj->setValue($_REQUEST['ao_value']);
$obj->setDisplay($_REQUEST['ao_display']);
$obj->setMetalink($_REQUEST['ao_metalink']);
$obj->setPerk($perk->getID());
$perk->insertNode($obj);
}
@ -366,7 +421,7 @@ $c .= "</div></td>
$open = $menu->getOpenCat();
if($open != 0) {
$cat = new CSRCategory($open,$_REQUEST['cult'],$_REQUEST['civ']);
$cat = new CSRCategory($open,null,$_REQUEST['cult'],$_REQUEST['civ']);
if($_REQUEST['grant'] != "") {
$cat->grantNode($_REQUEST['grant'],$_USER->getID());