require_once "common.php"; isnewday(2); //select distinct creaturelevel,max(creaturehealth) as creaturehealth,max(creatureattack) as creatureattack,max(creaturedefense) as creaturedefense,max(creatureexp) as creatureexp,max(creaturegold) as creaturegold from creatures where creaturelevel<17 group by creaturelevel; $creaturestattable=" +---------------+----------------+----------------+-----------------+-------------+--------------+ | creaturelevel | creaturehealth | creatureattack | creaturedefense | creatureexp | creaturegold | +---------------+----------------+----------------+-----------------+-------------+--------------+ | 1 | 10 | 1 | 1 | 14 | 36 | | 2 | 21 | 3 | 3 | 24 | 97 | | 3 | 32 | 5 | 4 | 34 | 148 | | 4 | 43 | 7 | 6 | 45 | 162 | | 5 | 53 | 9 | 7 | 55 | 198 | | 6 | 64 | 11 | 8 | 66 | 234 | | 7 | 74 | 13 | 10 | 77 | 268 | | 8 | 84 | 15 | 11 | 89 | 302 | | 9 | 94 | 17 | 13 | 101 | 336 | | 10 | 105 | 19 | 14 | 114 | 369 | | 11 | 115 | 21 | 15 | 127 | 402 | | 12 | 125 | 23 | 17 | 141 | 435 | | 13 | 135 | 25 | 18 | 156 | 467 | | 14 | 145 | 27 | 20 | 172 | 499 | | 15 | 155 | 29 | 21 | 189 | 531 | | 16 | 166 | 31 | 22 | 207 | 563 | +---------------+----------------+----------------+-----------------+-------------+--------------+ "; $creaturestats=Array(); $creaturestattable=split("\n",$creaturestattable); $x=0; while (list($key,$val)=each($creaturestattable)){ if (strpos($val,"|")!==false){ //echo("$val`n"); $x++; $a = split("\\|",$val); if ($x==1){ $stats=array(); while (list($key1,$val1)=each($a)){ if (trim($val1)>"") { $stats[$key1]=trim($val1); //output($val1." is col $key1`n"); } } }else{ reset($stats); while (list($key1,$val1)=each($stats)){ $creaturestats[(int)$a[1]][$val1]=trim($a[$key1]); //output ("[".(int)$a[1]."][$val1]=".trim($a[$key1])."`n"); } } } } page_header("Creature Editor"); if ($session['user']['superuser'] >= 2){ addnav("G?Zurück zur Grotte","superuser.php"); addnav("W?Zurück zum Weltlichen","village.php"); if ($_POST[save]<>""){ if (!isset($_POST['location'])) $_POST['location']=0; if ($_POST[id]!=""){ $sql="UPDATE creatures SET "; //unset($_POST[save]); while (list($key,$val)=each($_POST)){ if (substr($key,0,8)=="creature") $sql.="$key = \"$val\", "; } reset($creaturestats[(int)$_POST[creaturelevel]]); while (list($key,$val)=each($creaturestats[$_POST[creaturelevel]])){ if ( $key!="creaturelevel" && substr($key,0,8)=="creature"){ $sql.="$key = \"".addslashes($val)."\", "; } } $sql.=" location=\"".(int)($_POST['location'])."\", "; //$sql = substr($sql,0,strlen($sql)-2); $sql.= " createdby=\"".addslashes($session['user']['login'])."\" "; $sql.= " WHERE creatureid='$_POST[id]'"; //output($sql); db_query($sql) or output("`\$".db_error(LINK)."`0`n`#$sql`0`n"); output(db_affected_rows()." ".(db_affected_rows()==1?"Eintrag":"Einträge")." geändert."); }else{ $cols = array(); $vals = array(); while (list($key,$val)=each($_POST)){ if (substr($key,0,8)=="creature" || $key=="location") { array_push($cols,$key); array_push($vals,$val); //$sql.="$key = \"$val\", "; } } reset($creaturestats[(int)$_POST[creaturelevel]]); while (list($key,$val)=each($creaturestats[$_POST[creaturelevel]])){ if ($key!="creaturelevel"){ //$sql.="$key = \"".addslashes($val)."\", "; array_push($cols,$key); array_push($vals,$val); } } $sql="INSERT INTO creatures (".join(",",$cols).",createdby) VALUES (\"".join("\",\"",$vals)."\",\"".addslashes($session['user']['login'])."\")"; //echo $sql; db_query($sql); } } if ($_GET[op]=="del"){ $sql = "DELETE FROM creatures WHERE creatureid = \"$_GET[id]\""; db_query($sql); if (db_affected_rows()>0){ output("Kreatur gelöscht`n`n"); }else{ output("Kreatur nicht gelöscht: ".db_error(LINK)); } $_GET[op]=""; } if ($_GET[op]==""){ $sql = "SELECT * FROM creatures ORDER BY creaturelevel,creaturename"; $result = db_query($sql) or die(db_error(LINK)); addnav("Eine Kreatur hinzufügen","creatures.php?op=add"); output("
| Ops | Kreaturname | Level | Waffe | Nachricht beim Tod | Autor | [Edit|Del] | ",true); }else{ output(" |
| [Edit|". "Del] | ",true); addnav("","creatures.php?op=edit&id=$row[creatureid]"); addnav("","creatures.php?op=del&id=$row[creatureid]"); } output($row[creaturename]); output(" | ",true); output($row[creaturelevel]); output(" | ",true); output($row[creatureweapon]); output(" | ",true); output($row[creaturelose]); output(" | ",true); output($row[createdby]); output(" |