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