From ff46ec48a47751a9731f7d97cc46036eb64eeb18 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Tue, 5 Dec 2023 16:18:33 +0700 Subject: [PATCH] Removed sys_getloadavg() (#1188) --- CHANGELOG.md | 1 - admin/stats/tr_stats.php | 8 -------- admin/stats/tracker.php | 8 -------- common.php | 7 +------ library/includes/cron/cron_run.php | 2 -- library/includes/page_footer.php | 8 -------- src/Legacy/Attach.php | 2 +- src/Legacy/SqlDb.php | 1 - 8 files changed, 2 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d20534c86..0b4e2814a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,6 @@ - Improved cookie management 🍪 [\#1171](https://github.com/torrentpier/torrentpier/pull/1171) ([belomaxorka](https://github.com/belomaxorka)) - Replaced strpos() with simplified realization [\#1172](https://github.com/torrentpier/torrentpier/pull/1172) ([belomaxorka](https://github.com/belomaxorka)) - Replaced some 'switch' with the 'match' expression [\#1173](https://github.com/torrentpier/torrentpier/pull/1173) ([belomaxorka](https://github.com/belomaxorka)) -- Replaced some time() with TIMENOW constant [\#1174](https://github.com/torrentpier/torrentpier/pull/1174) ([belomaxorka](https://github.com/belomaxorka)) - Feature to ban specific torrent clients [\#1175](https://github.com/torrentpier/torrentpier/pull/1175) ([kovalensky](https://github.com/kovalensky)) - Code re-formatting [\#1176](https://github.com/torrentpier/torrentpier/pull/1176) ([kovalensky](https://github.com/kovalensky)) - Removed useless width for BBCode buttons [\#1180](https://github.com/torrentpier/torrentpier/pull/1180) ([belomaxorka](https://github.com/belomaxorka)) diff --git a/admin/stats/tr_stats.php b/admin/stats/tr_stats.php index ba0951a83..d45ed4b2d 100644 --- a/admin/stats/tr_stats.php +++ b/admin/stats/tr_stats.php @@ -38,14 +38,6 @@ foreach ($sql as $i => $query) { echo ''; echo '
';
 
-if ($l = sys('la')) {
-    $l = explode(' ', $l);
-    for ($i = 0; $i < 3; $i++) {
-        $l[$i] = round($l[$i], 1);
-    }
-    echo "\n\nloadavg: $l[0] $l[1] $l[2]\n\n";
-}
-
 echo 'gen time: ' . sprintf('%.3f', array_sum(explode(' ', microtime())) - TIMESTART) . " sec\n";
 
 echo '
'; diff --git a/admin/stats/tracker.php b/admin/stats/tracker.php index 246508337..3ba7b8a1a 100644 --- a/admin/stats/tracker.php +++ b/admin/stats/tracker.php @@ -174,14 +174,6 @@ echo ''; echo !$client_full ? '

Simple stats for clients are being cached for one hour.

' : ''; echo '
';
 
-if ($l = sys('la')) {
-    $l = explode(' ', $l);
-    for ($i = 0; $i < 3; $i++) {
-        $l[$i] = round($l[$i], 1);
-    }
-    echo "\n\nloadavg: $l[0] $l[1] $l[2]\n\n";
-}
-
 echo 'gen time: ' . sprintf('%.3f', array_sum(explode(' ', microtime())) - TIMESTART) . " sec\n";
 echo '
'; echo ''; diff --git a/common.php b/common.php index a6b6b98d8..2f7f05ffa 100644 --- a/common.php +++ b/common.php @@ -334,18 +334,13 @@ function hide_bb_path(string $path): string return ltrim(str_replace(BB_PATH, '', $path), '/\\'); } -function sys($param) +function sys(string $param) { switch ($param) { - case 'la': - return function_exists('sys_getloadavg') ? implode(' ', sys_getloadavg()) : 0; - break; case 'mem': return memory_get_usage(); - break; case 'mem_peak': return memory_get_peak_usage(); - break; default: trigger_error("invalid param: $param", E_USER_ERROR); } diff --git a/library/includes/cron/cron_run.php b/library/includes/cron/cron_run.php index bce726b9c..dab485707 100644 --- a/library/includes/cron/cron_run.php +++ b/library/includes/cron/cron_run.php @@ -54,7 +54,6 @@ foreach ($cron_jobs as $job) { $msg[] = 'start'; $msg[] = date('m-d'); $msg[] = date('H:i:s'); - $msg[] = sprintf('%-4s', round(sys('la'), 1)); $msg[] = sprintf('%05d', getmypid()); $msg[] = $job['cron_title']; $msg = implode(LOG_SEPR, $msg); @@ -78,7 +77,6 @@ foreach ($cron_jobs as $job) { $msg[] = ' end'; $msg[] = date('m-d'); $msg[] = date('H:i:s'); - $msg[] = sprintf('%-4s', round(sys('la'), 1)); $msg[] = sprintf('%05d', getmypid()); $msg[] = round(utime() - $cron_start_time) . '/' . round(utime() - TIMESTART) . ' sec'; $msg = implode(LOG_SEPR, $msg); diff --git a/library/includes/page_footer.php b/library/includes/page_footer.php index cf02bd87c..5102edcf4 100644 --- a/library/includes/page_footer.php +++ b/library/includes/page_footer.php @@ -53,14 +53,6 @@ if ($show_dbg_info) { $stat .= humn_size(sys('mem_peak'), 2) . ' / '; $stat .= humn_size(sys('mem'), 2); - if ($l = sys('la')) { - $l = explode(' ', $l); - for ($i = 0; $i < 3; $i++) { - $l[$i] = round($l[$i], 1); - } - $stat .= "  |  " . $lang['LIMIT'] . " $l[0] $l[1] $l[2]"; - } - $stat .= '  ]'; if (SQL_DEBUG) { diff --git a/src/Legacy/Attach.php b/src/Legacy/Attach.php index 6e817000e..0e7ecc3cf 100644 --- a/src/Legacy/Attach.php +++ b/src/Legacy/Attach.php @@ -847,7 +847,7 @@ class Attach $this->attach_filename = preg_replace('#([\xC2\xC3])([\x80-\xBF])#', 'chr(ord(\'$1\')<<6&0xC0|ord(\'$2\')&0x3F)', $this->attach_filename); $this->attach_filename = rawurlencode($this->attach_filename); $this->attach_filename = preg_replace("/(%[0-9A-F]{1,2})/i", '', $this->attach_filename); - $this->attach_filename = trim($this->attach_filename . '_' .make_rand_str(13)); + $this->attach_filename = trim($this->attach_filename . '_' . make_rand_str(13)); } $this->attach_filename = str_replace(['&', '&', ' '], '_', $this->attach_filename); $this->attach_filename = str_replace('php', '_php_', $this->attach_filename); diff --git a/src/Legacy/SqlDb.php b/src/Legacy/SqlDb.php index f6a772759..8a366b2f0 100644 --- a/src/Legacy/SqlDb.php +++ b/src/Legacy/SqlDb.php @@ -891,7 +891,6 @@ class SqlDb $msg[] = round($this->sql_starttime); $msg[] = date('m-d H:i:s', $this->sql_starttime); $msg[] = sprintf('%-6s', $q_time); - $msg[] = sprintf('%-4s', round(sys('la'), 1)); $msg[] = sprintf('%05d', getmypid()); $msg[] = $this->db_server; $msg[] = Dev::short_query($this->cur_query);