Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
ratio
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Support

2020-11-10 16:16:52
Hello, can you tell me how to display the ratio in memberlist.php
2020-11-12 15:05:26
It’s a matter of rounding 2 columns by 2 (users.uploaded & users.downloaded). What version, mysqli?
2020-11-13 05:13:07
You can try this, depending where you put it the id needs changing for show we use $CUR[user]
$res = SQL_Query_exec("SELECT uploaded, downloaded FROM users WHERE id = $CURUSER[id]");
while ($row = mysqli_fetch_assoc($res)) {

 if ($row['downloaded'] > 0)
{
$ratio = $row['uploaded'] / $row['downloaded'];
$ratio = number_format($ratio, 2);
$color = get_ratio_color($ratio);
if ($color)
     $ratio = "<font color=#ffff00>$ratio</font>";
} else if ($row['uploaded'] > 0)
    $ratio = 'Inf.';
}
echo $ratio;
}

Test on index.php at top (above check block) if it works we look at you memberlist.php
2020-11-13 17:55:57
"m-jay, post: 69544, member: 20288":

You can try this, depending where you put it the id needs changing for show we use $CUR[user]
$res = SQL_Query_exec("SELECT uploaded, downloaded FROM users WHERE id = $CURUSER[id]");
while ($row = mysqli_fetch_assoc($res)) {

 if ($row['downloaded'] > 0)
{
$ratio = $row['uploaded'] / $row['downloaded'];
$ratio = number_format($ratio, 2);
$color = get_ratio_color($ratio);
if ($color)
     $ratio = "<font color=#ffff00>$ratio</font>";
} else if ($row['uploaded'] > 0)
    $ratio = 'Inf.';
}
echo $ratio;
}

Test on index.php at top (above check block) if it works we look at you memberlist.php


Where is the function for get_ratio_color() ?
2020-11-13 18:27:31
It's on v2.08
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";
2020-11-13 20:01:30
"m-jay, post: 69546, member: 20288":

It's on v2.08
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";



Thats actually really useful logic, permissions, text or banner for user can be added etc :unsure: very cool
2020-11-14 05:19:36
If you use it mate will you test the other code, once I know the syntax works I can easily add it to the memberlist table for niki
2020-11-14 18:23:09
"m-jay, post: 69548, member: 20288":

If you use it mate will you test the other code, once I know the syntax works I can easily add it to the memberlist table for niki


with some porting, I sure will and report back as to its functionality.
2020-11-17 23:43:22
try this. Feel free to make it better :) memberlist.php below
<?php
//
//  TorrentTrader v3.x

require_once("backend/functions.php");
dbconn();
loggedinonly();

if ($CURUSER["view_users"]=="no")
   show_error_msg(T_("ERROR"), T_("NO_USER_VIEW"), 1);

$search = trim($_GET['search']);
$class = (int) $_GET['class'];
$letter = trim($_GET['letter']);

if (!$class)
   unset($class);

$q = $query = null;
if ($search) {
   $query = "username LIKE " . sqlesc("%$search%") . " AND status='confirmed'";
   if ($search) {
       $q = "search=" . htmlspecialchars($search);
   }
} elseif ($letter) {
   if (strlen($letter) > 1)
       unset($letter);
   if ($letter == "" || strpos("abcdefghijklmnopqrstuvwxyz", $letter) === false) {
       unset($letter);
   } else {
       $query = "username LIKE '$letter%' AND status='confirmed'";
   }
   $q = "letter=$letter";
}

if (!$query) {
   $query = "status='confirmed'";
}

if ($class) {
   $query .= " AND class=$class";
   $q .= ($q ? "&amp;" : "") . "class=$class";
}

stdhead(T_("USERS"));
begin_frame(T_("USERS"));
print("<br /><form method='get' action='memberlist.php'>\n");
print(T_("SEARCH").": <input type='text' size='30' name='search' />\n");
print("<select name='class'>\n");
print("<option value='-'>(any class)</option>\n");
$res = SQL_Query_exec("SELECT group_id, level FROM groups");
while ($row = mysqli_fetch_array($res)) {
   print("<option value='$row[group_id]'" . ($class && $class == $row['group_id'] ? " selected='selected'" : "") . ">".htmlspecialchars($row['level'])."</option>\n");
}
print("</select>\n");
print("<input type='submit' value='".T_("SEARCH")."' />\n");
print("</form>\n");

print("<p>\n");

print("<a href='memberlist.php'><b>".T_("ALL")."</b></a> - \n");
foreach (range("a", "z") as $l) {
   $L = strtoupper($l);
   if ($l == $letter)
       print("<b>$L</b>\n");
   else
       print("<a href='memberlist.php?letter=$l'><b>$L</b></a>\n");
}

print("</p>\n");

$page = (int) $_GET['page'];
$perpage = 25;

$res = SQL_Query_exec("SELECT COUNT(*) FROM users WHERE $query");
$arr = mysqli_fetch_row($res);
$pages = floor($arr[0] / $perpage);
if ($pages * $perpage < $arr[0])
 ++$pages;

if ($page < 1)
 $page = 1;
else
 if ($page > $pages)
   $page = $pages;

for ($i = 1; $i <= $pages; ++$i)
 if ($i == $page)
   $pagemenu .= "$i\n";
 else
   $pagemenu .= "<a href='?$q&amp;page=$i'>$i</a>\n";

if ($page == 1)
 $browsemenu .= "";
//  $browsemenu .= "[Prev]";
else
 $browsemenu .= "<a href='?$q&amp;page=" . ($page - 1) . "'>[Prev]</a>";

$browsemenu .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";

if ($page == $pages)
 $browsemenu .= "";
//  $browsemenu .= "[Next]";
else
 $browsemenu .= "<a href='?$q&amp;page=" . ($page + 1) . "'>[Next]</a>";

$offset = ($page * $perpage) - $perpage;

$res = SQL_Query_exec("SELECT users.*, groups.level FROM users LEFT JOIN groups ON groups.group_id=users.class WHERE $query ORDER BY username LIMIT $offset,$perpage");

begin_table();
print("<tr><th class='table_head'>" . T_("USERNAME") . "</th><th class='table_head'>" . T_("REGISTERED") . "</th><th class='table_head'>" . T_("LAST_ACCESS") . "</th><th class='table_head'>" . T_("CLASS") . "</th><th class='table_head'>" . T_("COUNTRY") . "</th><th class='table_head'>" . T_("RATIO") . "</th></tr>\n");
while ($arr = mysqli_fetch_assoc($res)) {

       $cres = SQL_Query_exec("SELECT name,flagpic FROM countries WHERE id=$arr[country]");

       if ($carr = mysqli_fetch_assoc($cres)) {
           $country = "<td align=\"center\" class='table_col1' style='padding: 0px'><img src='$site_config[SITEURL]/images/countries/$carr[flagpic]' title='".htmlspecialchars($carr['name'])."' alt='".htmlspecialchars($carr['name'])."' /></td>";
       } else {
           $country = "<td align=\"center\"  class='table_col1' style='padding: 0px'><img src='$site_config[SITEURL]/images/countries/unknown.gif' alt='Unknown' /></td>";
       }
   
       $r = SQL_Query_exec("SELECT uploaded, downloaded FROM users WHERE id=$arr[id]");
       $user = mysqli_fetch_assoc($r);
       if ($user["downloaded"] > 0) {
           $ratio = number_format($user["uploaded"] / $user["downloaded"], 2);
       }else{
           $ratio = "Inf";
       }

   
/*    if ($arr['added'] == '0000-00-00 00:00:00')
       $arr['added'] = '-';
   if ($arr['last_access'] == '0000-00-00 00:00:00')
       $arr['last_access'] = T_("NEVER");*/

 print("<tr><td class='table_col1' align='left'><a href='account-details.php?id=$arr[id]'><b>$arr[username]</b></a>" .($arr["donated"] > 0 ? "<img src='$site_config[SITEURL]/images/star.png' border='0' alt='Donated' />" : "")."</td>" .
 "<td align=\"center\" class='table_col2'>".utc_to_tz($arr["added"])."</td><td align=\"center\" class='table_col1'>".utc_to_tz($arr["last_access"])."</td>".
   "<td class='table_col2' align='center'>" . T_($arr["level"]) . "</td>$country ". "<td class='table_col2' align='center'>" . $ratio . "</td></tr>\n");
}
end_table();

print("<p>$pagemenu<br />$browsemenu</p>");
end_frame();
stdfoot();

?>

TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2020-11-19 16:59:00
Merci fonctionne bien maintenant (y)
2020-11-19 22:47:33
This one uses the built-in color function. Probably need to tweak the colors, but its a start. Tweak your colors in backend/functions.php. look for get_ratio_color and alter those css values

<?php
//
//  TorrentTrader v3.x
require_once("backend/functions.php");
dbconn();
loggedinonly();
if ($CURUSER["view_users"]=="no")
   show_error_msg(T_("ERROR"), T_("NO_USER_VIEW"), 1);
 
$search = trim($_GET['search']);
$class = (int) $_GET['class'];
$letter = trim($_GET['letter']);
if (!$class)
   unset($class);
$q = $query = null;
if ($search) {
   $query = "username LIKE " . sqlesc("%$search%") . " AND status='confirmed'";
   if ($search) {
       $q = "search=" . htmlspecialchars($search);
   }
} elseif ($letter) {
   if (strlen($letter) > 1)
       unset($letter);
   if ($letter == "" || strpos("abcdefghijklmnopqrstuvwxyz", $letter) === false) {
       unset($letter);
   } else {
       $query = "username LIKE '$letter%' AND status='confirmed'";
   }
   $q = "letter=$letter";
}
if (!$query) {
   $query = "status='confirmed'";
}
if ($class) {
   $query .= " AND class=$class";
   $q .= ($q ? "&amp;" : "") . "class=$class";
}
stdhead(T_("USERS"));
begin_frame(T_("USERS"));
print("<br /><form method='get' action='memberlist.php'>\n");
print(T_("SEARCH").": <input type='text' size='30' name='search' />\n");
print("<select name='class'>\n");
print("<option value='-'>(any class)</option>\n");
$res = SQL_Query_exec("SELECT group_id, level FROM groups");
while ($row = mysqli_fetch_array($res)) {
   print("<option value='$row[group_id]'" . ($class && $class == $row['group_id'] ? " selected='selected'" : "") . ">".htmlspecialchars($row['level'])."</option>\n");
}
print("</select>\n");
print("<input type='submit' value='".T_("SEARCH")."' />\n");
print("</form>\n");
print("<p>\n");
print("<a href='memberlist.php'><b>".T_("ALL")."</b></a> - \n");
foreach (range("a", "z") as $l) {
   $L = strtoupper($l);
   if ($l == $letter)
       print("<b>$L</b>\n");
   else
       print("<a href='memberlist.php?letter=$l'><b>$L</b></a>\n");
}
print("</p>\n");
$page = (int) $_GET['page'];
$perpage = 25;
$res = SQL_Query_exec("SELECT COUNT(*) FROM users WHERE $query");
$arr = mysqli_fetch_row($res);
$pages = floor($arr[0] / $perpage);
if ($pages * $perpage < $arr[0])
 ++$pages;
if ($page < 1)
 $page = 1;
else
 if ($page > $pages)
   $page = $pages;
for ($i = 1; $i <= $pages; ++$i)
 if ($i == $page)
   $pagemenu .= "$i\n";
 else
   $pagemenu .= "<a href='?$q&amp;page=$i'>$i</a>\n";
if ($page == 1)
 $browsemenu .= "";
//  $browsemenu .= "[Prev]";
else
 $browsemenu .= "<a href='?$q&amp;page=" . ($page - 1) . "'>[Prev]</a>";
$browsemenu .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
if ($page == $pages)
 $browsemenu .= "";
//  $browsemenu .= "[Next]";
else
 $browsemenu .= "<a href='?$q&amp;page=" . ($page + 1) . "'>[Next]</a>";
$offset = ($page * $perpage) - $perpage;
$res = SQL_Query_exec("SELECT users.*, groups.level FROM users LEFT JOIN groups ON groups.group_id=users.class WHERE $query ORDER BY username LIMIT $offset,$perpage");
begin_table();
print("<tr><th class='table_head'>" . T_("USERNAME") . "</th><th class='table_head'>" . T_("REGISTERED") . "</th><th class='table_head'>" . T_("LAST_ACCESS") . "</th><th class='table_head'>" . T_("CLASS") . "</th><th class='table_head'>" . T_("COUNTRY") . "</th><th class='table_head'>" . T_("RATIO") . "</th></tr>\n");
while ($arr = mysqli_fetch_assoc($res)) {
 
       $cres = SQL_Query_exec("SELECT name,flagpic FROM countries WHERE id=$arr[country]");
       if ($carr = mysqli_fetch_assoc($cres)) {
           $country = "<td align=\"center\" class='table_col1' style='padding: 0px'><img src='$site_config[SITEURL]/images/countries/$carr[flagpic]' title='".htmlspecialchars($carr['name'])."' alt='".htmlspecialchars($carr['name'])."' /></td>";
       } else {
           $country = "<td align=\"center\"  class='table_col1' style='padding: 0px'><img src='$site_config[SITEURL]/images/countries/unknown.gif' alt='Unknown' /></td>";
       }
       /// Ratio added below
       $r = SQL_Query_exec("SELECT uploaded, downloaded FROM users WHERE id=$arr[id]");
       $user = mysqli_fetch_assoc($r);
       if ($user["downloaded"] > 0) {
           $ratio = number_format($user["uploaded"] / $user["downloaded"], 2);
           $ratio = "<font color=" . get_ratio_color($ratio) . ">$ratio</font>";
       }else{
           $ratio = "Inf";
       }
       /// End Ratio addition
     
/*  if ($arr['added'] == '0000-00-00 00:00:00')
       $arr['added'] = '-';
   if ($arr['last_access'] == '0000-00-00 00:00:00')
       $arr['last_access'] = T_("NEVER");*/
 print("<tr><td class='table_col1' align='left'><a href='account-details.php?id=$arr[id]'><b>$arr[username]</b></a>" .($arr["donated"] > 0 ? "<img src='$site_config[SITEURL]/images/star.png' border='0' alt='Donated' />" : "")."</td>" .
 "<td align=\"center\" class='table_col2'>".utc_to_tz($arr["added"])."</td><td align=\"center\" class='table_col1'>".utc_to_tz($arr["last_access"])."</td>".
   "<td class='table_col2' align='center'>" . T_($arr["level"]) . "</td>$country ". "<td class='table_col2' align='center'>" . $ratio . "</td></tr>\n");
}
end_table();
print("<p>$pagemenu<br />$browsemenu</p>");
end_frame();
stdfoot();
?>


TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2020-11-20 02:54:16
$search = trim($_GET['search']);

if (array_key_exists(‘search’, $_GET))

Faster and safer. While it’s missing a dictionary definition to the keys, it will still do it’s job.

Array structures are lightening fast on CPU and out of the box perfect for any version of PHP (including BETA 8).
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 1
  • Members: 0
  • Guests online: 1
  • Comments: 3
  • Messages: 1,728