LoGD Standardrelease steht hier zum Download zur Verfügung!
<?php
/*
Kindereditor by Kamui 26.10.2006
Idee by -Dom
*/
require_once "common.php";
isnewday(1);
page_header("Kindereditor");
addnav("G?Zurück zur Grotte","superuser.php");
//addnav("Kinder dieser Welt","hof.php?op=kinder");
addnav("Kind neu eintragen","kindereditor.php?op=add");
addnav("Refresh","kindereditor.php");
$array=array(
"Kind,title",
"id"=>"ID,hidden",
"name"=>"Name",
"mama"=>"Mutter des Kindes(accountid)",
"papa"=>"Vater des Kindes(accountid)",
"geschlecht"=>"Geschlecht des Kinds,enum,0,Männlich ,1,Weiblich",
"gebdat"=>"Geburtsdatum",
"unehelich"=>"Unehelich?,bool",
);
$kindadd = array(
"Kind,title",
"id"=>"ID,hidden",
"name"=>"Name des Kindes",
//"kind"=>"Kind der Mutter und des Vaters(accountid, wahlweise)",
"mama"=>"Mutter des Kindes(accountid)",
"papa"=>"Vater des Kindes(accountid)",
"geschlecht"=>"Geschlecht des Kinds,enum,0,Männlich ,1,Weiblich",
"gebdat"=>"Geburtsdatum",
"unehelich"=>"Unehelich?,bool",
);
if ($_GET['op']==""){
$sql = "SELECT * FROM kinder";
$result = db_query($sql);
output("<table><tr class=trhead><td>`&Name</td><td> </td><td>`&Mutter</td><td>`&Vater</td><td>`&Geburtsdatum</td>", true);
if($session[user][superuser]>=2) output("<td>`&Edit</td>",true);
if($session[user][superuser]>=2) output("<td>`&Löschen</td>",true);
while ($row = db_fetch_assoc($result)) {
output("<tr class=".($i%2?"trlight":"trdark")."><td>".$row[name],true);
if($row['geschlecht'] == 1)
output("<td>`c<img src=images/female.gif>`c</td>",true);
else
output("<td>`c<img src=images/male.gif>`c</td>",true);
output("</td>", true);
$sqlm = "SELECT name FROM accounts WHERE acctid = " . $row[mama];
$resultm = db_query($sqlm) or die(db_error(LINK));
if($rowm = db_fetch_assoc($resultm))
output(" <td> ".$rowm[name]." </td> ",true);
else
output(" <td> `c---`c </td> ",true);
$sqlp = "SELECT name FROM accounts WHERE acctid = " . $row[papa];
$resultp = db_query($sqlp) or die(db_error(LINK));
if($rowp = db_fetch_assoc($resultp))
output(" <td> ".$rowp[name]." </td> ",true);
else
output("<td>`c---`c</td>",true);
output("</td>", true);
output(" <td> ".$row[gebdat]." </td>",true);
if ($session[user][superuser]>=3) output("<td><a href='kindereditor.php?op=edit&id=$row[id]'>Edit",true);
if ($session[user][superuser]>=3) addnav("","kindereditor.php?op=edit&id=$row[id]");
if ($session[user][superuser]>=3) output("<td><a href='kindereditor.php?op=dele&id=$row[id]'>Löschen",true);
if ($session[user][superuser]>=3) addnav("","kindereditor.php?op=dele&id=$row[id]");
}
output("</tr></table>",true);
}
if($_GET[op]=="edit"){
$sql = "SELECT * FROM kinder WHERE id='$_GET[id]'";
$result = db_query($sql);
$row = db_fetch_assoc($result);
output("<form action='kindereditor.php?op=save' method='POST'>",true);
addnav("","kindereditor.php?op=save");
showform($array,$row);
output("</form>",true);
}else if($_GET[op]=="dele"){
$sql = "DELETE FROM kinder WHERE id='$_GET[id]'";
db_query($sql);
redirect("kindereditor.php");
}else if($_GET[op]=="save"){
if ((int)$_POST[id]>0){
$sql = "UPDATE kinder SET name=\"$_POST[name]\",mama=\"$_POST[mama]\",papa=\"$_POST[papa]\",geschlecht=\"$_POST[geschlecht]\",info=\"$_POST[info]\",gebdat=\"$_POST[gebdat]\",unehelich=\"$_POST[unehelich]\" WHERE id='$_POST[id]'";
}
db_query($sql);
redirect("kindereditor.php");
}
if($_GET['op']=="add"){
output("<form action='kindereditor.php?op=save2' method='POST'>",true);
addnav("","kindereditor.php?op=save2");
output("<input type='submit' class='button' value='Speichern'>",true);
showform($kindadd,"");
output("</form>",true);
addnav("Zurück","kindereditor.php");
}
if($_GET['op']=="save"){
// kind=\"$_POST[kind]\",
$sql = "UPDATE kinder SET name=\"$_POST[name]\", mama=\"$_POST[mama]\", papa=\"$_POST[papa]\" WHERE id=\"$_GET[id]\"";
db_query($sql) or die(db_error(LINK));
output("Die Änderungen wurden übernommen.");
addnav("Zurück","kindereditor.php");
}
if($_GET['op']=="save2"){
//kind, '$_POST[kind]',
$sql = "INSERT INTO kinder (id,name,mama,papa) VALUES ('$_POST[id]','$_POST[name]','$_POST[mama]','$_POST[papa]')";
db_query($sql) or die(db_error(LINK));
output("Die Änderungen wurden übernommen.");
addnav("Zurück","kindereditor.php");
}
page_footer();
?>