-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrUASparser.class.php
More file actions
45 lines (33 loc) · 1.11 KB
/
rUASparser.class.php
File metadata and controls
45 lines (33 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/**
some improvements for official clas
*/
require_once('rlib/UASparser.php');
class rUASparser extends UASparser
{
public $updateInterval = 286400; // 1 day
protected $is_bot = null;
protected $is_mobile = null;
public function __construct($cacheDirectory = null, $updateInterval = null) {
if(!$cacheDirectory) $cacheDirectory = dirname(__FILE__).'/uas-cache';
if(!is_dir($cacheDirectory)) @mkdir($cacheDirectory, 0777);
parent::__construct($cacheDirectory, $updateInterval);
}
public function Parse()
{
$info = parent::Parse();
$this->is_bot = !empty($info['typ']) && ($info['typ'] == 'Robot');
$this->is_mobile = !empty($info['typ']) && ($info['typ'] == 'Mobile Browser' || $info['typ'] == 'Wap Browser');
return $info;
}
public function isBot()
{
if($this->is_bot === NULL) $this->Parse();
return $this->is_bot;
}
public function isMobile()
{
if($this->is_mobile === NULL) $this->Parse();
return $this->is_mobile;
}
}