Completed
Push — master ( c40a3c...7281f1 )
by Mark
9s
created
src/CrawlerDetect.php 1 patch
Indentation   +431 added lines, -431 removed lines patch added patch discarded remove patch
@@ -4,453 +4,453 @@
 block discarded – undo
4 4
 
5 5
 class CrawlerDetect
6 6
 {
7
-    /**
8
-     * The user agent.
9
-     *
10
-     * @var null
11
-     */
12
-    protected $userAgent = null;
7
+	/**
8
+	 * The user agent.
9
+	 *
10
+	 * @var null
11
+	 */
12
+	protected $userAgent = null;
13 13
 
14
-    /**
15
-     * Headers that contain a user agent.
16
-     *
17
-     * @var array
18
-     */
19
-    protected $httpHeaders = array();
14
+	/**
15
+	 * Headers that contain a user agent.
16
+	 *
17
+	 * @var array
18
+	 */
19
+	protected $httpHeaders = array();
20 20
 
21
-    /**
22
-     * Store regex matches.
23
-     *
24
-     * @var array
25
-     */
26
-    protected $matches = array();
21
+	/**
22
+	 * Store regex matches.
23
+	 *
24
+	 * @var array
25
+	 */
26
+	protected $matches = array();
27 27
 
28
-    /**
29
-     * List of strings to remove from the user agent before running the crawler regex
30
-     * Over a large list of user agents, this gives us about a 55% speed increase!
31
-     *
32
-     * @var array
33
-     */
34
-    protected static $ignore = array(
35
-        'Safari.[\d\.]*',
36
-        'Firefox.[\d\.]*',
37
-        'Chrome.[\d\.]*',
38
-        'Chromium.[\d\.]*',
39
-        'MSIE.[\d\.]',
40
-        'Opera\/[\d\.]*',
41
-        'Mozilla.[\d\.]*',
42
-        'AppleWebKit.[\d\.]*',
43
-        'Trident.[\d\.]*',
44
-        'Windows NT.[\d\.]*',
45
-        'Android.[\d\.]*',
46
-        'Macintosh.',
47
-        'Ubuntu',
48
-        'Linux',
49
-        '[ ]Intel',
50
-        'Mac OS X [\d_]*',
51
-        '(like )?Gecko(.[\d\.]*)?',
52
-        'KHTML',
53
-        'CriOS.[\d\.]*',
54
-        'CPU iPhone OS ([0-9_])* like Mac OS X',
55
-        'CPU OS ([0-9_])* like Mac OS X',
56
-        'iPod',
57
-        'compatible',
58
-        'x86_..',
59
-        'i686',
60
-        'x64',
61
-        'X11',
62
-        'rv:[\d\.]*',
63
-        'Version.[\d\.]*',
64
-        'WOW64',
65
-        'Win64',
66
-        'Dalvik.[\d\.]*',
67
-        '\.NET CLR [\d\.]*',
68
-        'Presto.[\d\.]*',
69
-        'Media Center PC',
70
-        'BlackBerry',
71
-        'Build',
72
-        'Opera Mini\/\d{1,2}\.\d{1,2}\.[\d\.]*\/\d{1,2}\.',
73
-        'Opera',
74
-        '\.NET[\d\.]*',
75
-        '\(|\)|;|,', // Remove the following characters ( ) : ,
76
-    );
28
+	/**
29
+	 * List of strings to remove from the user agent before running the crawler regex
30
+	 * Over a large list of user agents, this gives us about a 55% speed increase!
31
+	 *
32
+	 * @var array
33
+	 */
34
+	protected static $ignore = array(
35
+		'Safari.[\d\.]*',
36
+		'Firefox.[\d\.]*',
37
+		'Chrome.[\d\.]*',
38
+		'Chromium.[\d\.]*',
39
+		'MSIE.[\d\.]',
40
+		'Opera\/[\d\.]*',
41
+		'Mozilla.[\d\.]*',
42
+		'AppleWebKit.[\d\.]*',
43
+		'Trident.[\d\.]*',
44
+		'Windows NT.[\d\.]*',
45
+		'Android.[\d\.]*',
46
+		'Macintosh.',
47
+		'Ubuntu',
48
+		'Linux',
49
+		'[ ]Intel',
50
+		'Mac OS X [\d_]*',
51
+		'(like )?Gecko(.[\d\.]*)?',
52
+		'KHTML',
53
+		'CriOS.[\d\.]*',
54
+		'CPU iPhone OS ([0-9_])* like Mac OS X',
55
+		'CPU OS ([0-9_])* like Mac OS X',
56
+		'iPod',
57
+		'compatible',
58
+		'x86_..',
59
+		'i686',
60
+		'x64',
61
+		'X11',
62
+		'rv:[\d\.]*',
63
+		'Version.[\d\.]*',
64
+		'WOW64',
65
+		'Win64',
66
+		'Dalvik.[\d\.]*',
67
+		'\.NET CLR [\d\.]*',
68
+		'Presto.[\d\.]*',
69
+		'Media Center PC',
70
+		'BlackBerry',
71
+		'Build',
72
+		'Opera Mini\/\d{1,2}\.\d{1,2}\.[\d\.]*\/\d{1,2}\.',
73
+		'Opera',
74
+		'\.NET[\d\.]*',
75
+		'\(|\)|;|,', // Remove the following characters ( ) : ,
76
+	);
77 77
 
78
-    /**
79
-     * Array of regular expressions to match against the user agent.
80
-     *
81
-     * @var array
82
-     */
83
-    protected static $crawlers = array(
84
-        '008\\/',
85
-        'A6-Indexer',
86
-        'Aboundex',
87
-        'Accoona-AI-Agent',
88
-        'acoon',
89
-        'AddThis',
90
-        'ADmantX',
91
-        'AHC',
92
-        'Airmail',
93
-        'Anemone',
94
-        'Arachmo',
95
-        'archive-com',
96
-        'B-l-i-t-z-B-O-T',
97
-        'bibnum\.bnf',
98
-        'biglotron',
99
-        'binlar',
100
-        'BingPreview',
101
-        'boitho\.com-dc',
102
-        'BrokenLinkCheck\.com',
103
-        'BUbiNG',
104
-        'Butterfly\\/',
105
-        'BuzzSumo',
106
-        'CapsuleChecker',
107
-        'CC Metadata Scaper',
108
-        'Cerberian Drtrs',
109
-        'changedetection',
110
-        'Charlotte',
111
-        'clips\.ua\.ac\.be',
112
-        'CloudFlare-AlwaysOnline',
113
-        'coccoc',
114
-        'Commons-HttpClient',
115
-        'convera',
116
-        'cosmos',
117
-        'Covario-IDS',
118
-        'curl',
119
-        'CyberPatrol',
120
-        'Dragonfly File Reader',
121
-        'DataparkSearch',
122
-        'dataprovider',
123
-        'Digg',
124
-        'DomainAppender',
125
-        'drupact',
126
-        'EARTHCOM',
127
-        'ECCP',
128
-        'ec2linkfinder',
129
-        'ElectricMonk',
130
-        'Embedly',
131
-        'europarchive\.org',
132
-        'EventMachine HttpClient',
133
-        'ExactSearch',
134
-        'ezooms',
135
-        'eZ Publish Link Validator',
136
-        'facebookexternalhit',
137
-        'FeedBurner',
138
-        'Feedfetcher-Google',
139
-        'FeedValidator',
140
-        'FindLinks',
141
-        'findlink',
142
-        'findthatfile',
143
-        'Flamingo_SearchEngine',
144
-        'fluffy',
145
-        'getprismatic\.com',
146
-        'g00g1e\.net',
147
-        'GigablastOpenSource',
148
-        'grub-client',
149
-        'Genieo',
150
-        'Go-http-client',
151
-        'Google-HTTP-Java-Client',
152
-        'Google favicon',
153
-        'Google Keyword Suggestion',
154
-        'GoogleProducer',
155
-        'heritrix',
156
-        'Holmes',
157
-        'htdig',
158
-        'httpunit',
159
-        'httrack',
160
-        'HubSpot Marketing Grader',
161
-        'ichiro',
162
-        'infegy',
163
-        'igdeSpyder',
164
-        'InAGist',
165
-        'InfoWizards Reciprocal Link System PRO',
166
-        'integromedb',
167
-        'IODC',
168
-        'IOI',
169
-        'ips-agent',
170
-        'iZSearch',
171
-        'L\.webis',
172
-        'Larbin',
173
-        'libwww',
174
-        'Link Valet',
175
-        'linkdex',
176
-        'LinkExaminer',
177
-        'LinkWalker',
178
-        'Lipperhey Link Explorer',
179
-        'Lipperhey SEO Service',
180
-        'LongURL API',
181
-        'ltx71',
182
-        'lwp-trivial',
183
-        'MegaIndex\.ru',
184
-        'mabontland',
185
-        'MagpieRSS',
186
-        'Mediapartners-Google',
187
-        'MetaURI',
188
-        'Mnogosearch',
189
-        'mogimogi',
190
-        'Morning Paper',
191
-        'Mrcgiguy',
192
-        'MVAClient',
193
-        'Netcraft Web Server Survey',
194
-        'netresearchserver',
195
-        'Netvibes',
196
-        'NewsGator',
197
-        'newsme',
198
-        'NG-Search',
199
-        '^NING\\/',
200
-        'nineconnections\.com',
201
-        'nominet\.org\.uk',
202
-        'Notifixious',
203
-        'nutch',
204
-        'NutchCVS',
205
-        'Nymesis',
206
-        'oegp',
207
-        'Omea Reader',
208
-        'online link validator',
209
-        'Online Website Link Checker',
210
-        'Orbiter',
211
-        'ow\.ly',
212
-        'Ploetz \+ Zeller',
213
-        'PagePeeker',
214
-        'page2rss',
215
-        'panscient',
216
-        'Peew',
217
-        'phpcrawl',
218
-        'Pinterest',
219
-        'Pizilla',
220
-        'Plukkie',
221
-        'Pompos',
222
-        'postano',
223
-        'PostPost',
224
-        'postrank',
225
-        'proximic',
226
-        'Pulsepoint XT3 web scraper',
227
-        'PycURL',
228
-        'Python-httplib2',
229
-        'python-requests',
230
-        'Python-urllib',
231
-        'Qseero',
232
-        'Qwantify',
233
-        'Radian6',
234
-        'RebelMouse',
235
-        'REL Link Checker',
236
-        'RetrevoPageAnalyzer',
237
-        'Riddler',
238
-        'Robosourcer',
239
-        'Ruby',
240
-        'SBIder',
241
-        'ScoutJet',
242
-        'ScoutURLMonitor',
243
-        'Scrapy',
244
-        'Scrubby',
245
-        'SearchSight',
246
-        'semanticdiscovery',
247
-        'SEOstats',
248
-        'Seznam screenshot-generator',
249
-        'ShopWiki',
250
-        'SimplePie',
251
-        'SiteBar',
252
-        'siteexplorer\.info',
253
-        'slider\.com',
254
-        'slurp',
255
-        'Snappy',
256
-        'sogou',
257
-        'speedy',
258
-        'Springshare Link Checker',
259
-        'Sqworm',
260
-        'StackRambler',
261
-        'Stratagems Kumo',
262
-        'summify',
263
-        'teoma',
264
-        'theoldreader\.com',
265
-        'TinEye',
266
-        'Traackr.com',
267
-        'truwoGPS',
268
-        'Typhoeus',
269
-        'tweetedtimes\.com',
270
-        'Twikle',
271
-        'UdmSearch',
272
-        'UnwindFetchor',
273
-        'updated',
274
-        'URLChecker',
275
-        'urlresolver',
276
-        'Validator\.nu\\/LV',
277
-        'Vagabondo',
278
-        'Vivante Link Checker',
279
-        'Vortex',
280
-        'voyager\\/',
281
-        'VYU2',
282
-        'W3C-checklink',
283
-        'W3C_CSS_Validator_JFouffa',
284
-        'W3C_I18n-Checker',
285
-        'W3C-mobileOK',
286
-        'W3C_Unicorn',
287
-        'W3C_Validator',
288
-        'WebIndex',
289
-        'Websquash\.com',
290
-        'webcollage',
291
-        'webmon ',
292
-        'WeSEE:Search',
293
-        'wf84',
294
-        'wget',
295
-        'WomlpeFactory',
296
-        'wotbox',
297
-        'Xenu Link Sleuth',
298
-        'XML Sitemaps Generator',
299
-        'Y!J-ASR',
300
-        'yacy',
301
-        'Yahoo Ad monitoring',
302
-        'Yahoo Link Preview',
303
-        'Yahoo! Slurp China',
304
-        'Yahoo! Slurp',
305
-        'YahooSeeker',
306
-        'YahooSeeker-Testing',
307
-        'YandexImages',
308
-        'YandexMetrika',
309
-        'YandexDirectDyn',
310
-        'yandex',
311
-        'yanga',
312
-        'yeti',
313
-        'yoogliFetchAgent',
314
-        'Zao',
315
-        'ZyBorg',
316
-        '[a-z0-9\\-_]*((?<!cu)bot|crawler|archiver|transcoder|spider)',
317
-    );
78
+	/**
79
+	 * Array of regular expressions to match against the user agent.
80
+	 *
81
+	 * @var array
82
+	 */
83
+	protected static $crawlers = array(
84
+		'008\\/',
85
+		'A6-Indexer',
86
+		'Aboundex',
87
+		'Accoona-AI-Agent',
88
+		'acoon',
89
+		'AddThis',
90
+		'ADmantX',
91
+		'AHC',
92
+		'Airmail',
93
+		'Anemone',
94
+		'Arachmo',
95
+		'archive-com',
96
+		'B-l-i-t-z-B-O-T',
97
+		'bibnum\.bnf',
98
+		'biglotron',
99
+		'binlar',
100
+		'BingPreview',
101
+		'boitho\.com-dc',
102
+		'BrokenLinkCheck\.com',
103
+		'BUbiNG',
104
+		'Butterfly\\/',
105
+		'BuzzSumo',
106
+		'CapsuleChecker',
107
+		'CC Metadata Scaper',
108
+		'Cerberian Drtrs',
109
+		'changedetection',
110
+		'Charlotte',
111
+		'clips\.ua\.ac\.be',
112
+		'CloudFlare-AlwaysOnline',
113
+		'coccoc',
114
+		'Commons-HttpClient',
115
+		'convera',
116
+		'cosmos',
117
+		'Covario-IDS',
118
+		'curl',
119
+		'CyberPatrol',
120
+		'Dragonfly File Reader',
121
+		'DataparkSearch',
122
+		'dataprovider',
123
+		'Digg',
124
+		'DomainAppender',
125
+		'drupact',
126
+		'EARTHCOM',
127
+		'ECCP',
128
+		'ec2linkfinder',
129
+		'ElectricMonk',
130
+		'Embedly',
131
+		'europarchive\.org',
132
+		'EventMachine HttpClient',
133
+		'ExactSearch',
134
+		'ezooms',
135
+		'eZ Publish Link Validator',
136
+		'facebookexternalhit',
137
+		'FeedBurner',
138
+		'Feedfetcher-Google',
139
+		'FeedValidator',
140
+		'FindLinks',
141
+		'findlink',
142
+		'findthatfile',
143
+		'Flamingo_SearchEngine',
144
+		'fluffy',
145
+		'getprismatic\.com',
146
+		'g00g1e\.net',
147
+		'GigablastOpenSource',
148
+		'grub-client',
149
+		'Genieo',
150
+		'Go-http-client',
151
+		'Google-HTTP-Java-Client',
152
+		'Google favicon',
153
+		'Google Keyword Suggestion',
154
+		'GoogleProducer',
155
+		'heritrix',
156
+		'Holmes',
157
+		'htdig',
158
+		'httpunit',
159
+		'httrack',
160
+		'HubSpot Marketing Grader',
161
+		'ichiro',
162
+		'infegy',
163
+		'igdeSpyder',
164
+		'InAGist',
165
+		'InfoWizards Reciprocal Link System PRO',
166
+		'integromedb',
167
+		'IODC',
168
+		'IOI',
169
+		'ips-agent',
170
+		'iZSearch',
171
+		'L\.webis',
172
+		'Larbin',
173
+		'libwww',
174
+		'Link Valet',
175
+		'linkdex',
176
+		'LinkExaminer',
177
+		'LinkWalker',
178
+		'Lipperhey Link Explorer',
179
+		'Lipperhey SEO Service',
180
+		'LongURL API',
181
+		'ltx71',
182
+		'lwp-trivial',
183
+		'MegaIndex\.ru',
184
+		'mabontland',
185
+		'MagpieRSS',
186
+		'Mediapartners-Google',
187
+		'MetaURI',
188
+		'Mnogosearch',
189
+		'mogimogi',
190
+		'Morning Paper',
191
+		'Mrcgiguy',
192
+		'MVAClient',
193
+		'Netcraft Web Server Survey',
194
+		'netresearchserver',
195
+		'Netvibes',
196
+		'NewsGator',
197
+		'newsme',
198
+		'NG-Search',
199
+		'^NING\\/',
200
+		'nineconnections\.com',
201
+		'nominet\.org\.uk',
202
+		'Notifixious',
203
+		'nutch',
204
+		'NutchCVS',
205
+		'Nymesis',
206
+		'oegp',
207
+		'Omea Reader',
208
+		'online link validator',
209
+		'Online Website Link Checker',
210
+		'Orbiter',
211
+		'ow\.ly',
212
+		'Ploetz \+ Zeller',
213
+		'PagePeeker',
214
+		'page2rss',
215
+		'panscient',
216
+		'Peew',
217
+		'phpcrawl',
218
+		'Pinterest',
219
+		'Pizilla',
220
+		'Plukkie',
221
+		'Pompos',
222
+		'postano',
223
+		'PostPost',
224
+		'postrank',
225
+		'proximic',
226
+		'Pulsepoint XT3 web scraper',
227
+		'PycURL',
228
+		'Python-httplib2',
229
+		'python-requests',
230
+		'Python-urllib',
231
+		'Qseero',
232
+		'Qwantify',
233
+		'Radian6',
234
+		'RebelMouse',
235
+		'REL Link Checker',
236
+		'RetrevoPageAnalyzer',
237
+		'Riddler',
238
+		'Robosourcer',
239
+		'Ruby',
240
+		'SBIder',
241
+		'ScoutJet',
242
+		'ScoutURLMonitor',
243
+		'Scrapy',
244
+		'Scrubby',
245
+		'SearchSight',
246
+		'semanticdiscovery',
247
+		'SEOstats',
248
+		'Seznam screenshot-generator',
249
+		'ShopWiki',
250
+		'SimplePie',
251
+		'SiteBar',
252
+		'siteexplorer\.info',
253
+		'slider\.com',
254
+		'slurp',
255
+		'Snappy',
256
+		'sogou',
257
+		'speedy',
258
+		'Springshare Link Checker',
259
+		'Sqworm',
260
+		'StackRambler',
261
+		'Stratagems Kumo',
262
+		'summify',
263
+		'teoma',
264
+		'theoldreader\.com',
265
+		'TinEye',
266
+		'Traackr.com',
267
+		'truwoGPS',
268
+		'Typhoeus',
269
+		'tweetedtimes\.com',
270
+		'Twikle',
271
+		'UdmSearch',
272
+		'UnwindFetchor',
273
+		'updated',
274
+		'URLChecker',
275
+		'urlresolver',
276
+		'Validator\.nu\\/LV',
277
+		'Vagabondo',
278
+		'Vivante Link Checker',
279
+		'Vortex',
280
+		'voyager\\/',
281
+		'VYU2',
282
+		'W3C-checklink',
283
+		'W3C_CSS_Validator_JFouffa',
284
+		'W3C_I18n-Checker',
285
+		'W3C-mobileOK',
286
+		'W3C_Unicorn',
287
+		'W3C_Validator',
288
+		'WebIndex',
289
+		'Websquash\.com',
290
+		'webcollage',
291
+		'webmon ',
292
+		'WeSEE:Search',
293
+		'wf84',
294
+		'wget',
295
+		'WomlpeFactory',
296
+		'wotbox',
297
+		'Xenu Link Sleuth',
298
+		'XML Sitemaps Generator',
299
+		'Y!J-ASR',
300
+		'yacy',
301
+		'Yahoo Ad monitoring',
302
+		'Yahoo Link Preview',
303
+		'Yahoo! Slurp China',
304
+		'Yahoo! Slurp',
305
+		'YahooSeeker',
306
+		'YahooSeeker-Testing',
307
+		'YandexImages',
308
+		'YandexMetrika',
309
+		'YandexDirectDyn',
310
+		'yandex',
311
+		'yanga',
312
+		'yeti',
313
+		'yoogliFetchAgent',
314
+		'Zao',
315
+		'ZyBorg',
316
+		'[a-z0-9\\-_]*((?<!cu)bot|crawler|archiver|transcoder|spider)',
317
+	);
318 318
 
319
-    /**
320
-     * All possible HTTP headers that represent the
321
-     * User-Agent string.
322
-     *
323
-     * @var array
324
-     */
325
-    protected static $uaHttpHeaders = array(
326
-        // The default User-Agent string.
327
-        'HTTP_USER_AGENT',
328
-        // Header can occur on devices using Opera Mini.
329
-        'HTTP_X_OPERAMINI_PHONE_UA',
330
-        // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
331
-        'HTTP_X_DEVICE_USER_AGENT',
332
-        'HTTP_X_ORIGINAL_USER_AGENT',
333
-        'HTTP_X_SKYFIRE_PHONE',
334
-        'HTTP_X_BOLT_PHONE_UA',
335
-        'HTTP_DEVICE_STOCK_UA',
336
-        'HTTP_X_UCBROWSER_DEVICE_UA',
337
-    );
319
+	/**
320
+	 * All possible HTTP headers that represent the
321
+	 * User-Agent string.
322
+	 *
323
+	 * @var array
324
+	 */
325
+	protected static $uaHttpHeaders = array(
326
+		// The default User-Agent string.
327
+		'HTTP_USER_AGENT',
328
+		// Header can occur on devices using Opera Mini.
329
+		'HTTP_X_OPERAMINI_PHONE_UA',
330
+		// Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
331
+		'HTTP_X_DEVICE_USER_AGENT',
332
+		'HTTP_X_ORIGINAL_USER_AGENT',
333
+		'HTTP_X_SKYFIRE_PHONE',
334
+		'HTTP_X_BOLT_PHONE_UA',
335
+		'HTTP_DEVICE_STOCK_UA',
336
+		'HTTP_X_UCBROWSER_DEVICE_UA',
337
+	);
338 338
 
339
-    /**
340
-     * Class constructor.
341
-     */
342
-    public function __construct(array $headers = null, $userAgent = null)
343
-    {
344
-        $this->setHttpHeaders($headers);
345
-        $this->setUserAgent($userAgent);
346
-    }
339
+	/**
340
+	 * Class constructor.
341
+	 */
342
+	public function __construct(array $headers = null, $userAgent = null)
343
+	{
344
+		$this->setHttpHeaders($headers);
345
+		$this->setUserAgent($userAgent);
346
+	}
347 347
 
348
-    /**
349
-     * Set HTTP headers.
350
-     *
351
-     * @param array $httpHeaders
352
-     */
353
-    public function setHttpHeaders($httpHeaders = null)
354
-    {
355
-        // use global _SERVER if $httpHeaders aren't defined
356
-        if (!is_array($httpHeaders) || !count($httpHeaders)) {
357
-            $httpHeaders = $_SERVER;
358
-        }
359
-        // clear existing headers
360
-        $this->httpHeaders = array();
361
-        // Only save HTTP headers. In PHP land, that means only _SERVER vars that
362
-        // start with HTTP_.
363
-        foreach ($httpHeaders as $key => $value) {
364
-            if (substr($key, 0, 5) === 'HTTP_') {
365
-                $this->httpHeaders[$key] = $value;
366
-            }
367
-        }
368
-    }
348
+	/**
349
+	 * Set HTTP headers.
350
+	 *
351
+	 * @param array $httpHeaders
352
+	 */
353
+	public function setHttpHeaders($httpHeaders = null)
354
+	{
355
+		// use global _SERVER if $httpHeaders aren't defined
356
+		if (!is_array($httpHeaders) || !count($httpHeaders)) {
357
+			$httpHeaders = $_SERVER;
358
+		}
359
+		// clear existing headers
360
+		$this->httpHeaders = array();
361
+		// Only save HTTP headers. In PHP land, that means only _SERVER vars that
362
+		// start with HTTP_.
363
+		foreach ($httpHeaders as $key => $value) {
364
+			if (substr($key, 0, 5) === 'HTTP_') {
365
+				$this->httpHeaders[$key] = $value;
366
+			}
367
+		}
368
+	}
369 369
 
370
-    /**
371
-     * Return user agent headers.
372
-     *
373
-     * @return array
374
-     */
375
-    public function getUaHttpHeaders()
376
-    {
377
-        return self::$uaHttpHeaders;
378
-    }
370
+	/**
371
+	 * Return user agent headers.
372
+	 *
373
+	 * @return array
374
+	 */
375
+	public function getUaHttpHeaders()
376
+	{
377
+		return self::$uaHttpHeaders;
378
+	}
379 379
 
380
-    /**
381
-     * Set the user agent.
382
-     *
383
-     * @param string $userAgent
384
-     */
385
-    public function setUserAgent($userAgent = null)
386
-    {
387
-        if (false === empty($userAgent)) {
388
-            return $this->userAgent = $userAgent;
389
-        } else {
390
-            $this->userAgent = null;
391
-            foreach ($this->getUaHttpHeaders() as $altHeader) {
392
-                if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow.
393
-                    $this->userAgent .= $this->httpHeaders[$altHeader].' ';
394
-                }
395
-            }
380
+	/**
381
+	 * Set the user agent.
382
+	 *
383
+	 * @param string $userAgent
384
+	 */
385
+	public function setUserAgent($userAgent = null)
386
+	{
387
+		if (false === empty($userAgent)) {
388
+			return $this->userAgent = $userAgent;
389
+		} else {
390
+			$this->userAgent = null;
391
+			foreach ($this->getUaHttpHeaders() as $altHeader) {
392
+				if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow.
393
+					$this->userAgent .= $this->httpHeaders[$altHeader].' ';
394
+				}
395
+			}
396 396
 
397
-            return $this->userAgent = (!empty($this->userAgent) ? trim($this->userAgent) : null);
398
-        }
399
-    }
397
+			return $this->userAgent = (!empty($this->userAgent) ? trim($this->userAgent) : null);
398
+		}
399
+	}
400 400
 
401
-    /**
402
-     * Build the user agent regex.
403
-     *
404
-     * @return string
405
-     */
406
-    public function getRegex()
407
-    {
408
-        return '('.implode('|', self::$crawlers).')';
409
-    }
401
+	/**
402
+	 * Build the user agent regex.
403
+	 *
404
+	 * @return string
405
+	 */
406
+	public function getRegex()
407
+	{
408
+		return '('.implode('|', self::$crawlers).')';
409
+	}
410 410
 
411
-    /**
412
-     * Build the replacement regex.
413
-     *
414
-     * @return string
415
-     */
416
-    public function getIgnored()
417
-    {
418
-        return '('.implode('|', self::$ignore).')';
419
-    }
411
+	/**
412
+	 * Build the replacement regex.
413
+	 *
414
+	 * @return string
415
+	 */
416
+	public function getIgnored()
417
+	{
418
+		return '('.implode('|', self::$ignore).')';
419
+	}
420 420
 
421
-    /**
422
-     * Check user agent string against the regex.
423
-     *
424
-     * @param string $userAgent
425
-     *
426
-     * @return bool
427
-     */
428
-    public function isCrawler($userAgent = null)
429
-    {
430
-        $agent = is_null($userAgent) ? $this->userAgent : $userAgent;
421
+	/**
422
+	 * Check user agent string against the regex.
423
+	 *
424
+	 * @param string $userAgent
425
+	 *
426
+	 * @return bool
427
+	 */
428
+	public function isCrawler($userAgent = null)
429
+	{
430
+		$agent = is_null($userAgent) ? $this->userAgent : $userAgent;
431 431
 
432
-        $agent = preg_replace('/'.$this->getIgnored().'/i', '', $agent);
432
+		$agent = preg_replace('/'.$this->getIgnored().'/i', '', $agent);
433 433
 
434
-        if (trim($agent) === false) {
435
-            return false;
436
-        } else {
437
-            $result = preg_match('/'.$this->getRegex().'/i', trim($agent), $matches);
438
-        }
434
+		if (trim($agent) === false) {
435
+			return false;
436
+		} else {
437
+			$result = preg_match('/'.$this->getRegex().'/i', trim($agent), $matches);
438
+		}
439 439
 
440
-        if ($matches) {
441
-            $this->matches = $matches;
442
-        }
440
+		if ($matches) {
441
+			$this->matches = $matches;
442
+		}
443 443
 
444
-        return (bool) $result;
445
-    }
444
+		return (bool) $result;
445
+	}
446 446
 
447
-    /**
448
-     * Return the matches.
449
-     *
450
-     * @return string
451
-     */
452
-    public function getMatches()
453
-    {
454
-        return $this->matches[0];
455
-    }
447
+	/**
448
+	 * Return the matches.
449
+	 *
450
+	 * @return string
451
+	 */
452
+	public function getMatches()
453
+	{
454
+		return $this->matches[0];
455
+	}
456 456
 }
Please login to merge, or discard this patch.