#1470 admin tool; dev workprint

This commit is contained in:
SirCotare 2012-07-02 18:56:13 +02:00
parent 2e82c7ef12
commit edd9dd80a7
23 changed files with 2436 additions and 294 deletions

View file

@ -10,8 +10,6 @@
function insert();
function setInDev($true_false);
function getID(); // needed to identify a node
}
?>

View file

@ -1,44 +1,20 @@
<?php
class AdmAchievement extends AchAchievement implements ADM, AdmDispatcher {
class AdmAchievement extends AchAchievement implements ADM {
use AdmDispatcher;
function AdmAchievement($data,$parent) {
$this->init();
parent::__construct($data,$parent);
}
protected function makeChild(&$d) {
protected function makeChild($d) {
return new AdmPerk($d,$this);
}
function insertNode(&$n) { // add a Perk
#@overrides AdmDispatcher::insertNode()
function insertNode($n) {
$n->insert();
$this->nodes[] = $n;
}
function removeNode($id) { // remove a Perk
$res = $this->getNode($id);
if($res != null) {
$res->delete_me();
$this->unsetChild($id);
}
}
function updateNode($id,$data) { // update a Perk
$res = $this->getNode($id);
if($res != null) {
#MISSING: set new data
#
$res->update();
}
}
function getNode($id) { // find a Perk
foreach($this->nodes as $elem) {
if($elem->getID == $id) {
return $elem;
}
}
return null;
$this->addOpen($n);
}
function delete_me() {
@ -47,56 +23,36 @@
$DBc->sqlQuery("DELETE FROM ach_achievement WHERE aa_id='".$this->getID()."'");
$DBc->sqlQuery("DELETE FROM ach_player_achievement WHERE apa_id='".$this->getID()."'");
$DBc->sqlQuery("DELETE FROM ach_achievement_lang WHERE NOT EXISTS (SELECT * FROM ach_achievement WHERE aa_id=aal_achievement)");
foreach($this->nodes as $elem) {
$elem->delete_me();
$this->unsetChild($elem->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_achievement SET aa_parent='".$this->getParent())."',aa_tie_race='".mysql_real_escape_string($this->getTieRace())."',aa_tie_cult='".mysql_real_escape_string($this->getTieCult())."',aa_tie_civ='".mysql_real_escape_string($this->getTieCiv())."',aa_image='".mysql_real_escape_string($this->getImage())."',aa_dev='".$this->getDev()."' WHERE aa_id='".$this->geID()."'");
$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()."'");
#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())."");
}
function insert() {
global $DBc;
$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();
$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()).")");
}
function unsetChild($id) { // remove child with given ID from nodes list; unset should destruct it.
foreach($this->nodes as $key=>$elem) {
if($elem->getID() == $id) {
unset($this->nodes[$key]);
return null;
}
}
}
function setInDev($tf) {
if($tf == true) {
$this->setDev(1);
}
else {
$this->setDev(0);
}
$this->update();
}
function setDev($d) {
$this->dev = $d;
}
function setID($id) {
$this->id = $id;
}
function setParent($p) {
$this->parent = $p
}
function setCategory($c) {
$this->category = $c;
@ -122,7 +78,7 @@
$this->name = $n;
}
function setTemplate($i) {
function setTemplate($t) {
$this->template = $t;
}
}

View file

@ -1,12 +1,12 @@
<?php
class AdmAtom implements ADM {
use Node;
protected $id;
protected $objective;
protected $mandatory;
protected $ruleset;
protected $ruleset_parsed;
protected $parent;
protected $parent_id;
function AdmAtom($data,$parent) {
$this->parent = $parent;
@ -25,11 +25,11 @@
}
function update() {
$DBc->sqlQuery("UPDATE ach_atom SET atom_mandatory='".."',atom_ruleset='".."',atom_ruleset_parsed='".."' WHERE atom_id='".$this->id."'");
#$DBc->sqlQuery("UPDATE ach_atom SET atom_mandatory='".."',atom_ruleset='".."',atom_ruleset_parsed='".."' WHERE atom_id='".$this->id."'");
}
function insert() {
$DBc->sqlQuery("INSERT INTO ach_atom (atom_objective,atom_mandatory,atom_ruleset,atom_ruleset_parsed) VALUES ('".."','".."','".."','".."')");
#$DBc->sqlQuery("INSERT INTO ach_atom (atom_objective,atom_mandatory,atom_ruleset,atom_ruleset_parsed) VALUES ('".."','".."','".."','".."')");
$id = mysql_insert_id();
$this->setID($id);
}
@ -63,5 +63,9 @@
private function parse() {
}
function setInDev($tf) {
}
}
?>

View file

@ -1,54 +1,20 @@
<?php
class AdmCategory extends AchCategory implements AdmDispatcher {
class AdmCategory extends AchCategory {
use AdmDispatcher;
function AdmCategory($id,$cult = null,$civ = null) {
$this->init();
parent::__construct($id,$cult,$civ);
}
protected function makeChild(&$d) {
protected function makeChild($d) {
return new AdmAchievement($d,$this);
}
function insertNode(&$n) {
#@overrides AdmDispatcher::insertNode()
function insertNode($n) {
$n->insert();
$this->nodes[] = $n;
$this->addOpen($n);
}
function removeNode($id) {
$res = $this->getNode($id);
if($res != null) {
$res->delete_me();
$this->unsetChild($id);
}
}
function updateNode($id,$data) {
$res = $this->getNode($id);
if($res != null) {
#MISSING: set new data
#aa_id aa_category aa_parent aa_tie_race aa_tie_cult aa_tie_civ aa_image aa_dev
$res->update();
}
}
function getNode($id) { // try to find the Achievement node that has the given ID. Return null on failure.
foreach($this->nodes as $elem) {
if($elem->getID == $id) {
return $elem;
}
}
return null;
}
function unsetChild($id) { // remove child with given ID from nodes list; unset should destruct it.
foreach($this->nodes as $key=>$elem) {
if($elem->getID() == $id) {
unset($this->nodes[$key]);
return null;
}
}
}
}
?>

View file

@ -0,0 +1,70 @@
<?php
trait AdmDispatcher {
/*---------------------------
The AdminDispatcher trait provides functions to pass
manipulation requests on to child nodes.
Classes using this trait must be inherited from Parentum!
The "path" is definded a an enumeration of id numbers along
the structural path, seperated by ";",
eg.: 1;2;5;18
This will try to return the node with the id "18" that is a child
of "5", which is child of "2", which is child of "1". "1" in this
case is the first instance that calls getElementByPath() without
arguments.
---------------------------*/
function insertNode($n) {
$n->setParent($this);
$n->insert();
$this->addChild($n);
}
function removeNode($id) {
$res = $this->getChildByID($id);
if($res != null) {
$res->delete_me();
$this->removeChild($id);
}
}
function updateNode($id) { // PROBABLY USELESS!
$res = $this->getChildByID($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->getChildByID($tmp[1]);
if($c != null) {
unset($tmp[0]);
return $c->getElementByPath(implode(";",$tmp));
}
return null;
}
else {
return $this;
}
}
return null;
}
}
?>

View file

@ -3,6 +3,7 @@
private $ach_count;
function AdmMenuNode($data,$parent) {
$this->init();
parent::__construct($data,$parent);
global $DBc;
@ -32,18 +33,21 @@
}
function getNode($id) { // try to find the child node that has the given ID. Return null on failure.
if($id == $this->getID()) { // found!
return $this;
$res = $this->getChildByID($id);
if($res != null) {
return $res;
}
else {
foreach($this->nodes as $elem) { // check children
$tmp = $elem->getNode($id);
if($tmp != null) {
return $tmp;
}
$iter = $this->getIterator();
while($iter->hasNext()) { // check children
$curr = $iter->getNext();
$tmp = $curr->getNode($id);
if($tmp != null) {
return $tmp;
}
return null;
}
return null;
}
function delete_me() { // remove this node
@ -57,18 +61,18 @@
// call delete function for all children
foreach($this->nodes as $elem) {
$elem->delete_me();
$this->unsetChild($elem->getID());
$this->removeChild($elem->getID());
}
}
function unsetChild($id) { // remove child with given ID from nodes list; unset should destruct.
/*function unsetChild($id) { // remove child with given ID from nodes list; unset should destruct.
foreach($this->nodes as $key=>$elem) {
if($elem->getID() == $id) {
unset($this->nodes[$key]);
return null;
}
}
}
}*/
function insertChild(&$n) { // insert a new child
// insert command to create database entry
@ -76,7 +80,7 @@
// set the new child's parent and add it to the node list
$n->setParent($this);
$this->nodes[] = $n;
$this->addChild($n);
}
function update() {
@ -151,9 +155,6 @@
}
}
function setParent(&$p) {
$this->parent = $p;
}
function setParentID($p) {
if($p == null || strtolower($p) == "null") {
@ -164,9 +165,6 @@
}
}
function setID($id) {
$this->id = $id;
}
function getNextOrder() {
if($this->isEmpty()) {

View file

@ -1,11 +1,14 @@
<?php
class AdmMenu extends AchMenu {
use Dispatcher;
use AdmDispatcher;
function AdmMenu($open) {
$this->init();
parent::__construct($open);
unset($this->nodes[0]); // unset the auto-generated "summary" node
#$this->drawTree();
#$this->removeChild(0); // unset the auto-generated "summary" node
}
protected function makeChild($d) { // override child generator to use admin classes
@ -16,7 +19,7 @@
$res = $this->getNode($id);
if($res != null) {
$res->delete_me();
$this->unsetChild($id);
$this->removeChild($id);
}
}
@ -31,7 +34,7 @@
else {
$n->setParent($this);
$n->insert();
$this->nodes[] = $n;
$this->addChild($n);
}
}
@ -61,8 +64,17 @@
}
function getNode($id) { // try to find the MenuNode that has the given ID. Return null on failure.
foreach($this->nodes as $elem) {
$tmp = $elem->getNode($id);
#echo "<br>getNode(".$id.")";
$res = $this->getChildByID($id);
if($res != null) {
return $res;
}
$iter = $this->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
#echo $curr->getID();
$tmp = $curr->getNode($id);
if($tmp != null) {
return $tmp;
}
@ -77,20 +89,22 @@
}
$val = array();
foreach($this->nodes as $elem) {
$val[] = $elem->getOrder();
$iter = $this->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
$val[] = $curr->getOrder();
}
return (max($val)+1);
}
function unsetChild($id) { // remove child with given ID from nodes list; unset should destruct it.
/*function unsetChild($id) { // remove child with given ID from nodes list; unset should destruct it.
foreach($this->nodes as $key=>$elem) {
if($elem->getID() == $id) {
unset($this->nodes[$key]);
return null;
}
}
}
}*/
}
?>

View file

@ -1,7 +1,9 @@
<?php
class AdmObjective extends AchObjective implements ADM, AdmDispatcher {
class AdmObjective extends AchObjective implements ADM {
use AdmDispatcher;
function AdmObjective($data,$parent) {
$this->init();
parent::__construct($data,$parent);
global $DBc;
@ -13,63 +15,44 @@
}
}
private function makeChild($d) {
protected function makeChild($d) {
return new AdmAtom($d,$this);
}
function insertNode(&$n) { // insert an Atom
$n->insert();
$this->nodes[] = $n;
}
function removeNode($id) { // remove an Atom
$res = $this->getNode($id);
if($res != null) {
$res->delete_me();
$this->unsetChild($id);
}
}
function updateNode($id,$data) { // update an Atom
$res = $this->getNode($id);
if($res != null) {
#MISSING: set new data
#
$res->update();
}
}
function getNode($id) { // find an atom
foreach($this->nodes as $elem) {
if($elem->getID == $id) {
return $elem;
}
}
return null;
}
function delete_me() {
global $DBc;
$DBc->sqlQuery("DELETE FROM ach_objective WHERE ao_id='".$this->getID()."'");
$DBc->sqlQuery("DELETE FROM ach_player_objective WHERE apo_objective='".$this->getID()."'");
foreach($this->nodes as $elem) {
$elem->delete_me();
$iter = $this->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
$curr->delete_me();
$this->removeChild($curr->getID());
}
}
function update() {
global $DBc;
$DBc->sqlQuery("UPDATE ach_objective SET ao_condition='".mysql_real_escape_string($this->getCondition())."',ao_value=".mre($this->getValue()).",ao_display='".mysql_real_escape_string($this->getDisplay())."',ao_metalink=".mkn($this->getMetalink())." WHERE ao_id='".$this->getID()."'");
$DBc->sqlQuery("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())."'");
}
function insert() {
global $DBc;
$DBc->sqlQuery("INSERT INTO ach_objective (ao_perk,ao_condition,ao_value,ao_display,ao_metalink) VALUES ('".$this->getPerk()."','".mysql_real_escape_string($this->getCondition())."',".mre($this->getValue()).",'".mysql_real_escape_string($this->getDisplay())."',".mkn($this->getMetalink()).")");
$id = mysql_insert_id();
$this->setID($id);
$DBc->sqlQuery("INSERT INTO ach_objective_lang (aol_objective,aol_lang,aopl_name) VALUES ('".$this->getID()."','en','".mysql_real_escape_string($this->getName())."')");
}
function setInDev($tf) {
function setCondition($c) {
$this->condition = $c;
}
}
?>

View file

@ -1,77 +1,86 @@
<?php
class AdmPerk extends AchPerk implements ADM, AdmDispatcher {
class AdmPerk extends AchPerk implements ADM {
use AdmDispatcher;
protected $condition;
protected $condition_value;
function AdmPerk($data,$parent) {
$this->init();
parent::__construct($data,$parent);
$this->condition = $data["ap_condition"];
$this->condition_value = $data["ap_condition_value"];
}
protected function makeChild($d) {
return new AdmObjective($d,$this);
}
function insertNode(&$n) { // insert an Objective
$n->insert();
$this->nodes[] = $n;
}
function removeNode($id) { // remove an Objective
$res = $this->getNode($id);
if($res != null) {
$res->delete_me();
$this->unsetChild($id);
}
}
function updateNode($id,$data) { // update an Objective
$res = $this->getNode($id);
if($res != null) {
#MISSING: set new data
#
$res->update();
}
}
function getNode($id) { // find an Objective
foreach($this->nodes as $elem) {
if($elem->getID == $id) {
return $tmp;
}
}
return null;
}
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()."'");
foreach($this->nodes as $elem) {
$elem->delete_me();
$this->unsetChild($elem->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=NULL,ap_value='".mysql_real_escape_string($this->getValue())."',ap_condition='".mysql_real_escape_string($this->getCondition())."',ap_condition_value=".mkn($this->getConditionValue()).",ap_dev='".$this->getDev()."' WHERE ap_id='".$this->getID()."'");
$DBc->sqlQuery("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())."");
}
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) VALUES ('".$this->getAchievement()."',NULL,'".mysql_real_escape_string($this->getValue())."','".mysql_real_escape_string($this->getCondition())."',".mkn($this->getConditionValue()).",'1')");
$id = mysql_insert_id();
$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()).")");
}
function unsetChild($id) { // remove child with given ID from nodes list; unset should destruct it.
foreach($this->nodes as $key=>$elem) {
if($elem->getID() == $id) {
unset($this->nodes[$key]);
return null;
}
}
function setAchievement($a) {
$this->achievement = $a;
}
function setInDev($tf) {
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;
}
}
?>

View file

@ -1,19 +1,60 @@
<?php
class CSRAchievement extends AchAchievement implements CSR {
use CSRDispatcher;
function CSRAchievement(&$data) {
parent::__construct($data);
function CSRAchievement($data,$parent) {
$this->init();
parent::__construct($data,$parent);
}
protected function makeChild($d) {
return new CSRPerk($d,$this);
}
function grant($pid) {
foreach($this->nodes as $elem) {
$elem->grant($pid);
$iter = $this->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
$curr->grant($pid);
$this->setChildDone($curr->getIdx());
}
$this->parent->setChildDone($this->idx);
}
function deny($pid) {
foreach($this->nodes as $elem) {
$elem->deny($pid);
$iter = $this->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
$curr->deny($pid);
$this->setChildOpen($curr->getIdx());
}
$this->parent->setChildOpen($this->idx);
}
function setPerkDone($idx) {
echo "perk<br>";
$this->setChildDone($idx);
echo "ach<br>";
$this->parent->addChildDone($this->idx);
if(!$this->hasOpen()) {
$this->parent->removeChildOpen($this->idx);
}
}
function setPerkOpen($idx) {
echo "perk<br>";
$this->setChildOpen($idx);
echo "ach<br>";
$this->parent->addChildOpen($this->idx);
if(!$this->hasDone()) {
$this->parent->removeChildDone($this->idx);
}
}
}

View file

@ -1,9 +1,10 @@
<?php
class CSRAtom implements CSR {
private $id;
use Node;
function CSRAtom(&$data) {
function CSRAtom($data,$parent) {
$this->id = $data['atom_id'];
$this->parent = $parent;
}
function grant($pid) {

View file

@ -0,0 +1,50 @@
<?php
class CSRCategory extends AchCategory implements CSR {
use CSRDispatcher;
function CSRCategory($id,$cult = null,$civ = null) {
$this->init();
parent::__construct($id,$cult,$civ);
}
protected function makeChild($d) {
return new CSRAchievement($d,$this);
}
function grant($id) {
return false; // category can't grant!
}
function deny($id) {
return false; // category can't grant!
}
/*function setAchOpen($idx,$state) {
if($state == false) {
$this->unsetOpen($idx);
if(!in_array($idx,$this->child_done)) {
$this->child_done[] = $idx;
}
}
else {
if(!in_array($idx,$this->child_open)) {
$this->child_open[] = $idx;
}
}
}
function setAchDone($idx,$state) {
if($state == false) {
$this->unsetDone($idx);
if(!in_array($idx,$this->child_open)) {
$this->child_open[] = $idx;
}
}
else {
if(!in_array($idx,$this->child_done)) {
$this->child_done[] = $idx;
}
}
}*/
}
?>

View file

@ -0,0 +1,67 @@
<?php
trait CSRDispatcher {
function grantNode($path,$player) {
#echo "start: ".$path." id: ".$this->getID()."<br>";
if(is_numeric($path)) {
//it's me (id == numeric)
if($this->getID() == $path) {
$this->grant($player);
#echo "grant()<br>";
}
}
else {
//get child with the next level id and dispatch
$tmp = explode(";",$path);
$c = $this->getChildByID($tmp[1]);
#echo "...".$tmp[1];
if($c != null) { // check if it's really own child
unset($tmp[0]);
$c->grantNode(implode(";",$tmp),$player);
#echo "grantNode()<br>";
}
}
#echo "end<br>";
}
function denyNode($path,$player) {
if(is_numeric($path)) {
//it's me (id == numeric)
if($this->getID() == $path) {
$this->deny($player);
}
}
else {
//get child with the next level id and dispatch
$tmp = explode(";",$path);
if($tmp[0] == $this->getID()) { // it's my id!
$c = $this->getChildByID($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);
}
}
?>

View file

@ -1,27 +1,37 @@
<?php
class CSRObjective extends AchObjective implements CSR {
use CSRDispatcher;
private $nodes;
#private $nodes;
function CSRObjective(&$data) {
parent::__construct($data);
function CSRObjective($data,$parent) {
$this->init();
parent::__construct($data,$parent);
global $DBc;
$res = $DBc->sqlQuery("SELECT atom_id FROM ach_atom WHERE atom_objective='".$this->getID()."'");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$this->nodes[] = new CSRAtom($res[$i]);
$this->addChild($this->makeChild($res[$i]));
}
}
protected function makeChild($d) {
return new CSRAtom($d,$this);
}
function grant($pid) {
global $DBc;
$DBc->sqlQuery("INSERT INTO ach_player_objective (apo_objective,apo_player,apo_date) VALUES ('".$this->getID()."','".$pid."','".time()."')");
$this->done = 1;
$this->progress = $this->value;
foreach($this->nodes as $elem) {
$elem->grant($pid);
$iter = $this->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
$curr->grant($pid);
}
}
@ -29,9 +39,13 @@
global $DBc;
$DBc->sqlQuery("DELETE FROM ach_player_objective WHERE apo_objective='".$this->getID()."' AND apo_player='".$pid."'");
$this->done = 0;
$this->progress = 0;
foreach($this->nodes as $elem) {
$elem->deny($pid);
$iter = $this->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
$curr->deny($pid);
}
}
}

View file

@ -1,17 +1,28 @@
<?php
class CSRPerk extends AchPerk implements CSR {
use CSRDispatcher;
function CSRPerk(&$data) {
parent::__construct($data);
function CSRPerk($data,$parent) {
$this->init();
parent::__construct($data,$parent);
}
protected function makeChild($d) {
return new CSRObjective($d,$this);
}
function grant($pid) {
global $DBc;
$DBc->sqlQuery("INSERT INTO ach_player_perk (app_perk,app_player,app_date) VALUES ('".$this->getID()."','".$pid."','".time()."')");
$this->done = time();
#echo $this->idx."<br>";
$this->parent->setPerkDone($this->idx);
foreach($this->nodes as $elem) {
$elem->grant();
$iter = $this->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
$curr->grant($pid);
}
}
@ -19,9 +30,13 @@
global $DBc;
$DBc->sqlQuery("DELETE FROM ach_player_perk WHERE app_perk='".$this->getID()."' AND app_player='".$pid."'");
$this->done = 0;
$this->parent->setPerkOpen($this->idx);
foreach($this->nodes as $elem) {
$elem->deny($pid);
$iter = $this->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
$curr->deny($pid);
}
}
}

View file

@ -1,7 +1,9 @@
<?php
interface CSR {
function grant($player_id);
function grant($player);
function deny($player_id);
function deny($player);
function getID();
}
?>

View file

@ -0,0 +1,160 @@
<?php
class mySQL {
var $DBc;
var $DBstats;
var $cached;
function mre($in) {
if(is_array($in)) {
foreach($in as $key=>$elem) {
$in[$key] = mysql_real_escape_string(stripslashes($elem));
}
}
else {
$in = mysql_real_escape_string(stripslashes($in));
}
return $in;
}
function mySQL($err=false) {
$this->DBstats = array();
$this->DBc = false;
if($err === "DIE" || $err === "PRINT" || $err === "ALERT" || $err === "HIDE" || $err === "LOG") {
$this->DBerror = $err;
}
else {
$this->DBerror = "HIDE";
}
$this->resetStats();
$this->cached = false;
}
function connect($ip,$user,$pass,$db=false) {
$this->DBc = mysql_pconnect($ip,$user,$pass) or $this->error(mysql_error());
if($this->DBc && $db) {
$this->database($db);
}
$this->resetStats();
}
function database($db) {
if(!$this->DBc) {
return false;
}
mysql_select_db($db,$this->DBc) or $this->error(mysql_error());
}
function resetStats() {
$this->DBstats['query'] = 0;
$this->DBstats['error'] = 0;
}
function getStats() {
return $this->DBstats;
}
function sendSQL($query,$handling="PLAIN",$buffer=false) { // can be INSERT, DELETE, UPDATE, ARRAY, NONE, PLAIN
#if($this->cached !== false) {
#$this->unlinkSql($this->cached);
#}
if(!$this->DBc) {
return false;
}
if($buffer === false && $handling !== "PLAIN") {
$res = mysql_unbuffered_query($query,$this->DBc) or $this->error(mysql_error(),$query);
}
else {
$res = mysql_query($query,$this->DBc) or $this->error(mysql_error(),$query);
}
#$this->cached = $res;
$this->DBstats['query']++;
if($res) {
if($handling === "INSERT") {
$tmp = mysql_insert_id($this->DBc) or $this->error(mysql_error());;
$this->unlinkSql($res);
return $tmp;
}
elseif($handling === "DELETE" || $handling === "UPDATE") {
$tmp = mysql_affected_rows($this->DBc) or $this->error(mysql_error());
$this->unlinkSql($res);
return $tmp;
}
elseif($handling === "ARRAY") {
$tmp = $this->parseSql($res);
$this->unlinkSql($res);
return $tmp;
}
elseif($handling === "NONE") {
$this->unlinkSql($res);
return true;
}
else {
return $res;
}
mysql_free_result($res);
}
else {
return false;
}
}
function unlinkSql($res) {
@mysql_free_result($res);
}
private function parseSql($res) {
$data = array();
$k = 0;
while($tmp = mysql_fetch_array($res,MYSQL_ASSOC)) {
$data[$k] = $tmp;
$k++;
}
return $data;
}
function getNext($res) {
if($res) {
if($tmp = mysql_fetch_array($res,MYSQL_ASSOC)) {
return $tmp;
}
else {
return false;
}
}
else {
return false;
}
}
private function error($error,$query = false) {
$this->DBstats['error']++;
if($query != false) {
$error .= " -->|".$query."|<--";
}
switch($this->DBerror) {
case 'DIE':
die($error);
break;
case 'PRINT':
echo "<br><b>".$error."</b><br>";
break;
case 'ALERT':
echo "<script language='javascript'>\n<!--\nalert(\"database error:\\n".mysql_real_escape_string($error)."\");\n// -->\n</script>";
break;
case 'LOG':
logf("MySQL ERROR: ".$error);
break;
default:
flush();
break;
}
}
}
?>

View file

@ -11,4 +11,9 @@
$_CONF['enable_offgame'] = true;
$_CONF['enable_CSR'] = true;
$_CONF['enable_ADM'] = true;
$_CONF['char_mysql_server'] = "localhost";
$_CONF['char_mysql_user'] = "root";
$_CONF['char_mysql_pass'] = "";
$_CONF['char_mysql_database'] = "app_achievements";
?>

View file

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

View file

@ -0,0 +1,565 @@
<?php
function is_user($id) {
global $DBc_char;
$res = $DBc_char->sendSQL("SELECT count(*) as anz FROM characters WHERE char_id='".mysql_real_escape_string($id)."'","ARRAY");
if($res[0]['anz'] > 0) {
return true;
}
return false;
}
function csr_render_yubopoints() {
global $DBc,$_USER,$_CONF;
$res = $DBc->sqlQuery("SELECT sum(ap_value) as anz FROM ach_perk,ach_player_perk WHERE ap_id=app_perk AND app_player='".$_USER->getID()."'");
$html = "<div style='display:block;border-bottom:1px solid #000000;'><span style='font-size:32px;'>".$_USER->getName()."&nbsp;<img src='".$_CONF['image_url']."pic/yubo_done.png'>&nbsp;".$res[0]['anz']."</span></div>";
return $html;
}
function csr_render_find_player() {
global $DBc_char;
$html = "<form method='post' action='?mode=player'>
<fieldset>
<legend>Search for a player</legend>
<table>
<tr>
<td>Name:&nbsp;</td>
<td><input type='text' name='pname' value=\"".$_REQUEST['pname']."\" /></td>
</tr>
<tr>
<td colspan='2'><input type='submit' value='search' /></td>
</tr>
</table>
</fieldset>
</form>";
if($_REQUEST['pname'] != "") {
$html .= "<div style='display:block;color:#000000;background-color:#FFFFFF;margin-top:5px;'>";
$res = $DBc_char->sendSQL("SELECT char_id,char_name FROM characters WHERE char_name LIKE '".mysql_real_escape_string($_REQUEST['pname'])."%'","ARRAY");
$sz = sizeof($res);
if($sz == 0) {
$html .= "<b>no characters found</b>";
}
$cols = 1;
if($sz > 8) {
$cols = 3;
}
$html .= "<table><tr>";
for($i=0;$i<$sz;$i++) {
if($cols != 1 && ($i%$cols) == 0) {
$html .= "</tr><tr>";
}
$html .= "<td><a href='?mode=player&pid=".$res[$i]['char_id']."'><b>".$res[$i]['char_name']."</b></a></td>";
}
$html .= "</tr></table>";
$html .= "</div>";
}
return $html;
}
function csr_render_menu(&$menu,$sub = 0) {
$html = "<style>
.ach_menu {
display:block;
padding:2px;
border:1px solid #000000;
margin-bottom:2px;
color:#FFFFFF;
}
.ach_menu:hover {
color:orange;
}
.ach_mspan a {
text-decoration:none;
}
</style>";
return $html.adm_render_mnode($menu,$sub);
}
function adm_render_mnode(&$menu,$sub) {
global $_CONF;
$iter = $menu->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
#$sz = $menu->getSize();
#for($i=0;$i<$sz;$i++) {
# $curr = $menu->getChild($i);
if($curr->inDev()) {
#continue;
}
$html .= "<span class='ach_mspan'><a href='?mode=player&pid=".$_REQUEST['pid']."&cat=".$curr->getID()."'><table class='ach_menu'>
<tr>";
if($sub == 0) {
$html .= "<td><img src='".$_CONF['image_url']."pic/menu/".$curr->getImage()."' /></td>";
}
$html .= "<td style='font-size:".(20-$sub)."px;font-weight:bold;";
if($curr->isOpen()) {
$html .= "color:orange;";
}
$html .= "'>".$curr->getName()."</td>
</tr>
</table></a></span>";
if($curr->hasOpenCat() != 0) {
$html .= "<div style='display:block;margin-left:25px;'>".adm_render_mnode($curr,($sub+4))."</div>";
}
}
return $html;
}
function csr_render_category(&$cat) {
$html = "";
if($cat->isTiedCult() || $cat->isTiedCiv()) {
$html .= ach_render_tiebar($cat->getCurrentCult(),$cat->getCurrentCiv(),$cat);
}
$iter = $cat->getDone();
echo "<br>done: ".var_export($iter,true)."<br>";
while($iter->hasNext()) {
$curr = $cat->getChildByIdx($iter->getNext());
#$sz = sizeof($tmp);
#for($i=0;$i<$sz;$i++) {
#echo "A";
if($curr->inDev()) {
continue;
}
$html .= ach_render_achievement_done($curr);
}
$iter = $cat->getOpen();
echo "<br>open: ".var_export($iter,true)."<br>";
while($iter->hasNext()) {
$tmp = $iter->getNext();
$curr = $cat->getChildByIdx($tmp);
echo "<b>".$tmp."-".$curr->getIdx()."</b><br>";
#$sz = sizeof($tmp);
#for($i=0;$i<$sz;$i++) {
#echo "B";
if($curr->inDev()) {
continue;
}
$html .= ach_render_achievement_open($curr);
}
return $html;
}
function ach_render_achievement_done(&$ach) {
global $_CONF;
$html = '<div style="display: block; margin-bottom: 5px;"><table cellpadding="0" cellspacing="0" width="100%">
<tbody><tr>
<td width="3px"><img src="'.$_CONF['image_url'].'pic/bar_done_ul.png"></td>
<td style="background-image: url('.$_CONF['image_url'].'pic/bar_done_u.png);"></td>
<td width="3px"><img src="'.$_CONF['image_url'].'pic/bar_done_ur.png"></td>
</tr>
<tr>
<td style="background-image: url('.$_CONF['image_url'].'pic/bar_done_l.png);"></td>
<td style="background-image: url('.$_CONF['image_url'].'pic/bar_done_bg.png);">
<center><table width="100%" cellspacing="0" cellpadding="0">
<tbody><tr>
<td rowspan="2" valign="top"><img src="'.$_CONF['image_url'].'pic/icon/'.$ach->getImage().'"></td>
<td width="100%"><center><span style="font-weight:bold;font-size:24px;color:#000000;">'.$ach->getName().'</span></center></td>
<td rowspan="2" valign="top" style="font-weight: bold; text-align: center; font-size: 30px;color:#000000;padding-right:10px;">
'.$ach->getValueDone().'<br><img src="'.$_CONF['image_url'].'pic/yubo_done.png">
</td>
</tr><tr><td align="center" valign="top">';
$html .= ach_render_perk_done($ach);
$html .= '</td></tr></tbody></table></center>
</td>
<td style="background-image: url('.$_CONF['image_url'].'pic/bar_done_r.png);"></td>
</tr>
<tr>
<td><img src="'.$_CONF['image_url'].'pic/bar_done_bl.png"></td>
<td style="background-image: url('.$_CONF['image_url'].'pic/bar_done_b.png);"></td>
<td><img src="'.$_CONF['image_url'].'pic/bar_done_br.png"></td>
</tr>
</tbody></table></div>';
return $html;
}
function ach_render_achievement_open(&$ach) {
global $_CONF;
$html = '<div style="display: block; margin-bottom: 5px;"><table cellpadding="0" cellspacing="0" width="100%">
<tbody><tr>
<td width="3px"><img src="'.$_CONF['image_url'].'pic/bar_pending_ul.png"></td>
<td style="background-image: url('.$_CONF['image_url'].'pic/bar_pending_u.png);"></td>
<td width="3px"><img src="'.$_CONF['image_url'].'pic/bar_pending_ur.png"></td>
</tr>
<tr>
<td style="background-image: url('.$_CONF['image_url'].'pic/bar_pending_l.png);"></td>
<td>
<center><table width="100%" cellspacing="0" cellpadding="0">
<tbody><tr>
<td rowspan="2" valign="top"><img src="'.$_CONF['image_url'].'pic/icon/grey/'.$ach->getImage().'"></td>
<td width="100%"><center><span style="font-weight:bold;font-size:24px;color:#FFFFFF;">'.$ach->getName().'</span></center></td>
<td rowspan="2" valign="top" style="font-weight: bold; text-align: center; font-size: 30px;color:#FFFFFF;padding-right:10px;">
'.$ach->getValueOpen().'<br><img src="'.$_CONF['image_url'].'pic/yubo_pending.png">
</td>
</tr><tr><td align="center" valign="top">';
$html .= ach_render_perk_open($ach);
$html .= '</td></tr></tbody></table></center>
</td>
<td style="background-image: url('.$_CONF['image_url'].'pic/bar_pending_r.png);"></td>
</tr>
<tr>
<td><img src="'.$_CONF['image_url'].'pic/bar_pending_bl.png"></td>
<td style="background-image: url('.$_CONF['image_url'].'pic/bar_pending_b.png);"></td>
<td><img src="'.$_CONF['image_url'].'pic/bar_pending_br.png"></td>
</tr>
</tbody></table></div>';
return $html;
}
function ach_render_perk_open(&$ach) {
#echo var_export($perk_list,true);
$html = "";
$perk_list = $ach->getOpen();
$perk = $ach->getChildByIdx($perk_list->getNext());
echo "<b>".$ach->getIdx()."</b>";
echo "<br>".var_export($perk_list,true)."<br>";
#$perk = $ach->getChild($perk_list[0]);
if($perk->inDev()) {
return $html;
}
$html .= "<span style='color:#999999;font-weight:bold;display:block;'>";
if($perk->getName() != null) {
$html .= $perk->getName();
}
else {
$tml .= "[untitled]";
}
$html .= " <a href='?mode=player&pid=".$_REQUEST['pid']."&cat=".$_REQUEST['cat']."&grant=".$perk->getPath()."'><b>Perk:</b> grant</a>";
#if($perk->getName() != null) {
$html .= "</span>";
#}
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 = $ach->getChildByIdx($perk_list->getNext());
#foreach($perk_list as $elem) {
#$perk = $ach->getChild($elem);
if($perk->inDev()) {
continue;
}
$html .= "<div style='display:block;'><span style='color:#66CC00;font-weight:bold;'>".$perk->getName()."</span> ( ".date('d.m.Y',$perk->getDone())." ) <img src='".$_CONF['image_url']."pic/yubo_done.png' width='15px' /> ".$perk->getValue()." <a href='?mode=player&pid=".$_REQUEST['pid']."&cat=".$_REQUEST['cat']."&deny=".$perk->getPath()."'>Perk: deny</a></div>";
}
return $html;
}
function ach_render_obj_list($obj) {
$html = "<center><table width='90%'>";
$i = 0;
$skip = false;
while($obj->hasNext()) {
#foreach($obj as $elem) {
$elem = $obj->getNext();
if(($i%2) == 0) {
$html .= "<tr>";
}
switch($elem->getDisplay()) {
case "meta":
$html .= "<td width='50%'>".ach_render_obj_meta($elem)."</td>";
break;
case "value":
if(($i%2) == 1) {
$html .= "</tr><tr>";
}
$html .= "<td colspan='2' width='100%'><center>".ach_render_obj_value($elem)."</center></td>";
$i++;
break;
case "simple":
$html .= "<td width='50%'>".ach_render_obj_simple($elem)."</td>";
break;
case "hidden":
default:
//do nothing
$skip = true;
break;
}
if(($i%2) == 1) {
$html .= "</tr>";
}
if(!$skip) {
$i++;
}
$skip = false;
}
if(($i%2) == 1) {
$html .= "</tr>";
}
$html .= "</table></center>";
return $html;
}
function ach_render_obj_simple(&$obj) {
global $_CONF;
$html = "";
if($obj->isdone()) {
$html .= "<img src='".$_CONF['image_url']."pic/check.png' height='10px' />&nbsp;<span style='color:#71BE02;'>";
}
else {
$html .= "<img src='".$_CONF['image_url']."pic/pending.png' height='10px' />&nbsp;<span style='color:#999999;'>";
}
$html .= $obj->getName();
if($obj->isdone()) {
$html .= " <a href='?mode=player&pid=".$_REQUEST['pid']."&cat=".$_REQUEST['cat']."&deny=".$obj->getPath()."'>Obj: deny</a>";
}
else {
$html .= " <a href='?mode=player&pid=".$_REQUEST['pid']."&cat=".$_REQUEST['cat']."&grant=".$obj->getPath()."'>Obj: grant</a>";
}
$html .= "</span>";
return $html;
}
function ach_render_obj_meta(&$obj) {
global $_CONF;
$html = "";
if($obj->isdone()) {
$col = "#71BE02";
$grey = "";
}
else {
$col = "#999999";
$grey = "grey/";
}
$html .= "<table cellspacing='0' cellpadding='0'>
<tr>
<td><img src='".$_CONF['image_url']."pic/icon/".$grey.$obj->getMetaImage()."' width='20px' /></td>
<td valign='middle'><span style='color:".$col.";'>&nbsp;".$obj->getName();
if($obj->isdone()) {
$html .= " <a href='?mode=player&pid=".$_REQUEST['pid']."&cat=".$_REQUEST['cat']."&deny=".$obj->getPath()."'>Obj: deny</a>";
}
else {
$html .= " <a href='?mode=player&pid=".$_REQUEST['pid']."&cat=".$_REQUEST['cat']."&grant=".$obj->getPath()."'>Obj: grant</a>";
}
$html .= "</span></td>
</tr>
</table>";
return $html;
}
function ach_render_obj_value(&$obj) {
$html = "";
if($obj->getName() != null) {
if($obj->isdone()) {
$col = "#71BE02";
}
else {
$col = "#999999";
}
$html .= "<div style='color:".$col.";display:block;'>".$obj->getName()."</div>";
}
$html .= "<table>
<tr>
<td>".ach_render_progressbar($obj->getProgress(),$obj->getValue(),350)."</td>
<td>";
if($obj->isdone()) {
$html .= " <a href='?mode=player&pid=".$_REQUEST['pid']."&cat=".$_REQUEST['cat']."&deny=".$obj->getPath()."'>Obj: deny</a>";
}
else {
$html .= " <a href='?mode=player&pid=".$_REQUEST['pid']."&cat=".$_REQUEST['cat']."&grant=".$obj->getPath()."'>Obj: grant</a>";
}
$html .= "</td>
</tr>
</table>";
return $html;
}
function ach_render_progressbar($prog,$val,$width) {
$val = max(1,$val);
$left = floor($width*(100*($prog/$val))/100);
$html = "
<table width='".$width."px' cellspacing='0' cellpadding='0' style='border:1px solid #FFFFFF;color:#000000;'>
<tr>
<td bgcolor='#66CC00' width='".$left."px' align='right'>";
if(($prog/$val) > 0.85) {
$html .= "&nbsp;".nf($prog)." / ".nf($val)."&nbsp;";
}
$html .= "</td>
<td align='left' style='color:#FFFFFF;'>";
if(($prog/$val) <= 0.85) {
$html .= "&nbsp;".nf($prog)." / ".nf($val)."&nbsp;";
}
$html .= "</td>
</tr>
</table>";
return $html;
}
function ach_render_summary_header() {
global $_USER;
return "<div style='display:block;font-weight:bold;font-size:30px;color:#FFFFFF;text-align:center;margin-bottom:10px;'>".get_translation('ach_summary_header',$_USER->getLang())."</div>";
}
function ach_render_summary_footer(&$summary) {
global $_USER;
$nodes = $summary->getSummary();
$html = "";
$sum_done = 0;
$sum_total = 0;
$i = 0;
foreach($nodes as $elem) {
if(($i%3) == 0) {
$html .= "<tr>";
}
$html .= "<td width='50%' align='center'>".$elem[0]."<br>".ach_render_progressbar($elem[1],$elem[2],200)."</td>";
$sum_done += $elem[1];
$sum_total += $elem[2];
if(($i%3) == 2) {
$html .= "</tr>";
}
$i++;
}
if(($i%3) == 2) {
$html .= "</tr>";
}
$html = "<p />
<div style='display:block;font-weight:bold;font-size:30px;color:#FFFFFF;text-align:center;margin-bottom:10px;'>".get_translation('ach_summary_stats',$_USER->getLang())."</div>
<table>
<tr>
<td colspan='3' align='center'>".get_translation('ach_summary_stats_total',$_USER->getLang())."<br>".ach_render_progressbar($sum_done,$sum_total,450)."<br></td>
</tr>
".$html."
</table>";
return $html;
}
function ach_render_tiebar($cult = "c_neutral", $civ = "c_neutral",&$cat) {
global $_USER,$_CONF;
$html = "<style>
.o {
color:orange;
}
</style>
<div style='display:block;text-align:center;'><form method='post' action='?cat=".$cat->getID()."' id='cc_form'>
<table>
<tr>";
if($cat->isTiedCult()) {
$html.= "<td>
<select name='cult' onchange='document.getElementById(\"cc_form\").submit();'>
<option value='c_neutral'"; if($cult == "c_neutral") { $html.= " selected='selected'"; } $html .= ">".get_translation('ach_c_neutral',$_USER->getLang())."</option>
<option value='c_kami'"; if($cult == "c_kami") { $html.= " selected='selected'"; } $html .= ">Kami</option>
<option value='c_karavan'"; if($cult == "c_karavan") { $html.= " selected='selected'"; } $html .= ">Karavan</option>
</select>
</td>";
}
if($cat->isTiedCiv()) {
$html.= "<td>
<select name='civ' onchange='document.getElementById(\"cc_form\").submit();'>
<option value='c_neutral'"; if($civ == "c_neutral") { $html.= " selected='selected'"; } $html .= ">".get_translation('ach_c_neutral',$_USER->getLang())."</option>
<option value='c_fyros'"; if($civ == "c_fyros") { $html.= " selected='selected'"; } $html .= ">Fyros</option>
<option value='c_matis'"; if($civ == "c_matis") { $html.= " selected='selected'"; } $html .= ">Matis</option>
<option value='c_tryker'"; if($civ == "c_tryker") { $html.= " selected='selected'"; } $html .= ">Tryker</option>
<option value='c_zorai'"; if($civ == "c_zorai") { $html.= " selected='selected'"; } $html .= ">Zorai</option>
</select>
</td>";
}
$html.= "</tr>
</table>
</form></div>
<div style='display:block;font-weight:bold;font-size:20px;color:#FFFFFF;text-align:center;margin-bottom:5px;'>";
if($cat->isTiedCult() && !$cat->isTiedCiv() && $cult == "c_neutral") { // neutral / xx
#While being of neutral allegiance with the higher powers
$html .= get_translation('ach_allegiance_neutral_cult',$_USER->getLang(),array("<span class='o'>".get_translation('ach_c_neutral',$_USER->getLang())."</span>"));
}
elseif($cat->isTiedCiv() && !$cat->isTiedCult() && $civ == "c_neutral") { // xx / neutral
#While being of neutral allegiance with the homin civilizations
$html .= get_translation('ach_allegiance_neutral_civ',$_USER->getLang(),array("<span class='o'>".get_translation('ach_c_neutral',$_USER->getLang())."</span>"));
}
elseif($cat->isTiedCiv() && $cat->isTiedCult() && $cult == "c_neutral" && $civ == "c_neutral") { // neutral / neutral
#While being of neutral allegiance
$html .= get_translation('ach_allegiance_neutral',$_USER->getLang(),array("<span class='o'>".get_translation('ach_c_neutral',$_USER->getLang())."</span>"));
}
else { //other
#While being aligned with the
$html .= get_translation('ach_allegiance_start',$_USER->getLang());
if($cat->isTiedCult() && $cult != "c_neutral") {
#CULT
$html .= "<span class='o'>".ach_translate_cc($cult)."</span>";
if($cat->isTiedCiv() && $civ != "c_neutral") {
#and the CIV
$html .= get_translation('ach_allegiance_and',$_USER->getLang())." <span class='o'>".ach_translate_cc($civ)."</span>";
}
}
elseif($cat->isTiedCiv() && $civ != "c_neutral") {
#CIV
$html .= "<span class='o'>".ach_translate_cc($civ)."</span>";
}
}
#, accomplish the following achievements:
$html .= get_translation('ach_allegiance_end',$_USER->getLang())."</div>";
return $html;
}
?>

View file

@ -0,0 +1,171 @@
<?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>&nbsp;</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>&nbsp;<a href='javascript:hs(\"edit_m".$curr->getID()."\",\"block\");'><img src='pic/icon_edit.gif'></a>";
if($sub == 0) {
$html .= "&nbsp;<a href='javascript:hs(\"ins_m".$curr->getID()."\",\"block\");'><img src='pic/b_insrow.png'></a>";
}
$html .= "&nbsp;&nbsp;&nbsp;<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>&nbsp;</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>&nbsp;</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;
}
?>

View file

@ -24,44 +24,54 @@ $user['admin'] = true;
require_once($_CONF['app_achievements_path']."class/RyzomUser_class.php");
require_once("class/RyzomAdmin_class.php");
$_USER = new RyzomAdmin($user);
$_ADMIN = new RyzomAdmin($user);
require_once("include/ach_render_admin.php");
#require_once("include/ach_render_csr.php");
require_once($_CONF['app_achievements_path']."class/RenderNodeIterator_abstract.php");
require_once($_CONF['app_achievements_path']."class/NodeIterator_class.php");
require_once($_CONF['app_achievements_path']."class/AchList_abstract.php");
require_once($_CONF['app_achievements_path']."class/Tieable_inter.php");
require_once($_CONF['app_achievements_path']."class/AchMenu_class.php");
require_once($_CONF['app_achievements_path']."class/AchMenuNode_class.php");
#require_once($_CONF['app_achievements_path']."class/AchCategory_class.php");
#require_once($_CONF['app_achievements_path']."class/AchAchievement_class.php");
#require_once($_CONF['app_achievements_path']."class/AchPerk_class.php");
#require_once($_CONF['app_achievements_path']."class/AchObjective_class.php");
require_once("class/ADM_inter.php");
require_once("class/AdmDispatcher_inter.php");
require_once("class/AdmMenu_class.php");
require_once("class/AdmMenuNode_class.php");
#require_once("class/AdmCategory_class.php");
#require_once("class/AdmAchievement_class.php");
#require_once("class/AdmPerk_class.php");
#require_once("class/AdmObjective_class.php");
/*require_once("class/CSR_inter.php");
require_once("class/CSRMenu_class.php");
require_once("class/CSRCategory_class.php");
require_once("class/CSRAchievement_class.php");
require_once("class/CSRPerk_class.php");
require_once("class/CSRObjective_class.php");*/
if($_USER->isIG()) {
if($_ADMIN->isIG()) {
die("IG disabled for admin tool!");
}
$DBc = ryDB::getInstance("ahufler");
require_once("class/mySQL_class.php");
#require_once("include/ach_render_admin.php");
#require_once("include/ach_render_csr.php");
require_once($_CONF['app_achievements_path']."include/ach_render_common.php");
require_once($_CONF['app_achievements_path']."class/AVLTree_class.php");
require_once($_CONF['app_achievements_path']."class/Parentum_abstract.php");
require_once($_CONF['app_achievements_path']."class/AchList_abstract.php");
require_once($_CONF['app_achievements_path']."class/Tieable_inter.php");
require_once($_CONF['app_achievements_path']."class/NodeIterator_class.php");
require_once($_CONF['app_achievements_path']."class/Node_trait.php");
require_once($_CONF['app_achievements_path']."class/InDev_trait.php");
require_once($_CONF['app_achievements_path']."class/AchMenu_class.php");
require_once($_CONF['app_achievements_path']."class/AchMenuNode_class.php");
require_once($_CONF['app_achievements_path']."class/AchCategory_class.php");
require_once($_CONF['app_achievements_path']."class/AchAchievement_class.php");
require_once($_CONF['app_achievements_path']."class/AchPerk_class.php");
require_once($_CONF['app_achievements_path']."class/AchObjective_class.php");
require_once("class/ADM_inter.php");
require_once("class/AdmDispatcher_trait.php");
require_once("class/AdmMenu_class.php");
require_once("class/AdmMenuNode_class.php");
require_once("class/AdmCategory_class.php");
require_once("class/AdmAchievement_class.php");
require_once("class/AdmPerk_class.php");
require_once("class/AdmObjective_class.php");
require_once("class/AdmAtom_class.php");
require_once("class/CSRDispatcher_trait.php");
require_once("class/CSR_inter.php");
#require_once("class/CSRMenu_class.php");
require_once("class/CSRCategory_class.php");
require_once("class/CSRAchievement_class.php");
require_once("class/CSRPerk_class.php");
require_once("class/CSRObjective_class.php");
require_once("class/CSRAtom_class.php");
$DBc = ryDB::getInstance("app_achievements");
#$DBc = ryDB::getInstance("ahufler");
function mkn($x) {
if($x == null || strtolower($x) == "null") {
@ -94,21 +104,27 @@ $c = "<script type='text/javascript'>
}
</script>
<style>
h1 {
margin-top:0px;
}
</style>
<center><table width='100%'>
<tr>
<td valign='top' width='230px'><div style='font-weight:bold;font-size:14px;'>";
<td valign='top' width='200px'><div style='font-weight:bold;font-size:14px;'>";
if($_USER->isAdmin()) {
if($_ADMIN->isAdmin()) {
$c .= "<b>Admin</b><br>
<ul>
<li><a href='?mode=menu'>menu settings</a></li>
<li><a href='?mode=ach'>achievement settings</a></li>
</ul><p />";
}
if($_USER->isCSR()) {
if($_ADMIN->isCSR()) {
$c .= "<b>CSR</b><br>
<ul>
<li><a href='?mode=player'>administrate player</a></li>
<li><a href='?mode=player'>player administration</a></li>
</ul><p />";
}
@ -118,13 +134,26 @@ $c = "<script type='text/javascript'>
$c .= "</div></td>
<td valign='top'>";
if($_REQUEST['mode'] == "menu" && $_USER->isAdmin()) {
if($_REQUEST['mode'] == "menu" && $_ADMIN->isAdmin()) {
$c .= "<h1>Menu Settings</h1>";
$user = array();
$user['id'] = 1;
$user['lang'] = 'en';
$user['name'] = 'Talvela';
$user['race'] = "r_matis";
$user['civilization'] = "c_neutral";
$user['cult'] = "c_neutral";
$_USER = new RyzomUser($user);
require_once("include/adm_render_menu.php");
$menu = new AdmMenu(false);
if($_REQUEST['act'] == "insert") {
$n = new AdmMenuNode(array(),null);
$n->setID(null);
$n->setDev(1);
$n->setInDev(true);
$n->setName($_REQUEST['acl_name']);
$n->setImage($_REQUEST['ac_image']);
$n->setParentID($_REQUEST['ac_parent']);
@ -149,6 +178,230 @@ $c .= "</div></td>
$c .= adm_render_menu($menu);
}
if($_REQUEST['mode'] == "ach" && $_ADMIN->isAdmin()) {
$c .= "<h1>Achievement Settings</h1>";
$user = array();
$user['id'] = 0;
$user['lang'] = 'en';
$user['name'] = 'Talvela';
$user['race'] = "r_matis";
$user['civilization'] = "c_neutral";
$user['cult'] = "c_neutral";
$_USER = new RyzomUser($user);
//menu
require_once("include/adm_render_ach.php");
$menu = new AdmMenu($_REQUEST['cat']);
$c .= "<center><table>
<tr>
<td valign='top'><div style='width:230px;font-weight:bold;font-size:14px;'>";
$c .= adm_render_menu($menu);
$c .= "</div></td>
<td width='645px' valign='top'>";
$open = $menu->getOpenCat();
if($open != 0) {
$cat = new AdmCategory($open,$_REQUEST['cult'],$_REQUEST['civ']);
if($_REQUEST['act'] == "ach_move") {
$ach = $cat->getChildByID($_REQUEST['id']);
if($ach != null) {
$ach->setCategory($_REQUEST['new_cat']);
$ach->update();
$cat->removeChild($ach->getID());
}
}
if($_REQUEST['act'] == "ach_insert") {
$ach = new AdmAchievement(array(),$cat);
$ach->setCategory($cat->getID());
$ach->setName($_REQUEST['aal_name']);
$ach->setTemplate($_REQUEST['aal_template']);
$ach->setTieCult($_REQUEST['aa_tie_cult']);
$ach->setTieCiv($_REQUEST['aa_tie_civ']);
$ach->setImage($_REQUEST['aa_image']);
$cat->insertNode($ach);
$perk = new AdmPerk(array(),$ach);
$perk->setAchievement($ach->getID());
$perk->setName($_REQUEST['apl_name']);
$perk->setTemplate($_REQUEST['apl_name']);
$perk->setValue($_REQUEST['ap_value']);
$ach->insertNode($perk);
}
if($_REQUEST['act'] == "ach_update") {
$ach = $cat->getChildByID($_REQUEST['id']);
if($ach != null) {
$ach->setName($_REQUEST['aal_name']);
$ach->setTemplate($_REQUEST['aal_template']);
$ach->setTieCult($_REQUEST['aa_tie_cult']);
$ach->setTieCiv($_REQUEST['aa_tie_civ']);
$ach->setImage($_REQUEST['aa_image']);
$ach->update();
}
}
if($_REQUEST['act'] == "perk_insert") {
$ach = $cat->getChildByID($_REQUEST['id']);
if($ach != null) {
$perk = new AdmPerk(array(),$ach);
$perk->setAchievement($ach->getID());
$perk->setName($_REQUEST['apl_name']);
$perk->setTemplate($_REQUEST['apl_name']);
$perk->setValue($_REQUEST['ap_value']);
#MISSING: parent
#$perk->setCondition($_REQUEST['ap_condition']);
#$perk->setConditionValue($_REQUEST['ap_condition_value']);
$ach->insertNode($perk);
}
}
if($_REQUEST['act'] == "perk_update") {
$perk = $cat->getElementByPath($_REQUEST['id']);
if($perk != null) {
$perk->setName($_REQUEST['apl_name']);
$perk->setTemplate($_REQUEST['apl_template']);
$perk->setValue($_REQUEST['ap_value']);
#$perk->setParentID($_REQUEST['ap_parent']);
$perk->setCondition($_REQUEST['ap_condition']);
$perk->setConditionValue($_REQUEST['ap_condition_value']);
$perk->update();
}
}
if($_REQUEST['act'] == "obj_insert") {
$perk = $cat->getElementByPath($_REQUEST['id']);
if($perk != null) {
$obj = new AdmObjective(array(),$perk);
$obj->setName($_REQUEST['aol_name']);
$obj->setCondition($_REQUEST['ao_condition']);
$obj->setValue($_REQUEST['ao_value']);
$obj->setDisplay($_REQUEST['ao_display']);
$obj->setMetalink($_REQUEST['ao_metalink']);
$perk->insertNode($obj);
}
}
if($_REQUEST['act'] == "obj_update") {
$obj = $cat->getElementByPath($_REQUEST['id']);
if($obj != null) {
$obj->setName($_REQUEST['aol_name']);
$obj->setCondition($_REQUEST['ao_condition']);
$obj->setValue($_REQUEST['ao_value']);
$obj->setDisplay($_REQUEST['ao_display']);
$obj->setMetalink($_REQUEST['ao_metalink']);
$obj->update();
}
}
if($_REQUEST['act'] == "delete") {
$elem = $cat->getElementByPath($_REQUEST['id']);
$par = $elem->getParent();
$par->removeNode($elem->getID());
}
if($_REQUEST['act'] == "dev") {
$curr = $cat->getElementByPath($_REQUEST['id']);
$curr->setInDev(($_REQUEST['state'] != 1));
}
$c .= adm_render_category($cat);
}
#a:p:o:a
$c .= "</td>
</tr>
</table></center>";
//category
}
if($_REQUEST['mode'] == "player" && $_ADMIN->isCSR()) {
$c .= "<h1>Player Administration</h1>";
$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']);
//menu
require_once("include/adm_render_csr.php");
if(!is_user($_REQUEST['pid'])) { // no user ID
$c .= csr_render_find_player();
}
else {
$user = array();
$user['id'] = $_REQUEST['pid'];
$user['lang'] = 'en';
$user['name'] = 'Talvela';
$user['race'] = "r_matis";
$user['civilization'] = "c_neutral";
$user['cult'] = "c_neutral";
$_USER = new RyzomUser($user);
$menu = new AchMenu($_REQUEST['cat']);
$open = $menu->getOpenCat();
if($open != 0) {
$cat = new CSRCategory($open,$_REQUEST['cult'],$_REQUEST['civ']);
if($_REQUEST['grant'] != "") {
$cat->grantNode($_REQUEST['grant'],$_USER->getID());
}
if($_REQUEST['deny'] != "") {
$cat->denyNode($_REQUEST['deny'],$_USER->getID());
}
}
$c .= "<center><table>
<tr>
<td colspan='2' align='left'>".csr_render_yubopoints($user['id'])."</td>
</tr>
<tr>
<td valign='top'><div style='width:230px;font-weight:bold;font-size:14px;'>";
$c .= csr_render_menu($menu);
$c .= "</div></td>
<td width='645px' valign='top'>";
$open = $menu->getOpenCat();
if($open != 0) {
$c .= csr_render_category($cat);
}
$c .= "</td>
</tr>
</table></center>";
}
}
#$c .= ach_render_content();
$c .= "</td>
@ -156,6 +409,6 @@ $c .= "</td>
</table></center>";
echo ryzom_app_render("achievements admin", $c, $_USER->isIG());
echo ryzom_app_render("achievements admin", $c, $_ADMIN->isIG());
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 618 B