1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240:
|
<? /* TABELLENSTRUKTUR CREATE TABLE `furniture` ( `furnid` int(11) NOT NULL auto_increment, `furnname` varchar(25) collate latin1_german2_ci NOT NULL default '', `class` varchar(10) collate latin1_german2_ci NOT NULL default '', `description` mediumtext collate latin1_german2_ci NOT NULL, `furnpic` text collate latin1_german2_ci NOT NULL, `costgold` int(11) NOT NULL default '0', `costgems` int(11) NOT NULL default '0', `contributor` text collate latin1_german2_ci NOT NULL, PRIMARY KEY (`furnid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci AUTO_INCREMENT=174 ;
*/
require_once 'common.php';
page_header('Der Möbeleditor');
switch($_GET['op']) { case '': // Möbel aus der Datenbank holen $sql = 'SELECT * FROM `furniture` ORDER BY `class` ASC, `furnid` ASC'; $result = db_query($sql); output('`c<h3>`&Bereits vorhandene Möbel`0</h3>`c',true); $n = db_num_rows($result); if($n){ // Möbel in Tabelle anzeigen $class = ''; for($i=0; $i<$n; $i++) { $row = db_fetch_assoc($result); if($class != $row['class']) output('`n`c`b`&'.$row['class'].'`b`c`n'); output('<table border="0"> <tr> <td width="75" valign="top">`&'.$row['furnid'].' `n `n <a href="furnedit.php?op=edit&furnid='.$row['furnid'].'">Edit</a>`n <a href="furnedit.php?op=del&furnid='.$row['furnid'].'">Del</a></td> <td valign="top" width="200">`c`b`^'.$row['furnname'].'`b`c `n `b`&Preis`b (`^Gold `&/ `%Gems`&): `^'.$row['costgold'].' `&/ `%'.$row['costgems'].'`0 `n `b`&Ersteller:`b '.$row['contributor'].'</td> <td width="75"><img src="./images/housepics/'.$row['furnpic'].'" alt="furn#'.$row['furnid'].'" width="50" height="50"></td> <td valign="top">`n`n'.$row['description'].'</td> </tr> </table>`n',true); addnav('','furnedit.php?op=edit&furnid='.$row['furnid']); addnav('','furnedit.php?op=del&furnid='.$row['furnid']); $class = $row['class']; } } else { output('`c`&`bKeine Möbel vorhanden.`b`&`c'); } // Navigation addnav('Aktionen'); addnav('Aktualisieren', 'furnedit.php'); //addnav('Beispiel Showform', 'beispiel.php'); addnav('Möbel'); addnav('Neues Möbelstück einfügen', 'furnedit.php?op=new'); addnav('Zurück'); addnav('Zurück zum Weltlichen', 'village.php'); addnav('Zurück zur Grotte', 'superuser.php'); break; case 'del': switch($session['count']) { case 0: // Sicherheitsabfrage output('`b`&Willst du das Möbelstück wirklich löschen?'); addnav('Ja!', 'furnedit.php?op=del&furnid='.$_GET['furnid']); addnav('Nein...', 'furnedit.php'); $session['count']++; break; case 1: // Bestätigt, also löschen.... $sql = 'DELETE FROM `furniture` WHERE `furnid` = '.$_GET['furnid']; db_query($sql); output('`b`&Du hast das Möbelstück gelöscht.'); unset($session['count']); break; } addnav('Zurück'); addnav('Zurück zum Editor', 'furnedit.php'); addnav('Zurück zum Weltlichen', 'village.php'); addnav('Zurück zur Grotte', 'superuser.php'); break; case 'new': case 'edit': if(!$_POST) { // Falls editieren genutzt wird, werden die Daten bezüglich des zu editierenden Möbelstücks aus der Datenbank geholt. if($_GET['op'] == 'edit') { $sql = 'SELECT * FROM `furniture` WHERE `furnid` = '.$_GET['furnid']; $result = db_query($sql); $row = db_fetch_assoc($result); } // Einbinden der showform Klasse von Eliwood //include './lib/showform.class.php'; nicht länger nötig, da includierung nun in common.php // Erzeugen des $form Arrays $form = array( 'furnname' => array( 'Name des Möbelstücks', 'text' ), 'class' => array( 'Klasse des Möbelstücks', 'text' ), 'description' => array( 'Beschreibung des Möbelstücks', 'textarea', 50, 5 ), 'furnpic' => array( 'Link für das Bild des Möbelstücks', 'text' ), 'costgold' => array( 'Preis (Gold) (leer lassen, wenn 0)', 'int' ), 'costgems' => array( 'Preis (Gems) (leer lassen, wenn 0)', 'int' ), 'contributor' => array( 'Ersteller des Möbelstücks (leer lassen wenn du es selbst bist)', 'text' ) ); // Ausgabe des $form Arrays mit der Showform Klasse if($_GET['op'] == 'edit') { $Showform = new Showform('Möbelstück #'.$row['furnid'].' bearbeiten', $form, $row); $Showform->enableSave(); rawoutput('<form action="furnedit.php?op=edit&furnid='.$row['furnid'].'" method="POST">'); addnav('','furnedit.php?op=edit&furnid='.$row['furnid']); } elseif($_GET['op'] == 'new') { $Showform = new Showform('Neues Möbelstück', $form); $Showform->enableSave(); rawoutput('<form action="furnedit.php?op=new" method="POST">'); addnav('','furnedit.php?op=new'); } rawoutput($Showform->getOut()); rawoutput('</form>'); } else { if(empty($_POST['furnname']) || empty($_POST['class']) || empty($_POST['description']) || empty($_POST['furnpic'])) { $words = array( 'furnname' => 'Name des Möbelstücks', 'class' => 'Klasse des Möbelstücks', 'description' => 'Beschreibung des Möbelstücks', 'furnpic' => 'Link für das Bild des Möbelstücks', ); foreach($_POST as $key => $value) { if($key == 'contributor') continue; if($key == 'costgold') continue; if($key == 'costgems') continue; if($value=='') output('`b`&» `$Fülle `i`^'.$words[$key].'`i`$ aus!`b`0`n`n'); } addnav('Nochmal probieren', 'furnedit.php?op='.($_GET['op']=='edit'?'edit&furnid='.$_GET['furnid']:'new')); } else { if($_POST['contributor'] == '') $_POST['contributor'] = $session['user']['login'] ; if($_POST['costgold'] == '') $_POST['costgold'] = 0; if($_POST['costgems'] == '') $_POST['costgems'] = 0; if($_GET['op'] == 'new') { $sql = 'INSERT INTO `furniture` ( `furnname`, `class`, `description`, `furnpic`, `costgold`, `costgems`, `contributor` ) VALUES ( "'.$_POST['furnname'].'", "'.$_POST['class'].'", "'.$_POST['description'].'", "'.$_POST['furnpic'].'", '.$_POST['costgold'].', '.$_POST['costgems'].', "'.$_POST['contributor'].'" )'; db_query($sql); output('`n`n`b`&Du hast erfolgreich das Möbelstück `i`^'.$_POST['furnname'].'`i `&eingefügt!'); addnav('Aktionen'); addnav('Neuer Gegenstand', 'furnedit.php?op=new'); } elseif($_GET['op'] == 'edit') { $sql = 'UPDATE `furniture` SET `furnname` = "'.$_POST['furnname'].'", `class` = "'.$_POST['class'].'", `description` = "'.$_POST['description'].'", `furnpic` = "'.$_POST['furnpic'].'", `costgold` = '.$_POST['costgold'].', `costgems` = '.$_POST['costgems'].', `contributor` = "'.$_POST['contributor'].'" WHERE `furnid` = '.$_GET['furnid']; db_query($sql); output('`n`n`b`&Du hast erfolgreich das Möbelstück `i`^'.$_POST['furnname'].'`i `&editiert!'); } unset($_POST); } } // Navigation addnav('Zurück'); addnav('Zurück zum Editor', 'furnedit.php'); addnav('Zurück zum Weltlichen', 'village.php'); addnav('Zurück zur Grotte', 'superuser.php'); break; } $session['user']['standort']='Admin-Grotte'; page_footer(); ?>
|