From f3513719e82186640a082b9b8b6bbfa4afec9ee0 Mon Sep 17 00:00:00 2001 From: naosense Date: Thu, 21 Sep 2023 09:09:34 +0800 Subject: [PATCH] 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']; } } }