<?

require_once("include/bittorrent.php");

hit_start();

if (!mkglobal("id"))
    die();

$id = 0 + $id;
if (!$id)
    die();

dbconn();

hit_count();

loggedinorreturn();

$res = mysql_query("SELECT * FROM stream WHERE id = $id");
$row = mysql_fetch_array($res);
if (!$row)
    die();

stdhead("Sendung von " . $row["streamer"] . " bearbeiten");

if (!isset($CURUSER) || ($CURUSER["id"] != $row["addedby"] && get_user_class() < UC_MODERATOR)) {
?>
<table cellpadding="4" cellspacing="1" border="0" style="width:650px" class="tableinborder">
 <tr class="tabletitle" width="100%">
  <td colspan="10" width="100%"><span class="normalfont"><center><b> Du darfst diese Sendung nicht bearbeiten </b></center></span></td> 
 </tr><tr><td width="100%" class="tablea">Du bist nicht
 der rechtm&auml;&szlig;ige Bearbeiter, oder Du bist nicht korrekt
 <a href="login.php?returnto=<?=urlencode($_SERVER["REQUEST_URI"])?>&amp;nowarn=1">eingeloggt</a>.
</td></tr></table>
<?
}
else {

    print("<form name=editsendeplan method=post action=takeeditsendeplan.php enctype=multipart/form-data>\n");
    print("<input type=\"hidden\" name=\"id\" value=\"$id\">\n");
    if (isset($_GET["returnto"]))
        print("<input type=\"hidden\" name=\"returnto\" value=\"" . htmlspecialchars($_GET["returnto"]) . "\" />\n");
?>
<br>
<table cellpadding="4" cellspacing="1" border="0" style="width:650px" class="tableinborder">
 <tr class="tabletitle" width="100%">
  <td colspan="5" width="100%"><span class="normalfont"><center><b>Sendung von <?=$row["streamer"]?> bearbeiten</b></center></span></td> 
 </tr>
<?    

$s .= "</select>\n";

    $s = "<select name=\"type\">\n";

    $cats = tagelist();
    foreach ($cats as $subrow) {
        $s .= "<option value=\"" . $subrow["id"] . "\"";
        if ($subrow["id"] == $row["tage"])
            $s .= " selected=\"selected\"";
        $s .= ">" . htmlspecialchars($subrow["name"]) . "</option>\n";
    }

    $s .= "</select>\n";

$s1 .= "</select>\n";

    $s1 = "<select name=\"type1\">\n";

    $cats1 = dayslist();
    foreach ($cats1 as $subrow1) {
        $s1 .= "<option value=\"" . $subrow1["id"] . "\"";
        if ($subrow1["id"] == $row["days"])
            $s1 .= " selected=\"selected\"";
        $s1 .= ">" . htmlspecialchars($subrow1["name"]) . "</option>\n";
    }

    $s1 .= "</select>\n";

$s2 .= "</select>\n";

    $s2 = "<select name=\"type2\">\n";

    $cats2 = monthslist();
    foreach ($cats2 as $subrow2) {
        $s2 .= "<option value=\"" . $subrow2["id"] . "\"";
        if ($subrow2["id"] == $row["months"])
            $s2 .= " selected=\"selected\"";
        $s2 .= ">" . htmlspecialchars($subrow2["name"]) . "</option>\n";
    }

    $s2 .= "</select>\n";

$s3 .= "</select>\n";

    $s3 = "<select name=\"type3\">\n";

    $cats3 = yearslist();
    foreach ($cats3 as $subrow3) {
        $s3 .= "<option value=\"" . $subrow3["id"] . "\"";
        if ($subrow3["id"] == $row["years"])
            $s3 .= " selected=\"selected\"";
        $s3 .= ">" . htmlspecialchars($subrow3["name"]) . "</option>\n";
    }

    $s3 .= "</select>\n";

  print("<tr><td class=tablea>Datum</td><td class=tablea align=left>Tag $s</td><td class=tablea align=left>$s1</td><td class=tablea align=left>Monat $s2</td><td class=tablea align=left>Jahr $s3</td></tr>\n");

$s4 .= "</select>\n";

    $s4 = "<select name=\"type4\">\n";

    $cats4 = hourslist();
    foreach ($cats4 as $subrow4) {
        $s4 .= "<option value=\"" . $subrow4["id"] . "\"";
        if ($subrow4["id"] == $row["hours"])
            $s4 .= " selected=\"selected\"";
        $s4 .= ">" . htmlspecialchars($subrow4["name"]) . "</option>\n";
    }

    $s4 .= "</select>\n";

$s5 .= "</select>\n";

    $s5 = "<select name=\"type5\">\n";

    $cats5 = minuteslist();
    foreach ($cats5 as $subrow5) {
        $s5 .= "<option value=\"" . $subrow5["id"] . "\"";
        if ($subrow5["id"] == $row["minutes"])
            $s5 .= " selected=\"selected\"";
        $s5 .= ">" . htmlspecialchars($subrow5["name"]) . "</option>\n";
    }

    $s5 .= "</select>\n";

  print("<tr><td class=tablea>Zeit</td><td class=tablea align=left colspan=2>Stunden $s4</td><td class=tablea align=left colspan=2>Minuten $s5</td></tr>\n");

  print("<tr><td class=tablea>Streamer</td><td class=tablea align=left colspan=4><input type=text name=streamer value=" . htmlspecialchars($row["streamer"]) . " size=80></td></tr>\n");
  print("<tr><td class=tablea>Beschreibung</td><td class=tablea align=left colspan=4><input type=text name=descr value=" . htmlspecialchars($row["descr"]) . " size=80></td></tr>\n");
  print("<tr><td class=tablea>Radio Nr.</td><td class=tablea align=left colspan=4><input type=text name=streamnr value=" . htmlspecialchars($row["streamnr"]) . " size=80></td></tr>\n");

  

    print("<tr><td class=\"tablea\" colspan=\"5\" align=\"center\"><input type=\"submit\" value='Ändern!' style='height: 25px; width: 100px'> <input type=reset value='Verwerfen' style='height: 25px; width: 100px'></td></tr>\n");
    print("</table>\n");
    print("</form>\n");
    print("<br>\n");

}

stdfoot();

hit_end();

?>