<hack>
<file>
<name>"database"</name>
<operation>
<action>"sql"</action>
<data><![CDATA[CREATE TABLE `{$db_prefix}files_thanks` (
`infohash` char(40) NOT NULL default '0',
`userid` int(11) NOT NULL default '0',
KEY `infohash` (`infohash`)
) TYPE=MyISAM;]]></data>
</operation>
</file>
<file>
<name>"$CURRENT_FOLDER/toCopy/thanks.php"</name>
<operation>
<action>"copy"</action>
<where>"$DEFAULT_ROOT"</where>
<data>"thanks.php"</data>
</operation>
</file>
<file>
<name>"$DEFAULT_LANGUAGE_PATH/lang_torrents.php"</name>
<operation>
<action>"add"</action>
<search><![CDATA[?>]]></search>
<where>"before"</where>
<data><![CDATA[
$language["THANKS_BE_FIRST"]="Nobody thanks for this torrent, be the first!";
$language["THANKS_USERS"]="Who thanks";
$language["THANKS_YOU"]="Say Thank You!";
]]></data>
</operation>
</file>
<file>
<name>"$DEFAULT_STYLE_PATH/torrent.details.tpl"</name>
<operation>
<action>"add"</action>
<search><![CDATA[</script>]]></search>
<where>"before"</where>
<data><![CDATA[
function disable_button(state)
{
document.getElementById('ty').disabled=(state=='1'?true:false);
}
at=new sack();
function ShowUpdate()
{
var mytext=at.response + '';
var myout=mytext.split('|');
document.getElementById('thanks_div').style.display='block';
document.getElementById('loading').style.display='none';
document.getElementById('thanks_div').innerHTML = myout[0]; //at.response;
disable_button(myout[1]);
}
function thank_you(ia)
{
disable_button('1');
at.resetData();
at.onLoading=show_wait;
at.requestFile='thanks.php';
at.setVar('infohash',"'"+ia+"'");
at.setVar('thanks',1);
at.onCompletion = ShowUpdate;
at.runAJAX();
}
function ShowThank(ia)
{
at.resetData();
at.onLoading=show_wait;
at.requestFile='thanks.php';
at.setVar('infohash',"'"+ia+"'");
at.onCompletion = ShowUpdate;
at.runAJAX();
}
function show_wait()
{
document.getElementById('thanks_div').style.display='none';
document.getElementById('loading').style.display='block';
}
]]></data>
</operation>
<operation>
<action>"add"</action>
<search><![CDATA[<tr>
<td align="right" class="header"><tag:language.INFO_HASH /></td>
<td class="lista" align="center"><tag:torrent.info_hash /></td>
</tr>
<tr>]]></search>
<where>"after"</where>
<data><![CDATA[
<td align="right" class="header" valign="top"><tag:language.THANKS_USERS /></td>
<td class="lista" align="center">
<form action="thanks.php" method="post" onsubmit="return false">
<div id="thanks_div" name="thanks_div" style="display:block;"></div>
<div id="loading" name="loading" style="display:none;"><img src="images/ajax-loader.gif" alt="" title="ajax-loader" /></div>
<input type="button" id="ty" disabled="disabled" value="<tag:language.THANKS_YOU />" onclick="thank_you('<tag:torrent.info_hash />')" />
</form>
<script type="text/javascript">ShowThank('<tag:torrent.info_hash />');</script>
</td>
</tr>
<tr>
]]></data>
</operation>
</file>
</hack>
Thanks.php
<?php
if (isset($_POST["infohash"]))
{
$THIS_BASEPATH=dirname(__FILE__);
require("$THIS_BASEPATH/include/functions.php");
include(load_language("lang_torrents.php"));
dbconn();
$uid = intval(0+$CURUSER['uid']);
$infohash=($_POST["infohash"]);
$out="";
$rt=mysql_query("SELECT uploader FROM {$TABLE_PREFIX}files WHERE info_hash=$infohash AND uploader=$uid");
// he's not the uploader
if (mysql_num_rows($rt)==0)
$button=true;
else
$button=false;
// saying thank you.
if (isset($_POST["thanks"]) && $button)
{
mysql_free_result($rt);
$rt=mysql_query("SELECT userid FROM {$TABLE_PREFIX}files_thanks WHERE userid=$uid AND infohash=$infohash");
// never thanks for this file
if (mysql_num_rows($rt)==0)
{
@mysql_query("INSERT INTO {$TABLE_PREFIX}files_thanks (infohash, userid) VALUES ($infohash, $uid)");
}
}
mysql_free_result($rt);
$rt=mysql_query("SELECT u.id, u.username, ul.prefixcolor, ul.suffixcolor FROM {$TABLE_PREFIX}files_thanks t LEFT JOIN
{$TABLE_PREFIX}users u ON u.id=t.userid LEFT JOIN {$TABLE_PREFIX}users_level ul ON u.id_level=ul.id WHERE infohash=$infohash");
if (mysql_num_rows($rt)==0)
$out=$language["THANKS_BE_FIRST"];
while ($ty=mysql_fetch_assoc($rt))
{
if ($ty["id"]==$uid) // already thank
$button=false;
$out.="<a href=\"$BASEURL/index.php?page=userdetails&id=".$ty["id"]."\">".unesc($ty["prefixcolor"].$ty["username"].$ty["suffixcolor"])."</a> ";
}
if ($button && $CURUSER["uid"]>1)
$out.="|0";
else
$out.="|1";
}
else
$out= "no direct access!";
echo $out;
die;
?>







