Keine / Alle';
// Sucharray erstellen
while($s = db_fetch_assoc($res)) {
$sections .= '';
}
$link = 'su_randomcomment.php';
addnav('',$link);
addnav('Aktionen');
addnav('Neu','su_randomcomment.php?op=edit');
$out = '`c
`n';
$out .= '
| `bID`b |
`bSection`b |
`bText`b |
`bWahrscheinl.`b |
`bAbstand`b |
`bWetter`b |
`bZeit`b |
`bRL-Date`b |
`bAktionen`b |
';
$sql = 'SELECT * FROM random_commentary '.($section != '' ? 'WHERE section="'.$section.'"' : '').' ORDER BY id ASC';
$res = db_query($sql);
while($c = db_fetch_assoc($res)) {
$c['section'] = ($c['section'] == '' ? 'Alle' : $c['section']);
$c['weather'] = ($c['weather'] == 0 ? 'Keines' : Weather::$weather[$c['weather']]['name']);
$style = ($style == 'trlight' ? 'trdark' : 'trlight');
$editlink = 'su_randomcomment.php?op=edit&id='.$c['id'];
addnav('',$editlink);
$dellink = 'su_randomcomment.php?op=del&id='.$c['id'];
addnav('',$dellink);
$out .= '
| '.$c['id'].' |
'.$c['section'].'`& |
'.$c['comment'].'`& |
'.$c['chance'].' |
'.$c['gap'].' |
'.$c['weather'].'`& |
Monat '.$c['month_min'].' - '.$c['month_max'].', Stunde '.$c['hour_min'].' - '.$c['hour_max'].'`& |
'.$c['rldate'].'`& |
[ Edit ]
[ `$Del`& ]
|
';
}
$out .= '
`c';
output($out,true);
break;
case 'edit': // Editformular für einen Zufallskommentar
$weather_enum = 'enum,0,Keines';
foreach(Weather::$weather as $id=>$w) {
$weather_enum.=','.$id.','.substr($w['name'],0,15).'..';
}
$section_enum = 'enum, ,Alle,all_private,Alle privat,all_public,Alle öffentlich,all_inside,Alle drinnen,all_outside,Alle draußen';
foreach($rcomment_sections as $s=>$v) {
$section_enum.=','.$s.','.$s;
}
$form = array(
'id' => 'ID,viewonly',
'comment' => 'Kommentar',
'section' => 'Chatsektion (interner Name),'.$section_enum,
'gap' => 'Mindestabstand zw. 2 identischen',
'chance' => 'Wahrscheinlichkeit (0-250),int',
'month_min' => 'Monat min. (1-12) für Erscheinen,int',
'month_max' => 'Monat max. (1-12) für Erscheinen,int',
'hour_min' => 'Stunde min. (0-23) für Erscheinen,int',
'hour_max' => 'Stunde max. (0-23) für Erscheinen,int',
'rldate' => 'Realdate für Erscheinen (Y-m-d)',
'weather' => 'Bestimmtem Wetter zuweisen,'.$weather_enum
);
$data = array('id'=>'NEU','comment'=>'/msg', 'section'=>'village', 'gap'=>1, 'chance'=>1, 'weather'=>0, 'month_min'=>1, 'month_max'=>12, 'hour_min'=>0, 'hour_max'=>23, 'rldate'=>'0000-00-00');
$id = (int)$_GET['id'];
if($id) {
$sql = 'SELECT * FROM random_commentary WHERE id='.$id;
$res = db_query($sql);
$data = db_fetch_assoc($res);
}
addnav('Aktionen');
addnav('Abbruch','su_randomcomment.php'.($id ? '?section='.$data['section'] : '') );
$link = 'su_randomcomment.php?op=save';
addnav('',$link);
output('',true);
break;
case 'del': // Löschen
$id = (int)$_GET['id'];
$sql = 'DELETE FROM random_commentary WHERE id='.$id;
db_query($sql);
if(!db_affected_rows()) {
$session['message'] = '`$Fehler bei Löschen!';
redirect('su_randomcomment.php');
}
else {
$session['message'] = '`@Erfolgreich gelöscht!';
redirect('su_randomcomment.php');
}
break;
case 'save': // Abspeichern
$id = (int)$_POST['id'];
$comment = addslashes(stripslashes($_POST['comment']));
$section = addslashes(stripslashes($_POST['section']));
$chance = (int)$_POST['chance'];
$gap = (int)$_POST['gap'];
$month_min = (int)$_POST['month_min'];
$month_max = (int)$_POST['month_max'];
$hour_max = (int)$_POST['hour_max'];
$hour_min = (int)$_POST['hour_min'];
$rldate = $_POST['rldate'];
$_weather = (int)$_POST['weather'];
$sql = ($id ? 'UPDATE ' : 'INSERT INTO ');
$sql .= ' random_commentary SET
comment="'.$comment.'",
section="'.$section.'",
chance="'.$chance.'",
gap="'.$gap.'",
month_min="'.$month_min.'",
month_max="'.$month_max.'",
hour_max="'.$hour_max.'",
hour_min="'.$hour_min.'",
rldate="'.$rldate.'",
weather="'.$_weather.'"';
$sql .= ($id ? ' WHERE id='.$id : '');
db_query($sql);
$session['message'] = '`@Erfolgreich gespeichert!';
if(!$id)
{
$id = db_insert_id();
}
redirect('su_randomcomment.php?op=edit&id='.$id);
break;
}
addnav('Startseite','su_randomcomment.php' );
page_footer();
?>