Location: PHPKode > projects > Trunk.net > thanks.php
<?
require_once("include/functions.php");
dbconn();

loggedinorreturn();
parked();

$userid = $CURUSER["id"];
$torrentid = (int) $_POST["torrentid"];

if (empty($torrentid)) {
stdmsg($tracker_lang["error"], "Don't try to crack me!");
}

$ajax = $_POST["ajax"];
if ($ajax == "yes") {
mysql_query("INSERT INTO thanks (torrentid, userid) VALUES ($torrentid, $userid)") or sqlerr(__FILE__,__LINE__);
$thanks_sql = mysql_query("SELECT * FROM thanks WHERE torrentid = $torrentid");
$thanks_all = mysql_numrows($thanks_sql);
if ($thanks_all) {
while($rows_t = mysql_fetch_array($thanks_sql)) {
$thanks_userid = $rows_t["userid"];
$user_sql = mysql_query("SELECT * FROM users WHERE id = $thanks_userid");
$rows_a = mysql_fetch_array($user_sql);
$username_t = $rows_a["username"];
$thanksby = $thanksby."<a href=\"userdetails.php?id=$thanks_userid\">$username_t</a>, ";
}
$thanksby = substr($thanksby, 0, -2);
$t_userid = $CURUSER["id"];
$tsql = mysql_query("SELECT COUNT(*) FROM thanks WHERE torrentid = $torrentid AND userid = $t_userid");
$trows = mysql_fetch_array($tsql);
$t_ab = $trows[0];
if ($t_ab == "0" && $t_userid != $row["owner"]) {
$thanksby = "<form action=\"thanks.php\" method=\"post\">
<input type=\"submit\" name=\"submit\" onclick=\"send(); return false;\" value=\"".$tracker_lang['thanks']."\">
<input type=\"hidden\" name=\"torrentid\" value=\"$torrentid\">".$thanksby."
</form>";
} else {
$thanksby = "<form action=\"thanks.php\" method=\"post\">
<input type=\"submit\" name=\"submit\" onclick=\"send(); return false;\" value=\"".$tracker_lang['thanks']."\" disabled>
<input type=\"hidden\" name=\"torrentid\" value=\"$torrentid\">".$thanksby."
</form>";
}
} else {
$thanksby = "<form action=\"thanks.php\" method=\"post\">
<input type=\"submit\" name=\"submit\" onclick=\"send(); return false;\" value=\"".$tracker_lang['thanks']."\" " . ($CURUSER["id"] == $row["owner"] ? "disabled" : "") . ">
<input type=\"hidden\" name=\"torrentid\" value=\"$torrentid\">".$tracker_lang['none_yet']."
</form>";
}
header ("Content-Type: text/html; charset=" . $tracker_lang['language_charset']);
print $thanksby;
} else {
$res = mysql_query("INSERT INTO thanks (torrentid, userid) VALUES ($torrentid, $userid)") or sqlerr(__FILE__,__LINE__);
header("Location: $DEFAULTBASEURL/details.php?id=$torrentid&thanks=1");
}
?>
Return current item: Trunk.net