Project

General

Profile

Download (1.48 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php-cgi -f
2
<?php
3
/*
4
 * rc.initial.ping
5
 *
6
 * part of pfSense (https://www.pfsense.org)
7
 * Copyright (c) 2004-2013 BSD Perimeter
8
 * Copyright (c) 2013-2016 Electric Sheep Fencing
9
 * Copyright (c) 2014-2020 Rubicon Communications, LLC (Netgate)
10
 * All rights reserved.
11
 *
12
 * originally part of m0n0wall (http://m0n0.ch/wall)
13
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
14
 * All rights reserved.
15
 *
16
 * Licensed under the Apache License, Version 2.0 (the "License");
17
 * you may not use this file except in compliance with the License.
18
 * You may obtain a copy of the License at
19
 *
20
 * http://www.apache.org/licenses/LICENSE-2.0
21
 *
22
 * Unless required by applicable law or agreed to in writing, software
23
 * distributed under the License is distributed on an "AS IS" BASIS,
24
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
 * See the License for the specific language governing permissions and
26
 * limitations under the License.
27
 */
28

    
29
/* parse the configuration and include all functions used below */
30
require_once("config.inc");
31
require_once("functions.inc");
32

    
33
$fp = fopen('php://stdin', 'r');
34

    
35
echo "\nEnter a host name or IP address: ";
36

    
37
$pinghost = chop(fgets($fp));
38
if (is_ipaddrv4($pinghost) || is_hostname($pinghost)) {
39
	$command = "ping";
40
} elseif (is_ipaddrv6($pinghost)) {
41
	$command = "ping6";
42
}
43
if ($command) {
44
	echo "\n";
45
	passthru("/sbin/{$command} -c 3 -n " . escapeshellarg($pinghost));
46
	echo "\nPress ENTER to continue.\n";
47
	fgets($fp);
48
}
49

    
50
fclose($fp);
51
?>
(41-41/82)