1 |
cb7d18d5
|
Renato Botelho
|
#!/usr/local/bin/php-cgi -f
|
2 |
5b237745
|
Scott Ullrich
|
<?php
|
3 |
|
|
/*
|
4 |
ac24dc24
|
Renato Botelho
|
* rc.initial.ping
|
5 |
|
|
*
|
6 |
|
|
* part of pfSense (https://www.pfsense.org)
|
7 |
b8f91b7c
|
Luiz Souza
|
* Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
|
8 |
ac24dc24
|
Renato Botelho
|
* All rights reserved.
|
9 |
|
|
*
|
10 |
|
|
* originally part of m0n0wall (http://m0n0.ch/wall)
|
11 |
c5d81585
|
Renato Botelho
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
12 |
ac24dc24
|
Renato Botelho
|
* All rights reserved.
|
13 |
|
|
*
|
14 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
15 |
|
|
* you may not use this file except in compliance with the License.
|
16 |
|
|
* You may obtain a copy of the License at
|
17 |
ac24dc24
|
Renato Botelho
|
*
|
18 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
19 |
ac24dc24
|
Renato Botelho
|
*
|
20 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
21 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
22 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
23 |
|
|
* See the License for the specific language governing permissions and
|
24 |
|
|
* limitations under the License.
|
25 |
ac24dc24
|
Renato Botelho
|
*/
|
26 |
e173dd74
|
Phil Davis
|
|
27 |
ac24dc24
|
Renato Botelho
|
/* parse the configuration and include all functions used below */
|
28 |
|
|
require_once("config.inc");
|
29 |
|
|
require_once("functions.inc");
|
30 |
e173dd74
|
Phil Davis
|
|
31 |
ac24dc24
|
Renato Botelho
|
$fp = fopen('php://stdin', 'r');
|
32 |
e173dd74
|
Phil Davis
|
|
33 |
ac24dc24
|
Renato Botelho
|
echo "\nEnter a host name or IP address: ";
|
34 |
e173dd74
|
Phil Davis
|
|
35 |
ac24dc24
|
Renato Botelho
|
$pinghost = chop(fgets($fp));
|
36 |
|
|
if (is_ipaddrv4($pinghost) || is_hostname($pinghost)) {
|
37 |
|
|
$command = "ping";
|
38 |
|
|
} elseif (is_ipaddrv6($pinghost)) {
|
39 |
|
|
$command = "ping6";
|
40 |
|
|
}
|
41 |
|
|
if ($command) {
|
42 |
|
|
echo "\n";
|
43 |
|
|
passthru("/sbin/{$command} -c 3 -n " . escapeshellarg($pinghost));
|
44 |
|
|
echo "\nPress ENTER to continue.\n";
|
45 |
|
|
fgets($fp);
|
46 |
|
|
}
|
47 |
e173dd74
|
Phil Davis
|
|
48 |
ac24dc24
|
Renato Botelho
|
fclose($fp);
|
49 |
5b237745
|
Scott Ullrich
|
?>
|