From 47ab439325d3bab0c08879f95e9bdf8c22792241 Mon Sep 17 00:00:00 2001 From: whwyy Date: Wed, 15 Jul 2026 10:41:18 +0800 Subject: [PATCH] eee --- function.php | 84 ++++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/function.php b/function.php index f23c4b60..0c9bf438 100644 --- a/function.php +++ b/function.php @@ -212,47 +212,47 @@ if (!function_exists('call')) { } -if (!function_exists('checkPortIsAlready')) { - - - /** - * @param $port - * @return bool|string - */ - function checkPortIsAlready($port): bool|string - { - $port = (int)$port; - if ($port <= 0) { - return FALSE; - } - - if (!Kiri::getPlatform()->isLinux()) { - exec("lsof -i :" . $port . " | grep -i 'LISTEN' | awk '{print $2}'", $output); - if (empty($output)) { - return FALSE; - } - $output = explode(PHP_EOL, $output[0]); - return $output[0]; - } - - exec('netstat -lnp 2>/dev/null | grep :' . $port . ' | grep "LISTEN" | awk \'{print $7}\'', $output); - if (empty($output)) { - exec('ss -ltnp 2>/dev/null | grep :' . $port . ' | sed -n \"s/.*pid=\\([0-9]*\\).*/\\1/p\"', $output); - } - if (empty($output)) { - return FALSE; - } - - $pid = trim((string)$output[0]); - if (str_contains($pid, '/')) { - $pid = explode('/', $pid)[0]; - } - - return $pid !== '' ? $pid : FALSE; - } - -} - +if (!function_exists('checkPortIsAlready')) { + + + /** + * @param $port + * @return bool|string + */ + function checkPortIsAlready($port): bool|string + { + $port = (int)$port; + if ($port <= 0) { + return FALSE; + } + + if (!Kiri::getPlatform()->isLinux()) { + exec("lsof -i :" . $port . " | grep -i 'LISTEN' | awk '{print $2}'", $output); + if (empty($output)) { + return FALSE; + } + $output = explode(PHP_EOL, $output[0]); + return $output[0]; + } + + exec('netstat -lnp 2>/dev/null | grep :' . $port . ' | grep "LISTEN" | awk \'{print $7}\'', $output); + if (empty($output)) { + exec('ss -ltnp 2>/dev/null | grep :' . $port . ' | sed -n \"s/.*pid=\\([0-9]*\\).*/\\1/p\"', $output); + } + if (empty($output)) { + return FALSE; + } + + $pid = trim((string)$output[0]); + if (str_contains($pid, '/')) { + $pid = explode('/', $pid)[0]; + } + + return $pid !== '' ? $pid : FALSE; + } + +} + if (!function_exists('set_env')) { @@ -704,7 +704,7 @@ if (!function_exists('get_file_extension')) { } else if (function_exists('finfo_open')) { $fInfo = finfo_open(FILEINFO_MIME); $mimeType = finfo_file($fInfo, $filename); - finfo_close($fInfo); +// finfo_close($fInfo); $mimeType = current(explode('; ', $mimeType)); if (!($search = array_search($mimeType, $mime_types))) { return $mimeType;