Completed
Branch master (258150)
by Dev
02:16 queued 26s
created

SafeBrowsing::IsOkForsafeBrowsing()   A

Complexity

Conditions 5
Paths 6

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 11
nc 6
nop 1
dl 0
loc 17
rs 9.6111
c 0
b 0
f 0
1
<?php
2
3
namespace rOpenDev\Google;
4
5
use rOpenDev\curl\CurlRequest;
6
7
class SafeBrowsing
8
{
9
    public $proxy;
10
11
    public static function get($url)
12
    {
13
        $current = new self();
14
15
        return $current->IsOkForsafeBrowsing($url);
16
    }
17
18
19
    public function IsOkForsafeBrowsing($url)
20
    {
21
        $url = 'https://transparencyreport.google.com/transparencyreport/api/v3/safebrowsing/status?site='.$url;
22
        $curl = new CurlRequest($url);
23
        $curl->setDestkopUserAgent();
24
        $curl->setReturnHeader();
25
        if (isset($this->proxy)) {
26
            $curl->setProxy($this->proxy);
27
        }
28
        $output = $curl->execute();
29
        $headers = $curl->getHeader();
30
        if ($curl->hasError() || strpos($output, '<title>Sorry...</title>') !== false) {
31
            return false;
32
        }
33
34
        //return strpos($output, 'Ce site n\'est actuellement pas') !== false ? true : false;
35
        return strpos($headers[0], '200') !== false ? true : false;
36
    }
37
}
38