Completed
Push — master ( 5e74d9...55d050 )
by Guilherme Luiz Argentino
06:49
created

curlssltest.php ➔ nxs_cURLTest()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 20
nc 2
nop 3
dl 0
loc 22
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * To change this license header, choose License Headers in Project Properties.
5
 * To change this template file, choose Tools | Templates
6
 * and open the template in the editor.
7
 */
8
9
function nxs_cURLTest($url, $msg, $testText) {
10
    $ch = curl_init();
11
    curl_setopt($ch, CURLOPT_URL, $url);
12
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36");
13
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
14
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
15
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
16
    $response = curl_exec($ch);
17
    $errmsg = curl_error($ch);
18
    $cInfo = curl_getinfo($ch);
19
    curl_close($ch);
20
    echo "Testing ... " . $url . " - " . $cInfo['url'] . "<br />";
21
    if (stripos($response, $testText) !== false) {
22
        echo "...." . $msg . " - OK<br />";
23
    } else {
24
        echo "....<b style='color:red;'>" . $msg . " - Problem</b><br /><pre>";
25
        print_r($errmsg);
26
        print_r($cInfo);
27
        print_r(htmlentities($response));
28
        echo "</pre>There is a problem with cURL. You need to contact your server admin or hosting provider.";
29
    }
30
}
31
32
//nxs_cURLTest("http://www.nextscripts.com/", "HTTPS to NXS", "Social Networks");
33
nxs_cURLTest("http://www.google.com/intl/en/contact/", "HTTP to Google", "Mountain View, CA");
34
nxs_cURLTest("https://www.google.com/intl/en/contact/", "HTTPS to Google", "Mountain View, CA");
35
nxs_cURLTest("https://www.facebook.com/", "HTTPS to Facebook", 'id="facebook"');
36
nxs_cURLTest("https://graph.facebook.com/", "HTTPS to API (Graph) Facebook", 'get');
37
nxs_cURLTest("https://www.linkedin.com/nhome/", "HTTPS to LinkedIn", 'rel="canonical" href="https://www.linkedin.com/');
38
nxs_cURLTest("https://twitter.com/", "HTTPS to Twitter", '<link rel="canonical" href="https://twitter.com');
39
nxs_cURLTest("https://www.pinterest.com/", "HTTPS to Pinterest", 'content="Pinterest"');
40
nxs_cURLTest("https://www.livejournal.com/", "HTTP to LiveJournal", 'LiveJournal');
41