Completed
Push — master ( 0af654...85d367 )
by Mark
03:39
created
src/CrawlerDetect.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
     public function setHttpHeaders($httpHeaders = null)
462 462
     {
463 463
         // use global _SERVER if $httpHeaders aren't defined
464
-        if (!is_array($httpHeaders) || !count($httpHeaders)) {
464
+        if ( ! is_array($httpHeaders) || ! count($httpHeaders)) {
465 465
             $httpHeaders = $_SERVER;
466 466
         }
467 467
         // clear existing headers
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
                 }
493 493
             }
494 494
 
495
-            return $this->userAgent = (!empty($this->userAgent) ? trim($this->userAgent) : null);
495
+            return $this->userAgent = ( ! empty($this->userAgent) ? trim($this->userAgent) : null);
496 496
         }
497 497
     }
498 498
 
Please login to merge, or discard this patch.
Indentation   +520 added lines, -520 removed lines patch added patch discarded remove patch
@@ -13,543 +13,543 @@
 block discarded – undo
13 13
 
14 14
 class CrawlerDetect
15 15
 {
16
-    /**
17
-     * The user agent.
18
-     *
19
-     * @var null
20
-     */
21
-    protected $userAgent = null;
16
+	/**
17
+	 * The user agent.
18
+	 *
19
+	 * @var null
20
+	 */
21
+	protected $userAgent = null;
22 22
 
23
-    /**
24
-     * Headers that contain a user agent.
25
-     *
26
-     * @var array
27
-     */
28
-    protected $httpHeaders = array();
23
+	/**
24
+	 * Headers that contain a user agent.
25
+	 *
26
+	 * @var array
27
+	 */
28
+	protected $httpHeaders = array();
29 29
 
30
-    /**
31
-     * Store regex matches.
32
-     *
33
-     * @var array
34
-     */
35
-    protected $matches = array();
30
+	/**
31
+	 * Store regex matches.
32
+	 *
33
+	 * @var array
34
+	 */
35
+	protected $matches = array();
36 36
 
37
-    /**
38
-     * List of strings to remove from the user agent before running the crawler regex
39
-     * Over a large list of user agents, this gives us about a 55% speed increase!
40
-     *
41
-     * @var array
42
-     */
43
-    protected static $ignore = array(
44
-        'Safari.[\d\.]*',
45
-        'Firefox.[\d\.]*',
46
-        'Chrome.[\d\.]*',
47
-        'Chromium.[\d\.]*',
48
-        'MSIE.[\d\.]',
49
-        'Opera\/[\d\.]*',
50
-        'Mozilla.[\d\.]*',
51
-        'AppleWebKit.[\d\.]*',
52
-        'Trident.[\d\.]*',
53
-        'Windows NT.[\d\.]*',
54
-        'Android.[\d\.]*',
55
-        'Macintosh.',
56
-        'Ubuntu',
57
-        'Linux',
58
-        '[ ]Intel',
59
-        'Mac OS X [\d_]*',
60
-        '(like )?Gecko(.[\d\.]*)?',
61
-        'KHTML',
62
-        'CriOS.[\d\.]*',
63
-        'CPU iPhone OS ([0-9_])* like Mac OS X',
64
-        'CPU OS ([0-9_])* like Mac OS X',
65
-        'iPod',
66
-        'compatible',
67
-        'x86_..',
68
-        'i686',
69
-        'x64',
70
-        'X11',
71
-        'rv:[\d\.]*',
72
-        'Version.[\d\.]*',
73
-        'WOW64',
74
-        'Win64',
75
-        'Dalvik.[\d\.]*',
76
-        ' \.NET CLR [\d\.]*',
77
-        'Presto.[\d\.]*',
78
-        'Media Center PC',
79
-        'BlackBerry',
80
-        'Build',
81
-        'Opera Mini\/\d{1,2}\.\d{1,2}\.[\d\.]*\/\d{1,2}\.',
82
-        'Opera',
83
-        ' \.NET[\d\.]*',
84
-        '\(|\)|;|,', // Remove the following characters ( ) : ,
85
-    );
37
+	/**
38
+	 * List of strings to remove from the user agent before running the crawler regex
39
+	 * Over a large list of user agents, this gives us about a 55% speed increase!
40
+	 *
41
+	 * @var array
42
+	 */
43
+	protected static $ignore = array(
44
+		'Safari.[\d\.]*',
45
+		'Firefox.[\d\.]*',
46
+		'Chrome.[\d\.]*',
47
+		'Chromium.[\d\.]*',
48
+		'MSIE.[\d\.]',
49
+		'Opera\/[\d\.]*',
50
+		'Mozilla.[\d\.]*',
51
+		'AppleWebKit.[\d\.]*',
52
+		'Trident.[\d\.]*',
53
+		'Windows NT.[\d\.]*',
54
+		'Android.[\d\.]*',
55
+		'Macintosh.',
56
+		'Ubuntu',
57
+		'Linux',
58
+		'[ ]Intel',
59
+		'Mac OS X [\d_]*',
60
+		'(like )?Gecko(.[\d\.]*)?',
61
+		'KHTML',
62
+		'CriOS.[\d\.]*',
63
+		'CPU iPhone OS ([0-9_])* like Mac OS X',
64
+		'CPU OS ([0-9_])* like Mac OS X',
65
+		'iPod',
66
+		'compatible',
67
+		'x86_..',
68
+		'i686',
69
+		'x64',
70
+		'X11',
71
+		'rv:[\d\.]*',
72
+		'Version.[\d\.]*',
73
+		'WOW64',
74
+		'Win64',
75
+		'Dalvik.[\d\.]*',
76
+		' \.NET CLR [\d\.]*',
77
+		'Presto.[\d\.]*',
78
+		'Media Center PC',
79
+		'BlackBerry',
80
+		'Build',
81
+		'Opera Mini\/\d{1,2}\.\d{1,2}\.[\d\.]*\/\d{1,2}\.',
82
+		'Opera',
83
+		' \.NET[\d\.]*',
84
+		'\(|\)|;|,', // Remove the following characters ( ) : ,
85
+	);
86 86
 
87
-    /**
88
-     * Array of regular expressions to match against the user agent.
89
-     *
90
-     * @var array
91
-     */
92
-    protected static $crawlers = array(
93
-        '.*Java.*outbrain',
94
-        '008\/',
95
-        '^NING\/',
96
-        'A6-Indexer',
97
-        'Aboundex',
98
-        'Accoona-AI-Agent',
99
-        'acoon',
100
-        'AddThis',
101
-        'ADmantX',
102
-        'AHC',
103
-        'Airmail',
104
-        'alexa site audit',
105
-        'Anemone',
106
-        'Apache-HttpClient\/',
107
-        'Arachmo',
108
-        'archive-com',
109
-        'B-l-i-t-z-B-O-T',
110
-        'Backlink-Ceck\.de',
111
-        'baidu\.com',
112
-        'BazQux',
113
-        'bibnum\.bnf',
114
-        'biglotron',
115
-        'BingLocalSearch',
116
-        'BingPreview',
117
-        'binlar',
118
-        'Bloglovin',
119
-        'Blogtrottr',
120
-        'boitho\.com-dc',
121
-        'Browsershots',
122
-        'BUbiNG',
123
-        'Butterfly\/',
124
-        'BuzzSumo',
125
-        'CapsuleChecker',
126
-        'CC Metadata Scaper',
127
-        'Cerberian Drtrs',
128
-        'changedetection',
129
-        'Charlotte',
130
-        'clips\.ua\.ac\.be',
131
-        'CloudFlare-AlwaysOnline',
132
-        'coccoc',
133
-        'CommaFeed',
134
-        'Commons-HttpClient',
135
-        'convera',
136
-        'cosmos',
137
-        'corporatetwitnews',
138
-        'Covario-IDS',
139
-        'cron-job\.org',
140
-        'Curious George',
141
-        'curl',
142
-        'CyberPatrol',
143
-        'DataparkSearch',
144
-        'dataprovider',
145
-        'Daum(oa)?[ \/][0-9]',
146
-        'developers\.google\.com\/\+\/web\/snippet\/',
147
-        'Digg',
148
-        'DomainAppender',
149
-        'Dragonfly File Reader',
150
-        'drupact',
151
-        'EARTHCOM',
152
-        'ec2linkfinder',
153
-        'ECCP',
154
-        'ElectricMonk',
155
-        'EMail Exractor',
156
-        'EmailWolf',
157
-        'Embed PHP Library',
158
-        'Embedly',
159
-        'europarchive\.org',
160
-        'EventMachine HttpClient',
161
-        'ExactSearch',
162
-        'ExaleadCloudview',
163
-        'ezooms',
164
-        'facebookexternalhit',
165
-        'facebookplatform',
166
-        'Feed Wrangler',
167
-        'Feedbin',
168
-        'FeedBurner',
169
-        'Feedfetcher-Google',
170
-        'Feedly',
171
-        'Feedspot',
172
-        'FeedValidator',
173
-        'Fever',
174
-        'findlink',
175
-        'findthatfile',
176
-        'Flamingo_SearchEngine',
177
-        'FlipboardProxy',
178
-        'fluffy',
179
-        'Funnelback',
180
-        'g00g1e\.net',
181
-        'Genieo',
182
-        'getprismatic\.com',
183
-        'GigablastOpenSource',
184
-        'Go-http-client',
185
-        'Google favicon',
186
-        'Google Keyword Suggestion',
187
-        'Google Page Speed Insights',
188
-        'Google Web Preview',
189
-        'Google-HTTP-Java-Client',
190
-        'Google-Site-Verification',
191
-        'google_partner_monitoring',
192
-        'GoogleProducer',
193
-        'Grammarly',
194
-        'grub-client',
195
-        'heritrix',
196
-        'Holmes',
197
-        'htdig',
198
-        'HTTPMon',
199
-        'http-kit',
200
-        'http_requester',
201
-        'httpunit',
202
-        'http_request2',
203
-        'httrack',
204
-        'HubPages.*crawlingpolicy',
205
-        'HubSpot Marketing Grader',
206
-        'ichiro',
207
-        'IDG Twitter Links Resolver',
208
-        'igdeSpyder',
209
-        'InAGist',
210
-        'infegy',
211
-        'InfoWizards Reciprocal Link System PRO',
212
-        'inpwrd\.com',
213
-        'integromedb',
214
-        'IODC',
215
-        'IOI',
216
-        'ips-agent',
217
-        'iZSearch',
218
-        '^Java\/',
219
-        'Jigsaw',
220
-        'Jobrapido',
221
-        'kouio',
222
-        'L\.webis',
223
-        'Larbin',
224
-        'libwww',
225
-        'Link Valet',
226
-        'linkCheck',
227
-        'linkdex',
228
-        'LinkExaminer',
229
-        'LinkWalker',
230
-        'Lipperhey',
231
-        'link checker',
232
-        'link validator',
233
-        'LongURL API',
234
-        'ltx71',
235
-        'lwp-trivial',
236
-        'lycos',
237
-        'mabontland',
238
-        'MagpieRSS',
239
-        'Mediapartners-Google',
240
-        'MegaIndex\.ru',
241
-        'MetaURI',
242
-        'MergeFlow-PageReader',
243
-        'Mnogosearch',
244
-        'mogimogi',
245
-        'Mojolicious (Perl)',
246
-        'Morning Paper',
247
-        'Mrcgiguy',
248
-        'MVAClient',
249
-        'Netcraft Web Server Survey',
250
-        'NetcraftSurveyAgent',
251
-        'NetLyzer FastProbe',
252
-        'netresearch',
253
-        'Netvibes',
254
-        'NewsBlur .*(Fetcher|Finder)',
255
-        'NewsGator',
256
-        'newsme',
257
-        'newspaper\/',
258
-        'NG-Search',
259
-        'nineconnections\.com',
260
-        'nominet\.org\.uk',
261
-        'Notifixious',
262
-        'nuhk',
263
-        'nutch',
264
-        'Nuzzel',
265
-        'Nymesis',
266
-        'oegp',
267
-        'Omea Reader',
268
-        'omgili',
269
-        'Orbiter',
270
-        'ow\.ly',
271
-        'Go [\d\.]* package http',
272
-        'page2rss',
273
-        'PagePeeker',
274
-        'panscient',
275
-        'Peew',
276
-        'PhantomJS\/',
277
-        'phpcrawl',
278
-        'phpservermon',
279
-        'Pingdom\.com',
280
-        'Pinterest',
281
-        'Pizilla',
282
-        'Ploetz \+ Zeller',
283
-        'Plukkie',
284
-        'PocketParser',
285
-        'Pompos',
286
-        'postano',
287
-        'PostPost',
288
-        'postrank',
289
-        'proximic',
290
-        'Pulsepoint XT3 web scraper',
291
-        'Python-httplib2',
292
-        'python-requests',
293
-        'Python-urllib',
294
-        'Qseero',
295
-        'Qwantify',
296
-        'Radian6',
297
-        'Readability',
298
-        'RebelMouse',
299
-        'RetrevoPageAnalyzer',
300
-        'Riddler',
301
-        'Robosourcer',
302
-        'ROI Hunter',
303
-        'Ruby',
304
-        'SalesIntelligent',
305
-        'SBIder',
306
-        'scooter',
307
-        'ScoutJet',
308
-        'ScoutURLMonitor',
309
-        'Scrapy',
310
-        'Scrubby',
311
-        'SearchSight',
312
-        'semanticdiscovery',
313
-        'SEOstats',
314
-        'Server Density Service Monitoring',
315
-        'servernfo\.com',
316
-        'Seznam screenshot-generator',
317
-        'ShopWiki',
318
-        'SilverReader',
319
-        'SimplePie',
320
-        'Site24x7',
321
-        'SiteBar',
322
-        'siteexplorer\.info',
323
-        'Siteimprove\.com',
324
-        'SkypeUriPreview',
325
-        'slider\.com',
326
-        'slurp',
327
-        'SMRF URL Expander',
328
-        'snapchat-proxy',
329
-        'Snappy',
330
-        'SNK Siteshooter B0t',
331
-        'sogou',
332
-        'SortSite',
333
-        'speedy',
334
-        'Spinn3r',
335
-        'Sqworm',
336
-        'StackRambler',
337
-        'Stratagems Kumo',
338
-        'summify',
339
-        'teoma',
340
-        'theoldreader\.com',
341
-        'TinEye',
342
-        'Tiny Tiny RSS',
343
-        'Traackr.com',
344
-        'truwoGPS',
345
-        'tweetedtimes\.com',
346
-        'Twikle',
347
-        'Typhoeus',
348
-        'ubermetrics-technologies',
349
-        'UdmSearch',
350
-        'UnwindFetchor',
351
-        'updated',
352
-        'URLChecker',
353
-        'urlresolver',
354
-        'Vagabondo',
355
-        'Validator\.nu\/LV',
356
-        'via ggpht\.com GoogleImageProxy',
357
-        'vkShare',
358
-        'Vortex',
359
-        'voyager\/',
360
-        'VYU2',
361
-        'W3C-checklink',
362
-        'W3C-mobileOK',
363
-        'W3C_CSS_Validator_JFouffa',
364
-        'W3C_I18n-Checker',
365
-        'W3C_Unicorn',
366
-        'W3C_Validator',
367
-        'Wappalyzer',
368
-        'WinHttpRequest',
369
-        'web-capture\.net',
370
-        'WebCapture',
371
-        'WebCorp',
372
-        'webcollage',
373
-        'WebIndex',
374
-        'WebFetch',
375
-        'webmon ',
376
-        'websitepulse[+ ]checker',
377
-        'Websquash\.com',
378
-        'WebThumbnail',
379
-        'WeSEE:Search',
380
-        'wf84',
381
-        'wget',
382
-        'WhatsApp',
383
-        'WomlpeFactory',
384
-        'WordPress\/',
385
-        'wotbox',
386
-        'wscheck',
387
-        'WWW-Mechanize',
388
-        'www\.monitor\.us',
389
-        'XaxisSemanticsClassifier',
390
-        'Xenu Link Sleuth',
391
-        'XML Sitemaps Generator',
392
-        'Y!J-ASR',
393
-        'yacy',
394
-        'Yahoo Ad monitoring',
395
-        'Yahoo Link Preview',
396
-        'YahooSeeker',
397
-        'yandex',
398
-        'yanga',
399
-        'yeti',
400
-        'yoogliFetchAgent',
401
-        'YottaaMonitor',
402
-        'Zao',
403
-        'zgrab',
404
-        'ZyBorg',
405
-        '[a-z0-9\-_]*((?<!cu)bot|crawler|archiver|transcoder|spider)',
406
-    );
87
+	/**
88
+	 * Array of regular expressions to match against the user agent.
89
+	 *
90
+	 * @var array
91
+	 */
92
+	protected static $crawlers = array(
93
+		'.*Java.*outbrain',
94
+		'008\/',
95
+		'^NING\/',
96
+		'A6-Indexer',
97
+		'Aboundex',
98
+		'Accoona-AI-Agent',
99
+		'acoon',
100
+		'AddThis',
101
+		'ADmantX',
102
+		'AHC',
103
+		'Airmail',
104
+		'alexa site audit',
105
+		'Anemone',
106
+		'Apache-HttpClient\/',
107
+		'Arachmo',
108
+		'archive-com',
109
+		'B-l-i-t-z-B-O-T',
110
+		'Backlink-Ceck\.de',
111
+		'baidu\.com',
112
+		'BazQux',
113
+		'bibnum\.bnf',
114
+		'biglotron',
115
+		'BingLocalSearch',
116
+		'BingPreview',
117
+		'binlar',
118
+		'Bloglovin',
119
+		'Blogtrottr',
120
+		'boitho\.com-dc',
121
+		'Browsershots',
122
+		'BUbiNG',
123
+		'Butterfly\/',
124
+		'BuzzSumo',
125
+		'CapsuleChecker',
126
+		'CC Metadata Scaper',
127
+		'Cerberian Drtrs',
128
+		'changedetection',
129
+		'Charlotte',
130
+		'clips\.ua\.ac\.be',
131
+		'CloudFlare-AlwaysOnline',
132
+		'coccoc',
133
+		'CommaFeed',
134
+		'Commons-HttpClient',
135
+		'convera',
136
+		'cosmos',
137
+		'corporatetwitnews',
138
+		'Covario-IDS',
139
+		'cron-job\.org',
140
+		'Curious George',
141
+		'curl',
142
+		'CyberPatrol',
143
+		'DataparkSearch',
144
+		'dataprovider',
145
+		'Daum(oa)?[ \/][0-9]',
146
+		'developers\.google\.com\/\+\/web\/snippet\/',
147
+		'Digg',
148
+		'DomainAppender',
149
+		'Dragonfly File Reader',
150
+		'drupact',
151
+		'EARTHCOM',
152
+		'ec2linkfinder',
153
+		'ECCP',
154
+		'ElectricMonk',
155
+		'EMail Exractor',
156
+		'EmailWolf',
157
+		'Embed PHP Library',
158
+		'Embedly',
159
+		'europarchive\.org',
160
+		'EventMachine HttpClient',
161
+		'ExactSearch',
162
+		'ExaleadCloudview',
163
+		'ezooms',
164
+		'facebookexternalhit',
165
+		'facebookplatform',
166
+		'Feed Wrangler',
167
+		'Feedbin',
168
+		'FeedBurner',
169
+		'Feedfetcher-Google',
170
+		'Feedly',
171
+		'Feedspot',
172
+		'FeedValidator',
173
+		'Fever',
174
+		'findlink',
175
+		'findthatfile',
176
+		'Flamingo_SearchEngine',
177
+		'FlipboardProxy',
178
+		'fluffy',
179
+		'Funnelback',
180
+		'g00g1e\.net',
181
+		'Genieo',
182
+		'getprismatic\.com',
183
+		'GigablastOpenSource',
184
+		'Go-http-client',
185
+		'Google favicon',
186
+		'Google Keyword Suggestion',
187
+		'Google Page Speed Insights',
188
+		'Google Web Preview',
189
+		'Google-HTTP-Java-Client',
190
+		'Google-Site-Verification',
191
+		'google_partner_monitoring',
192
+		'GoogleProducer',
193
+		'Grammarly',
194
+		'grub-client',
195
+		'heritrix',
196
+		'Holmes',
197
+		'htdig',
198
+		'HTTPMon',
199
+		'http-kit',
200
+		'http_requester',
201
+		'httpunit',
202
+		'http_request2',
203
+		'httrack',
204
+		'HubPages.*crawlingpolicy',
205
+		'HubSpot Marketing Grader',
206
+		'ichiro',
207
+		'IDG Twitter Links Resolver',
208
+		'igdeSpyder',
209
+		'InAGist',
210
+		'infegy',
211
+		'InfoWizards Reciprocal Link System PRO',
212
+		'inpwrd\.com',
213
+		'integromedb',
214
+		'IODC',
215
+		'IOI',
216
+		'ips-agent',
217
+		'iZSearch',
218
+		'^Java\/',
219
+		'Jigsaw',
220
+		'Jobrapido',
221
+		'kouio',
222
+		'L\.webis',
223
+		'Larbin',
224
+		'libwww',
225
+		'Link Valet',
226
+		'linkCheck',
227
+		'linkdex',
228
+		'LinkExaminer',
229
+		'LinkWalker',
230
+		'Lipperhey',
231
+		'link checker',
232
+		'link validator',
233
+		'LongURL API',
234
+		'ltx71',
235
+		'lwp-trivial',
236
+		'lycos',
237
+		'mabontland',
238
+		'MagpieRSS',
239
+		'Mediapartners-Google',
240
+		'MegaIndex\.ru',
241
+		'MetaURI',
242
+		'MergeFlow-PageReader',
243
+		'Mnogosearch',
244
+		'mogimogi',
245
+		'Mojolicious (Perl)',
246
+		'Morning Paper',
247
+		'Mrcgiguy',
248
+		'MVAClient',
249
+		'Netcraft Web Server Survey',
250
+		'NetcraftSurveyAgent',
251
+		'NetLyzer FastProbe',
252
+		'netresearch',
253
+		'Netvibes',
254
+		'NewsBlur .*(Fetcher|Finder)',
255
+		'NewsGator',
256
+		'newsme',
257
+		'newspaper\/',
258
+		'NG-Search',
259
+		'nineconnections\.com',
260
+		'nominet\.org\.uk',
261
+		'Notifixious',
262
+		'nuhk',
263
+		'nutch',
264
+		'Nuzzel',
265
+		'Nymesis',
266
+		'oegp',
267
+		'Omea Reader',
268
+		'omgili',
269
+		'Orbiter',
270
+		'ow\.ly',
271
+		'Go [\d\.]* package http',
272
+		'page2rss',
273
+		'PagePeeker',
274
+		'panscient',
275
+		'Peew',
276
+		'PhantomJS\/',
277
+		'phpcrawl',
278
+		'phpservermon',
279
+		'Pingdom\.com',
280
+		'Pinterest',
281
+		'Pizilla',
282
+		'Ploetz \+ Zeller',
283
+		'Plukkie',
284
+		'PocketParser',
285
+		'Pompos',
286
+		'postano',
287
+		'PostPost',
288
+		'postrank',
289
+		'proximic',
290
+		'Pulsepoint XT3 web scraper',
291
+		'Python-httplib2',
292
+		'python-requests',
293
+		'Python-urllib',
294
+		'Qseero',
295
+		'Qwantify',
296
+		'Radian6',
297
+		'Readability',
298
+		'RebelMouse',
299
+		'RetrevoPageAnalyzer',
300
+		'Riddler',
301
+		'Robosourcer',
302
+		'ROI Hunter',
303
+		'Ruby',
304
+		'SalesIntelligent',
305
+		'SBIder',
306
+		'scooter',
307
+		'ScoutJet',
308
+		'ScoutURLMonitor',
309
+		'Scrapy',
310
+		'Scrubby',
311
+		'SearchSight',
312
+		'semanticdiscovery',
313
+		'SEOstats',
314
+		'Server Density Service Monitoring',
315
+		'servernfo\.com',
316
+		'Seznam screenshot-generator',
317
+		'ShopWiki',
318
+		'SilverReader',
319
+		'SimplePie',
320
+		'Site24x7',
321
+		'SiteBar',
322
+		'siteexplorer\.info',
323
+		'Siteimprove\.com',
324
+		'SkypeUriPreview',
325
+		'slider\.com',
326
+		'slurp',
327
+		'SMRF URL Expander',
328
+		'snapchat-proxy',
329
+		'Snappy',
330
+		'SNK Siteshooter B0t',
331
+		'sogou',
332
+		'SortSite',
333
+		'speedy',
334
+		'Spinn3r',
335
+		'Sqworm',
336
+		'StackRambler',
337
+		'Stratagems Kumo',
338
+		'summify',
339
+		'teoma',
340
+		'theoldreader\.com',
341
+		'TinEye',
342
+		'Tiny Tiny RSS',
343
+		'Traackr.com',
344
+		'truwoGPS',
345
+		'tweetedtimes\.com',
346
+		'Twikle',
347
+		'Typhoeus',
348
+		'ubermetrics-technologies',
349
+		'UdmSearch',
350
+		'UnwindFetchor',
351
+		'updated',
352
+		'URLChecker',
353
+		'urlresolver',
354
+		'Vagabondo',
355
+		'Validator\.nu\/LV',
356
+		'via ggpht\.com GoogleImageProxy',
357
+		'vkShare',
358
+		'Vortex',
359
+		'voyager\/',
360
+		'VYU2',
361
+		'W3C-checklink',
362
+		'W3C-mobileOK',
363
+		'W3C_CSS_Validator_JFouffa',
364
+		'W3C_I18n-Checker',
365
+		'W3C_Unicorn',
366
+		'W3C_Validator',
367
+		'Wappalyzer',
368
+		'WinHttpRequest',
369
+		'web-capture\.net',
370
+		'WebCapture',
371
+		'WebCorp',
372
+		'webcollage',
373
+		'WebIndex',
374
+		'WebFetch',
375
+		'webmon ',
376
+		'websitepulse[+ ]checker',
377
+		'Websquash\.com',
378
+		'WebThumbnail',
379
+		'WeSEE:Search',
380
+		'wf84',
381
+		'wget',
382
+		'WhatsApp',
383
+		'WomlpeFactory',
384
+		'WordPress\/',
385
+		'wotbox',
386
+		'wscheck',
387
+		'WWW-Mechanize',
388
+		'www\.monitor\.us',
389
+		'XaxisSemanticsClassifier',
390
+		'Xenu Link Sleuth',
391
+		'XML Sitemaps Generator',
392
+		'Y!J-ASR',
393
+		'yacy',
394
+		'Yahoo Ad monitoring',
395
+		'Yahoo Link Preview',
396
+		'YahooSeeker',
397
+		'yandex',
398
+		'yanga',
399
+		'yeti',
400
+		'yoogliFetchAgent',
401
+		'YottaaMonitor',
402
+		'Zao',
403
+		'zgrab',
404
+		'ZyBorg',
405
+		'[a-z0-9\-_]*((?<!cu)bot|crawler|archiver|transcoder|spider)',
406
+	);
407 407
 
408
-    /**
409
-     * All possible HTTP headers that represent the
410
-     * User-Agent string.
411
-     *
412
-     * @var array
413
-     */
414
-    protected static $uaHttpHeaders = array(
415
-        // The default User-Agent string.
416
-        'HTTP_USER_AGENT',
417
-        // Header can occur on devices using Opera Mini.
418
-        'HTTP_X_OPERAMINI_PHONE_UA',
419
-        // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
420
-        'HTTP_X_DEVICE_USER_AGENT',
421
-        'HTTP_X_ORIGINAL_USER_AGENT',
422
-        'HTTP_X_SKYFIRE_PHONE',
423
-        'HTTP_X_BOLT_PHONE_UA',
424
-        'HTTP_DEVICE_STOCK_UA',
425
-        'HTTP_X_UCBROWSER_DEVICE_UA',
426
-    );
408
+	/**
409
+	 * All possible HTTP headers that represent the
410
+	 * User-Agent string.
411
+	 *
412
+	 * @var array
413
+	 */
414
+	protected static $uaHttpHeaders = array(
415
+		// The default User-Agent string.
416
+		'HTTP_USER_AGENT',
417
+		// Header can occur on devices using Opera Mini.
418
+		'HTTP_X_OPERAMINI_PHONE_UA',
419
+		// Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
420
+		'HTTP_X_DEVICE_USER_AGENT',
421
+		'HTTP_X_ORIGINAL_USER_AGENT',
422
+		'HTTP_X_SKYFIRE_PHONE',
423
+		'HTTP_X_BOLT_PHONE_UA',
424
+		'HTTP_DEVICE_STOCK_UA',
425
+		'HTTP_X_UCBROWSER_DEVICE_UA',
426
+	);
427 427
 
428
-    /**
429
-     * Class constructor.
430
-     */
431
-    public function __construct(array $headers = null, $userAgent = null)
432
-    {
433
-        $this->setHttpHeaders($headers);
434
-        $this->setUserAgent($userAgent);
435
-    }
428
+	/**
429
+	 * Class constructor.
430
+	 */
431
+	public function __construct(array $headers = null, $userAgent = null)
432
+	{
433
+		$this->setHttpHeaders($headers);
434
+		$this->setUserAgent($userAgent);
435
+	}
436 436
 
437
-    /**
438
-     * Set HTTP headers.
439
-     *
440
-     * @param array $httpHeaders
441
-     */
442
-    public function setHttpHeaders($httpHeaders = null)
443
-    {
444
-        // use global _SERVER if $httpHeaders aren't defined
445
-        if (!is_array($httpHeaders) || !count($httpHeaders)) {
446
-            $httpHeaders = $_SERVER;
447
-        }
448
-        // clear existing headers
449
-        $this->httpHeaders = array();
450
-        // Only save HTTP headers. In PHP land, that means only _SERVER vars that
451
-        // start with HTTP_.
452
-        foreach ($httpHeaders as $key => $value) {
453
-            if (substr($key, 0, 5) === 'HTTP_') {
454
-                $this->httpHeaders[$key] = $value;
455
-            }
456
-        }
457
-    }
437
+	/**
438
+	 * Set HTTP headers.
439
+	 *
440
+	 * @param array $httpHeaders
441
+	 */
442
+	public function setHttpHeaders($httpHeaders = null)
443
+	{
444
+		// use global _SERVER if $httpHeaders aren't defined
445
+		if (!is_array($httpHeaders) || !count($httpHeaders)) {
446
+			$httpHeaders = $_SERVER;
447
+		}
448
+		// clear existing headers
449
+		$this->httpHeaders = array();
450
+		// Only save HTTP headers. In PHP land, that means only _SERVER vars that
451
+		// start with HTTP_.
452
+		foreach ($httpHeaders as $key => $value) {
453
+			if (substr($key, 0, 5) === 'HTTP_') {
454
+				$this->httpHeaders[$key] = $value;
455
+			}
456
+		}
457
+	}
458 458
 
459
-    /**
460
-     * Return user agent headers.
461
-     *
462
-     * @return array
463
-     */
464
-    public function getUaHttpHeaders()
465
-    {
466
-        return self::$uaHttpHeaders;
467
-    }
459
+	/**
460
+	 * Return user agent headers.
461
+	 *
462
+	 * @return array
463
+	 */
464
+	public function getUaHttpHeaders()
465
+	{
466
+		return self::$uaHttpHeaders;
467
+	}
468 468
 
469
-    /**
470
-     * Set the user agent.
471
-     *
472
-     * @param string $userAgent
473
-     */
474
-    public function setUserAgent($userAgent = null)
475
-    {
476
-        if (false === empty($userAgent)) {
477
-            return $this->userAgent = $userAgent;
478
-        } else {
479
-            $this->userAgent = null;
480
-            foreach ($this->getUaHttpHeaders() as $altHeader) {
481
-                if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow.
482
-                    $this->userAgent .= $this->httpHeaders[$altHeader].' ';
483
-                }
484
-            }
469
+	/**
470
+	 * Set the user agent.
471
+	 *
472
+	 * @param string $userAgent
473
+	 */
474
+	public function setUserAgent($userAgent = null)
475
+	{
476
+		if (false === empty($userAgent)) {
477
+			return $this->userAgent = $userAgent;
478
+		} else {
479
+			$this->userAgent = null;
480
+			foreach ($this->getUaHttpHeaders() as $altHeader) {
481
+				if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow.
482
+					$this->userAgent .= $this->httpHeaders[$altHeader].' ';
483
+				}
484
+			}
485 485
 
486
-            return $this->userAgent = (!empty($this->userAgent) ? trim($this->userAgent) : null);
487
-        }
488
-    }
486
+			return $this->userAgent = (!empty($this->userAgent) ? trim($this->userAgent) : null);
487
+		}
488
+	}
489 489
 
490
-    /**
491
-     * Return the array of crawler regexs.
492
-     *
493
-     * @return array
494
-     */
495
-    public function getCrawlers()
496
-    {
497
-        return self::$crawlers;
498
-    }
490
+	/**
491
+	 * Return the array of crawler regexs.
492
+	 *
493
+	 * @return array
494
+	 */
495
+	public function getCrawlers()
496
+	{
497
+		return self::$crawlers;
498
+	}
499 499
 
500
-    /**
501
-     * Build the user agent regex.
502
-     *
503
-     * @return string
504
-     */
505
-    public function getRegex()
506
-    {
507
-        return '('.implode('|', self::$crawlers).')';
508
-    }
500
+	/**
501
+	 * Build the user agent regex.
502
+	 *
503
+	 * @return string
504
+	 */
505
+	public function getRegex()
506
+	{
507
+		return '('.implode('|', self::$crawlers).')';
508
+	}
509 509
 
510
-    /**
511
-     * Build the replacement regex.
512
-     *
513
-     * @return string
514
-     */
515
-    public function getIgnored()
516
-    {
517
-        return '('.implode('|', self::$ignore).')';
518
-    }
510
+	/**
511
+	 * Build the replacement regex.
512
+	 *
513
+	 * @return string
514
+	 */
515
+	public function getIgnored()
516
+	{
517
+		return '('.implode('|', self::$ignore).')';
518
+	}
519 519
 
520
-    /**
521
-     * Check user agent string against the regex.
522
-     *
523
-     * @param string $userAgent
524
-     *
525
-     * @return bool
526
-     */
527
-    public function isCrawler($userAgent = null)
528
-    {
529
-        $agent = is_null($userAgent) ? $this->userAgent : $userAgent;
520
+	/**
521
+	 * Check user agent string against the regex.
522
+	 *
523
+	 * @param string $userAgent
524
+	 *
525
+	 * @return bool
526
+	 */
527
+	public function isCrawler($userAgent = null)
528
+	{
529
+		$agent = is_null($userAgent) ? $this->userAgent : $userAgent;
530 530
 
531
-        $agent = preg_replace('/'.$this->getIgnored().'/i', '', $agent);
531
+		$agent = preg_replace('/'.$this->getIgnored().'/i', '', $agent);
532 532
 
533
-        if (trim($agent) === false) {
534
-            return false;
535
-        } else {
536
-            $result = preg_match('/'.$this->getRegex().'/i', trim($agent), $matches);
537
-        }
533
+		if (trim($agent) === false) {
534
+			return false;
535
+		} else {
536
+			$result = preg_match('/'.$this->getRegex().'/i', trim($agent), $matches);
537
+		}
538 538
 
539
-        if ($matches) {
540
-            $this->matches = $matches;
541
-        }
539
+		if ($matches) {
540
+			$this->matches = $matches;
541
+		}
542 542
 
543
-        return (bool) $result;
544
-    }
543
+		return (bool) $result;
544
+	}
545 545
 
546
-    /**
547
-     * Return the matches.
548
-     *
549
-     * @return string
550
-     */
551
-    public function getMatches()
552
-    {
553
-        return $this->matches[0];
554
-    }
546
+	/**
547
+	 * Return the matches.
548
+	 *
549
+	 * @return string
550
+	 */
551
+	public function getMatches()
552
+	{
553
+		return $this->matches[0];
554
+	}
555 555
 }
Please login to merge, or discard this patch.
tests/UATests.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -11,55 +11,55 @@
 block discarded – undo
11 11
 
12 12
 class UserAgentTest extends PHPUnit_Framework_TestCase
13 13
 {
14
-    protected $CrawlerDetect;
14
+	protected $CrawlerDetect;
15 15
 
16
-    public function setUp()
17
-    {
18
-        $this->CrawlerDetect = new Jaybizzle\CrawlerDetect\CrawlerDetect();
19
-    }
16
+	public function setUp()
17
+	{
18
+		$this->CrawlerDetect = new Jaybizzle\CrawlerDetect\CrawlerDetect();
19
+	}
20 20
 
21
-    public function testBots()
22
-    {
23
-        $lines = file(__DIR__.'/crawlers.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
21
+	public function testBots()
22
+	{
23
+		$lines = file(__DIR__.'/crawlers.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
24 24
 
25
-        foreach ($lines as $line) {
26
-            $test = $this->CrawlerDetect->isCrawler($line);
27
-            $this->assertEquals($test, true, $line);
28
-        }
29
-    }
25
+		foreach ($lines as $line) {
26
+			$test = $this->CrawlerDetect->isCrawler($line);
27
+			$this->assertEquals($test, true, $line);
28
+		}
29
+	}
30 30
 
31
-    public function testDevices()
32
-    {
33
-        $lines = file(__DIR__.'/devices.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
31
+	public function testDevices()
32
+	{
33
+		$lines = file(__DIR__.'/devices.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
34 34
 
35
-        foreach ($lines as $line) {
36
-            $test = $this->CrawlerDetect->isCrawler($line);
37
-            $this->assertEquals($test, false, $line);
38
-        }
39
-    }
35
+		foreach ($lines as $line) {
36
+			$test = $this->CrawlerDetect->isCrawler($line);
37
+			$this->assertEquals($test, false, $line);
38
+		}
39
+	}
40 40
 
41
-    public function testReturnsCorrectMatchedBotName()
42
-    {
43
-        $test = $this->CrawlerDetect->isCrawler('Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X) AppleWebKit (KHTML, like Gecko) Mobile (compatible; Yahoo Ad monitoring; https://help.yahoo.com/kb/yahoo-ad-monitoring-SLN24857.html)');
41
+	public function testReturnsCorrectMatchedBotName()
42
+	{
43
+		$test = $this->CrawlerDetect->isCrawler('Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X) AppleWebKit (KHTML, like Gecko) Mobile (compatible; Yahoo Ad monitoring; https://help.yahoo.com/kb/yahoo-ad-monitoring-SLN24857.html)');
44 44
 
45
-        $matches = $this->CrawlerDetect->getMatches();
45
+		$matches = $this->CrawlerDetect->getMatches();
46 46
 
47
-        $this->assertEquals($this->CrawlerDetect->getMatches(), 'Yahoo Ad monitoring', $matches);
48
-    }
47
+		$this->assertEquals($this->CrawlerDetect->getMatches(), 'Yahoo Ad monitoring', $matches);
48
+	}
49 49
 
50
-    public function testForRegexCollision()
51
-    {
52
-        $crawlers = $this->CrawlerDetect->getCrawlers();
50
+	public function testForRegexCollision()
51
+	{
52
+		$crawlers = $this->CrawlerDetect->getCrawlers();
53 53
 
54
-        foreach ($crawlers as $key1 => $regex) {
55
-            foreach ($crawlers as $key2 => $compare) {
56
-                // Dont check this regex against itself
57
-                if ($key1 != $key2) {
58
-                    preg_match('/'.$regex.'/i', stripslashes($compare), $matches);
54
+		foreach ($crawlers as $key1 => $regex) {
55
+			foreach ($crawlers as $key2 => $compare) {
56
+				// Dont check this regex against itself
57
+				if ($key1 != $key2) {
58
+					preg_match('/'.$regex.'/i', stripslashes($compare), $matches);
59 59
 
60
-                    $this->assertEmpty($matches, $regex.' collided with '.$compare);
61
-                }
62
-            }
63
-        }
64
-    }
60
+					$this->assertEmpty($matches, $regex.' collided with '.$compare);
61
+				}
62
+			}
63
+		}
64
+	}
65 65
 }
Please login to merge, or discard this patch.