mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 18:48:21 -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
|
@ -74,7 +74,7 @@ foreach ($rowset as $cnt => $row) {
|
|||
|
||||
function commify_callback($matches)
|
||||
{
|
||||
return number_format($matches[0]);
|
||||
return commify($matches[0]);
|
||||
}
|
||||
|
||||
function commify_ob($contents)
|
||||
|
|
|
@ -235,8 +235,8 @@ foreach ($cat_forums as $cid => $c) {
|
|||
'FORUM_ID' => $fid,
|
||||
'FORUM_NAME' => $fname_html,
|
||||
'FORUM_DESC' => $f['forum_desc'],
|
||||
'POSTS' => number_format($f['forum_posts']),
|
||||
'TOPICS' => number_format($f['forum_topics']),
|
||||
'POSTS' => commify($f['forum_posts']),
|
||||
'TOPICS' => commify($f['forum_topics']),
|
||||
'LAST_SF_ID' => $f['last_sf_id'] ?? null,
|
||||
'MODERATORS' => isset($moderators[$fid]) ? implode(', ', $moderators[$fid]) : '',
|
||||
'FORUM_FOLDER_ALT' => $new ? $lang['NEW'] : $lang['OLD'],
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -185,8 +185,8 @@ if (!$forum_data['forum_parent'] && isset($forums['f'][$forum_id]['subforums'])
|
|||
'FORUM_NAME' => $fname_html,
|
||||
'FORUM_DESC' => $forums['f'][$sf_forum_id]['forum_desc'],
|
||||
'U_VIEWFORUM' => FORUM_URL . $sf_forum_id,
|
||||
'TOPICS' => number_format($sf_data['forum_topics']),
|
||||
'POSTS' => number_format($sf_data['forum_posts']),
|
||||
'TOPICS' => commify($sf_data['forum_topics']),
|
||||
'POSTS' => commify($sf_data['forum_posts']),
|
||||
'LAST_POST' => $last_post,
|
||||
));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue