phping.php

Gesponsorde koppelingen

PHP script bestanden

  1. phping.php

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/*
 * phPing - PHP Ping Tool
 * Public version 1.4
 * Released on 08-09-10
 *
 * Free to share, keep the above please :-)
 */


class phPing {

    public $result;
    public $host;
    public $port;
    public $count;
    public $timeout;
    public $errornumber;
    public $errorstring;
    
    public function __construct($host, $port, $count, $timeout = 5)
    {

        $this -> host = $host;
        $this -> port = $port;
        $this -> count = $count;
        $this -> timeout = $timeout;    
        
        return $this -> ping();
    }

    
    final protected function ping()
    {

        for($p = 1; $p <= $this -> count; $p++)
        {

            $time = explode(' ', microtime());
            $start = $time[1] + $time[0];
            
            $tmp_socket = @fsockopen($this -> host, $this -> port, $this -> errornumber, $this -> errorstring, $this -> timeout);
            
            $time = explode(' ', microtime());
            $end = $time[1] + $time[0];
            
            if(empty($this -> errorstring))
            {

                $this -> result[$p] = round(($end - $start), 4).'s';
            }

            else
            {
                $this -> result[$p] = $this -> errorstring;    
            }
        }

        
        return $this -> result;
    }
}


$object = new phPing('phphulp.nl', 80, 4);
echo 'phPing V1.4<br />';
echo 'Host: '.$object -> host.':'.$object -> port.'<br />';
echo 'Packets: '.$object -> count.'<br />';
echo 'Results:<pre>'.print_r($object -> result, true).'</pre>';

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.