#1470 some cleanup; some bugfix; some documentation
--HG-- branch : gsoc2012-achievementshg/feature/gsoc2013-dfighter
parent
c96ff882cd
commit
c888a5249e
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
ini_set("display_errors","1");
|
||||
|
||||
if(file_exists("monitor.stop")) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
require_once("class/mySQL_class.php");
|
||||
require_once("conf.php");
|
||||
|
||||
//create database connection
|
||||
$DBc = new mySQL($CONF['mysql_error']);
|
||||
$DBc->connect($CONF['mysql_server'],$CONF['mysql_user'],$CONF['mysql_pass'],$CONF['mysql_database']);
|
||||
|
||||
//check status
|
||||
$res = $DBc->sendSQL("SELECT * FROM ach_monitor_status ORDER by ams_start DESC LIMIT 0,1","ARRAY");
|
||||
|
||||
if(($res[0]['ams_start'] < (time()-$CONF['timeout']) && $res[0]['ams_end'] == 0) || ($res[0]['ams_end'] > 0 && $res[0]['ams_end'] < (time()-$CONF['timeout']))) {
|
||||
$fp = fsockopen($CONF['self_host'], 80, $errno, $errstr, 30);
|
||||
if(!$fp) {
|
||||
logf("ERROR: self call; socket: ".$errstr." (."$errno.")");
|
||||
}
|
||||
else {
|
||||
$out = "GET ".$CONF['self_path']." HTTP/1.1\r\n";
|
||||
$out .= "Host: ".$CONF['self_host']."\r\n";
|
||||
$out .= "Connection: Close\r\n\r\n";
|
||||
|
||||
fwrite($fp, $out);
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
exit(0);
|
||||
?>
|
@ -1,207 +0,0 @@
|
||||
<?php
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
ini_set("display_errors","1");
|
||||
|
||||
if(file_exists("parser.stop")) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
require_once("class/mySQL_class.php");
|
||||
require_once("conf.php");
|
||||
require_once("inlcude/functions_inc.php");
|
||||
|
||||
$logfile = false;
|
||||
if($CONF['logging'] == true) {
|
||||
require_once("class/Logfile_class.php");
|
||||
#$logfile = fopen($CONF['logfile'].'.'.date("Ymd",time()).'.txt','a');
|
||||
$logfile = new Logfile($CONF['logfile']);
|
||||
}
|
||||
|
||||
//set mode: cron || single with given cid
|
||||
#MISSING: conf to allow external calls; whitelist ips
|
||||
$MODE = "CRON";
|
||||
if($_REQUEST["cid"] > 0 || $_REQUEST["invoke"] == "TRUE") {
|
||||
if($_REQUEST["cid"] > 0 && $_REQUEST["invoke"] == "TRUE") {
|
||||
$MODE = "SINGLE";
|
||||
$CID = $DBc->mre($_REQUEST["cid"]);
|
||||
}
|
||||
else {
|
||||
$e = "Failed to start SINGLE mode; cid=".$_REQUEST["cid"];
|
||||
logf($e);
|
||||
die($e);
|
||||
}
|
||||
}
|
||||
|
||||
//create database connection
|
||||
$DBc = new mySQL($CONF['mysql_error']);
|
||||
$DBc->connect($CONF['mysql_server'],$CONF['mysql_user'],$CONF['mysql_pass'],$CONF['mysql_database']);
|
||||
|
||||
if($MODE == "CRON") {
|
||||
$RID = $DBc->sendSQL("INSERT INTO ach_monitor_state (ams_start,ams_end) VALUES ('".time()."','0')","INSERT"); // insert run into monitoring table
|
||||
}
|
||||
|
||||
require_once("class/DataSourceHandler_class.php");
|
||||
require_once("class/DataSource_abstract.php");
|
||||
|
||||
require_once("class/Atom_class.php");
|
||||
|
||||
//create datasource handler
|
||||
$_DATA = new DataSourceHandler();
|
||||
foreach($CONF['data_source'] as $elem) { //populate
|
||||
require_once("source/".$elem."/".$elem."_class.php");
|
||||
eval('$tmp = new '.$elem.'();');
|
||||
$_DATA->registerDataSource($tmp);
|
||||
}
|
||||
|
||||
//synch chars from ring_open character table
|
||||
if($CONF['synch_chars'] == true) {
|
||||
$DBc_char = new mySQL($CONF['mysql_error']);
|
||||
$DBc_char->connect($CONF['char_mysql_server'],$CONF['char_mysql_user'],$CONF['char_mysql_pass'],$CONF['char_mysql_database']);
|
||||
|
||||
$DBc->sendSQL("UPDATE ach_monitor_character SET amc_confirmed='0'","NONE");
|
||||
|
||||
$res = $DBc_char->sendSQL("SELECT char_id,last_played_date FROM characters","ARRAY");
|
||||
$sz = sizeof($res);
|
||||
for($i=0;$i<$sz;$i++) {
|
||||
$DBc->sendSQL("INSERT INTO ach_monitor_character (amc_character,amc_last_import,amc_last_login,amc_confirmed) VALUES ('".$res[$i]['char_id']."','0','".dateTime_to_timestamp($res[$i]['last_played_date'])."','1') ON DUPLICATE KEY UPDATE amc_confirmed='1', amc_last_login='".dateTime_to_timestamp($res[$i]['last_played_date'])."'","NONE");
|
||||
}
|
||||
|
||||
$DBc->sendSQL("DELETE FROM ach_monitor_character WHERE amc_confirmed='0'","NONE"); //remove deleted characters
|
||||
//remove data for deleted chars
|
||||
$DBc->sendSQL("DELETE FROM ach_player_atom WHERE NOT EXISTS (SELECT * FROM ach_monitor_character WHERE amc_character='apa_player')","NONE");
|
||||
$DBc->sendSQL("DELETE FROM ach_player_objective WHERE NOT EXISTS (SELECT * FROM ach_monitor_character WHERE amc_character='apo_player')","NONE");
|
||||
$DBc->sendSQL("DELETE FROM ach_player_perk WHERE NOT EXISTS (SELECT * FROM ach_monitor_character WHERE amc_character='app_player')","NONE");
|
||||
$DBc->sendSQL("DELETE FROM ach_player_valuecache WHERE NOT EXISTS (SELECT * FROM ach_monitor_character WHERE amc_character='apv_player')","NONE");
|
||||
}
|
||||
|
||||
// fetch candidates
|
||||
if($MODE == "SINGLE") {
|
||||
$chars = array();
|
||||
$chars[] = array('amc_character',$CID);
|
||||
}
|
||||
else {
|
||||
#$chars = array();
|
||||
|
||||
$DBc->sendSQL("UPDATE ach_monitor_character SET amc_working='0' WHERE amc_last_import<'".(time()-60*60)."'"); // unlock if something went wrong
|
||||
|
||||
$DBc->sendSQL("UPDATE ach_monitor_character SET amc_working='".$RID."' WHERE amc_last_login>amc_last_import AND amc_working='0'","NONE");
|
||||
|
||||
$chars = $DBc->sendSQL("SELECT amc_character FROM ach_monitor_character WHERE amc_working='".$RID."'","ARRAY");
|
||||
}
|
||||
|
||||
|
||||
//fork if enabled in conf
|
||||
if($CONF['fork'] == true && $MODE == "CRON") {
|
||||
require_once("class/ParallelCURL_class.php");
|
||||
|
||||
$max_requests = 0;
|
||||
$curl_options = array(
|
||||
CURLOPT_SSL_VERIFYPEER => FALSE,
|
||||
CURLOPT_SSL_VERIFYHOST => FALSE,
|
||||
CURLOPT_USERAGENT, 'Ryzom - Achievement Tracker',
|
||||
);
|
||||
|
||||
$_CURL = new ParallelCurl($max_requests, $curl_options);
|
||||
|
||||
foreach($chars as $elem) {
|
||||
$_CURL->startRequest("http://".$CONF['self_host']."/".$CONF['self_path']."?invoke=TRUE&cid=".$elem['amc_character'], 'received_char',null);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$atom_list = array();
|
||||
|
||||
foreach($chars as $elem) {
|
||||
$_DATA->freeData($elem['amc_character']);
|
||||
|
||||
#STEP 1: evaluate atoms
|
||||
|
||||
//get unfinished perks which have no parent or complete parent
|
||||
#$res = $DBc->sendSQL("SELECT ap_id FROM ach_perk WHERE (ap_parent IS NULL OR EXISTS (SELECT * FROM ach_player_perk WHERE app_player='".$elem['amc_character']."' AND app_perk=ap_parent)) AND (NOT EXISTS (SELECT * FROM ach_player_perk WHERE app_player='".$elem['amc_character']."' AND app_perk=ap_id))","ARRAY");
|
||||
|
||||
//get all unfinished perks since perks my not directly inherit objectives...
|
||||
$res = $DBc->sendSQL("SELECT ap_id FROM ach_perk WHERE NOT EXISTS (SELECT * FROM ach_player_perk WHERE app_player='".$elem['amc_character']."' AND app_perk=ap_id)","ARRAY");
|
||||
foreach($res as $perk) {
|
||||
//get unfinished atoms belonging to unfinished objectives
|
||||
$res = $DBc->sendSQL("SELECT ach_atom.* FROM ach_atom,ach_objective WHERE ao_perk='".$perk['ap_id']."' AND ao_id=atom_objective AND NOT EXISTS (SELECT * FROM ach_player_objective WHERE apo_player='".$elem['amc_character']."' AND apo_objective=ao_id)","ARRAY");
|
||||
foreach($res2 as $atom) {
|
||||
if(!isset($atom_list[$atom['atom_id']])) { // only load if not already cached
|
||||
$atom_list[$atom['atom_id']] = new Atom($atom);
|
||||
}
|
||||
|
||||
$atom_list[$atom['atom_id']]->evalRuleset($elem['amc_character']);
|
||||
}
|
||||
}
|
||||
|
||||
$_DATA->freeData($elem['amc_character']);
|
||||
|
||||
$DBc->sendSQL("UPDATE ach_monitor_character SET amc_last_import='".time()."', amc_working='0' WHERE amc_character='".$elem['amc_character']."' AND amc_working='".$RID."'","NONE");
|
||||
|
||||
#STEP 2: detect obj/perk progression
|
||||
//obj
|
||||
$res = $DBc->sendSQL("SELECT ao_id FROM ach_objective WHERE ao_condition='all' AND NOT EXISTS (SELECT * FROM ach_atom WHERE atom_objective=ao_id AND NOT EXISTS (SELECT * FROM ach_player_atom WHERE apa_atom=atom_id AND apa_state!='GRANT' AND apa_player='".$elem['amc_character']."'))","ARRAY");
|
||||
$sz = sizeof($res);
|
||||
for($i=0;$i<$sz;$i++) {
|
||||
$DBc->sendSQL("INSERT INTO ach_player_objective (apo_objective,apo_player,apo_date) VALUES ('".$res[$i]['ao_id']."','".$elem['amc_character']."','".time()."')","NONE");
|
||||
}
|
||||
|
||||
$res = $DBc->sendSQL("SELECT ao_id FROM ach_objective WHERE ao_condition='value' AND ao_value<=(SELECT count(*) FROM ach_atom WHERE atom_objective=ao_id AND EXISTS (SELECT * FROM ach_player_atom WHERE apa_atom=atom_id AND apa_state='GRANT' AND apa_player='".$elem['amc_character']."'))","ARRAY");
|
||||
$sz = sizeof($res);
|
||||
for($i=0;$i<$sz;$i++) {
|
||||
$DBc->sendSQL("INSERT INTO ach_player_objective (apo_objective,apo_player,apo_date) VALUES ('".$res[$i]['ao_id']."','".$elem['amc_character']."','".time()."')","NONE");
|
||||
}
|
||||
|
||||
$res = $DBc->sendSQL("SELECT ao_id FROM ach_objective WHERE ao_condition='any' AND EXISTS (SELECT * FROM ach_atom WHERE atom_objective=ao_id AND EXISTS (SELECT * FROM ach_player_atom WHERE apa_atom=atom_id AND apa_state='GRANT' AND apa_player='".$elem['amc_character']."'))","ARRAY");
|
||||
$sz = sizeof($res);
|
||||
for($i=0;$i<$sz;$i++) {
|
||||
$DBc->sendSQL("INSERT INTO ach_player_objective (apo_objective,apo_player,apo_date) VALUES ('".$res[$i]['ao_id']."','".$elem['amc_character']."','".time()."')","NONE");
|
||||
}
|
||||
|
||||
//perk
|
||||
$res = $DBc->sendSQL("SELECT ap_id FROM ach_perk WHERE ap_condition='all' AND NOT EXISTS (SELECT * FROM ach_objective WHERE ao_perk=ap_id AND NOT EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_state!='GRANT' AND apo_player='".$elem['amc_character']."'))","ARRAY");
|
||||
$sz = sizeof($res);
|
||||
for($i=0;$i<$sz;$i++) {
|
||||
$DBc->sendSQL("INSERT INTO ach_player_perk (app_objective,app_player,app_date) VALUES ('".$res[$i]['ap_id']."','".$elem['amc_character']."','".time()."')","NONE");
|
||||
}
|
||||
|
||||
$res = $DBc->sendSQL("SELECT ap_id FROM ach_perk WHERE ap_condition='value' AND ap_value<=(SELECT count(*) FROM ach_objective WHERE ao_perk=ap_id AND EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_state='GRANT' AND apo_player='".$elem['amc_character']."'))","ARRAY");
|
||||
$sz = sizeof($res);
|
||||
for($i=0;$i<$sz;$i++) {
|
||||
$DBc->sendSQL("INSERT INTO ach_player_perk (app_objective,app_player,app_date) VALUES ('".$res[$i]['ap_id']."','".$elem['amc_character']."','".time()."')","NONE");
|
||||
}
|
||||
|
||||
$res = $DBc->sendSQL("SELECT ap_id FROM ach_perk WHERE ap_condition='any' AND EXISTS (SELECT * FROM ach_objective WHERE ao_perk=ap_id AND EXISTS (SELECT * FROM ach_player_objective WHERE apo_objective=ao_id AND apo_state='GRANT' AND apo_player='".$elem['amc_character']."'))","ARRAY");
|
||||
$sz = sizeof($res);
|
||||
for($i=0;$i<$sz;$i++) {
|
||||
$DBc->sendSQL("INSERT INTO ach_player_perk (app_objective,app_player,app_date) VALUES ('".$res[$i]['ap_id']."','".$elem['amc_character']."','".time()."')","NONE");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($CONF['sleep_time'] != false) {
|
||||
sleep($CONF['sleep_time']);
|
||||
}
|
||||
|
||||
//self call if cron mode is on
|
||||
if($MODE == "CRON" && $CONF['enable_selfcall'] == true) {
|
||||
$DBc->sendSQL("UPDATE ach_monitor_state SET ams_end='".time()."' WHERE ams_id='".$RID."'","NONE");
|
||||
|
||||
$fp = fsockopen($CONF['self_host'], 80, $errno, $errstr, 30);
|
||||
if(!$fp) {
|
||||
logf("ERROR: self call; socket: ".$errstr." (."$errno.")");
|
||||
}
|
||||
else {
|
||||
$out = "GET ".$CONF['self_path']." HTTP/1.1\r\n";
|
||||
$out .= "Host: ".$CONF['self_host']."\r\n";
|
||||
$out .= "Connection: Close\r\n\r\n";
|
||||
|
||||
fwrite($fp, $out);
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
if($logfile) {
|
||||
$logfile->write();
|
||||
}
|
||||
|
||||
exit(0);
|
||||
?>
|
@ -1,47 +0,0 @@
|
||||
<?php
|
||||
abstract class DataSource {
|
||||
private $data;
|
||||
private $types = array();
|
||||
private $write = false;
|
||||
|
||||
function DataSource() {
|
||||
require_once(dirname(__FILE__)."/conf.php");
|
||||
|
||||
$this->types = $CONF["types"];
|
||||
$this->write = $CONF["write"];
|
||||
$this->data = array();
|
||||
}
|
||||
|
||||
function freeData($ident) {
|
||||
unset $this->data[$ident];
|
||||
}
|
||||
|
||||
function getTypes() {
|
||||
return $this->types;
|
||||
}
|
||||
|
||||
function isWriteable() {
|
||||
return $this->write;
|
||||
}
|
||||
|
||||
function getData($ident,$type,$mode,$cond) {
|
||||
if(!isset($this->data[$ident])) {
|
||||
$this->data[$ident] = array();
|
||||
}
|
||||
|
||||
if(!isset($this->data[$ident][$type])) {
|
||||
$this->loadData($ident,$type);
|
||||
}
|
||||
|
||||
if($mode == "*") {
|
||||
return $this->data[$ident][$type]->getRows($cond);
|
||||
}
|
||||
else {
|
||||
return $this->data[$ident][$type]->countRows($cond);
|
||||
}
|
||||
}
|
||||
|
||||
abstract function loadData($ident,$type);
|
||||
abstract function writeData($ident,$type,$keys,$data);
|
||||
}
|
||||
?>
|
@ -1,88 +0,0 @@
|
||||
<?php
|
||||
class DataTable {
|
||||
private $table;
|
||||
|
||||
function DataTable(&$res) {
|
||||
$this->table = $res;
|
||||
}
|
||||
|
||||
function countRows(&$cond) {
|
||||
$rules = $this->parseCond($cond);
|
||||
|
||||
$res = 0;
|
||||
|
||||
foreach($this->table as $elem) {
|
||||
$m = true;
|
||||
|
||||
foreach($rules as $r) {
|
||||
$tmp = '
|
||||
if($elem[$r[0]] '.$r[1].') { }
|
||||
else {
|
||||
$m = false;
|
||||
}
|
||||
';
|
||||
|
||||
try {
|
||||
eval($tmp);
|
||||
}
|
||||
catch(Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
if($m == true) {
|
||||
$res++;
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
function getRows(&$cond) {
|
||||
$rules = $this->parseCond($cond);
|
||||
|
||||
$res = array();
|
||||
|
||||
foreach($this->table as $elem) {
|
||||
$m = true;
|
||||
|
||||
foreach($rules as $r) {
|
||||
$tmp = '
|
||||
if($elem[$r[0]] '.$r[1].') { }
|
||||
else {
|
||||
$m = false;
|
||||
}
|
||||
';
|
||||
|
||||
try {
|
||||
eval($tmp);
|
||||
}
|
||||
catch(Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
if($m == true) {
|
||||
$res[] = $elem;
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
private function parseCond(&$cond) {
|
||||
$c = array();
|
||||
|
||||
$tmp = explode("and",strtolower($cond));
|
||||
|
||||
foreach($tmp as $elem) {
|
||||
$matches = array();
|
||||
preg_match("#([a-zA-Z0-9_]+) ?([.]*)#", trim($elem), $matches);
|
||||
|
||||
$c[] = array($matches[1],$matches[2]);
|
||||
}
|
||||
|
||||
return $c;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,160 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This class is designed to make it easy to run multiple curl requests in parallel, rather than
|
||||
// waiting for each one to finish before starting the next. Under the hood it uses curl_multi_exec
|
||||
// but since I find that interface painfully confusing, I wanted one that corresponded to the tasks
|
||||
// that I wanted to run.
|
||||
//
|
||||
// To use it, first create the ParallelCurl object:
|
||||
//
|
||||
// $parallelcurl = new ParallelCurl(10);
|
||||
//
|
||||
// The first argument to the constructor is the maximum number of outstanding fetches to allow
|
||||
// before blocking to wait for one to finish. You can change this later using setMaxRequests()
|
||||
// The second optional argument is an array of curl options in the format used by curl_setopt_array()
|
||||
//
|
||||
// Next, start a URL fetch:
|
||||
//
|
||||
// $parallelcurl->startRequest('http://example.com', 'on_request_done', array('something'));
|
||||
//
|
||||
// The first argument is the address that should be fetched
|
||||
// The second is the callback function that will be run once the request is done
|
||||
// The third is a 'cookie', that can contain arbitrary data to be passed to the callback
|
||||
//
|
||||
// This startRequest call will return immediately, as long as less than the maximum number of
|
||||
// requests are outstanding. Once the request is done, the callback function will be called, eg:
|
||||
//
|
||||
// on_request_done($content, 'http://example.com', $ch, array('something'));
|
||||
//
|
||||
// The callback should take four arguments. The first is a string containing the content found at
|
||||
// the URL. The second is the original URL requested, the third is the curl handle of the request that
|
||||
// can be queried to get the results, and the fourth is the arbitrary 'cookie' value that you
|
||||
// associated with this object. This cookie contains user-defined data.
|
||||
//
|
||||
// By Pete Warden <pete@petewarden.com>, freely reusable, see http://petewarden.typepad.com for more
|
||||
|
||||
class ParallelCurl {
|
||||
|
||||
public $max_requests;
|
||||
public $options;
|
||||
|
||||
public $outstanding_requests;
|
||||
public $multi_handle;
|
||||
|
||||
public function __construct($in_max_requests = 10, $in_options = array()) {
|
||||
$this->max_requests = $in_max_requests;
|
||||
$this->options = $in_options;
|
||||
|
||||
$this->outstanding_requests = array();
|
||||
$this->multi_handle = curl_multi_init();
|
||||
}
|
||||
|
||||
//Ensure all the requests finish nicely
|
||||
public function __destruct() {
|
||||
$this->finishAllRequests();
|
||||
}
|
||||
|
||||
// Sets how many requests can be outstanding at once before we block and wait for one to
|
||||
// finish before starting the next one
|
||||
public function setMaxRequests($in_max_requests) {
|
||||
$this->max_requests = $in_max_requests;
|
||||
}
|
||||
|
||||
// Sets the options to pass to curl, using the format of curl_setopt_array()
|
||||
public function setOptions($in_options) {
|
||||
|
||||
$this->options = $in_options;
|
||||
}
|
||||
|
||||
// Start a fetch from the $url address, calling the $callback function passing the optional
|
||||
// $user_data value. The callback should accept 3 arguments, the url, curl handle and user
|
||||
// data, eg on_request_done($url, $ch, $user_data);
|
||||
public function startRequest($url, $callback, $user_data = array(), $post_fields=null) {
|
||||
|
||||
if( $this->max_requests > 0 )
|
||||
$this->waitForOutstandingRequestsToDropBelow($this->max_requests);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, $this->options);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
|
||||
if (isset($post_fields)) {
|
||||
curl_setopt($ch, CURLOPT_POST, TRUE);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
|
||||
}
|
||||
|
||||
curl_multi_add_handle($this->multi_handle, $ch);
|
||||
|
||||
$ch_array_key = (int)$ch;
|
||||
|
||||
$this->outstanding_requests[$ch_array_key] = array(
|
||||
'url' => $url,
|
||||
'callback' => $callback,
|
||||
'user_data' => $user_data,
|
||||
);
|
||||
|
||||
$this->checkForCompletedRequests();
|
||||
}
|
||||
|
||||
// You *MUST* call this function at the end of your script. It waits for any running requests
|
||||
// to complete, and calls their callback functions
|
||||
public function finishAllRequests() {
|
||||
$this->waitForOutstandingRequestsToDropBelow(1);
|
||||
}
|
||||
|
||||
// Checks to see if any of the outstanding requests have finished
|
||||
private function checkForCompletedRequests() {
|
||||
|
||||
// Call select to see if anything is waiting for us
|
||||
if (curl_multi_select($this->multi_handle, 0.0) === -1)
|
||||
return;
|
||||
|
||||
// Since something's waiting, give curl a chance to process it
|
||||
do {
|
||||
$mrc = curl_multi_exec($this->multi_handle, $active);
|
||||
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
|
||||
|
||||
// Now grab the information about the completed requests
|
||||
while ($info = curl_multi_info_read($this->multi_handle)) {
|
||||
|
||||
$ch = $info['handle'];
|
||||
$ch_array_key = (int)$ch;
|
||||
|
||||
if (!isset($this->outstanding_requests[$ch_array_key])) {
|
||||
die("Error - handle wasn't found in requests: '$ch' in ".
|
||||
print_r($this->outstanding_requests, true));
|
||||
}
|
||||
|
||||
$request = $this->outstanding_requests[$ch_array_key];
|
||||
|
||||
$url = $request['url'];
|
||||
$content = curl_multi_getcontent($ch);
|
||||
$callback = $request['callback'];
|
||||
$user_data = $request['user_data'];
|
||||
|
||||
call_user_func($callback, $content, $url, $ch, $user_data);
|
||||
|
||||
unset($this->outstanding_requests[$ch_array_key]);
|
||||
|
||||
curl_multi_remove_handle($this->multi_handle, $ch);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Blocks until there's less than the specified number of requests outstanding
|
||||
private function waitForOutstandingRequestsToDropBelow($max)
|
||||
{
|
||||
while (1) {
|
||||
$this->checkForCompletedRequests();
|
||||
if (count($this->outstanding_requests)<$max)
|
||||
break;
|
||||
|
||||
usleep(10000);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
@ -1,132 +0,0 @@
|
||||
private function parseRuleset() {
|
||||
$this->ruleset_parsed = $this->ruleset;
|
||||
#WORKPAD:####
|
||||
/*
|
||||
Trigger:
|
||||
by value
|
||||
(by event)
|
||||
|
||||
Sources:
|
||||
XML
|
||||
valuecache
|
||||
ring_open
|
||||
(Achievement Service)
|
||||
(Mirror Service)
|
||||
|
||||
Keywords:
|
||||
VALUE
|
||||
GRANT:EVENT player_death
|
||||
DENY:TIMER 3600
|
||||
RESET
|
||||
RESET_ALL
|
||||
UNLOCK
|
||||
UNLOCK_ALL
|
||||
|
||||
IF
|
||||
SCRIPT
|
||||
MSG
|
||||
|
||||
VALUE dappers = c_money
|
||||
IF(dappers >= 5000) {
|
||||
GRANT
|
||||
}
|
||||
|
||||
VALUE sum = c_cache:sum
|
||||
IF(sum > 1000) {
|
||||
GRANT
|
||||
}
|
||||
|
||||
VALUE tmp = c_fame[scorchers]
|
||||
IF(tmp == 0) {
|
||||
DENY:3600
|
||||
}
|
||||
|
||||
VALUE x = c_pos_x
|
||||
VALUE y = c_pos_y
|
||||
SCRIPT inside(x,y) {
|
||||
IF(MSG == "Majestic Garden") {
|
||||
GRANT
|
||||
}
|
||||
}
|
||||
|
||||
EVENT player_death
|
||||
ON player_death {
|
||||
UNLOCK
|
||||
}
|
||||
|
||||
EVENT region_changed
|
||||
ON region_changed {
|
||||
IF(MSG == "Majestic Garden") {
|
||||
GRANT
|
||||
}
|
||||
}
|
||||
*/
|
||||
#############
|
||||
|
||||
|
||||
#VALUE var = name;
|
||||
$match = array();
|
||||
preg_match_all("#VALUE ([a-zA-Z0-9_]) ?= ?([a-zA-Z0-9_]);#", $this->ruleset_parsed, $match,PREG_PATTERN_ORDER);
|
||||
foreach($match[0] as $key=>$elem) {
|
||||
$tmp = '$'.$match[1][$key].' = $_DATA->getData("VALUE","'.$match[2][$key].'",$user);\n';
|
||||
$tmp .= 'if($'.$match[1][$key].' == ) {\n';
|
||||
$tmp .= 'ERROR\n';
|
||||
$tmp .= '}\n';
|
||||
$this->ruleset_parsed = str_replace($elem,$tmp,$this->ruleset_parsed);
|
||||
}
|
||||
|
||||
|
||||
#IF(statement) { }
|
||||
$match = array();
|
||||
preg_match_all("#IF ?\(([^\)]*)\) ?{#", $this->ruleset_parsed, $match,PREG_PATTERN_ORDER);
|
||||
foreach($match[0] as $key=>$elem) {
|
||||
$tmp = 'if() {\n';
|
||||
$this->ruleset_parsed = str_replace($elem,$tmp,$this->ruleset_parsed);
|
||||
}
|
||||
|
||||
|
||||
SCRIPT script(a,r,g,s) {
|
||||
MSG
|
||||
}
|
||||
|
||||
#EVENT name;
|
||||
$match = array();
|
||||
preg_match_all("#EVENT ([^;]*);#", $this->ruleset_parsed, $match,PREG_PATTERN_ORDER);
|
||||
foreach($match[0] as $key=>$elem) {
|
||||
$tmp = '';
|
||||
$this->ruleset_parsed = str_replace($elem,$tmp,$this->ruleset_parsed);
|
||||
}
|
||||
|
||||
ON name {
|
||||
MSG
|
||||
}
|
||||
|
||||
#GRANT;
|
||||
#GRANT:EVENT name;
|
||||
#GRANT:TIMER seconds;
|
||||
$match = array();
|
||||
preg_match_all("#GRANT:?([^;]*);#", $this->ruleset_parsed, $match,PREG_PATTERN_ORDER);
|
||||
foreach($match[0] as $key=>$elem) {
|
||||
$tmp = '$this->grant("'.$match[1][$key].'");';
|
||||
$this->ruleset_parsed = str_replace($elem,$tmp,$this->ruleset_parsed);
|
||||
}
|
||||
|
||||
#DENY;
|
||||
#DENY:EVENT name;
|
||||
#DENY:TIMER seconds;
|
||||
$match = array();
|
||||
preg_match_all("#DENY:?([^;]*);#", $this->ruleset_parsed, $match,PREG_PATTERN_ORDER);
|
||||
foreach($match[0] as $key=>$elem) {
|
||||
$tmp = '$this->deny("'.$match[1][$key].'");';
|
||||
$this->ruleset_parsed = str_replace($elem,$tmp,$this->ruleset_parsed);
|
||||
}
|
||||
|
||||
#RESET;
|
||||
#RESET_ALL;
|
||||
#UNLOCK;
|
||||
#UNLOCK_ALL;
|
||||
$this->ruleset_parsed = str_replace("RESET_ALL;",'$this->reset_all();',$this->ruleset_parsed);
|
||||
$this->ruleset_parsed = str_replace("RESET;",'$this->reset_();',$this->ruleset_parsed);
|
||||
$this->ruleset_parsed = str_replace("UNLOCK_ALL;",'$this->unlock_all();',$this->ruleset_parsed);
|
||||
$this->ruleset_parsed = str_replace("UNLOCK;",'$this->unlock();',$this->ruleset_parsed);
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
class ValueCache extends DataSource {
|
||||
function ValueCache() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function loadData($ident,$type) {
|
||||
$res = $DBc->sendSQL("SELECT apv_value,apv_date,apv_name FROM ach_player_valuecache WHERE apv_player='".$DBc->mre($ident)."'","ARRAY");
|
||||
|
||||
$this->data[$ident][$type] = new DataTable($res);
|
||||
}
|
||||
|
||||
function writeData($ident,$type,$keys,$data) {
|
||||
global $DBc;
|
||||
|
||||
$DBc->sendSQL("INSERT INTO ach_player_valuecache (apv_name,apv_player,apv_value,apv_date) VALUES ('".$DBc->mre($keys[0])."','".$DBc->mre($ident)."','".$DBc->mre($data[0])."','".time()."') ON DUPLICATE KEY UPDATE apv_value='".$DBc->mre($data)."', apv_date='".time()."'","NONE");
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
$CONF = array();
|
||||
|
||||
$CONF['types'] = array("c_cache");
|
||||
$CONF['write'] = true;
|
||||
|
||||
?>
|
@ -1,229 +0,0 @@
|
||||
<?php
|
||||
class XMLapi extends DataSource {
|
||||
private $xml_path;
|
||||
|
||||
function XMLapi() {
|
||||
parent::__construct();
|
||||
|
||||
$this->xml_path = $CONF['xml_path'];
|
||||
}
|
||||
|
||||
function loadData($ident,$type) {
|
||||
switch($type) {
|
||||
case 'c_stats':
|
||||
case 'c_connection':
|
||||
case 'c_gear':
|
||||
case 'c_fp':
|
||||
case 'c_skills':
|
||||
case 'c_fame':
|
||||
case 'c_pet':
|
||||
$path = $this->xml_path."full/".$ident.".xml";
|
||||
break;
|
||||
case 'c_items':
|
||||
$path = $this->xml_path."item/".$ident.".xml";
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
$xml = new SimpleXMLElement(file_get_contents($path));
|
||||
|
||||
switch($type) {
|
||||
case 'c_stats':
|
||||
$this->loadStats($xml);
|
||||
break;
|
||||
case 'c_connection':
|
||||
$this->loadConnection($xml);
|
||||
break;
|
||||
case 'c_gear':
|
||||
$this->loadGear($xml);
|
||||
break;
|
||||
case 'c_fp':
|
||||
$this->loadFp($xml);
|
||||
break;
|
||||
case 'c_skills':
|
||||
$this->loadSkills($xml);
|
||||
break;
|
||||
case 'c_fame':
|
||||
$this->loadFame($xml);
|
||||
break;
|
||||
case 'c_pet':
|
||||
$this->loadPet($xml);
|
||||
break;
|
||||
case 'c_items':
|
||||
$this->loadItems($xml);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function getItems(&$xml) {
|
||||
$dta = array();
|
||||
|
||||
$r = $xml->xpath('item');
|
||||
$dta[] = $r->attributes();
|
||||
|
||||
return $dta;
|
||||
}
|
||||
|
||||
private function loadGear(&$xml) {
|
||||
$this->data['c_gear'] = $this->getItems($xml);
|
||||
}
|
||||
|
||||
private function loadFp(&$xml) {
|
||||
$dta = array();
|
||||
|
||||
$r = $xml->xpath('faction_points');
|
||||
foreach($r->children() as $elem) {
|
||||
$dta[] = array($elem->getName()=>$elem);
|
||||
}
|
||||
|
||||
$this->data['c_fp'] = $dta;
|
||||
}
|
||||
|
||||
private function loadSkills(&$xml) {
|
||||
$dta = array();
|
||||
|
||||
$r = $xml->xpath('skills');
|
||||
foreach($r->children() as $elem) {
|
||||
$dta[] = array($elem->getName()=>$elem);
|
||||
}
|
||||
|
||||
$this->data['c_skills'] = $dta;
|
||||
}
|
||||
|
||||
private function loadPet(&$xml) {
|
||||
$dta = array();
|
||||
|
||||
$r = $xml->xpath('pet');
|
||||
foreach($r as $pet) {
|
||||
$tmp = $pet->attributes();
|
||||
$child = $pet->children();
|
||||
$tmp = array_merge($tmp,$child[0]->attributes());
|
||||
|
||||
$dta[] = $tmp;
|
||||
}
|
||||
|
||||
$this->data['c_pet'] = $dta;
|
||||
}
|
||||
|
||||
private function loadFame(&$xml) {
|
||||
$dta = array();
|
||||
|
||||
$r = $xml->xpath('fames');
|
||||
foreach($r->children() as $elem) {
|
||||
$dta[] = array($elem->getName()=>$elem);
|
||||
}
|
||||
|
||||
$this->data['c_fame'] = $dta;
|
||||
}
|
||||
|
||||
private function loadItems(&$xml) {
|
||||
$this->data['c_items'] = $this->getItems($xml);
|
||||
}
|
||||
|
||||
private function loadConnection(&$xml) {
|
||||
$dta = array();
|
||||
|
||||
$r = $xml->xpath('log');
|
||||
|
||||
while(list( , $node) = each($r)) {
|
||||
#$attr = $node->attributes();
|
||||
#$dta[] = array("in"=>$attr[],"out"=>$attr[1],"duration"=>$attr[2]);
|
||||
$dta[] = $node->attributes();
|
||||
}
|
||||
|
||||
$this->data['c_connection'] = $dta;
|
||||
}
|
||||
|
||||
private function loadStats(&$xml) {
|
||||
$dta = array();
|
||||
|
||||
$slist = array( 'name',
|
||||
'shard',
|
||||
'uid',
|
||||
'slot',
|
||||
'cid',
|
||||
'race',
|
||||
'gender',
|
||||
'titleid',
|
||||
'played_time',
|
||||
'latest_login',
|
||||
'latest_logout',
|
||||
'hair_type',
|
||||
'hair_color',
|
||||
'tattoo',
|
||||
'eyes_color',
|
||||
'gabarit_height',
|
||||
'gabarit_torso_width',
|
||||
'gabarit_arms_width',
|
||||
'gabarit_legs_width',
|
||||
'gabarit_breast_size',
|
||||
'morph1',
|
||||
'morph2',
|
||||
'morph3',
|
||||
'morph4',
|
||||
'morph5',
|
||||
'morph6',
|
||||
'morph7',
|
||||
'morph8',
|
||||
'gid',
|
||||
'name',
|
||||
'icon',
|
||||
'money',
|
||||
'cult',
|
||||
'civ',
|
||||
'constitution',
|
||||
'metabolism',
|
||||
'intelligence',
|
||||
'wisdom',
|
||||
'strength',
|
||||
'wellbalanced',
|
||||
'dexterity',
|
||||
'will',
|
||||
'building');
|
||||
|
||||
foreach($slist as $elem) {
|
||||
$r = $xml->xpath($elem);
|
||||
$dta[$elem] = $r[0];
|
||||
}
|
||||
|
||||
#<position x="17027.559" y="-32943.011" head="-1.981871"/>
|
||||
$r = $xml->xpath("position");
|
||||
$attr = $r->attributes();
|
||||
$dta['pos_x'] = $attr['x'];
|
||||
$dta['pos_y'] = $attr['y'];
|
||||
$dta['pos_head'] = $attr['head'];
|
||||
|
||||
#<hitpoints max="3941">3941</hitpoints>
|
||||
#<stamina max="1790">1790</stamina>
|
||||
#<sap max="1890">1890</sap>
|
||||
#<focus max="2750">2750</focus>
|
||||
$r = $xml->xpath("hitpoints");
|
||||
$attr = $r->attributes();
|
||||
$dta['hitpoints'] = $attr['hitpoints'];
|
||||
|
||||
$r = $xml->xpath("stamina");
|
||||
$attr = $r->attributes();
|
||||
$dta['stamina'] = $attr['stamina'];
|
||||
|
||||
$r = $xml->xpath("sap");
|
||||
$attr = $r->attributes();
|
||||
$dta['sap'] = $attr['sap'];
|
||||
|
||||
$r = $xml->xpath("focus");
|
||||
$attr = $r->attributes();
|
||||
$dta['focus'] = $attr['focus'];
|
||||
|
||||
$this->data['c_stats'] = array($dta);
|
||||
}
|
||||
|
||||
function writeData($ident,$field,$data,$type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
$CONF = array();
|
||||
|
||||
$CONF['types'] = array("c_stats","c_items","c_connection","c_gear","c_fp","c_skills","c_fame","c_pet");
|
||||
$CONF['write'] = false;
|
||||
|
||||
$CONF['xml_path'] = "foo/bar/xml/"; // this is a dummy ^^
|
||||
?>
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 66 KiB |
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 188 KiB After Width: | Height: | Size: 234 KiB |
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 33 KiB |
@ -1,57 +0,0 @@
|
||||
<?php
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
ini_set("display_errors","1");
|
||||
|
||||
define('APP_NAME', 'app_achievements');
|
||||
|
||||
require_once('conf.php');
|
||||
require_once("fb/facebook.php");
|
||||
|
||||
|
||||
$facebook = new Facebook(array(
|
||||
'appId' => $_CONF['fb_id'],
|
||||
'secret' => $_CONF['fb_secret'],
|
||||
'cookie' => true
|
||||
));
|
||||
|
||||
// Get the url to redirect for login to facebook
|
||||
// and request permission to write on the user's wall.
|
||||
$login_url = $facebook->getLoginUrl(
|
||||
array('scope' => 'publish_stream')
|
||||
);
|
||||
|
||||
|
||||
// If not authenticated, redirect to the facebook login dialog.
|
||||
// The $login_url will take care of redirecting back to us
|
||||
// after successful login.
|
||||
if (!$facebook->getUser()) {
|
||||
|
||||
echo '<script type="text/javascript">
|
||||
top.location.href = "'.$login_url.'";
|
||||
</script>';
|
||||
}
|
||||
else {
|
||||
echo var_export($facebook->getUser(),true);
|
||||
// Do the wall post.
|
||||
try {
|
||||
|
||||
$facebook->api("/me/feed", "post", array(
|
||||
message => "My character Talvela just earned <b>'Bejeweled'</b> on Ryzom!",
|
||||
picture => "http://www.3025-game.de/special/app_achievements/pic/icon/test.png",
|
||||
link => "http://www.ryzom.com",
|
||||
name => "Ryzom - MMO",
|
||||
caption => "Join and play for fee!"
|
||||
));
|
||||
echo "post";
|
||||
|
||||
} catch (FacebookApiException $e) {
|
||||
echo $e;
|
||||
$login_url = $facebook->getLoginUrl( array(
|
||||
'scope' => 'publish_stream'
|
||||
));
|
||||
echo 'Please <a href="' . $login_url . '">login.</a>';
|
||||
#error_log($e->getType());
|
||||
#error_log($e->getMessage());
|
||||
}
|
||||
}
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,121 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIFgjCCBGqgAwIBAgIQDKKbZcnESGaLDuEaVk6fQjANBgkqhkiG9w0BAQUFADBm
|
||||
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
|
||||
d3cuZGlnaWNlcnQuY29tMSUwIwYDVQQDExxEaWdpQ2VydCBIaWdoIEFzc3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gwFoAU8Bdi
|
||||
E1U9s/8KAGv7UISX8+1i0BowHQYDVR0OBBYEFPAXYhNVPbP/CgBr+1CEl/PtYtAa
|
||||
MAwGA1UdEwQFMAMBAf8wGQYJKoZIhvZ9B0EABAwwChsEVjQuMAMCBJAwDQYJKoZI
|
||||
hvcNAQEFBQADgYEAkNwwAvpkdMKnCqV8IY00F6j7Rw7/JXyNEwr75Ji174z4xRAN
|
||||
95K+8cPV1ZVqBLssziY2ZcgxxufuP+NXdYR6Ee9GTxj005i7qIcyunL2POI9n9cd
|
||||
2cNgQ4xYDiKWL2KjLB+6rQXvqzJ4h6BUcxm1XAX5Uj5tLUUL9wqT6u0G+bI=
|
||||
-----END CERTIFICATE-----
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
@ -1,181 +0,0 @@
|
||||
<?php
|
||||
class AdmPerk extends AchPerk implements ADM {
|
||||
function insertNode($n) {
|
||||
$n->setParent($this);
|
||||
$n->insert();
|
||||
$this->addChild($n);
|
||||
}
|
||||
|
||||
function removeNode($id) {
|
||||
$res = $this->getChildDataByID($id);
|
||||
if($res != null) {
|
||||
$res->delete_me();
|
||||
$this->removeChild($id);
|
||||
}
|
||||
}
|
||||
|
||||
function updateNode($id) { // PROBABLY USELESS!
|
||||
$res = $this->getChildDataByID($id);
|
||||
if($res != null) {
|
||||
$res->update();
|
||||
}
|
||||
}
|
||||
|
||||
function getPathID($path = "") {
|
||||
if($path != "") {
|
||||
$path = ";".$path;
|
||||
}
|
||||
$path = $this->getID().$path;
|
||||
if($this->parent != null) {
|
||||
return $this->parent->getPathID($path);
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
function getElementByPath($pid) {
|
||||
$tmp = explode(";",$pid);
|
||||
if($tmp[0] == $this->getID()) {
|
||||
if(sizeof($tmp) > 1) {
|
||||
$c = $this->getChildDataByID($tmp[1]);
|
||||
if($c != null) {
|
||||
unset($tmp[0]);
|
||||
return $c->getElementByPath(implode(";",$tmp));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected $condition;
|
||||
protected $condition_value;
|
||||
protected $porder;
|
||||
|
||||
function AdmPerk($data,$parent) {
|
||||
parent::__construct($data,$parent);
|
||||
|
||||
$this->condition = $data["ap_condition"];
|
||||
$this->condition_value = $data["ap_condition_value"];
|
||||
$this->porder = $data["ap_porder"];
|
||||
}
|
||||
|
||||
protected function makeChild($d) {
|
||||
return new AdmObjective($d,$this);
|
||||
}
|
||||
|
||||
function delete_me() {
|
||||
global $DBc;
|
||||
|
||||
$DBc->sqlQuery("DELETE FROM ach_perk WHERE ap_id='".$this->getID()."'");
|
||||
$DBc->sqlQuery("DELETE FROM ach_player_perk WHERE app_perk='".$this->getID()."'");
|
||||
|
||||
$iter = $this->getIterator();
|
||||
while($iter->hasNext()) {
|
||||
$curr = $iter->getNext();
|
||||
$curr->delete_me();
|
||||
$this->removeChild($curr->getID());
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
global $DBc;
|
||||
|
||||
$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','".$DBc->sqlEscape($this->getName())."',".mkn($this->getTemplate()).") ON DUPLICATE KEY UPDATE apl_name='".$DBc->sqlEscape($this->getName())."',apl_template=".mkn($this->getTemplate())."");
|
||||
}
|
||||
|
||||
function insert() {
|
||||
global $DBc;
|
||||
|
||||
$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()).",'".$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','".$DBc->sqlEscape($this->getName())."',".mkn($this->getTemplate()).")");
|
||||
}
|
||||
|
||||
function setAchievement($a) {
|
||||
$this->achievement = $a;
|
||||
}
|
||||
|
||||
function setName($name) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
function setTemplate($t) {
|
||||
$this->template = $t;
|
||||
}
|
||||
|
||||
function setValue($v) {
|
||||
$this->value = $v;
|
||||
}
|
||||
|
||||
function getCondition() {
|
||||
return $this->condition;
|
||||
}
|
||||
|
||||
function getConditionValue() {
|
||||
return $this->condition_value;
|
||||
}
|
||||
|
||||
function setCondition($c) {
|
||||
$this->condition = $c;
|
||||
}
|
||||
|
||||
function setConditionValue($v) {
|
||||
$this->condition_value = $v;
|
||||
}
|
||||
|
||||
function getPorder() {
|
||||
return $this->porder;
|
||||
}
|
||||
|
||||
function setPorder($p) {
|
||||
$this->porder = $p;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
else {
|
||||
//remove from ach list; insert after parent
|
||||
#echo "--".$p."<br>";
|
||||
$this->parent_id = $p;
|
||||
|
||||
#$this->parent->removeChild($this->id);
|
||||
#$item = $this->parent->getChildByID($this->parent_id);
|
||||
#$tmp = $item->getChild();
|
||||
#if($tmp != null) {
|
||||
# $this->parent->addOpen($this,$tmp->getID());
|
||||
#}
|
||||
#else {
|
||||
# $this->parent->addOpen($this,null);
|
||||
#}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@ -0,0 +1,198 @@
|
||||
<?php
|
||||
class AdmTask extends AchTask implements ADM {
|
||||
#########################
|
||||
# PHP 5.3 compatible
|
||||
# AdmDispatcher_trait replaces this in PHP 5.4
|
||||
|
||||
function insertNode($n) {
|
||||
$n->setParent($this);
|
||||
$n->insert();
|
||||
$this->addChild($n);
|
||||
}
|
||||
|
||||
function removeNode($id) {
|
||||
$res = $this->getChildDataByID($id);
|
||||
if($res != null) {
|
||||
$res->delete_me();
|
||||
$this->removeChild($id);
|
||||
}
|
||||
}
|
||||
|
||||
function updateNode($id) { // PROBABLY USELESS!
|
||||
$res = $this->getChildDataByID($id);
|
||||
if($res != null) {
|
||||
$res->update();
|
||||
}
|
||||
}
|
||||
|
||||
function getPathID($path = "") {
|
||||
if($path != "") {
|
||||
$path = ";".$path;
|
||||
}
|
||||
$path = $this->getID().$path;
|
||||
if($this->parent != null) {
|
||||
return $this->parent->getPathID($path);
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
function getElementByPath($pid) {
|
||||
$tmp = explode(";",$pid);
|
||||
if($tmp[0] == $this->getID()) {
|
||||
if(sizeof($tmp) > 1) {
|
||||
$c = $this->getChildDataByID($tmp[1]);
|
||||
if($c != null) {
|
||||
unset($tmp[0]);
|
||||
return $c->getElementByPath(implode(";",$tmp));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
#########################
|
||||
|
||||
protected $condition;
|
||||
protected $condition_value;
|
||||
protected $torder;
|
||||
|
||||
function AdmTask($data,$parent) {
|
||||
parent::__construct($data,$parent);
|
||||
|
||||
$this->condition = $data["at_condition"];
|
||||
$this->condition_value = $data["at_condition_value"];
|
||||
$this->torder = $data["at_torder"];
|
||||
}
|
||||
|
||||
protected function makeChild($d) {
|
||||
return new AdmObjective($d,$this);
|
||||
}
|
||||
|
||||
function getLang($lang) {
|
||||
global $DBc;
|
||||
|
||||
$res = $DBc->sqlQuery("SELECT * FROM ach_task_lang WHERE atl_task='".$this->getID()."' AND atl_lang='".$lang."'");
|
||||
|
||||
return array(0=>$res[0]['atl_name'],1=>$res[0]['atl_template']);
|
||||
}
|
||||
|
||||
function setLang($lang,$txt,$tpl) {
|
||||
global $DBc,$_USER;
|
||||
|
||||
$DBc->sqlQuery("INSERT INTO ach_task_lang (atl_task,atl_lang,atl_name,atl_template) VALUES ('".$this->getID()."','".$DBc->sqlEscape($lang)."','".$DBc->sqlEscape($txt)."',".mkn($tpl).") ON DUPLICATE KEY UPDATE apl_name='".$DBc->sqlEscape($txt)."',apl_template=".mkn($tpl)."");
|
||||
|
||||
if($_USER->getLang() == $lang) {
|
||||
$this->name = $txt;
|
||||
$this->template = $tpl;
|
||||
}
|
||||
}
|
||||
|
||||
function delete_me() {
|
||||
global $DBc;
|
||||
|
||||
$DBc->sqlQuery("DELETE FROM ach_task WHERE at_id='".$this->getID()."'");
|
||||
$DBc->sqlQuery("DELETE FROM ach_player_task WHERE apt_task='".$this->getID()."'");
|
||||
|
||||
$iter = $this->getIterator();
|
||||
while($iter->hasNext()) {
|
||||
$curr = $iter->getNext();
|
||||
$curr->delete_me();
|
||||
$this->removeChild($curr->getID());
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
global $DBc;
|
||||
|
||||
$DBc->sqlQuery("UPDATE ach_task SET at_parent=".mkn($this->getParentID()).",at_value='".$DBc->sqlEscape($this->getValue())."',at_condition='".$DBc->sqlEscape($this->getCondition())."',at_condition_value=".mkn($this->getConditionValue()).",at_dev='".$this->getDev()."',at_torder='".$this->torder."' WHERE at_id='".$this->getID()."'");
|
||||
|
||||
$DBc->sqlQuery("INSERT INTO ach_task_lang (atl_task,atl_lang,atl_name,atl_template) VALUES ('".$this->getID()."','en','".$DBc->sqlEscape($this->getName())."',".mkn($this->getTemplate()).") ON DUPLICATE KEY UPDATE atl_name='".$DBc->sqlEscape($this->getName())."',atl_template=".mkn($this->getTemplate())."");
|
||||
}
|
||||
|
||||
function insert() {
|
||||
global $DBc;
|
||||
|
||||
$this->dev = 1;
|
||||
|
||||
$DBc->sqlQuery("INSERT INTO ach_task (at_achievement,at_parent,at_value,at_condition,at_condition_value,at_dev,at_torder) VALUES ('".$this->getAchievement()."',".mkn($this->getParentID()).",'".$DBc->sqlEscape($this->getValue())."','".$DBc->sqlEscape($this->getCondition())."',".mkn($this->getConditionValue()).",'1','".$this->torder."')");
|
||||
$id = $DBc->insertID();
|
||||
$this->setID($id);
|
||||
|
||||
$DBc->sqlQuery("INSERT INTO ach_task_lang (atl_task,atl_lang,atl_name,atl_template) VALUES ('".$this->getID()."','en','".$DBc->sqlEscape($this->getName())."',".mkn($this->getTemplate()).")");
|
||||
}
|
||||
|
||||
function setAchievement($a) {
|
||||
$this->achievement = $a;
|
||||
}
|
||||
|
||||
function setName($name) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
function setTemplate($t) {
|
||||
$this->template = $t;
|
||||
}
|
||||
|
||||
function setValue($v) {
|
||||
$this->value = $v;
|
||||
}
|
||||
|
||||
function getCondition() {
|
||||
return $this->condition;
|
||||
}
|
||||
|
||||
function getConditionValue() {
|
||||
return $this->condition_value;
|
||||
}
|
||||
|
||||
function setCondition($c) {
|
||||
$this->condition = $c;
|
||||
}
|
||||
|
||||
function setConditionValue($v) {
|
||||
$this->condition_value = $v;
|
||||
}
|
||||
|
||||
function getTorder() {
|
||||
return $this->torder;
|
||||
}
|
||||
|
||||
function setTorder($t) {
|
||||
$this->torder = $t;
|
||||
}
|
||||
|
||||
function setParentID($p,$order = true) { #reordering must happen A) after insert B) when updating
|
||||
if($p == null || $p == "null") {
|
||||
|
||||
$this->parent_id = null;
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$this->parent_id = $p;
|
||||
|
||||
}
|
||||
|
||||
if($order == true) {
|
||||
|
||||
$iter = $this->parent->getIterator();
|
||||
while($iter->hasNext()) {
|
||||
$curr = $iter->getNext();
|
||||
if($curr->getID() == $this->id) {
|
||||
continue;
|
||||
}
|
||||
if($curr->getParentID() == $this->parent_id) {
|
||||
$curr->setParentID($this->id,false);
|
||||
$curr->update();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
trait Dispatcher {
|
||||
function insertNode(&$n) {
|
||||
#MISSING: set this as parent
|
||||
$n->insert();
|
||||
$this->nodes[] = $n;
|
||||
}
|
||||
|
||||
function removeNode($id) {#NAMENSKONFLIKT!!
|
||||
$res = $this->getNode($id);
|
||||
if($res != null) {
|
||||
$res->delete_me();
|
||||
$this->removeNode($res);
|
||||
}
|
||||
}
|
||||
|
||||
function updateNode($id,$data) {
|
||||
$res = $this->getNode($id);
|
||||
if($res != null) {
|
||||
#MISSING: set new data
|
||||
#
|
||||
$res->update();
|
||||
}
|
||||
}
|
||||
|
||||
function getNode($id) {
|
||||
return $this->getIdx($id);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,171 +0,0 @@
|
||||
<?php
|
||||
function adm_render_menu(&$menu,$sub = 0) {
|
||||
$html = "<style>
|
||||
.ach_menu {
|
||||
display:block;
|
||||
padding:2px;
|
||||
border:1px solid #000000;
|
||||
margin-bottom:2px;
|
||||
color:#FFFFFF;
|
||||
}
|
||||
.ach_menu:hover {
|
||||
color:orange;
|
||||
}
|
||||
|
||||
.ach_mspan a {
|
||||
text-decoration:none;
|
||||
}
|
||||
</style>";
|
||||
|
||||
$html .= "<div style='display:block;background-color:#FFFFFF;padding:3px;margin-bottom:5px;color:#000000;'>
|
||||
<div style='display:block;text-align:right;'><a href='javascript:hs(\"new_main\",\"block\");'><img src='pic/b_insrow.png'></a></div>
|
||||
|
||||
<div style='display:none;' id='new_main'>
|
||||
<form method='post' action='?mode=menu&act=insert'>
|
||||
<fieldset>
|
||||
<legend>create new category</legend>
|
||||
<input type='hidden' name='ac_parent' value='NULL' />
|
||||
<table>
|
||||
<tr>
|
||||
<td>name</td>
|
||||
<td><input type='text' name='acl_name' /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>image</td>
|
||||
<td><input type='text' name='ac_image' /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td><input type='submit' value='create' /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>";
|
||||
|
||||
if($_REQUEST['ac_id'] > 0 && $_REQUEST['confirm'] == "delete") {
|
||||
$curr = $menu->getNode($_REQUEST['ac_id']);
|
||||
$html .= "<div style='display:block;'>
|
||||
<fieldset>
|
||||
<legend>Are you sure you want to delete this category?</legend>";
|
||||
if($curr->hasAchievements()) {
|
||||
$html .= "<b>You may NOT DELETE this category since there are still achievements tied to it or one of its sub-categories!</b>";
|
||||
}
|
||||
else {
|
||||
$html .= "<b style='font-size:16px;'>".$curr->getName()."</b><p>";
|
||||
|
||||
if($curr->getParentID() == null) {
|
||||
$html .= "<b>WARNING:</b> Deleting this category will also delete ALL sub-categories!<br>";
|
||||
}
|
||||
$html .= "<a href='?mode=menu&act=delete&ac_id=".$_REQUEST['ac_id']."'><b>delete</b></a>";
|
||||
}
|
||||
$html .= "</fieldset>
|
||||
</div>";
|
||||
}
|
||||
|
||||
$html .= "</div>";
|
||||
|
||||
return $html.ach_render_mnode($menu,$sub);
|
||||
}
|
||||
|
||||
function ach_render_mnode(&$menu,$sub) {
|
||||
global $_CONF;
|
||||
|
||||
# echo "1";
|
||||
|
||||
$iter = $menu->getIterator();
|
||||
while($iter->hasNext()) {
|
||||
$curr = $iter->getNext();
|
||||
#$sz = $menu->getSize();
|
||||
#for($i=0;$i<$sz;$i++) {
|
||||
# $curr = $menu->getChild($i);
|
||||
|
||||
$html .= "<span class='ach_mspan'><table class='ach_menu'>
|
||||
<tr>";
|
||||
if($sub == 0) {
|
||||
$html .= "<td><img src='".$_CONF['image_url']."pic/menu/".$curr->getImage()."' /></td>";
|
||||
}
|
||||
$html .= "<td style='font-size:".(20-$sub)."px;font-weight:bold;' width='100%'>";
|
||||
if($curr->inDev()) {
|
||||
$html .= "<s>";
|
||||
}
|
||||
|
||||
$html .= $curr->getName();
|
||||
|
||||
if($curr->inDev()) {
|
||||
$html .= "</s>";
|
||||
}
|
||||
$html .= "</td>
|
||||
<td style='background-color:#FFFFFF;padding:3px;'><nobr><a href='?mode=menu&act=dev&state=".$curr->getDev()."&ac_id=".$curr->getID()."'><img src='pic/";
|
||||
if($curr->inDev()) {
|
||||
$html .= "red";
|
||||
}
|
||||
else {
|
||||
$html .= "green";
|
||||
}
|
||||
$html .= ".gif' /></a> <a href='javascript:hs(\"edit_m".$curr->getID()."\",\"block\");'><img src='pic/icon_edit.gif'></a>";
|
||||
|
||||
if($sub == 0) {
|
||||
$html .= " <a href='javascript:hs(\"ins_m".$curr->getID()."\",\"block\");'><img src='pic/b_insrow.png'></a>";
|
||||
}
|
||||
|
||||
$html .= " <a href='?mode=menu&confirm=delete&ac_id=".$curr->getID()."'><img src='pic/b_drop.png'></a></nobr></td>
|
||||
</tr>
|
||||
</table></span>";
|
||||
if($sub == 0) {
|
||||
$html .= "<div style='display:none;color:#000000;background-color:#FFFFFF;' id='ins_m".$curr->getID()."'>
|
||||
<form method='post' action='?mode=menu&act=insert'>
|
||||
<fieldset>
|
||||
<legend>create new sub-category</legend>
|
||||
<input type='hidden' name='ac_parent' value='".$curr->getID()."' />
|
||||
<input type='hidden' name='ac_image' value='NULL' />
|
||||
<table>
|
||||
<tr>
|
||||
<td>name</td>
|
||||
<td><input type='text' name='acl_name' /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td><input type='submit' value='create' /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>";
|
||||
}
|
||||
|
||||
$html .= "<div style='display:none;color:#000000;background-color:#FFFFFF;' id='edit_m".$curr->getID()."'>
|
||||
<form method='post' action='?mode=menu&act=update&ac_id=".$curr->getID()."'>
|
||||
<fieldset>
|
||||
<legend>edit category</legend>";
|
||||
if($sub != 0) {
|
||||
$html .= "<input type='hidden' name='ac_image' value='NULL' />";
|
||||
}
|
||||
$html .= "<table>
|
||||
<tr>
|
||||
<td>name</td>
|
||||
<td><input type='text' name='acl_name' value='".$curr->getName()."' /></td>
|
||||
</tr>";
|
||||
if($sub == 0) {
|
||||
$html .= "<tr>
|
||||
<td>image</td>
|
||||
<td><input type='text' name='ac_image' value='".$curr->getImage()."' /></td>
|
||||
</tr>";
|
||||
}
|
||||
$html .= "<tr>
|
||||
<td> </td>
|
||||
<td><input type='submit' value='save' /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>";
|
||||
|
||||
if(!$curr->isEmpty()) {
|
||||
$html .= "<div style='display:block;margin-left:25px;'>".ach_render_mnode($curr,($sub+4))."</div>";
|
||||
}
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue