1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +02:00

PHP 8.1 fixes.

This commit is contained in:
Cameron
2021-11-25 10:18:53 -08:00
parent 98b8955185
commit 9d6a9611e2
17 changed files with 110 additions and 88 deletions

View File

@@ -325,6 +325,7 @@ class admin_log_ui extends e_admin_ui
$log = e107::getLog();
$frm = e107::getForm();
$sql = e107::getDb();
$tp = e107::getParser();
$back_count = 0;
$action = '';
@@ -371,7 +372,7 @@ class admin_log_ui extends e_admin_ui
if(($action == "backdel") && isset($_POST['backdeltype']))
{
// $old_date = intval($qs[1]);
$old_string = strftime("%d %B %Y", $old_date);
$old_string = $tp->toDate($old_date, "%d %B %Y");
$qry = "dblog_datestamp < ".$old_date; // Same field for both logs
switch($_POST['backdeltype'])

View File

@@ -65,7 +65,7 @@ if (!empty($_POST['ban_types']))
}
}
$filename = 'banlist_'.strftime("%Y%m%d_%H%M%S").'.csv';
$filename = 'banlist_'.e107::getParser()->toDate(time(), "%Y%m%d_%H%M%S").'.csv';
if ($error_string = do_export($filename, $type_list, $format_array, $use_separator, $use_quote))
{
@@ -78,6 +78,7 @@ banlist_adminlog('06','File: '.$filename.'<br />'.$error_string);
function do_export($filename, $type_list='',$format_array=array(), $sep = ',', $quot = '"')
{
$sql = e107::getDb();
$tp = e107::getParser();
$export_text = '';
$qry = "SELECT * FROM `#banlist` ";
if ($type_list != '') $qry .= " WHERE`banlist_bantype` IN ({$type_list})";
@@ -98,7 +99,7 @@ function do_export($filename, $type_list='',$format_array=array(), $sep = ',', $
break;
case 'banlist_datestamp' :
case 'banlist_banexpires' :
if ($row[$f]) $line .= $spacer.$quot.strftime($v,$row[$f]).$quot; else $line .= $spacer.$quot.'0'.$quot;
if ($row[$f]) $line .= $spacer.$quot.$tp->toDate($row[$f], $v).$quot; else $line .= $spacer.$quot.'0'.$quot;
break;
}
$spacer = $sep;

View File

@@ -542,9 +542,9 @@ class cron_admin_form_ui extends e_admin_form_ui
$text .= "<br />";
$text .= ($day != '*') ? LAN_CRON_52 ." ". $day : LAN_CRON_40; // Day(s)
$text .= "<br />";
$text .= ($month != '*') ? LAN_CRON_53 ." ". strftime("%B", mktime(00, 00, 00, (int) $month, 1, 2000)) : LAN_CRON_41; // Month(s)
$text .= ($month != '*') ? LAN_CRON_53 ." ". eShims::strftime("%B", mktime(00, 00, 00, (int) $month, 1, 2000)) : LAN_CRON_41; // Month(s)
$text .= "<br />";
$text .= ($weekday != '*') ? LAN_CRON_54 ." ". strftime("%A", mktime(00, 00, 00, 5, (int) $weekday, 2000)) : LAN_CRON_42; // Weekday(s)
$text .= ($weekday != '*') ? LAN_CRON_54 ." ". eShims::strftime("%A", mktime(00, 00, 00, 5, (int) $weekday, 2000)) : LAN_CRON_42; // Weekday(s)
return "<a class='e-tip' href=''>".ADMIN_INFO_ICON."</a>
@@ -711,7 +711,7 @@ class cron_admin_form_ui extends e_admin_form_ui
{
$sel = (in_array($i, $month)) ? "selected='selected'" : "";
$diz = mktime(00, 00, 00, $i, 1, 2000);
$text .= "<option value='$i' $sel>".strftime("%B", $diz)."</option>\n";
$text .= "<option value='$i' $sel>".eShims::strftime("%B", $diz)."</option>\n";
}
$text .= "</select>
@@ -724,7 +724,7 @@ class cron_admin_form_ui extends e_admin_form_ui
for ($i = 0; $i <= 6; $i++)
{
$sel = (in_array(strval($i), $weekday)) ? "selected='selected'" : "";
$text .= "<option value='$i' $sel>".strftime("%A", mktime(00, 00, 00, 5, $i, 2000))."</option>\n";
$text .= "<option value='$i' $sel>".eShims::strftime("%A", mktime(00, 00, 00, 5, $i, 2000))."</option>\n";
}
$text .= "</select>
";

View File

@@ -785,53 +785,9 @@ $text .= "
$def = strtotime('December 21, 2012 3:45pm');
$inputdate = array( // TODO add more formats
"%A, %d %B, %Y" => strftime("%A, %d %B, %Y",$def),
"%A, %d %b, %Y" => strftime("%A, %d %b, %Y",$def),
"%a, %d %B, %Y" => strftime("%a, %d %B, %Y",$def),
"%a, %d %b, %Y" => strftime("%a, %d %b, %Y",$def),
"%A, %B %d, %Y" => strftime("%A, %B %d, %Y",$def),
"%A, %b %d, %Y" => strftime("%A, %b %d, %Y",$def),
"%A, %b %d, %y" => strftime("%A, %b %d, %y",$def),
"%B %d, %Y" => strftime("%B %d, %Y",$def),
"%b %d, %Y" => strftime("%b %d, %Y",$def),
"%b %d, %y" => strftime("%b %d, %y",$def),
"%d %B, %Y" => strftime("%d %B, %Y",$def),
"%d %b, %Y" => strftime("%d %b, %Y",$def),
"%d %b, %y" => strftime("%d %b, %y",$def),
"%Y-%m-%d" => strftime("%Y-%m-%d",$def),
"%d-%m-%Y" => strftime("%d-%m-%Y",$def),
"%m/%d/%Y" => strftime("%m/%d/%Y",$def)
);
$inputtime = array();
$inputtime["%I:%M %p"] = strftime("%I:%M %p",$def);
if(e107::getDate()->supported('P'))
{
$inputtime["%I:%M %P"] = strftime("%I:%M %P",$def);
}
if(e107::getDate()->supported('l'))
{
$inputtime["%l:%M %p"] = strftime("%l:%M %p",$def);
$inputtime["%l:%M %P"] = strftime("%l:%M %P",$def);
}
$inputtime["%H:%M"] = strftime("%H:%M",$def);
$inputtime["%H:%M:%S"] = strftime("%H:%M:%S",$def);
$inputdate = e107::getDate()->dateFormats($def);
$inputtime = e107::getDate()->timeFormats($def);
$text .= "
<tr>

View File

@@ -1305,7 +1305,7 @@ class admin_shortcodes extends e_shortcode
<br /><br />
<b>' .FOOTLAN_19. '</b>
<br />
' .strftime('%A %d %B %Y - %H:%M').
' .eShims::strftime('%A %d %B %Y - %H:%M').
'<br />';
return e107::getRender()->tablerender(FOOTLAN_13, $text, '', TRUE);

View File

@@ -80,10 +80,10 @@ trait StrptimeTrait
for ($i = 1; $i <= 12; $i++)
{
$k = strftime('%B', mktime(0, 0, 0, $i));
$k = @strftime('%B', mktime(0, 0, 0, $i));
$fullmonth[$k] = $i;
$j = strftime('%b', mktime(0, 0, 0, $i));
$j = @strftime('%b', mktime(0, 0, 0, $i));
$abrevmonth[$j] = $i;
}

View File

@@ -391,7 +391,7 @@ class CronParser
function getLastRan()
{
return explode(",", strftime("%M,%H,%d,%m,%w,%Y", $this->lastRan)); //Get the values for now in a format we can use
return explode(",", eShims::strftime("%M,%H,%d,%m,%w,%Y", $this->lastRan)); //Get the values for now in a format we can use
}
function getLastRanUnix()
@@ -505,7 +505,7 @@ class CronParser
}
//put the current time into an array
$t = strftime("%M,%H,%d,%m,%w,%Y", time());
$t = eShims::strftime("%M,%H,%d,%m,%w,%Y", time());
$this->now = explode(",", $t);
$this->year = $this->now[5];

View File

@@ -37,17 +37,17 @@ class e_date
for ($i=1; $i < 8; $i++)
{
$day = strftime('%A', mktime(1, 1, 1, 1, $i, 2012));
$day = eShims::strftime('%A', mktime(1, 1, 1, 1, $i, 2012));
$dates['days'][] = $day;
$dates['daysShort'][] = strftime('%a', mktime(1, 1, 1, 1, $i, 2012));
$dates['daysShort'][] = eShims::strftime('%a', mktime(1, 1, 1, 1, $i, 2012));
$dates['daysMin'][] = substr($day, 0, 2);
}
for ($i=1; $i < 13; $i++)
{
$dates['months'][] = strftime('%B', mktime(1, 1, 1, $i, 2, 2013));
$dates['monthsShort'][] = strftime('%h', mktime(1, 1, 1, $i, 2, 2013));
$dates['months'][] = eShims::strftime('%B', mktime(1, 1, 1, $i, 2, 2013));
$dates['monthsShort'][] = eShims::strftime('%h', mktime(1, 1, 1, $i, 2, 2013));
}
@@ -88,7 +88,7 @@ class e_date
$marray = array();
for ($i = 1; $i < 13; $i++)
{
$marray[$i] = strftime($val, mktime(1, 1, 1, $i, 1, 2000));
$marray[$i] = eShims::strftime($val, mktime(1, 1, 1, $i, 1, 2000));
}
return $marray;
@@ -102,15 +102,15 @@ class e_date
switch ($type)
{
case 'day-shortest': // eg. 'Tu'
$days[] = substr(strftime('%a', mktime(1, 1, 1, 6, $i, 2014)), 0, 2);
$days[] = substr(eShims::strftime('%a', mktime(1, 1, 1, 6, $i, 2014)), 0, 2);
break;
case 'day-short': // eg. 'Tue'
$days[] = strftime('%a', mktime(1, 1, 1, 6, $i, 2014));
$days[] = eShims::strftime('%a', mktime(1, 1, 1, 6, $i, 2014));
break;
default: // eg. 'Tuesday'
$days[] = strftime('%A', mktime(1, 1, 1, 6, $i, 2014));
$days[] = eShims::strftime('%A', mktime(1, 1, 1, 6, $i, 2014));
break;
}
}
@@ -196,7 +196,7 @@ class e_date
break;
}
$dateString = strftime($mask, $datestamp);
$dateString = eShims::strftime($mask, $datestamp);
if (!e107::getParser()->isUTF8($dateString))
{
@@ -788,8 +788,8 @@ class e_date
trigger_error('<b>' . __METHOD__ . ' is deprecated.</b> Use eShims::strptime() instead', E_USER_DEPRECATED); // NO LAN
$vals = eShims::strptime($str, $format); // PHP5 is more accurate than below.
$vals['tm_amon'] = strftime('%b', mktime(0, 0, 0, $vals['tm_mon'] + 1));
$vals['tm_fmon'] = strftime('%B', mktime(0, 0, 0, $vals['tm_mon'] + 1));
$vals['tm_amon'] = eShims::strftime('%b', mktime(0, 0, 0, $vals['tm_mon'] + 1));
$vals['tm_fmon'] = eShims::strftime('%B', mktime(0, 0, 0, $vals['tm_mon'] + 1));
return $vals;
}
@@ -869,7 +869,7 @@ class e_date
// Evaluate the formats whilst suppressing any errors.
foreach($strftimeFormats as $format => $description)
{
$strftimeValues[$format] = strftime("%{$format}");
$strftimeValues[$format] = eShims::strftime("%{$format}");
}
// Find the longest value.
@@ -910,7 +910,71 @@ class e_date
return in_array($timezone, timezone_identifiers_list());
}
public function dateFormats($datestamp = null)
{
if(empty($datestamp))
{
$datestamp = time();
}
$formats = array(
"%A, %d %B, %Y",
"%A, %d %b, %Y",
"%a, %d %B, %Y",
"%a, %d %b, %Y",
"%A, %B %d, %Y",
"%A, %b %d, %Y",
"%A, %b %d, %y",
"%B %d, %Y",
"%b %d, %Y",
"%b %d, %y",
"%d %B, %Y",
"%d %b, %Y",
"%d %b, %y",
"%Y-%m-%d",
"%d-%m-%Y",
"%m/%d/%Y"
);
$ret = [];
foreach($formats as $f)
{
$ret[$f] = eShims::strftime($f,$datestamp);
}
return $ret;
}
function timeFormats($datestamp=null)
{
if(empty($datestamp))
{
$datestamp = time();
}
$inputtime = array();
$inputtime["%I:%M %p"] = eShims::strftime("%I:%M %p",$datestamp);
if(e107::getDate()->supported('P'))
{
$inputtime["%I:%M %P"] = eShims::strftime("%I:%M %P",$datestamp);
}
if(e107::getDate()->supported('l'))
{
$inputtime["%l:%M %p"] = eShims::strftime("%l:%M %p",$datestamp);
$inputtime["%l:%M %P"] = eShims::strftime("%l:%M %P",$datestamp);
}
$inputtime["%H:%M"] = eShims::strftime("%H:%M",$datestamp);
$inputtime["%H:%M:%S"] = eShims::strftime("%H:%M:%S",$datestamp);
return $inputtime;
}
}

View File

@@ -229,7 +229,7 @@
{
$ret = array();
$invert = false;
if(strpos($fmask, '~') === 0)
if(!empty($fmask) && strpos($fmask, '~') === 0)
{
$invert = true; // Invert selection - exclude files which match selection
$fmask = substr($fmask, 1);

View File

@@ -1452,7 +1452,7 @@ class banlistManager
private function dateFormat($date)
{
if ($date == 0) return '0';
return strftime('%Y%m%d_%H%M%S',$date);
return eShims::strftime('%Y%m%d_%H%M%S',$date);
}

View File

@@ -632,7 +632,7 @@ class e_news_item extends e_front_model
$params = array($val); //value is always the first callback argument
$params = array_merge($params, explode(',', $parm['arg']));
//should be done with date handler (awaiting for modifications)
return strftime(varset($parm['arg'], e107::getPref('shortdate')), $val);
return eShims::strftime(varset($parm['arg'], e107::getPref('shortdate')), $val);
break;
default:

View File

@@ -34,14 +34,14 @@ if (!function_exists('strptime'))
}
}
/*
if (!function_exists('strftime'))
{
function strftime($format, $timestamp)
{
return eShims::strftime($format, $timestamp);
}
}
}*/
// Fix for exim missing.

View File

@@ -34,7 +34,7 @@ if(e_QUERY)
{
$query_string = intval(e_QUERY);
$row = $sql->retrieve("banner", "*", "banner_id = '{$query_string}'"); // select the banner
$ip = e107::getIPHandler()->getIP(FALSE);
$ip = e107::getIPHandler()->getIP();
$newip = (strpos($row['banner_ip'], "{$ip}^") !== FALSE) ? $row['banner_ip'] : "{$row['banner_ip']}{$ip}^"; // what does this do?
$sql->update("banner", "banner_clicks = banner_clicks + 1, `banner_ip` = '{$newip}' WHERE `banner_id` = '{$query_string}'");
// header("Location: {$row['banner_clickurl']}");
@@ -96,16 +96,16 @@ if (isset($_POST['clientsubmit']))
{
while ($row = $sql->fetch())
{
$start_date = ($row['banner_startdate'] ? strftime("%d %B %Y", $row['banner_startdate']) : BANNERLAN_31);
$end_date = ($row['banner_enddate'] ? strftime("%d %B %Y", $row['banner_enddate']) : BANNERLAN_31);
$start_date = ($row['banner_startdate'] ? $tp->toDate($row['banner_startdate'], "%d %B %Y") : BANNERLAN_31);
$end_date = ($row['banner_enddate'] ? $tp->toDate($row['banner_enddate'], "%d %B %Y") : BANNERLAN_31);
$scArray = array();
$scArray['BANNER_TABLE_CLICKPERCENTAGE'] = ($row['banner_clicks'] && $row['banner_impressions'] ? round(($row['banner_clicks'] / $row['banner_impressions']) * 100)."%" : "-");
$scArray['BANNER_TABLE_IMPRESSIONS_LEFT'] = ($row['banner_impurchased'] ? $row['banner_impurchased'] - $row['banner_impressions'] : BANNERLAN_30);
$scArray['BANNER_TABLE_IMPRESSIONS_PURCHASED'] = ($row['banner_impurchased'] ? $row['banner_impurchased'] : BANNERLAN_30);
$scArray['BANNER_TABLE_IMPRESSIONS_PURCHASED'] = ($row['banner_impurchased'] ? $row['banner_impurchased'] : BANNERLAN_30);
$scArray['BANNER_TABLE_CLIENTNAME'] = $row['banner_clientname'];
$scArray['BANNER_TABLE_BANNER_ID'] = $row['banner_id'];
$scArray['BANNER_TABLE_BANNER_CLICKS'] = $row['banner_clicks'];
$scArray['BANNER_TABLE_BANNER_ID'] = $row['banner_id'];
$scArray['BANNER_TABLE_BANNER_CLICKS'] = $row['banner_clicks'];
$scArray['BANNER_TABLE_BANNER_IMPRESSIONS'] = $row['banner_impressions'];
$scArray['BANNER_TABLE_ACTIVE'] = LAN_VISIBILITY." ".($row['banner_active'] != "255" ? LAN_YES : "<b>".LAN_NO."</b>");
$scArray['BANNER_TABLE_STARTDATE'] = LAN_START." ".$start_date;

View File

@@ -140,7 +140,7 @@ class downloadCategory
{
$text = "<tr><td>".$cat['download_category_id']."</td><td>".$cat['download_category_parent']."</td><td>";
$text .= $prefix.htmlspecialchars($cat['download_category_name']).$postfix."</td><td>".$cat['d_size']."</td>";
$text .= "<td>".$cat['d_count']."</td><td>".$cat['d_requests']."</td><td>".strftime('%H:%M %d-%m-%Y',$cat['d_last'])."</td>";
$text .= "<td>".$cat['d_count']."</td><td>".$cat['d_requests']."</td><td>".eShims::strftime('%H:%M %d-%m-%Y',$cat['d_last'])."</td>";
$text .= "</tr>";
return $text;
}

View File

@@ -727,14 +727,14 @@ class listclass
if($thisday == $current_day)
{
$datepreftoday = $this->list_pref[$this->mode."_datestyletoday"];
return strftime($datepreftoday, $datestamp);
return eShims::strftime($datepreftoday, $datestamp);
}
}
}
//else use default date style
$datepref = $this->list_pref[$this->mode."_datestyle"];
return strftime($datepref, $datestamp);
return eShims::strftime($datepref, $datestamp);
}
/**

View File

@@ -1889,10 +1889,10 @@ class news_front
// render new date header if pref selected ...
$thispostday = strftime("%j", $news['news_datestamp']);
$thispostday = eShims::strftime("%j", $news['news_datestamp']);
if ($newpostday != $thispostday && (isset($this->pref['news_newdateheader']) && $this->pref['news_newdateheader']))
{
echo "<div class='".DATEHEADERCLASS."'>".strftime("%A %d %B %Y", $news['news_datestamp'])."</div>";
echo "<div class='".DATEHEADERCLASS."'>".eShims::strftime("%A %d %B %Y", $news['news_datestamp'])."</div>";
}
$newpostday = $thispostday;
$news['category_id'] = $news['news_category'];

View File

@@ -264,7 +264,7 @@ class compareImages
break;
case "png":
return imagecreatefrompng($i);
return @imagecreatefrompng($i);
break;
case "gif":