mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 13:54:02 -07:00
Fixed: [Deprecated] number_format(): Passing null to parameter (#729)
This commit is contained in:
parent
de076c80ef
commit
0c5f584bbd
5 changed files with 28 additions and 12 deletions
|
@ -17,7 +17,7 @@ $data = array();
|
|||
|
||||
// usercount
|
||||
$row = DB()->fetch_row("SELECT COUNT(*) AS usercount FROM " . BB_USERS . " WHERE user_id NOT IN(" . EXCLUDED_USERS . ")");
|
||||
$data['usercount'] = number_format($row['usercount']);
|
||||
$data['usercount'] = commify($row['usercount']);
|
||||
|
||||
// newestuser
|
||||
$row = DB()->fetch_row("SELECT user_id, username, user_rank FROM " . BB_USERS . " WHERE user_active = 1 ORDER BY user_id DESC LIMIT 1");
|
||||
|
@ -25,21 +25,21 @@ $data['newestuser'] = $row;
|
|||
|
||||
// post/topic count
|
||||
$row = DB()->fetch_row("SELECT SUM(forum_topics) AS topiccount, SUM(forum_posts) AS postcount FROM " . BB_FORUMS);
|
||||
$data['postcount'] = number_format($row['postcount']);
|
||||
$data['topiccount'] = number_format($row['topiccount']);
|
||||
$data['postcount'] = commify($row['postcount']);
|
||||
$data['topiccount'] = commify($row['topiccount']);
|
||||
|
||||
// Tracker stats
|
||||
if ($bb_cfg['tor_stats']) {
|
||||
// torrents stat
|
||||
$row = DB()->fetch_row("SELECT COUNT(topic_id) AS torrentcount, SUM(size) AS size FROM " . BB_BT_TORRENTS);
|
||||
$data['torrentcount'] = number_format($row['torrentcount']);
|
||||
$data['torrentcount'] = commify($row['torrentcount']);
|
||||
$data['size'] = $row['size'];
|
||||
|
||||
// peers stat
|
||||
$row = DB()->fetch_row("SELECT SUM(seeders) AS seeders, SUM(leechers) AS leechers, ((SUM(speed_up) + SUM(speed_down))/2) AS speed FROM " . BB_BT_TRACKER_SNAP);
|
||||
$data['seeders'] = number_format($row['seeders']);
|
||||
$data['leechers'] = number_format($row['leechers']);
|
||||
$data['peers'] = number_format($row['seeders'] + $row['leechers']);
|
||||
$data['seeders'] = commify($row['seeders']);
|
||||
$data['leechers'] = commify($row['leechers']);
|
||||
$data['peers'] = commify($row['seeders'] + $row['leechers']);
|
||||
$data['speed'] = $row['speed'];
|
||||
}
|
||||
|
||||
|
|
|
@ -360,6 +360,8 @@ function prn_r($var, $title = '', $print = true)
|
|||
}
|
||||
|
||||
/**
|
||||
* Convert special characters to HTML entities
|
||||
*
|
||||
* @param $txt
|
||||
* @param bool $double_encode
|
||||
* @param int $quote_style
|
||||
|
@ -371,6 +373,20 @@ function htmlCHR($txt, bool $double_encode = false, int $quote_style = ENT_QUOTE
|
|||
return (string)htmlspecialchars($txt ?? '', $quote_style, $charset, $double_encode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds commas between every group of thousands
|
||||
*
|
||||
* @param float|null $num
|
||||
* @param int $decimals
|
||||
* @param string|null $decimal_separator
|
||||
* @param string|null $thousands_separator
|
||||
* @return string
|
||||
*/
|
||||
function commify(?float $num, int $decimals = 0, ?string $decimal_separator = '.', ?string $thousands_separator = ','): string
|
||||
{
|
||||
return number_format($num ?? 0.0, $decimals, $decimal_separator, $thousands_separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $txt
|
||||
* @param int $quote_style
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue