Test Failed
Pull Request — master (#78)
by Gabriel
02:37
created

ScriptedAgentDetector::checkRobotGoogle()   C

Complexity

Conditions 8
Paths 5

Size

Total Lines 36
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 36
rs 5.3846
cc 8
eloc 25
nc 5
nop 0
1
<?php
2
3
namespace Sinergi\BrowserDetector;
4
5
class ScriptedAgentDetector implements DetectorInterface
6
{
7
    const FUNC_PREFIX = 'checkRobot';
8
9
    protected static $userAgentString;
10
11
    /**
12
     * @var ScriptedAgent
13
     */
14
    protected static $scriptedAgent;
15
16
    protected static $robotsList = array(
17
        'Google',
18
        'Baidu',
19
        'Facebook',
20
        'Bing',
21
        'Slurp',
22
        'Twitter',
23
        'Skype',
24
        'W3CValidator',
25
        'wkHTMLtoPDF',
26
        'Yandex',
27
        'Apple',
28
        'Paperli',
29
        'Ahrefs',
30
        'MJ12',
31
        'LiveLap',
32
        'Webdav',
33
        'MetaURI',
34
        'TLSProbe',
35
        'ScoopIt',
36
        'Netcraft',
37
        'Curl',
38
        'Python',
39
        'GoLang',
40
        'Perl',
41
        'Wget',
42
        'ZGrab',
43
        'Java',
44
        'Shellshock',
45
        'Browershots',
46
        'Whois',
47
        'MageReport',
48
        'Adbeat',
49
        'Ubermetrics',
50
        'Socialrank',
51
        'GlutenFree',
52
        'ICQ',
53
        'Proximic',
54
        'Verisign'
55
    );
56
57
    /**
58
     * Routine to determine the scripted agent type.
59
     *
60
     * @param ScriptedAgent $scriptedAgent
61
     * @param UserAgent $userAgent
62
     *
63
     * @return bool
64
     */
65
    public static function detect(ScriptedAgent $scriptedAgent, UserAgent $userAgent = null)
66
    {
67
        self::$scriptedAgent = $scriptedAgent;
68
        if (is_null($userAgent)) {
69
            $userAgent = self::$scriptedAgent->getUserAgent();
70
        }
71
        self::$userAgentString = $userAgent->getUserAgentString();
72
73
        self::$scriptedAgent->setName(ScriptedAgent::UNKNOWN);
74
        self::$scriptedAgent->setType(ScriptedAgent::UNKNOWN);
75
        self::$scriptedAgent->setInfoURL(ScriptedAgent::UNKNOWN);
76
77
        foreach (self::$robotsList as $robotName) {
78
            $funcName = self::FUNC_PREFIX . $robotName;
79
80
            if (self::$funcName()) {
81
                return true;
82
            }
83
        }
84
85
        return false;
86
    }
87
88
    /**
89
     * Determine if the browser is wkHTMLtoPDF
90
     *
91
     * @return bool
92
     */
93 View Code Duplication
    public static function checkRobotwkHTMLtoPDF()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
94
    {
95
        if (stripos(self::$userAgentString, 'wkhtmltopdf') !== false) {
96
            self::$scriptedAgent->setName(ScriptedAgent::WKHTMLTOPDF);
97
            self::$scriptedAgent->setType(ScriptedAgent::TOOL);
98
            self::$scriptedAgent->setInfoURL("https://wkhtmltopdf.org/");
99
            return true;
100
        }
101
        return false;
102
    }
103
104
    /**
105
     * Determine if the browser is the ICQ preview.
106
     *
107
     * @return bool
108
     */
109
    public static function checkRobotICQ()
0 ignored issues
show
Coding Style introduced by
checkRobotICQ uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
110
    {
111
        //Chrome 51 always provides the Upgrade-Insecure-Requests header. ICQ does not.
112
        //But to be extra safe, also check for the russian language which the ICQ bot sets.
113
        if (stripos(self::$userAgentString, 'Chrome/51.0.2704.103') !== FALSE && !isset($_SERVER['HTTP_UPGRADE_INSECURE_REQUESTS']) && stristr($_SERVER['HTTP_ACCEPT_LANGUAGE'], "ru-RU") !== FALSE)
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected false, but found FALSE.
Loading history...
114
        {
115
            self::$scriptedAgent->setName(ScriptedAgent::ICQ);
116
            self::$scriptedAgent->setType(ScriptedAgent::PREVIEW);
117
            self::$scriptedAgent->setInfoURL("https://icq.com");
118
            return true;
119
        }
120
        return false;
121
    }
122
123
    /**
124
     * Determine if the agent is GoogleBot, or a google ads bot.
125
     *
126
     * @return bool
127
     */
128
    public static function checkRobotGoogle()
129
    {
130
        if (stripos(self::$userAgentString, "Googlebot") !== false)
131
        {
132
            self::$scriptedAgent->setName(ScriptedAgent::GOOGLEBOT);
133
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
134
            self::$scriptedAgent->setInfoURL("https://support.google.com/webmasters/answer/1061943?hl=en");
135
            return true;
136
        }
137
        if (stripos(self::$userAgentString, "AdsBot-Google") !== false
138
            || stripos(self::$userAgentString, "Mediapartners-Google") !== false
139
            || stripos(self::$userAgentString, "Google-Adwords") !== false
140
            || stripos(self::$userAgentString, "AdXVastFetcher-Google") !== false
141
        )
142
        {
143
            self::$scriptedAgent->setName(ScriptedAgent::GOOGLEADS);
144
            self::$scriptedAgent->setType(ScriptedAgent::ADVERTISING);
145
            self::$scriptedAgent->setInfoURL("https://support.google.com/webmasters/answer/1061943?hl=en");
146
            return true;
147
        }
148
        if (stripos(self::$userAgentString, "Google Favicon") !== false)
149
        {
150
            self::$scriptedAgent->setName(ScriptedAgent::GOOGLEFAVICON);
151
            self::$scriptedAgent->setType(ScriptedAgent::GENERIC);
152
            self::$scriptedAgent->setInfoURL("https://www.webmasterworld.com/search_engine_spiders/4626518.htm");
153
            return true;
154
        }
155
        if (stripos(self::$userAgentString, "Google Web Preview") !== false)
156
        {
157
            self::$scriptedAgent->setName(ScriptedAgent::GOOGLEPREVIEW);
158
            self::$scriptedAgent->setType(ScriptedAgent::PREVIEW);
159
            self::$scriptedAgent->setInfoURL("https://www.distilnetworks.com/bot-directory/bot/google-web-preview/");
160
            return true;
161
        }
162
        return false;
163
    }
164
165
    /**
166
     * Determine if the agent is the Baidu spider.
167
     *
168
     * @return bool
169
     */
170 View Code Duplication
    public static function checkRobotBaidu()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
171
    {
172
        if (stripos(self::$userAgentString, "Baiduspider") !== false)
173
        {
174
            self::$scriptedAgent->setName(ScriptedAgent::BAIDU);
175
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
176
            self::$scriptedAgent->setInfoURL("https://support.google.com/webmasters/answer/1061943?hl=en");
177
            return true;
178
        }
179
        return false;
180
    }
181
182
    /**
183
     * Determine if the agent is the Facebook preview bot.
184
     *
185
     * @return bool
186
     */
187 View Code Duplication
    public static function checkRobotFacebook()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
188
    {
189
        if (stripos(self::$userAgentString, "facebookexternalhit") !== false)
190
        {
191
            self::$scriptedAgent->setName(ScriptedAgent::FACEBOOK);
192
            self::$scriptedAgent->setType(ScriptedAgent::PREVIEW);
193
            self::$scriptedAgent->setInfoURL("https://www.facebook.com/externalhit_uatext.php");
194
            return true;
195
        }
196
        return false;
197
    }
198
199
    /**
200
     * Determine if the agent is the bing spider, bing preview bot, or MSN bot
201
     *
202
     * @return bool
203
     */
204
    public static function checkRobotBing()
205
    {
206
207
        if (stripos(self::$userAgentString, "adidxbot/") !== false)
208
        {
209
            self::$scriptedAgent->setName(ScriptedAgent::BING);
210
            self::$scriptedAgent->setType(ScriptedAgent::ADVERTISING);
211
            self::$scriptedAgent->setInfoURL("https://www.bing.com/webmaster/help/which-crawlers-does-bing-use-8c184ec0");
212
            return true;
213
        }
214
        if (stripos(self::$userAgentString, "/bingbot.htm") !== false)
215
        {
216
            self::$scriptedAgent->setName(ScriptedAgent::BING);
217
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
218
            self::$scriptedAgent->setInfoURL("https://www.bing.com/webmaster/help/which-crawlers-does-bing-use-8c184ec0");
219
            return true;
220
        }
221
        if (stripos(self::$userAgentString, "/msnbot.htm") !== false)
222
        {
223
            self::$scriptedAgent->setName(ScriptedAgent::MSNBOT);
224
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
225
            self::$scriptedAgent->setInfoURL("https://www.bing.com/webmaster/help/which-crawlers-does-bing-use-8c184ec0");
226
            return true;
227
        }
228
        if (stripos(self::$userAgentString, "BingPreview/") !== false)
229
        {
230
            self::$scriptedAgent->setName(ScriptedAgent::BING_PREVIEW);
231
            self::$scriptedAgent->setType(ScriptedAgent::PREVIEW);
232
            self::$scriptedAgent->setInfoURL("https://www.bing.com/webmaster/help/which-crawlers-does-bing-use-8c184ec0");
233
            return true;
234
        }
235
        return false;
236
    }
237
238
    /**
239
     * Determine if the agent is the Yahoo Slurp! Spider.
240
     *
241
     * @return bool
242
     *
243
     */
244 View Code Duplication
    public static function checkRobotSlurp()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
245
    {
246
        if (stripos(self::$userAgentString, "Yahoo! Slurp") !== false)
247
        {
248
            self::$scriptedAgent->setName(ScriptedAgent::SLURP);
249
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
250
            self::$scriptedAgent->setInfoURL("https://help.yahoo.com/kb/SLN22600.html");
251
            return true;
252
        }
253
        return false;
254
    }
255
256
    /**
257
     * Determine if the agent is the twitter preview bot.
258
     *
259
     * @return bool
260
     */
261 View Code Duplication
    public static function checkRobotTwitter()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
262
    {
263
        if (stripos(self::$userAgentString, "Twitterbot/") !== false)
264
        {
265
            self::$scriptedAgent->setName(ScriptedAgent::TWITTER);
266
            self::$scriptedAgent->setType(ScriptedAgent::PREVIEW);
267
            self::$scriptedAgent->setInfoURL("http://stackoverflow.com/questions/22362215/twitter-user-agent-on-sharing");
268
            return true;
269
        }
270
        return false;
271
    }
272
273
    /**
274
     * Determine if the agent is the skype preview bot.
275
     *
276
     * @return bool
277
     */
278 View Code Duplication
    public static function checkRobotSkype()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
279
    {
280
        if (stripos(self::$userAgentString, "SkypeUriPreview") !== false)
281
        {
282
            self::$scriptedAgent->setName(ScriptedAgent::SKYPE);
283
            self::$scriptedAgent->setType(ScriptedAgent::PREVIEW);
284
            self::$scriptedAgent->setInfoURL("http://www.skype.com");
285
            return true;
286
        }
287
        return false;
288
    }
289
290
    /**
291
     * Determine if the agent is the W3C Validator tool.
292
     *
293
     * @return bool
294
     */
295
    public static function checkRobotW3CValidator()
296
    {
297
        if (stripos(self::$userAgentString, "W3C_Validator/") !== false ||
298
            stripos(self::$userAgentString, "Validator.nu/") !== false ||
299
            stripos(self::$userAgentString, "W3C-mobileOK/DDC-") !== false ||
300
            stripos(self::$userAgentString, "W3C_I18n-Checker/") !== false ||
301
            stripos(self::$userAgentString, "FeedValidator/") !== false ||
302
            stripos(self::$userAgentString, "Jigsaw/") !== false ||
303
            stripos(self::$userAgentString, "JW3C_Unicorn/") !== false
304
        )
305
        {
306
            self::$scriptedAgent->setName(ScriptedAgent::W3CVALIDATOR);
307
            self::$scriptedAgent->setType(ScriptedAgent::TOOL);
308
            self::$scriptedAgent->setInfoURL("https://validator.w3.org/services");
309
            return true;
310
        }
311
        if (stripos(self::$userAgentString, "NING/") !== false ||
312
            stripos(self::$userAgentString, "W3C-checklink") !== false)
313
        {
314
            self::$scriptedAgent->setName(ScriptedAgent::W3CVALIDATOR);
315
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
316
            self::$scriptedAgent->setInfoURL("https://validator.w3.org/services");
317
            return true;
318
        }
319
        return false;
320
    }
321
322
    /**
323
     * Determine if the agent is the Yandex spider.
324
     *
325
     * @return bool
326
     */
327 View Code Duplication
    public static function checkRobotYandex()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
328
    {
329
        if (stripos(self::$userAgentString, "YandexBot/") !== false)
330
        {
331
            self::$scriptedAgent->setName(ScriptedAgent::YANDEX);
332
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
333
            self::$scriptedAgent->setInfoURL("http://yandex.com/bots");
334
            return true;
335
        }
336
        return false;
337
    }
338
339
    /**
340
     * Determine if the agent is the AppleBot
341
     *
342
     * @return bool
343
     */
344 View Code Duplication
    public static function checkRobotApple()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
345
    {
346
        if (stripos(self::$userAgentString, "AppleBot/") !== false)
347
        {
348
            self::$scriptedAgent->setName(ScriptedAgent::APPLEBOT);
349
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
350
            self::$scriptedAgent->setInfoURL("https://support.apple.com/en-gb/HT204683");
351
            return true;
352
        }
353
        return false;
354
    }
355
356
    /**
357
     * Determine if the agent is the Paper.li bot.
358
     *
359
     * @return bool
360
     */
361 View Code Duplication
    public static function checkRobotPaperli()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
362
    {
363
        if (stripos(self::$userAgentString, "PaperLiBot/") !== false)
364
        {
365
            self::$scriptedAgent->setName(ScriptedAgent::PAPERLI);
366
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
367
            self::$scriptedAgent->setInfoURL("https://support.paper.li/hc/en-us/articles/204105253-What-is-Paper-li-");
368
            return true;
369
        }
370
        return false;
371
    }
372
373
    /**
374
     * Determine if the agent is the Ahrefs survey.
375
     *
376
     * @return bool
377
     */
378 View Code Duplication
    public static function checkRobotAhrefs()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
379
    {
380
        if (stripos(self::$userAgentString, "AhrefsBot/") !== false)
381
        {
382
            self::$scriptedAgent->setName(ScriptedAgent::AHREFS);
383
            self::$scriptedAgent->setType(ScriptedAgent::SURVEY);
384
            self::$scriptedAgent->setInfoURL("https://ahrefs.com/robot");
385
            return true;
386
        }
387
        return false;
388
    }
389
390
    /**
391
     * Determine if the agent is the Majestic 12 spider.
392
     *
393
     * @return bool
394
     */
395 View Code Duplication
    public static function checkRobotMJ12()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
396
    {
397
        if (stripos(self::$userAgentString, "MJ12Bot/") !== false)
398
        {
399
            self::$scriptedAgent->setName(ScriptedAgent::MJ12);
400
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
401
            self::$scriptedAgent->setInfoURL("http://www.majestic12.co.uk/projects/dsearch/mj12bot.php");
402
            return true;
403
        }
404
        return false;
405
    }
406
407
    /**
408
     * Determine if the agent is the LiveLap spider.
409
     *
410
     * @return bool
411
     */
412 View Code Duplication
    public static function checkRobotLiveLap()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
413
    {
414
        if (stripos(self::$userAgentString, "LivelapBot/") !== false)
415
        {
416
            self::$scriptedAgent->setName(ScriptedAgent::LIVELAP);
417
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
418
            self::$scriptedAgent->setInfoURL("http://site.livelap.com/crawler.html");
419
            return true;
420
        }
421
        return false;
422
    }
423
424
    /**
425
     * Determine if the agent is a Web Distributed Authoring and Versioning client. Usually unexpected WebDAV requests are hack attempts.
426
     *
427
     * @return bool
428
     */
429 View Code Duplication
    public static function checkRobotWebdav()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
430
    {
431
        if (stripos(self::$userAgentString, "WEBDAV Client") !== false ||
432
            stripos(self::$userAgentString, "Microsoft Office Existence Discovery") !== false) //Office Webdav probe
433
        {
434
            self::$scriptedAgent->setName(ScriptedAgent::WEBDAV);
435
            self::$scriptedAgent->setType(ScriptedAgent::TOOL);
436
            self::$scriptedAgent->setInfoURL("https://en.wikipedia.org/wiki/WebDAV");
437
            return true;
438
        }
439
        return false;
440
    }
441
442
    /**
443
     * Determine if the agent is the MetaURI scraper.
444
     *
445
     * @return bool
446
     */
447 View Code Duplication
    public static function checkRobotMetaURI()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
448
    {
449
        if (stripos(self::$userAgentString, "MetaURI API/") !== false)
450
        {
451
            self::$scriptedAgent->setName(ScriptedAgent::METAURI);
452
            self::$scriptedAgent->setType(ScriptedAgent::SURVEY);
453
            self::$scriptedAgent->setInfoURL("https://github.com/stateless-systems/uri-meta");
454
            return true;
455
        }
456
        return false;
457
    }
458
459
    /**
460
     * Determine if the agent is the TLSProbe tool.
461
     *
462
     * @return bool
463
     */
464 View Code Duplication
    public static function checkRobotTLSProbe()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
465
    {
466
        if (stripos(self::$userAgentString, "TLSProbe/") !== false)
467
        {
468
            self::$scriptedAgent->setName(ScriptedAgent::TLSPROBE);
469
            self::$scriptedAgent->setType(ScriptedAgent::TOOL);
470
            self::$scriptedAgent->setInfoURL("https://bitbucket.org/marco-bellaccini/tlsprobe");
471
            return true;
472
        }
473
        return false;
474
    }
475
476
    /**
477
     * Determine if the agent is the scoop.it bots.
478
     *
479
     * @return bool
480
     */
481 View Code Duplication
    public static function checkRobotScoopIt()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
482
    {
483
        if (stripos(self::$userAgentString, "wpif Safari") !== false
484
            || stripos(self::$userAgentString, "imgsizer Safari") !== false)
485
        {
486
            self::$scriptedAgent->setName(ScriptedAgent::SCOOPIT);
487
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
488
            self::$scriptedAgent->setInfoURL("https://www.webmasterworld.com/search_engine_spiders/4785385.htm");
489
            return true;
490
        }
491
        return false;
492
    }
493
494
    /**
495
     * Determine if the agent is the Netcraft SSL Survey.
496
     *
497
     * @return bool
498
     */
499 View Code Duplication
    public static function checkRobotNetcraft()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
500
    {
501
        if (stripos(self::$userAgentString, "Netcraft SSL Server Survey") !== false)
502
        {
503
            self::$scriptedAgent->setName(ScriptedAgent::NETCRAFT);
504
            self::$scriptedAgent->setType(ScriptedAgent::SURVEY);
505
            self::$scriptedAgent->setInfoURL("https://www.netcraft.com/internet-data-mining/ssl-survey/");
506
            return true;
507
        }
508
        return false;
509
    }
510
511
    /**
512
     * Determine if the agent is the curl library/cli tool.
513
     *
514
     * @return bool
515
     */
516 View Code Duplication
    public static function checkRobotCurl()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
517
    {
518
        if (stripos(self::$userAgentString, "curl/") !== false)
519
        {
520
            self::$scriptedAgent->setName(ScriptedAgent::CURL);
521
            self::$scriptedAgent->setType(ScriptedAgent::GENERIC);
522
            self::$scriptedAgent->setInfoURL("https://curl.haxx.se/");
523
            return true;
524
        }
525
        return false;
526
    }
527
528
    /**
529
     * Determine if the agent is the python programming language.
530
     *
531
     * @return bool
532
     */
533 View Code Duplication
    public static function checkRobotPython()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
534
    {
535
        if (stripos(self::$userAgentString, "python-requests/") !== false ||
536
            stripos(self::$userAgentString, "python-urllib/") !== false)
537
        {
538
            self::$scriptedAgent->setName(ScriptedAgent::PYTHON);
539
            self::$scriptedAgent->setType(ScriptedAgent::GENERIC);
540
            self::$scriptedAgent->setInfoURL("https://www.python.org/");
541
            return true;
542
        }
543
        return false;
544
    }
545
546
    /**
547
     * Determine if the agent is the GoLang programming language.
548
     *
549
     * @return bool
550
     */
551 View Code Duplication
    public static function checkRobotGoLang()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
552
    {
553
        if (stripos(self::$userAgentString, "Go-http-client") !== false)
554
        {
555
            self::$scriptedAgent->setName(ScriptedAgent::GOLANG);
556
            self::$scriptedAgent->setType(ScriptedAgent::GENERIC);
557
            self::$scriptedAgent->setInfoURL("https://golang.org/");
558
            return true;
559
        }
560
        return false;
561
    }
562
563
    /**
564
     * Determine if the agent is the perl programming language.
565
     *
566
     * @return bool
567
     */
568 View Code Duplication
    public static function checkRobotPerl()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
569
    {
570
        if (stripos(self::$userAgentString, "libwww-perl/") !== false)
571
        {
572
            self::$scriptedAgent->setName(ScriptedAgent::PERL);
573
            self::$scriptedAgent->setType(ScriptedAgent::GENERIC);
574
            self::$scriptedAgent->setInfoURL("https://www.perl.org/");
575
            return true;
576
        }
577
        return false;
578
    }
579
580
    /**
581
     * Determine if the agent is the wget tool.
582
     *
583
     * @return bool
584
     */
585 View Code Duplication
    public static function checkRobotWget()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
586
    {
587
        if (stripos(self::$userAgentString, "Wget/") !== false)
588
        {
589
            self::$scriptedAgent->setName(ScriptedAgent::WGET);
590
            self::$scriptedAgent->setType(ScriptedAgent::TOOL);
591
            self::$scriptedAgent->setInfoURL("https://www.gnu.org/software/wget/");
592
            return true;
593
        }
594
        return false;
595
    }
596
597
    /**
598
     * Determine if the agent is the zgrab TLS banner tool.
599
     *
600
     * @return bool
601
     */
602 View Code Duplication
    public static function checkRobotZGrab()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
603
    {
604
        if (stripos(self::$userAgentString, "zgrab/") !== false)
605
        {
606
            self::$scriptedAgent->setName(ScriptedAgent::ZGRAB);
607
            self::$scriptedAgent->setType(ScriptedAgent::TOOL);
608
            self::$scriptedAgent->setInfoURL("https://github.com/zmap/zgrab");
609
            return true;
610
        }
611
        return false;
612
    }
613
614
    /**
615
     * Determine if the agent is the Java programming language.
616
     *
617
     * @return bool
618
     */
619 View Code Duplication
    public static function checkRobotJava()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
620
    {
621
        if (stripos(self::$userAgentString, "Java/") !== false)
622
        {
623
            self::$scriptedAgent->setName(ScriptedAgent::JAVA);
624
            self::$scriptedAgent->setType(ScriptedAgent::GENERIC);
625
            self::$scriptedAgent->setInfoURL("https://www.java.com/en/");
626
            return true;
627
        }
628
        return false;
629
    }
630
631
    /**
632
     * Determine if the agent is the ShellShock exploit.
633
     *
634
     * @return bool
635
     */
636 View Code Duplication
    public static function checkRobotShellshock()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
637
    {
638
        if (stripos(self::$userAgentString, "() { :;}; /bin/bash -c") !== false)
639
        {
640
            self::$scriptedAgent->setName(ScriptedAgent::SHELLSHOCK);
641
            self::$scriptedAgent->setType(ScriptedAgent::EXPLOIT);
642
            self::$scriptedAgent->setInfoURL("https://blog.cloudflare.com/inside-shellshock/");
643
            return true;
644
        }
645
        return false;
646
    }
647
648
    /**
649
     * Determine if the agent is the browsershots testing tool.
650
     *
651
     * @return bool
652
     */
653 View Code Duplication
    public static function checkRobotBrowershots()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
654
    {
655
        if (stripos(self::$userAgentString, "Browsershots") !== false)
656
        {
657
            self::$scriptedAgent->setName(ScriptedAgent::BROWSERSHOTS);
658
            self::$scriptedAgent->setType(ScriptedAgent::SURVEY);
659
            self::$scriptedAgent->setInfoURL("http://browsershots.org/");
660
            return true;
661
        }
662
        return false;
663
    }
664
665
    /**
666
     * Determine if the agent is the who.is spider.
667
     *
668
     * @return bool
669
     */
670 View Code Duplication
    public static function checkRobotWhois()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
671
    {
672
        if (stripos(self::$userAgentString, "who.is bot") !== false)
673
        {
674
            self::$scriptedAgent->setName(ScriptedAgent::WHOIS);
675
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
676
            self::$scriptedAgent->setInfoURL("http://www.who.is/");
677
            return true;
678
        }
679
        return false;
680
    }
681
682
    /**
683
     * Determine if the agent is the MageReport exploit survey.
684
     *
685
     * @return bool
686
     */
687 View Code Duplication
    public static function checkRobotMageReport()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
688
    {
689
        if (stripos(self::$userAgentString, "MageReport") !== false)
690
        {
691
            self::$scriptedAgent->setName(ScriptedAgent::MAGEREPORT);
692
            self::$scriptedAgent->setType(ScriptedAgent::SURVEY);
693
            self::$scriptedAgent->setInfoURL("https://www.magereport.com/");
694
            return true;
695
        }
696
        return false;
697
    }
698
699
    /**
700
     * Determine if the agent is the AdBeat advertising survey.
701
     *
702
     * @return bool
703
     */
704 View Code Duplication
    public static function checkRobotAdbeat()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
705
    {
706
        if (stripos(self::$userAgentString, "adbeat.com") !== false)
707
        {
708
            self::$scriptedAgent->setName(ScriptedAgent::ADBEAT);
709
            self::$scriptedAgent->setType(ScriptedAgent::ADVERTISING);
710
            self::$scriptedAgent->setInfoURL("https://www.adbeat.com/operation_policy");
711
            return true;
712
        }
713
        return false;
714
    }
715
716
    /**
717
     * Determine if the agent is the SocialRankIO crawler.
718
     *
719
     * @return bool
720
     */
721 View Code Duplication
    public static function checkRobotSocialrank()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
722
    {
723
        if (stripos(self::$userAgentString, "SocialRankIOBot") !== false)
724
        {
725
            self::$scriptedAgent->setName(ScriptedAgent::SOCIALRANK);
726
            self::$scriptedAgent->setType(ScriptedAgent::SURVEY);
727
            self::$scriptedAgent->setInfoURL("http://socialrank.io/about");
728
            return true;
729
        }
730
        return false;
731
    }
732
733
    /**
734
     * Determine if the agent is the Gluten Free crawler.
735
     *
736
     * @return bool
737
     */
738 View Code Duplication
    public static function checkRobotGlutenFree()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
739
    {
740
        if (stripos(self::$userAgentString, "Gluten Free Crawler/") !== false)
741
        {
742
            self::$scriptedAgent->setName(ScriptedAgent::GLUTENFREE);
743
            self::$scriptedAgent->setType(ScriptedAgent::SURVEY);
744
            self::$scriptedAgent->setInfoURL("http://glutenfreepleasure.com/");
745
            return true;
746
        }
747
        return false;
748
    }
749
750
    /**
751
     * Determine if the agent is the Proximic spider.
752
     *
753
     * @return bool
754
     */
755 View Code Duplication
    public static function checkRobotProximic()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
756
    {
757
        if (stripos(self::$userAgentString, "proximic;") !== false)
758
        {
759
            self::$scriptedAgent->setName(ScriptedAgent::PROXIMIC);
760
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
761
            self::$scriptedAgent->setInfoURL("http://www.proximic.com/info/spider.php");
762
            return true;
763
        }
764
        return false;
765
    }
766
767
    /**
768
     * Determine if the agent is the Ubermetrics survey.
769
     *
770
     * @return bool
771
     */
772 View Code Duplication
    public static function checkRobotUbermetrics()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
773
    {
774
        if (stripos(self::$userAgentString, "@ubermetrics-technologies.com") !== false)
775
        {
776
            self::$scriptedAgent->setName(ScriptedAgent::UBERMETRICS);
777
            self::$scriptedAgent->setType(ScriptedAgent::SURVEY);
778
            self::$scriptedAgent->setInfoURL("https://www.ubermetrics-technologies.com/");
779
            return true;
780
        }
781
        return false;
782
    }
783
784
    /**
785
     * Determine if the agent is the Verisign ips-agent.
786
     *
787
     * @return bool
788
     */
789 View Code Duplication
    public static function checkRobotVerisign()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
790
    {
791
        if (stripos(self::$userAgentString, "ips-agent") !== false)
792
        {
793
            self::$scriptedAgent->setName(ScriptedAgent::VERISIGN);
794
            self::$scriptedAgent->setType(ScriptedAgent::SURVEY);
795
            self::$scriptedAgent->setInfoURL("http://www.spambotsecurity.com/forum/viewtopic.php?f=7&t=1453");
796
            return true;
797
        }
798
        return false;
799
    }
800
}
801