diff --git a/e107_admin/admin_log.php b/e107_admin/admin_log.php
index 05de1d5cc..02ab537ff 100644
--- a/e107_admin/admin_log.php
+++ b/e107_admin/admin_log.php
@@ -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'])
diff --git a/e107_admin/banlist_export.php b/e107_admin/banlist_export.php
index bdaf00fdb..c9d1acc98 100644
--- a/e107_admin/banlist_export.php
+++ b/e107_admin/banlist_export.php
@@ -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.'
'.$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;
diff --git a/e107_admin/cron.php b/e107_admin/cron.php
index b59565856..e39dfa9df 100644
--- a/e107_admin/cron.php
+++ b/e107_admin/cron.php
@@ -542,9 +542,9 @@ class cron_admin_form_ui extends e_admin_form_ui
$text .= "
";
$text .= ($day != '*') ? LAN_CRON_52 ." ". $day : LAN_CRON_40; // Day(s)
$text .= "
";
- $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 .= "
";
- $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 "".ADMIN_INFO_ICON."
@@ -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 .= "\n";
+ $text .= "\n";
}
$text .= "
@@ -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 .= "\n";
+ $text .= "\n";
}
$text .= "
";
diff --git a/e107_admin/prefs.php b/e107_admin/prefs.php
index d79bd2443..34cb2cda9 100644
--- a/e107_admin/prefs.php
+++ b/e107_admin/prefs.php
@@ -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 .= "
diff --git a/e107_core/shortcodes/batch/admin_shortcodes.php b/e107_core/shortcodes/batch/admin_shortcodes.php
index 7d7084e2d..01a7721aa 100644
--- a/e107_core/shortcodes/batch/admin_shortcodes.php
+++ b/e107_core/shortcodes/batch/admin_shortcodes.php
@@ -1305,7 +1305,7 @@ class admin_shortcodes extends e_shortcode
' .FOOTLAN_19. '
- ' .strftime('%A %d %B %Y - %H:%M').
+ ' .eShims::strftime('%A %d %B %Y - %H:%M').
'
';
return e107::getRender()->tablerender(FOOTLAN_13, $text, '', TRUE);
diff --git a/e107_handlers/Shims/Internal/StrptimeTrait.php b/e107_handlers/Shims/Internal/StrptimeTrait.php
index 099fb4baa..78b2a97b5 100644
--- a/e107_handlers/Shims/Internal/StrptimeTrait.php
+++ b/e107_handlers/Shims/Internal/StrptimeTrait.php
@@ -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;
}
diff --git a/e107_handlers/cron_class.php b/e107_handlers/cron_class.php
index 26d4c3297..415b6e243 100644
--- a/e107_handlers/cron_class.php
+++ b/e107_handlers/cron_class.php
@@ -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];
diff --git a/e107_handlers/date_handler.php b/e107_handlers/date_handler.php
index 8ccd73c50..6100bf84a 100644
--- a/e107_handlers/date_handler.php
+++ b/e107_handlers/date_handler.php
@@ -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('' . __METHOD__ . ' is deprecated. 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;
+ }
}
diff --git a/e107_handlers/file_class.php b/e107_handlers/file_class.php
index 195ace931..53e40b2d1 100644
--- a/e107_handlers/file_class.php
+++ b/e107_handlers/file_class.php
@@ -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);
diff --git a/e107_handlers/iphandler_class.php b/e107_handlers/iphandler_class.php
index a1e00bee9..d60ce0685 100644
--- a/e107_handlers/iphandler_class.php
+++ b/e107_handlers/iphandler_class.php
@@ -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);
}
diff --git a/e107_handlers/news_class.php b/e107_handlers/news_class.php
index 435e59947..4bf9a8cba 100644
--- a/e107_handlers/news_class.php
+++ b/e107_handlers/news_class.php
@@ -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:
diff --git a/e107_handlers/php_compatibility_handler.php b/e107_handlers/php_compatibility_handler.php
index f39becc4d..26d5da817 100644
--- a/e107_handlers/php_compatibility_handler.php
+++ b/e107_handlers/php_compatibility_handler.php
@@ -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.
diff --git a/e107_plugins/banner/banner.php b/e107_plugins/banner/banner.php
index 1a57a832d..825c878cd 100644
--- a/e107_plugins/banner/banner.php
+++ b/e107_plugins/banner/banner.php
@@ -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 : "".LAN_NO."");
$scArray['BANNER_TABLE_STARTDATE'] = LAN_START." ".$start_date;
diff --git a/e107_plugins/download/handlers/category_class.php b/e107_plugins/download/handlers/category_class.php
index 638add31a..3eed067bd 100644
--- a/e107_plugins/download/handlers/category_class.php
+++ b/e107_plugins/download/handlers/category_class.php
@@ -140,7 +140,7 @@ class downloadCategory
{
$text = "
".$cat['download_category_id']." | ".$cat['download_category_parent']." | ";
$text .= $prefix.htmlspecialchars($cat['download_category_name']).$postfix." | ".$cat['d_size']." | ";
- $text .= "".$cat['d_count']." | ".$cat['d_requests']." | ".strftime('%H:%M %d-%m-%Y',$cat['d_last'])." | ";
+ $text .= "".$cat['d_count']." | ".$cat['d_requests']." | ".eShims::strftime('%H:%M %d-%m-%Y',$cat['d_last'])." | ";
$text .= "
";
return $text;
}
diff --git a/e107_plugins/list_new/list_class.php b/e107_plugins/list_new/list_class.php
index f3d2263e6..fef1fdb79 100644
--- a/e107_plugins/list_new/list_class.php
+++ b/e107_plugins/list_new/list_class.php
@@ -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);
}
/**
diff --git a/e107_plugins/news/news.php b/e107_plugins/news/news.php
index 0559e0678..c7ec9695d 100644
--- a/e107_plugins/news/news.php
+++ b/e107_plugins/news/news.php
@@ -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 "";
+ echo "";
}
$newpostday = $thispostday;
$news['category_id'] = $news['news_category'];
diff --git a/e107_tests/tests/unit/e_thumbnailTest.php b/e107_tests/tests/unit/e_thumbnailTest.php
index 8129f9ae2..18470bdab 100644
--- a/e107_tests/tests/unit/e_thumbnailTest.php
+++ b/e107_tests/tests/unit/e_thumbnailTest.php
@@ -264,7 +264,7 @@ class compareImages
break;
case "png":
- return imagecreatefrompng($i);
+ return @imagecreatefrompng($i);
break;
case "gif":