getMessage());
}
return $db;
}
function fmtb($kbytes)
{
$Max = 1024;
$Output = $kbytes;
$Suffix = 'K';
if ($Output > $Max)
{
$Output /= 1024;
$Suffix = 'M';
}
if ($Output > $Max)
{
$Output /= 1024;
$Suffix = 'G';
}
if ($Output > $Max)
{
$Output /= 1024;
$Suffix = 'T';
}
return(sprintf("
%.1f%s | ", $Output, $Suffix));
}
function ip2s32($ip) {
$i = ip2long($ip);
return ($i & 0x80000000 ? '-' . ((~$i & 0x7fffffff)+1) : ''. ($i & 0x7fffffff));
}
function prepare_sql_subnet($subnet) {
list($snet, $smask) = explode('/', $subnet);
$inet = ip2s32($snet);
if($smask > 0 && $smask < 32) {
$mask = -1 << (32 - (int)$smask);
return "and (ip & $mask = $inet)";
} elseif ($inet) {
return "and ip = " . $inet;
}
return "";
}
$starttime = time();
set_time_limit(300);
?>