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