From fd2e0189fa6ea9463d92a96fdc44aea3411edb1d Mon Sep 17 00:00:00 2001 From: milkyway Date: Sat, 28 Jul 2018 13:55:09 +0200 Subject: [PATCH 1/4] Replaced deprecated code --- src/pData.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pData.php b/src/pData.php index 2a57a03..137acfe 100644 --- a/src/pData.php +++ b/src/pData.php @@ -56,8 +56,8 @@ class pData function __construct() { - $this->Data = ""; - $this->DataDescription = ""; + $this->Data = array(); + $this->DataDescription = array(); $this->DataDescription["Position"] = "Name"; $this->DataDescription["Format"]["X"] = "number"; $this->DataDescription["Format"]["Y"] = "number"; @@ -74,7 +74,7 @@ function ImportFromCSV($FileName, $Delimiter = ",", $DataColumns = -1, $HasHeade $buffer = fgets($handle, 4096); $buffer = str_replace(chr(10), "", $buffer); $buffer = str_replace(chr(13), "", $buffer); - $Values = split($Delimiter, $buffer); + $Values = explode($Delimiter, $buffer); if ($buffer != "") { if ($HasHeader == TRUE && $HeaderParsed == FALSE) { @@ -128,7 +128,7 @@ function AddPoint($Value, $Serie = "Serie1", $Description = "") } } - if (count($Value) == 1) { + if (!is_array($Value)) { $this->Data[$ID][$Serie] = $Value; if ($Description != "") $this->Data[$ID]["Name"] = $Description; From a9039512131398956eb6a961b8e42847806505d9 Mon Sep 17 00:00:00 2001 From: milkyway Date: Sat, 28 Jul 2018 14:07:52 +0200 Subject: [PATCH 2/4] Do not init arrays as string --- src/pChart.php | 52 +++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/pChart.php b/src/pChart.php index 48949f0..309ee5d 100644 --- a/src/pChart.php +++ b/src/pChart.php @@ -1828,7 +1828,7 @@ function drawArea($Data, $Serie1, $Serie2, $R, $G, $B, $Alpha = 50) $YPos2 = $LayerHeight - (($Value2 - $this->VMin) * $this->DivisionRatio); if ($LastXPos != -1) { - $Points = ""; + $Points = array(); $Points[] = $LastXPos; $Points[] = $LastYPos1; $Points[] = $LastXPos; @@ -2009,10 +2009,10 @@ function drawCubicCurve($Data, $DataDescription, $Accuracy = .1, $SerieName = "" $GraphID = 0; foreach ($DataDescription["Values"] as $Key2 => $ColName) { if ($SerieName == "" || $SerieName == $ColName) { - $XIn = ""; - $Yin = ""; - $Yt = ""; - $U = ""; + $XIn = array(); + $Yin = array(); + $Yt = array(); + $U = array(); $XIn[0] = 0; $YIn[0] = 0; @@ -2026,7 +2026,7 @@ function drawCubicCurve($Data, $DataDescription, $Accuracy = .1, $SerieName = "" $Index = 1; $XLast = -1; - $Missing = ""; + $Missing = array(); foreach ($Data as $Key => $Values) { if (isset($Data[$Key][$ColName])) { $Value = $Data[$Key][$ColName]; @@ -2125,10 +2125,10 @@ function drawFilledCubicCurve($Data, $DataDescription, $Accuracy = .1, $Alpha = $GraphID = 0; foreach ($DataDescription["Values"] as $Key2 => $ColName) { - $XIn = ""; - $Yin = ""; - $Yt = ""; - $U = ""; + $XIn = array(); + $Yin = array(); + $Yt = array(); + $U = array(); $XIn[0] = 0; $YIn[0] = 0; @@ -2142,7 +2142,7 @@ function drawFilledCubicCurve($Data, $DataDescription, $Accuracy = .1, $Alpha = $Index = 1; $XLast = -1; - $Missing = ""; + $Missing = array(); foreach ($Data as $Key => $Values) { $Value = $Data[$Key][$ColName]; $XIn[$Index] = $Index; @@ -2172,7 +2172,7 @@ function drawFilledCubicCurve($Data, $DataDescription, $Accuracy = .1, $Alpha = for ($k = $Index - 1; $k >= 1; $k--) $Yt[$k] = $Yt[$k] * $Yt[$k + 1] + $U[$k]; - $Points = ""; + $Points = array(); $Points[] = $this->GAreaXOffset; $Points[] = $LayerHeight; @@ -2205,7 +2205,7 @@ function drawFilledCubicCurve($Data, $DataDescription, $Accuracy = .1, $Alpha = $YPos = $LayerHeight - (($Value - $this->VMin) * $this->DivisionRatio); if ($YLast != NULL && $AroundZero && !isset($Missing[floor($X)]) && !isset($Missing[floor($X + 1)])) { - $aPoints = ""; + $aPoints = array(); $aPoints[] = $XLast; $aPoints[] = $YLast; $aPoints[] = $XPos; @@ -2241,7 +2241,7 @@ function drawFilledCubicCurve($Data, $DataDescription, $Accuracy = .1, $Alpha = $YPos = $LayerHeight - (($YIn[$Index] - $this->VMin) * $this->DivisionRatio); if ($YLast != NULL && $AroundZero) { - $aPoints = ""; + $aPoints = array(); $aPoints[] = $XLast; $aPoints[] = $YLast; $aPoints[] = $LayerWidth - $this->GAreaXOffset; @@ -2310,7 +2310,7 @@ function drawFilledLineGraph($Data, $DataDescription, $Alpha = 100, $AroundZero $ID++; } - $aPoints = ""; + $aPoints = array(); $aPoints[] = $this->GAreaXOffset; $aPoints[] = $LayerHeight; @@ -2358,7 +2358,7 @@ function drawFilledLineGraph($Data, $DataDescription, $Alpha = 100, $AroundZero } if ($YLast <> $Empty && $AroundZero) { - $Points = ""; + $Points = array(); $Points[] = $XLast; $Points[] = $YLast; $Points[] = $XPos; @@ -2559,7 +2559,7 @@ function drawStackedBarGraph($Data, $DataDescription, $Alpha = 50, $Contiguous = } $SerieID = 0; - $LastValue = ""; + $LastValue = array(); foreach ($DataDescription["Values"] as $ColName) { $ID = 0; foreach ($DataDescription["Description"] as $keyI => $ValueI) { @@ -2723,7 +2723,7 @@ function drawRadarAxis($Data, $DataDescription, $Mosaic = TRUE, $BorderOffset = $Y2 = sin($Angle * 3.1418 / 180) * ($TRadius + $RadiusScale) + $YCenter; if ($t % 2 == 1 && $LastX1 != -1) { - $Plots = ""; + $Plots = array(); $Plots[] = $X1; $Plots[] = $Y1; $Plots[] = $X2; @@ -2939,7 +2939,7 @@ function drawFilledRadar($Data, $DataDescription, $Alpha = 50, $BorderOffset = 1 $Angle = -90; $XLast = -1; - $Plots = ""; + $Plots = array(); foreach ($Data as $Key => $Values) { if (isset($Data[$Key][$ColName])) { $Value = $Data[$Key][$ColName]; @@ -3028,7 +3028,7 @@ function drawBasicPieGraph($Data, $DataDescription, $XPos, $YPos, $Radius = 100, /* Calculate all polygons */ $Angle = 0; - $TopPlots = ""; + $TopPlots = array(); foreach ($iValues as $Key => $Value) { $TopPlots[$Key][] = $XPos; $TopPlots[$Key][] = $YPos; @@ -3158,7 +3158,7 @@ function drawFlatPieGraph($Data, $DataDescription, $XPos, $YPos, $Radius = 100, /* Calculate all polygons */ $Angle = 0; - $TopPlots = ""; + $TopPlots = array(); foreach ($iValues as $Key => $Value) { $XOffset = cos(($Angle + ($Value / 2 * $SpliceRatio)) * 3.1418 / 180) * $SpliceDistance; $YOffset = sin(($Angle + ($Value / 2 * $SpliceRatio)) * 3.1418 / 180) * $SpliceDistance; @@ -3317,10 +3317,10 @@ function drawPieGraph($Data, $DataDescription, $XPos, $YPos, $Radius = 100, $Dra /* Calculate all polygons */ $Angle = 0; $CDev = 5; - $TopPlots = ""; - $BotPlots = ""; - $aTopPlots = ""; - $aBotPlots = ""; + $TopPlots = array(); + $BotPlots = array(); + $aTopPlots = array(); + $aBotPlots = array(); foreach ($iValues as $Key => $Value) { $XCenterPos = cos(($Angle - $CDev + ($Value * $SpliceRatio + $SpliceDistanceRatio) / 2) * 3.1418 / 180) * $SpliceDistance + $XPos; $YCenterPos = sin(($Angle - $CDev + ($Value * $SpliceRatio + $SpliceDistanceRatio) / 2) * 3.1418 / 180) * $SpliceDistance + $YPos; @@ -3418,7 +3418,7 @@ function drawPieGraph($Data, $DataDescription, $XPos, $YPos, $Radius = 100, $Dra for ($i = $SpliceHeight - 1; $i >= 1; $i--) { foreach ($iValues as $Key => $Value) { $C_GraphLo = $this->AllocateColor($this->Picture, $this->Palette[$Key]["R"], $this->Palette[$Key]["G"], $this->Palette[$Key]["B"], -10); - $Plots = ""; + $Plots = array(); $Plot = 0; foreach ($TopPlots[$Key] as $Key2 => $Value2) { $Plot++; From e02ff38630c69ecd5b51a8d14dc4222d70595de0 Mon Sep 17 00:00:00 2001 From: milkyway Date: Sat, 28 Jul 2018 15:12:02 +0200 Subject: [PATCH 3/4] do not use count for probably null --- src/pChart.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pChart.php b/src/pChart.php index 309ee5d..5b3f456 100644 --- a/src/pChart.php +++ b/src/pChart.php @@ -4468,7 +4468,7 @@ function validateData($FunctionName, &$Data) */ function printErrors($Mode = "CLI") { - if (count($this->Errors) == 0) + if (!is_array($this->Errors)) return 0; if ($Mode == "CLI") { From 1620d9668203ea86c5dd60678fa944576e2ef8e0 Mon Sep 17 00:00:00 2001 From: milkyway Date: Sun, 29 Jul 2018 09:45:37 +0200 Subject: [PATCH 4/4] replaced deprecated function split --- src/pChart.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pChart.php b/src/pChart.php index 5b3f456..78072df 100644 --- a/src/pChart.php +++ b/src/pChart.php @@ -352,7 +352,7 @@ function loadColorPalette($FileName, $Delimiter = ",") $buffer = fgets($handle, 4096); $buffer = str_replace(chr(10), "", $buffer); $buffer = str_replace(chr(13), "", $buffer); - $Values = split($Delimiter, $buffer); + $Values = explode($Delimiter, $buffer); if (count($Values) == 3) { $this->Palette[$ColorID]["R"] = $Values[0]; $this->Palette[$ColorID]["G"] = $Values[1]; @@ -4542,7 +4542,7 @@ function getImageMap($MapName, $Flush = TRUE) { /* Strip HTML query strings */ $Values = $this->tmpFolder . $MapName; - $Value = split("\?", $Values); + $Value = explode('?', $Values); $FileName = $Value[0]; if (file_exists($FileName)) {