3 $microstart = explode(' ',microtime());
4 $start_time = $microstart[0] +
$microstart[1];
6 error_reporting(E_ALL ^ E_NOTICE
);
7 ini_set("display_errors","1");
9 define('APP_NAME', 'app_achievements_admin');
11 require_once('../config.php');
12 include_once('../lang.php');
13 include_once('lang.php');
14 require_once('conf.php');
16 // Ask to authenticate user (using ingame or session method) and fill $user with all information
17 ryzom_app_authenticate($user, true);
19 #echo var_export($user,true);
24 $user['name'] = 'Talvela';
25 $user['race'] = "r_matis";
26 $user['civilization'] = "c_neutral";
27 $user['cult'] = "c_neutral";
28 $user['admin'] = true;*/
30 require_once($_CONF['app_achievements_path']."class/RyzomUser_class.php");
31 require_once("class/RyzomAdmin_class.php");
32 $_ADMIN = new RyzomAdmin($user);
35 die("IG disabled for admin tool!");
38 require_once("class/mySQL_class.php");
40 require_once($_CONF['app_achievements_path']."include/ach_render_common.php");
42 require_once($_CONF['app_achievements_path']."class/DLL_class.php");
43 require_once($_CONF['app_achievements_path']."class/Node_abstract.php");
44 require_once($_CONF['app_achievements_path']."class/AVLTree_class.php");
45 require_once($_CONF['app_achievements_path']."class/Parentum_abstract.php");
46 require_once($_CONF['app_achievements_path']."class/AchList_abstract.php");
47 require_once($_CONF['app_achievements_path']."class/Tieable_inter.php");
48 require_once($_CONF['app_achievements_path']."class/NodeIterator_class.php");
49 #require_once($_CONF['app_achievements_path']."class/InDev_trait.php");
51 require_once($_CONF['app_achievements_path']."class/AchMenu_class.php");
52 require_once($_CONF['app_achievements_path']."class/AchMenuNode_class.php");
53 require_once($_CONF['app_achievements_path']."class/AchCategory_class.php");
54 require_once($_CONF['app_achievements_path']."class/AchAchievement_class.php");
55 require_once($_CONF['app_achievements_path']."class/AchTask_class.php");
56 require_once($_CONF['app_achievements_path']."class/AchObjective_class.php");
57 require_once($_CONF['app_achievements_path']."class/AchSummary_class.php");
59 require_once("class/ADM_inter.php");
60 #require_once("class/AdmDispatcher_trait.php");
61 require_once("class/AdmMenu_class.php");
62 require_once("class/AdmMenuNode_class.php");
63 require_once("class/AdmCategory_class.php");
64 require_once("class/AdmAchievement_class.php");
65 require_once("class/AdmTask_class.php");
66 require_once("class/AdmObjective_class.php");
67 require_once("class/AdmAtom_class.php");
69 #require_once("class/CSRDispatcher_trait.php");
70 require_once("class/CSR_inter.php");
71 require_once("class/CSRCategory_class.php");
72 require_once("class/CSRAchievement_class.php");
73 require_once("class/CSRTask_class.php");
74 require_once("class/CSRObjective_class.php");
75 require_once("class/CSRAtom_class.php");
77 $DBc = ryDB
::getInstance("app_achievements");
79 function mkn($x) { // make NULL function for SQL
81 if($x == null ||
strtolower($x) == "null" ||
$x == "") {
85 return "'".$DBc->sqlEscape($x)."'";
90 $c = "<script type='text/javascript'>
92 function hs(id,mod) { // hide / show
93 if(document.getElementById(id).style.display == 'none') {
94 document.getElementById(id).style.display=mod;
97 document.getElementById(id).style.display='none';
101 function hs_force(id,mod,show) { // hide / show forced
103 document.getElementById(id).style.display=mod;
106 document.getElementById(id).style.display='none';
117 <center><table width='100%'>
119 <td valign='top' width='200px'><div style='font-weight:bold;font-size:14px;'>";
121 if($_ADMIN->isAdmin()) {
122 $c .= "<b>Admin</b><br>
124 <li><a href='?mode=menu'>menu settings</a></li>
125 <li><a href='?mode=ach'>achievement settings</a></li>
126 <li><a href='?mode=atom'>trigger settings</a></li>
127 <li><a href='?mode=lang'>language editor</a></li>
128 <li><a href='?mode=stats'>statistics</a></li>
131 if($_ADMIN->isCSR()) {
132 $c .= "<b>CSR</b><br>
134 <li><a href='?mode=player'>player administration</a></li>
143 /*if($_REQUEST['mode'] == "insert_fame" && $_ADMIN->isAdmin()) {
144 $ftpl = 'ENTITY fame AS $fame {
145 if($fame->faction == ".faction" && ceil($fame->fame/6000) >= [0]) {
151 $res = $DBc->sqlQuery("SELECT at_id,atl_name FROM ach_achievement,ach_task,ach_task_lang WHERE at_achievement=aa_id AND ((aa_category<'24' AND aa_category>'15') OR aa_category='56') AND atl_task=at_id AND atl_lang='en'");
153 for($i=0;$i<sizeof($res);$i++) {
154 $DBc->sqlQuery("INSERT INTO ach_objective (ao_task,ao_condition,ao_value,ao_display,ao_metalink) VALUES ('".$res[$i]['at_id']."','all',NULL,'hidden',NULL)");
155 $nid = $DBc->insertID();
156 $DBc->sqlQuery("INSERT INTO ach_atom (atom_objective,atom_mandatory,atom_ruleset) VALUES ('".$nid."','0','".$DBc->sqlEscape(str_replace('[0]',$res[$i]['atl_name'],$ftpl))."')");
158 $c .= "INSERT INTO ach_objective (ao_task,ao_condition,ao_value,ao_display,ao_metalink) VALUES ('".$res[$i]['at_id']."','all',NULL,'hidden',NULL)<br>";
160 $c .= "INSERT INTO ach_atom (atom_objective,atom_mandatory,atom_ruleset) VALUES ('".$nid."','0','".$DBc->sqlEscape(str_replace('[0]',$res[$i]['atl_name'],$ftpl))."')<p>";
164 if($_REQUEST['mode'] == "enable_fame" && $_ADMIN->isAdmin()) {
165 $res = $DBc->sqlQuery("SELECT aa_id FROM ach_achievement WHERE (aa_category<'24' AND aa_category>'14') OR aa_category='56'");
167 for($i=0;$i<sizeof($res);$i++) {
168 $DBc->sqlQuery("UPDATE ach_achievement SET aa_dev='0' WHERE aa_id='".$res[$i]['aa_id']."'");
170 $DBc->sqlQuery("UPDATE ach_task SET at_dev='0' WHERE at_achievement='".$res[$i]['aa_id']."'");
177 if($_REQUEST['mode'] == "lang" && $_ADMIN->isAdmin()) {
178 $c .= "<h1>Language Editor</h1>";
182 $user['lang'] = 'en';
183 $user['name'] = 'Talvela';
184 $user['race'] = "matis";
185 $user['civ'] = "neutral";
186 $user['cult'] = "neutral";
188 $_USER = new RyzomUser($user);
191 require_once("include/adm_render_lang.php");
192 $menu = new AdmMenu($_REQUEST['cat']);
194 $c .= "<center><table>
196 <td valign='top'><div style='width:230px;font-weight:bold;font-size:14px;'>";
199 $c .= adm_render_menu($menu);
202 <td width='645px' valign='top'>";
204 $open = $menu->getOpenCat();
207 $cat = new AdmCategory($open,'%','%','%');
209 if($_REQUEST['act'] == "cat_save") {
210 if(is_array($_REQUEST['c_name'])) {
211 foreach($_REQUEST['c_name'] as $key=>$elem) {
212 $cat->setLang($key,$_REQUEST['c_name'][$key]);
217 if($_REQUEST['act'] == "ach_save") {
218 $ach = $cat->getElementByPath($_REQUEST['id']);
220 if(is_array($_REQUEST['a_name'])) {
221 foreach($_REQUEST['a_name'] as $key=>$elem) {
222 $ach->setLang($key,$_REQUEST['a_name'][$key],$_REQUEST['a_tpl'][$key]);
227 if($_REQUEST['act'] == "task_save") {
228 $task = $cat->getElementByPath($_REQUEST['id']);
230 if(is_array($_REQUEST['t_name'])) {
231 foreach($_REQUEST['t_name'] as $key=>$elem) {
232 $task->setLang($key,$_REQUEST['t_name'][$key],$_REQUEST['t_tpl'][$key]);
237 if($_REQUEST['act'] == "obj_save") {
238 $obj = $cat->getElementByPath($_REQUEST['id']);
240 if(is_array($_REQUEST['o_name'])) {
241 foreach($_REQUEST['o_name'] as $key=>$elem) {
242 $obj->setLang($key,$_REQUEST['o_name'][$key]);
249 $c .= atom_render_category($cat);
263 if($_REQUEST['mode'] == "atom" && $_ADMIN->isAdmin()) {
264 $c .= "<h1>Trigger Settings</h1>";
268 $user['lang'] = 'en';
269 $user['name'] = 'Talvela';
270 $user['race'] = "matis";
271 $user['civ'] = "neutral";
272 $user['cult'] = "neutral";
274 $_USER = new RyzomUser($user);
277 require_once("include/adm_render_atom.php");
278 $menu = new AdmMenu($_REQUEST['cat']);
280 $c .= "<center><table>
282 <td valign='top'><div style='width:230px;font-weight:bold;font-size:14px;'>";
285 $c .= adm_render_menu($menu);
288 <td width='645px' valign='top'>";
290 $open = $menu->getOpenCat();
293 $cat = new AdmCategory($open,'%','%','%');
295 if($_REQUEST['act'] == "insert_atom") {
296 $obj = $cat->getElementByPath($_REQUEST['id']);
299 $atom = new AdmAtom(array(),$obj);
300 $atom->setRuleset($_REQUEST['atom_ruleset']);
301 $atom->setMandatory($_REQUEST['atom_mandatory']);
302 $atom->setObjective($obj->getID());
304 $obj->insertNode($atom);
308 if($_REQUEST['act'] == "update_atom") {
309 $atom = $cat->getElementByPath($_REQUEST['id']);
312 $atom->setRuleset($_REQUEST['atom_ruleset']);
313 $atom->setMandatory($_REQUEST['atom_mandatory']);
319 if($_REQUEST['act'] == "delete") {
320 $elem = $cat->getElementByPath($_REQUEST['id']);
321 $par = $elem->getParent();
322 $par->removeNode($elem->getID());
325 $c .= atom_render_category($cat);
338 if($_REQUEST['mode'] == "menu" && $_ADMIN->isAdmin()) {
339 $c .= "<h1>Menu Settings</h1>";
343 $user['lang'] = 'en';
344 $user['name'] = 'Talvela';
345 $user['race'] = "matis";
346 $user['civ'] = "neutral";
347 $user['cult'] = "neutral";
349 $_USER = new RyzomUser($user);
351 require_once("include/adm_render_menu.php");
352 $menu = new AdmMenu(false);
354 if($_REQUEST['act'] == "insert") {
355 $n = new AdmMenuNode(array(),null);
358 $n->setName($_REQUEST['acl_name']);
359 $n->setImage($_REQUEST['ac_image']);
360 $n->setParentID($_REQUEST['ac_parent']);
362 $menu->insertNode($n);
365 if($_REQUEST['act'] == "delete") {
366 $menu->removeNode($_REQUEST['ac_id']);
369 if($_REQUEST['act'] == "update") {
370 $menu->updateNode($_REQUEST['ac_id'],array("acl_name"=>$_REQUEST['acl_name'],"ac_image"=>$_REQUEST['ac_image']));
373 if($_REQUEST['act'] == "dev") {
374 $curr = $menu->getNode($_REQUEST['ac_id']);
375 $curr->setInDev(($_REQUEST['state'] != 1));
379 $c .= adm_render_menu($menu);
383 * Achievement settings
386 if($_REQUEST['mode'] == "ach" && $_ADMIN->isAdmin()) {
387 $c .= "<h1>Achievement Settings</h1>";
391 $user['lang'] = 'en';
392 $user['name'] = 'Talvela';
393 $user['race'] = "matis";
394 $user['civ'] = "neutral";
395 $user['cult'] = "neutral";
397 $_USER = new RyzomUser($user);
400 require_once("include/adm_render_ach.php");
401 $menu = new AdmMenu($_REQUEST['cat']);
403 $c .= "<center><table>
405 <td valign='top'><div style='width:230px;font-weight:bold;font-size:14px;'>";
408 $c .= adm_render_menu($menu);
411 <td width='645px' valign='top'>";
413 $open = $menu->getOpenCat();
416 if($_REQUEST['cult']) {
417 $cult = $_REQUEST['cult'];
418 $_SESSION['cult'] = $cult;
420 elseif($_SESSION['cult']) {
421 $cult = $_SESSION['cult'];
424 $cult = $_USER->getCult();
427 if($_REQUEST['civ']) {
428 $civ = $_REQUEST['civ'];
429 $_SESSION['civ'] = $civ;
431 elseif($_SESSION['civ']) {
432 $civ = $_SESSION['civ'];
435 $civ = $_USER->getCiv();
440 $cat = new AdmCategory($open,$_USER->getRace(),$cult,$civ);
442 $microstop = explode(' ',microtime());
443 $stop_time = $microstop[0] +
$microstop[1];
445 echo "<br>loading: ".round($stop_time - $start_time,3);
447 $start_time = $stop_time;
449 if($_REQUEST['act'] == "ach_move") {
450 $ach = $cat->getChildDataByID($_REQUEST['id']);
452 $ach->setCategory($_REQUEST['new_cat']);
454 $cat->removeChild($ach->getID());
456 $iter = $cat->getOpen();
457 while($iter->hasNext()) {
458 $item = $iter->getNext();
460 if($ach->getID() == $item->getParentID()) {
461 $item->setCategory($_REQUEST['new_cat']);
463 $cat->removeChild($item->getID());
469 if($_REQUEST['act'] == "ach_insert") {
470 $ach = new AdmAchievement(array(),$cat);
471 $ach->setCategory($cat->getID());
472 $ach->setName($_REQUEST['aal_name']);
473 $ach->setTemplate($_REQUEST['aal_template']);
474 $ach->setImage($_REQUEST['aa_image']);
475 $ach->setParentID($_REQUEST['aa_parent']);
476 $ach->setSticky($_REQUEST['aa_sticky']);
478 $cat->insertNode($ach);
480 $task = new AdmTask(array(),$ach);
481 $task->setAchievement($ach->getID());
482 $task->setName($_REQUEST['atl_name']);
483 $task->setTemplate($_REQUEST['atl_template']);
484 $task->setValue($_REQUEST['at_value']);
485 $task->setCondition($_REQUEST['at_condition']);
486 $task->setConditionValue($_REQUEST['at_condition_value']);
487 $task->setHeritage(0);
489 if(is_array($_REQUEST['at_tie_allegiance'])) {
490 $task->setTieAlign($_REQUEST['at_tie_allegiance']);
493 $ach->insertNode($task);
496 if($_REQUEST['act'] == "ach_update") {
497 $ach = $cat->getChildDataByID($_REQUEST['id']);
500 $ach->setName($_REQUEST['aal_name']);
501 $ach->setTemplate($_REQUEST['aal_template']);
502 #$ach->setTieCult($_REQUEST['aa_tie_cult']);
503 #$ach->setTieCiv($_REQUEST['aa_tie_civ']);
504 $ach->setImage($_REQUEST['aa_image']);
505 $ach->setParentID($_REQUEST['aa_parent']);
506 $ach->setSticky($_REQUEST['aa_sticky']);
512 if($_REQUEST['act'] == "task_insert") {
513 $ach = $cat->getChildDataByID($_REQUEST['id']);
515 $task = new AdmTask(array(),$ach);
516 $task->setAchievement($ach->getID());
517 $task->setName($_REQUEST['atl_name']);
518 $task->setTemplate($_REQUEST['atl_template']);
519 $task->setValue($_REQUEST['at_value']);
520 $task->setCondition($_REQUEST['at_condition']);
521 $task->setConditionValue($_REQUEST['at_condition_value']);
522 $task->setHeritage($_REQUEST['at_inherit']);
524 if(is_array($_REQUEST['at_tie_allegiance'])) {
525 $task->setTieAlign($_REQUEST['at_tie_allegiance']);
528 $ach->insertNode($task);
529 $task->setParentID($_REQUEST['at_parent']);
535 if($_REQUEST['act'] == "task_update") {
536 $task = $cat->getElementByPath($_REQUEST['id']);
539 $task->setName($_REQUEST['atl_name']);
540 $task->setTemplate($_REQUEST['atl_template']);
541 $task->setValue($_REQUEST['at_value']);
542 $task->setCondition($_REQUEST['at_condition']);
543 $task->setConditionValue($_REQUEST['at_condition_value']);
544 $task->setHeritage($_REQUEST['at_inherit']);
546 if(is_array($_REQUEST['at_tie_allegiance'])) {
547 $task->setTieAlign($_REQUEST['at_tie_allegiance']);
550 $task->setParentID($_REQUEST['at_parent']);
552 $ach = $task->getParent();
559 if($_REQUEST['act'] == "obj_insert") {
560 $task = $cat->getElementByPath($_REQUEST['id']);
563 $obj = new AdmObjective(array(),$task);
564 $obj->setName($_REQUEST['aol_name']);
565 $obj->setCondition($_REQUEST['ao_condition']);
566 $obj->setValue($_REQUEST['ao_value']);
567 $obj->setDisplay($_REQUEST['ao_display']);
568 $obj->setMetalink($_REQUEST['ao_metalink']);
569 $obj->setTask($task->getID());
571 $task->insertNode($obj);
575 if($_REQUEST['act'] == "obj_update") {
576 $obj = $cat->getElementByPath($_REQUEST['id']);
579 $obj->setName($_REQUEST['aol_name']);
580 $obj->setCondition($_REQUEST['ao_condition']);
581 $obj->setValue($_REQUEST['ao_value']);
582 $obj->setDisplay($_REQUEST['ao_display']);
583 $obj->setMetalink($_REQUEST['ao_metalink']);
589 if($_REQUEST['act'] == "delete") {
590 $elem = $cat->getElementByPath($_REQUEST['id']);
592 $par = $elem->getParent();
593 $par->removeNode($elem->getID());
595 if(get_class($elem) == "AdmAchievement") {
596 $iter = $cat->getOpen();
597 while($iter->hasNext()) {
598 $item = $iter->getNext();
600 if($elem->getID() == $item->getParentID()) {
601 $item->setParentID(null);
609 if($_REQUEST['act'] == "dev") {
610 $curr = $cat->getElementByPath($_REQUEST['id']);
611 $curr->setInDev(($_REQUEST['state'] != 1));
614 $microstop = explode(' ',microtime());
615 $stop_time = $microstop[0] +
$microstop[1];
617 echo "<br>manipulation: ".round($stop_time - $start_time,3);
619 $start_time = $stop_time;
621 $c .= adm_render_category($cat);
623 $microstop = explode(' ',microtime());
624 $stop_time = $microstop[0] +
$microstop[1];
626 echo "<br>rendering: ".round($stop_time - $start_time,3);
639 if($_REQUEST['mode'] == "stats" && $_ADMIN->isCSR()) {
640 require_once("include/adm_render_stats.php");
642 $c .= "<h1>Statistics</h1>";
644 $c .= stats_render();
650 if($_REQUEST['mode'] == "player" && $_ADMIN->isCSR()) {
651 $c .= "<h1>Player Administration</h1>";
653 #$DBc_char = new mySQL($_CONF['mysql_error']);
654 #$DBc_char->connect($_CONF['char_mysql_server'],$_CONF['char_mysql_user'],$_CONF['char_mysql_pass'],$_CONF['char_mysql_database']);
656 $DBc_char = ryDB
::getInstance("webig");
658 require_once("include/adm_render_csr.php");
660 if(!is_user($_REQUEST['pid'])) { // no user ID
661 $c .= csr_render_find_player();
665 $user['id'] = $_REQUEST['pid'];
666 $user['lang'] = 'en';
667 $dta = user_get_data($_REQUEST['pid']);
668 $user['char_name'] = user_get_name($_REQUEST['pid']);
669 $user['race'] = substr($dta['race'],2);
670 $user['civ'] = substr($dta['civilisation'],2);
671 $user['cult'] = substr($dta['cult'],2);
673 $_USER = new RyzomUser($user);
675 $menu = new AchMenu($_REQUEST['cat']);
677 $open = $menu->getOpenCat();
680 if($_REQUEST['cult']) {
681 $cult = $_REQUEST['cult'];
682 $_SESSION['cult'] = $cult;
684 elseif($_SESSION['cult']) {
685 $cult = $_SESSION['cult'];
688 $cult = $_USER->getCult();
691 if($_REQUEST['civ']) {
692 $civ = $_REQUEST['civ'];
693 $_SESSION['civ'] = $civ;
695 elseif($_SESSION['civ']) {
696 $civ = $_SESSION['civ'];
699 $civ = $_USER->getCiv();
702 $cat = new CSRCategory($open,$_USER->getRace(),$cult,$civ);
704 if($_REQUEST['grant'] != "") {
705 $cat->grantNode($_REQUEST['grant'],$_USER->getID());
708 if($_REQUEST['deny'] != "") {
709 $cat->denyNode($_REQUEST['deny'],$_USER->getID());
714 $c .= "<center><table>
716 <td colspan='2' align='left'>".csr_render_yubopoints($user['id'])."</td>
719 <td valign='top'><div style='width:230px;font-weight:bold;font-size:14px;'>";
722 $c .= csr_render_menu($menu);
725 <td width='645px' valign='top'>";
729 $c .= csr_render_category($cat);
732 $cat = new AchSummary($menu,3);
733 $c .= ach_render_summary_header();
737 $c .= ach_render_summary_footer($cat);
751 #$c = var_export($_USER).$c;
753 echo ryzom_app_render("achievements admin", $c, $_ADMIN->isIG());