#1470 repo update to latest version (web app)

This commit is contained in:
SirCotare 2012-08-07 17:41:50 +02:00
parent 6f84c47ac1
commit 9f6bd5774a
57 changed files with 2819 additions and 1130 deletions

View file

@ -9,39 +9,34 @@
require_once("class/mySQL_class.php");
require_once("conf.php");
require_once("include/functions_inc.php");
require_once("class/Entity_abstract.php");
$_REQUEST['file'] = $argv[1];
if(!$_REQUEST['file']) {
$_REQUEST['file'] = $argv[1];
}
/*$logfile = false;
$log = new Logfile();
if($CONF['logging'] == true) {
require_once("class/Logfile_class.php");
#$logfile = fopen($CONF['logfile'].'.'.date("Ymd",time()).'.txt','a');
$logfile = new Logfile($CONF['logfile']);#!! MUST HAVE ONE LOGFILE PER RUN!!
}*/
$log = 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);
}
}*/
$log->logf("File: '".$_REQUEST['file']."'");
$log->logf("Starting up... ",false);
if(!$_REQUEST['file']) {
$log->logf("ERROR: no file given! EXITING!");
die();
}
//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
#}
$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']);
require_once("class/DataDispatcher_class.php");
require_once("class/DataSourceHandler_class.php");
@ -50,11 +45,8 @@
require_once("class/ValueCache_class.php");
require_once("class/Atom_class.php");
#MISSING: static ValueCache!
$_CACHE = new ValueCache();
//create datasource handler
$_DISPATCHER = new DataDispatcher();
$_DATASOURCE = new DataSourceHandler();
@ -64,87 +56,98 @@
$_DATASOURCE->addSource($tmp);
}
// 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");
}*/
#REPLACE WITH REGEX!!!
$tmp = explode("/",$_REQUEST['file']);
$tmp2 = explode("_",$tmp[(sizeof($tmp)-1)]);
$chars = array(($tmp2[1]*16+$tmp2[2]));
$log->logf(" done!");
foreach($chars as $cid) {
#STEP 1: load and register atoms
$log->logf("Processing char '".$cid."' ...");
$log->logi("Loading and registering Atoms... ",false);
$atom_list = array();
$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");
$res2 = $DBc->sendSQL("SELECT ach_atom.* FROM ach_atom,ach_objective,ach_achievement WHERE ao_perk='".$perk['ap_id']."' AND ao_id=atom_objective AND ap_achievement=aa_id AND NOT EXISTS (SELECT * FROM ach_player_objective WHERE apo_player='".$cid."' AND apo_objective=ao_id) AND (aa_tie_race IS NULL OR aa_tie_race='') AND (aa_tie_cult IS NULL OR aa_tie_cult='') AND (aa_tie_civ IS NULL OR aa_tie_civ='')","ARRAY");
foreach($res2 as $atom) {
$a = new Atom($atom,$cid);
$atom_list[] = $a;
$a->register();
}
}
$log->logf("done!");
$log->logi("Driving data... ",false);
#STEP 2: drive data
$_CACHE->setChar($cid);
$_DATASOURCE->drive($cid);
$log->logf("done!");
#STEP 3: detect obj/perk progression
$log->logi("Detecting Objectives... ",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='".$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");
$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 NOT EXISTS (SELECT * FROM ach_player_atom WHERE apa_atom=atom_id AND apa_state='GRANT' AND apa_player='".$cid."')) AND EXISTS (SELECT * FROM ach_atom WHERE atom_objective=ao_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']."','".$cid."','".time()."')","NONE");
}
$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");
$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 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='".$cid."') AND EXISTS (SELECT * FROM ach_atom WHERE atom_objective=ao_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']."','".$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");
$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."')) AND EXISTS (SELECT * FROM ach_atom WHERE atom_objective=ao_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']."','".$cid."','".time()."')","NONE");
}
$log->logf("done!");
$log->logi("Clearing atom data... ",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='".$cid."' AND atom_objective=ao_id)");
$log->logf("done!");
//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");
$log->logi("Detecting Perks... ",false);
$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."')) AND EXISTS (SELECT * FROM ach_objective WHERE ao_perk=ap_id) AND ap_dev='0'","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");
$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."')) AND EXISTS (SELECT * FROM ach_objective WHERE ao_perk=ap_id) AND ap_dev='0'","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");
$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."')) AND EXISTS (SELECT * FROM ach_objective WHERE ao_perk=ap_id) AND ap_dev='0'","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");
}
$log->logf("done!");
}
$log->logf("Run complete; exiting...");
exit(0);
?>

View file

@ -17,7 +17,7 @@
function register() {
global $DBc,$_DATA;
echo "register<br>";
#echo "register<br>";
try {
return eval($this->ruleset);
@ -40,18 +40,29 @@
$_DISPATCHER->unregisterValue($name,$callback);
}
function grant() {
function registerEntity($name,$func) {
global $_DISPATCHER;
$tmp = new Callback($this,$func);
$_DISPATCHER->registerEntity($name,$tmp);
}
function unregisterEntity($name,$callback) {
global $_DISPATCHER;
$_DISPATCHER->unregisterEntity($name,$callback);
}
function grant($count = 1) {
global $DBc;
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");
$DBc->sendSQL("INSERT INTO ach_player_atom (apa_atom,apa_player,apa_date,apa_expire,apa_state,apa_value) VALUES ('".$this->id."','".$this->user."','".time()."',null,'GRANT','".$count."')","NONE");
}
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");
$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','1')","NONE");
}
function reset_() {

View file

@ -53,7 +53,6 @@
}
function dispatchValue($key,$val) {
echo "dispatching: $key=>$val<br>";
if(is_array($this->value[$key])) {
foreach($this->value[$key] as $callback) {
$callback->call($val);

View file

@ -0,0 +1,13 @@
<?php
abstract class Entity {
private $name;
function getName() {
return $this->name;
}
function setName($n) {
$this->name = $n;
}
}
?>

View file

@ -3,20 +3,34 @@
private $logfile;
private $buffer;
function Logfile($f) {
$this->logfile = $f;
$this->buffer = "";
function Logfile($f = false) {
$this->logfile = false;
if($f != false) {
$this->logfile = fopen($this->logfile.'.'.$_REQUEST['file'].'.'.date("Ymd",time()).'.txt','a');;
}
}
function append($t) {
$this->buffer .= $t;
function logf($t,$nl = true) {
$this->write($t);
if($nl == true) {
$this->write("\n");
}
}
function write() {
$f = fopen($this->logfile.'.'.date("Ymd",time()).'.txt','a');
fwrite($f,$this->buffer);
fclose($f);
$this->buffer = "";
function logi($t,$nl = true) {
$this->write(" > ".$t);
if($nl == true) {
$this->write("\n");
}
}
function write($txt) {
fwrite($this->logfile,$txt);
}
function close() {
fclose($this->logfile);
}
}
?>

View file

@ -132,6 +132,8 @@
}
private function error($error,$query = false) {
global $log;
$this->DBstats['error']++;
if($query != false) {
@ -149,7 +151,7 @@
echo "<script language='javascript'>\n<!--\nalert(\"database error:\\n".mysql_real_escape_string($error)."\");\n// -->\n</script>";
break;
case 'LOG':
logf("MySQL ERROR: ".$error);
$log->logf("MySQL ERROR: ".$error);
break;
default:
flush();

View file

@ -1,31 +1,21 @@
<?php
require_once("../../webig/config.php");
$CONF = array();
$CONF['logging'] = true;
$CONF['logfile'] = "log/AchWebParser.log";
$CONF['mysql_error'] = "PRINT";
$CONF['mysql_server'] = "localhost";
$CONF['mysql_user'] = "root";
$CONF['mysql_pass'] = "";
$CONF['mysql_database'] = "app_achievements";
$CONF['mysql_server'] = RYAPI_WEBDB_HOST;
$CONF['mysql_user'] = RYAPI_WEBDB_LOGIN;
$CONF['mysql_pass'] = RYAPI_WEBDB_PASS;
$CONF['mysql_database'] = "app_achievements_test";
$CONF['data_source'] = array("PDRtoXMLdriver");
/*$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'] = "app_achievements";
$CONF['fork'] = true;
$CONF['self_host'] = "127.0.0.1";
$CONF['self_path'] = "/path/to/AchWebParser.php";
$CONF['sleep_time'] = 1500;
$CONF['enable_selfcall'] = true;
$CONF['timeout'] = 60*60;
$CONF['data_source'] = array("PDRtoXMLdriver");
?>

View file

@ -0,0 +1,128 @@
<?php
@include_once("script/include_InPoly_class.php");
function in_region($pos,$where) {
$region = array();
/*$region['dunes_of_exile'] = array("16254 -25988","16510 -26034","16590 -25980","16644 -25866","16616 -25752","16664 -25630","16690 -25510","16788 -25302","16844 -25174","16792 -24680","16964 -24434","17020 -24100","16266 -23846","16118 -23882","16068 -24472","15936 -24610","15924 -24884","16176 -25508","16246 -25504","16274 -25684","16278 -25852","16206 -25928","16254 -25988");
$region['frahar_towers'] = array("16968 -24444","16798 -24652","16796 -24830","16822 -24982","16830 -25072","16848 -25166","16690 -25504","16620 -25760","16646 -25872","16598 -25964","16612 -26012","16768 -26018","16782 -25988","16812 -25990","16816 -26014","16860 -26010","16916 -26052","17004 -26040","17000 -25984","17102 -25928","17136 -25856","17152 -25732","17186 -25748","17182 -25992","17208 -26018","17268 -25994","17256 -25962","17340 -25914","17338 -25866","17394 -25834","17436 -25716","17436 -25586","17448 -25386","17454 -25026","17468 -24896","17472 -24736","17586 -24560","17606 -24488","17592 -24276","17594 -24154","16968 -24444");
$region['oflovaks_oasis'] = array("17400 -25838","17420 -25890","17508 -25872","17532 -25826","17568 -25820","17610 -25840","17634 -25876","17670 -25838","17662 -25776","17702 -25726","17700 -25662","17770 -25668","17774 -25602","17798 -25558","17784 -25498","17846 -25436","17960 -25454","17994 -25432","18074 -25444","18066 -25372","18090 -25304","18092 -25046","18152 -24862","18160 -24730","18154 -24644","18168 -24326","18122 -24196","17596 -24244","17588 -24338","17606 -24502","17512 -24684","17462 -24732","17460 -24846","17464 -25000","17446 -25078","17452 -25336","17430 -25604","17440 -25688","17400 -25838");
$region['imperial_dunes'] = array("18146 -24058","18134 -24212","18166 -24314","18154 -24648","18162 -24758","18130 -24936","18092 -25054","18090 -25308","18174 -25338","18236 -25420","18258 -25422","18274 -25466","18368 -25462","18454 -25496","18534 -25482","18570 -25420","18546 -25378","18560 -25332","18540 -25306","18548 -25250","18508 -25204","18572 -25178","18570 -25128","18602 -25114","18578 -25048","18586 -25016","18664 -25012","18668 -24964","18642 -24868","18660 -24784","18718 -24784","18702 -24846","18708 -24894","18724 -24940","18768 -24958","18762 -24890","18804 -24880","18822 -24844","18862 -24842","18888 -24862","18960 -24800","19012 -24830","19068 -24800","19124 -24776","19124 -24750","19066 -24730","19058 -24690","19102 -24668","19152 -24686","19224 -24622","19192 -24584","19220 -24532","19248 -24550","19320 -24476","19292 -24434","19320 -24404","19292 -24354","19330 -24322","19366 -24362","19406 -24356","19426 -24308","19506 -24274","19490 -24228","19592 -24042","-256048 -628","-256584 -628","18146 -24058");
$region['outlaw_canyon'] = array("18518 -25216","18560 -25262","18538 -25298","18558 -25342","18546 -25390","18576 -25420","18554 -25504","18518 -25548","18564 -25622","18560 -25708","18624 -25766","18660 -25852","18680 -25918","18726 -25970","18756 -26052","18800 -26090","18854 -26088","18878 -26122","18932 -26104","18932 -26046","18972 -26032","19044 -26056","19080 -26008","19122 -26064","19166 -26032","19220 -26112","19270 -26084","19254 -26022","19288 -25994","19392 -25972","19462 -26006","19536 -25966","19430 -25932","19326 -25918","19216 -25956","19110 -25906","19148 -25878","19130 -25822","19226 -25800","19158 -25766","19198 -25726","19202 -25676","19252 -25682","19264 -25612","19242 -25582","19196 -25586","19186 -25554","19232 -25546","19240 -25486","19312 -25484","19332 -25422","19378 -25396","19364 -25350","19398 -25344","19362 -25300","19364 -25238","19434 -25226","19456 -25272","19496 -25264","19504 -25208","19446 -25166","19502 -25118","19570 -25146","19590 -25082","19670 -24994","19734 -25000","19752 -24970","19742 -24938","19784 -24922","19860 -24974","19890 -24948","19876 -24892","19810 -24858","19862 -24798","19970 -24840","19958 -24896","19986 -24996","20020 -24884","20026 -24770","20086 -24722","20130 -24698","20196 -24704","20294 -24668","20310 -24618","20274 -24376","20034 -24250","19940 -24152","19772 -24088","19526 -24136","19494 -24228","19494 -24290","19434 -24308","19380 -24368","19330 -24330","19294 -24362","19314 -24412","19292 -24446","19310 -24484","19254 -24544","19218 -24536","19184 -24582","19224 -24616","19146 -24686","19080 -24666","19052 -24714","19144 -24762","19012 -24826","18956 -24802","18884 -24862","18842 -24840","18758 -24904","18770 -24956","18708 -24948","18720 -24900","18706 -24776","18652 -24776","18638 -24888","18666 -25002","18580 -25028","18604 -25122","18576 -25136","18560 -25198","18518 -25216");
$region['sawdust_mines'] = array("19284 -26078","19368 -26066","19660 -26082","19726 -26112","19786 -26070","19970 -26100","20094 -26078","19940 -25808","20222 -25488","20308 -25234","20314 -25064","20208 -24702","20122 -24704","20026 -24776","20012 -24930","19994 -25000","19948 -24896","19974 -24846","19872 -24808","19802 -24854","19886 -24904","19886 -24956","19850 -24974","19776 -24928","19732 -24948","19752 -24976","19710 -25000","19664 -24992","19608 -25096","19578 -25098","19572 -25136","19490 -25118","19450 -25176","19504 -25226","19500 -25268","19440 -25260","19422 -25228","19360 -25236","19370 -25310","19398 -25356","19306 -25460","19308 -25498","19236 -25504","19228 -25550","19188 -25562","19198 -25592","19244 -25586","19272 -25626","19254 -25676","19200 -25676","19182 -25742","19152 -25778","19224 -25798","19164 -25822","19126 -25824","19130 -25880","19098 -25904","19212 -25958","19340 -25916","19514 -25968","19470 -26006","19378 -25978","19280 -25994","19254 -26032","19284 -26078");
$region['savage_dunes'] = array("19272 -26074","19466 -26068","19718 -26102","19834 -26068","19978 -26096","20036 -26088","20310 -26460","20320 -26682","20320 -26800","20280 -26958","20206 -27022","19926 -26970","18092 -26922","18096 -26758","18032 -26680","17994 -26678","17956 -26610","18106 -26610","18116 -26576","18174 -26558","18210 -26602","18268 -26570","18296 -26606","18362 -26596","18410 -26622","18482 -26582","18534 -26568","18538 -26510","18466 -26462","18486 -26424","18568 -26398","18608 -26404","18648 -26392","18624 -26314","18646 -26244","18694 -26244","18688 -26202","18722 -26192","18728 -26116","18814 -26128","18824 -26090","18892 -26124","18936 -26094","18936 -26048","18968 -26032","19040 -26062","19082 -26008","19116 -26058","19164 -26026","19220 -26116","19272 -26074");
$region['scorched_corridor'] = array("17954 -26620","17108 -26814","16788 -26780","16274 -26616","16012 -26236","16094 -26036","16252 -26000","16504 -26054","16606 -25978","16618 -26022","16764 -26020","16786 -25970","16822 -26022","16872 -26010","16922 -26064","17004 -26036","17002 -25974","17134 -25914","17148 -25714","17196 -25760","17186 -25816","17200 -25876","17184 -25932","17208 -26022","17268 -26006","17254 -25954","17346 -25918","17346 -25854","17392 -25834","17426 -25888","17512 -25862","17534 -25818","17594 -25832","17636 -25874","17670 -25840","17666 -25772","17700 -25726","17692 -25654","17762 -25666","17796 -25552","17786 -25494","17842 -25438","18070 -25442","18068 -25364","18084 -25312","18176 -25338","18270 -25462","18548 -25492","18526 -25550","18572 -25648","18562 -25710","18618 -25762","18668 -25864","18698 -25952","18738 -25988","18778 -26074","18832 -26098","18782 -26134","18720 -26120","18724 -26196","18684 -26214","18676 -26252","18630 -26262","18650 -26394","18588 -26410","18492 -26438","18474 -26476","18542 -26526","18528 -26580","18430 -26618","18342 -26598","18290 -26604","18260 -26578","18200 -26602","18170 -26562","18114 -26584","18092 -26610","17954 -26620");
$region['nexus_minor'] = array("9160 -6100","7852 -6740","7892 -7168","8120 -7420","8356 -7612","8560 -7672","8668 -8320","-252676 -7900","9340 -7732","9436 -7352","9752 -7312","9668 -6640","9580 -6104","9160 -6100");
$region['winds_of_muse'] = array("14476 -30936","15300 -30864","15228 -31408","15460 -31656","15988 -31496","17036 -30592","16932 -29720","16460 -29528","15580 -29608","15116 -29680","14988 -29984","14588 -30000","14308 -30624","14476 -30936");
$region['bounty_beaches'] = array("14364 -31280","15172 -31280","15364 -31688","15228 -32184","15260 -33280","14924 -33320","14676 -33200","14284 -33336","13788 -33008","13764 -32784","13760 -32356","13852 -32080","13768 -31876","13780 -31636","13792 -31428","14364 -31280");
$region['fount'] = array("14276 -33456","14668 -33144","15052 -33440","15500 -33376","15916 -34232","16244 -34288","16284 -34632","15732 -34864","15396 -34800","14636 -34864","14268 -34592","14276 -33456");
$region['enchanted_isle'] = array("17036 -34072","16764 -34352","16956 -34744","17348 -34856","17668 -34864","18164 -34672","18388 -34520","18660 -34456","18636 -33584","18612 -33264","17428 -33472","17060 -33680","17036 -34072");
$region['liberty_lake'] = array("15228 -32288","15292 -32720","15284 -33256","15804 -33696","15848 -33752","16016 -33596","16180 -33444","16308 -33348","16408 -33328","16416 -33244","16580 -33180","16656 -33352","16844 -33516","17260 -33576","17980 -33320","18628 -33264","18740 -32512","18700 -31224","18668 -30600","17844 -30624","17796 -30856","17684 -31024","17640 -31324","17508 -31564","17620 -31684","17736 -31736","17768 -31812","17724 -31916","17524 -31948","17372 -32020","17380 -32116","17316 -32144","17292 -32252","17240 -32156","17116 -32124","16952 -32212","16892 -32124","16800 -32084","16784 -32000","16672 -31976","16604 -31912","16516 -31916","16468 -31848","16540 -31804","16480 -31760","16476 -31700","16180 -31432","15312 -31964","15228 -32288");
$region['dew_drops'] = array("17116 -30504","16188 -31392","16322 -31574","16476 -31706","16486 -31766","16546 -31806","16464 -31850","16534 -31934","16592 -31912","16694 -31982","16778 -31994","16800 -32086","16896 -32126","16944 -32212","17028 -32182","17102 -32128","17218 -32144","17270 -32186","17284 -32246","17322 -32240","17318 -32148","17386 -32116","17378 -32004","17554 -31936","17728 -31920","17776 -31814","17734 -31732","17632 -31690","17526 -31580","17514 -31552","17632 -31346","17686 -31030","17802 -30856","17850 -30658","17116 -30504");
$region['lagoons_of_loria'] = array("16956 -29960","17116 -30488","18540 -30472","18724 -30952","18700 -32000","19116 -32272","19776 -32084","19740 -31316","20000 -30688","19972 -29992","19476 -29760","19204 -29464","17988 -29456","17544 -29496","16956 -29960");
$region['resting_water'] = array("15748 -33856","15944 -34232","16352 -34384","16800 -34364","17048 -34040","17032 -33612","16886 -33542","16726 -33416","16646 -33354","16614 -33200","16530 -33196","16470 -33240","16430 -33246","16410 -33326","16286 -33366","16196 -33428","16130 -33496","16060 -33534","16022 -33612","15938 -33648","15908 -33698","15766 -33800","15748 -33856");
$region['hidden_source'] = array("356 -964","912 -1552","1244 -1940","1422 -2004","1546 -1918","1642 -1956","1674 -2012","1730 -2008","1758 -2040","1836 -2020","1832 -1968","1868 -1958","1876 -1888","2024 -1848","2048 -1800","2092 -1802","2108 -1756","2154 -1774","2202 -1764","2234 -1726","2196 -1674","2230 -1596","2266 -1588","2282 -1548","2350 -1518","2324 -1480","2334 -1448","2368 -1442","2374 -1350","2430 -1316","2466 -1322","2522 -1256","1996 -580","1560 -336","1236 -324","636 -416","320 -664","356 -964");
$region['knoll_of_dissent'] = array("1256 -2232","1976 -2888","2816 -2856","2988 -2790","3132 -2698","3274 -2624","3366 -2552","3522 -2542","3580 -2568","3656 -2566","3684 -2498","3836 -2412","4492 -2148","4460 -2042","4382 -1890","4320 -1848","4284 -1802","4204 -1742","4154 -1656","4080 -1620","3990 -1540","3942 -1522","3854 -1406","3780 -1388","3742 -1326","3590 -1180","2536 -1236","2472 -1310","2378 -1342","2366 -1444","2320 -1464","2340 -1524","2288 -1540","2268 -1582","2230 -1602","2196 -1674","2236 -1728","2198 -1766","2116 -1766","2078 -1800","2032 -1816","2030 -1850","1880 -1882","1866 -1962","1836 -1966","1832 -2020","1758 -2032","1726 -2012","1674 -2008","1638 -1952","1556 -1922","1296 -2072","1256 -2232");
$region['grove_of_confusion'] = array("3590 -1182","3748 -1330","3780 -1388","3858 -1402","3944 -1532","3986 -1534","4084 -1630","4140 -1644","4214 -1756","4304 -1822","4336 -1872","4372 -1882","4566 -2240","5292 -1924","6240 -1280","6240 -320","4352 -320","3664 -560","3590 -1182");
$region['majestic_garden'] = array("3842 -2410","3688 -2498","3654 -2570","3576 -2576","3524 -2544","3368 -2560","3234 -2644","3198 -2676","3106 -2706","2850 -2882","3320 -3472","3216 -3968","4240 -4764","4360 -4856","4428 -4844","4556 -4876","4632 -4868","4690 -4904","4756 -4926","4814 -4954","5232 -4934","5412 -4376","5124 -3908","5160 -3380","4936 -2948","4256 -2820","4184 -2564","3842 -2410");
$region['fleeting_garden'] = array("4056 -4740","4242 -4754","4354 -4852","4428 -4848","4540 -4876","4638 -4870","4690 -4912","4756 -4920","4810 -4954","5130 -4940","5424 -5552","6020 -5536","6176 -5656","6240 -6368","5988 -6440","5830 -6372","5722 -6286","5626 -6270","5572 -6224","5346 -6242","5302 -6270","5184 -6274","5100 -6306","4822 -6380","4552 -6020","4474 -5804","4410 -5718","4324 -5582","4202 -5416","4110 -5410","4036 -5354","4010 -5282","3812 -5116","3650 -4904","3902 -4726","4056 -4740");
$region['upper_bog'] = array("4588 -6150","4480 -5818","4416 -5720","4318 -5572","4210 -5426","4110 -5412","4044 -5356","4010 -5284","3810 -5112","3642 -4892","3388 -5268","3100 -5712","2904 -6848","2768 -7792","3636 -7788","4616 -7776","4520 -7288","4688 -6664","4588 -6150");
$region['heretics_hovel'] = array("4704 -6644","4444 -7236","4444 -7808","5784 -7832","6236 -7828","6236 -7096","6080 -6496","5906 -6396","5820 -6368","5758 -6320","5718 -6278","5628 -6270","5562 -6224","5440 -6240","5342 -6240","5304 -6274","5190 -6272","5120 -6302","5044 -6312","4806 -6388","4704 -6644");
$region['knot_of_dementia'] = array("6880 -1752","6884 -2472","7300 -3436","7904 -4088","8240 -4024","8404 -3908","8496 -3820","8620 -3720","8644 -3670","8614 -3636","8614 -3570","8652 -3546","8638 -3230","8596 -3198","8512 -3196","8454 -3098","8444 -2850","8466 -2654","8518 -2550","8802 -2558","8810 -2252","8924 -2206","8966 -2080","8958 -1982","9120 -1746","9184 -1542","9214 -1352","8800 -984","8296 -1016","7748 -1156","7352 -1340","7140 -1508","6880 -1544","6880 -1752");
$region['haven_of_purity'] = array("9222 -1344","9188 -1464","9178 -1574","9162 -1660","8958 -1978","8964 -2080","8924 -2214","8818 -2254","8792 -2582","8824 -2636","8752 -2712","8800 -2800","8816 -2866","8868 -2906","8954 -2880","9070 -2874","9114 -2926","9136 -3006","9192 -3052","9230 -3050","9280 -3106","9280 -3148","9330 -3198","9440 -3204","9498 -3322","9616 -3358","9876 -3356","9924 -3286","9918 -3202","9962 -3156","10082 -3038","10090 -2996","10022 -2956","10080 -2890","10128 -2856","10216 -2864","10238 -2830","10234 -2620","10142 -2542","10138 -2498","10080 -2484","10032 -2410","9846 -2388","9754 -2284","9758 -2116","9702 -1928","9662 -1506","9664 -1450","9854 -1276","9474 -1120","9274 -1146","9222 -1344");
$region['void'] = array("9808 -1342","9658 -1470","9672 -1640","9694 -1898","9724 -1996","9758 -2126","9754 -2286","9818 -2360","9832 -2394","10010 -2402","10046 -2420","10074 -2490","10134 -2494","10148 -2558","10222 -2602","10238 -2692","10290 -2718","10362 -2718","10406 -2788","10416 -2836","10484 -2884","10670 -2868","10730 -2852","10836 -2886","10878 -2958","10886 -3126","10950 -3198","11084 -3196","11128 -3240","11182 -3230","11206 -3178","11196 -2952","11284 -2870","11354 -2888","11432 -2868","11448 -2892","11420 -2914","11504 -2898","11528 -2858","11522 -2782","11588 -2722","11758 -2694","11904 -2638","11996 -2604","12054 -2614","12274 -2550","12428 -2516","12480 -2476","12480 -1232","11952 -980","10496 -1008","9808 -1342");
$region['cities_of_intuition'] = array("8086 -4048","8204 -4032","8348 -3958","8466 -3848","8558 -3784","8638 -3690","8612 -3578","8648 -3530","8634 -3228","8514 -3192","8456 -3108","8436 -2858","8474 -2632","8510 -2552","8792 -2554","8806 -2618","8828 -2638","8756 -2706","8756 -2750","8800 -2790","8810 -2866","8866 -2910","8950 -2878","9062 -2878","9126 -2948","9142 -3014","9236 -3056","9282 -3102","9284 -3158","9330 -3200","9442 -3200","9498 -3322","9634 -3358","9876 -3358","9950 -3346","10092 -3366","10168 -3410","10244 -3382","10240 -3504","10286 -3664","10346 -3668","10432 -3732","10408 -3848","10438 -3940","10376 -4002","10162 -3994","10084 -4060","10074 -4154","10152 -4250","10120 -4272","10084 -4366","10014 -4370","9936 -4326","9756 -4334","9400 -4588","9128 -4452","9008 -4176","8920 -4096","8236 -4112","8086 -4048");
$region['grove_of_umbra'] = array("9418 -4580","9616 -4422","9776 -4330","9932 -4324","10024 -4368","10092 -4370","10114 -4284","10154 -4246","10076 -4146","10098 -4046","10162 -3990","10380 -4008","10404 -4100","10472 -4156","10580 -4132","10696 -4160","10840 -4156","10890 -4090","10914 -4020","11006 -3970","11084 -3852","11136 -3832","11442 -3838","11502 -3890","11530 -3956","11590 -4008","11732 -3998","11860 -3992","12024 -3910","12240 -3804","12448 -3796","12468 -5896","11328 -5888","9756 -5340","9524 -5128","9418 -4580");
$region['maiden_grove'] = array("12272 -3794","12012 -3918","11870 -3988","11594 -4006","11520 -3934","11456 -3842","11272 -3830","11094 -3840","11002 -3974","10930 -4004","10888 -4062","10878 -4112","10834 -4150","10694 -4160","10602 -4132","10484 -4156","10404 -4098","10378 -4002","10442 -3936","10408 -3862","10430 -3760","10412 -3712","10330 -3660","10290 -3660","10254 -3588","10238 -3476","10236 -3378","10178 -3406","10092 -3362","9930 -3344","9876 -3348","9924 -3280","9922 -3192","10084 -3028","10088 -2990","10026 -2956","10088 -2878","10154 -2852","10216 -2868","10236 -2828","10236 -2690","10276 -2714","10352 -2716","10410 -2788","10416 -2834","10476 -2882","10662 -2868","10726 -2846","10820 -2874","10878 -2946","10886 -3086","10890 -3134","10948 -3200","11084 -3198","11124 -3236","11184 -3228","11206 -3176","11196 -2950","11224 -2912","11280 -2874","11346 -2884","11424 -2864","11428 -2904","11490 -2904","11522 -2860","11516 -2782","11574 -2720","11738 -2700","11994 -2600","12046 -2614","12346 -2540","12416 -2524","12432 -2860","12448 -3460","12272 -3794");
$region['under_spring'] = array("2596 -10496","2576 -10716","2628 -10912","3160 -11264","3436 -11272","3666 -11044","3726 -10666","3828 -10538","3782 -9890","3542 -9788","3348 -9788","2914 -10028","2612 -10276","2596 -10496");
$region['land_of_continuity'] = array("452 -13296","184 -13676","-259776 -5920","540 -14856","1176 -15120","1324 -14824","1420 -14784","1572 -14760","1920 -14528","1756 -14120","1740 -13752","1584 -13740","1636 -13392","1196 -13124","652 -13140","452 -13296");
$region['sunken_city'] = array("1768 -14184","1904 -14540","2696 -14556","2948 -14420","2924 -13780","2404 -13144","1852 -13132","1616 -13416","1604 -13708","1748 -13760","1768 -14184");
$region['forbidden_depths'] = array("1956 -14552","2716 -14568","3020 -14696","3020 -15352","2500 -15784","1956 -15840","1844 -15440","1108 -15240","1324 -14680","1956 -14552");
$region['windy_gate'] = array("5496 -10240","5480 -10904","5648 -11960","5888 -12000","6072 -12000","6192 -12016","6296 -11984","6468 -11988","6416 -11100","6332 -10148","6240 -9700","5952 -9644","5580 -9632","5444 -9888","5496 -10240");
$region['elusive_forest'] = array("5666 -11962","5898 -11996","6082 -12002","6198 -12022","6290 -11988","6448 -11996","6710 -11978","6756 -12280","7324 -12296","7348 -12824","6792 -13152","6660 -13588","6468 -13584","6300 -13612","6064 -13604","5828 -13564","5728 -12892","5568 -12160","5666 -11962");
$region['gate_of_obscurity'] = array("5922 -13596","6094 -13612","6306 -13618","6486 -13582","6670 -13584","6776 -14124","6876 -14592","6732 -15212","6908 -15308","6864 -15836","6712 -15854","6638 -15842","6530 -15854","6338 -15698","6120 -15410","6162 -14942","6154 -14562","5842 -14432","5954 -14004","5922 -13596");
$region['trench_of_trials'] = array("6348 -15714","6520 -15852","6664 -15846","6812 -15860","7022 -16332","7078 -16776","7082 -16900","6900 -16946","6582 -16892","6450 -16618","6150 -16906","5914 -16922","5526 -16926","5450 -16668","5462 -16394","5840 -16174","5882 -15768","5990 -15566","6348 -15714");
$region['abyss_of_ichor'] = array("492 -10932","508 -11288","672 -11348","924 -11328","1148 -11088","1488 -11164","1588 -10952","1568 -10636","1596 -9816","1004 -9768","852 -9812","616 -10296","484 -10652","492 -10932");*/
$region['silan_shining_lake'] = array("8876 -11020","8788 -10664","9020 -10528","9236 -10560","9348 -10820","9212 -11020","8876 -11020");
$region['silan_throne_room'] = array("9580 -10552","9412 -10740","9516 -10900","9876 -10840","10008 -10636","9792 -10468","9580 -10552");
$region['silan_blight_zone'] = array("9372 -10992","9224 -11112","9096 -11280","9076 -11664","9208 -11836","9772 -11832","9840 -11356","9604 -11036","9372 -10992");
$region['silan_arena'] = array("10208 -11534","10098 -11532","10092 -11644","10166 -11700","10218 -11694","10208 -11534");
$region['silan_hunting_grounds'] = array("10472 -10676","10212 -10980","10356 -11364","10988 -11512","11260 -11092","11060 -10760","10472 -10676");
$region['silan_rangers_land'] = array("10256 -11608","10186 -11652","10204 -11718","10338 -11710","10356 -11630","10256 -11608");
$region['silan_kami'] = array("10398 -11636","10338 -11670","10356 -11702","10488 -11708","10494 -11672","10398 -11636");
$region['silan_karavan'] = array("10314 -11814","10292 -11884","10498 -11888","10512 -11828","10314 -11814");
echo "pos!";
if(!isset($region[$where])) {
echo "unknown";
return false;
}
else {
$points = array();
//load charpos & petpos
#$comp = $DBc->sendSQL("SELECT c_pos_x,c_pos_y FROM ryzom_character WHERE c_xmlid='".$xmlid."'","ARRAY");
#$points[] = floor($comp[0]['c_pos_x'])." ".floor($comp[0]['c_pos_y']);
$points[] = floor($pos->x/1000)." ".floor($pos->y/1000);
$pointLocation = new pointLocation();
foreach($points as $point) {
if($pointLocation->pointInPolygon($point, $region[$where], false) != "outside") {
return true;
}
}
echo "false";
return false;
}
}
?>

View file

@ -0,0 +1,68 @@
<?php
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;
}
}
}
function pointStringToCoordinates($pointString) {
$coordinates = explode(" ", $pointString);
return array("x" => $coordinates[0], "y" => $coordinates[1]);
}
}
?>

View file

@ -1,9 +1,34 @@
<?php
$BASE_PATH = dirname(__FILE__);
require_once($BASE_PATH."/entity/FactionPoints_entity.php");
require_once($BASE_PATH."/entity/Fame_entity.php");
require_once($BASE_PATH."/entity/Item_entity.php");
require_once($BASE_PATH."/entity/LastLogStats_entity.php");
require_once($BASE_PATH."/entity/Mission_entity.php");
require_once($BASE_PATH."/entity/PermanentMod_entity.php");
require_once($BASE_PATH."/entity/Pet_entity.php");
require_once($BASE_PATH."/entity/PhysCharacs_entity.php");
require_once($BASE_PATH."/entity/PhysScores_entity.php");
require_once($BASE_PATH."/entity/SkillPoints_entity.php");
require_once($BASE_PATH."/entity/Skills_entity.php");
require_once($BASE_PATH."/entity/SpentSkillPoints_entity.php");
require_once($BASE_PATH."/entity/Position_entity.php");
require_once($BASE_PATH."/entity/Gear_entity.php");
require_once($BASE_PATH."/entity/SkillList_entity.php");
require_once($BASE_PATH."/entity/MissionList_entity.php");
class PDRtoXMLdriver extends SourceDriver {
private $conf;
private $ignore;
private $ignore_block;
private $lock;
private $open;
private $entity;
private $inv;
private $iblock;
private $gear;
private $skills;
function PDRtoXMLdriver() {
require_once("conf.php");
@ -12,21 +37,31 @@
$this->lock = 0;
$this->open = null;
$this->entity = null;
$this->inv = null;
$this->iblock = false;
$this->gear = new Gear();
$this->skills = new SkillList();
$this->mission = new MissionList();
//these nodes are ignored, but children are processed
$this->ignore = array();
$this->ignore[] = "XML";
$this->ignore[] = "ENTITYBASE";
$this->ignore[] = "NORMALPOSITIONS";
$this->ignore[] = "_VEC";
$this->ignore[] = "SESSIONID";
$this->ignore[] = "POSSTATE";
#$this->ignore[] = "POSSTATE";
$this->ignore[] = "_PLAYERROOM";
$this->ignore[] = "_INVENTORYID";
$this->ignore[] = "_PHYSCHARACS";
$this->ignore[] = "_PHYSSCORES";
$this->ignore[] = "_SKILLS";
$this->ignore[] = "_FAMES";
//these nodes are ignored, as well as their children
$this->ignore_block = array();
$this->ignore_block[] = "_MEMORIZEDPHRASES";
$this->ignore_block[] = "_FORBIDPOWERDATES";
@ -45,7 +80,7 @@
}
function drive($cid) {
global $CONF;
global $CONF,$_DISPATCHER;
echo "kk";
@ -64,6 +99,10 @@
echo "error";
}
xml_parser_free($xml_parser);
$_DISPATCHER->dispatchEntity($this->gear->getName(),$this->gear);
$_DISPATCHER->dispatchEntity($this->skills->getName(),$this->skills);
$_DISPATCHER->dispatchEntity($this->skills->mission(),$this->mission);
}
function startElement($parser, $name, $attrs) {
@ -81,17 +120,624 @@
$this->lock = 1;
return null;
}
/* faction points */
if($name == "FACTIONPOINTS") {
$this->open = "FACTIONPOINTS";
return null;
}
if($this->open == "FACTIONPOINTS") {
if($name == "__KEY__") {
$this->entity = new FactionPoints();
$this->entity->faction = $attrs["VALUE"];
return null;
}
if($name == "__VAL__") {
$this->entity->value = $attrs["VALUE"];
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
$this->entity = null;
return null;
}
return null;
}
/* Fame */
if($name == "_FAME") {
$this->open = "_FAME";
return null;
}
if($this->open == "_FAME") {
if($name == "__KEY__") {
$this->entity = new Fame();
$this->entity->faction = $attrs["VALUE"];
return null;
}
if($name == "FAME") {
$this->entity->fame = $attrs["VALUE"];
return null;
}
if($name == "FAMEMEMORY") {
$this->entity->famememory = $attrs["VALUE"];
return null;
}
if($name == "LASTFAMECHANGETREND") {
$this->entity->lastfamechangetrend = $attrs["VALUE"];
return null;
}
return null;
}
/* last log stats */
if($name == "_LASTLOGSTATS") {
$this->open = "_LASTLOGSTATS";
$this->entity = new LastLogStats();
return null;
}
if($this->open == "_LASTLOGSTATS") {
if($name == "LOGINTIME") {
$this->entity->logintime = $attrs["VALUE"];
return null;
}
if($name == "DURATION") {
$this->entity->duration = $attrs["VALUE"];
return null;
}
if($name == "LOGOFFTIME") {
$this->entity->logofftime = $attrs["VALUE"];
return null;
}
return null;
}
/* mission */
if($name == "_MISSIONHISTORIES") {
$this->open = "_MISSIONHISTORIES";
return null;
}
if($this->open == "_MISSIONHISTORIES") {
if($name == "__KEY__") {
$this->entity = new Mission();
$this->entity->mission = $attrs["VALUE"];
return null;
}
if($name == "SUCCESSFULL") {
$this->entity->successfull = $attrs["VALUE"];
return null;
}
if($name == "UTC_LASTSUCCESSDATE") {
$this->entity->utc_lastsuccessdate = $attrs["VALUE"];
return null;
}
return null;
}
/* permanent mod */
if($name == "SCOREPERMANENTMODIFIERS") {
$this->open = "SCOREPERMANENTMODIFIERS";
return null;
}
if($this->open == "SCOREPERMANENTMODIFIERS") {
if($name == "__KEY__") {
$this->entity = new PermanentMod();
$this->entity->score = $attrs["VALUE"];
return null;
}
if($name == "__VAL__") {
$this->entity->value = $attrs["VALUE"];
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
$this->entity = null;
return null;
}
return null;
}
/* pet */
if($name == "_PLAYERPETS") {
$this->open = "_PLAYERPETS";
return null;
}
if($this->open == "_PLAYERPETS") {
if($name == "__KEY__") {
$this->entity = new Pet();
$this->entity->pet = $attrs["VALUE"];
return null;
}
if($name == "TICKETPETSHEETID") {
$this->entity->ticketpetsheetid = $attrs["VALUE"];
return null;
}
if($name == "PETSHEETID") {
$this->entity->petsheetid = $attrs["VALUE"];
return null;
}
if($name == "PRICE") {
$this->entity->price = $attrs["VALUE"];
return null;
}
if($name == "OWNERID") {
$this->entity->ownerid = $attrs["VALUE"];
return null;
}
if($name == "STABLEALIAS") {
$this->entity->stablealias = $attrs["VALUE"];
return null;
}
if($name == "LANDSCAPE_X") {
$this->entity->landscape_x = $attrs["VALUE"];
return null;
}
if($name == "LANDSCAPE_Y") {
$this->entity->landscape_y = $attrs["VALUE"];
return null;
}
if($name == "LANDSCAPE_Z") {
$this->entity->landscape_z = $attrs["VALUE"];
return null;
}
if($name == "UTC_DEATHTICK") {
$this->entity->utc_deathtick = $attrs["VALUE"];
return null;
}
if($name == "PETSTATUS") {
$this->entity->petstatus = $attrs["VALUE"];
return null;
}
if($name == "SLOT") {
$this->entity->slot = $attrs["VALUE"];
return null;
}
if($name == "ISTPALLOWED") {
$this->entity->istpallowed = $attrs["VALUE"];
return null;
}
if($name == "SATIETY") {
$this->entity->satiety = $attrs["VALUE"];
return null;
}
if($name == "CUSTOMNAME") {
$this->entity->customname = $attrs["VALUE"];
return null;
}
return null;
}
/* physical characteristics */
if($name == "_PHYSICALCHARACTERISTICS") {
$this->open = "_PHYSICALCHARACTERISTICS";
return null;
}
if($this->open == "_PHYSICALCHARACTERISTICS") {
if($name == "__KEY__") {
$this->entity = new PhysCharacs();
$this->entity->charac = $attrs["VALUE"];
return null;
}
if($name == "__VAL__") {
$this->entity->value = $attrs["VALUE"];
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
$this->entity = null;
return null;
}
return null;
}
/* physical scores */
if($name == "PHYSICALSCORES") {
$this->open = "PHYSICALSCORES";
return null;
}
if($this->open == "PHYSICALSCORES") {
if($name == "__KEY__") {
$this->entity = new PhysScores();
$this->entity->score = $attrs["VALUE"];
return null;
}
if($name == "CURRENT") {
$this->entity->current = $attrs["VALUE"];
return null;
}
if($name == "BASE") {
$this->entity->base = $attrs["VALUE"];
return null;
}
if($name == "MAX") {
$this->entity->max = $attrs["VALUE"];
return null;
}
if($name == "BASEREGENERATEREPOS") {
$this->entity->baseregeneraterepos = $attrs["VALUE"];
return null;
}
if($name == "BASEREGENERATEACTION") {
$this->entity->baseregenerateaction = $attrs["VALUE"];
return null;
}
if($name == "CURRENTREGENERATE") {
$this->entity->currentregenerate = $attrs["VALUE"];
return null;
}
return null;
}
/* skill points */
if($name == "SKILLPOINTS") {
$this->open = "SKILLPOINTS";
return null;
}
if($this->open == "SKILLPOINTS") {
if($name == "__KEY__") {
$this->entity = new SkillPoints();
$this->entity->skill = $attrs["VALUE"];
return null;
}
if($name == "__VAL__") {
$this->entity->value = $attrs["VALUE"];
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
$this->entity = null;
return null;
}
return null;
}
/* spent skill points */
if($name == "SPENTSKILLPOINTS") {
$this->open = "SPENTSKILLPOINTS";
return null;
}
if($this->open == "SPENTSKILLPOINTS") {
if($name == "__KEY__") {
$this->entity = new SpentSkillPoints();
$this->entity->skill = $attrs["VALUE"];
return null;
}
if($name == "__VAL__") {
$this->entity->value = $attrs["VALUE"];
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
$this->entity = null;
return null;
}
return null;
}
/* skills */
if($name == "SKILLS") {
$this->open = "SKILLS";
return null;
}
if($this->open == "SKILLS") {
if($name == "__KEY__") {
$this->entity = new Skills();
$this->entity->skill = $attrs["VALUE"];
return null;
}
if($name == "BASE") {
$this->entity->base = $attrs["VALUE"];
return null;
}
if($name == "CURRENT") {
$this->entity->current = $attrs["VALUE"];
return null;
}
if($name == "MAXLVLREACHED") {
$this->entity->maxlvlreached = $attrs["VALUE"];
return null;
}
if($name == "XP") {
$this->entity->xp = $attrs["VALUE"];
return null;
}
if($name == "XPNEXTLVL") {
$this->entity->xpnextlvl = $attrs["VALUE"];
return null;
}
return null;
}
/* Position */
if($name == "POSSTATE") {
$this->open = "POSSTATE";
$this->entity = new Position();
return null;
}
if($this->open == "POSSTATE") {
if($name == "X") {
$this->entity->x = $attrs["VALUE"];
return null;
}
if($name == "Y") {
$this->entity->y = $attrs["VALUE"];
return null;
}
if($name == "Z") {
$this->entity->z = $attrs["VALUE"];
return null;
}
if($name == "HEADING") {
$this->entity->heading = $attrs["VALUE"];
return null;
}
return null;
}
/* items */
if($name == "ROOMINVENTORY") {
$this->inv = "room";
return null;
}
if($name == "INVENTORY") {
$this->iblock = true;
return null;
}
if($this->iblock == true) {
if($name == "__KEY__") {
$this->inv = $attrs["VALUE"];
}
if($name == "__VAL__") {
return null;
}
}
if($name == "_ITEMS" || $name == "_ITEM") {
$this->open = "_ITEM";
$this->entity = new Item();
$this->entity->inventory = $this->inv;
return null;
}
if($this->open == "_ITEM") {
if($name == "_CRAFTPARAMETERS") {
$this->icraft = true;
return null;
}
if($this->icraft == true) {
$this->entity->_craftparameters[strtolower($name)] = $attrs["VALUE"];
return null;
}
if($name == "_ITEMID") {
$this->entity->_itemid = $attrs["VALUE"];
return null;
}
if($name == "_SHEETID") {
$this->entity->_sheetid = $attrs["VALUE"];
return null;
}
if($name == "_LOCSLOT") {
$this->entity->_locslot = $attrs["VALUE"];
return null;
}
if($name == "_HP") {
$this->entity->_hp = $attrs["VALUE"];
return null;
}
if($name == "_RECOMMENDED") {
$this->entity->_recommended = $attrs["VALUE"];
return null;
}
if($name == "_CREATORID") {
$this->entity->_creatorid = $attrs["VALUE"];
return null;
}
if($name == "_PHRASEID") {
$this->entity->_phraseid = $attrs["VALUE"];
return null;
}
if($name == "_REFINVENTORYSLOT") {
$this->entity->_refinventoryslot = $attrs["VALUE"];
return null;
}
if($name == "REFINVENTORYID") {
$this->entity->refinventoryid = $attrs["VALUE"];
return null;
}
if($name == "_USENEWSYSTEMREQUIREMENT") {
$this->entity->_usenewsystemrequirement = $attrs["VALUE"];
return null;
}
if($name == "_REQUIREDSKILLLEVEL") {
$this->entity->_requiredskilllevel = $attrs["VALUE"];
return null;
}
if($name == "_CUSTOMTEXT") {
$this->entity->_customtext = $attrs["VALUE"];
return null;
}
if($name == "_LOCKEDBYOWNER") {
$this->entity->_lockedbyowner = $attrs["VALUE"];
return null;
}
if($name == "_DROPABLE") {
$this->entity->_dropable = $attrs["VALUE"];
return null;
}
if($name == "STACKSIZE") {
$this->entity->stacksize = $attrs["VALUE"];
return null;
}
}
if($attrs["VALUE"] != "") {
echo "dispatching";
$_DISPATCHER->dispatchValue(strtolower($name),$attrs["VALUE"]);
}
}
function endElement($parser, $name) {
global $_DISPATCHER;
if(in_array($name,$this->ignore_block)) {
$this->lock = 0;
}
/* faction points */
if($name == "FACTIONPOINTS") {
$this->open = null;
return null;
}
/* fame */
if($name == "__VAL__" && $this->open == "FAME") {
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
$this->entity = null;
return null;
}
if($name == "_FAME") {
$this->open = null;
return null;
}
/* last log stats */
if($name == "_LASTLOGSTATS") {
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
$this->entity = null;
return null;
}
/* mission */
if($name == "__VAL__" && $this->open == "_MISSIONHISTORIES") {
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
$this->mission->missions[] = $this->entity;
$this->entity = null;
return null;
}
if($name == "_MISSIONHISTORIES") {
$this->open = null;
return null;
}
/* permanent mod */
if($name == "SCOREPERMANENTMODIFIERS") {
$this->open = null;
return null;
}
/* pet */
if($name == "__VAL__" && $this->open == "_PLAYERPETS") {
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
#echo "dispatched";
$this->entity = null;
return null;
}
if($name == "_PLAYERPETS") {
$this->open = null;
return null;
}
/* physical characteristics */
if($name == "_PHYSICALCHARACTERISTICS") {
$this->open = null;
return null;
}
/* physical scores */
if($name == "__VAL__" && $this->open == "PHYSICALSCORES") {
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
$this->entity = null;
return null;
}
if($name == "PHYSICALSCORES") {
$this->open = null;
return null;
}
/* skill points */
if($name == "SKILLPOINTS") {
$this->open = null;
return null;
}
/* spent skill points */
if($name == "SPENTSKILLPOINTS") {
$this->open = null;
return null;
}
/* skills */
if($name == "__VAL__" && $this->open == "SKILLS") {
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
$this->skills->skills[] = $this->entity;
$this->entity = null;
return null;
}
if($name == "SKILLS") {
$this->open = null;
return null;
}
/* position */
if($name == "POSSTATE") {
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
$this->entity = null;
return null;
}
/* items */
if($name == "_ITEMS") {
$_DISPATCHER->dispatchEntity($this->entity->getName(),$this->entity);
if($this->entity->refinventoryid != null) {
$this->gear->items[] = $this->entity;
}
$this->entity = null;
return null;
}
if($name == "INVENTORY") {
$this->iblock = false;
return null;
}
if($name == "_ITEM" || $name == "_ITEMS") {
$this->open = null;
return null;
}
}

View file

@ -0,0 +1,10 @@
<?php
class FactionPoints extends Entity {
public $faction;
public $value;
function FactionPoints() {
$this->setName("faction_points");
}
}
?>

View file

@ -0,0 +1,12 @@
<?php
class Fame extends Entity {
public $faction;
public $fame;
public $famememory;
public $lastfamechangetrend;
function Fame() {
$this->setName("fame");
}
}
?>

View file

@ -0,0 +1,9 @@
<?php
class Gear extends Entity {
public $items = array();
function Gear() {
$this->setName("gear");
}
}
?>

View file

@ -0,0 +1,28 @@
<?php
class Item extends Entity {
public $inventory = "";
public $_itemid = 0;
public $_sheetid = "";
public $_locslot = 0;
public $_hp = 0;
public $_recommended = "1";
public $_creatorid = "(0x0000000000:00:00:00)";
public $_phraseid = "";
public $_dropable = null;
public $stacksize = 1;
public $_usenewsystemrequirement = 1;
public $_requiredskilllevel = 0;
public $_customtext = "";
public $_lockedbyowner = 0;
public $_refinventoryslot = null;
public $refinventoryid = null;
public $_craftparameters = array();
function Item() {
$this->setName("item");
}
}
?>

View file

@ -0,0 +1,11 @@
<?php
class LastLogStats extends Entity {
public $logintime;
public $duration = 0;
public $logofftime;
function LastLogStats() {
$this->setName("lastlogstats");
}
}
?>

View file

@ -0,0 +1,9 @@
<?php
class MissionList extends Entity {
public $missions;
function MissionList() {
$this->setName("missionlist");
}
}
?>

View file

@ -0,0 +1,11 @@
<?php
class Mission extends Entity {
public $mission;
public $successful;
public $utc_lastsuccessdate;
function Mission() {
$this->setName("mission");
}
}
?>

View file

@ -0,0 +1,10 @@
<?php
class PermanentMod extends Entity {
public $score;
public $value;
function PermanentMod() {
$this->setName("permanentmodifiers");
}
}
?>

View file

@ -0,0 +1,24 @@
<?php
class Pet extends Entity {
public $pet;
public $ticketpetsheetid;
public $petsheetid;
public $pricev;
public $ownerid;
public $stablealias;
public $landscape_x;
public $landscape_y;
public $landscape_z;
public $utc_deathtick;
public $petstatus;
public $slot;
public $istpallowed;
public $satiety;
public $customname;
function Pet() {
$this->setName("pet");
#echo "created";
}
}
?>

View file

@ -0,0 +1,10 @@
<?php
class PhysCharacs extends Entity {
public $charac;
public $value;
function PhysCharacs() {
$this->setName("phys_characs");
}
}
?>

View file

@ -0,0 +1,15 @@
<?php
class PhysScores extends Entity {
public $score;
public $current;
public $base;
public $max;
public $baseregeneraterepos;
public $baseregenerateaction;
public $currentregenerate;
function PhysScores() {
$this->setName("phys_scores");
}
}
?>

View file

@ -0,0 +1,12 @@
<?php
class Position extends Entity {
public $x;
public $y;
public $z;
public $heading;
function Position() {
$this->setName("position");
}
}
?>

View file

@ -0,0 +1,9 @@
<?php
class SkillList extends Entity {
public $skills;
function SkillList() {
$this->setName("skilllist");
}
}
?>

View file

@ -0,0 +1,10 @@
<?php
class SkillPoints extends Entity {
public $skill;
public $value;
function SkillPoints() {
$this->setName("skillpoints");
}
}
?>

View file

@ -0,0 +1,14 @@
<?php
class Skill extends Entity {
public $skill;
public $current;
public $base;
public $maxlvlreached;
public $xp;
public $xpnextlvl;
function Skill() {
$this->setName("skill");
}
}
?>

View file

@ -0,0 +1,10 @@
<?php
class SpentSkillPoints extends Entity {
public $skill;
public $value;
function SpentSkillPoints() {
$this->setName("spentskillpoints");
}
}
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View file

@ -1,5 +1,8 @@
<?php
class AchAchievement extends AchList {
#########################
# PHP 5.3 compatible
# InDev_trait replaces this in PHP 5.4
protected $dev;
function inDev() {
@ -24,6 +27,7 @@
function setDev($d) {
$this->dev = $d;
}
#########################
protected $parent_id;
protected $category;

View file

@ -1,5 +1,8 @@
<?php
class AchMenuNode extends Parentum {
#########################
# PHP 5.3 compatible
# InDev_trait replaces this in PHP 5.4
protected $dev;
function inDev() {
@ -24,6 +27,7 @@
function setDev($d) {
$this->dev = $d;
}
#########################
protected $parent_id;
protected $name;

View file

@ -15,14 +15,14 @@
$this->open = $open;
// the summary page is autogenerated and has no database entry. We add it manually here.
/*$tmp = array();
$tmp = array();
$tmp['ac_id'] = 0;
$tmp['ac_parent'] = null;
$tmp['acl_name'] = get_translation('ach_summary',$_USER->getLang());
$tmp['ac_image'] = "test.png";
$tmp['ac_order'] = -1;
$tmp['open'] = $open;
$this->addChild(new AchMenuNode($tmp,$this));*/
$this->addChild(new AchMenuNode($tmp,$this));
$res = $DBc->sqlQuery("SELECT * FROM ach_category LEFT JOIN (ach_category_lang) ON (acl_lang='".$_USER->getLang()."' AND acl_category=ac_id) WHERE ac_parent IS NULL ORDER by ac_order ASC, acl_name ASC");

View file

@ -27,7 +27,7 @@
$this->progress = $this->value;
if(!$this->isDone()) {
$res = $DBc->sqlQuery("SELECT count(*) as anz FROM ach_player_atom,ach_atom WHERE apa_atom=atom_id AND atom_objective='".$this->id."' AND apa_player='".$_USER->getID()."'");
$res = $DBc->sqlQuery("SELECT sum(apa_value) as anz FROM ach_player_atom,ach_atom WHERE apa_atom=atom_id AND atom_objective='".$this->id."' AND apa_player='".$_USER->getID()."'");
$this->progress = $res[0]['anz'];
}
}

View file

@ -1,5 +1,8 @@
<?php
class AchPerk extends Parentum {
#########################
# PHP 5.3 compatible
# InDev_trait replaces this in PHP 5.4
protected $dev;
function inDev() {
@ -24,6 +27,7 @@
function setDev($d) {
$this->dev = $d;
}
#########################
protected $achievement;
protected $value;

View file

@ -13,7 +13,7 @@
//read all recent perks 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 FROM ach_achievement as ach,ach_perk,ach_player_perk WHERE ap_achievement=aa_id AND app_player='".$_USER->getID()."' AND app_perk=ap_id ORDER by app_date DESC LIMIT 0,".($size-1));
$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_perk,ach_player_perk WHERE ap_achievement=aa_id AND app_player='".$_USER->getID()."' AND app_perk=ap_id ORDER by app_date DESC LIMIT 0,".($size-1));
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {

View file

@ -10,4 +10,8 @@
$_CONF['enable_webig'] = true;
$_CONF['enable_offgame'] = true;
$_CONF['image_url'] = "http://www.3025-game.de/special/app_achievements/";
$_CONF['use_fb'] = true;
$_CONF['fb_id'] = "447985781893176";
$_CONF['fb_secret'] = "f953772f1f7d871db022a6023e7a3f42";
?>

View file

@ -0,0 +1,57 @@
<?php
error_reporting(E_ALL ^ E_NOTICE);
ini_set("display_errors","1");
define('APP_NAME', 'app_achievements');
require_once('conf.php');
require_once("fb/facebook.php");
$facebook = new Facebook(array(
'appId' => $_CONF['fb_id'],
'secret' => $_CONF['fb_secret'],
'cookie' => true
));
// Get the url to redirect for login to facebook
// and request permission to write on the user's wall.
$login_url = $facebook->getLoginUrl(
array('scope' => 'publish_stream')
);
// If not authenticated, redirect to the facebook login dialog.
// The $login_url will take care of redirecting back to us
// after successful login.
if (!$facebook->getUser()) {
echo '<script type="text/javascript">
top.location.href = "'.$login_url.'";
</script>';
}
else {
echo var_export($facebook->getUser(),true);
// Do the wall post.
try {
$facebook->api("/me/feed", "post", array(
message => "My character Talvela just earned <b>'Bejeweled'</b> on Ryzom!",
picture => "http://www.3025-game.de/special/app_achievements/pic/icon/test.png",
link => "http://www.ryzom.com",
name => "Ryzom - MMO",
caption => "Join and play for fee!"
));
echo "post";
} catch (FacebookApiException $e) {
echo $e;
$login_url = $facebook->getLoginUrl( array(
'scope' => 'publish_stream'
));
echo 'Please <a href="' . $login_url . '">login.</a>';
#error_log($e->getType());
#error_log($e->getMessage());
}
}
?>

View file

@ -0,0 +1,93 @@
<?php
/**
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
require_once "base_facebook.php";
/**
* Extends the BaseFacebook class with the intent of using
* PHP sessions to store user ids and access tokens.
*/
class Facebook extends BaseFacebook
{
/**
* Identical to the parent constructor, except that
* we start a PHP session to store the user ID and
* access token if during the course of execution
* we discover them.
*
* @param Array $config the application configuration.
* @see BaseFacebook::__construct in facebook.php
*/
public function __construct($config) {
if (!session_id()) {
session_start();
}
parent::__construct($config);
}
protected static $kSupportedKeys =
array('state', 'code', 'access_token', 'user_id');
/**
* Provides the implementations of the inherited abstract
* methods. The implementation uses PHP sessions to maintain
* a store for authorization codes, user ids, CSRF states, and
* access tokens.
*/
protected function setPersistentData($key, $value) {
if (!in_array($key, self::$kSupportedKeys)) {
self::errorLog('Unsupported key passed to setPersistentData.');
return;
}
$session_var_name = $this->constructSessionVariableName($key);
$_SESSION[$session_var_name] = $value;
}
protected function getPersistentData($key, $default = false) {
if (!in_array($key, self::$kSupportedKeys)) {
self::errorLog('Unsupported key passed to getPersistentData.');
return $default;
}
$session_var_name = $this->constructSessionVariableName($key);
return isset($_SESSION[$session_var_name]) ?
$_SESSION[$session_var_name] : $default;
}
protected function clearPersistentData($key) {
if (!in_array($key, self::$kSupportedKeys)) {
self::errorLog('Unsupported key passed to clearPersistentData.');
return;
}
$session_var_name = $this->constructSessionVariableName($key);
unset($_SESSION[$session_var_name]);
}
protected function clearAllPersistentData() {
foreach (self::$kSupportedKeys as $key) {
$this->clearPersistentData($key);
}
}
protected function constructSessionVariableName($key) {
return implode('_', array('fb',
$this->getAppId(),
$key));
}
}

View file

@ -413,12 +413,12 @@
<table width='".$width."px' cellspacing='0' cellpadding='0'>
<tr>
<td bgcolor='#66CC00' width='".$left."px'><font color='#000000'>";
if(($prog/$val) > 0.85) {
if(($prog/$val) > 0.5) {
$html .= "&nbsp;".nf($prog)." / ".nf($val)."&nbsp;";
}
$html .= "</font></td>
<td align='left' bgcolor='#00000066'><font color='#FFFFFF'>";
if(($prog/$val) <= 0.85) {
if(($prog/$val) <= 0.5) {
$html .= "&nbsp;".nf($prog)." / ".nf($val)."&nbsp;";
}
$html .= "</font></td>

View file

@ -4,7 +4,14 @@
$c = "<center><table>
<tr>
<td colspan='2' align='left'>".ach_render_yubopoints($user['id'])."</td>
<td colspan='2' align='left'>
<div style='display:block;border-bottom:1px solid #000000;'>
<div style='float:left;width:420px;'>".ach_render_yubopoints($user['id'])."</div>
<div style='float:right;width:420px;text-align:right;'>".ach_render_facebook()."</div>
<div style='clear:both;'></div>
</div>
</td>
</tr>
<tr>
<td valign='top'><div style='width:230px;font-weight:bold;font-size:14px;'>";
@ -120,13 +127,29 @@
$res = $DBc->sqlQuery("SELECT sum(ap_value) as anz FROM ach_perk,ach_player_perk WHERE ap_id=app_perk AND app_player='".$_USER->getID()."'");
$html = "<div style='display:block;border-bottom:1px solid #000000;'><span style='font-size:32px;'>".$_USER->getName()."&nbsp;<img src='".$_CONF['image_url']."pic/yubo_done.png'>&nbsp;".max(0,$res[0]['anz'])."</span></div>";
$html = "<div style='display:block;'><span style='font-size:32px;'>".$_USER->getName()."&nbsp;<img src='".$_CONF['image_url']."pic/yubo_done.png'>&nbsp;".max(0,$res[0]['anz'])."</span></div>";
return $html;
}
function ach_render_facebook() {
return "<div id='auth-status'>
<div id='auth-loggedout'>
<a href='#' id='auth-loginlink'><img src='pic/f-connect.png' height='30px'></a>
</div>
<div id='auth-loggedin' style='display:none'>
<table cellpadding='0' align='right'>
<tr>
<td rowspan='2'><img src='pic/facebook-logo.png' height='30px'></td>
<td style='text-align:left;font-size:10px;'>connected</td>
</tr>
<tr>
<td><span id='auth-displayname' style='font-size:16px;'></span></td>
</tr>
</table>
</div>
</div>";
}
function ach_render_twitter() {
@ -446,12 +469,12 @@
<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) {
if(($prog/$val) > 0.5) {
$html .= "&nbsp;".nf($prog)." / ".nf($val)."&nbsp;";
}
$html .= "</td>
<td align='left' style='color:#FFFFFF;'>";
if(($prog/$val) <= 0.85) {
if(($prog/$val) <= 0.5) {
$html .= "&nbsp;".nf($prog)." / ".nf($val)."&nbsp;";
}
$html .= "</td>

View file

@ -1,79 +1,129 @@
<?php
error_reporting(E_ALL ^ E_NOTICE);
ini_set("display_errors","1");
define('APP_NAME', 'app_achievements');
require_once('../webig/config.php');
include_once('../webig/lang.php');
include_once('lang.php');
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'] = 16;
$user['lang'] = 'en';
$user['name'] = 'Talvela';
$user['race'] = "r_matis";
$user['civilization'] = "c_neutral";
$user['cult'] = "c_neutral";
$user['ig'] = ($_REQUEST['ig']==1);
#$user['ig'] = true;
require_once("class/RyzomUser_class.php");
$_USER = new RyzomUser($user);
if($_USER->isIG()) {
require_once("include/ach_render_ig.php");
}
else {
require_once("include/ach_render_web.php");
}
require_once("include/ach_render_common.php");
require_once("class/DLL_class.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");
require_once("class/AchList_abstract.php");
require_once("class/Tieable_inter.php");
require_once("class/NodeIterator_class.php");
require_once("class/AchMenu_class.php");
require_once("class/AchMenuNode_class.php");
require_once("class/AchSummary_class.php");
require_once("class/AchCategory_class.php");
require_once("class/AchAchievement_class.php");
require_once("class/AchPerk_class.php");
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");
if(!$_USER->isIG && $_CONF['enable_webig'] == false) {
$c = ach_render_forbidden(false);
}
elseif($_USER->isIG && $_CONF['enable_offgame'] == false) {
$c = ach_render_forbidden(true);
}
else {
$c = ach_render();
}
echo ryzom_app_render("achievements", $c, $_USER->isIG());
?>
<?php
error_reporting(E_ALL ^ E_NOTICE);
ini_set("display_errors","1");
define('APP_NAME', 'app_achievements');
require_once('../webig/config.php');
include_once('../webig/lang.php');
include_once('lang.php');
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['cid'] = 1;
$user['lang'] = 'en';
$user['name'] = 'Talvela';
$user['race'] = "r_matis";
$user['civilization'] = "c_neutral";
$user['cult'] = "c_neutral";
$user['ig'] = ($_REQUEST['ig']==1);
#$user['ig'] = true;
require_once("class/RyzomUser_class.php");
$_USER = new RyzomUser($user);
if($_USER->isIG()) {
require_once("include/ach_render_ig.php");
}
else {
require_once("include/ach_render_web.php");
}
require_once("include/ach_render_common.php");
require_once("class/DLL_class.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");
require_once("class/AchList_abstract.php");
require_once("class/Tieable_inter.php");
require_once("class/NodeIterator_class.php");
require_once("class/AchMenu_class.php");
require_once("class/AchMenuNode_class.php");
require_once("class/AchSummary_class.php");
require_once("class/AchCategory_class.php");
require_once("class/AchAchievement_class.php");
require_once("class/AchPerk_class.php");
require_once("class/AchObjective_class.php");
require_once("fb/facebook.php");
// Update user acces on Db
#$DBc = ryDB::getInstance(APP_NAME."_test");
#$DBc = ryDB::getInstance(APP_NAME);
$DBc = ryDB::getInstance("ahufler");
$c = "";
if(!$_USER->isIG()) {
$facebook = new Facebook(array(
'appId' => $_CONF['fb_id'],
'secret' => $_CONF['fb_secret'],
'cookie' => true
));
// Get the url to redirect for login to facebook
// and request permission to write on the user's wall.
$login_url = $facebook->getLoginUrl(
array('scope' => 'publish_stream')
);
// If not authenticated, redirect to the facebook login dialog.
// The $login_url will take care of redirecting back to us
// after successful login.
if (! $facebook->getUser()) {
$c .= '<script type="text/javascript">
top.location.href = "'.$login_url.'";
</script>;';
}
else {
echo var_export($facebook->getUser(),true);
// Do the wall post.
try {
/*$facebook->api("/me/feed", "post", array(
message => "My character Talvela just achieved \"Bejeweled\" on Ryzom!",
picture => "http://www.3025-game.de/special/app_achievements/pic/icon/test.png",
link => "http://www.ryzom.com",
name => "Ryzom",
caption => "Join and play for fee!"
));*/
} catch (FacebookApiException $e) {
echo $e;
$login_url = $facebook->getLoginUrl( array(
'scope' => 'publish_stream'
));
echo 'Please <a href="' . $login_url . '">login.</a>';
#error_log($e->getType());
#error_log($e->getMessage());
}
}
}
if(!$_USER->isIG && $_CONF['enable_webig'] == false) {
$c .= ach_render_forbidden(false);
}
elseif($_USER->isIG && $_CONF['enable_offgame'] == false) {
$c .= ach_render_forbidden(true);
}
else {
$c .= ach_render();
}
echo ryzom_app_render("achievements", $c, $_USER->isIG());
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View file

@ -1,6 +1,55 @@
<?php
class AdmAchievement extends AchAchievement implements ADM {
use AdmDispatcher;
/*function insertNode($n) {
$n->setParent($this);
$n->insert();
$this->addChild($n);
}*/
function removeNode($id) {
$res = $this->getChildDataByID($id);
if($res != null) {
$res->delete_me();
$this->removeChild($id);
}
}
function updateNode($id) { // PROBABLY USELESS!
$res = $this->getChildDataByID($id);
if($res != null) {
$res->update();
}
}
function getPathID($path = "") {
if($path != "") {
$path = ";".$path;
}
$path = $this->getID().$path;
if($this->parent != null) {
return $this->parent->getPathID($path);
}
return $path;
}
function getElementByPath($pid) {
$tmp = explode(";",$pid);
if($tmp[0] == $this->getID()) {
if(sizeof($tmp) > 1) {
$c = $this->getChildDataByID($tmp[1]);
if($c != null) {
unset($tmp[0]);
return $c->getElementByPath(implode(";",$tmp));
}
return null;
}
else {
return $this;
}
}
return null;
}
function AdmAchievement($data,$parent) {
parent::__construct($data,$parent);
@ -34,10 +83,10 @@
function update() {
global $DBc;
$DBc->sqlQuery("UPDATE ach_achievement SET aa_category='".$this->getCategory()."',aa_parent=NULL,aa_tie_race=".mkn($this->getTieRace()).",aa_tie_cult=".mkn($this->getTieCult()).",aa_tie_civ=".mkn($this->getTieCiv()).",aa_image='".mysql_real_escape_string($this->getImage())."',aa_dev='".$this->getDev()."' WHERE aa_id='".$this->getID()."'");
$DBc->sqlQuery("UPDATE ach_achievement SET aa_category='".$this->getCategory()."',aa_parent=NULL,aa_tie_race=".mkn($this->getTieRace()).",aa_tie_cult=".mkn($this->getTieCult()).",aa_tie_civ=".mkn($this->getTieCiv()).",aa_image='".$DBc->sqlEscape($this->getImage())."',aa_dev='".$this->getDev()."' WHERE aa_id='".$this->getID()."'");
#MISSING: update lang entry
$DBc->sqlQuery("INSERT INTO ach_achievement_lang (aal_achievement,aal_lang,aal_name,aal_template) VALUES ('".$this->getID()."','en','".mysql_real_escape_string($this->getName())."',".mkn($this->getTemplate()).") ON DUPLICATE KEY UPDATE aal_name='".mysql_real_escape_string($this->getName())."',aal_template=".mkn($this->getTemplate())."");
$DBc->sqlQuery("INSERT INTO ach_achievement_lang (aal_achievement,aal_lang,aal_name,aal_template) VALUES ('".$this->getID()."','en','".$DBc->sqlEscape($this->getName())."',".mkn($this->getTemplate()).") ON DUPLICATE KEY UPDATE aal_name='".$DBc->sqlEscape($this->getName())."',aal_template=".mkn($this->getTemplate())."");
}
function insert() {
@ -45,11 +94,11 @@
$this->dev = 1;
$DBc->sqlQuery("INSERT INTO ach_achievement (aa_category,aa_parent,aa_tie_race,aa_tie_cult,aa_tie_civ,aa_image,aa_dev) VALUES ('".$this->getCategory()."',NULL,".mkn($this->getTieRace()).",".mkn($this->getTieCult()).",".mkn($this->getTieCiv()).",'".mysql_real_escape_string($this->getImage())."','1')");
$id = mysql_insert_id();
$DBc->sqlQuery("INSERT INTO ach_achievement (aa_category,aa_parent,aa_tie_race,aa_tie_cult,aa_tie_civ,aa_image,aa_dev) VALUES ('".$this->getCategory()."',NULL,".mkn($this->getTieRace()).",".mkn($this->getTieCult()).",".mkn($this->getTieCiv()).",'".$DBc->sqlEscape($this->getImage())."','1')");
$id = $DBc->insertID();
$this->setID($id);
$DBc->sqlQuery("INSERT INTO ach_achievement_lang (aal_achievement,aal_lang,aal_name,aal_template) VALUES ('".$this->getID()."','en','".mysql_real_escape_string($this->getName())."',".mkn($this->getTemplate()).")");
$DBc->sqlQuery("INSERT INTO ach_achievement_lang (aal_achievement,aal_lang,aal_name,aal_template) VALUES ('".$this->getID()."','en','".$DBc->sqlEscape($this->getName())."',".mkn($this->getTemplate()).")");
}

View file

@ -1,5 +1,56 @@
<?php
class AdmAtom extends Node implements ADM {
function insertNode($n) {
$n->setParent($this);
$n->insert();
$this->addChild($n);
}
function removeNode($id) {
$res = $this->getChildDataByID($id);
if($res != null) {
$res->delete_me();
$this->removeChild($id);
}
}
function updateNode($id) { // PROBABLY USELESS!
$res = $this->getChildDataByID($id);
if($res != null) {
$res->update();
}
}
function getPathID($path = "") {
if($path != "") {
$path = ";".$path;
}
$path = $this->getID().$path;
if($this->parent != null) {
return $this->parent->getPathID($path);
}
return $path;
}
function getElementByPath($pid) {
$tmp = explode(";",$pid);
if($tmp[0] == $this->getID()) {
if(sizeof($tmp) > 1) {
$c = $this->getChildDataByID($tmp[1]);
if($c != null) {
unset($tmp[0]);
return $c->getElementByPath(implode(";",$tmp));
}
return null;
}
else {
return $this;
}
}
return null;
}
protected $objective;
protected $mandatory;
protected $ruleset;
@ -23,15 +74,27 @@
}
function update() {
#$DBc->sqlQuery("UPDATE ach_atom SET atom_mandatory='".."',atom_ruleset='".."',atom_ruleset_parsed='".."' WHERE atom_id='".$this->id."'");
global $DBc;
$DBc->sqlQuery("UPDATE ach_atom SET atom_mandatory='".$this->getMandatory()."',atom_ruleset='".$DBc->sqlEscape($this->getRuleset())."',atom_ruleset_parsed='".$DBc->sqlEscape($this->getRulesetParsed())."' WHERE atom_id='".$this->id."'");
}
function insert() {
#$DBc->sqlQuery("INSERT INTO ach_atom (atom_objective,atom_mandatory,atom_ruleset,atom_ruleset_parsed) VALUES ('".."','".."','".."','".."')");
$id = mysql_insert_id();
global $DBc;
$DBc->sqlQuery("INSERT INTO ach_atom (atom_objective,atom_mandatory,atom_ruleset,atom_ruleset_parsed) VALUES ('".$this->getObjective()."','".$this->getMandatory()."','".$DBc->sqlEscape($this->getRuleset())."','".$DBc->sqlEscape($this->getRulesetParsed())."')");
$id = $DBc->insertID();
$this->setID($id);
}
function getObjective() {
return $this->objective;
}
function setObjective($o) {
$this->objective = $o;
}
function setMandatory($ft) {
if($ft == true) {
$this->mandatory = 1;
@ -58,73 +121,222 @@
return $this->ruleset;
}
private function parse() {
/*VALUE _money AS $money {
CACHE blach AS $test
function getRulesetParsed() {
return $this->ruleset_parsed;
}
if($money >= 10000 && $test == 0) {
GRANT
FINAL
}
else {
CACHE blach SET $money
}
}
private function parse() {
/*
VALUE _money AS $money {
CACHE blach AS $test;
if($money >= 10000 && $test == 0) {
RESET;
GRANT $money UNTIL TIMER:3600;
FINAL;
}
else {
CACHE blach SET $money;
}
SCRIPT wealth($money) AS $res;
if($res == "lol") {
DENY;
}
}
ENTITY _pos AS $pos {
SCRIPT inside($pos,"majestic_garden") AS $region;
if($region == true) {
GRANT;
}
}
*/
$res = $this->ruleset;
#VALUE ([^ ]+) AS ([^ ]+) {#
#VALUE ([^ ]+) AS ([$][^ ]+) {#
$match = array();
preg_match_all("#VALUE ([^ ]+) AS ([^ ]+) {#",$this->ruleset,$match);
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].'";';
function '.$func.'('.$match[2][$key].',$_P,$_CB) {
global $_CACHE;
$_IDENT = "'.$match[1][$key].'";';
//replace
$res = str_replace($elem,$tmp,$res);
}
#ENTITY ([^ ]+) AS ([^ ]+) {#
#ENTITY ([^ ]+) AS ([$][^ ]+) {#
$match = array();
preg_match_all("#ENTITY ([^ ]+) AS ([^ ]+) {#",$this->ruleset,$match);
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].'";';
function '.$func.'('.$match[2][$key].',$_P,$_CB) {
global $_CACHE;
$_IDENT = "'.$match[1][$key].'";';
//replace
$res = str_replace($elem,$tmp,$res);
}
#EVENT ([^ ]+) AS ([^ ]+) {#
#EVENT ([^ ]+) AS ([$][^ ]+) {#
$match = array();
preg_match_all("#EVENT ([^ ]+) AS ([^ ]+) {#",$this->ruleset,$match);
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].'";';
function '.$func.'('.$match[2][$key].',$_P,$_CB) {
global $_CACHE;
$_IDENT = "'.$match[1][$key].'";';
//replace
$res = str_replace($elem,$tmp,$res);
}
#CACHE ([^ ]+) AS ([^ ]+)#
#GRANT ([^;]*);#
$match = array();
preg_match_all("#GRANT ([^;]*);#",$this->ruleset,$match);
foreach($match[0] as $key=>$elem) {
$tmp = '$_P->grant('.$match[1][$key].');';
#GRANT#
//replace
$res = str_replace($elem,$tmp,$res);
}
#FINAL#
#GRANT;#
$match = array();
preg_match_all("#GRANT;#",$this->ruleset,$match);
foreach($match[0] as $key=>$elem) {
$tmp = '$_P->grant();';
#CACHE ([^ ]+) SET ([^ ]+)#*/
//replace
$res = str_replace($elem,$tmp,$res);
}
#DENY;#
$match = array();
preg_match_all("#DENY;#",$this->ruleset,$match);
foreach($match[0] as $key=>$elem) {
$tmp = '$_P->deny();';
//replace
$res = str_replace($elem,$tmp,$res);
}
#UNLOCK;#
$match = array();
preg_match_all("#UNLOCK;#",$this->ruleset,$match);
foreach($match[0] as $key=>$elem) {
$tmp = '$_P->unlock();';
//replace
$res = str_replace($elem,$tmp,$res);
}
#RESET;#
$match = array();
preg_match_all("#RESET;#",$this->ruleset,$match);
foreach($match[0] as $key=>$elem) {
$tmp = '$_P->reset_();';
//replace
$res = str_replace($elem,$tmp,$res);
}
#UNLOCK_ALL;#
$match = array();
preg_match_all("#UNLOCK_ALL;#",$this->ruleset,$match);
foreach($match[0] as $key=>$elem) {
$tmp = '$_P->unlock_all();';
//replace
$res = str_replace($elem,$tmp,$res);
}
#RESET_ALL;#
$match = array();
preg_match_all("#RESET_ALL;#",$this->ruleset,$match);
foreach($match[0] as $key=>$elem) {
$tmp = '$_P->reset_all();';
//replace
$res = str_replace($elem,$tmp,$res);
}
#FINAL VALUE;#
$match = array();
preg_match_all("#FINAL VALUE;#",$this->ruleset,$match);
foreach($match[0] as $key=>$elem) {
$tmp = '$_P->unregisterValue($_IDENT,$_CB);';
//replace
$res = str_replace($elem,$tmp,$res);
}
#FINAL ENTITY;#
$match = array();
preg_match_all("#FINAL ENTITY;#",$this->ruleset,$match);
foreach($match[0] as $key=>$elem) {
$tmp = '$_P->unregisterEntity($_IDENT,$_CB);';
//replace
$res = str_replace($elem,$tmp,$res);
}
#FINAL EVENT;#
$match = array();
preg_match_all("#FINAL EVENT;#",$this->ruleset,$match);
foreach($match[0] as $key=>$elem) {
$tmp = '$_P->unregisterEvent($_IDENT,$_CB);';
//replace
$res = str_replace($elem,$tmp,$res);
}
#CACHE ([^ ]+) AS ([$][^ ]+);#
$match = array();
preg_match_all("#CACHE ([^ ]+) AS ([$][^ ]+);#",$this->ruleset,$match);
foreach($match[0] as $key=>$elem) {
$tmp = $match[2][$key].' = $_CACHE->getData('.$match[1][$key].');';
//replace
$res = str_replace($elem,$tmp,$res);
}
#CACHE ([^ ]+) SET ([$][^ ]+);#
$match = array();
preg_match_all("#CACHE ([^ ]+) SET ([$][^ ]+);#",$this->ruleset,$match);
foreach($match[0] as $key=>$elem) {
$tmp = '$_CACHE->writeData('.$match[1][$key].','.$match[2][$key].');';
//replace
$res = str_replace($elem,$tmp,$res);
}
#SCRIPT ([^ ]+) AS ([$][^ ]+);#
$match = array();
preg_match_all("#SCRIPT ([^\(]+)\(([^\)]*)\) AS ([$][^ ]+);#",$this->ruleset,$match);
foreach($match[0] as $key=>$elem) {
$tmp = '@include_once("script/'.$match[1][$key].'_script.php");
'.$match[3][$key].' = '.$match[1][$key].'('.$match[2][$key].');';
//replace
$res = str_replace($elem,$tmp,$res);
}
$this->ruleset_parsed = $res;
}
}
?>

View file

@ -1,6 +1,55 @@
<?php
class AdmCategory extends AchCategory {
use AdmDispatcher;
/*function insertNode($n) {
$n->setParent($this);
$n->insert();
$this->addChild($n);
}*/
function removeNode($id) {
$res = $this->getChildDataByID($id);
if($res != null) {
$res->delete_me();
$this->removeChild($id);
}
}
function updateNode($id) { // PROBABLY USELESS!
$res = $this->getChildDataByID($id);
if($res != null) {
$res->update();
}
}
function getPathID($path = "") {
if($path != "") {
$path = ";".$path;
}
$path = $this->getID().$path;
if($this->parent != null) {
return $this->parent->getPathID($path);
}
return $path;
}
function getElementByPath($pid) {
$tmp = explode(";",$pid);
if($tmp[0] == $this->getID()) {
if(sizeof($tmp) > 1) {
$c = $this->getChildDataByID($tmp[1]);
if($c != null) {
unset($tmp[0]);
return $c->getElementByPath(implode(";",$tmp));
}
return null;
}
else {
return $this;
}
}
return null;
}
function AdmCategory($id,$race,$cult = null,$civ = null) {
parent::__construct($id,$race,$cult,$civ);

View file

@ -20,7 +20,9 @@
return true;
}
else {
foreach($this->nodes as $elem) {
$iter = $this->getIterator();
while($iter->hasNext()) {
$elem = $iter->getNext();
$res = $elem->hasAchievements();
if($res == true) {
return true;
@ -79,7 +81,7 @@
$DBc->sqlQuery("UPDATE ach_category SET ac_parent=".mkn($this->getParentID()).",ac_order='".$this->getOrder()."',ac_image=".mkn($this->getImage()).",ac_dev='".$this->getDev()."' WHERE ac_id='".$this->getID()."'");
#MISSING: update lang entry
$DBc->sqlQuery("INSERT IGNORE INTO ach_category_lang (acl_category,acl_lang,acl_name) VALUES ('".$this->getID()."','".$_USER->getLang()."','".mysql_real_escape_string($this->getName())."') ON DUPLICATE KEY UPDATE acl_name='".mysql_real_escape_string($this->getName())."'");
$DBc->sqlQuery("INSERT IGNORE INTO ach_category_lang (acl_category,acl_lang,acl_name) VALUES ('".$this->getID()."','".$_USER->getLang()."','".$DBc->sqlEscape($this->getName())."') ON DUPLICATE KEY UPDATE acl_name='".$DBc->sqlEscape($this->getName())."'");
}
function insert() { // write $this to the database as a new entry
@ -88,10 +90,10 @@
$this->setOrder($this->parent->getNextOrder());
$DBc->sqlQuery("INSERT INTO ach_category (ac_parent,ac_order,ac_image,ac_dev) VALUES (".mkn($this->getParentID()).",'".$this->getOrder()."',".mkn($this->getImage()).",'1')");
$id = mysql_insert_id();
$id = $DBc->insertID();
$this->setID($id);
#MISSING: insert lang entry
$DBc->sqlQuery("INSERT INTO ach_category_lang (acl_category,acl_lang,acl_name) VALUES ('".$this->getID()."','".$_USER->getLang()."','".mysql_real_escape_string($this->getName())."')");
$DBc->sqlQuery("INSERT INTO ach_category_lang (acl_category,acl_lang,acl_name) VALUES ('".$this->getID()."','".$_USER->getLang()."','".$DBc->sqlEscape($this->getName())."')");
}
@ -147,7 +149,10 @@
}
$val = array();
foreach($this->nodes as $elem) {
$iter = $this->getIterator();
while($iter->hasNext()) {
#foreach($this->nodes as $elem) {
$elem = $iter->getNext();
$val[] = $elem->getOrder();
}

View file

@ -1,13 +1,62 @@
<?php
class AdmMenu extends AchMenu {
use AdmDispatcher;
/*function insertNode($n) {
$n->setParent($this);
$n->insert();
$this->addChild($n);
}*/
/*function removeNode($id) {
$res = $this->getChildDataByID($id);
if($res != null) {
$res->delete_me();
$this->removeChild($id);
}
}*/
/*function updateNode($id) { // PROBABLY USELESS!
$res = $this->getChildDataByID($id);
if($res != null) {
$res->update();
}
}*/
function getPathID($path = "") {
if($path != "") {
$path = ";".$path;
}
$path = $this->getID().$path;
if($this->parent != null) {
return $this->parent->getPathID($path);
}
return $path;
}
function getElementByPath($pid) {
$tmp = explode(";",$pid);
if($tmp[0] == $this->getID()) {
if(sizeof($tmp) > 1) {
$c = $this->getChildDataByID($tmp[1]);
if($c != null) {
unset($tmp[0]);
return $c->getElementByPath(implode(";",$tmp));
}
return null;
}
else {
return $this;
}
}
return null;
}
function AdmMenu($open) {
parent::__construct($open);
#$this->drawTree();
#$this->removeChild(0); // unset the auto-generated "summary" node
$this->removeChild(0); // unset the auto-generated "summary" node
}
protected function makeChild($d) { // override child generator to use admin classes
@ -18,7 +67,8 @@
$res = $this->getNode($id);
if($res != null) {
$res->delete_me();
$this->removeChild($id);
$tmp = $res->getParent();
$tmp->removeChild($id);
}
}

View file

@ -1,13 +1,62 @@
<?php
class AdmObjective extends AchObjective implements ADM {
use AdmDispatcher;
function insertNode($n) {
$n->setParent($this);
$n->insert();
$this->addChild($n);
}
function removeNode($id) {
$res = $this->getChildDataByID($id);
if($res != null) {
$res->delete_me();
$this->removeChild($id);
}
}
function updateNode($id) { // PROBABLY USELESS!
$res = $this->getChildDataByID($id);
if($res != null) {
$res->update();
}
}
function getPathID($path = "") {
if($path != "") {
$path = ";".$path;
}
$path = $this->getID().$path;
if($this->parent != null) {
return $this->parent->getPathID($path);
}
return $path;
}
function getElementByPath($pid) {
$tmp = explode(";",$pid);
if($tmp[0] == $this->getID()) {
if(sizeof($tmp) > 1) {
$c = $this->getChildDataByID($tmp[1]);
if($c != null) {
unset($tmp[0]);
return $c->getElementByPath(implode(";",$tmp));
}
return null;
}
else {
return $this;
}
}
return null;
}
function AdmObjective($data,$parent) {
parent::__construct($data,$parent);
global $DBc;
$res = $DBc->sqlQuery("SELECT atom_id FROM ach_atom WHERE atom_objective='".$this->getID()."'");
$res = $DBc->sqlQuery("SELECT * FROM ach_atom WHERE atom_objective='".$this->getID()."'");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$this->addChild($this->makeChild($res[$i]));
@ -35,19 +84,19 @@
function update() {
global $DBc;
$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("UPDATE ach_objective SET ao_condition='".$DBc->sqlEscape($this->getCondition())."',ao_value=".mkn($this->getValue()).",ao_display='".$DBc->sqlEscape($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())."'");
$DBc->sqlQuery("INSERT INTO ach_objective_lang (aol_objective,aol_lang,aol_name) VALUES ('".$this->getID()."','en','".$DBc->sqlEscape($this->getName())."') ON DUPLICATE KEY UPDATE aol_name='".$DBc->sqlEscape($this->getName())."'");
}
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())."',".mkn($this->getValue()).",'".mysql_real_escape_string($this->getDisplay())."',".mkn($this->getMetaImage()).")");
$id = mysql_insert_id();
$DBc->sqlQuery("INSERT INTO ach_objective (ao_perk,ao_condition,ao_value,ao_display,ao_metalink) VALUES ('".$this->getPerk()."','".$DBc->sqlEscape($this->getCondition())."',".mkn($this->getValue()).",'".$DBc->sqlEscape($this->getDisplay())."',".mkn($this->getMetaImage()).")");
$id = $DBc->insertID();
$this->setID($id);
$DBc->sqlQuery("INSERT INTO ach_objective_lang (aol_objective,aol_lang,aol_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','".$DBc->sqlEscape($this->getName())."')");
}
function setCondition($c) {

View file

@ -1,6 +1,55 @@
<?php
class AdmPerk extends AchPerk implements ADM {
use AdmDispatcher;
function insertNode($n) {
$n->setParent($this);
$n->insert();
$this->addChild($n);
}
function removeNode($id) {
$res = $this->getChildDataByID($id);
if($res != null) {
$res->delete_me();
$this->removeChild($id);
}
}
function updateNode($id) { // PROBABLY USELESS!
$res = $this->getChildDataByID($id);
if($res != null) {
$res->update();
}
}
function getPathID($path = "") {
if($path != "") {
$path = ";".$path;
}
$path = $this->getID().$path;
if($this->parent != null) {
return $this->parent->getPathID($path);
}
return $path;
}
function getElementByPath($pid) {
$tmp = explode(";",$pid);
if($tmp[0] == $this->getID()) {
if(sizeof($tmp) > 1) {
$c = $this->getChildDataByID($tmp[1]);
if($c != null) {
unset($tmp[0]);
return $c->getElementByPath(implode(";",$tmp));
}
return null;
}
else {
return $this;
}
}
return null;
}
protected $condition;
protected $condition_value;
@ -35,9 +84,9 @@
function update() {
global $DBc;
$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("UPDATE ach_perk SET ap_parent=".mkn($this->getParentID()).",ap_value='".$DBc->sqlEscape($this->getValue())."',ap_condition='".$DBc->sqlEscape($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())."");
$DBc->sqlQuery("INSERT INTO ach_perk_lang (apl_perk,apl_lang,apl_name,apl_template) VALUES ('".$this->getID()."','en','".$DBc->sqlEscape($this->getName())."',".mkn($this->getTemplate()).") ON DUPLICATE KEY UPDATE apl_name='".$DBc->sqlEscape($this->getName())."',apl_template=".mkn($this->getTemplate())."");
}
function insert() {
@ -45,11 +94,11 @@
$this->dev = 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();
$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()).",'".$DBc->sqlEscape($this->getValue())."','".$DBc->sqlEscape($this->getCondition())."',".mkn($this->getConditionValue()).",'1','".$this->porder."')");
$id = $DBc->insertID();
$this->setID($id);
$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()).")");
$DBc->sqlQuery("INSERT INTO ach_perk_lang (apl_perk,apl_lang,apl_name,apl_template) VALUES ('".$this->getID()."','en','".$DBc->sqlEscape($this->getName())."',".mkn($this->getTemplate()).")");
}
function setAchievement($a) {
@ -92,29 +141,40 @@
$this->porder = $p;
}
function setParentID($p) { #!! CUTTING KILLS NODES! HAVE TO BE REROUTED!
private function reOrder() {
//check if order is OK!
if($this->parent_id == null) {
}
else {
}
}
function setParentID($p) { #reordering must happen A) after insert B) when updating
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());
#$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>";
#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);
}
#$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

@ -1,6 +1,68 @@
<?php
class CSRAchievement extends AchAchievement implements CSR {
use CSRDispatcher;
function grantNode($path,$player) {
#echo "start: ".$path." id: ".$this->getID()."<br>";
if(is_numeric($path)) {
//it's me (id == numeric)
if($this->getID() == $path) {
$this->grant($player);
#echo "grant()<br>";
}
}
else {
//get child with the next level id and dispatch
$tmp = explode(";",$path);
$c = $this->getChildDataByID($tmp[1]);
#echo "...".$tmp[1];
if($c != null) { // check if it's really own child
unset($tmp[0]);
$c->grantNode(implode(";",$tmp),$player);
#echo "grantNode()<br>";
}
}
#echo "end<br>";
}
function denyNode($path,$player) {
if(is_numeric($path)) {
//it's me (id == numeric)
if($this->getID() == $path) {
$this->deny($player);
}
}
else {
//get child with the next level id and dispatch
$tmp = explode(";",$path);
if($tmp[0] == $this->getID()) { // it's my id!
$c = $this->getChildDataByID($tmp[1]);
if($c != null) { // check if it's really own child
unset($tmp[0]);
$c->denyNode(implode(";",$tmp),$player);
}
}
}
}
function getPath($path = "") {
if($path != "") {
$path = ";".$path;
}
$path = $this->getID().$path;
if($this->hasParent()) {
$path = $this->parent->getPath($path);
}
return $path;
}
private function hasParent() {
return ($this->parent != null);
}
function CSRAchievement($data,$parent) {
parent::__construct($data,$parent);

View file

@ -1,6 +1,68 @@
<?php
class CSRCategory extends AchCategory implements CSR {
use CSRDispatcher;
function grantNode($path,$player) {
#echo "start: ".$path." id: ".$this->getID()."<br>";
if(is_numeric($path)) {
//it's me (id == numeric)
if($this->getID() == $path) {
$this->grant($player);
#echo "grant()<br>";
}
}
else {
//get child with the next level id and dispatch
$tmp = explode(";",$path);
$c = $this->getChildDataByID($tmp[1]);
#echo "...".$tmp[1];
if($c != null) { // check if it's really own child
unset($tmp[0]);
$c->grantNode(implode(";",$tmp),$player);
#echo "grantNode()<br>";
}
}
#echo "end<br>";
}
function denyNode($path,$player) {
if(is_numeric($path)) {
//it's me (id == numeric)
if($this->getID() == $path) {
$this->deny($player);
}
}
else {
//get child with the next level id and dispatch
$tmp = explode(";",$path);
if($tmp[0] == $this->getID()) { // it's my id!
$c = $this->getChildDataByID($tmp[1]);
if($c != null) { // check if it's really own child
unset($tmp[0]);
$c->denyNode(implode(";",$tmp),$player);
}
}
}
}
function getPath($path = "") {
if($path != "") {
$path = ";".$path;
}
$path = $this->getID().$path;
if($this->hasParent()) {
$path = $this->parent->getPath($path);
}
return $path;
}
private function hasParent() {
return ($this->parent != null);
}
function CSRCategory($id,$race,$cult = null,$civ = null) {
parent::__construct($id,$race,$cult,$civ);

View file

@ -1,6 +1,68 @@
<?php
class CSRObjective extends AchObjective implements CSR {
use CSRDispatcher;
function grantNode($path,$player) {
#echo "start: ".$path." id: ".$this->getID()."<br>";
if(is_numeric($path)) {
//it's me (id == numeric)
if($this->getID() == $path) {
$this->grant($player);
#echo "grant()<br>";
}
}
else {
//get child with the next level id and dispatch
$tmp = explode(";",$path);
$c = $this->getChildDataByID($tmp[1]);
#echo "...".$tmp[1];
if($c != null) { // check if it's really own child
unset($tmp[0]);
$c->grantNode(implode(";",$tmp),$player);
#echo "grantNode()<br>";
}
}
#echo "end<br>";
}
function denyNode($path,$player) {
if(is_numeric($path)) {
//it's me (id == numeric)
if($this->getID() == $path) {
$this->deny($player);
}
}
else {
//get child with the next level id and dispatch
$tmp = explode(";",$path);
if($tmp[0] == $this->getID()) { // it's my id!
$c = $this->getChildDataByID($tmp[1]);
if($c != null) { // check if it's really own child
unset($tmp[0]);
$c->denyNode(implode(";",$tmp),$player);
}
}
}
}
function getPath($path = "") {
if($path != "") {
$path = ";".$path;
}
$path = $this->getID().$path;
if($this->hasParent()) {
$path = $this->parent->getPath($path);
}
return $path;
}
private function hasParent() {
return ($this->parent != null);
}
#private $nodes;

View file

@ -1,6 +1,68 @@
<?php
class CSRPerk extends AchPerk implements CSR {
use CSRDispatcher;
function grantNode($path,$player) {
#echo "start: ".$path." id: ".$this->getID()."<br>";
if(is_numeric($path)) {
//it's me (id == numeric)
if($this->getID() == $path) {
$this->grant($player);
#echo "grant()<br>";
}
}
else {
//get child with the next level id and dispatch
$tmp = explode(";",$path);
$c = $this->getChildDataByID($tmp[1]);
#echo "...".$tmp[1];
if($c != null) { // check if it's really own child
unset($tmp[0]);
$c->grantNode(implode(";",$tmp),$player);
#echo "grantNode()<br>";
}
}
#echo "end<br>";
}
function denyNode($path,$player) {
if(is_numeric($path)) {
//it's me (id == numeric)
if($this->getID() == $path) {
$this->deny($player);
}
}
else {
//get child with the next level id and dispatch
$tmp = explode(";",$path);
if($tmp[0] == $this->getID()) { // it's my id!
$c = $this->getChildDataByID($tmp[1]);
if($c != null) { // check if it's really own child
unset($tmp[0]);
$c->denyNode(implode(";",$tmp),$player);
}
}
}
}
function getPath($path = "") {
if($path != "") {
$path = ";".$path;
}
$path = $this->getID().$path;
if($this->hasParent()) {
$path = $this->parent->getPath($path);
}
return $path;
}
private function hasParent() {
return ($this->parent != null);
}
function CSRPerk($data,$parent) {
parent::__construct($data,$parent);

View file

@ -53,12 +53,17 @@
}
function adm_render_category(&$cat) {
$html = "";
$html = "<style>
.bw {
background-color:#FFFFFF;
color:#000000;
}
</style>";
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;'>
$html .= "<div style='display:block;padding:3px;margin-bottom:5px;' class='bw'>
<fieldset>
<legend>Delete</legend>
Are you sure you want to delete <b>".$tmp->getName()."</b><p>
@ -82,15 +87,15 @@
<legend>add new achievement</legend>
<table>
<tr>
<td>name:</td>
<td class='bw'>name:</td>
<td><input type='text' name='aal_name' /></td>
</tr>
<tr>
<td>naming template:</td>
<td class='bw'>naming template:</td>
<td><input type='text' name='aal_template' /></td>
</tr>
<tr>
<td>cult:</td>
<td class='bw'>cult:</td>
<td>
<select name='aa_tie_cult'>
<option value='null' selected='selected'>any</option>
@ -101,7 +106,7 @@
</td>
</tr>
<tr>
<td>civilization:</td>
<td class='bw'>civilization:</td>
<td>
<select name='aa_tie_civ'>
<option value='null' selected='selected'>any</option>
@ -114,26 +119,26 @@
</td>
</tr>
<tr>
<td>image:</td>
<td class='bw'>image:</td>
<td><input type='text' name='aa_image' /></td>
</tr>
<tr>
<td colspan='2'><hr /></td>
</tr>
<tr>
<td>perk name:</td>
<td class='bw'>perk name:</td>
<td><input type='text' name='apl_name' /></td>
</tr>
<tr>
<td>naming template:</td>
<td class='bw'>naming template:</td>
<td><input type='text' name='apl_template' /></td>
</tr>
<tr>
<td>perk yubopoints:</td>
<td class='bw'>perk yubopoints:</td>
<td><input type='text' name='ap_value' /></td>
</tr>
<tr>
<td>condition:</td>
<td class='bw'>condition:</td>
<td>
<select name='ap_condition'>
<option value='all' selected='selected'>all</option>
@ -143,7 +148,7 @@
</td>
</tr>
<tr>
<td>condition value:</td>
<td class='bw'>condition value:</td>
<td><input type='text' name='ap_condition_value' /></td>
</tr>
<tr>
@ -187,41 +192,6 @@
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;
@ -237,9 +207,9 @@
<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>';
<td width="100%"><center><table><tr><td><span style="font-weight:bold;font-size:24px;color:#FFFFFF;"><a name="ach_'.$ach->getID().'">[ach:]</a>'.$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/";
$html .= "<td style='background-color:#FFFFFF;padding:3px;'><nobr><a href='?mode=ach&cat=".$_REQUEST['cat']."&act=dev&state=".$ach->getDev()."&id=".$ach->getPathID()."#ach_".$ach->getID()."'><img src='pic/";
if($ach->inDev()) {
$html .= "red";
}
@ -261,20 +231,20 @@
</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'>
<form method='post' action='?mode=ach&cat=".$_REQUEST['cat']."&id=".$ach->getID()."&act=ach_update#ach_".$ach->getID()."'>
<fieldset>
<legend>edit achievement</legend>
<table>
<tr>
<td>name:</td>
<td class='bw'>name:</td>
<td><input type='text' name='aal_name' value=\"".$ach->getName()."\" /></td>
</tr>
<tr>
<td>naming template:</td>
<td class='bw'>naming template:</td>
<td><input type='text' name='aal_template' value=\"".$ach->getTemplate()."\" /></td>
</tr>
<tr>
<td>cult:</td>
<td class='bw'>cult:</td>
<td>
<select name='aa_tie_cult'>
<option value='null'"; if($ach->getTieCult() == null) { $html .= " selected='selected'"; } $html .= ">any</option>
@ -285,7 +255,7 @@
</td>
</tr>
<tr>
<td>civilization:</td>
<td class='bw'>civilization:</td>
<td>
<select name='aa_tie_civ'>
<option value='null'"; if($ach->getTieCiv() == null) { $html .= " selected='selected'"; } $html .= ">any</option>
@ -298,7 +268,7 @@
</td>
</tr>
<tr>
<td>image:</td>
<td class='bw'>image:</td>
<td><input type='text' name='aa_image' value='".$ach->getImage()."' /></td>
</tr>
<tr>
@ -310,24 +280,24 @@
</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'>
<form method='post' action='?mode=ach&cat=".$_REQUEST['cat']."&id=".$ach->getID()."&act=perk_insert#ach_".$ach->getID()."'>
<fieldset>
<legend>add new perk</legend>
<table>
<tr>
<td>name:</td>
<td class='bw'>name:</td>
<td><input type='text' name='apl_name' /></td>
</tr>
<tr>
<td>naming template:</td>
<td class='bw'>naming template:</td>
<td><input type='text' name='apl_template' /></td>
</tr>
<tr>
<td>yubopoints:</td>
<td class='bw'>yubopoints:</td>
<td><input type='text' name='ap_value' /></td>
</tr>
<tr>
<td>parent:</td>
<td class='bw'>parent:</td>
<td>
<select name='ap_parent'>
<option value='null' selected='selected'>[set as main perk]</option>";
@ -341,7 +311,7 @@
</td>
</tr>
<tr>
<td>condition:</td>
<td class='bw'>condition:</td>
<td>
<select name='ap_condition'>
<option value='all' selected='selected'>all</option>
@ -351,7 +321,7 @@
</td>
</tr>
<tr>
<td>condition value:</td>
<td class='bw'>condition value:</td>
<td><input type='text' name='ap_condition_value' /></td>
</tr>
<tr>
@ -368,7 +338,7 @@
<legend>move achievement</legend>
<table>
<tr>
<td>new category:</td>
<td class='bw'>new category:</td>
<td>
<select name='new_cat'>";
$iter = $menu->getIterator();
@ -425,9 +395,9 @@
}
#if($perk->getName() != null) {
$html .= "<table><tr><td><span style='color:#999999;font-weight:bold;display:block;'>[perk:]".$perk->getDisplayName()."</span></td>";
$html .= "<table><tr><td><span style='color:#999999;font-weight:bold;display:block;'><a name='perk_".$perk->getID()."'>[perk:]</a>".$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/";
$html .= "<td style='background-color:#FFFFFF;padding:3px;'><nobr><a href='?mode=ach&cat=".$_REQUEST['cat']."&act=dev&state=".$perk->getDev()."&id=".$perk->getPathID()."#perk_".$perk->getID()."'><img src='pic/";
if($perk->inDev()) {
$html .= "red";
}
@ -442,24 +412,24 @@
</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'>
<form method='post' action='?mode=ach&cat=".$_REQUEST['cat']."&id=".$perk->getPathID()."&act=perk_update#perk_".$perk->getID()."'>
<fieldset>
<legend>edit perk</legend>
<table>
<tr>
<td>name:</td>
<td class='bw'>name:</td>
<td><input type='text' name='apl_name' value='".$perk->getName()."' /></td>
</tr>
<tr>
<td>naming template:</td>
<td class='bw'>naming template:</td>
<td><input type='text' name='apl_template' value=\"".$perk->getTemplate()."\" /></td>
</tr>
<tr>
<td>yubopoints:</td>
<td class='bw'>yubopoints:</td>
<td><input type='text' name='ap_value' value='".$perk->getValue()."' /></td>
</tr>
<tr>
<td>parent:</td>
<td class='bw'>parent:</td>
<td>
<select name='ap_parent'>
<option value='null' selected='selected'>[set as main perk]</option>";
@ -482,7 +452,7 @@
</td>
</tr>
<tr>
<td>condition:</td>
<td class='bw'>condition:</td>
<td>
<select name='ap_condition'>
<option value='all'"; if($perk->getCondition() == "all") { $html .= " selected='selected'"; } $html .= ">all</option>
@ -492,7 +462,7 @@
</td>
</tr>
<tr>
<td>condition value:</td>
<td class='bw'>condition value:</td>
<td><input type='text' name='ap_condition_value' value='".$perk->getConditionValue()."' /></td>
</tr>
<tr>
@ -504,16 +474,16 @@
</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'>
<form method='post' action='?mode=ach&cat=".$_REQUEST['cat']."&id=".$perk->getPathID()."&act=obj_insert#perk_".$perk->getID()."'>
<fieldset>
<legend>add new objective</legend>
<table>
<tr>
<td>name:</td>
<td class='bw'>name:</td>
<td><input type='text' name='aol_name' /></td>
</tr>
<tr>
<td>type:</td>
<td class='bw'>type:</td>
<td>
<select name='ao_display'>
<option value='simple' selected='selected'>simple</option>
@ -524,21 +494,21 @@
</td>
</tr>
<tr>
<td>trigger condition:</td>
<td class='bw'>trigger condition:</td>
<td>
<select name='ao_condition'>
<option value='simple' selected='selected'>require all</option>
<option value='hidden'>require any</option>
<option value='all' selected='selected'>require all</option>
<option value='any'>require any</option>
<option value='value'>value / progressbar</option>
</select>
</td>
</tr>
<tr>
<td>trigger value:</td>
<td class='bw'>trigger value:</td>
<td><input type='text' name='ao_value' /></td>
</tr>
<tr>
<td>metalink:</td>
<td class='bw'>metalink:</td>
<td></td>
</tr>
<tr>
@ -557,24 +527,6 @@
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%'>";
@ -624,16 +576,16 @@
#$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'>
<form method='post' action='?mode=ach&cat=".$_REQUEST['cat']."&id=".$elem->getPathID()."&act=obj_update#perk_".$elem->getPerk()."'>
<fieldset>
<legend>edit objective</legend>
<table>
<tr>
<td>name:</td>
<td class='bw'>name:</td>
<td><input type='text' name='aol_name' value='".$elem->getName()."' /></td>
</tr>
<tr>
<td>type:</td>
<td class='bw'>type:</td>
<td>
<select name='ao_display'>
<option value='simple'"; if($elem->getDisplay() == "simple") { $html .= " selected='selected'"; } $html .= ">simple</option>
@ -644,21 +596,21 @@
</td>
</tr>
<tr>
<td>trigger condition:</td>
<td class='bw'>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='all'"; if($elem->getCondition() == "all") { $html .= " selected='selected'"; } $html .= ">require all</option>
<option value='any'"; if($elem->getCondition() == "any") { $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 class='bw'>trigger value:</td>
<td><input type='text' name='ao_value' value='".$elem->getValue()."' /></td>
</tr>
<tr>
<td>metalink:</td>
<td class='bw'>metalink:</td>
<td></td>
</tr>
<tr>
@ -699,7 +651,7 @@
$html .= "<img src='".$_CONF['image_url']."pic/pending.png' height='10px' />&nbsp;<span style='color:#999999;'>";
}
$html .= "[obj:]".$obj->getDisplayName()."</span>";
$html .= "<a name='".$obj->getID()."'>[obj:]</a>".$obj->getDisplayName()."</span>";
return $html;
}
@ -719,7 +671,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:]".$obj->getDisplayName()."</span></td>
<td valign='middle'><span style='color:".$col.";'>&nbsp;<a name='".$obj->getID()."'>[obj:]</a>".$obj->getDisplayName()."</span></td>
</tr>
</table>";
}
@ -750,7 +702,7 @@
else {
$col = "#999999";
}
$html .= "<div style='color:".$col.";display:block;'>[obj: untitled]</div>";
$html .= "<div style='color:".$col.";display:block;'><a name='".$obj->getID()."'>[obj: hidden]</a></div>";
#}
#$html .= ach_render_progressbar($obj->getProgress(),$obj->getValue(),350);

View file

@ -26,13 +26,8 @@
$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'>
$html .= "<span class='ach_mspan'><a href='?mode=atom&cat=".$curr->getID()."'><table class='ach_menu'>
<tr>";
if($sub == 0) {
$html .= "<td><img src='".$_CONF['image_url']."pic/menu/".$curr->getImage()."' /></td>";
@ -52,805 +47,208 @@
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>";
function atom_render_category(&$cat) {
$html = "<style>
.bar {
background-color:#FFFFFF;
color:#000000;
padding:2px;
margin-bottom:2px;
font-weight:bold;
}
.bar a {
color:#000000;
text-decoration:none;
}
</style>
<script type='text/javascript'>
function setSelectionRange(input, selectionStart, selectionEnd) {
if (input.setSelectionRange) {
input.focus();
input.setSelectionRange(selectionStart, selectionEnd);
}
else if (input.createTextRange) {
var range = input.createTextRange();
range.collapse(true);
range.moveEnd('character', selectionEnd);
range.moveStart('character', selectionStart);
range.select();
}
}
function replaceSelection (input, replaceString) {
if (input.setSelectionRange) {
var selectionStart = input.selectionStart;
var selectionEnd = input.selectionEnd;
input.value = input.value.substring(0, selectionStart)+ replaceString + input.value.substring(selectionEnd);
if (selectionStart != selectionEnd){
setSelectionRange(input, selectionStart, selectionStart + replaceString.length);
}else{
setSelectionRange(input, selectionStart + replaceString.length, selectionStart + replaceString.length);
}
$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>
}else if (document.selection) {
var range = document.selection.createRange();
</form>
</div>
</div>";
if (range.parentElement() == input) {
var isCollapsed = range.text == '';
range.text = replaceString;
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;
if (!isCollapsed) {
range.moveStart('character', -replaceString.length);
range.select();
}
$html .= ach_render_achievement_done($curr);
}*/
}
}
}
// We are going to catch the TAB key so that we can use it, Hooray!
function catchTab(item,e){
if(navigator.userAgent.match('Gecko')){
c=e.which;
}else{
c=e.keyCode;
}
if(c==9){
replaceSelection(item,String.fromCharCode(9));
setTimeout('document.getElementById(\"'+item.id+'\").focus();',0);
return false;
}
}
</script>
";
$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>";
$open = explode(";",$_REQUEST['id']);
$html .= "&nbsp;<a href='javascript:hs(\"new_perk_".$ach->getID()."\",\"block\");'><img src='pic/b_insrow.png'></a>";
$o = "none";
if($open[1] == $ach->getID()) {
$o = "block";
}
$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>';
$html = "<div style='display: block; margin-bottom: 5px;'>
<div style='display:block;font-size:22px;' class='bar'><a href='javascript:hs(\"ach_".$ach->getID()."\",\"block\");'>[+]</a> ".$ach->getName()." <span style='font-size:12px;'>(ties= race: ".$ach->getTieRace()."; civ: ".$ach->getTieCiv()."; cult: ".$ach->getTieCult().")</span></div>
<div style='margin-left:25px;display:".$o.";' id='ach_".$ach->getID()."'>".ach_render_perk_open($ach)."</div>
</div>";
return $html;
}
function ach_render_perk_open(&$ach) {
#echo var_export($perk_list,true);
$html = "";
$open = explode(";",$_REQUEST['id']);
$perk_list = $ach->getOpen();
while($perk_list->hasNext()) {
$perk = $perk_list->getNext();
#$perk = $ach->getChild($perk_list[0]);
if($perk->inDev()) {
#return $html;
$o = "none";
if($open[2] == $perk->getID()) {
$o = "block";
}
#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>";
$html .= "<div style='display: block; margin-bottom: 5px;'>
<div style='display:block;font-size:16px;' class='bar'><a href='javascript:hs(\"perk_".$perk->getID()."\",\"block\");'>[+]</a> ".$perk->getDisplayName()." <span style='font-size:12px;'>(condition= ".$perk->getCondition().": ".$perk->getConditionValue().")</span></div>
<div style='margin-left:25px;display:".$o.";' id='perk_".$perk->getID()."'>".ach_render_obj_list($perk->getIterator())."</div>
</div>";
}
return $html;
}
function ach_render_obj_list($obj) {
$html = "<center><table width='90%'>";
$html = "";
#$i = 0;
#$skip = false;
$open = explode(";",$_REQUEST['id']);
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>";
#$o = "none";
#if($open[3] == $elem->getID()) {
$o = "block";
#}
$html .= "<div style='display: block; margin-bottom: 5px;'>
<div style='display:block;' class='bar'><a href='javascript:hs(\"obj_".$elem->getID()."\",\"block\");' name='obj_".$elem->getID()."'>[+]</a> ".$elem->getDisplayName()." <span style='font-size:12px;'>(condition= ".$elem->getCondition().": ".$elem->getValue().")</span></div>
<div style='margin-left:25px;display:".$o.";' id='obj_".$elem->getID()."'>
<div style='display:block;'><a href='javascript:hs(\"add_atom_".$elem->getID()."\",\"block\");'>add</a></div>
<div style='display:none;' id='add_atom_".$elem->getID()."'>
<form method='post' action='?mode=atom&cat=".$_REQUEST['cat']."&act=insert_atom&id=".$elem->getPathID()."#obj_".$elem->getID()."'>
<fieldset>
<legend>add atom trigger</legend>
<table>
<tr>
<td><textarea name='atom_ruleset' rows='6' cols='80' onkeydown='return catchTab(this,event);'></textarea></td>
</tr>
<tr>
<td><input type='hidden' name='atom_mandatory' value='0' /><input type='checkbox' name='atom_mandatory' value='1' />&nbsp;mandatory</td>
</tr>
<tr>
<td><input type='submit' value='add' /></td>
</tr>
</table>
</fieldset>
<hr>
</form>
</div>
".ach_render_atom_list($elem->getIterator())."
</div>
</div>";
}
return $html;
}
function ach_render_atom_list($atom) {
$html = "";
while($atom->hasNext()) {
$elem = $atom->getNext();
#if(!$skip) {
# $i++;
#}
#$skip = false;
$html .= "<form method='post' action='?mode=atom&cat=".$_REQUEST['cat']."&act=update_atom&id=".$elem->getPathID()."#obj_".$elem->getObjective()."'>
<table>
<tr>
<td><textarea name='atom_ruleset' rows='6' cols='80' onkeydown='return catchTab(this,event);'>".$elem->getRuleset()."</textarea></td>
<td valign='top' rowspan='3'><a href='?mode=atom&cat=".$_REQUEST['cat']."&act=delete&id=".$elem->getPathID()."#obj_".$elem->getObjective()."'>[X]</a></td>
</tr>
<tr>
<td><div style='width:555px;overflow:scroll;'><pre>".$elem->getRulesetParsed()."</pre></div></td>
</tr>
<tr>
<td><input type='hidden' name='atom_mandatory' value='0' /><input type='checkbox' name='atom_mandatory' value='1'";
if($elem->getMandatory() == 1) {
$html .= " checked='checked'";
}
$html .= " />&nbsp;mandatory</td>
</tr>
<tr>
<td colspan='2'><input type='submit' value='edit' /></td>
</tr>
</table>
</form><hr>";
}
#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

@ -0,0 +1,193 @@
<?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();
$html .= "<span class='ach_mspan'><a href='?mode=atom&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 atom_render_category(&$cat) {
$html = "<style>
.bar {
background-color:#FFFFFF;
color:#000000;
padding:2px;
margin-bottom:2px;
font-weight:bold;
}
.bar a {
color:#000000;
text-decoration:none;
}
</style>";
$iter = $cat->getOpen();
while($iter->hasNext()) {
$curr = $iter->getNext();
$html .= ach_render_achievement_open($curr);
}
return $html;
}
function ach_render_achievement_open(&$ach) {
global $_CONF,$menu;
$open = explode(";",$_REQUEST['id']);
$o = "none";
if($open[1] == $ach->getID()) {
$o = "block";
}
$html = "<div style='display: block; margin-bottom: 5px;'>
<div style='display:block;font-size:22px;' class='bar'><a href='javascript:hs(\"ach_".$ach->getID()."\",\"block\");'>[+]</a> ".$ach->getName()." <span style='font-size:12px;'>(ties= race: ".$ach->getTieRace()."; civ: ".$ach->getTieCiv()."; cult: ".$ach->getTieCult().")</span></div>
<div style='margin-left:25px;display:".$o.";' id='ach_".$ach->getID()."'>".ach_render_perk_open($ach)."</div>
</div>";
return $html;
}
function ach_render_perk_open(&$ach) {
$html = "";
$open = explode(";",$_REQUEST['id']);
$perk_list = $ach->getOpen();
while($perk_list->hasNext()) {
$perk = $perk_list->getNext();
$o = "none";
if($open[2] == $perk->getID()) {
$o = "block";
}
$html .= "<div style='display: block; margin-bottom: 5px;'>
<div style='display:block;font-size:16px;' class='bar'><a href='javascript:hs(\"perk_".$perk->getID()."\",\"block\");'>[+]</a> ".$perk->getDisplayName()." <span style='font-size:12px;'>(condition= ".$perk->getCondition().": ".$perk->getConditionValue().")</span></div>
<div style='margin-left:25px;display:".$o.";' id='perk_".$perk->getID()."'>".ach_render_obj_list($perk->getIterator())."</div>
</div>";
}
return $html;
}
function ach_render_obj_list($obj) {
$html = "";
$open = explode(";",$_REQUEST['id']);
while($obj->hasNext()) {
$elem = $obj->getNext();
#$o = "none";
#if($open[3] == $elem->getID()) {
$o = "block";
#}
$html .= "<div style='display: block; margin-bottom: 5px;'>
<div style='display:block;' class='bar'><a href='javascript:hs(\"obj_".$elem->getID()."\",\"block\");' name='obj_".$elem->getID()."'>[+]</a> ".$elem->getDisplayName()." <span style='font-size:12px;'>(condition= ".$elem->getCondition().": ".$elem->getValue().")</span></div>
<div style='margin-left:25px;display:".$o.";' id='obj_".$elem->getID()."'>
<div style='display:block;'><a href='javascript:hs(\"add_atom_".$elem->getID()."\",\"block\");'>add</a></div>
<div style='display:none;' id='add_atom_".$elem->getID()."'>
<form method='post' action='?mode=atom&cat=".$_REQUEST['cat']."&act=insert_atom&id=".$elem->getPathID()."#obj_".$elem->getID()."'>
<fieldset>
<legend>add atom trigger</legend>
<table>
<tr>
<td><textarea name='atom_ruleset' rows='6' cols='80' onkeydown='return catchTab(this,event);'></textarea></td>
</tr>
<tr>
<td><input type='hidden' name='atom_mandatory' value='0' /><input type='checkbox' name='atom_mandatory' value='1' />&nbsp;mandatory</td>
</tr>
<tr>
<td><input type='submit' value='add' /></td>
</tr>
</table>
</fieldset>
<hr>
</form>
</div>
".ach_render_atom_list($elem->getIterator())."
</div>
</div>";
}
return $html;
}
function ach_render_atom_list($atom) {
$html = "";
while($atom->hasNext()) {
$elem = $atom->getNext();
$html .= "<form method='post' action='?mode=atom&cat=".$_REQUEST['cat']."&act=update_atom&id=".$elem->getPathID()."#obj_".$elem->getObjective()."'>
<table>
<tr>
<td><textarea name='atom_ruleset' rows='6' cols='80' onkeydown='return catchTab(this,event);'>".$elem->getRuleset()."</textarea></td>
<td valign='top' rowspan='3'><a href='?mode=atom&cat=".$_REQUEST['cat']."&act=delete&id=".$elem->getPathID()."#obj_".$elem->getObjective()."'>[X]</a></td>
</tr>
<tr>
<td><div style='width:555px;overflow:scroll;'><pre>".$elem->getRulesetParsed()."</pre></div></td>
</tr>
<tr>
<td><input type='hidden' name='atom_mandatory' value='0' /><input type='checkbox' name='atom_mandatory' value='1'";
if($elem->getMandatory() == 1) {
$html .= " checked='checked'";
}
$html .= " />&nbsp;mandatory</td>
</tr>
<tr>
<td colspan='2'><input type='submit' value='edit' /></td>
</tr>
</table>
</form><hr>";
}
return $html;
}
?>

View file

@ -44,7 +44,7 @@
</div>";
if($_REQUEST['ac_id'] > 0 && $_REQUEST['confirm'] == "delete") {
$curr = $menu->getChildDataByID($_REQUEST['ac_id']);
$curr = $menu->getNode($_REQUEST['ac_id']);
$html .= "<div style='display:block;'>
<fieldset>
<legend>Are you sure you want to delete this category?</legend>";
@ -95,8 +95,8 @@
if($curr->inDev()) {
$html .= "</s>";
}
$html .= "</td>
<td style='background-color:#FFFFFF;padding:3px;'><nobr><a href='?mode=menu&act=dev&state=".$curr->getDev()."&ac_id=".$curr->getID()."'><img src='pic/";
$html .= "<a name='cat_".$curr->getID()."'></td>
<td style='background-color:#FFFFFF;padding:3px;'><nobr><a href='?mode=menu&act=dev&state=".$curr->getDev()."&ac_id=".$curr->getID()."#cat_".$curr->getID()."'><img src='pic/";
if($curr->inDev()) {
$html .= "red";
}
@ -114,7 +114,7 @@
</table></span>";
if($sub == 0) {
$html .= "<div style='display:none;color:#000000;background-color:#FFFFFF;' id='ins_m".$curr->getID()."'>
<form method='post' action='?mode=menu&act=insert'>
<form method='post' action='?mode=menu&act=insert#cat_".$curr->getID()."'>
<fieldset>
<legend>create new sub-category</legend>
<input type='hidden' name='ac_parent' value='".$curr->getID()."' />
@ -135,7 +135,7 @@
}
$html .= "<div style='display:none;color:#000000;background-color:#FFFFFF;' id='edit_m".$curr->getID()."'>
<form method='post' action='?mode=menu&act=update&ac_id=".$curr->getID()."'>
<form method='post' action='?mode=menu&act=update&ac_id=".$curr->getID()."#cat_".$curr->getID()."'>
<fieldset>
<legend>edit category</legend>";
if($sub != 0) {

View file

@ -43,7 +43,7 @@ require_once($_CONF['app_achievements_path']."class/Parentum_abstract.php");
require_once($_CONF['app_achievements_path']."class/AchList_abstract.php");
require_once($_CONF['app_achievements_path']."class/Tieable_inter.php");
require_once($_CONF['app_achievements_path']."class/NodeIterator_class.php");
require_once($_CONF['app_achievements_path']."class/InDev_trait.php");
#require_once($_CONF['app_achievements_path']."class/InDev_trait.php");
require_once($_CONF['app_achievements_path']."class/AchMenu_class.php");
require_once($_CONF['app_achievements_path']."class/AchMenuNode_class.php");
@ -53,7 +53,7 @@ require_once($_CONF['app_achievements_path']."class/AchPerk_class.php");
require_once($_CONF['app_achievements_path']."class/AchObjective_class.php");
require_once("class/ADM_inter.php");
require_once("class/AdmDispatcher_trait.php");
#require_once("class/AdmDispatcher_trait.php");
require_once("class/AdmMenu_class.php");
require_once("class/AdmMenuNode_class.php");
require_once("class/AdmCategory_class.php");
@ -62,7 +62,7 @@ require_once("class/AdmPerk_class.php");
require_once("class/AdmObjective_class.php");
require_once("class/AdmAtom_class.php");
require_once("class/CSRDispatcher_trait.php");
#require_once("class/CSRDispatcher_trait.php");
require_once("class/CSR_inter.php");
#require_once("class/CSRMenu_class.php");
require_once("class/CSRCategory_class.php");
@ -75,11 +75,12 @@ $DBc = ryDB::getInstance("app_achievements_test");
#$DBc = ryDB::getInstance("ahufler");
function mkn($x) {
global $DBc;
if($x == null || strtolower($x) == "null") {
return "NULL";
}
else {
return "'".mysql_real_escape_string($x)."'";
return "'".$DBc->sqlEscape($x)."'";
}
}
@ -121,6 +122,7 @@ $c = "<script type='text/javascript'>
<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>
<li><a href='?mode=lang'>language editor</a></li>
</ul><p />";
}
if($_ADMIN->isCSR()) {
@ -136,6 +138,81 @@ $c = "<script type='text/javascript'>
$c .= "</div></td>
<td valign='top'>";
if($_REQUEST['mode'] == "lang" && $_ADMIN->isAdmin()) {
$c .= "<h1>Language Editor</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_lang.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,'%','%','%');
if($_REQUEST['act'] == "insert_atom") {
$obj = $cat->getElementByPath($_REQUEST['id']);
if($obj != null) {
$atom = new AdmAtom(array(),$obj);
$atom->setRuleset($_REQUEST['atom_ruleset']);
$atom->setMandatory($_REQUEST['atom_mandatory']);
$atom->setObjective($obj->getID());
$obj->insertNode($atom);
}
}
if($_REQUEST['act'] == "update_atom") {
$atom = $cat->getElementByPath($_REQUEST['id']);
if($atom != null) {
$atom->setRuleset($_REQUEST['atom_ruleset']);
$atom->setMandatory($_REQUEST['atom_mandatory']);
$atom->update();
}
}
if($_REQUEST['act'] == "delete") {
$elem = $cat->getElementByPath($_REQUEST['id']);
$par = $elem->getParent();
$par->removeNode($elem->getID());
}
$c .= atom_render_category($cat);
}
#a:p:o:a
$c .= "</td>
</tr>
</table></center>";
}
if($_REQUEST['mode'] == "atom" && $_ADMIN->isAdmin()) {
$c .= "<h1>Tigger Settings</h1>";
@ -168,6 +245,36 @@ $c .= "</div></td>
if($open != 0) {
$cat = new AdmCategory($open,'%','%','%');
if($_REQUEST['act'] == "insert_atom") {
$obj = $cat->getElementByPath($_REQUEST['id']);
if($obj != null) {
$atom = new AdmAtom(array(),$obj);
$atom->setRuleset($_REQUEST['atom_ruleset']);
$atom->setMandatory($_REQUEST['atom_mandatory']);
$atom->setObjective($obj->getID());
$obj->insertNode($atom);
}
}
if($_REQUEST['act'] == "update_atom") {
$atom = $cat->getElementByPath($_REQUEST['id']);
if($atom != null) {
$atom->setRuleset($_REQUEST['atom_ruleset']);
$atom->setMandatory($_REQUEST['atom_mandatory']);
$atom->update();
}
}
if($_REQUEST['act'] == "delete") {
$elem = $cat->getElementByPath($_REQUEST['id']);
$par = $elem->getParent();
$par->removeNode($elem->getID());
}
$c .= atom_render_category($cat);
}
@ -280,7 +387,7 @@ $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']);
$perk->setCondition($_REQUEST['ap_condition']);
$perk->setConditionValue($_REQUEST['ap_condition_value']);