From 04dbd21feb9686b296b0ea2882bda174a70d8bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Hukkam=C3=A4ki?= Date: Sat, 9 Dec 2023 04:06:42 +0200 Subject: [PATCH] Fix PHP 8.2 deprecation - part 1 --- lib/WeatherMap.functions.php | 6 +++--- lib/WeatherMapNode.class.php | 10 ++++++++-- lib/Weathermap.class.php | 12 +++++++++--- lib/datasources/WeatherMapDataSource_fping.php | 1 + lib/datasources/WeatherMapDataSource_mrtg.php | 6 +++--- lib/datasources/WeatherMapDataSource_snmp.php | 1 + lib/datasources/WeatherMapDataSource_snmp2c.php | 1 + 7 files changed, 26 insertions(+), 11 deletions(-) diff --git a/lib/WeatherMap.functions.php b/lib/WeatherMap.functions.php index d606a89..72b32a1 100644 --- a/lib/WeatherMap.functions.php +++ b/lib/WeatherMap.functions.php @@ -1883,7 +1883,7 @@ function wimagefilledrectangle( $image ,$x1, $y1, $x2, $y2, $color ) $r = $r/255; $g=$g/255; $b=$b/255; $a=(127-$a)/127; metadump("FRECT $x1 $y1 $x2 $y2 $r $g $b $a"); - return(imagefilledrectangle( $image ,$x1, $y1, $x2, $y2, $color )); + return(imagefilledrectangle( $image ,(int)$x1, (int)$y1, (int)$x2, (int)$y2, $color )); } function wimagerectangle( $image ,$x1, $y1, $x2, $y2, $color ) @@ -1915,7 +1915,7 @@ function wimagepolygon($image, $points, $num_points, $color) metadump("POLY $num_points ".$pts." $r $g $b $a"); - return(imagepolygon($image, $points, $num_points, $color)); + return(imagepolygon($image, $points, $color)); } function wimagefilledpolygon($image, $points, $num_points, $color) @@ -1935,7 +1935,7 @@ function wimagefilledpolygon($image, $points, $num_points, $color) metadump("FPOLY $num_points ".$pts." $r $g $b $a"); - return(imagefilledpolygon($image, $points, $num_points, $color)); + return(imagefilledpolygon($image, $points, $color)); } function wimagecreatetruecolor($width, $height) diff --git a/lib/WeatherMapNode.class.php b/lib/WeatherMapNode.class.php index 55fa40d..2ef8f86 100644 --- a/lib/WeatherMapNode.class.php +++ b/lib/WeatherMapNode.class.php @@ -54,7 +54,8 @@ class WeatherMapNode extends WeatherMapItem var $template; var $polar; var $boundingboxes=array(); - + var $aiconoutlinecolour; + var $aiconfillcolour; function __construct() { $this->inherit_fieldlist=array @@ -627,6 +628,11 @@ function pre_render($im, &$map) $txt_y -= $bbox_y1; $txt_y += ($this->labeloffsety + $dy); + $label_x1=(int)$label_x1; + $label_y1=(int)$label_y1; + $label_x2=(int)$label_x2; + $label_y2=(int)$label_y2; + # print "FINAL TEXT at $txt_x , $txt_y\n"; // if there's an icon, then you can choose to have no background @@ -716,7 +722,7 @@ function NewDraw($im, &$map) if(isset($this->image)) { imagealphablending($im, true); - imagecopy ( $im, $this->image, $this->x - $this->centre_x, $this->y - $this->centre_y, 0, 0, imagesx($this->image), imagesy($this->image) ); + imagecopy ( $im, $this->image, (int)($this->x - $this->centre_x), (int)($this->y - $this->centre_y), 0, 0, imagesx($this->image), imagesy($this->image) ); } } diff --git a/lib/Weathermap.class.php b/lib/Weathermap.class.php index f575fd2..441f5a7 100644 --- a/lib/Weathermap.class.php +++ b/lib/Weathermap.class.php @@ -274,6 +274,12 @@ class WeatherMap extends WeatherMapBase var $coverage = array(); var $colourtable = array(); var $warncount = 0; + var $numscales = array(); + var $dumpconfig; + var $labelstyle; + var $fonts; + var $basehref; + var $image; function WeatherMap(){ return __construct(); @@ -503,7 +509,7 @@ function myimagestring($image, $fontnumber, $x, $y, $string, $colour, $angle = 0 } if (($fontnumber > 0) && ($fontnumber < 6)) { - imagestring($image, $fontnumber, $x, $y - imagefontheight($fontnumber), $string, $colour); + imagestring($image, $fontnumber, (int)$x, (int)$y - imagefontheight($fontnumber), $string, $colour); if ($angle != 0) { wm_warn("Angled text doesn't work with non-FreeType fonts [WMWARN02]\n"); } @@ -1106,7 +1112,7 @@ function DrawLabelRotated( )) { $bgcol = myimagecolorallocate($im, $bgcolour[0], $bgcolour[1], $bgcolour[2]); # imagefilledrectangle($im, $x1, $y1, $x2, $y2, $bgcol); - wimagefilledpolygon($im, $points, 4, $bgcol); + wimagefilledpolygon($im, array_slice($points,0,8), 4, $bgcol); } if ($outlinecolour != array @@ -1117,7 +1123,7 @@ function DrawLabelRotated( )) { $outlinecol = myimagecolorallocate($im, $outlinecolour[0], $outlinecolour[1], $outlinecolour[2]); # imagerectangle($im, $x1, $y1, $x2, $y2, $outlinecol); - wimagepolygon($im, $points, 4, $outlinecol); + wimagepolygon($im, array_slice($points,0,8), 4, $outlinecol); } $textcol = myimagecolorallocate($im, $textcolour[0], $textcolour[1], $textcolour[2]); diff --git a/lib/datasources/WeatherMapDataSource_fping.php b/lib/datasources/WeatherMapDataSource_fping.php index 14dd97b..4c7a737 100644 --- a/lib/datasources/WeatherMapDataSource_fping.php +++ b/lib/datasources/WeatherMapDataSource_fping.php @@ -6,6 +6,7 @@ // TARGET fping:hostname class WeatherMapDataSource_fping extends WeatherMapDataSource { + var $fping_cmd; var $addresscache = array(); var $donepings = FALSE; diff --git a/lib/datasources/WeatherMapDataSource_mrtg.php b/lib/datasources/WeatherMapDataSource_mrtg.php index 86d0c69..e118134 100644 --- a/lib/datasources/WeatherMapDataSource_mrtg.php +++ b/lib/datasources/WeatherMapDataSource_mrtg.php @@ -39,10 +39,10 @@ function ReadData($targetstring, &$map, &$item) while (!feof($fd)) { $buffer=fgets($fd, 4096); - wm_debug("MRTG ReadData: Matching on '${matchvalue}in $matchperiod' and '${matchvalue}out $matchperiod'\n"); + wm_debug("MRTG ReadData: Matching on '{$matchvalue}in $matchperiod' and '{$matchvalue}out $matchperiod'\n"); - if (preg_match("/<\!-- ${matchvalue}in $matchperiod ([-+]?\d+\.?\d*) -->/", $buffer, $matches)) { $data[IN] = $matches[1] * 8; } - if (preg_match("/<\!-- ${matchvalue}out $matchperiod ([-+]?\d+\.?\d*) -->/", $buffer, $matches)) { $data[OUT] = $matches[1] * 8; } + if (preg_match("/<\!-- {$matchvalue}in $matchperiod ([-+]?\d+\.?\d*) -->/", $buffer, $matches)) { $data[IN] = $matches[1] * 8; } + if (preg_match("/<\!-- {$matchvalue}out $matchperiod ([-+]?\d+\.?\d*) -->/", $buffer, $matches)) { $data[OUT] = $matches[1] * 8; } } fclose($fd); # don't bother with the modified time if the target is a URL diff --git a/lib/datasources/WeatherMapDataSource_snmp.php b/lib/datasources/WeatherMapDataSource_snmp.php index 803e2ee..ee5bd6c 100644 --- a/lib/datasources/WeatherMapDataSource_snmp.php +++ b/lib/datasources/WeatherMapDataSource_snmp.php @@ -14,6 +14,7 @@ // (that is, TARGET snmp:community:host:in_oid:out_oid class WeatherMapDataSource_snmp extends WeatherMapDataSource { + var $down_cache; function Init(&$map) { diff --git a/lib/datasources/WeatherMapDataSource_snmp2c.php b/lib/datasources/WeatherMapDataSource_snmp2c.php index 645e2ee..6133044 100644 --- a/lib/datasources/WeatherMapDataSource_snmp2c.php +++ b/lib/datasources/WeatherMapDataSource_snmp2c.php @@ -15,6 +15,7 @@ class WeatherMapDataSource_snmp2c extends WeatherMapDataSource { + var $down_cache; function Init(&$map) {