From b91e3e84b2ce5083c599128331b96bd4e972d558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=93=87=E5=91=9C=E5=93=87=E5=91=9C=E5=91=80=E5=92=A6?= =?UTF-8?q?=E8=80=B6?= Date: Wed, 20 Sep 2023 17:51:53 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E9=80=82=E9=85=8D64=E4=BD=8D=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- device.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/device.php b/device.php index 3c7180d..00e9d62 100644 --- a/device.php +++ b/device.php @@ -42,6 +42,21 @@ if (($str = @file("/proc/cpuinfo")) !== false){ else{ $D['cpu']['model'] = $model[1][0].$bogomips[1][0].' ×'.$D['cpu']['count']; } + } else { + if (($str = @shell_exec("lscpu")) !== false){ + $str = implode("", $str); + @preg_match_all("/Model\s+name\s{0,}\:+\s{0,}([\w\s\)\(\@.-]+)([\r\n]+)/s", $str, $model); + @preg_match_all("/CPU\(s\)\s{0,}\:+\s{0,}(\d+)([\r\n]+)/s", $str, $cpucnt); + if (false !== is_array($model[1])) { + $D['cpu']['count'] = $cpucnt[1][0]; + if($D['cpu']['count'] == 1){ + $D['cpu']['model'] = $model[1][0].$bogomips[1][0]; + } + else{ + $D['cpu']['model'] = $model[1][0].$bogomips[1][0].' ×'.$D['cpu']['count']; + } + } + } } if (false !== is_array($pimodel[1])){ @@ -180,4 +195,4 @@ function get_info(){ $D['net']['count'] = 0; } } -?> \ No newline at end of file +?> From f3513719e82186640a082b9b8b6bbfa4afec9ee0 Mon Sep 17 00:00:00 2001 From: naosense Date: Thu, 21 Sep 2023 09:09:34 +0800 Subject: [PATCH 2/4] fix 64bit cpu info --- device.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/device.php b/device.php index 00e9d62..9eb6308 100644 --- a/device.php +++ b/device.php @@ -33,7 +33,7 @@ if (($str = @file("/proc/cpuinfo")) !== false){ @preg_match_all("/BogoMIPS\s{0,}\:+\s{0,}([\d\.]+)[\r\n]+/", $str, $bogomips); @preg_match_all("/Model\s{0,}\:+\s{0,}([\w\s\)\(\@.-]+)([\r\n]+)/s", $str, $pimodel); - if (false !== is_array($model[1])){ + if (false){ $D['cpu']['count'] = sizeof($model[1]); $bogomips[1][0] = ' | Bogomips:'.$bogomips[1][0]; if($D['cpu']['count'] == 1){ @@ -43,18 +43,16 @@ if (($str = @file("/proc/cpuinfo")) !== false){ $D['cpu']['model'] = $model[1][0].$bogomips[1][0].' ×'.$D['cpu']['count']; } } else { - if (($str = @shell_exec("lscpu")) !== false){ - $str = implode("", $str); - @preg_match_all("/Model\s+name\s{0,}\:+\s{0,}([\w\s\)\(\@.-]+)([\r\n]+)/s", $str, $model); - @preg_match_all("/CPU\(s\)\s{0,}\:+\s{0,}(\d+)([\r\n]+)/s", $str, $cpucnt); - if (false !== is_array($model[1])) { - $D['cpu']['count'] = $cpucnt[1][0]; - if($D['cpu']['count'] == 1){ - $D['cpu']['model'] = $model[1][0].$bogomips[1][0]; - } - else{ - $D['cpu']['model'] = $model[1][0].$bogomips[1][0].' ×'.$D['cpu']['count']; - } + $str = shell_exec("lscpu"); + @preg_match_all("/Model\s+name\s{0,}\:+\s{0,}([\w\s\)\(\@.-]+)([\r\n]+)/s", $str, $model); + @preg_match_all("/CPU\(s\)\s{0,}\:+\s{0,}(\d+)([\r\n]+)/s", $str, $cpucnt); + if (false !== is_array($model[1])) { + $D['cpu']['count'] = $cpucnt[1][0]; + if($D['cpu']['count'] == 1){ + $D['cpu']['model'] = $model[1][0].' '.$bogomips[1][0]; + } + else{ + $D['cpu']['model'] = $model[1][0].' '.$bogomips[1][0].' ×'.$D['cpu']['count']; } } } From 0f0b901bf6c1bde6c6c9a88c8810eef8f5a93d82 Mon Sep 17 00:00:00 2001 From: naosense Date: Thu, 21 Sep 2023 11:46:43 +0800 Subject: [PATCH 3/4] fix cpu info on arm64 --- device.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/device.php b/device.php index 9eb6308..3d94180 100644 --- a/device.php +++ b/device.php @@ -33,7 +33,7 @@ if (($str = @file("/proc/cpuinfo")) !== false){ @preg_match_all("/BogoMIPS\s{0,}\:+\s{0,}([\d\.]+)[\r\n]+/", $str, $bogomips); @preg_match_all("/Model\s{0,}\:+\s{0,}([\w\s\)\(\@.-]+)([\r\n]+)/s", $str, $pimodel); - if (false){ + if (is_array($model[1]) && !empty($model[1])){ $D['cpu']['count'] = sizeof($model[1]); $bogomips[1][0] = ' | Bogomips:'.$bogomips[1][0]; if($D['cpu']['count'] == 1){ @@ -48,11 +48,12 @@ if (($str = @file("/proc/cpuinfo")) !== false){ @preg_match_all("/CPU\(s\)\s{0,}\:+\s{0,}(\d+)([\r\n]+)/s", $str, $cpucnt); if (false !== is_array($model[1])) { $D['cpu']['count'] = $cpucnt[1][0]; + $bogomips[1][0] = ' | Bogomips:'.$bogomips[1][0]; if($D['cpu']['count'] == 1){ - $D['cpu']['model'] = $model[1][0].' '.$bogomips[1][0]; + $D['cpu']['model'] = $model[1][0].$bogomips[1][0]; } else{ - $D['cpu']['model'] = $model[1][0].' '.$bogomips[1][0].' ×'.$D['cpu']['count']; + $D['cpu']['model'] = $model[1][0].$bogomips[1][0].' ×'.$D['cpu']['count']; } } } From dbcc8789d0285839b19180d0b41ce44b79684e10 Mon Sep 17 00:00:00 2001 From: naosense Date: Thu, 21 Sep 2023 14:41:07 +0800 Subject: [PATCH 4/4] break word when the word is too long --- index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index d587d3b..c4b7466 100644 --- a/index.php +++ b/index.php @@ -214,7 +214,7 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'device.php');
-
+

IN

OUT
@@ -245,4 +245,4 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'device.php');
- \ No newline at end of file +