=2) addnav("Item Editor","itemeditor.php");
// into menu of superuser.php
//
require_once "common.php";
page_header("Item Editor");
addnav("G?Zurück zur Grotte","superuser.php");
addnav("W?Zurück zum Weltlichen","village.php");
if ($_GET['op']=="del"){
$sql = "DELETE FROM items WHERE id=$_GET[id]";
db_query($sql);
$_GET['op']="";
$_GET['show']=$_GET['show']; // huh? weshalb hab ich das geschrieben?
}
if ($_GET['op']=="add"){
output("Item erzeugen:`n");
addnav("Item Editor","itemeditor.php");
if ($_GET[show]) addnav("$_GET[show]","itemeditor.php?show=".urlencode($_GET[show])."");
itemform(array("class"=>$_GET[show]));
}elseif ($_GET['op']=="edit"){
addnav("Item Editor","itemeditor.php");
if ($_GET[show]) addnav("$_GET[show]","itemeditor.php?show=".urlencode($_GET[show])."");
$sql = "SELECT * FROM items WHERE id='{$_GET['id']}'";
$result = db_query($sql);
if (db_num_rows($result)<=0){
output("`iItem nicht vorhanden.`i");
}else{
output("Item Editor:`n");
$row = db_fetch_assoc($result);
$row['buff']=unserialize($row['buff']);
itemform($row);
}
}elseif ($_GET['op']=="save"){
$buff = array();
reset($_POST['item']['buff']);
if (isset($_POST['item']['buff']['activate'])) $_POST['item']['buff']['activate']=join(",",$_POST['item']['buff']['activate']);
while (list($key,$val)=each($_POST['item']['buff'])){
if ($val>""){
$buff[$key]=stripslashes($val);
}
}
$_POST['item']['buff']=$buff;
reset($_POST['item']);
$keys='';
$vals='';
$sql='';
$i=0;
while (list($key,$val)=each($_POST['item'])){
if (is_array($val)) $val = addslashes(serialize($val));
if ($_GET['id']>""){
$sql.=($i>0?",":"")."$key='$val'";
}else{
$keys.=($i>0?",":"")."$key";
$vals.=($i>0?",":"")."'$val'";
}
$i++;
}
if ($_GET['id']>""){
$sql="UPDATE items SET $sql WHERE id='{$_GET['id']}'";
}else{
$sql="INSERT INTO items ($keys) VALUES ($vals)";
}
db_query($sql);
if (db_affected_rows()>0){
output("Item gespeichert!");
}else{
output("Item nicht gespeichert: $sql");
}
addnav("Item Editor","itemeditor.php");
if ($_GET[show]) addnav("$_GET[show]","itemeditor.php?show=".urlencode($_GET[show])."");
}else{
if($_GET['show']){
$ppp=50; // Player Per Page to display
if (!$_GET[limit]){
$page=0;
}else{
$page=(int)$_GET[limit];
addnav("Vorherige Seite","itemeditor.php?show=".urlencode($_GET[show])."&limit=".($page-1)."");
}
$limit="".($page*$ppp).",".($ppp+1);
$sql = "SELECT items.*,accounts.name AS ownername FROM items
LEFT JOIN accounts ON accounts.acctid=items.owner WHERE class='$_GET[show]' ORDER BY id LIMIT $limit";
output("
",true);
output("| Ops | Name | Besitzer | Beschreibung |
",true);
$result = db_query($sql);
if (db_num_rows($result)>$ppp) addnav("Nächste Seite","itemeditor.php?show=".urlencode($_GET[show])."&limit=".($page+1)."");
$cat = "";
for ($i=0;$i",true);
output("[ Edit |",true);
addnav("","itemeditor.php?op=edit&id=$row[id]&show=".urlencode($row['class'])."");
output(" Löschen ] | ",true);
addnav("","itemeditor.php?op=del&id=$row[id]&show=".urlencode($row['class'])."");
output("$row[name] | ",true);
output("$row[ownername] | ",true);
output("$row[description] | ",true);
output("",true);
}
output("
",true);
addnav("Item Editor","itemeditor.php");
addnav("Item hinzufügen","itemeditor.php?op=add&show=".urlencode($_GET[show])."");
}else{
$sql = "SELECT class FROM items ORDER BY class";
output("Verfügbare \"classes\":`n`n",true);
output("| Name |
",true);
$result = db_query($sql);
$cat = "";
for ($i=0;$i$row[class] | ",true);
$cat = $row['class'];
addnav("","itemeditor.php?show=".urlencode($row['class'])."");
output("",true);
}
}
output("
`n`nUm eine class zu löschen, müssen alle Items dieser class gelöscht werden.`nUm eine neue class zu erstellen, einfach ein Item erzeugen.",true);
addnav("Item hinzufügen","itemeditor.php?op=add");
}
}
function itemform($item){
global $output;
output("";
}
page_footer();
?>