diff --git a/Access_Core.php b/Access_Core.php index 51b489a..d3af8c3 100644 --- a/Access_Core.php +++ b/Access_Core.php @@ -84,6 +84,23 @@ class Access_Core break; } $this->logs['list'] = $this->db->fetchAll($query); + foreach ($this->logs['list'] as &$row) { + $ua = new Access_UA($row['ua']); + if ($ua->isRobot()) { + $name = $ua->getRobotID(); + $version = $ua->getRobotVersion(); + } else { + $name = $ua->getBrowserName(); + $version = $ua->getBrowserVersion(); + } + if ($name == '') { + $row['display_name'] = _t('未知'); + } elseif ($version == '') { + $row['display_name'] = $name; + } else { + $row['display_name'] = $name . ' / ' . $version; + } + } $this->htmlEncode($this->logs['list']); diff --git a/Access_UA.php b/Access_UA.php index 9daa84f..051828e 100644 --- a/Access_UA.php +++ b/Access_UA.php @@ -102,14 +102,14 @@ class Access_UA { if ($this->robotID === null) { if (!empty($this->ua)) { - if (preg_match('#([a-zA-Z0-9]+(?:bot|spider))[ /]*([0-9.]*)#i', $this->ua, $matches)) { + if (preg_match('#([a-zA-Z0-9]+\s*(?:bot|spider))[ /]*([0-9.]*)#i', $this->ua, $matches)) { $this->robotID = $this->robotName = $matches[1]; $this->robotVersion = $matches[2]; } foreach (self::$robots as $val) { if (strpos($this->ual, $this->filter($val)) !== false) { $this->robotID = $this->robotName = $val; - $this->robotVersion = $val; + $this->robotVersion = ''; } } } @@ -117,7 +117,7 @@ class Access_UA if ($this->robotName == null) $this->robotName = ''; if ($this->robotVersion == null) $this->robotVersion = ''; } - return $this->robotID !== '' || $this->robotName !== ''; + return $this->robotID !== ''; } /** @@ -189,7 +189,7 @@ class Access_UA $this->osVersion = ''; } else { $this->osID = ''; - $this->osName = '未知'; + $this->osName = ''; $this->osVersion = ''; } } @@ -285,7 +285,7 @@ class Access_UA $this->browserVersion = $matches[2]; } else { $this->browserID = ''; - $this->browserName = '未知'; + $this->browserName = ''; $this->browserVersion = ''; } } diff --git a/page/console.php b/page/console.php index 8afc7b1..b6cf490 100644 --- a/page/console.php +++ b/page/console.php @@ -77,7 +77,7 @@ $access = new Access_Core(); "> - ua->getBrowserName() . ' / ' . $access->ua->getBrowserVersion(); ?> +