ping

Gesponsorde koppelingen

PHP script bestanden

  1. ping

« 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php

        // Address error handling.

        ini_set('display_errors', 1);
        error_reporting(E_ALL ^ E_NOTICE);

        // Obtain POST data.

        $ping_ip_addr = $_POST['ping_ip_addr']; // input
        $ping_count   = $_POST['ping_count'];   // select
        $ping_option  = $_POST['ping_option'];  // select

        // Remove any slashes if Magic Quotes GPC is enabled.


        if (get_magic_quotes_gpc())
        {

                $ping_ip_addr = stripslashes($ping_ip_addr);
        }


        // Create arrays.

        $ping_count_array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 25); // Ping count

?>


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title>Ping</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="author" content="firstbase" />
<style type="text/css">

body
{
        margin: 0;
        padding: 10px;
        background-color: #ffffff;
}

div.output
{
        margin: 0;
        padding: 10px;
        background-color: #eeeeee;
        border-style: solid;
        border-width: 1px;
        border-color: #000000;
}

</style>
</head>

<body>
<h1>Ping</h1>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<p><label for="ping_ip_addr">IP address:</label><br />
<input name="ping_ip_addr" id="ping_ip_addr" type="text" value="<?php echo $_POST['submit'] == 'Ping' ? htmlentities($ping_ip_addr, ENT_QUOTES) : $_SERVER['REMOTE_ADDR'];; ?>" size="40" maxlength="15" /></p>
<p><label for="ping_count">Ping count:</label><br />
<select name="ping_count" id="ping_count">
<?php

        foreach ($ping_count_array as $ping_count_item)
        {

                echo '<option' . ($ping_count == $ping_count_item ? ' selected="selected"' : '') . '>' . $ping_count_item . '</option>' . "\n";
        }


?>

</select></p>
<p><input type="submit" name="submit" value="Ping" /></p>
</form>
<p>Ping may take a while, please be patient.</p>
<?php

        if ($_POST['submit'] == 'Ping') // Form has been submitted.
        {
                echo '<div class="output">' . "\n";

                /**************************************************************************/

                // Check for spoofed form submission.


                $illegal = FALSE;

                if (strlen($ping_ip_addr) > 15)
                {

                        $illegal = TRUE;
                }


                if (!in_array($ping_count, $ping_count_array))
                {

                        $illegal = TRUE;
                }


                /**************************************************************************/

                if (!$illegal) // Form submission was not spoofed.
                {
                        if (ereg('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$', $ping_ip_addr)) // Acquired data contains no problems.
                        {
                                // Display result.

                                echo '<pre>' . "\n" .
                                'ping -n ' . $ping_count . ' ' . $ping_ip_addr . "\n\n";

                                system('ping -n ' . $ping_count . ' ' . $ping_ip_addr); // Ping IP address.

                                echo '</pre>' . "\n" .
                                '<p>Ping complete.</p>' . "\n";
                        }

                        else // Acquired data contains problems!
                        {
                                echo '<p>Please enter a valid IP address.</p>' . "\n";
                        }
                }

                else // Form submission was spoofed!
                {
                        echo '<p>An illegal operation was encountered.</p>' . "\n";
                }


                echo '</div>' . "\n";
        }


?>

</body>

</html>

 
 

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.