09 Donation Progress

Started by Mindless, July 20, 2012, 08:30:50 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Daniel

thanks now it works and also i was importing in the wrong database Lol  , wich i have deletedet now so i dont make the same mistake again its bad to  make sql late Lol
Quote from: MAST3R on July 21, 2012, 08:16:22 AM
change this
$dt = sqlesc(time - $secs);

with this, maibe work
$dt = sqlesc(time() - $secs);
or
$dt = sqlesc(TIME_NOW - $secs);

MAST3R

change this
$dt = sqlesc(time - $secs);

with this, maibe work
$dt = sqlesc(time() - $secs);
or
$dt = sqlesc(TIME_NOW - $secs);

Daniel

#5
apparentley get an error to at  index.php

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /var/www/index.php on line 184

above is that some thing with my php settings ?

what bothers me is after i addet your index.php code the cache one  i get an error if you look at my site
the one u have i need and mysql in order to make it work mindless works fine
http://tracker.sourcebook.eu

my index.php look like this

<?php
/*
+------------------------------------------------
|   TBDev.net BitTorrent Tracker PHP
|   =============================================
|   by CoLdFuSiOn
|   (c) 2003 - 2009 TBDev.Net
|   http://www.tbdev.net
|   =============================================
|   svn: http://sourceforge.net/projects/tbdevnet/
|   Licence Info: GPL
+------------------------------------------------
|   $Date$
|   $Revision$
|   $Author$
|   $URL$
+------------------------------------------------
*/
ob_start("ob_gzhandler");
//==Start memcache
require_once('include/class_cache.php');
require_once 
"include/bittorrent.php";
require_once 
"include/user_functions.php";
$mc1 = NEW CACHE();
dbconn(true);



    
$lang array_mergeload_language('global'), load_language('index') );
    
//$lang = ;
    
    
$HTMLOUT '';
/*
$a = @mysql_fetch_assoc(@mysql_query("SELECT id,username FROM users WHERE status='confirmed' ORDER BY id DESC LIMIT 1")) or die(mysql_error());
if ($CURUSER)
  $latestuser = "<a href='userdetails.php?id=" . $a["id"] . "'>" . $a["username"] . "</a>";
else
  $latestuser = $a['username'];
*/

 //==Stats Begin
    
$cache_stats "./cache/stats.txt";
    
$cache_stats_life 60// 5min
    
if (file_exists($cache_stats) && is_array(unserialize(file_get_contents($cache_stats))) && (time() - filemtime($cache_stats)) < $cache_stats_life)
    
$row unserialize(@file_get_contents($cache_stats));
    else {
    
$stats mysql_query("SELECT *, seeders + leechers AS peers, seeders / leechers AS ratio, unconnectables / (seeders + leechers) AS ratiounconn FROM stats WHERE id = '1' LIMIT 1") or sqlerr(__FILE____LINE__);
    
$row mysql_fetch_assoc($stats);
    
$handle fopen($cache_stats"w+");
    
fwrite($handleserialize($row));
    
fclose($handle);
    }

    
$seeders number_format($row['seeders']);
    
$leechers number_format($row['leechers']);
    
$registered number_format($row['regusers']);
    
$unverified number_format($row['unconusers']);
    
$torrents number_format($row['torrents']);
    
$torrentstoday number_format($row['torrentstoday']);
    
$ratiounconn $row['ratiounconn'];
    
$unconnectables $row['unconnectables'];
    
$ratio round(($row['ratio'] * 100));
    
$peers number_format($row['peers']);
    
$numactive number_format($row['numactive']);
    
$donors number_format($row['donors']);
    
$forumposts number_format($row['forumposts']);
    
$forumtopics number_format($row['forumtopics']);
    
//==End


    //stdhead();
    //$HTMLOUT .= "<div class='roundedCorners'><font class='small''>Welcome to our newest member, <b>$latestuser</b>!</font></div>\n";

    
$adminbutton '';
    
    if (
get_user_class() >= UC_ADMINISTRATOR)
          
$adminbutton "&nbsp;<span style='float:right;'><a href='admin.php?action=news'>News page</a></span>\n";
          
    
$HTMLOUT .= "<div style='text-align:center;width:100%;'>
    <div style='background:#00345B;color:#6c0000;height:25px;'><span style='font-weight:bold;font-size:12pt;'>
{$lang['news_title']}</span>{$adminbutton}</div><br />";
      
    
$res mysql_query("SELECT * FROM news WHERE added + ( 3600 *24 *45 ) >
	
	
	
	
	
"
.time()." ORDER BY added DESC LIMIT 10") or sqlerr(__FILE____LINE__);
	
	
	
	
	

    if (
mysql_num_rows($res) > 0)
    {
      require_once 
"include/bbcode_functions.php";

      
$button "";
      
      while(
$array mysql_fetch_assoc($res))
      {
        if (
get_user_class() >= UC_ADMINISTRATOR)
        {
          
$button "<div style='float:right;'><a href='admin.php?action=news&amp;mode=edit&amp;newsid={$array['id']}'>{$lang['news_edit']}</a>&nbsp;<a href='admin.php?action=news&amp;mode=delete&amp;newsid={$array['id']}'>{$lang['news_delete']}</a></div>";
        }
        
        
$HTMLOUT .= "<div style='background:height:20px;'><span style='font-weight:bold;font-size:10pt;'>{$array['headline']}</span></div>\n";
        
        
$HTMLOUT .= "<span style='color:grey;font-weight:bold;text-decoration:underline;'>".get_date$array['added'],'DATE') . "</span>{$button}\n";
        
        
$HTMLOUT .= "<div style='margin-top:10px;padding:5px;'>".format_comment($array['body'])."</div>\n";
        
      
      }
     
    }

    
$HTMLOUT .= "</div><br />\n";


$HTMLOUT .="<div class='roundedCorners' style='text-align:center;width:100%;border:0px solid black;padding:5px;'>
   <div style='background:#00345B;color:#6c0000;height:25px;'><span style='font-weight:bold;font-size:12pt;'>
{$lang['index_stats_title']}</span></div><br />
   <table width='100%' border='1' cellspacing='0' cellpadding='10'><tr><td align='center'>
   <table class='main' border='1' cellspacing='0' cellpadding='5'>
   <tr>
    <td class='rowhead'>
{$lang['index_stats_regged']}</td><td align='right'>{$registered}/{$TBDEV['maxusers']}</td>
    <td class='rowhead'>
{$lang['index_stats_online']}</td><td align='right'>{$numactive}</td>
   </tr>
   <tr>
    <td class='rowhead'>
{$lang['index_stats_uncon']}</td><td align='right'>{$unverified}</td>
    <td class='rowhead'>
{$lang['index_stats_donor']}</td><td align='right'>{$donors}</td>
   </tr>
   <tr>
    <td colspan='4'> </td>
   </tr>
   <tr>
    <td class='rowhead'>
{$lang['index_stats_topics']}</td><td align='right'>{$forumtopics}</td>
    <td class='rowhead'>
{$lang['index_stats_torrents']}</td><td align='right'>{$torrents}</td>
   </tr>
   <tr>
   <td class='rowhead'>
{$lang['index_stats_posts']}</td><td align='right'>{$forumposts}</td>
    <td class='rowhead'>
{$lang['index_stats_newtor']}</td><td align='right'>{$torrentstoday}</td>
   </tr>
   <tr>
   <td colspan='4'> </td>
   </tr>
   <tr>
    <td class='rowhead'>
{$lang['index_stats_peers']}</td><td align='right'>{$peers}</td>
    <td class='rowhead'>
{$lang['index_stats_unconpeer']}</td><td align='right'>{$unconnectables}</td>
   </tr>
   <tr>
    <td class='rowhead'>
{$lang['index_stats_seeders']}</td><td align='right'>{$seeders}</td>
    <td class='rowhead' align='right'><b>
{$lang['index_stats_unconratio']}</b></td><td align='right'><b>".round($ratiounconn 100)."</b></td>
   </tr>
   <tr>
    <td class='rowhead'>
{$lang['index_stats_leechers']}</td><td align='right'>{$leechers}</td>
    <td class='rowhead'>
{$lang['index_stats_slratio']}</td><td align='right'>{$ratio}</td>
   </tr></table></td></tr></table></div><br />"
;
   
//latest torrents [see limit on config]
        
$HTMLOUT .= "<div style='text-align:center;width:80%;border:0px solid blue;padding:5px;'>
        <div style='background:#00345B;height:25px;'><span style='font-weight:bold;font-size:12pt;'>
{$lang['latesttorrents_title']}</span></div><br />";
 
$res mysql_query("SELECT t.id, t.name, t.category, t.seeders, t.leechers, c.name AS cat_name, c.image AS cat_img ".
 
"FROM torrents AS t ".
 
"LEFT JOIN categories AS c ON c.id = t.category ".
 
"WHERE t.visible='yes' ".
 
"ORDER BY t.added DESC LIMIT {$TBDEV['latest_torrents_limit']}") or sqlerr(__FILE____LINE__);
if (
mysql_num_rows($res) > 0)
{
$HTMLOUT .= "<table width='100%' cellspacing='0' cellpadding='5'><tr>
<td class='colhead' align='center' width='1%'>
{$lang['latesttorrents_type']}</td>
<td class='colhead' align='center'>
{$lang['latesttorrents_name']}</td>
<td class='colhead' align='center' width='1%'>
{$lang['latesttorrents_seeders']}</td>
<td class='colhead' align='center' width='1%'>
{$lang['latesttorrents_leechers']}</td></tr>";
while(
$arr mysql_fetch_assoc($res))
{
$dispname htmlspecialchars($arr['name']);
$catname htmlspecialchars($arr['cat_name']);
$catpic htmlspecialchars($arr['cat_img']);
 
$HTMLOUT .= "<tr><td align='center' style='padding:0px;'><a href='/browse.php?cat={$arr['category']}'><img border='0' src='{$TBDEV['pic_base_url']}caticons/{$catpic}' alt='{$catname}' /></a></td>
<td align='left'><a href='/details.php?id=
{$arr['id']}&amp;hit=1' title='{$dispname}'><b>{$dispname}</b></a></td>
<td align='center'>
{$arr['seeders']}</td>
<td align='center'>
{$arr['leechers']}</td></tr>";
}
$HTMLOUT .= "</table></div><br />\n";
} else {
// if there are no torrents
$HTMLOUT .= "<div style='text-align:center;border:0px solid blue;background:#00345B;'><span style='font-weight:bold;font-size:10pt;'>{$lang['latesttorrents_no_torrents']}</span></div></div><br />";
}
//====Donation progress by snuggles // Cache the bar also...
	
$cache_funds "./cache/funds.txt";
    
$cache_funds_life 60 60// Hourly
    
if (file_exists($cache_funds) && is_array(unserialize(file_get_contents($cache_funds))) && (time() - filemtime($cache_funds)) < $cache_funds_life)
    
$row unserialize(@file_get_contents($cache_funds));
    else {
    
$funds mysql_query("SELECT sum(cash) as total_funds FROM funds") or sqlerr(__FILE____LINE__);
    
$row mysql_fetch_assoc($funds);
    
$handle fopen($cache_funds"w+");
    
fwrite($handleserialize($row));
    
fclose($handle);
    }
//end latest torrents
/*
<h2>Server load</h2>
<table width='100%' border='1' cellspacing='0' cellpadding='1'0><tr><td align=center>
<table class=main border='0' width=402><tr><td style='padding: 0px; background-image: url("<?php echo $TBDEV['pic_base_url']?>loadbarbg.gif"); background-repeat: repeat-x'>
<?php $percent = min(100, round(exec('ps ax | grep -c apache') / 256 * 100));
if ($percent <= 70) $pic = "loadbargreen.gif";
elseif ($percent <= 90) $pic = "loadbaryellow.gif";
else $pic = "loadbarred.gif";
$width = $percent * 4;
print("<img height='1'5 width=$width src=\"{$TBDEV['pic_base_url']}{$pic}\" alt='$percent%'>"); ?>
</td></tr></table>
</td></tr></table>
*/

  
    
    
$HTMLOUT .= "";

///////////////////////////// FINAL OUTPUT //////////////////////

    
print stdhead('Home') . $HTMLOUT stdfoot();
?>


Quote from: MelvinMeow on July 21, 2012, 12:32:32 AM
Change:
$dt = sqlesc(time - $secs));
To:
$dt = sqlesc(time - $secs);  (Removed the extra ")" .

MelvinMeow

Change:
$dt = sqlesc(time - $secs));
To:
$dt = sqlesc(time - $secs);  (Removed the extra ")" .

Daniel

there is an error in the code below

// ===clear funds after one month
    $secs = 28 * 86400;
    $dt = sqlesc(time - $secs)); <--- that one give me an error what it is i dunno :S
    mysql_query("DELETE FROM funds WHERE added < $dt");
    // ===end
    // === Remove donor status if time is up AND set class back to power user... remember to set the class number for your system in the users_buffer
    //== Donation Progress Mod Updated For Tbdev 2009/2010 by Bigjoos
    $res = mysql_query("SELECT id, modcomment FROM users WHERE donor='yes' AND donoruntil < ".TIME_NOW." AND donoruntil <> '0'") or sqlerr(__FILE__, __LINE__);
    $msgs_buffer = $users_buffer = array();
    if (mysql_num_rows($res) > 0) {
        $subject = "Donor status removed by system.";
        $msg = "Your Donor status has timed out and has been auto-removed by the system, and your Vip status has been removed. We would like to thank you once again for your support to {$TBDEV['site_name']}. If you wish to re-new your donation, Visit the site paypal link. Cheers!\n";
        while ($arr = mysql_fetch_assoc($res)) {
            $modcomment = sqlesc(get_date( time(), 'DATE', 1 ) . " - Donation 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, donor, donoruntil, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE class=values(class),
            donor=values(donor),donoruntil=values(donoruntil),modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__);
            $count = mysql_affected_rows();
            write_log("Cleanup: Donation status expired - " . $count / 2 . " Member(s)");
        }
        unset ($users_buffer);
        unset ($msgs_buffer);
    }
    // ===end===//


MelvinMeow

Caches the bar...  I added this code after you guys started adding all the caching stuff to 09 a few years ago.
//====Donation progress by snuggles // Cache the bar also...
$cache_funds = "./cache/funds.txt";
    $cache_funds_life = 1 * 60 * 60; // Hourly
    if (file_exists($cache_funds) && is_array(unserialize(file_get_contents($cache_funds))) && (time() - filemtime($cache_funds)) < $cache_funds_life)
    $row = unserialize(@file_get_contents($cache_funds));
    else {
    $funds = mysql_query("SELECT sum(cash) as total_funds FROM funds") or sqlerr(__FILE__, __LINE__);
    $row = mysql_fetch_assoc($funds);
    $handle = fopen($cache_funds, "w+");
    fwrite($handle, serialize($row));
    fclose($handle);
    }

Mindless

#1
Quote

'Sir_SnuggleBunny'

Here it is :P a done deal lol
the donation progress mod by snuggles
with a donation progress bar
total donated by user
monthly donated amount in userdetails with a countdown
reset donor status (if they are bad)
add time to donor length if they donate again before the time is up
decimal friendly
and a page to display all donations current and total  :D

also change style to match your site... I use alternating colors a lot, so you will need to either add this to your stylesheets or remove it from the code

cheers,
snuggles

Full credit to snuggs for this one - Thanks to pdq - Elephant2 for advices :)

Reworked And Updated For 09
Xhtml valid

Code (sql) Select
CREATE TABLE `funds` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `cash` decimal(8,2) NOT NULL default '0.00',
  `user` int(10) unsigned NOT NULL default '0',
  `added` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;


Code (sql) Select
ALTER TABLE users ADD `donoruntil` int(11) unsigned NOT NULL default '0';
ALTER TABLE users ADD `donated` decimal(8,2) NOT NULL default '0.00';
ALTER TABLE users ADD `total_donated` decimal(8,2) NOT NULL default '0.00';



@ file include cleanup.php add :

   
Code (php) Select
// ===clear funds after one month
    $secs = 28 * 86400;
    $dt = sqlesc(TIME_NOW - $secs);
    mysql_query("DELETE FROM funds WHERE added < $dt");
    // ===end
    // === Remove donor status if time is up AND set class back to power user... remember to set the class number for your system in the users_buffer
    //== Donation Progress Mod Updated For Tbdev 2009/2010 by Bigjoos
    $res = mysql_query("SELECT id, modcomment FROM users WHERE donor='yes' AND donoruntil < ".TIME_NOW." AND donoruntil <> '0'") or sqlerr(__FILE__, __LINE__);
    $msgs_buffer = $users_buffer = array();
    if (mysql_num_rows($res) > 0) {
        $subject = "Donor status removed by system.";
        $msg = "Your Donor status has timed out and has been auto-removed by the system, and your Vip status has been removed. We would like to thank you once again for your support to {$TBDEV['site_name']}. If you wish to re-new your donation, Visit the site paypal link. Cheers!\n";
        while ($arr = mysql_fetch_assoc($res)) {
            $modcomment = sqlesc(get_date( time(), 'DATE', 1 ) . " - Donation 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, donor, donoruntil, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE class=values(class),
            donor=values(donor),donoruntil=values(donoruntil),modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__);
            $count = mysql_affected_rows();
            write_log("Cleanup: Donation status expired - " . $count / 2 . " Member(s)");
        }
        unset ($users_buffer);
        unset ($msgs_buffer);
    }
    // ===end===//


@ file modtask.php remove :

   
Code (php) Select
// Clear donor - Code not called for setting donor
    if (isset($_POST['donor']) && (($donor = $_POST['donor']) != $user['donor']))
    {
    $updateset[] = "donor = " . sqlesc($donor);
    $updateset[] = "warneduntil = 0";
    if ($donor == 'no')
    {
    $modcomment = get_date( time(), 'DATE', 1 ) . "{$lang['modtask_donor_removed']}".$CURUSER['username'].".\n". $modcomment;
    $msg = sqlesc("{$lang['modtask_donor_expired']}");
    $added = time();
    mysql_query("INSERT INTO messages (sender, receiver, msg, added) VALUES (0, $userid, $msg, $added)") or sqlerr(__FILE__, __LINE__);
    }
    }

    // Set donor - Time based
    if ((isset($_POST['donorlength'])) && ($donorlength = 0 + $_POST['donorlength']))
    {
    if ($donorlength == 255)
    {
    $modcomment = get_date( time(), 'DATE', 1 ) . "{$lang['modtask_donor_set']}" . $CURUSER['username'] . ".\n" . $modcomment;
    $msg = sqlesc("{$lang['modtask_received_donor']}".$CURUSER['username']);
    $updateset[] = "donoruntil = 0";
    }
    else
    {
    $donoruntil = (time() + $donorlength * 604800);
    $dur = $donorlength . "{$lang['modtask_week']}" . ($donorlength > 1 ? "s" : "");
    $msg = sqlesc(sprintf($lang['modtask_donor_duration'], $dur) . $CURUSER['username']);
    $modcomment = get_date( time(), 'DATE', 1 ) . sprintf($lang['modtask_donor_for'], $dur) . $CURUSER['username']."\n".$modcomment;
    $updateset[] = "donoruntil = ".$donoruntil;
    }
    $added = time();
    mysql_query("INSERT INTO messages (sender, receiver, msg, added) VALUES (0, $userid, $msg, $added)") or sqlerr(__FILE__, __LINE__);
    $updateset[] = "donor = 'yes'";
    }


Replace it with this :

   
Code (php) Select
// === add donated amount to user and to funds table
    if ((isset($_POST['donated'])) && (($donated = $_POST['donated']) != $user['donated'])) {
       $added = sqlesc(time());
       mysql_query("INSERT INTO funds (cash, user, added) VALUES ($donated, $userid, $added)") or sqlerr(__file__, __line__);
       $updateset[] = "donated = " . sqlesc($donated);
       $updateset[] = "total_donated = $user[total_donated] + " . sqlesc($donated);
    }
    // ====end
   
    // === Set donor - Time based
    if ((isset($_POST['donorlength'])) && ($donorlength = 0 + $_POST['donorlength'])) {
       if ($donorlength == 255) {   
       $modcomment = get_date( time(), 'DATE', 1 ) . "{$lang['modtask_donor_set']}" . $CURUSER['username'] . ".\n" . $modcomment;
       $msg = sqlesc("You have received donor status from " . $CURUSER['username']);
       $subject = sqlesc("Thank You for Your Donation!");
       $updateset[] = "donoruntil = '0'";
       } else {
       $donoruntil = (time() + $donorlength * 604800);
       $dur = $donorlength . " week" . ($donorlength > 1 ? "s" : "");
       $msg = sqlesc("Dear " . $user['username'] . "
       :wave:
       Thanks for your support to {$TBDEV['site_name']} !
       Your donation helps us in the costs of running the site!
       As a donor, you are given some bonus gigs added to your uploaded amount, the status of VIP, and the warm fuzzy feeling you get inside for helping to support this site that we all know and love :smile:

       so, thanks again, and enjoy!
       cheers,
       {$TBDEV['site_name']} Staff

       PS. Your donator status will last for $dur and can be found on your user details page and can only be seen by you :smile: It was set by " .$CURUSER['username']);
       $subject = sqlesc("Thank You for Your Donation!");
       $modcomment = get_date( time(), 'DATE', 1 ) . "{$lang['modtask_donor_set']}" . $CURUSER['username'] . ".\n" . $modcomment;
       $updateset[] = "donoruntil = " . sqlesc($donoruntil);
       }
       $added = sqlesc(time());
       mysql_query("INSERT INTO messages (sender, subject, receiver, msg, added) VALUES (0, $subject, $userid, $msg, $added)") or sqlerr(__file__, __line__);
       $updateset[] = "donor = 'yes'";
       $res = mysql_query("SELECT class FROM users WHERE id = $userid") or sqlerr(__file__,__line__);
       $arr = mysql_fetch_array($res);
       if ($user['class'] < UC_UPLOADER)
       $updateset[] = "class = '2'"; //=== set this to the number for vip on your server
    }
   
    // === add to donor length // thanks to CoLdFuSiOn & ShadowLeader
    if ((isset($_POST['donorlengthadd'])) && ($donorlengthadd = 0 + $_POST['donorlengthadd'])) {
       $donoruntil = $user["donoruntil"];
       $dur = $donorlengthadd . " week" . ($donorlengthadd > 1 ? "s" : "");
       $msg = sqlesc("Dear " . $user['username'] . "
       :wave:
       Thanks for your continued support to {$TBDEV['site_name']} !
       Your donation helps us in the costs of running the site. Everything above the current running costs will go towards next months costs!
       As a donor, you are given some bonus gigs added to your uploaded amount, and, you have the the status of VIP, and the warm fuzzy feeling you get inside for helping to support this site that we all know and love :smile:

       so, thanks again, and enjoy!
       cheers,
       {$TBDEV['site_name']} Staff

        PS. Your donator status will last for an extra $dur on top of your current donation status, and can be found on your user details page and can only be seen by you :smile: It was set by " .$CURUSER['username']);

        $subject = sqlesc("Thank You for Your Donation... Again!");
        $modcomment = get_date( time(), 'DATE', 1 ) . " - Donator status set for another $dur by " . $CURUSER['username'] .".\n" . $modcomment;
        $donorlengthadd = $donorlengthadd * 7;
        mysql_query("UPDATE users SET donoruntil = IF(donoruntil='0', ADDDATE(".TIME_NOW.", INTERVAL $donorlengthadd DAY ), ADDDATE( donoruntil, INTERVAL $donorlengthadd DAY)) WHERE id = $userid") or sqlerr(__file__, __line__);
        $added = sqlesc(time());
        mysql_query("INSERT INTO messages (sender, subject, receiver, msg, added) VALUES (0, $subject, $userid, $msg, $added)") or sqlerr(__file__, __line__);
        $updateset[] = "donated = $user[donated] + " . sqlesc($_POST['donated']);
        $updateset[] = "total_donated = $user[total_donated] + " . sqlesc($_POST['donated']);
    }
    // === end add to donor length
   
    // === Clear donor if they were bad
    if (isset($_POST['donor']) && (($donor = $_POST['donor']) != $user['donor'])) {
        $updateset[] = "donor = " . sqlesc($donor);
        $updateset[] = "donoruntil = '0'";
        $updateset[] = "donated = '0'";
        $updateset[] = "class = '1'"; //=== use this line to set them back to poweruser... change 2 to your poweruser class number
        if ($donor == 'no') {
        $modcomment = get_date( time(), 'DATE', 1 ) . " - {$lang['modtask_donor_removed']} " . $CURUSER['username'] .".\n" . $modcomment;
        $msg = sqlesc("{$lang['modtask_donor_removed']}");
        $added = sqlesc(time());
        $subject = sqlesc("Donator status expired.");
        mysql_query("INSERT INTO messages (sender, subject, receiver, msg, added) VALUES (0, $subject, $userid, $msg, $added)") or sqlerr(__file__, __line__);
        }
    }
    // ===end


@ file userdetails.php remove :

     
Code (php) Select
if ($CURUSER["class"] < UC_ADMINISTRATOR)
      $HTMLOUT .= "<input type='hidden' name='donor' value='$user[donor]' />\n";
      else
      {
        $HTMLOUT .= "<tr><td class='rowhead'>{$lang['userdetails_donor']}</td><td colspan='2' align='left'><input type='radio' name='donor' value='yes'" .($user["donor"] == "yes" ? " checked='checked'" : "")." />{$lang['userdetails_yes']} <input type='radio' name='donor' value='no'" .($user["donor"] == "no" ? " checked='checked'" : "")." />{$lang['userdetails_no']}</td></tr>\n";
      }

     
Replace it with :     

     
Code (php) Select
// === Donor mod time based by snuggles
     if ($CURUSER["class"] == UC_SYSOP) {
     $donor = $user["donor"] == "yes";
     $HTMLOUT .="<tr><td class='rowhead' align='right'><b>{$lang['userdetails_donor']}</b></td><td colspan='2' align='center'>";
     if ($donor) {
     $donoruntil = $user['donoruntil'];
     if ($donoruntil == '0')
     $HTMLOUT .="Arbitrary duration";
     else {
     $HTMLOUT .="<b>".$lang['userdetails_donor2']."</b> ".get_date($user['donoruntil'], 'DATE'). " ";
     $HTMLOUT .=" [ " . mkprettytime($donoruntil - TIME_NOW) . " ] To go\n";
     }
     } else {
     $HTMLOUT .="{$lang['userdetails_dfor']}<select name='donorlength'><option value='0'>------</option><option value='4'>1 month</option>" .
     "<option value='6'>6 weeks</option><option value='8'>2 months</option><option value='10'>10 weeks</option>" .
     "<option value='12'>3 months</option><option value='255'>Unlimited</option></select>\n";
     }
     $HTMLOUT .="<br /><b>{$lang['userdetails_cdonation']}</b><input type='text' size='6' name='donated' value=\"" .htmlspecialchars($user["donated"]) . "\" />" . "<b>{$lang['userdetails_tdonations']}</b>" . htmlspecialchars($user["total_donated"]) . "";
     if ($donor) {
     $HTMLOUT .="<br /><b>{$lang['userdetails_adonor']}</b> <select name='donorlengthadd'><option value='0'>------</option><option value='4'>1 month</option>" .
     "<option value='6'>6 weeks</option><option value='8'>2 months</option><option value='10'>10 weeks</option>" .
     "<option value='12'>3 months</option><option value='255'>Unlimited</option></select>\n";
     $HTMLOUT .="<br /><b>{$lang['userdetails_rdonor']}</b><input name='donor' value='no' type='checkbox' /> [ If they were bad ]";
     }
     $HTMLOUT .="</td></tr>\n";
     }
     // ====End


@ file index.php add this where you want :

   
Code (php) Select
//====Donation progress by snuggles
    $total_funds1 = mysql_query("SELECT sum(cash) as total_funds FROM funds");
    $arr_funds = mysql_fetch_assoc($total_funds1);
    $funds_so_far = $arr_funds["total_funds"];
    $totalneeded = 100;    //=== set this to your monthly wanted amount
    $funds_difference = $totalneeded - $funds_so_far;
    $Progress_so_far = number_format($funds_so_far / $totalneeded * 100, 1);
    if($Progress_so_far >= 100)
    $Progress_so_far = 100;
    $HTMLOUT .="<div style='text-align:left;width:80%;border:1px solid blue;padding:5px;'>
    <div style='background:lightgrey;height:25px;'><span style='font-weight:bold;font-size:12pt;'>{$lang['index_donations']}</span></div><br /><div align='center'><a href='{$TBDEV['baseurl']}/donate.php'>
    <img border='0' src='{$TBDEV['pic_base_url']}makedonation.gif' alt='Donate' title='Donate'  /></a><br /><br />
    <table width='140' style='height: 20%;' border='2'><tr>
    <td bgcolor='blue' align='center' valign='middle' width='$Progress_so_far%'>$Progress_so_far%</td><td bgcolor='grey' align='center' valign='middle'></td></tr></table></div></div><br />";
    //end


Or if you have the Memcache mod installed..

Add to config.php :

Code (php) Select
$TBDEV['expires']['total_funds'] = 0; // 0 = infinite

Replace the cached block in index with this and delete the cache/funds.txt file :

Code (php) Select
//== 09 Donation progress
    $progress='';
    $totalfunds_cache = $mc1->get_value('totalfunds_');
    if ($totalfunds_cache === false) {
    $totalfunds_cache =  mysql_fetch_assoc(mysql_query("SELECT sum(cash) as total_funds FROM funds"))/* or sqlerr(__FILE__, __LINE__)*/;
    $totalfunds_cache["total_funds"] = (int)$totalfunds_cache["total_funds"];
    $mc1->cache_value('totalfunds_', $totalfunds_cache, $TBDEV['expires']['total_funds']);
    }
    $funds_so_far = (int)$totalfunds_cache["total_funds"];
    $totalneeded = 100;    //=== set this to your monthly wanted amount
    $funds_difference = $totalneeded - $funds_so_far;
    $Progress_so_far = number_format($funds_so_far / $totalneeded * 100, 1);
    if($Progress_so_far >= 100)
    $Progress_so_far = 100;
    $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['index_donations']}</span></div><br /><div align='center'><a href='{$TBDEV['baseurl']}/donate.php'>
    <img border='0' src='{$TBDEV['pic_base_url']}makedonation.gif' alt='Donate' title='Donate'  /></a><br /><br />
    <table align='center' width='140' style='height: 20%;' border='2'><tr>
    <td bgcolor='transparent' align='center' valign='middle' width='$Progress_so_far%'>$Progress_so_far%</td><td bgcolor='grey' align='center' valign='middle'></td></tr></table></div></div><br />";
    //end

   
   
    modtask.php find :
   
   
Code (php) Select
// === add donated amount to user and to funds table
    if ((isset($_POST['donated'])) && (($donated = $_POST['donated']) != $user['donated'])) {
       $added = sqlesc(time());
       sql_query("INSERT INTO funds (cash, user, added) VALUES ($donated, $userid, $added)") or sqlerr(__file__, __line__);
       $updateset[] = "donated = " . sqlesc($donated);
       $updateset[] = "total_donated = $user[total_donated] + " . sqlesc($donated);
    }
    // ====end

   
    Change to :
   
   
Code (php) Select
// === add donated amount to user and to funds table
    if ((isset($_POST['donated'])) && (($donated = $_POST['donated']) != $user['donated'])) {
       $added = sqlesc(time());
       sql_query("INSERT INTO funds (cash, user, added) VALUES ($donated, $userid, $added)") or sqlerr(__file__, __line__);
       $updateset[] = "donated = " . sqlesc($donated);
       $updateset[] = "total_donated = $user[total_donated] + " . sqlesc($donated);
       $mc1->delete_value('totalfunds_');
    }
    // ====end

   
    cleanup.php find :
   
   
Code (php) Select
// ===Clear funds after one month
    $secs = 30 * 86400;
    $dt = sqlesc(time() - $secs);
    mysql_query("DELETE FROM funds WHERE added < $dt");
    // ===End

   
    Change to :
   
   
Code (php) Select
// ===Clear funds after one month
    $secs = 30 * 86400;
    $dt = sqlesc(time() - $secs);
    mysql_query("DELETE FROM funds WHERE added < $dt");
    $mc1->delete_value('totalfunds_');
    // ===End


@ file lang/en/lang_index.php add :

     
Code (php) Select
'index_donations' => "Donate",
   
@ file lang/en/userdetails.php add :   
     
     
Code (php) Select
'userdetails_donor2' => 'Donated status until',
     'userdetails_dfor' => 'Donor for',
     'userdetails_cdonation' => 'Current donation',
     'userdetails_tdonations' => 'Total donations £',
     'userdetails_adonor' => 'Add to donor time:',
     'userdetails_rdonor' => 'Remove donor status',


Upload donations.php to root :

Code (php) Select
<?php
require ("include/bittorrent.php");
require_once 
ROOT_PATH.'/include/user_functions.php';
require_once 
ROOT_PATH.'/include/html_functions.php';
require_once 
ROOT_PATH.'/include/pager_functions.php';
dbconn(false);
loggedinorreturn();

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

$HTMLOUT ="";

if (
$CURUSER['class'] < UC_ADMINISTRATOR)
    
stderr("Sorry""Access denied!");

if (isset(
$_GET["total_donors"])) {
    
$total_donors $_GET["total_donors"];
    if (
$total_donors != '1')
        
stderr("Error""I smell a rat!");

    
$res mysql_query("SELECT COUNT(*) FROM users WHERE total_donated != '0.00'") or sqlerr(__FILE____LINE__);
    
$row mysql_fetch_array($res);
    
$count $row[0];
    
$perpage 25;
    
    
$pager pager($perpage$count"donations.php?");
    
    if (
mysql_num_rows($res) == 0)
        
stderr("Sorry""no donors found!");

    
$users number_format(get_row_count("users""WHERE total_donated != '0.00'"));
    
$HTMLOUT .= begin_frame("Donor List: All Donations [ $users ]"true);
    
$res mysql_query("SELECT id,username,email,added,donated,total_donated FROM users WHERE total_donated != '0.00' ORDER BY id DESC") or sqlerr(__FILE____LINE__);
    }
    
// ===end total donors
    
else {
    
$res mysql_query("SELECT COUNT(*) FROM users WHERE donor='yes'") or sqlerr(__FILE____LINE__);
    
$row mysql_fetch_array($res);
    
$count $row[0];
    
$perpage 25;
    
$pager pager($perpage$count"donations.php?");

    if (
mysql_num_rows($res) == 0)
        
stderr("Sorry""no donors found!");

    
$users number_format(get_row_count("users""WHERE donor='yes'"));
    
$HTMLOUT .= begin_frame("Donor List: Current Donors [ $users ]"true);
    
$res mysql_query("SELECT id,username,email,added,donated,total_donated FROM users WHERE donor='yes' ORDER BY id DESC") or sqlerr(__FILE____LINE__);
    }

    
$HTMLOUT .= begin_table();
    
$HTMLOUT .="<tr><td colspan='9' align='center'><a class='altlink' href='{$TBDEV['baseurl']}/donations.php'>Current Donors</a> || <a class='altlink' href='{$TBDEV['baseurl']}/donations.php?total_donors=1'>All Donations</a></td></tr>";

    if (
$count $perpage)
    
$HTMLOUT .= $pager['pagertop'];

    
$HTMLOUT .="<tr><td class='colhead'>ID</td><td class='colhead' align='left'>Username</td><td class='colhead' align='left'>e-mail</td>" "<td class='colhead' align='left'>Joined</td><td class='colhead' align='left'>Donor Until?</td><td class='colhead' align='left'>" "Current</td><td class='colhead' align='left'>Total</td><td class='colhead' align='left'>PM</td></tr>";
    while (
$arr = @mysql_fetch_assoc($res)) {
   
    
// =======change colors
    
$count2 ="";
    if (
$count2 == 0) {
        
$count2 $count2 1;
        
$class "clearalt7";
    } else {
        
$count2 0;
        
$class "clearalt6";
    }
    
// =======end
    
$HTMLOUT .="<tr><td valign='bottom' class='$class'><a class='altlink' href='{$TBDEV['baseurl']}/userdetails.php?id=" htmlspecialchars($arr['id']) . "'>" htmlspecialchars($arr['id']) . "</a></td>" "<td align='left' valign='bottom' class='$class'><a class='altlink' href='{$TBDEV['baseurl']}/userdetails.php?id=" htmlspecialchars($arr['id']) . "'><b>" htmlspecialchars($arr['username']) . "</b></a>" "</td><td align='left' valign='bottom' class='$class'><a class='altlink' href='mailto:" htmlspecialchars($arr['email']) . "'>" htmlspecialchars($arr['email']) . "</a>" "</td><td align='left' valign='bottom' class='$class'><font size=\"-3\"> ".get_date($arr['added'], 'DATE'). "</font>" "</td><td align='left' valign='bottom' class='$class'>";

    
$r = @mysql_query("SELECT donoruntil FROM users WHERE id=" sqlesc($arr[id]) . "") or sqlerr();
    
$user mysql_fetch_array($r);
    
$donoruntil $user['donoruntil'];
    if (
$donoruntil == '0')
        
$HTMLOUT .="n/a";
    else
        
$HTMLOUT .="<font size=\"-3\"> ".get_date($r['donoruntil'], 'DATE'). " [ " mkprettytime($donoruntil TIME_NOW) . " ] To go...</font>";

    
$HTMLOUT .="</td><td align='left' valign='bottom' class='$class'><b>£" htmlspecialchars($arr['donated']) . "</b></td>" "<td align='left' valign='bottom' class='$class'><b>£" htmlspecialchars($arr['total_donated']) . "</b></td>" "<td align='left' valign='bottom' class='$class'><b><a class='altlink' href='{$TBDEV['baseurl']}/sendmessage.php?receiver=" htmlspecialchars($arr['id']) . "'>PM</a></b></td></tr>";
    }
    
$HTMLOUT .= end_table();
    
$HTMLOUT .= end_frame();
    if (
$count $perpage)
    
$HTMLOUT .= $pager['pagerbottom'];

    print 
stdhead('Donations') . $HTMLOUT stdfoot();
?>


Add the css to both stylesheets :

Code (html) Select
td.clearalt6 {
background: #004E98;
padding: 5px;
border: 0px;
border: hidden;}
td.clearalt7 {
padding: 5px;
background: #777777;
border: 0px;
border: hidden;}


Thats it - Please post any errors improvements or optmizations and i'll update the main post - You'll notice donations.php has not yet got language entrys i will do that asap :)
Think the pager on donations.php could be wrong as well not sure so please advise :-P