09 Seedbonus System

Started by Mindless, July 21, 2012, 10:24:42 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

tcboxa

Recently discovered a problem with the cleanup section of the SeedBonus System.

We had a user seeding almost 1000 torrents and discovered that he was getting almost 1000 bonus points per hour. Its since been fixed but i wondered why i had never seen anyone make mention of it before, the only mention is to change the 5 from the code below.

if ($arr['tcount'] >= 1000)
                $arr['tcount'] = 5;


Im still learning so please correct me if i am wrong. The $arr['tcount'] = 5; does nothing unless the user is seeding 1000 or more torrents. The If statement amount of 1000 should match the max amount of torrents to award bonus points to one user at any given time.

In my case i changed it to the following

if ($arr['tcount'] >= 20)
                $arr['tcount'] = 20;


Have i missed something? surely someone else has run into the same problem.
Centos 7.4.1708 x86
Apache 2.4.29
PHP 7.0.14
MariaDB 10.1.29

Mindless

Change to :
Code (php) Select
print($ajax? json_encode(array('status'=>false,'err'=>$msg)) : $msg);
}
}
}
// ===add karma
@mysql_query("UPDATE users SET seedbonus = seedbonus+5.0 WHERE id =".$uid."") or sqlerr(__FILE__, __LINE__);
// ===end
break;
}



for rating a torrent = 5 points
in takerate.php just under:
Code (php) Select
mysql_query("UPDATE torrents SET numratings = numratings + 1, ratingsum = ratingsum + $rating WHERE id = $id");


add:
Code (php) Select
//===add karma
mysql_query("UPDATE users SET seedbonus = seedbonus+5.0 WHERE id = ".sqlesc($userid)."") or sqlerr(__FILE__, __LINE__);
//===end



forum querys :

for making a post = 1 point &
starting a topic = 2 points
in forum/forum_post.php just after:
Code (php) Select
$topicid = mysql_insert_id() or stderr("{$lang['forum_post_error']}", "{$lang['forum_post_topic_id']}");

add:
Code (php) Select
//===add karma
mysql_query("UPDATE users SET seedbonus = seedbonus+2.0 WHERE id = ".sqlesc($userid)."") or sqlerr(__FILE__, __LINE__);
//===end



in file forum/forum_post.php after:
Code (php) Select
update_topic_last_post($topicid);


add:
Code (php) Select
//===add karma
mysql_query("UPDATE users SET seedbonus = seedbonus+1.0 WHERE id = ".sqlesc($userid)."") or sqlerr(__FILE__, __LINE__);
//==end



lang_mybonus.php (replace your old one with this one.)
Code (php) Select
<?php

$lang 
= array(

#bonus errors
'bonus_error_msg' => "Error",
'bonus_rat_msg' => "I smell a rat!",
'bonus_nouser_msg' => " No User with that username ",
'bonus_notid_msg' => "That is not your user ID!",
'bonus_notthere_msg' => "How can we remove a warning that isn't there?<br />go back to your <a class='altlink' href='{$TBDEV['baseurl']}/mybonus.php'>Karma Bonus Point</a> page and think that one over.",
'bonus_lower_msg' => "Now why would you want to lower yourself to VIP?<br />go back to your <a class='altlink' href='{$TBDEV['baseurl']}/mybonus.php'>Karma Bonus Point</a> page and think that one over.",
'bonus_notorrent_msg' => "No torrent with that ID!<br />Back to your <a class='altlink' href='{$TBDEV['baseurl']}/mybonus.php'>Karma Bonus Point</a> page.",
'bonus_notenough_msg' => " you don\'t have enough Karma points.",
'bonus_fineratio_msg' => "Your ratio on that torrent is fine, you must have selected the wrong torrent ID.<br />Back to your <a class='altlink' href='{$TBDEV['baseurl']}/mybonus.php'>Karma Bonus Point</a> page.",


#bonus message
'bonus_system' => " Karma Bonus Point's system :",
'bonus_goodies' => " ] for goodies!",
'bonus_no_buttons' => "[ If no buttons appear, you have not earned enough bonus points to trade. ]",
'bonus_exchangepoints' => "Exchange your <a class='altlink' href='{$TBDEV['baseurl']}/mybonus.php'>Karma Bonus Points</a> [ current ",
'bonus_success' => "Success!",
'bonus_sorry' => "Sorry",
'bonus_karma' => "Karma Bonus",
'bonus_congrat' => "Congratulations! ",
'bonus_by' => "</b> Karma points by ",
'bonus_also' => "You may also ",
'bonus_send' => "send ",
'bonus_orgoback' => " a message as well</a>, or go back to your <a class='altlink' href='mybonus.php'>Karma Bonus Point</a> page.",
'bonus_spread' => "you have spread the Karma well.<br /><br />Member <b>",
'bonus_love' => " will be pleased with your kindness!<br /><br />This is the message that was sent:<br /><b>Subject:</b> Someone Loves you!<br /> <p>You have been given a gift of <b>",
'bonus_fancy' => "Not so fast there Mr. fancy pants!",
'bonus_cannot' => " you can not spread the karma to yourself...<br />If you want to spread the love, pick another user! ",
'bonus_uploadinc' => " you have just increased your upload amount by ",
'bonus_smilies' => " you have got yourself a set of custom smilies for one month! ",
'bonus_warning' => " you have removed your warning for the low price of 1000 points!! ",
'bonus_invites' => " you have got your self 3 new invites! ",
'bonus_knownas' => " you are now known as ",
'bonus_ratio' => " you have gained a 1 to 1 ratio on the selected torrent, and the difference in MB has been added to your total upload! ",
'bonus_vip' => " you have got yourself VIP Status for one month! ",
'bonus_goback' => " Click to go back to your <a class='altlink' href='{$TBDEV['baseurl']}/mybonus.php'>Karma Bonus Point</a> page.",

#bonus img alternates
'bonus_img_karma' => "Good Karma",
'bonus_img_bad' => "Bad Karma",
'bonus_img_woot' => "wOOt",

#bonus headers
'bonus_head_descr' => "Description",
'bonus_head_points' => "Points",
'bonus_head_trade' => "Trade",

#bonus options
'bonus_op_username' => "Username:",
'bonus_op_username2' => "Enter the <b>username</b> of the person you would like to send karma to, and select how many points you want to send and click Exchange!",
'bonus_op_given' => "to be given: ",
'bonus_op_karma' => " Karma Points!",
'bonus_op_title' => "Enter the <b>Special Title</b> you would like to have ",
'bonus_op_click' => " click Exchange! ",
'bonus_op_min' => "min.",
'bonus_op_max' => "max.",
'bonus_op_idnum' => "Enter the <b>ID number of the Torrent:</b> ",
'bonus_op_idnum2' => " you would like to buy a 1 to 1 ratio on.</b> ",
'bonus_op_more' => "<b>more points needed</b>",

#bonus table
'bonus_table_hell' => "What the hell are these Karma Bonus points, and how do I get them?",
'bonus_table_rest_of' => "For every hour that you seed a torrent, you are awarded with 1
  Karma Bonus Point... <br />If you save up enough of them, you can trade them in for goodies like bonus GB(s) to 
  your upload<br /> stats,getting more invites, or doing the real Karma booster... give them to another user!<br />
  and yes! this is awarded on a per torrent basis (max of 5) even if there are no leechers on the Torrent you are seeding! <br />
  <h1>Other things that will get you karma points : </h1>
  - Uploading a new torrent = 15 points
  <br />- Putting up an offer = 10 points
  <br />- Filling a request = 10 points
  <br />- Comment on torrent = 3 points
  <br />- Saying thanks = 2 points
  <br />- Rating a torrent = 2 points
  <br />- Making a post = 1 point
  <br />- Starting a topic = 2 points 
  <br />
  <h1>Some things that will cost you karma points:</h1>
  <br />- Upload credit
  <br />- Custom title
  <br />- One month VIP status
  <br />- A 1:1 ratio on a torrent
  <br />- Buying off your warning
  <br />- One month custom smilies for the forums and comments
  <br />- Getting extra invites
  <br />- Giving a gift of karma points to another user
  <br />- Asking for a re-seed
  <br />- Making a request
  <br />- But keep in mind that everything that can get
  you karma can also be lost, <br />ie : if you up a torrent then delete it, you will gain and then lose 15 points, <br />
  making a post and having it deleted will do the same<br /><br />... and there are other hidden bonus karma points all 
  over the site.<br /><br />Yet another way to help out your ratio! 
  <br />- *please note, staff can give or take away 
  points for breaking the rules, or doing good for the community.
  <br />"
,
'bonus_table_go_back' => "Back to homepage",


#bonus page name
'bonus_page_name' => "Karma Bonus Points page",

);

?>



lang_global.php Add:
Code (php) Select
'gl_bonus' => "Bonus:",


@ file include/bittorrent.php to display bonus on status bar change :
Code (php) Select
"$IsDonor$warn&nbsp; [<a href='logout.php'>{$lang['gl_logout']}</a>]&nbsp;$member_reputation


to
Code (php) Select
"$IsDonor$warn&nbsp; [<a href='{$TBDEV['baseurl']}/logout.php'>{$lang['gl_logout']}</a>]&nbsp;$member_reputation".
"&nbsp;&nbsp;{$lang['gl_bonus']}&nbsp;<a href='{$TBDEV['baseurl']}/mybonus.php'>{$CURUSER['seedbonus']}</a>

Mindless

Posted 29 November 2009 - 02:47 PM
sir_snugglebunny = ok... here it is lol the uber bonus point mod all in one post lol
credit to TvRecall for writing it in the first place,
the mod has since been altered with input by: devinkray - cddvdheaven - DRRRR - vlahdr - sherl0k - okiee - lords- dopeydwerg - WRK - Fantomax - porthos - dokty - Sir_SnuggleBunny - wicked - XiaNYdE

lol I don't care if anybody likes this mod, I'm just impressed with how many people contributed to making it... I think that is what this place is all about ;)

MOD DONE!!!

Reworked for 09 using the updated mybonus.php
moresmiles.php and moresmilies_custom.php Xhtml Valid
mybonus.php has 39 html errors now.
Everything else is Xhtml Vaild :)

SQL (if you need it)
Code (sql) Select
CREATE TABLE `bonus` (
`id` int(5) NOT NULL auto_increment,
`bonusname` varchar(50) NOT NULL default '',
`points` decimal(10,1) NOT NULL default '0.0',
`description` text NOT NULL,
`art` varchar(10) NOT NULL default 'traffic',
`menge` bigint(20) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
);


Code (sql) Select
INSERT INTO `bonus` VALUES (1, '1.0GB Uploaded', 75.0, 'With enough bonus points acquired, you are able to exchange them for an Upload Credit. The points are then removed from your Bonus Bank and the credit is added to your total uploaded amount.', 'traffic', 1073741824);
INSERT INTO `bonus` VALUES (2, '2.5GB Uploaded', 150.0, 'With enough bonus points acquired, you are able to exchange them for an Upload Credit. The points are then removed from your Bonus Bank and the credit is added to your total uploaded amount.', 'traffic', 2684354560);
INSERT INTO `bonus` VALUES (3, '5GB Uploaded', 250.0, 'With enough bonus points acquired, you are able to exchange them for an Upload Credit. The points are then removed from your Bonus Bank and the credit is added to your total uploaded amount.', 'traffic', 5368709120);
INSERT INTO `bonus` VALUES (4, '3 Invites', 20.0, 'With enough bonus points acquired, you are able to exchange them for a few invites. The points are then removed from your Bonus Bank and the invitations are added to your invites amount.', 'invite', 3);
INSERT INTO `bonus` VALUES (5, 'Custom Title!', 50.0, 'For only 50.0 Karma Bonus Points you can buy yourself a custom title. the only restrictions are no foul or offensive language or userclass can be entered. The points are then removed from your Bonus Bank and your special title is changed to the title of your choice', 'title', 1);
INSERT INTO `bonus` VALUES (6, 'VIP Status', 500.0, 'With enough bonus points acquired, you can buy yourself VIP status for one month. The points are then removed from your Bonus Bank and your status is changed.', 'class', 1);
INSERT INTO `bonus` VALUES (7, 'Give A Karma Gift', 100.0, 'Well perhaps you don''t need the upload credit, but you know somebody that could use the Karma boost! You are now able to give your Karma credits as a gift! The points are then removed from your Bonus Bank and added to the account of a user of your choice!\r\n\r\nAnd they recieve a PM with all the info as well as who it came from...', 'gift_1', 1073741824);
INSERT INTO `bonus` VALUES (8, 'Custom Smilies', 300.0, 'With enough bonus points acquired, you can buy yourself a set of custom smilies for one month! The points are then removed from your Bonus Bank and with a click of a link, your new smilies are available whenever you post or comment!', 'smile', 1);
INSERT INTO `bonus` VALUES (9, 'Remove Warning', 1000.0, 'With enough bonus points acquired... So you''ve been naughty... tsk tsk Yep now for the Low Low price of only 1000 points you can have that warning taken away lol.!', 'warning', 1);
INSERT INTO `bonus` VALUES (10, 'Ratio Fix', 500.0, 'With enough bonus points acquired, you can bring the ratio of one torrent to a 1 to 1 ratio! The points are then removed from your Bonus Bank and your status is changed.', 'ratio', 1);



to use some of the other options, you will also need this SQL: (you may have some already, just add the ones you need)
Code (sql) Select
ALTER TABLE `users` ADD `seedbonus` decimal(10,1) NOT NULL default '200.0';
ALTER TABLE `users` ADD `bonuscomment` text;
ALTER TABLE `users` ADD `vip_added` enum('yes','no') NOT NULL default 'no';
ALTER TABLE `users` ADD `vip_until` int(10) NOT NULL default '0';
ALTER TABLE `users` ADD `smile_until` int(10) NOT NULL default '0';



don't add the stuff you don't want... or use ezeros bonus manager :)

add this to your style sheets css, change to fit your colors / theme:
Code (html) Select
td.clearalt6 {
background: #004E98;
padding: 5px;
border: 0px;
border: hidden;}
td.clearalt7 {
padding: 5px;
background: #777777;
border: 0px;
border: hidden;}



mybonus.php
Code (php) Select
<?php
////////////////////////////////////////////////////////
// Bonus Mod by TvRecall.org
// Bonus Mod Updated by devin
// Version 0.3
// Updated 01/05/2006
// under GPL-License
///////////////////////////////////////////////////////
/******************************************************
Total credit to TvRecall for writing this fine mod in the first place,
the mod has since been altered with code and input by:
devinkray - cddvdheaven - DRRRR - vlahdr - sherl0k - okiee - lords - XiaNYdE
dopeydwerg - WRK - Fantomax - porthos - dokty - xam - wicked & Sir_SnuggleBunny

UPDATED!!! Wed, Nov 28th 2007
UPDATED FOR 09 - Nov 28th 2009
*******************************************************/
require_once("include/bittorrent.php");
require_once(
"include/user_functions.php");
require_once(
"include/bbcode_functions.php");
dbconn(false);

loggedinorreturn();

$lang array_mergeload_language('global'), load_language('mybonus') );

$HTMLOUT ='';

function 
I_smell_a_rat($var){
 if ((
$var) == 1)
    
$var $var;
 else
    
stderr("{$lang['bonus_error_msg']}""{$lang['bonus_rat_msg']}");
}

$bonus htmlspecialchars($CURUSER['seedbonus'], 1);


switch (
true){
case (isset(
$_GET['up_success'])):
I_smell_a_rat($_GET['up_success']);

$amt = (int)$_GET['amt'];

switch (
$amt) {
case 
$amt == 75.0:
   
$amt '1 GB';
   break;
case 
$amt == 150.0:
   
$amt '2.5 GB';
   break;
default:
   
$amt '5 GB';
}

$HTMLOUT .= "<table align='center' width='80%'>
<tr>
<td class='colhead' align='left' colspan='2'><h1>
{$lang['bonus_success']}</h1></td>
</tr><tr>
<td class='clearalt6' align='left'><img src='
{$TBDEV['pic_base_url']}smilies/karma.gif' alt='{$lang['bonus_img_karma']}' title='{$lang['bonus_img_karma']}' /></td>
<td class='clearalt6' align='left'><b>
{$lang['bonus_congrat']}</b>".$CURUSER['username']."{$lang['bonus_uploadinc']}".$amt."!
<img src='
{$TBDEV['pic_base_url']}smilies/w00t.gif' alt='{$lang['bonus_img_woot']}' title='{$lang['bonus_img_woot']}' /><br /><br /><br /><br />{$lang['bonus_goback']}<br /><br /></td>
</tr>
</table>"
;
print 
stdhead('Bonus Karma') . $HTMLOUT stdfoot();
die;

case (isset(
$_GET['class_success'])):
I_smell_a_rat($_GET['class_success']);
 
$HTMLOUT .="<table align='center' width='80%'><tr><td class='colhead' align='left' colspan='2'><h1>{$lang['bonus_success']}</h1></td></tr>
<tr><td align='left' class='clearalt6'><img src='
{$TBDEV['pic_base_url']}smilies/karma.gif' alt='{$lang['bonus_img_karma']}' title='{$lang['bonus_img_karma']}' /></td><td align='left' class='clearalt6'>
<b>
{$lang['bonus_congrat']}</b>".$CURUSER['username']."{$lang['bonus_vip']}<img src='{$TBDEV['pic_base_url']}smilies/w00t.gif' alt='{$lang['bonus_img_woot']}' title='{$lang['bonus_img_woot']}' /><br />
<br />
{$lang['bonus_goback']}<br /><br /></td></tr></table>";
print 
stdhead('Karma Bonus') . $HTMLOUT stdfoot();
die;
case (isset(
$_GET['smile_success'])):
I_smell_a_rat($_GET['smile_success']);
 
$HTMLOUT .="<table align='center' width='80%'><tr><td class='colhead' align='left' colspan='2'><h1>{$lang['bonus_success']}</h1></td></tr>
<tr><td align='left' class='clearalt6'><img src='
{$TBDEV['pic_base_url']}smilies/karma.gif' alt='{$lang['bonus_img_karma']}' title='{$lang['bonus_img_karma']}' /></td><td align='left' class='clearalt6'>
<b>
{$lang['bonus_congrat']}</b>".$CURUSER['username']."{$lang['bonus_smilies']}<img src='{$TBDEV['pic_base_url']}smilies/w00t.gif' alt='{$lang['bonus_img_woot']}' title='{$lang['bonus_img_woot']}' /><br />
<br />
{$lang['bonus_goback']}<br /><br /></td></tr></table>";
print 
stdhead('Karma Bonus') . $HTMLOUT stdfoot();
die;
case (isset(
$_GET['warning_success'])):
I_smell_a_rat($_GET['warning_success']);
 
$HTMLOUT .="<table align='center' width='80%'><tr><td class='colhead' align='left' colspan='2'><h1>{$lang['bonus_success']}</h1></td></tr>
<tr><td align='left' class='clearalt6'><img src='
{$TBDEV['pic_base_url']}smilies/karma.gif' alt='{$lang['bonus_img_karma']}' title='{$lang['bonus_img_karma']}' /></td><td align='left' class='clearalt6'>
<b>
{$lang['bonus_congrat']}</b>".$CURUSER['username']."{$lang['bonus_warning']}<img src='{$TBDEV['pic_base_url']}smilies/w00t.gif' alt='{$lang['bonus_img_woot']}' title='{$lang['bonus_img_woot']}' /><br />
<br />
{$lang['bonus_goback']}<br /><br /></td></tr></table>";
print 
stdhead('Karma Bonus') . $HTMLOUT stdfoot();
die;
case (isset(
$_GET['invite_success'])):
I_smell_a_rat($_GET['invite_success']);
 
$HTMLOUT .="<table align='center' width='80%'><tr><td class='colhead' align='left' colspan='2'><h1>{$lang['bonus_success']}</h1></td></tr><tr><td align='left' class='clearalt6'>
<img src='
{$TBDEV['pic_base_url']}smilies/karma.gif' alt='{$lang['bonus_img_karma']}' title='{$lang['bonus_img_karma']}' /></td><td align='left' class='clearalt6'>
<b>
{$lang['bonus_congrat']}</b>".$CURUSER['username']."{$lang['bonus_invites']}<img src='{$TBDEV['pic_base_url']}smilies/w00t.gif' alt='{$lang['bonus_img_woot']}' title='{$lang['bonus_img_woot']}' /><br /><br />{$lang['bonus_goback']}<br /><br /></td></tr></table>";
print 
stdhead('Karma Bonus') . $HTMLOUT stdfoot();
die;
case (isset(
$_GET['title_success'])):
I_smell_a_rat($_GET['title_success']);
 
$HTMLOUT .="<table align='center' width='80%'><tr><td class='colhead' align='left' colspan='2'><h1>{$lang['bonus_success']}</h1></td></tr><tr>
<td align='left' class='clearalt6'><img src='
{$TBDEV['pic_base_url']}smilies/karma.gif' alt='{$lang['bonus_img_karma']}' title='{$lang['bonus_img_karma']}' /></td><td align='left' class='clearalt6'>
<b>
{$lang['bonus_congrat']}</b>".$CURUSER['username']."{$lang['bonus_knownas']}<b>".$CURUSER['title']."</b>! <img src='{$TBDEV['pic_base_url']}smilies/w00t.gif' alt='{$lang['bonus_img_woot']}' title='{$lang['bonus_img_woot']}' /><br />
<br />
{$lang['bonus_goback']}<br /><br /></td></tr></table>";
print 
stdhead('Karma Bonus') . $HTMLOUT stdfoot();
die;
case (isset(
$_GET['ratio_success'])):
I_smell_a_rat($_GET['ratio_success']);

$HTMLOUT .="<table align='center' width='80%'><tr><td class='colhead' align='left' colspan='2'><h1>{$lang['bonus_success']}</h1></td></tr><tr>
<td align='left' class='clearalt6'><img src='
{$TBDEV['pic_base_url']}smilies/karma.gif' alt='{$lang['bonus_img_karma']}' title='{$lang['bonus_img_karma']}' /></td><td align='left' class='clearalt6'><b>{$lang['bonus_congrat']}</b> ".$CURUSER['username']."{$lang['bonus_ratio']}<img src='{$TBDEV['pic_base_url']}smilies/w00t.gif' alt='{$lang['bonus_img_woot']}' title='{$lang['bonus_img_woot']}' /><br />
<br />
{$lang['bonus_goback']}<br /><br />
</td></tr></table>"
;
print 
stdhead('Karma Bonus') . $HTMLOUT stdfoot();
die;
case (isset(
$_GET['gift_fail'])):
I_smell_a_rat($_GET['gift_fail']);

$HTMLOUT .="<table align='center' width='80%'><tr><td class='colhead' align='left' colspan='2'><h1>Huh?</h1></td></tr><tr><td align='left' class='clearalt6'>
<img src='
{$TBDEV['pic_base_url']}smilies/cry.gif' alt='{$lang['bonus_img_bad']}' title='{$lang['bonus_img_bad']}' /></td><td align='left' class='clearalt6'><b>{$lang['bonus_fancy']}</b><br />
<b>"
.$CURUSER['username']."...</b>{$lang['bonus_cannot']}<br />
<br />
{$lang['bonus_goback']}<br /><br /></td></tr></table>";
print 
stdhead('Karma Bonus') . $HTMLOUT stdfoot();
die;
case (isset(
$_GET['gift_fail_user'])):
I_smell_a_rat($_GET['gift_fail_user']);

$HTMLOUT .="<table align='center' width='80%'><tr><td class='colhead' align='left' colspan='2'><h1>{$lang['bonus_error_msg']}</h1></td></tr><tr><td align='left' class='clearalt6'>
<img src='
{$TBDEV['pic_base_url']}smilies/cry.gif' alt='{$lang['bonus_img_bad']}' title='{$lang['bonus_img_bad']}' /></td><td align='left' class='clearalt6'><b>{$lang['bonus_sorry']} ".$CURUSER['username']."...</b>
<br />
{$lang['bonus_nouser_msg']}<br /><br />{$lang['bonus_goback']}<br /><br /></td></tr></table>";
print 
stdhead('Karma Bonus') . $HTMLOUT stdfoot();
die;
case (isset(
$_GET['gift_fail_points'])):
I_smell_a_rat($_GET['gift_fail_points']);

$HTMLOUT .="<table align='center' width='80%'><tr><td class='colhead' align='left' colspan='2'><h1>Oops!</h1></td></tr><tr><td align='left' class='clearalt6'>
<img src='
{$TBDEV['pic_base_url']}smilies/cry.gif' alt='{$lang['bonus_img_bad']}' title='{$lang['bonus_img_bad']}' /></td><td align=left class=clearalt6><b>{$lang['bonus_sorry']} </b>".$CURUSER['username']."{$lang['bonus_notenough_msg']}
<br />
{$lang['bonus_goback']}<br /><br /></td></tr></table>";
print 
stdhead('Karma Bonus') . $HTMLOUT stdfoot();
die;
case (isset(
$_GET['gift_success'])): 
I_smell_a_rat($_GET['gift_success']);
 
$HTMLOUT  .="<table align='center' width='80%'><tr><td class='colhead' align='left' colspan='2'><h1>{$lang['bonus_success']}</h1></td></tr><tr><td align='left' class='clearalt6'>
<img src='
{$TBDEV['pic_base_url']}smilies/karma.gif' alt='{$lang['bonus_img_karma']}' title='{$lang['bonus_img_karma']}' /></td><td align='left' class='clearalt6'><b>{$lang['bonus_congrat']}".$CURUSER['username']." </b>
{$lang['bonus_spread']}".htmlspecialchars($_GET['usernamegift'])."</b>{$lang['bonus_love']}".($_GET['gift_amount_points'])."{$lang['bonus_by']}".$CURUSER['username']."</p><br />
{$lang['bonus_also']}<a class='altlink' href='{$TBDEV['baseurl']}/sendmessage.php?receiver=".($_GET['gift_id'])."'>{$lang['bonus_send']}".htmlspecialchars($_GET['usernamegift'])."{$lang['bonus_orgoback']}<br /><br /></td></tr></table>";
print 
stdhead('Karma Bonus') . $HTMLOUT stdfoot();
die;
}

//=== exchange
if (isset($_GET['exchange'])){
I_smell_a_rat($_GET['exchange']);

$userid $CURUSER['id'];
if (!
is_valid_id($userid))
stderr("{$lang['bonus_error_msg']}""{$lang['bonus_notid_msg']}");

$option $_POST['option'];

$res_points mysql_query("SELECT * FROM bonus WHERE id =" sqlesc($option));
$arr_points mysql_fetch_assoc($res_points);

$art $arr_points['art'];
$points $arr_points['points'];
if (
$points == 0)
stderr("{$lang['bonus_error_msg']}""{$lang['bonus_rat_msg']}");

$seedbonus=htmlspecialchars($bonus-$points,1);
$upload $CURUSER['uploaded'];
$download $CURUSER['downloaded'];
$bonuscomment $CURUSER['bonuscomment'];
$bpoints $CURUSER['seedbonus'];

if(
$bonus $points)
stderr("{$lang['bonus_sorry']}""{$lang['bonus_notenough_msg']}");

switch (
$art){
case 
'traffic':
//=== trade for one upload credit
$up $upload $arr_points['menge'];
$bonuscomment get_datetime(), 'DATE') . " - " .$points" Points for upload bonus.\n " .$bonuscomment;
mysql_query("UPDATE users SET uploaded = $upload + $arr_points[menge], seedbonus = '$seedbonus', bonuscomment = '$bonuscomment' WHERE id = '$userid'") or sqlerr(__FILE____LINE__);
header("Refresh: 0; url='{$TBDEV['baseurl']}/mybonus.php?up_success=1&amt=$points'");
die;
 break;
case 
'traffic2':
case 
'ratio':
//=== trade for one torrent 1:1 ratio
$torrent_number $_POST['torrent_id'];
$res_snatched mysql_query("SELECT s.uploaded, s.downloaded, t.name FROM snatched AS s LEFT JOIN torrents AS t ON t.id = s.torrentid WHERE s.userid = '$userid' AND torrentid = ".sqlesc($torrent_number)." LIMIT 1") or sqlerr(__FILE____LINE__);
$arr_snatched mysql_fetch_assoc($res_snatched);
if (
$arr_snatched['name'] == '')
stderr("{$lang['bonus_error_msg']}""{$lang['bonus_notorrent_msg']}");
if (
$arr_snatched['uploaded'] >= $arr_snatched['downloaded'])
stderr("{$lang['bonus_error_msg']}""{$lang['bonus_fineratio_msg']}");
mysql_query("UPDATE snatched SET uploaded = '$arr_snatched[downloaded]' WHERE userid = '$userid' AND torrentid = ".sqlesc($torrent_number)) or sqlerr(__FILE____LINE__);
$difference $arr_snatched['downloaded'] - $arr_snatched['uploaded'];
$bonuscomment get_datetime(), 'DATE') . " - " .$points" Points for 1 to 1 ratio on torrent: ".$arr_snatched['name']." ".$torrent_number.", ".$difference." added .\n " .$bonuscomment;
mysql_query("UPDATE users SET uploaded = $upload + $difference, bonuscomment = '$bonuscomment', seedbonus = '$seedbonus' WHERE id = '$userid'") or sqlerr(__FILE____LINE__);
header("Refresh: 0; url='{$TBDEV['baseurl']}/mybonus.php?ratio_success=1'");
die;
 break;
 case 
'class':
//=== trade for one month VIP status 
if ($CURUSER['class'] > UC_VIP)
stderr("{$lang['bonus_error_msg']}""{$lang['bonus_lower_msg']}");
$vip_until = (86400 28 time());
$bonuscomment get_datetime(), 'DATE') . " - " .$points" Points for 1 month VIP Status.\n " .$bonuscomment;
mysql_query("UPDATE users SET class = ".UC_VIP.", vip_added = 'yes', vip_until = '$vip_until', seedbonus = '$seedbonus', bonuscomment = '$bonuscomment' WHERE id = '$userid'") or sqlerr(__FILE____LINE__);
header("Refresh: 0; url='{$TBDEV['baseurl']}/mybonus.php?class_success=1'");
die;
 break;
 case 
'warning':
//=== trade for removal of warning
if ($CURUSER['warned'] == 'no')
stderr("{$lang['bonus_error_msg']}""{$lang['bonus_notthere_msg']}");
$bonuscomment get_datetime(), 'DATE') . " - " .$points" Points for removing warning.\n " .$bonuscomment;
$res_warning mysql_query("SELECT modcomment FROM users WHERE id = '$userid'") or sqlerr(__FILE____LINE__);
$arr mysql_fetch_assoc($res_warning);
$modcomment htmlspecialchars($arr['modcomment']);
$modcomment get_datetime(), 'DATE') . " - Warning removed by - Bribe with Karma.\n"$modcomment;
$modcom sqlesc($modcomment);
mysql_query("UPDATE users SET warned = 'no', warneduntil = '0', seedbonus = '$seedbonus', bonuscomment = '$bonuscomment', modcomment = $modcom WHERE id = '$userid'") or sqlerr(__FILE____LINE__);
$dt sqlesc(time());
$subject sqlesc("Warning removed by Karma.");
$msg sqlesc("Your warning has been removed by the big Karma payoff... Please keep on your best behaviour from now on.\n");
mysql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $userid$dt$msg$subject)") or sqlerr(__FILE____LINE__);
header("Refresh: 0; url='{$TBDEV['baseurl']}/mybonus.php?warning_success=1'");
die;
 break;
 case 
'smile':
//=== trade for one month special smilies
$smile_until = (86400 28 time());
$bonuscomment get_datetime(), 'DATE') . " - " .$points" Points for 1 month of custom smilies.\n " .$bonuscomment;
mysql_query("UPDATE users SET smile_until = '$smile_until', seedbonus = '$seedbonus', bonuscomment = '$bonuscomment' WHERE id = '$userid'") or sqlerr(__FILE____LINE__);
header("Refresh: 0; url='{$TBDEV['baseurl']}/mybonus.php?smile_success=1'");
die;
 break;
 case 
'invite':
//=== trade for invites
$invites $CURUSER['invites'];
$inv $invites+$arr_points['menge'];
$bonuscomment get_datetime(), 'DATE') . " - " .$points" Points for invites.\n " .$bonuscomment;
mysql_query("UPDATE users SET invites = '$inv', seedbonus = '$seedbonus', bonuscomment = '$bonuscomment' WHERE id = '$userid'") or sqlerr(__FILE____LINE__);
header("Refresh: 0; url='{$TBDEV['baseurl']}/mybonus.php?invite_success=1'");
die;
 break;
 case 
'title':
//=== trade for special title
/**** the $words array are words that you DO NOT want the user to have... use to filter "bad words" & user class...
the user class is just for show, but what the hell :p Add more or edit to your liking.
*note if they try to use a restricted word, they will recieve the special title "I just wasted my karma" *****/

$title htmlentities(sqlesc($_POST['title']));
$words = array('fuck''shit''Moderator''Administrator''Admin''pussy''Sysop''cunt''nigger''VIP''Super User''Power User''ADMIN''SYSOP''MODERATOR''ADMINISTRATOR');
$title str_replace($words"I just wasted my karma"$title);
$bonuscomment get_datetime(), 'DATE') . " - " .$points" Points for custom title. Old title was $CURUSER[title] new title is ".$title.".\n " .$bonuscomment;
mysql_query("UPDATE users SET title = '$title', seedbonus = '$seedbonus', bonuscomment = '$bonuscomment' WHERE id = '$userid'") or sqlerr(__FILE____LINE__);
header("Refresh: 0; url='{$TBDEV['baseurl']}/mybonus.php?title_success=1'");
die;
 break;
 case 
'gift_1':
//=== trade for giving the gift of karma
$points $_POST['bonusgift'];
$usernamegift htmlentities(trim($_POST['username']));
$res mysql_query("SELECT id,seedbonus,bonuscomment,username FROM users WHERE username=" sqlesc($usernamegift));
$arr mysql_fetch_assoc($res);
$useridgift $arr['id'];
$userseedbonus $arr['seedbonus'];
$bonuscomment_gift $arr['bonuscomment'];
$usernamegift $arr['username'];

$check_me = array(100,200,300,400,500,666);
if (!
in_array($points$check_me))
stderr("{$lang['bonus_error_msg']}""{$lang['bonus_rat_msg']}");

if(
$bonus >= $points){
$pointshtmlspecialchars($points,1);
$bonuscomment get_datetime(), 'DATE') . " - " .$points" Points as gift to $usernamegift .\n " .$bonuscomment;
$bonuscomment_gift get_datetime(), 'DATE') . " - recieved " .$points" Points as gift from $CURUSER[username] .\n " .$bonuscomment_gift;
$seedbonus=$bonus-$points;
$giftbonus1=$userseedbonus+$points;
if (
$userid==$useridgift){
header("Refresh: 0; url='{$TBDEV['baseurl']}/mybonus.php?gift_fail=1'");
die;
}
if (!
$useridgift){
header("Refresh: 0; url='{$TBDEV['baseurl']}/mybonus.php?gift_fail_user=1'");
die;
}
mysql_query("SELECT bonuscomment,id FROM users WHERE id = '$useridgift'") or sqlerr(__FILE____LINE__);
//=== and to post to the person who gets the gift!
mysql_query("UPDATE users SET seedbonus = '$seedbonus', bonuscomment = '$bonuscomment' WHERE id = '$userid'") or sqlerr(__FILE____LINE__);
mysql_query("UPDATE users SET seedbonus = '$giftbonus1', bonuscomment = '$bonuscomment_gift' WHERE id = '$useridgift'");
//===send message
$subject sqlesc("Someone Loves you");
$added sqlesc(time());
$msg sqlesc("You have been given a gift of $points Karma points by ".$CURUSER['username']);
mysql_query("INSERT INTO messages (sender, subject, receiver, msg, added) VALUES(0, $subject$useridgift$msg$added)") or sqlerr(__FILE____LINE__);
header("Refresh: 0; url='{$TBDEV['baseurl']}/mybonus.php?gift_success=1&gift_amount_points=$points&usernamegift=$usernamegift&gift_id=$useridgift'");
die;
}
else{
header("Refresh: 0; url='{$TBDEV['baseurl']}/mybonus.php?gift_fail_points=1'");
die;
}
break;
}
}

//==== this is the default page
$HTMLOUT .="<div class='roundedCorners' style='text-align:left;width:80%;border:1px solid black;padding:5px;'>
<div style='background:transparent;height:25px;'>
<span style='font-weight:bold;font-size:12pt;'>
{$lang['bonus_system']}</span></div>";

$HTMLOUT .="<table align='center' width='100%' border='1' cellspacing='0' cellpadding='5'>
<tr>
<td align='center' colspan='4' style='background:transparent;height:25px;'>
{$lang['bonus_exchangepoints']}".$bonus."{$lang['bonus_goodies']}
<br /><br />
{$lang['bonus_no_buttons']}<br /><br />
</td>
</tr>
<tr>
<td style='background:transparent;height:25px;' align='left'>
{$lang['bonus_head_descr']}</td>
<td style='background:transparent;height:25px;' align='center'>
{$lang['bonus_head_points']}</td>
<td style='background:transparent;height:25px;' align='center'>
{$lang['bonus_head_trade']}</td></tr>";

$res mysql_query("SELECT * FROM bonus ORDER BY id ASC");
while (
$gets mysql_fetch_assoc($res)){
//=======change colors
$count1='';
$count1= (++$count1)%2;
$class 'clearalt'.($count1==0?'6':'7');
$otheroption "<table align='center' width='100%'>
<tr>
<td class='"
.$class."'><b>{$lang['bonus_op_username']}</b>
<input type='text' name='username' size='20' maxlength='24' /></td>
<td class='"
.$class."'> <b>{$lang['bonus_op_given']}</b>
<select name='bonusgift'> 
<option value='100.0'> 100.0</option> 
<option value='200.0'> 200.0</option> 
<option value='300.0'> 300.0</option> 
<option value='400.0'> 400.0</option>
<option value='500.0'> 500.0</option>
<option value='666.0'> 666.0</option></select>
{$lang['bonus_op_karma']}</td></tr></table>";


switch (
true){
    case (
$gets['id'] == 5):
    
$HTMLOUT .="<tr><td align='left' class='".$class."'><form action='{$TBDEV['baseurl']}/mybonus.php?exchange=1' method='post'><input type='hidden' name='option' value='".$gets['id']."' /> <input type='hidden' name='art' value='".$gets['art']."' /><h1><font color='#CECFF3'>".$gets['bonusname']."</font></h1>".$gets['description']."<br /><br />{$lang['bonus_op_title']}<input type='text' name='title' size='30' maxlength='30' />{$lang['bonus_op_click']}</td><td align='center' class='".$class."'>".$gets['points']."</td>";
break;
 case (
$gets['id'] == 7):
  
$HTMLOUT .="<tr><td align='left' class='".$class."'><form action='{$TBDEV['baseurl']}/mybonus.php?exchange=1' method='post'><input type='hidden' name='option' value='".$gets['id']."' /> <input type='hidden' name='art' value='".$gets['art']."' /><h1><font color='#CECFF3'>".$gets['bonusname']."</font></h1>".$gets['description']."<br /><br />{$lang['bonus_op_username2']}<br />".$otheroption."</td><td align=center class='".$class."'>{$lang['bonus_op_min']}<br />".$gets['points']."<br />{$lang['bonus_op_max']}<br />666</td>";
break;
 case (
$gets['id'] == 9):
  
$HTMLOUT .="<tr><td align='left' class='".$class."'><form action='{$TBDEV['baseurl']}/mybonus.php?exchange=1' method='post'><input type='hidden' name='option' value='".$gets['id']."' /> <input type='hidden' name='art' value='".$gets['art']."' /><h1><font color='#CECFF3'>".$gets['bonusname']."</font></h1>".$gets['description']."</td><td align='center' class='".$class."'>{$lang['bonus_op_min']}<br />".$gets['points']."</td>";
break;
 case (
$gets['id'] == 10):
  
$HTMLOUT .="<tr><td align='left' class='".$class."'><form action='{$TBDEV['baseurl']}/mybonus.php?exchange=1' method='post'><input type='hidden' name='option' value='".$gets['id']."' /> <input type='hidden' name='art' value='".$gets['art']."' /><h1><font color='#CECFF3'>".$gets['bonusname']."</font></h1>".$gets['description']."<br /><br />{$lang['bonus_op_idnum']}<input type='text' name='torrent_id' size='4' maxlength='8' />{$lang['bonus_op_idnum2']}</td><td align='center' class='".$class."'>{$lang['bonus_op_min']}<br />".$gets['points']."</td>";
break;
default:
  
$HTMLOUT .="<tr><td align='left' class='".$class."'><form action='{$TBDEV['baseurl']}/mybonus.php?exchange=1' method='post'><input type='hidden' name='option' value='".$gets['id']."' /> <input type='hidden' name='art' value='".$gets['art']."' /><h1><font color='#CECFF3'>".$gets['bonusname']."</font></h1>".$gets['description']."</td><td align='center' class='".$class."'>".$gets['points']."</td>";
}

if(
$bonus >= $gets['points']) {

switch (
true){
case (
$gets['id'] == 7):
$HTMLOUT .="<td class='".$class."'><input class='button' type='submit' name='submit' value='Karma Gift!' /></td></form>";
break;
default:
$HTMLOUT .="<td class='".$class."'><input class='button' type='submit' name='submit' value='Exchange!' /></td></form>";
}

else 
$HTMLOUT .="<td class='".$class."' align='center'>{$lang['bonus_op_more']}</td></form>";
}

$HTMLOUT .="</tr></table>
 <div style='background:transparent;height:25px;'>
 <span style='font-weight:bold;font-size:12pt;'>
{$lang['bonus_table_hell']}</span></div>
 <table align='center' width='100%'>
  <tr>

  <td class='clearalt6'>
{$lang['bonus_table_rest_of']}
  <div align='center'><br />
  <a class='altlink' href='
{$TBDEV['baseurl']}/index.php'><b>{$lang['bonus_table_go_back']}</b></a></div>
  </td></tr></table></div>"
;

print 
stdhead('Karma Bonus Page') . $HTMLOUT stdfoot();
?>



the above file has all options in it, you will have to remove or alter it to fit your needs...
if you use the buy 1:1 ratio on a torrent, YOU MUST HAVE a snatched mod installed namely the 09 New and Improved Snatchlist, if you use the Recreate Complex Snatchlist then check the querys to be sure that the stuff matches YOUR snatched table... not all snatched tables are created equal!
and to use the invites, be sure to have an invite system installed.. the 09 new and safer number key invite system is, If you use another invite mod check the querys to be sure they match...

now in your cleanup.php you'll need some stuff added:

under this:
Code (php) Select
if (count($update))
@mysql_query("UPDATE torrents SET " . implode(",", $update) . " WHERE id = $id");
}



add:
Code (php) Select
// === Update karma seeding bonus... made nicer by devinkray
      // ==   Updated and optimized by pdq
      // === using this will work for multiple torrents UP TO 5!... change the 5 to whatever... 1 to give the karma for only 1 torrent at a time, or 100 to make it unlimited (almost) your choice
      // /======seeding bonus per torrent
      $res = mysql_query('SELECT COUNT(torrent) As tcount, userid FROM peers WHERE seeder =\'yes\' GROUP BY userid') or sqlerr(__FILE__, __LINE__);
      if (mysql_num_rows($res) > 0) {
        while ($arr = mysql_fetch_assoc($res)) {
            if ($arr['tcount'] >= 1000)
                $arr['tcount'] = 5;
            $users_buffer[] = '(' . $arr['userid'] . ',0.225 * ' . $arr['tcount'] . ')';
        }
        if (sizeof($users_buffer) > 0) {
            mysql_query("INSERT INTO users (id,seedbonus) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE seedbonus=seedbonus+values(seedbonus)") or sqlerr(__FILE__, __LINE__);
            $count = mysql_affected_rows();
            write_log("Cleanup - " . $count / 2 . " users received seedbonus");
        }
        unset ($users_buffer);
    }



if you use the custom smilies... still in cleanup.php add:
Code (php) Select
// === Updated remove custom smilies by Bigjoos:)
    $res = mysql_query("SELECT id FROM users WHERE smile_until < ".TIME_NOW." AND smile_until <> '0'") or sqlerr(__FILE__, __LINE__);
    $msgs_buffer = $users_buffer = array();
    if (mysql_num_rows($res) > 0) {
        $subject = "Custom smilies expired.";
        $msg = "Your Custom smilies have timed out and has been auto-removed by the system. If you would like to have them again, exchange some Karma Bonus Points again. Cheers!\n";
        while ($arr = mysql_fetch_assoc($res)) {
            $modcomment = sqlesc(get_date( time(), 'DATE', 1 ) . " - Custom smilies Automatically Removed By System\n");
            $msgs_buffer[] = '(0,' . $arr['id'] . ','.time().', ' . sqlesc($msg) . ', ' . sqlesc($subject) . ' )';
            $users_buffer[] = '(' . $arr['id'] . ', \'0\', ' . $modcomment . ')';
        }
        if (sizeof($msgs_buffer) > 0) {
            mysql_query("INSERT INTO messages (sender,receiver,added,msg,subject) VALUES " . implode(', ', $msgs_buffer)) or sqlerr(__FILE__, __LINE__);
            mysql_query("INSERT INTO users (id, smile_until, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE smile_until=values(smile_until),
modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__);
        $count = mysql_affected_rows();
        write_log("Cleanup - Removed Custom smilies from " . $count / 2 . " members");
        }
        unset ($users_buffer);
        unset ($msgs_buffer);
    }



and finally - remove Karma vip:
Code (php) Select
// === Updated remove karma vip by Bigjoos - change class number '1' in the users_buffer to whatever is under your vip class number
    $res = mysql_query("SELECT id, modcomment FROM users WHERE vip_added='yes' AND vip_until < ".TIME_NOW."") or sqlerr(__FILE__, __LINE__);
    $msgs_buffer = $users_buffer = array();
    if (mysql_num_rows($res) > 0) {
         $subject = "VIP status expired.";
         $msg = "Your VIP status has timed out and has been auto-removed by the system. Become a VIP again by donating to {$TBDEV['site_name']} , or exchanging some Karma Bonus Points. Cheers !\n";
         while ($arr = mysql_fetch_assoc($res)) {
            $modcomment = sqlesc(get_date( time(), 'DATE', 1 ) . " - Vip status Automatically Removed By System\n");
            $msgs_buffer[] = '(0,' . $arr['id'] . ','.time().', ' . sqlesc($msg) . ', ' . sqlesc($subject) . ')';
            $users_buffer[] = '(' . $arr['id'] . ',1, \'no\', \'0\' , ' . $modcomment . ')';
        }
        if (sizeof($msgs_buffer) > 0) {
            mysql_query("INSERT INTO messages (sender,receiver,added,msg,subject) VALUES " . implode(', ', $msgs_buffer)) or sqlerr(__FILE__, __LINE__);
            mysql_query("INSERT INTO users (id, class, vip_added, vip_until, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE class=values(class),
vip_added=values(vip_added),vip_until=values(vip_until),modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__);
        $count = mysql_affected_rows();
        write_log("Cleanup - Karma Vip status expired on - " . $count / 2 . " Member(s)");
        }
        unset ($users_buffer);
        unset ($msgs_buffer);
    }



now for the custom smilies to work, you'll be needing to have some BBcode... in include/bbcode_functions.php ==> Skip this step if you have the 09 textbbcode installed:
:

change the format_comment function global:
Code (php) Select
global $smilies, $TBDEV;


to
Code (php) Select
global $smilies, $customsmilies, $TBDEV;



Add this further down before your textbbcode function :
Code (php) Select
//=== smilie function
function get_smile()
{
global $CURUSER;
return $CURUSER["smile_until"];
}



At the very top of your bbcode_function under , like : ==> Skip this step if you have the 09 textbbcode installed:
Code (php) Select
function textbbcode($form,$text,$content="") {


add this :
Code (php) Select
$custombutton = '';
$smilebutton = '';
if(get_smile() != '0')
$custombutton .="<a href=javascript:PopCustomSmiles('shbox','shbox_text')>[ Custom Smilies ]</a>\n";
$smilebutton = "<a href=javascript:PopMoreSmiles('shbox','shbox_text')>[ More Smilies ]</a>\n";



at the bottom of your bbcode function after the last smilie : ==> Skip this step if you have the 09 textbbcode installed:
Code (php) Select
<td align="center"><a href="javascript:em(':shifty:');" ><img border="0" alt=" " src="pic/smilies/shifty.gif" width="20" height="20" /></a></td>


add this:
Code (php) Select
<span style='font-weight:bold;font-size:7pt;'><?php echo $smilebutton ?></span>
<span style='font-weight:bold;font-size:7pt;'><?php echo $custombutton ?></span>



find - more and likely where your shoutbox display is or in your format_comment function ?: ==> Skip this step if you have the 09 textbbcode installed:
function PopMoreSmiles(form,name) {
     link='moresmiles.php?form='+form+'&text='+name
     newWin=window.open(link,'moresmile','height=500,width=800,resizable=yes,scrollbars=yes');
     if (window.focus) {newWin.focus()}
}



after it add:
Code (php) Select
//=== custom smilies
function PopCustomSmiles(form,name) {
     link='moresmilies_custom.php?form='+form+'&text='+name
     newWin=window.open(link,'moresmile','height=600,width=400,resizable=yes,scrollbars=yes');
     if (window.focus) {newWin.focus()}
}




in your format comment function (still in include/bbcode_functions.php) find ==> Skip this step if you have the 09 textbbcode installed:
Code (php) Select
foreach($smilies as $code => $url) {
$s = str_replace($code, "<img border='0' src=\"{$TBDEV['pic_base_url']}smilies/{$url}\" alt=\"" . htmlspecialchars($code) . "\" />", $s);
}
return $s;
}



change to:
Code (php) Select
foreach($smilies as $code => $url) {
$s = str_replace($code, "<img border='0' src=\"{$TBDEV['pic_base_url']}smilies/{$url}\" alt=\"" . htmlspecialchars($code) . "\" />", $s);
}
foreach($customsmilies as $code => $url) {
$s = str_replace($code, "<img border='0' src=\"{$TBDEV['pic_base_url']}smilies/{$url}\" alt=\"" . htmlspecialchars($code) . "\" />", $s);
}
return $s;
}



now add this to include/emoticons.php then add your smilies to each array same as $smilies array ==> Skip this step if you have the 09 textbbcode installed :
Code (php) Select
$customsmilies = array( 
":clown:" => "clown.gif",
  );



now you may need need a file called moresmiles.php:
Code (php) Select
<?php
require_once("include/bittorrent.php");
require_once 
ROOT_PATH.'/include/bbcode_functions.php';
dbconn(false);
$lang array_mergeload_language('global'));

loggedinorreturn();

      
$htmlout '';
    
$htmlout "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
      \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
      <html xmlns='http://www.w3.org/1999/xhtml'>
      <head>
    <meta name='generator' content='TBDev.net' />
     <meta name='MSSmartTagsPreventParsing' content='TRUE' />
      <title>More Smilies</title>
    <link rel='stylesheet' href='./1.css' type='text/css' />
    </head>
    <body>
    <script type='text/javascript'>
    function SmileIT(smile,form,text){
    window.opener.document.forms[form].elements[text].value = window.opener.document.forms[form].elements[text].value+' '+smile+' ';
    window.opener.document.forms[form].elements[text].focus();
    window.close();
    }
    </script>
    <table class='list' width='100%' cellpadding='1' cellspacing='1'>"
;
    
$count='';
    while ((list(
$code$url) = each($smilies))) {
    if (
$count == 0)
    
$htmlout .= " \n<tr>";
    
$htmlout .= "\n\t<td class=\"list\" align=\"center\"><a href=\"javascript: SmileIT('" str_replace("'""\'"$code) . "','" htmlspecialchars($_GET["form"]) . "','" htmlspecialchars($_GET["text"]) . "')\"><img border='0' src='./pic/smilies/" $url "' alt='' /></a></td>";
    
$count++;
    if (
$count == 0)
    
$htmlout .= "\n</tr>";
    }
    
$htmlout .= "</tr></table><div align='center'><a href='javascript: window.close()'>[ Close Window ]</a></div></body></html>";

print 
$htmlout;



and you'll need a file called moresmilies_custom.php:
Code (php) Select
<?php
require_once("include/bittorrent.php");
require_once 
ROOT_PATH.'/include/bbcode_functions.php';
require_once 
ROOT_PATH.'/include/user_functions.php';
dbconn(false);
loggedinorreturn();

$lang array_mergeload_language('global'));

if(
$CURUSER['smile_until'] == '0')
stderr("Error""you do not have access!"); 

    
$htmlout '';
    
$htmlout "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
      \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
      <html xmlns='http://www.w3.org/1999/xhtml'>
      <head>
    <meta name='generator' content='TBDev.net' />
     <meta name='MSSmartTagsPreventParsing' content='TRUE' />
      <title>Custom Smilies</title>
    <link rel='stylesheet' href='./1.css' type='text/css' />
    </head>
    <body>
    <script type='text/javascript'>
    function SmileIT(smile,form,text){
    window.opener.document.forms[form].elements[text].value = window.opener.document.forms[form].elements[text].value+' '+smile+' ';
    window.opener.document.forms[form].elements[text].focus();
    window.close();
    }
    </script>
    <table class='list' width='100%' cellpadding='1' cellspacing='1'>"
;
    
$count 0;
    
$ctr 0;
    global 
$customsmilies;
while ((list(
$code$url) = each($customsmilies))) {
    if (
$count 3==0)
      
$htmlout .= "<tr>";
      
$htmlout .= "<td align='center'><a href=\"javascript: SmileIT('".str_replace("'","\'",$code)."','".htmlspecialchars($_GET['form'])."','".htmlspecialchars($_GET['text'])."')\"><img border='0' src='./pic/smilies/".$url."' alt='' /></a></td>";
      
$count++;

   if (
$count 3==0)
   
$htmlout .= "</tr>";
   }
   
$htmlout .= "</tr></table><br /><div align='center'><a class='altlink' href='javascript: window.close()'><b>[ Close window ]</b></a></div></body></html>";
   print 
$htmlout;



if you want to show their points on their user page, add it in userdetails.php wherever you want:
Code (php) Select
$HTMLOUT .= "<tr><td class='rowhead'>{$lang['userdetails_bonus_points']}</td><td align='left'>".(int)$user['seedbonus']."</td></tr>";


and just below modcomment in userdetails.php add:
Code (php) Select
//=== bonus comment
    $bonuscomment = htmlspecialchars($user["bonuscomment"]);
    $HTMLOUT .= "<tr><td class='rowhead'>{$lang['userdetails_bonus_comment']}</td><td colspan='2' align='left'><textarea cols='60' rows='6' name='bonuscomment' readonly='readonly' style='background:purple;color:yellow;'>$bonuscomment</textarea></td></tr>\n";
    //==end



so staff can give or delete points add this where you want it:
Code (php) Select
if ($CURUSER['class'] >= UC_MODERATOR)
$HTMLOUT .= "<tr><td class='rowhead'>{$lang['userdetails_bonus_points']}</td><td colspan='2' align='left'><input type='text' size='6' name='seedbonus' value='".(int)$user['seedbonus']."' /></td></tr>";




in lang/en/lang_userdetails.php add:
Code (php) Select
'userdetails_bonus_comment' => "Bonus Comment",
'userdetails_bonus_points' => "Karma points",



in modtask add:
Code (php) Select
//=== karma bonus
      if ((isset($_POST['seedbonus'])) && (($seedbonus = $_POST['seedbonus']) != $user['seedbonus']))
     {
     $modcomment = get_date( time(), 'DATE', 1 ) . " - Seeding bonus set to $seedbonus by " . $CURUSER['username'] . ".\n" . $modcomment;
     $updateset[] = "seedbonus = " . sqlesc($seedbonus);
     }
     // == end



now for adding or removing Karma Bonus Points for doing stuff... change the point amount to whatever you like.

for uploading a new torrent = 15 points
in takeupload.php just after
Code (php) Select
move_uploaded_file($tmpname, "{$TBDEV['torrent_dir']}/$id.torrent");


add:
Code (php) Select
//===add karma
mysql_query("UPDATE users SET seedbonus = seedbonus+15.0 WHERE id = ".sqlesc($CURUSER["id"])."") or sqlerr(__FILE__, __LINE__);
//===end



and in delete.php just after:
Code (php) Select
write_log("{$lang['delete_torrent']} $id ({$row['name']}){$lang['delete_deleted_by']}{$CURUSER['username']} ($reasonstr)\n");


add:
Code (php) Select
//===remove karma
mysql_query("UPDATE users SET seedbonus = seedbonus-15.0 WHERE id = ".sqlesc($row["owner"])."") or sqlerr(__FILE__, __LINE__);
//===end



for comment on torrent = 3 points
in comment.php just after
Code (php) Select
@mysql_query("UPDATE torrents SET comments = comments + 1 WHERE id = $torrentid");


add:
Code (php) Select
//===add karma
mysql_query("UPDATE users SET seedbonus = seedbonus+3.0 WHERE id = ".sqlesc($CURUSER["id"])."") or sqlerr(__FILE__, __LINE__);
//===end




also in comment.php just after:
Code (php) Select
mysql_query("UPDATE torrents SET comments = comments - 1 WHERE id = $torrentid");


add:
Code (php) Select
//===Remove karma
mysql_query("UPDATE users SET seedbonus = seedbonus-3.0 WHERE id = ".sqlesc($owner["id"])."") or sqlerr(__FILE__, __LINE__);
//===end



for saying thanks = 2 points - several versions of this adapt yours if you need to

find in takethankyou.php:
Code (php) Select
mysql_query("UPDATE torrents SET thanks = thanks + 1 WHERE id = ".sqlesc($id)."");


add under it:
Code (php) Select
mysql_query("UPDATE users SET seedbonus = seedbonus+5.0 WHERE id = ".sqlesc($CURUSER["id"])."") or sqlerr(__FILE__, __LINE__);


Or for putyns new thanks mod find :
Code (php) Select
print($ajax? json_encode(array('status'=>false,'err'=>$msg)) : $msg);
}
}
}
break;
}