Skip to content

Commit

Permalink
Merge pull request #100 from vhuk/fix-8.2-deprecations-part-1
Browse files Browse the repository at this point in the history
Fix PHP deprecation
  • Loading branch information
laf authored Dec 17, 2023
2 parents ea60439 + 04dbd21 commit ea57b45
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 11 deletions.
6 changes: 3 additions & 3 deletions lib/WeatherMap.functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions lib/WeatherMapNode.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) );
}

}
Expand Down
12 changes: 9 additions & 3 deletions lib/Weathermap.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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
Expand All @@ -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]);
Expand Down
1 change: 1 addition & 0 deletions lib/datasources/WeatherMapDataSource_fping.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// TARGET fping:hostname

class WeatherMapDataSource_fping extends WeatherMapDataSource {
var $fping_cmd;

var $addresscache = array();
var $donepings = FALSE;
Expand Down
6 changes: 3 additions & 3 deletions lib/datasources/WeatherMapDataSource_mrtg.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/datasources/WeatherMapDataSource_snmp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions lib/datasources/WeatherMapDataSource_snmp2c.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

class WeatherMapDataSource_snmp2c extends WeatherMapDataSource
{
var $down_cache;

function Init(&$map)
{
Expand Down

0 comments on commit ea57b45

Please sign in to comment.