Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   BT.Manager (phpMyBitTorrent) (http://www.bvlist.com/forumdisplay.php?f=23)
-   -   stats.php error message... (http://www.bvlist.com/showthread.php?t=9166)

Giorgatzelos 16th May 2013 00:10

stats.php error message...
 
PHP Code:

Top 10 Best Sharers (with minimum 100 MB downloaded
Account Rank    Account User    Uploaded    Downloaded    ratio
1    Optimus Prime    21.83 TB    32.91 GB    679.18
2    Giorgatzelos    9.09 TB    4.43 GB    2
,102.27 


after table top 10 sharers i get this message:


Code:

BIGINT UNSIGNED value is out of range in '(`hostz_11543320_1`.`torrent_users`.`downloaded` - `hostz_11543320_1`.`torrent_users`.`uploaded`)'
Bump: maybe the error is because there are 2 sharers and the sql seeks for 10?...
i looked at the code and this is the only i can think of....

joeroberts 16th May 2013 04:55

try this one
Code:

/*
*------------------------------phpMyBitTorrent V 2.0.5-------------------------*
*--- The Ultimate BitTorrent Tracker and BMS (Bittorrent Management System) ---*
*--------------  Created By Antonio Anzivino (aka DJ Echelon)  --------------*
*-------------------  And Joe Robertson (aka joeroberts)  -------------------*
*-------------              http://www.p2pmania.it              -------------*
*------------ Based on the Bit Torrent Protocol made by Bram Cohen ------------*
*-------------              http://www.bittorrent.com            -------------*
*------------------------------------------------------------------------------*
*------------------------------------------------------------------------------*
*--  This program is free software; you can redistribute it and/or modify  --*
*--  it under the terms of the GNU General Public License as published by  --*
*--  the Free Software Foundation; either version 2 of the License, or      --*
*--  (at your option) any later version.                                    --*
*--                                                                          --*
*--  This program is distributed in the hope that it will be useful,        --*
*--  but WITHOUT ANY WARRANTY; without even the implied warranty of        --*
*--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          --*
*--  GNU General Public License for more details.                          --*
*--                                                                          --*
*--  You should have received a copy of the GNU General Public License      --*
*--  along with this program; if not, write to the Free Software            --*
*-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA --*
*--                                                                          --*
*------------------------------------------------------------------------------*
*------              ©2010 phpMyBitTorrent Development Team              ------*
*-----------              http://phpmybittorrent.com              -----------*
*------------------------------------------------------------------------------*
*-----------------  Sunday, September 14, 2008 9:05 PM  ---------------------*
*/
if (defined('IN_PMBT'))die ("You can't include this file");
define("IN_PMBT",true);
include("header.php");
  function get_ratio_color($ratio)
  {
    if ($ratio < 0.1) return "#ff0000";
    if ($ratio < 0.2) return "#ee0000";
    if ($ratio < 0.3) return "#dd0000";
    if ($ratio < 0.4) return "#cc0000";
    if ($ratio < 0.5) return "#bb0000";
    if ($ratio < 0.6) return "#aa0000";
    if ($ratio < 0.7) return "#990000";
    if ($ratio < 0.8) return "#880000";
    if ($ratio < 0.9) return "#770000";
    if ($ratio < 1) return "#660000";
    return "#000000";
  }

if (!$user->user) loginrequired("user");

function get_row_count($table, $suffix = "")
{
  if ($suffix)
    $suffix = " $suffix";
  ($r = mysql_query("SELECT COUNT(*) FROM $table$suffix")) or die(mysql_error());
  ($a = mysql_fetch_row($r)) or die(mysql_error());
  return $a[0];
}
function usertable($res, $frame_caption) {
$menu = '';
  print ("
$frame_caption
");
    if (mysql_num_rows($res) > 0)
    {
    print("\n");
  $num = 0;
  while ($a = mysql_fetch_assoc($res)) {
    ++$num;
    if ($a["uploaded"] == "0")
      break;
    if ($a["downloaded"]) {
      $ratio = $a["uploaded"] / $a["downloaded"];
      $color = get_ratio_color($ratio);
      $ratio = number_format($ratio, 2);
      if ($color)
        $ratio = "$ratio";
    }
    else
      $ratio = "Inf.";
    if ($menu != "1") {
      echo ""
        .""
        .""
        .""
        .""
        .""
        ."";
      $menu = 1;
    }
    print("");
  }
  echo "
"._btstats_rank.""._btstats_user.""._btstats_uploaded.""._btstats_downloaded.""._btstats_ratio."
$num" . $a["username"] .
          "
" . mksize($a["uploaded"]) .
          "
" . mksize($a["downloaded"]) .
          "
" . $ratio . "
";
      }else{
        echo ""._btstats_noshow."
";
    }
}

function _torrenttable($res, $frame_caption) {
$menu = '';
  print ("
$frame_caption
");
  if (mysql_num_rows($res) > 0)
    {
      print("\n");
  $num = 0;
  while ($a = mysql_fetch_assoc($res)) {
      ++$num;
      if ($a["leechers"])
      {
        $r = $a["seeders"] / $a["leechers"];
        $ratio = "" . number_format($r, 2) . "";
      }
      else
        $ratio = "Inf.";
        if ($menu != "1") {
          echo ""
              .""
              .""
              .""
              .""
              .""
              .""
              .""
              ."";
          $menu = 1;
        }
                $dispname = htmlspecialchars($a["name"]);
                $dispname = str_replace("_", " ", $dispname);
                $dispname = str_replace(".", " ", $dispname);
        print("\n");
    }
    echo "
"._btstats_rank.""._btstats_user.""._btstats_completed.""._btstats_seeds.""._btstats_leech.""._btstats_peers.""._btstats_ratio."
$num" .
        ((strlen($dispname) <= 25) ? $dispname : substr($dispname,0,24)."...")."
" . number_format($a["completed"]) .
        "
" . number_format($a["seeders"]) .
        "
" . number_format($a["leechers"]) .
        "
" . ($a["leechers"] + $a["seeders"]) .
        "
$ratio
";
    }else{
        echo ""._btstats_noshow."
";
    }
}

function countriestable($res, $frame_caption) {
    OpenTable2($frame_caption);
      if (mysql_num_rows($res) > 0)
    {
    print("\n");
   
    echo "";
    echo "";
    echo "";
    echo "";
    echo "";
   
    $num = 0;
    while ($a = mysql_fetch_assoc($res))
    {
      ++$num;
      print("
     
      \n");
    }
    echo "
"._btstats_rank.""._btstats_country.""._btstats_users."
$num $a[name]$a[num]
";
        CloseTable2();

        }else{
        echo ""._btstats_noshow."";
    }
}
function postertable($res, $frame_caption) {
    OpenTable2($frame_caption);
      if (mysql_num_rows($res) > 0)
    {
    print("\n");
   
    echo "";
    echo "";
    echo "";
    echo "";
    echo "";
   
    $num = 0;
    while ($a = mysql_fetch_assoc($res))
    {
      ++$num;
      print("\n");
    }
    echo "
"._btstats_rank.""._btstats_user.""._btstats_posted."
$num$a[username]$a[num]
";
    CloseTable2();
        }else{
        echo ""._btstats_noshow."";
        CloseTable2();
    }
}

//main stats here
$a = @mysql_fetch_assoc(@mysql_query("SELECT id,username FROM ".$db_prefix."_users WHERE active = '1' ORDER BY id DESC LIMIT 5"));
if ($user->user)
  $latestuser = "" . $a["username"] . "";
else
  $latestuser = "$a[username]";
$registered = number_format(get_row_count("".$db_prefix."_users"));
$torrents = number_format(get_row_count("".$db_prefix."_torrents"));

$result = mysql_query("SELECT SUM(downloaded) AS totaldl FROM ".$db_prefix."_users") or sqlerr(__FILE__, __LINE__);

while ($row = mysql_fetch_array ($result))
{
$totaldownloaded      = $row["totaldl"];
}
$result = mysql_query("SELECT SUM(uploaded) AS totalul FROM ".$db_prefix."_users") or sqlerr(__FILE__, __LINE__);

while ($row = mysql_fetch_array ($result))
{
$totaluploaded      = $row["totalul"];
}
$seeders = get_row_count("".$db_prefix."_peers", "WHERE seeder='yes'");
$leechers = get_row_count("".$db_prefix."_peers", "WHERE seeder='no'");
$localtorrent = number_format(get_row_count("".$db_prefix."_torrents", "WHERE tracker IS NULL AND exeem IS NOT NULL"));
$externaltorrent = number_format(get_row_count("".$db_prefix."_torrents", "WHERE tracker IS NOT NULL"));

$usersactive = 0;
if ($leechers == 0)
  $ratio = "100";
else
  $ratio = round($seeders / $leechers * 100);
 if ($ratio < 20)
    $ratio = "" . $ratio . "%";
 else
    $ratio .= "%";
$peers = number_format($seeders + $leechers);
$seeders = number_format($seeders);
$leechers = number_format($leechers);
// start count registered today
$res = mysql_query("SELECT COUNT(*) FROM ".$db_prefix."_users WHERE UNIX_TIMESTAMP(" . gmdate("YmdHis") . ") - UNIX_TIMESTAMP(regdate) < 86400");
$arr44 = mysql_fetch_row($res);
$regtoday = $arr44[0];

function getmicrotime(){
    list($usec, $sec) = explode(" ",microtime());
    return ((float)$usec + (float)$sec);
}
$time_start = getmicrotime();
//end here

///////////////////////////////////////// PAGE LAYOUT //////////////////////////////

OpenTable(_btstats_extra);


echo "
"._btstats_welcome." $latestuser";
echo ""._btstats_total." $registered ";
echo ""._btstats_new_today." $regtoday ";
echo ""._btstats_active."  $peers ";
ECHO ""._btstats_downloaded."  ".mksize($totaldownloaded)." ";
ECHO ""._btstats_uploaded."  ".mksize($totaluploaded)." ";
echo ""._btstats_tracking."  $torrents  "._btstats_torrents."";
echo ""._btstats_local."  $localtorrent  Torrents ";
echo ""._btstats_external."  $externaltorrent  Torrents ";
echo ""._btstats_seeds."$seeders ";
echo ""._btstats_leech."$leechers ";
echo ""._btstats_seed_ratio."  $ratio ";
echo "
";



  $r = mysql_query("SELECT ".$db_prefix."_users.id, ".$db_prefix."_users.username, COUNT(".$db_prefix."_torrents.owner) as num FROM ".$db_prefix."_torrents LEFT JOIN ".$db_prefix."_users ON ".$db_prefix."_users.id = ".$db_prefix."_torrents.owner GROUP BY owner ORDER BY num DESC LIMIT 10") or sqlerr();
  postertable($r, _btstats_top10_posters); echo "";

  $r = mysql_query("SELECT id, username, uploaded, downloaded FROM ".$db_prefix."_users  ORDER BY uploaded DESC LIMIT 10") or die;
  usertable($r, _btstats_top10_uploaders); echo "";

  $r = mysql_query("SELECT id, username, uploaded, downloaded FROM ".$db_prefix."_users  ORDER BY downloaded DESC LIMIT 10") or die;
  usertable($r, _btstats_top10_leechers); echo "";

  $r = mysql_query("SELECT id, username, uploaded, downloaded FROM ".$db_prefix."_users WHERE downloaded > 104857600 ORDER BY (CAST(uploaded AS SIGNED) - CAST(downloaded AS SIGNED)) DESC LIMIT 10") or die(mysql_error());
  usertable($r, ""._btstats_top10_best_shares.""._btstats_100mb.""); echo "";

  $r = mysql_query("SELECT id, username, uploaded, downloaded FROM ".$db_prefix."_users WHERE downloaded > 104857600  ORDER BY (CAST(downloaded AS SIGNED) - CAST(uploaded AS SIGNED)) DESC, downloaded DESC LIMIT 10") or die(mysql_error());
  usertable($r, ""._btstats_top10_worst_shares.""._btstats_100mb.""); echo "";

  $r = mysql_query("SELECT * FROM ".$db_prefix."_torrents ORDER BY seeders + leechers DESC, seeders DESC, added ASC LIMIT 10") or sqlerr();
  _torrenttable($r, ""._btstats_top10_active.""); echo "";

  $r = mysql_query("SELECT * FROM ".$db_prefix."_torrents WHERE seeders >= 5 ORDER BY seeders / leechers DESC, seeders DESC, added ASC LIMIT 10") or sqlerr();
  _torrenttable($r, ""._btstats_top10_best_seed.""._btstats_top10_5seeds.""); echo "";

  $r = mysql_query("SELECT * FROM ".$db_prefix."_torrents WHERE leechers >= 5 AND completed > 0 ORDER BY seeders / leechers ASC, leechers DESC LIMIT 10") or sqlerr();
  _torrenttable($r, ""._btstats_top10_worst_seeded.""._btstats_top10_5leech.""); echo "";
 
    $r = mysql_query("SELECT * FROM ".$db_prefix."_torrents WHERE  completed > 0 ORDER BY seeders / leechers ASC, completed DESC LIMIT 10") or sqlerr();
  _torrenttable($r, ""._btstats_top10_most_complete.""); echo "";

  $r = mysql_query("SELECT ".$db_prefix."_countries.name, flagpic, COUNT(".$db_prefix."_users.country) as num FROM ".$db_prefix."_countries LEFT JOIN ".$db_prefix."_users ON ".$db_prefix."_users.country = ".$db_prefix."_countries.id GROUP BY ".$db_prefix."_countries.name ORDER BY num DESC LIMIT 10") or sqlerr();
  countriestable($r, ""._btstats_top10_countries."");echo "";

  CloseTable();
include ("footer.php");
?>


Giorgatzelos 16th May 2013 16:13

Worked like a charm!Thanks Joe!


All times are GMT +2. The time now is 23:56.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.