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