Location: PHPKode > projects > Trunk.net > takethankyou.php
<?

require_once("include/functions.php");

hit_start();

dbconn();

function bark($msg) {
stdhead();
stdmsg("Thanks failed!", $msg);
stdfoot();
exit;
}

hit_count();

if (!isset($CURUSER))
die();

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

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

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

$ras = mysql_query("select 1 from thanks WHERE torid='$id' AND uid =" .$CURUSER["id"]. " ") or die(mysql_error());
$raw = mysql_fetch_array($ras);
if ($raw)
bark("You already thanked.");

$text = ":thankyou:";

mysql_query("INSERT INTO thanks (uid, torid, thank_date) VALUES (" .$CURUSER["id"]. ",$id, '" . get_date_time() . "')");
 mysql_query("INSERT INTO comments (user, torrent, added, text, ori_text) VALUES (" .
     $CURUSER["id"] . ",$id, '" . get_date_time() . "', " . sqlesc($text) .
      "," . sqlesc($text) . ")");


$newid = mysql_insert_id();

mysql_query("UPDATE torrents SET thanks = thanks + 1 WHERE id = $id");

header("Refresh: 0; url=details.php?id=$id&viewcomm=$newid#comm$newid");

hit_end();

?>
Return current item: Trunk.net