check_website

Php code posted
created at 13 Dec 15:24

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php

if(!isset($argv[1])) { echo "Usage: ./check_www <url (without http://)>\n"; exit(2); }

$url = "http://" . $argv[1];
$header = @get_headers($url, 1);

if(!$header) { echo "Could not connect to $url"; exit(2); }

if(preg_match('/200/', $header[0]))
        {
        print_r($header[0]);
        exit(0);
        }
elseif(preg_match('/302/', $header[0]))
        {
        print_r($header[0]);
        exit(0);
        }
elseif(preg_match('/301/', $header[0]))
        {
        print_r($header[0]);
        exit(0);
        }
else
        {
        print_r($header[0]);
        exit(2);
        }
?>
635 Bytes in 3 ms with coderay