2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-01 19:30:31 +00:00
fhem-mirror/fhem/webfrontend/pgm3/include/functions.php
martinhaas 5fbd1b8050 minor bugfix: rebuild picture of fht on every entry in the log (not only on change of measured-temp. Changes in fht.php
logrotate: better warning if there are wrong rights for the pgm3-logrotate


git-svn-id: https://svn.fhem.de/fhem/trunk@117 2b470e98-0d58-463d-a4d8-8e2adae1ed80
2007-12-03 10:10:29 +00:00

52 lines
1.3 KiB
PHP

<?php
##Functions for pgm3
function LogRotate($array,$file,$logrotatelines)
{
$counter=count($array);
$filename=$file;
if (!$handle = fopen($filename, "w")) {
print "Logrotate: cannot open $filename -- correct rights?? Read the chapter in the config.php!";
exit;
}
for ($x = $counter-$logrotatelines; $x < $counter; $x++)
{fwrite($handle, $array[$x]);};
fclose($handle);
}
function bft($windspeed) # wind speed in Beaufort
{
if($windspeed>= 118.5) { $bft= 12; }
elseif($windspeed>= 103.7) { $bft= 11; }
elseif($windspeed>= 88.9) { $bft= 10; }
elseif($windspeed>= 75.9) { $bft= 9; }
elseif($windspeed>= 63.0) { $bft= 8; }
elseif($windspeed>= 51.9) { $bft= 7; }
elseif($windspeed>= 40.7) { $bft= 6; }
elseif($windspeed>= 29.6) { $bft= 5; }
elseif($windspeed>= 20.4) { $bft= 4; }
elseif($windspeed>= 13.0) { $bft= 3; }
elseif($windspeed>= 7.4) { $bft= 2; }
elseif($windspeed>= 1.9) { $bft= 1; }
else $bft= 0;
return($bft);
}
function randdefine()
{
$rand1 = rand(500,20000);
$rand2 = rand(500,20000);
$rq = md5($rand1.$rand2);
$randdefine=substr($rq,0,5);
return ($randdefine);
}
?>