807 |
807 |
return 0;
|
808 |
808 |
}
|
809 |
809 |
|
810 |
|
// 2**N returns an exact result as an INT if possible, and a float/double if not.
|
|
810 |
// 2**N returns an exact result as an INT if possible, and a float/double if not.
|
811 |
811 |
// Detect this switch, rather than comparing $result<=PHP_MAX_INT or $bits >=8*PHP_INT_SIZE as it's (probably) easier to get completely reliable
|
812 |
812 |
$result = 2 ** $snsize;
|
813 |
|
|
|
813 |
|
814 |
814 |
if ($exact && !is_int($result)) {
|
815 |
815 |
//exact required but can't represent result exactly as an INT
|
816 |
816 |
return 0;
|
... | ... | |
850 |
850 |
$largest_sn = min($bits1, $bits2);
|
851 |
851 |
$subnetv4_start1 = gen_subnetv4($subnet1, $largest_sn);
|
852 |
852 |
$subnetv4_start2 = gen_subnetv4($subnet2, $largest_sn);
|
853 |
|
|
|
853 |
|
854 |
854 |
if ($subnetv4_start1 == '' || $subnetv4_start2 == '') {
|
855 |
855 |
// One or both args is not a valid IPv4 subnet
|
856 |
856 |
//FIXME: needs to return "bad data" not true/false if bad. For now return false, best we can do until fixed
|
... | ... | |
865 |
865 |
$largest_sn = min($bits1, $bits2);
|
866 |
866 |
$subnetv6_start1 = gen_subnetv6($subnet1, $largest_sn);
|
867 |
867 |
$subnetv6_start2 = gen_subnetv6($subnet2, $largest_sn);
|
868 |
|
|
|
868 |
|
869 |
869 |
if ($subnetv6_start1 == '' || $subnetv6_start2 == '') {
|
870 |
870 |
// One or both args is not a valid IPv6 subnet
|
871 |
871 |
//FIXME: needs to return "bad data" not true/false if bad. For now return false, best we can do until fixed
|
... | ... | |
1863 |
1863 |
return ("$num {$units[$i]}");
|
1864 |
1864 |
}
|
1865 |
1865 |
|
1866 |
|
function update_filter_reload_status($text) {
|
|
1866 |
function update_filter_reload_status($text, $new=false) {
|
1867 |
1867 |
global $g;
|
1868 |
1868 |
|
1869 |
|
file_put_contents("{$g['varrun_path']}/filter_reload_status", $text);
|
|
1869 |
if ($new) {
|
|
1870 |
file_put_contents("{$g['varrun_path']}/filter_reload_status", $text . PHP_EOL);
|
|
1871 |
} else {
|
|
1872 |
file_put_contents("{$g['varrun_path']}/filter_reload_status", $text . PHP_EOL, FILE_APPEND);
|
|
1873 |
}
|
1870 |
1874 |
}
|
1871 |
1875 |
|
1872 |
1876 |
/****** util/return_dir_as_array
|
Revise update_filter_relaod_status() function to append status messages rather than overwrite the file