this is my torrent detail test, you can look this and help me for bad codage?
<?php
//
// TorrentTrader v2.x
// This file was last updated: 28/November/2007 by TorrentialStorm
//
//
http://www.torrenttrader.org
//
//
require_once("backend/functions.php");
require_once("backend/BDecode.php");
require_once("backend/parse.php");//replace with parse later
dbconn();
$torrent_dir = $site_config["torrent_dir"];
$nfo_dir = $site_config["nfo_dir"];
//check permissions
if ($site_config["MEMBERSONLY"]){
loggedinonly();
if($CURUSER["view_torrents"]=="no")
show_error_msg("Error","You do not have permission to view torrents",1);
}
//************ DO SOME "GET" STUFF BEFORE PAGE LAYOUT ***************
$id = (int) $_GET["id"];
$scrape = (int)$_GET["scrape"];
if (!is_valid_id($id))
show_error_msg("ERROR","Thats not a valid ID",1);
//GET ALL MYSQL VALUES FOR THIS TORRENT
$res = mysql_query("SELECT torrents.anon, torrents.thanks, torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, torrents.nfo, torrents.last_action, torrents.numratings, torrents.name, torrents.owner, torrents.save_as, torrents.descr, torrents.synopsis, torrents.movie, torrents.screenshot, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.external, torrents.image1, torrents.image2, torrents.announce, torrents.numfiles, torrents.freeleech, IF(torrents.numratings < 2, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, torrents.numratings, categories.name AS cat_name, torrentlang.name AS lang_name, torrentlang.image AS lang_image, categories.parent_cat as cat_parent, users.username, users.privacy FROM torrents LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN torrentlang ON torrents.torrentlang = torrentlang.id LEFT JOIN users ON torrents.owner = users.id WHERE torrents.id = $id") or die(mysql_error());
$row = mysql_fetch_array($res);
$moderator = $CURUSER["edit_torrents"] == "yes";
//DECIDE IF TORRENT EXISTS
if (!$row || ($row["banned"] == "yes" && !$moderator))
show_error_msg("Error","" . TORRENT_NOT_FOUND . "",1);
//torrent is availiable so do some stuff
if ($_GET["hit"]) {
mysql_query("UPDATE torrents SET views = views + 1 WHERE id = $id");
header("Location: torrents-details.php?id=$id");
die;
}
stdhead("Details for torrent \"" . $row["name"] . "\"");
if ($CURUSER["id"] == $row["owner"])
$owned = 1;
else
$owned = 0;
if ($CURUSER["edit_torrents"]=="yes")
$owned = 1;
//take rating
if ($_GET["takerating"] == 'yes'){
$rating = (int)$_POST['rating'];
if ($rating <= 0 || $rating > 5)
show_error_msg("Rating Error", "Invalid rating",1);
$res = mysql_query("INSERT INTO ratings (torrent, user, rating, added) VALUES ($id, " . $CURUSER["id"] . ", $rating, '".get_date_time()."')");
if (!$res) {
if (mysql_errno() == 1062)
show_error_msg("Rating Error", "You have already rated this torrent.",1);
else
show_error_msg("Rating Error", "A Unknown Error, contact staff",1);
}
mysql_query("UPDATE torrents SET numratings = numratings + 1, ratingsum = ratingsum + $rating WHERE id = $id");
show_error_msg(".RATING.", "".RATING_THANK."<BR><BR><a href=torrents-details.php?id=$id>" . BACK_TO_TORRENT . "</a>");
}
//take comment add
if ($_GET["takecomment"] == 'yes'){
loggedinonly();
$commentbody = $_POST['body'];
if (!$commentbody)
show_error_msg("Error","You did not enter anything!",1);
mysql_query("UPDATE torrents SET comments = comments + 1 WHERE id = $id") or die(mysql_error());
mysql_query("INSERT INTO comments (user, torrent, added, text) VALUES (".$CURUSER["id"].", ".$id.", '" .get_date_time(). "', " . sqlesc($body).")") or die(mysql_error());
if (mysql_affected_rows() == 1)
show_error_msg("".COMPLETED."","".COMMENT_ADDED."",0);
else
show_error_msg("Error","Unable to add comment",0);
}//end insert comment
//START OF PAGE LAYOUT HERE
$char1 = 50; //cut length
$shortname = CutName(htmlspecialchars($row["name"]), $char1);
begin_frame("" . TORRENT_DETAILS_FOR . " \"" . $shortname . "\"");
echo "<div align=right>[<a href=report.php?torrent=$id><B>" . REPORT_TORRENT . "</B></a>] ";
if ($owned)
echo "[<a href=torrents-edit.php?id=$row[id]><B>".EDIT_TORRENT."</B></a>]";
echo "</div>";
$previd = mysql_query("SELECT id, name FROM torrents WHERE id < $id ORDER BY id DESC LIMIT 1");
$prev = mysql_fetch_row($previd);
$previd = $prev[0];
$prevname = htmlspecialchars($prev[1]);
$nextid = mysql_query("SELECT id, name FROM torrents WHERE id > $id ORDER BY id ASC LIMIT 1");
$next = mysql_fetch_row($nextid);
$nextid = $next[0];
$nextname = htmlspecialchars($next[1]);
echo "<table border=0 width=100%><tr>";
if ($previd)
echo "<td align=center><a href='torrents-details.php?id=$previd'>[Torrent Pr