Thread: Personal stats
View Single Post
  #2  
Old 4th July 2011, 16:12
joeroberts's Avatar
joeroberts joeroberts is offline
BT.Manager Owner
 
Join Date: Jan 2008
United States
Posts: 2,113
Default
PHP Code:
if ($user->user)
{

OpenTable("Personal stats");
        
$sql = "SELECT seedbonus, avatar, uploaded,  downloaded, invites, uploaded/downloaded AS ratio FROM ".$db_prefix."_users WHERE id = '".$user->id."';";
        
$res = $db->sql_query($sql);
        list (
$seedbonus, $avatar, $uploaded, $downloaded, $invites, $ratio) = $db->sql_fetchrow($res);
        
$db->sql_freeresult($res);
        echo 
"<p>".pic("pic_uploaded.gif").mksize($uploaded)."<br>";
        echo 
pic("pic_downloaded.gif").mksize($downloaded)."<br>";
        echo 
pic("pic_ratio.gif");
        echo 
"&nbsp;";
        if (
$downloaded == 0)
                echo 
"&infin;";
        elseif (
$ratio < 0.1)
                echo 
"<font color=\"#ff0000\">" . number_format($ratio, 2) . "</font>";
        elseif (
$ratio < 0.2)
                echo 
"<font color=\"#ee0000\">" . number_format($ratio, 2) . "</font>";
        elseif (
$ratio < 0.3)
                echo 
"<font color=\"#dd0000\">" . number_format($ratio, 2) . "</font>";
        elseif (
$ratio < 0.4)
                echo 
"<font color=\"#cc0000\">" . number_format($ratio, 2) . "</font>";
        elseif (
$ratio < 0.5)
                echo 
"<font color=\"#bb0000\">" . number_format($ratio, 2) . "</font>";
        elseif (
$ratio < 0.6)
                echo 
"<font color=\"#aa0000\">" . number_format($ratio, 2) . "</font>";
        elseif (
$ratio < 0.7)
                echo 
"<font color=\"#990000\">" . number_format($ratio, 2) . "</font>";
        elseif (
$ratio < 0.8)
                echo 
"<font color=\"#880000\">" . number_format($ratio, 2) . "</font>";
        elseif (
$ratio < 0.9)
                echo 
"<font color=\"#770000\">" . number_format($ratio, 2) . "</font>";
        elseif (
$ratio < 1)
                echo 
"<font color=\"#660000\">" . number_format($ratio, 2) . "</font>";
        else
                echo 
"<font color=\"#00FF00\">".  number_format($ratio, 2) . "</font>";
        echo 
"<br>\n";
        
#Numer of seeding Torrents
        
$sql = "SELECT P.torrent AS id, T.name as name FROM ".$db_prefix."_peers P, ".$db_prefix."_torrents T WHERE P.uid = '".$user->id."' AND P.seeder = 'yes' AND T.id = P.torrent;";
        
$res = $db->sql_query($sql);
        
$cnt = $db->sql_numrows($res);
        
$torrents = Array();
        while (
$tor = $db->sql_fetchrow($res)) {
                
$torrents[] = htmlspecialchars((strlen($tor["name"]) > 33) ? substr($tor["name"],0,30)."..." : $tor["name"]);
        }
        if (
$cnt > 0) help(pic("upload.gif"),"<p>".implode($torrents,"<br>")."</p>",_btyoureseeding);
        else echo 
pic("upload.gif",null,_btyoureseeding);
        echo 
$cnt;
        
$db->sql_freeresult($sql);
        unset(
$sql, $res, $torrents, $tor, $cnt);
        
#Number of downloading Torrents
        
echo "<br>\n";
        
$sql = "SELECT P.torrent AS id, T.name as name FROM ".$db_prefix."_peers P, ".$db_prefix."_torrents T WHERE P.uid = '".$user->id."' AND P.seeder = 'no' AND T.id = P.torrent;";
        
$res = $db->sql_query($sql);
        
$cnt = $db->sql_numrows($res);
        
$torrents = Array();
        while (
$tor = $db->sql_fetchrow($res)) {
                
$torrents[] = htmlspecialchars((strlen($tor["name"]) > 33) ? substr($tor["name"],0,30)."..." : $tor["name"]);
        }
        if (
$cnt > 0) help(pic("download.gif"),"<p>".implode($torrents,"<br>")."</p>",_btyoureleeching);
        else echo 
pic("download.gif",null,_btyoureleeching);
        echo 
$cnt;
        
$db->sql_freeresult($sql);
        unset(
$sql, $res, $torrents, $tor, $cnt);
        if(
$avatar=="blank.gif")$thavatar = "themes/eVo_blue/pics/noavatar.gif";
        else 
        
$thavatar = "avatars/".$avatar;
        echo 
"</p>";
        echo 
"<br>\n";
        echo 
"<br>\n";
        echo 
"<p align=\"center\"><b>"._btwelcomebk."</b></p>\n";
        echo 
"<p align=\"center\"><b>".$user->name."</b></p>\n";        
        echo 
"<b>".$thavatar."</b><br>";
        echo 
"<br>\n";
        print(
"<p>Seeding Bonus: <a href='mybonus.php'>".$seedbonus."</a></p>");

CloseTable();    
} 
__________________
Do not ask me to help you work on your site that is not phpMyBitTorrent
Do not ask me to make a mod for any other source
Do not Ask me to setup your site.
I will no longer help you setup your site, there is a setup script if you have trouble with it post in the forum here or in BT.Manager™ forum
My Current Demo is here http://demo.btmanager.org/
Reply With Quote