diff --git a/code/web/app/app_achievements/_AchWebParser/AchWebParser.php b/code/web/app/app_achievements/_AchWebParser/AchWebParser.php index 0d02dcc70..3394635f3 100644 --- a/code/web/app/app_achievements/_AchWebParser/AchWebParser.php +++ b/code/web/app/app_achievements/_AchWebParser/AchWebParser.php @@ -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); ?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/class/Atom_class.php b/code/web/app/app_achievements/_AchWebParser/class/Atom_class.php index 700475e45..9e9bc30ab 100644 --- a/code/web/app/app_achievements/_AchWebParser/class/Atom_class.php +++ b/code/web/app/app_achievements/_AchWebParser/class/Atom_class.php @@ -17,7 +17,7 @@ function register() { global $DBc,$_DATA; - echo "register
"; + #echo "register
"; 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
"; - - $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_() { diff --git a/code/web/app/app_achievements/_AchWebParser/class/DataDispatcher_class.php b/code/web/app/app_achievements/_AchWebParser/class/DataDispatcher_class.php index b20239821..2ee25d979 100644 --- a/code/web/app/app_achievements/_AchWebParser/class/DataDispatcher_class.php +++ b/code/web/app/app_achievements/_AchWebParser/class/DataDispatcher_class.php @@ -53,7 +53,6 @@ } function dispatchValue($key,$val) { - echo "dispatching: $key=>$val
"; if(is_array($this->value[$key])) { foreach($this->value[$key] as $callback) { $callback->call($val); diff --git a/code/web/app/app_achievements/_AchWebParser/class/Entity_abstract.php b/code/web/app/app_achievements/_AchWebParser/class/Entity_abstract.php new file mode 100644 index 000000000..e7322444a --- /dev/null +++ b/code/web/app/app_achievements/_AchWebParser/class/Entity_abstract.php @@ -0,0 +1,13 @@ +name; + } + + function setName($n) { + $this->name = $n; + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/class/Logfile_class.php b/code/web/app/app_achievements/_AchWebParser/class/Logfile_class.php index 58254ff3c..aab4cb01c 100644 --- a/code/web/app/app_achievements/_AchWebParser/class/Logfile_class.php +++ b/code/web/app/app_achievements/_AchWebParser/class/Logfile_class.php @@ -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); } } ?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/class/mySQL_class.php b/code/web/app/app_achievements/_AchWebParser/class/mySQL_class.php index dba981254..5aca70da4 100644 --- a/code/web/app/app_achievements/_AchWebParser/class/mySQL_class.php +++ b/code/web/app/app_achievements/_AchWebParser/class/mySQL_class.php @@ -132,6 +132,8 @@ } private function error($error,$query = false) { + global $log; + $this->DBstats['error']++; if($query != false) { @@ -149,7 +151,7 @@ echo ""; break; case 'LOG': - logf("MySQL ERROR: ".$error); + $log->logf("MySQL ERROR: ".$error); break; default: flush(); diff --git a/code/web/app/app_achievements/_AchWebParser/conf.php b/code/web/app/app_achievements/_AchWebParser/conf.php index 5cf0e27ff..dc5286fd1 100644 --- a/code/web/app/app_achievements/_AchWebParser/conf.php +++ b/code/web/app/app_achievements/_AchWebParser/conf.php @@ -1,31 +1,21 @@ \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/script/in_region_script.php b/code/web/app/app_achievements/_AchWebParser/script/in_region_script.php new file mode 100644 index 000000000..282670c79 --- /dev/null +++ b/code/web/app/app_achievements/_AchWebParser/script/in_region_script.php @@ -0,0 +1,128 @@ +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; + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/script/include_InPoly_class.php b/code/web/app/app_achievements/_AchWebParser/script/include_InPoly_class.php new file mode 100644 index 000000000..491fa11bb --- /dev/null +++ b/code/web/app/app_achievements/_AchWebParser/script/include_InPoly_class.php @@ -0,0 +1,68 @@ +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]); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/PDRtoXMLdriver_class.php b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/PDRtoXMLdriver_class.php index 60241dca2..b48da1c0d 100644 --- a/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/PDRtoXMLdriver_class.php +++ b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/PDRtoXMLdriver_class.php @@ -1,9 +1,34 @@ 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; + } + + } diff --git a/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/FactionPoints_entity.php b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/FactionPoints_entity.php new file mode 100644 index 000000000..fa18a0fc6 --- /dev/null +++ b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/FactionPoints_entity.php @@ -0,0 +1,10 @@ +setName("faction_points"); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Fame_entity.php b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Fame_entity.php new file mode 100644 index 000000000..0cfc5f15b --- /dev/null +++ b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Fame_entity.php @@ -0,0 +1,12 @@ +setName("fame"); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Gear_entity.php b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Gear_entity.php new file mode 100644 index 000000000..b84008061 --- /dev/null +++ b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Gear_entity.php @@ -0,0 +1,9 @@ +setName("gear"); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Item_entity.php b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Item_entity.php new file mode 100644 index 000000000..2ffb89316 --- /dev/null +++ b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Item_entity.php @@ -0,0 +1,28 @@ +setName("item"); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/LastLogStats_entity.php b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/LastLogStats_entity.php new file mode 100644 index 000000000..30878f04a --- /dev/null +++ b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/LastLogStats_entity.php @@ -0,0 +1,11 @@ +setName("lastlogstats"); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/MissionList_entity.php b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/MissionList_entity.php new file mode 100644 index 000000000..ab4a7bea9 --- /dev/null +++ b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/MissionList_entity.php @@ -0,0 +1,9 @@ +setName("missionlist"); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Mission_entity.php b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Mission_entity.php new file mode 100644 index 000000000..7a95ac744 --- /dev/null +++ b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Mission_entity.php @@ -0,0 +1,11 @@ +setName("mission"); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/PermanentMod_entity.php b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/PermanentMod_entity.php new file mode 100644 index 000000000..008a74895 --- /dev/null +++ b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/PermanentMod_entity.php @@ -0,0 +1,10 @@ +setName("permanentmodifiers"); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Pet_entity.php b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Pet_entity.php new file mode 100644 index 000000000..e92499d93 --- /dev/null +++ b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Pet_entity.php @@ -0,0 +1,24 @@ +setName("pet"); + #echo "created"; + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/PhysCharacs_entity.php b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/PhysCharacs_entity.php new file mode 100644 index 000000000..c71109d02 --- /dev/null +++ b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/PhysCharacs_entity.php @@ -0,0 +1,10 @@ +setName("phys_characs"); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/PhysScores_entity.php b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/PhysScores_entity.php new file mode 100644 index 000000000..d7deca5bb --- /dev/null +++ b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/PhysScores_entity.php @@ -0,0 +1,15 @@ +setName("phys_scores"); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Position_entity.php b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Position_entity.php new file mode 100644 index 000000000..029b1525b --- /dev/null +++ b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Position_entity.php @@ -0,0 +1,12 @@ +setName("position"); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/SkillList_entity.php b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/SkillList_entity.php new file mode 100644 index 000000000..b3e885b81 --- /dev/null +++ b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/SkillList_entity.php @@ -0,0 +1,9 @@ +setName("skilllist"); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/SkillPoints_entity.php b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/SkillPoints_entity.php new file mode 100644 index 000000000..81582b703 --- /dev/null +++ b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/SkillPoints_entity.php @@ -0,0 +1,10 @@ +setName("skillpoints"); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Skill_entity.php b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Skill_entity.php new file mode 100644 index 000000000..f06132ac8 --- /dev/null +++ b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/Skill_entity.php @@ -0,0 +1,14 @@ +setName("skill"); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/SpentSkillPoints_entity.php b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/SpentSkillPoints_entity.php new file mode 100644 index 000000000..5bacb0e52 --- /dev/null +++ b/code/web/app/app_achievements/_AchWebParser/source/PDRtoXMLdriver/entity/SpentSkillPoints_entity.php @@ -0,0 +1,10 @@ +setName("spentskillpoints"); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/_doc/devshot_005.jpg b/code/web/app/app_achievements/_doc/devshot_005.jpg new file mode 100644 index 000000000..63fc3380d Binary files /dev/null and b/code/web/app/app_achievements/_doc/devshot_005.jpg differ diff --git a/code/web/app/app_achievements/class/AchAchievement_class.php b/code/web/app/app_achievements/class/AchAchievement_class.php index 67d0360d9..4de86b646 100644 --- a/code/web/app/app_achievements/class/AchAchievement_class.php +++ b/code/web/app/app_achievements/class/AchAchievement_class.php @@ -1,5 +1,8 @@ dev = $d; } + ######################### protected $parent_id; protected $category; diff --git a/code/web/app/app_achievements/class/AchMenuNode_class.php b/code/web/app/app_achievements/class/AchMenuNode_class.php index ef232d520..8676ab974 100644 --- a/code/web/app/app_achievements/class/AchMenuNode_class.php +++ b/code/web/app/app_achievements/class/AchMenuNode_class.php @@ -1,5 +1,8 @@ dev = $d; } + ######################### protected $parent_id; protected $name; diff --git a/code/web/app/app_achievements/class/AchMenu_class.php b/code/web/app/app_achievements/class/AchMenu_class.php index 60f21f17b..6d11b10df 100644 --- a/code/web/app/app_achievements/class/AchMenu_class.php +++ b/code/web/app/app_achievements/class/AchMenu_class.php @@ -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"); diff --git a/code/web/app/app_achievements/class/AchObjective_class.php b/code/web/app/app_achievements/class/AchObjective_class.php index 2f5a38543..5a314a8fc 100644 --- a/code/web/app/app_achievements/class/AchObjective_class.php +++ b/code/web/app/app_achievements/class/AchObjective_class.php @@ -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']; } } diff --git a/code/web/app/app_achievements/class/AchPerk_class.php b/code/web/app/app_achievements/class/AchPerk_class.php index bef5e5d71..25585db11 100644 --- a/code/web/app/app_achievements/class/AchPerk_class.php +++ b/code/web/app/app_achievements/class/AchPerk_class.php @@ -1,5 +1,8 @@ dev = $d; } + ######################### protected $achievement; protected $value; diff --git a/code/web/app/app_achievements/class/AchSummary_class.php b/code/web/app/app_achievements/class/AchSummary_class.php index 85ca43b37..c607774de 100644 --- a/code/web/app/app_achievements/class/AchSummary_class.php +++ b/code/web/app/app_achievements/class/AchSummary_class.php @@ -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++) { diff --git a/code/web/app/app_achievements/conf.php b/code/web/app/app_achievements/conf.php index a9ff621a3..f31fc7bc3 100644 --- a/code/web/app/app_achievements/conf.php +++ b/code/web/app/app_achievements/conf.php @@ -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"; ?> \ No newline at end of file diff --git a/code/web/app/app_achievements/fb.php b/code/web/app/app_achievements/fb.php new file mode 100644 index 000000000..57b33dbbd --- /dev/null +++ b/code/web/app/app_achievements/fb.php @@ -0,0 +1,57 @@ + $_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 ''; + } + else { + echo var_export($facebook->getUser(),true); + // Do the wall post. + try { + + $facebook->api("/me/feed", "post", array( + message => "My character Talvela just earned 'Bejeweled' 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 login.'; + #error_log($e->getType()); + #error_log($e->getMessage()); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/fb/facebook.php b/code/web/app/app_achievements/fb/facebook.php new file mode 100644 index 000000000..c577c2aa4 --- /dev/null +++ b/code/web/app/app_achievements/fb/facebook.php @@ -0,0 +1,93 @@ +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)); + } +} diff --git a/code/web/app/app_achievements/include/ach_render_ig.php b/code/web/app/app_achievements/include/ach_render_ig.php index dee5e19c9..e9f54c163 100644 --- a/code/web/app/app_achievements/include/ach_render_ig.php +++ b/code/web/app/app_achievements/include/ach_render_ig.php @@ -413,12 +413,12 @@ diff --git a/code/web/app/app_achievements/include/ach_render_web.php b/code/web/app/app_achievements/include/ach_render_web.php index 3058b2890..8c9df92bd 100644 --- a/code/web/app/app_achievements/include/ach_render_web.php +++ b/code/web/app/app_achievements/include/ach_render_web.php @@ -4,7 +4,14 @@ $c = "
"; - if(($prog/$val) > 0.85) { + if(($prog/$val) > 0.5) { $html .= " ".nf($prog)." / ".nf($val)." "; } $html .= " "; - if(($prog/$val) <= 0.85) { + if(($prog/$val) <= 0.5) { $html .= " ".nf($prog)." / ".nf($val)." "; } $html .= "
- +
".ach_render_yubopoints($user['id'])." +
+
".ach_render_yubopoints($user['id'])."
+
".ach_render_facebook()."
+
+
+ +
"; @@ -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 = "
".$_USER->getName()."  ".max(0,$res[0]['anz'])."
"; + $html = "
".$_USER->getName()."  ".max(0,$res[0]['anz'])."
"; return $html; } function ach_render_facebook() { - + return "
+
+ +
+ +
"; } function ach_render_twitter() { @@ -446,12 +469,12 @@ diff --git a/code/web/app/app_achievements/index.php b/code/web/app/app_achievements/index.php index 316b636ae..79edf6bfb 100644 --- a/code/web/app/app_achievements/index.php +++ b/code/web/app/app_achievements/index.php @@ -1,79 +1,129 @@ -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()); - -?> +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 .= ';'; + } + 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 login.'; + #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()); + +?> diff --git a/code/web/app/app_achievements/pic/f-connect.png b/code/web/app/app_achievements/pic/f-connect.png new file mode 100644 index 000000000..ee067c17b Binary files /dev/null and b/code/web/app/app_achievements/pic/f-connect.png differ diff --git a/code/web/app/app_achievements/pic/facebook-logo.png b/code/web/app/app_achievements/pic/facebook-logo.png new file mode 100644 index 000000000..c469dafac Binary files /dev/null and b/code/web/app/app_achievements/pic/facebook-logo.png differ diff --git a/code/web/app/app_achievements_admin/class/AdmAchievement_class.php b/code/web/app/app_achievements_admin/class/AdmAchievement_class.php index bb01aafe1..635aef466 100644 --- a/code/web/app/app_achievements_admin/class/AdmAchievement_class.php +++ b/code/web/app/app_achievements_admin/class/AdmAchievement_class.php @@ -1,6 +1,55 @@ 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()).")"); } diff --git a/code/web/app/app_achievements_admin/class/AdmAtom_class.php b/code/web/app/app_achievements_admin/class/AdmAtom_class.php index 9ede36606..19c606d04 100644 --- a/code/web/app/app_achievements_admin/class/AdmAtom_class.php +++ b/code/web/app/app_achievements_admin/class/AdmAtom_class.php @@ -1,5 +1,56 @@ 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; } } ?> \ No newline at end of file diff --git a/code/web/app/app_achievements_admin/class/AdmCategory_class.php b/code/web/app/app_achievements_admin/class/AdmCategory_class.php index cd0ff71a1..7a09fefab 100644 --- a/code/web/app/app_achievements_admin/class/AdmCategory_class.php +++ b/code/web/app/app_achievements_admin/class/AdmCategory_class.php @@ -1,6 +1,55 @@ 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); diff --git a/code/web/app/app_achievements_admin/class/AdmMenuNode_class.php b/code/web/app/app_achievements_admin/class/AdmMenuNode_class.php index 05064d28c..853700202 100644 --- a/code/web/app/app_achievements_admin/class/AdmMenuNode_class.php +++ b/code/web/app/app_achievements_admin/class/AdmMenuNode_class.php @@ -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(); } diff --git a/code/web/app/app_achievements_admin/class/AdmMenu_class.php b/code/web/app/app_achievements_admin/class/AdmMenu_class.php index f646d0d3f..8fbc961bf 100644 --- a/code/web/app/app_achievements_admin/class/AdmMenu_class.php +++ b/code/web/app/app_achievements_admin/class/AdmMenu_class.php @@ -1,13 +1,62 @@ 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); } } diff --git a/code/web/app/app_achievements_admin/class/AdmObjective_class.php b/code/web/app/app_achievements_admin/class/AdmObjective_class.php index 82c301453..bec59b52b 100644 --- a/code/web/app/app_achievements_admin/class/AdmObjective_class.php +++ b/code/web/app/app_achievements_admin/class/AdmObjective_class.php @@ -1,13 +1,62 @@ 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) { diff --git a/code/web/app/app_achievements_admin/class/AdmPerk_class.php b/code/web/app/app_achievements_admin/class/AdmPerk_class.php index 73c446e40..8b0714961 100644 --- a/code/web/app/app_achievements_admin/class/AdmPerk_class.php +++ b/code/web/app/app_achievements_admin/class/AdmPerk_class.php @@ -1,6 +1,55 @@ 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."
"; + #echo "--".$p."
"; $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); + #} } } } diff --git a/code/web/app/app_achievements_admin/class/CSRAchievement_class.php b/code/web/app/app_achievements_admin/class/CSRAchievement_class.php index 2bcd2ad56..8375e01b2 100644 --- a/code/web/app/app_achievements_admin/class/CSRAchievement_class.php +++ b/code/web/app/app_achievements_admin/class/CSRAchievement_class.php @@ -1,6 +1,68 @@ getID()."
"; + if(is_numeric($path)) { + //it's me (id == numeric) + if($this->getID() == $path) { + $this->grant($player); + #echo "grant()
"; + } + } + 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()
"; + } + } + #echo "end
"; + } + + 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); diff --git a/code/web/app/app_achievements_admin/class/CSRCategory_class.php b/code/web/app/app_achievements_admin/class/CSRCategory_class.php index 6a118c6e3..650469c65 100644 --- a/code/web/app/app_achievements_admin/class/CSRCategory_class.php +++ b/code/web/app/app_achievements_admin/class/CSRCategory_class.php @@ -1,6 +1,68 @@ getID()."
"; + if(is_numeric($path)) { + //it's me (id == numeric) + if($this->getID() == $path) { + $this->grant($player); + #echo "grant()
"; + } + } + 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()
"; + } + } + #echo "end
"; + } + + 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); diff --git a/code/web/app/app_achievements_admin/class/CSRObjective_class.php b/code/web/app/app_achievements_admin/class/CSRObjective_class.php index d336a2ade..71531d227 100644 --- a/code/web/app/app_achievements_admin/class/CSRObjective_class.php +++ b/code/web/app/app_achievements_admin/class/CSRObjective_class.php @@ -1,6 +1,68 @@ getID()."
"; + if(is_numeric($path)) { + //it's me (id == numeric) + if($this->getID() == $path) { + $this->grant($player); + #echo "grant()
"; + } + } + 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()
"; + } + } + #echo "end
"; + } + + 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; diff --git a/code/web/app/app_achievements_admin/class/CSRPerk_class.php b/code/web/app/app_achievements_admin/class/CSRPerk_class.php index fcd8bd668..97f34ec36 100644 --- a/code/web/app/app_achievements_admin/class/CSRPerk_class.php +++ b/code/web/app/app_achievements_admin/class/CSRPerk_class.php @@ -1,6 +1,68 @@ getID()."
"; + if(is_numeric($path)) { + //it's me (id == numeric) + if($this->getID() == $path) { + $this->grant($player); + #echo "grant()
"; + } + } + 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()
"; + } + } + #echo "end
"; + } + + 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); diff --git a/code/web/app/app_achievements_admin/include/adm_render_ach.php b/code/web/app/app_achievements_admin/include/adm_render_ach.php index 133d3ed56..1639d5b66 100644 --- a/code/web/app/app_achievements_admin/include/adm_render_ach.php +++ b/code/web/app/app_achievements_admin/include/adm_render_ach.php @@ -53,12 +53,17 @@ } function adm_render_category(&$cat) { - $html = ""; + $html = ""; if($_REQUEST['confirm'] == "delete") { $tmp = $cat->getElementByPath($_REQUEST['id']); if($tmp != null) { - $html .= "
+ $html .= "
Delete Are you sure you want to delete ".$tmp->getName()."

@@ -82,15 +87,15 @@ add new achievement

"; - if(($prog/$val) > 0.85) { + if(($prog/$val) > 0.5) { $html .= " ".nf($prog)." / ".nf($val)." "; } $html .= " "; - if(($prog/$val) <= 0.85) { + if(($prog/$val) <= 0.5) { $html .= " ".nf($prog)." / ".nf($val)." "; } $html .= "
- + - + - + - + - + - + - + - + - + - + @@ -187,41 +192,6 @@ return $html; } - function ach_render_achievement_done(&$ach) { - global $_CONF; - - $html = '
name:name:
naming template:naming template:
cult:cult:
civilization:civilization:
image:image:

perk name:perk name:
naming template:naming template:
perk yubopoints:perk yubopoints:
condition:condition:
condition value:condition value:
- - - - - - - - - - - - - - - -
-
- - - - -
'.$ach->getName().'
- '.$ach->getValueDone().'
-
'; - $html .= ach_render_perk_done($ach); - $html .= '
-
'; - - return $html; - } - function ach_render_achievement_open(&$ach) { global $_CONF,$menu; @@ -237,9 +207,9 @@
-
'; +
[ach:]'.$ach->getName().'
'; - $html .= "
[ach:]'.$ach->getName().'getDev()."&id=".$ach->getPathID()."'>getDev()."&id=".$ach->getPathID()."#ach_".$ach->getID()."'>getID()."' style='margin-bottom:3px;margin-top:3px;display:none;color:#000000;background-color:#FFFFFF;'> -
+ getID()."'>
edit achievement - + - + - + - + - + @@ -310,24 +280,24 @@ "; $html .= "
name:name: getName()."\" />
naming template:naming template: getTemplate()."\" />
cult:cult:
civilization:civilization:
image:image:
- + - + - + - + - + - + @@ -368,7 +338,7 @@ move achievement
name:name:
naming template:naming template:
yubopoints:yubopoints:
parent:parent:
condition:condition:
condition value:condition value:
- +
new category:new category: "; + $html .= "
[perk:]".$perk->getDisplayName()."
"; - $html .= ""; - #} - - $html .= "
[perk:]".$perk->getDisplayName()."getDev()."&id=".$perk->getPathID()."'>getDev()."&id=".$perk->getPathID()."#perk_".$perk->getID()."'>getID()."' style='margin-bottom:3px;margin-top:3px;display:none;color:#000000;background-color:#FFFFFF;'> - + getID()."'>
edit perk - + - + - + - + - + - + @@ -504,16 +474,16 @@ "; $html .= "
name:name:
naming template:naming template: getTemplate()."\" />
yubopoints:yubopoints:
parent:parent:
condition:condition:
condition value:condition value:
- + - + - + - + - + @@ -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 .= "
".$perk->getName()." ( ".date('d.m.Y',$perk->getDone())." ) ".$perk->getValue()."
"; - } - - return $html; - } - function ach_render_obj_list($obj) { $html = "
name:name:
type:type:
trigger condition:trigger condition:
trigger value:trigger value:
metalink:metalink:
"; @@ -624,16 +576,16 @@ #$perk = $elem->getParent(); $html .= "
- + - + - + - + - + @@ -699,7 +651,7 @@ $html .= " "; } - $html .= "[obj:]".$obj->getDisplayName().""; + $html .= "[obj:]".$obj->getDisplayName().""; return $html; } @@ -719,7 +671,7 @@ return "
name:name:
type:type:
trigger condition:trigger condition:
trigger value:trigger value:
metalink:metalink:
- +
getMetaImage()."' width='20px' /> [obj:]".$obj->getDisplayName()." [obj:]".$obj->getDisplayName()."
"; } @@ -750,7 +702,7 @@ else { $col = "#999999"; } - $html .= "
[obj: untitled]
"; + $html .= ""; #} #$html .= ach_render_progressbar($obj->getProgress(),$obj->getValue(),350); diff --git a/code/web/app/app_achievements_admin/include/adm_render_atom.php b/code/web/app/app_achievements_admin/include/adm_render_atom.php index 133d3ed56..f1816f75e 100644 --- a/code/web/app/app_achievements_admin/include/adm_render_atom.php +++ b/code/web/app/app_achievements_admin/include/adm_render_atom.php @@ -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 .= " + + $html .= "
"; if($sub == 0) { $html .= ""; @@ -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 .= ""; + function atom_render_category(&$cat) { + $html = " + + + + "; + $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 = '
getImage()."' />
- - - - - - - - - - - - - - - -
-
- - - - -
'.$ach->getName().'
- '.$ach->getValueDone().'
-
'; - $html .= ach_render_perk_done($ach); - $html .= '
-
'; - - return $html; - } - function ach_render_achievement_open(&$ach) { global $_CONF,$menu; - $html = '
- - - - - - - - - - - - - - - -
-
- - - -
'; - - $html .= " -
[ach:]'.$ach->getName().'getDev()."&id=".$ach->getPathID()."'> "; + $open = explode(";",$_REQUEST['id']); - $html .= " "; + $o = "none"; + if($open[1] == $ach->getID()) { + $o = "block"; + } - $html .= " "; - - $html .= "   getPathID()."'>
"; - - $html .= '
-
'; - - $html .= ""; - - $html .= ""; - - $html .= ""; - - $html .= ach_render_perk_open($ach); - $html .= '
-
'; + $html = "
+
[+] ".$ach->getName()." (ties= race: ".$ach->getTieRace()."; civ: ".$ach->getTieCiv()."; cult: ".$ach->getTieCult().")
+
".ach_render_perk_open($ach)."
+
"; 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 .= ""; - $html .= " -
[perk:]".$perk->getDisplayName()."getDev()."&id=".$perk->getPathID()."'> "; - - $html .= " "; - - $html .= "   getPathID()."'>
"; - - $html .= ""; - - $html .= ""; - #} - #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 .= "
".$perk->getName()." ( ".date('d.m.Y',$perk->getDone())." ) ".$perk->getValue()."
"; + $html .= "
+
[+] ".$perk->getDisplayName()." (condition= ".$perk->getCondition().": ".$perk->getConditionValue().")
+
".ach_render_obj_list($perk->getIterator())."
+
"; } return $html; } function ach_render_obj_list($obj) { - $html = "
"; + $html = ""; - #$i = 0; - #$skip = false; + $open = explode(";",$_REQUEST['id']); while($obj->hasNext()) { - #foreach($obj as $elem) { $elem = $obj->getNext(); - #if(($i%2) == 0) { - $html .= ""; + + #$o = "none"; + #if($open[3] == $elem->getID()) { + $o = "block"; #} + $html .= "
+
[+] ".$elem->getDisplayName()." (condition= ".$elem->getCondition().": ".$elem->getValue().")
+
+ +
"; - #} - - switch($elem->getDisplay()) { - case "meta": - $html .= ""; - #} - $html .= ""; - #$i++; - break; - case "simple": - $html .= ""; - break; - case "hidden": - default: - //do nothing - #$skip = true; - #if(($i%2) == 1) { - # $html .= ""; - #} - $html .= ""; - #$i++; - break; - } - - $html .= " -
".ach_render_obj_meta($elem).""; - break; - case "value": - #if(($i%2) == 1) { - # $html .= "
".ach_render_obj_value($elem)."".ach_render_obj_simple($elem)."
".ach_render_obj_hidden($elem).""; - - #$html .= " "; - - $html .= "   getPathID()."'>
"; - - #$perk = $elem->getParent(); - - $html .= ""; - - #if(($i%2) == 1) { - $html .= "
+ + + + + + + + + +
 mandatory
+
+
+ + + ".ach_render_atom_list($elem->getIterator())." + + "; + } + + return $html; + } + + function ach_render_atom_list($atom) { + $html = ""; + + while($atom->hasNext()) { + $elem = $atom->getNext(); - #if(!$skip) { - # $i++; - #} - #$skip = false; + $html .= "
getPathID()."#obj_".$elem->getObjective()."'> + + + + + + + + + + + + + + +
getPathID()."#obj_".$elem->getObjective()."'>[X]
".$elem->getRulesetParsed()."
getMandatory() == 1) { + $html .= " checked='checked'"; + } + $html .= " /> mandatory
+

"; } - #if(($i%2) == 1) { - # $html .= "
"; - - return $html; - } - - function ach_render_obj_simple(&$obj) { - global $_CONF; - $html = ""; - if($obj->isdone()) { - $html .= " "; - } - else { - $html .= " "; - } - - $html .= "[obj:]".$obj->getDisplayName().""; - - return $html; - } - - function ach_render_obj_meta(&$obj) { - global $_CONF; - $html = ""; - if($obj->isdone()) { - $col = "#71BE02"; - $grey = ""; - } - else { - $col = "#999999"; - $grey = "grey/"; - } - - return " - - - - -
getMetaImage()."' width='20px' /> [obj:]".$obj->getDisplayName()."
"; - } - - function ach_render_obj_value(&$obj) { - $html = ""; - #if($obj->getName() != null) { - if($obj->isdone()) { - $col = "#71BE02"; - } - else { - $col = "#999999"; - } - $html .= "
[obj:]".$obj->getDisplayName()."
"; - #} - - $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 .= "
[obj: untitled]
"; - #} - - #$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 = " - - - - - -
"; - if(($prog/$val) > 0.85) { - $html .= " ".nf($prog)." / ".nf($val)." "; - } - $html .= ""; - if(($prog/$val) <= 0.85) { - $html .= " ".nf($prog)." / ".nf($val)." "; - } - $html .= "
"; - - return $html; - } - - - function ach_render_tiebar($cult = "c_neutral", $civ = "c_neutral",&$cat) { - global $_USER,$_CONF; - - $html = " - -
- - "; - if($cat->isTiedCult()) { - $html.= " - +
- - + "; + if($sub == 0) { + $html .= ""; + } + $html .= " + +
getImage()."' />".$curr->getName()."
"; + if($curr->hasOpenCat() != 0) { + $html .= "
".adm_render_mnode($curr,($sub+4))."
"; + } + } + + return $html; + } + + function atom_render_category(&$cat) { + $html = ""; + + $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 = "
+
[+] ".$ach->getName()." (ties= race: ".$ach->getTieRace()."; civ: ".$ach->getTieCiv()."; cult: ".$ach->getTieCult().")
+
".ach_render_perk_open($ach)."
+
"; + + 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 .= "
+
[+] ".$perk->getDisplayName()." (condition= ".$perk->getCondition().": ".$perk->getConditionValue().")
+
".ach_render_obj_list($perk->getIterator())."
+
"; + } + + 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 .= "
+
[+] ".$elem->getDisplayName()." (condition= ".$elem->getCondition().": ".$elem->getValue().")
+
+ + + ".ach_render_atom_list($elem->getIterator())." +
+
"; + } + + return $html; + } + + function ach_render_atom_list($atom) { + $html = ""; + + while($atom->hasNext()) { + $elem = $atom->getNext(); + + $html .= "
getPathID()."#obj_".$elem->getObjective()."'> + + + + + + + + + + + + + + +
getPathID()."#obj_".$elem->getObjective()."'>[X]
".$elem->getRulesetParsed()."
getMandatory() == 1) { + $html .= " checked='checked'"; + } + $html .= " /> mandatory
+

"; + } + + return $html; + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements_admin/include/adm_render_menu.php b/code/web/app/app_achievements_admin/include/adm_render_menu.php index d7fc5669d..ffc4505f7 100644 --- a/code/web/app/app_achievements_admin/include/adm_render_menu.php +++ b/code/web/app/app_achievements_admin/include/adm_render_menu.php @@ -44,7 +44,7 @@ "; if($_REQUEST['ac_id'] > 0 && $_REQUEST['confirm'] == "delete") { - $curr = $menu->getChildDataByID($_REQUEST['ac_id']); + $curr = $menu->getNode($_REQUEST['ac_id']); $html .= "
Are you sure you want to delete this category?"; @@ -95,8 +95,8 @@ if($curr->inDev()) { $html .= ""; } - $html .= "
getID()."'> -
+
create new sub-category @@ -135,7 +135,7 @@ } $html .= "