Merge pull request #87 from alorbach/pr-issue-75

Fix issues for PHP8 and PHP8.1 compatibility
This commit is contained in:
Andre Lorbach 2022-10-19 13:05:05 +02:00 committed by GitHub
commit c9f54208f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 65 additions and 47 deletions

View File

@ -118,7 +118,7 @@ if ( isset($_GET['op']) )
" WHERE " . DB_GROUPMEMBERS . ".groupid = " . $content['GROUPID'];
$result = DB_Query($sqlquery);
$tmparray = DB_GetAllRows($result, true);
if ( count($tmparray) > 0 )
if ( isset($tmparray) && count($tmparray) > 0 )
{
// Add UserID's to where clause!
foreach ($tmparray as $datarow)
@ -449,7 +449,7 @@ if ( !isset($_POST['op']) && !isset($_GET['op']) )
$result = DB_Query($sqlquery);
$content['GROUPS'] = DB_GetAllRows($result, true);
if ( count($content['GROUPS']) > 0 )
if ( isset($content['GROUPS']) && count($content['GROUPS']) > 0 )
{
// --- Process Groups
for($i = 0; $i < count($content['GROUPS']); $i++)
@ -476,7 +476,7 @@ if ( !isset($_POST['op']) && !isset($_GET['op']) )
$result = DB_Query($sqlquery);
$content['GROUPS'][$i]['USERS'] = DB_GetAllRows($result, true);
if ( count($content['GROUPS'][$i]['USERS']) > 0 )
if ( isset($content['GROUPS'][$i]['USERS']) && count($content['GROUPS'][$i]['USERS']) > 0 )
{
// Enable Groupmembers
$content['GROUPS'][$i]['GROUPMEMBERS'] = true;

View File

@ -1,7 +1,7 @@
README FOR JPGRAPH 4.3.1
README FOR JPGRAPH 4.4.1
=========================
This package contains the JpGraph PHP library version 4.3.1
This package contains the JpGraph PHP library version 4.4.1
The library is Copyright (C) 2000-2010 Asial Corporatoin and
released under dual license QPL 1.0 for open source and educational

View File

@ -126,7 +126,7 @@ class Image {
}
$this->img = @imagecreatetruecolor($aWidth, $aHeight);
if( $this->img < 1 ) {
if( !$this->img ) {
JpGraphError::RaiseL(25126);
//die("Can't create truecolor image. Check that you really have GD2 library installed.");
}
@ -188,7 +188,7 @@ class Image {
else {
$f = 'imagecopyresampled';
}
$f($aToHdl,$aFromHdl,$aToX,$aToY,$aFromX,$aFromY, $aWidth,$aHeight,$aw,$ah);
$f($aToHdl,$aFromHdl,(int)$aToX,(int)$aToY,(int)$aFromX,(int)$aFromY, (int)$aWidth,(int)$aHeight,(int)$aw,(int)$ah);
}
function Copy($fromImg,$toX,$toY,$fromX,$fromY,$toWidth,$toHeight,$fromWidth=-1,$fromHeight=-1) {
@ -285,7 +285,7 @@ class Image {
// Get the specific height for a text string
function GetTextHeight($txt="",$angle=0) {
$tmp = preg_split('/\n/',$txt);
$tmp = preg_split('/\n/',$txt ?: '');
$n = count($tmp);
$m=0;
for($i=0; $i< $n; ++$i) {
@ -333,7 +333,7 @@ class Image {
// etxt width.
function GetTextWidth($txt,$angle=0) {
$tmp = preg_split('/\n/',$txt);
$tmp = preg_split('/\n/',$txt ?: '');
$n = count($tmp);
if( $this->font_family <= FF_FONT2+1 ) {
@ -648,7 +648,7 @@ class Image {
$use_font = $this->font_family;
if( $dir==90 ) {
imagestringup($this->img,$use_font,$x,$y,$txt,$this->current_color);
imagestringup($this->img,$use_font,(int)$x,(int)$y,$txt,$this->current_color);
$aBoundingBox = array(round($x),round($y),round($x),round($y-$w),round($x+$h),round($y-$w),round($x+$h),round($y));
if( $aDebug ) {
// Draw bounding box
@ -658,7 +658,7 @@ class Image {
}
}
else {
if( preg_match('/\n/',$txt) ) {
if( preg_match('/\n/',$txt ?: '') ) {
$tmp = preg_split('/\n/',$txt);
for($i=0; $i < count($tmp); ++$i) {
$w1 = $this->GetTextWidth($tmp[$i]);
@ -675,7 +675,7 @@ class Image {
}
else {
//Put the text
imagestring($this->img,$use_font,$x,$y-$h+1,$txt,$this->current_color);
imagestring($this->img,$use_font,(int)$x,(int)($y-$h+1),$txt ?: '',$this->current_color);
}
if( $aDebug ) {
// Draw the bounding rectangle and the bounding box
@ -931,7 +931,7 @@ class Image {
// Do nothing the text is drawn at baseline by default
}
}
ImageTTFText ($this->img, $this->font_size, $dir, $x, $y,
ImageTTFText ($this->img, $this->font_size, $dir, (int)$x, (int)$y,
$this->current_color,$this->font_file,$txt);
// Calculate and return the co-ordinates for the bounding box
@ -1038,7 +1038,7 @@ class Image {
$xl -= $bbox[0]/2;
$yl = $y - $yadj;
//$xl = $xl- $xadj;
ImageTTFText($this->img, $this->font_size, $dir, $xl, $yl-($h-$fh)+$fh*$i,
ImageTTFText($this->img, $this->font_size, $dir, (int)$xl, (int)($yl-($h-$fh)+$fh*$i),
$this->current_color,$this->font_file,$tmp[$i]);
// echo "xl=$xl,".$tmp[$i]." <br>";
@ -1437,7 +1437,11 @@ class Image {
}
$old = $this->line_weight;
imagesetthickness($this->img,1);
imagefilledpolygon($this->img,$pts,count($pts)/2,$this->current_color);
if (CheckPHPVersion('8.1.0')) {
imagefilledpolygon($this->img,$pts,$this->current_color);
} else {
imagefilledpolygon($this->img,$pts,count($pts)/2,$this->current_color);
}
$this->line_weight = $old;
imagesetthickness($this->img,$old);
}
@ -1768,7 +1772,11 @@ class Image {
$p4y=ceil(($y1 - $dist_y));
$array=array($p1x,$p1y,$p2x,$p2y,$p3x,$p3y,$p4x,$p4y);
imagefilledpolygon ( $im, $array, (count($array)/2), $color );
if (CheckPHPVersion('8.1.0')) {
imagefilledpolygon ( $im, $array, $color );
} else {
imagefilledpolygon ( $im, $array, (count($array)/2), $color );
}
// for antialias
imageline($im, $p1x, $p1y, $p2x, $p2y, $color);
@ -1829,7 +1837,11 @@ class Image {
}
imagesetthickness($im, 1);
imagefilledpolygon($im, $pts,count($pts)/2, $color);
if (CheckPHPVersion('8.1.0')) {
imagefilledpolygon($im, $pts, $color);
} else {
imagefilledpolygon($im, $pts,count($pts)/2, $color);
}
$weight *= 2;

View File

@ -19,7 +19,7 @@ require_once('jpgraph_theme.inc.php');
require_once('gd_image.inc.php');
// Version info
define('JPG_VERSION','4.3.1');
define('JPG_VERSION','4.4.1');
// Minimum required PHP version
define('MIN_PHPVERSION','5.1.0');
@ -392,15 +392,15 @@ class DateLocale {
}
$this->iLocale = $aLocale;
for( $i = 0, $ofs = 0 - strftime('%w'); $i < 7; $i++, $ofs++ ) {
$day = strftime('%a', strtotime("$ofs day"));
for( $i = 0, $ofs = 0 - date('w'); $i < 7; $i++, $ofs++ ) {
$day = date('D', strtotime("$ofs day"));
$day[0] = strtoupper($day[0]);
$this->iDayAbb[$aLocale][]= $day[0];
$this->iShortDay[$aLocale][]= $day;
}
for($i=1; $i<=12; ++$i) {
list($short ,$full) = explode('|', strftime("%b|%B",strtotime("2001-$i-01")));
list($short ,$full) = explode('|', date("M|F",strtotime("2001-$i-01")));
$this->iShortMonth[$aLocale][] = ucfirst($short);
$this->iMonthName [$aLocale][] = ucfirst($full);
}
@ -3642,7 +3642,6 @@ class Grid {
// assumption offset==0 so we might end up drawing one
// to many gridlines
$i=0;
$x=$aTicksPos[$i];
while( $i<count($aTicksPos) && ($x=$aTicksPos[$i]) <= $limit ) {
if ( $aType == 'solid' ) $this->img->Line($x,$yl,$x,$yu);
elseif( $aType == 'dotted' ) $this->img->DashedLineForGrid($x,$yl,$x,$yu,1,6);
@ -4060,7 +4059,7 @@ class Axis extends AxisPrototype {
// that holds the labels set by the user. If the user hasn't
// specified any values we use whats in the automatically asigned
// labels in the maj_ticks_label
if( isset($this->ticks_label[$i*$m]) ) {
if( isset($this->ticks_label[$i *(int)$m]) ) {
$label=$this->ticks_label[$i*$m];
}
else {

View File

@ -406,10 +406,16 @@ class DateScale extends LinearScale {
// identical to LinearScale::AutoScale
if( $aStartTime == $aEndTime ) {
// Special case when we only have one data point.
// Create a small artifical intervall to do the autoscaling
// Create a small artificial interval to do the autoscaling
$aStartTime -= 10;
$aEndTime += 10;
}
if( abs($aEndTime - $aStartTime) <= 1 ) {
// Special case when we only have one second.
// Create a small artificial interval to do the autoscaling
$aStartTime -= 1;
$aEndTime += 1;
}
$done=false;
$i=0;
while( ! $done && $i < 5) {

View File

@ -2128,8 +2128,8 @@ class GanttScale {
}
// Get day in week for start and ending date (Sun==0)
$ds=strftime("%w",$this->iStartDate);
$de=strftime("%w",$this->iEndDate);
$ds=date("w",$this->iStartDate);
$de=date("w",$this->iEndDate);
// We want to start on iWeekStart day. But first we subtract a week
// if the startdate is "behind" the day the week start at.
@ -2278,17 +2278,17 @@ class GanttScale {
// Get day in month
function GetMonthDayNbr($aDate) {
return 0+strftime("%d",$aDate);
return 0+date("d",$aDate);
}
// Get day in year
function GetYearDayNbr($aDate) {
return 0+strftime("%j",$aDate);
return 0+date("z",$aDate);
}
// Get month number
function GetMonthNbr($aDate) {
return 0+strftime("%m",$aDate);
return 0+date("m",$aDate);
}
// Translate a date to screen coordinates (horizontal scale)
@ -2599,63 +2599,63 @@ class GanttScale {
$x+$daywidth,$yb-$this->day->iFrameWeight);
}
$mn = strftime('%m',$datestamp);
$mn = date('m',$datestamp);
if( $mn[0]=='0' )
$mn = $mn[1];
switch( $this->day->iStyle ) {
case DAYSTYLE_LONG:
// "Monday"
$txt = strftime('%A',$datestamp);
$txt = date('l',$datestamp);
break;
case DAYSTYLE_SHORT:
// "Mon"
$txt = strftime('%a',$datestamp);
$txt = date('D',$datestamp);
break;
case DAYSTYLE_SHORTDAYDATE1:
// "Mon 23/6"
$txt = strftime('%a %d/'.$mn,$datestamp);
$txt = date('D d/'.$mn,$datestamp);
break;
case DAYSTYLE_SHORTDAYDATE2:
// "Mon 23 Jun"
$txt = strftime('%a %d %b',$datestamp);
$txt = date('D d M',$datestamp);
break;
case DAYSTYLE_SHORTDAYDATE3:
// "Mon 23 Jun 2003"
$txt = strftime('%a %d %b %Y',$datestamp);
$txt = date('D d M Y',$datestamp);
break;
case DAYSTYLE_LONGDAYDATE1:
// "Monday 23 Jun"
$txt = strftime('%A %d %b',$datestamp);
$txt = date('l d M',$datestamp);
break;
case DAYSTYLE_LONGDAYDATE2:
// "Monday 23 Jun 2003"
$txt = strftime('%A %d %b %Y',$datestamp);
$txt = date('l d M Y',$datestamp);
break;
case DAYSTYLE_SHORTDATE1:
// "23/6"
$txt = strftime('%d/'.$mn,$datestamp);
$txt = date('d/'.$mn,$datestamp);
break;
case DAYSTYLE_SHORTDATE2:
// "23 Jun"
$txt = strftime('%d %b',$datestamp);
$txt = date('d M',$datestamp);
break;
case DAYSTYLE_SHORTDATE3:
// "Mon 23"
$txt = strftime('%a %d',$datestamp);
$txt = date('D d',$datestamp);
break;
case DAYSTYLE_SHORTDATE4:
// "23"
$txt = strftime('%d',$datestamp);
$txt = date('d',$datestamp);
break;
case DAYSTYLE_CUSTOM:
// Custom format
$txt = strftime($this->day->iLabelFormStr,$datestamp);
$txt = date($this->day->iLabelFormStr,$datestamp);
break;
case DAYSTYLE_ONELETTER:
default:
// "M"
$txt = strftime('%A',$datestamp);
$txt = date('l',$datestamp);
$txt = strtoupper($txt[0]);
break;
}
@ -2808,7 +2808,7 @@ class GanttScale {
$img->SetLineWeight($this->month->grid->iWeight);
$img->SetColor($this->month->iTextColor);
$year = 0+strftime("%Y",$this->iStartDate);
$year = 0+date("Y",$this->iStartDate);
$img->SetTextAlign("center");
if( $this->GetMonthNbr($this->iStartDate) == $this->GetMonthNbr($this->iEndDate)
&& $this->GetYear($this->iStartDate)==$this->GetYear($this->iEndDate) ) {
@ -3634,6 +3634,7 @@ class GanttVLine extends GanttPlotObject {
$this->iLine->SetColor($aColor);
$this->iLine->SetWeight($aWeight);
$this->iLine->SetStyle($aStyle);
$this->iLine->Show();
$this->iStart = $aDate;
$this->title = new TextPropertyBelow();
$this->title->Set($aTitle);

View File

@ -559,7 +559,7 @@ class RGB {
if( $aAlpha < 0 || $aAlpha > 1 ) {
JpGraphError::RaiseL(25080);//('Alpha parameter for color must be between 0.0 and 1.0');
}
return imagecolorresolvealpha($this->img, $r, $g, $b, round($aAlpha * 127));
return imagecolorresolvealpha($this->img, (int)$r, (int)$g, (int)$b, (int)round($aAlpha * 127));
}
// Try to convert an array with three valid numbers to the corresponding hex array

View File

@ -570,7 +570,7 @@ class WindrosePlot {
$this->iCircGridWeight = 1;
}
function _ThickCircle($aImg,$aXC,$aYC,$aRad,$aWeight=2,$aColor) {
function _ThickCircle($aImg,$aXC,$aYC,$aRad,$aWeight,$aColor) {
$aImg->SetColor($aColor);
$aRad *= 2 ;

View File

@ -624,7 +624,7 @@ function CheckAndSetRunMode()
*/
function RemoveMagicQuotes()
{
if (get_magic_quotes_gpc()) {
if(function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) {
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
while (list($key, $val) = each($process)) {
foreach ($val as $k => $v) {