09 Auto Thanks For Torrent Comments

Started by Mindless, July 24, 2012, 11:02:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Mindless

Insert a thankyou into a comment

Run the sql

CREATE TABLE IF NOT EXISTS `thankyou` (
  `tid` bigint(10) NOT NULL AUTO_INCREMENT,
  `uid` bigint(10) NOT NULL DEFAULT '0',
  `torid` bigint(10) NOT NULL DEFAULT '0',
  `thank_date` int(10) NOT NULL DEFAULT '0',
  PRIMARY KEY (`tid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;


ALTER TABLE torrents ADD `thanks` int(10) NOT NULL default '0';

details.php find :

$commentbar = "<p align='center'><a class='index' href='comment.php?action=add&amp;tid=$id'>{$lang['details_add_comment']}</a></p>\n";

Change to :

$commentbar = "<p align='center'><a class='index' href='comment.php?action=add&amp;tid=$id'>{$lang['details_add_comment']}</a>
    <br /><a class='index' href='{$TBDEV['baseurl']}/takethankyou.php?id=$id'>
    <img src='{$TBDEV['pic_base_url']}smilies/thankyou.gif' alt='Thanks' title='Thank You' border='0' /></a></p>\n";


Save and upload takethankyou.php

<?php
require_once('include/bittorrent.php');
require_once(
'include/user_functions.php');
dbconn();
loggedinorreturn();
$lang array_mergeload_language('global') );


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

$id $id;

if (!
is_valid_id($id))
    
stderr("Error""Bad Id");
  
if (!isset(
$CURUSER))
stderr("Error""Your not logged in");

$res mysql_query("SELECT 1 FROM torrents WHERE id = ".sqlesc($id)."") or sqlerr(__FILE____LINE__);
$row mysql_fetch_assoc($res);
if (!
$row)
stderr("Error","Torrent not found");

$res1 mysql_query("SELECT 1 FROM thankyou WHERE torid=".sqlesc($id)." AND uid =" .$CURUSER["id"]. " ") or sqlerr(__FILE____LINE__);
$row mysql_fetch_assoc($res1);
if (
$row)
stderr("Error""You already thanked.");

$text ":thankyou:";
$newid mysql_insert_id();
mysql_query("INSERT INTO thankyou (uid, torid, thank_date) VALUES (" .$CURUSER["id"]. ", ".sqlesc($id).", '" TIME_NOW "')") or sqlerr(__FILE____LINE__);
mysql_query("INSERT INTO comments (user, torrent, added, text, ori_text) VALUES (" .$CURUSER["id"] . ",".sqlesc($id).", '" TIME_NOW "', " sqlesc($text) ."," sqlesc($text) . ")") or sqlerr(__FILE____LINE__);
mysql_query("UPDATE torrents SET thanks = thanks + 1 WHERE id = ".sqlesc($id)."") or sqlerr(__FILE____LINE__);
header("Refresh: 0; url=details.php?id=$id");
?>