<?

require_once("include/bittorrent.php");

hit_start();

function bark($msg) {
    genbark($msg, "Änderung fehlgeschlagen!");
}

if (!mkglobal("id:descr:title"))
    bark("Fehlende Formulardaten!");

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

dbconn();

hit_count();

loggedinorreturn();

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

if ($CURUSER["id"] != $row["owner"] && get_user_class() < UC_MODERATOR)
    bark("Das ist nicht Dein Torrent! Wie konnte das passieren?\n");

$updateset = array();

$fileaction = $_POST['fileaction'];
if ($fileaction == "update")
{
  $file = $_FILES['file'];
  if (!file) die("Keine Daten " . var_dump($_FILES));
  $filename = $file['name'];
    $updateset[] = "filename = " . sqlesc($filename);
    $updateset[] = "added = " . sqlesc(get_date_time());
    $updateset[] = "size = " . $file["size"];
    $updateset[] = "uppedby = " . $CURUSER["id"];
    move_uploaded_file($file["tmp_name"], "database/$file[name]");
}


$updateset[] = "title = " . sqlesc($title);
$updateset[] = "description = " . sqlesc($descr);



mysql_query("UPDATE data SET " . join(",", $updateset) . " WHERE id = $id");

$returl = "database.php";
if (isset($_POST["returnto"]))
    $returl .= "&returnto=" . urlencode($_POST["returnto"]);
header("Refresh: 0; url=$returl");

hit_end();

?>