<?php
include("connect.php");
include("login_cookies.php");

$tid = date("H:i:s d/m - Y");

while($admin = mysql_fetch_array($db_admin)) {

if ($_COOKIE["pass"] == $admin["kode"]) {

 if ($admin["admin"] == "1") {

	if ($admin["exist"] == "1") {
/////////////////////////

if ($_GET["choose"] == "new") {

 if ($_POST[priority] == "" || $_POST[name] == "" || $_POST[href] == "" || $_POST[submit] == "") {
print "Én eller flere felter blev ikke udfyldt!";
 } else {
mysql_query("INSERT INTO `pytox_menu` (`prioritet`, `navn`, `href`) VALUES ('{$_POST[priority]}', '{$_POST[name]}', '{$_POST[href]}')") or die(mysql_error());
print "Menupunktet blev oprettet med succes!";
 }

print "<br /><a href=\"?site=Editmenu\">Tilbage til menu administrationen</a>";

} else if ($_GET["choose"] == "delete" && isset($_GET[menuid])) {

mysql_query("DELETE FROM `pytox_menu` WHERE `id` LIKE '{$_GET[menuid]}' LIMIT 1") or die(mysql_error());

print "Menupunktet blev slettet med succes!<br /><a href=\"?site=Editmenu\">Tilbage til menu administrationen</a>";

} else if ($_GET["choose"] == "edit" && isset($_GET[menuid])) {

 if ($_POST[priorityr] == "" || $_POST[namer] == "" || $_POST[hrefr] == "" || $_POST[submitr] == "") {
print "Én eller flere felter blev ikke udfyldt!";
 } else {

mysql_query("UPDATE `pytox_menu` SET `prioritet`='$_POST[priorityr]', `navn`='$_POST[namer]', `href`='$_POST[hrefr]' WHERE `id` LIKE '$_GET[menuid]' LIMIT 1") or die(mysql_error());

print "Menupunktet blev rettet med succes!<br /><a href=\"?site=Editmenu\">Tilbage til menu administrationen</a>";

 }

} else if ($_GET["choose"] == "show") {
?>
<table class="blackborder" style="width:500px;" cellpadding="2" cellspacing="0">
 <tr>
  <td style="border-bottom:1px solid #000;width:100px;border-right:1px solid #000;" class="submit">
Prioritet/Plads
  </td>
  <td style="border-bottom:1px solid #000;width:150px;border-right:1px solid #000;" class="submit">
Navn
  </td>
  <td style="border-bottom:1px solid #000;width:150px;border-right:1px solid #000;" class="submit">
Linker til
  </td>
  <td style="border-bottom:1px solid #000;width:100px;" class="submit">
Valg
  </td>
 </tr>
<?php
$shownowmenu = mysql_query("SELECT * FROM `pytox_menu` ORDER BY `prioritet` DESC");

while ($punkt = mysql_fetch_array($shownowmenu)) {

if ($i == 0) {
$i = 1;
$bgcolor = "#FFF";
} else if ($i == 1) {
$i = 0;
$bgcolor = "#EEE";
} else {
$i = 1;
$bgcolor = "#FFF";
}

?>
 <tr>
  <td style="border-bottom:1px dotted #000;width:100px;border-right:1px dotted #000;background-color:<?=$bgcolor?>;">
<?=$punkt[prioritet]?>
  </td>
  <td style="border-bottom:1px dotted #000;width:150px;border-right:1px dotted #000;background-color:<?=$bgcolor?>;">
"<?=$punkt[navn]?>"
  </td>
  <td style="border-bottom:1px dotted #000;width:150px;border-right:1px dotted #000;background-color:<?=$bgcolor?>;">
<a href="?site=<?=$punkt[href]?>">?site=<?=$punkt[href]?></a>
  </td>
  <td style="border-bottom:1px dotted #000;width:100px;background-color:<?=$bgcolor?>;">
<a href="?site=Editmenu&amp;choose=show&amp;subchoose=edit&amp;menuid=<?=$punkt[id]?>">Ret</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="?site=Editmenu&amp;choose=delete&amp;menuid=<?=$punkt[id]?>">Slet</a>
  </td>
 </tr>
<?php

}
?>
</table>
<br />
<br />
<?php
if ($_GET["subchoose"] == "edit" && isset($_GET["menuid"])) {

$editthis = mysql_query("SELECT * FROM `pytox_menu` WHERE `id` LIKE '{$_GET[menuid]}' LIMIT 1");

while ($edit = mysql_fetch_array($editthis)) {

?>
<form action="?site=Editmenu&amp;choose=edit&amp;menuid=<?=$edit[id]?>" method="post">
<strong>Ret</strong>
<br />
<table class="blackborder" style="width:550px;" cellpadding="2" cellspacing="0">
 <tr>
  <td style="border-bottom:1px solid #000;width:100px;border-right:1px solid #000;" class="submit">
Prioritet/Plads
  </td>
  <td style="border-bottom:1px solid #000;width:150px;border-right:1px solid #000;" class="submit">
Navn
  </td>
  <td style="border-bottom:1px solid #000;width:200px;border-right:1px solid #000;" class="submit">
Linker til
  </td>
  <td style="border-bottom:1px solid #000;width:100px;" class="submit">
Valg
  </td>
 </tr>
 <tr>
  <td style="width:100px;border-right:1px dotted #000;">
<input type="text" name="priorityr" value="<?=$edit[prioritet]?>" />
  </td>
  <td style="width:150px;border-right:1px dotted #000;">
<input type="text" name="namer" value="<?=$edit[navn]?>" />
  </td>
  <td style="width:200px;border-right:1px solid #000;">
?site=<input type="text" name="hrefr" value="<?=$edit[href]?>" />
  </td>
  <td style="width:100px;">
<input type="submit" value="Ret" name="submitr" />
  </td>
 </tr>
</table>
<?php
}
}
?>
<br />
<br />
<form action="?site=Editmenu&amp;choose=new" method="post">
<strong>Lav ny</strong>
<br />
<table class="blackborder" style="width:550px;" cellpadding="2" cellspacing="0">
 <tr>
  <td style="border-bottom:1px solid #000;width:100px;border-right:1px solid #000;" class="submit">
Prioritet/Plads
  </td>
  <td style="border-bottom:1px solid #000;width:150px;border-right:1px solid #000;" class="submit">
Navn
  </td>
  <td style="border-bottom:1px solid #000;width:200px;border-right:1px solid #000;" class="submit">
Linker til
  </td>
  <td style="border-bottom:1px solid #000;width:100px;" class="submit">
Valg
  </td>
 </tr>
 <tr>
  <td style="width:100px;border-right:1px dotted #000;">
<input type="text" name="priority" />
  </td>
  <td style="width:150px;border-right:1px dotted #000;">
<input type="text" name="name" />
  </td>
  <td style="width:200px;border-right:1px solid #000;">
?site=<input type="text" name="href" />
  </td>
  <td style="width:100px;">
<input type="submit" value="Opret" name="submit" />
  </td>
 </tr>
</table>
</form>
<?php

} else {

header("Location: index.php?site=Editmenu&choose=show");
?>
<a href="?site=Editmenu&amp;choose=show">Gå til administrationen</a>
<?php
}

/////////////////////////
	} else {// $admin[exist]
	header("Location: index.php?message=failure&errorid=60065");
	}

 }

}

}
?>