summaryrefslogtreecommitdiff
path: root/isup/ping.php
blob: 4c1bea7e5d34076b7654e3c08430ac0ea1c58ee9 (plain)
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
<?php

function ping($host, $ipv6){

	if ( $ipv6 )
		$ping = "/usr/bin/fping6";
	else
		$ping = "/usr/bin/fping";

	system($ping . " " . $host . " > /dev/null 2>&1", $ret);

	if ( $ret != 0 )
		return false;

	return true;
}

function sanitizeHost($host){

	if ( preg_match("|^[a-zA-Z]+://|", $host, $match) )
		$host = str_replace($match[0], "", $host);
	if ( preg_match("|(?<query>/.*)|", $host, $match) )
		$host = str_replace($match["query"], "", $host);

	return escapeshellarg($host);
}