1 |
cb7d18d5
|
Renato Botelho
|
#!/usr/local/bin/php-cgi -f
|
2 |
5b237745
|
Scott Ullrich
|
<?php
|
3 |
|
|
/*
|
4 |
8acd654a
|
Renato Botelho
|
* rc.initial.ping
|
5 |
|
|
*
|
6 |
|
|
* part of pfSense (https://www.pfsense.org)
|
7 |
2a2396a6
|
Renato Botelho
|
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
|
8 |
8acd654a
|
Renato Botelho
|
* All rights reserved.
|
9 |
|
|
*
|
10 |
|
|
* originally part of m0n0wall (http://m0n0.ch/wall)
|
11 |
aaec5634
|
Renato Botelho
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
12 |
8acd654a
|
Renato Botelho
|
* All rights reserved.
|
13 |
|
|
*
|
14 |
|
|
* Redistribution and use in source and binary forms, with or without
|
15 |
|
|
* modification, are permitted provided that the following conditions are met:
|
16 |
|
|
*
|
17 |
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
18 |
|
|
* this list of conditions and the following disclaimer.
|
19 |
|
|
*
|
20 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
21 |
|
|
* notice, this list of conditions and the following disclaimer in
|
22 |
|
|
* the documentation and/or other materials provided with the
|
23 |
|
|
* distribution.
|
24 |
|
|
*
|
25 |
|
|
* 3. All advertising materials mentioning features or use of this software
|
26 |
|
|
* must display the following acknowledgment:
|
27 |
|
|
* "This product includes software developed by the pfSense Project
|
28 |
|
|
* for use in the pfSense® software distribution. (http://www.pfsense.org/).
|
29 |
|
|
*
|
30 |
|
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
31 |
|
|
* endorse or promote products derived from this software without
|
32 |
|
|
* prior written permission. For written permission, please contact
|
33 |
|
|
* coreteam@pfsense.org.
|
34 |
|
|
*
|
35 |
|
|
* 5. Products derived from this software may not be called "pfSense"
|
36 |
|
|
* nor may "pfSense" appear in their names without prior written
|
37 |
|
|
* permission of the Electric Sheep Fencing, LLC.
|
38 |
|
|
*
|
39 |
|
|
* 6. Redistributions of any form whatsoever must retain the following
|
40 |
|
|
* acknowledgment:
|
41 |
|
|
*
|
42 |
|
|
* "This product includes software developed by the pfSense Project
|
43 |
|
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
44 |
|
|
*
|
45 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
46 |
|
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
47 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
48 |
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
49 |
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
50 |
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
51 |
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
52 |
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
53 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
54 |
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
55 |
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
56 |
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
57 |
|
|
*/
|
58 |
e173dd74
|
Phil Davis
|
|
59 |
8acd654a
|
Renato Botelho
|
/* parse the configuration and include all functions used below */
|
60 |
|
|
require_once("config.inc");
|
61 |
|
|
require_once("functions.inc");
|
62 |
e173dd74
|
Phil Davis
|
|
63 |
8acd654a
|
Renato Botelho
|
$fp = fopen('php://stdin', 'r');
|
64 |
e173dd74
|
Phil Davis
|
|
65 |
8acd654a
|
Renato Botelho
|
echo "\nEnter a host name or IP address: ";
|
66 |
e173dd74
|
Phil Davis
|
|
67 |
8acd654a
|
Renato Botelho
|
$pinghost = chop(fgets($fp));
|
68 |
|
|
if (is_ipaddrv4($pinghost) || is_hostname($pinghost)) {
|
69 |
|
|
$command = "ping";
|
70 |
|
|
} elseif (is_ipaddrv6($pinghost)) {
|
71 |
|
|
$command = "ping6";
|
72 |
|
|
}
|
73 |
|
|
if ($command) {
|
74 |
|
|
echo "\n";
|
75 |
|
|
passthru("/sbin/{$command} -c 3 -n " . escapeshellarg($pinghost));
|
76 |
|
|
echo "\nPress ENTER to continue.\n";
|
77 |
|
|
fgets($fp);
|
78 |
|
|
}
|
79 |
e173dd74
|
Phil Davis
|
|
80 |
8acd654a
|
Renato Botelho
|
fclose($fp);
|
81 |
5b237745
|
Scott Ullrich
|
?>
|