リビジョン | 6b278364164af06f7cee52bfe5f97a8a5f7544c9 (tree) |
---|---|
日時 | 2017-02-17 00:09:23 |
作者 | umorigu <umorigu@gmai...> |
コミッター | umorigu |
BugTrack/2414 strtotime return false on parsing failure in PHP5.1+
http://php.net/manual/en/function.strtotime.php
Returns a timestamp on success, FALSE otherwise. Previous to PHP 5.1.0,
this function would return -1 on failure.
@@ -1,7 +1,7 @@ | ||
1 | 1 | <?php |
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone |
3 | -// $Id: calendar_viewer.inc.php,v 1.37 2011/01/25 15:01:01 henoheno Exp $ | |
4 | -// Copyright (C) 2002-2005, 2007 PukiWiki Developers Team | |
3 | +// calendar_viewer.inc.php | |
4 | +// Copyright 2002-2017 PukiWiki Development Team | |
5 | 5 | // License: GPL v2 or (at your option) any later version |
6 | 6 | // |
7 | 7 | // Calendar viewer plugin - List pages that calendar/calnedar2 plugin created |
@@ -177,7 +177,7 @@ function plugin_calendar_viewer_convert() | ||
177 | 177 | |
178 | 178 | if (PLUGIN_CALENDAR_VIEWER_DATE_FORMAT !== FALSE) { |
179 | 179 | $time = strtotime(basename($page)); // $date_sep must be assumed '-' or ''! |
180 | - if ($time == -1) { | |
180 | + if ($time === FALSE || $time === -1) { | |
181 | 181 | $s_page = htmlsc($page); // Failed. Why? |
182 | 182 | } else { |
183 | 183 | $week = $weeklabels[date('w', $time)]; |
@@ -330,4 +330,3 @@ function plugin_calendar_viewer_isValidDate($aStr, $aSepList = '-/ .') | ||
330 | 330 | return FALSE; |
331 | 331 | } |
332 | 332 | } |
333 | - |
@@ -1,6 +1,8 @@ | ||
1 | 1 | <?php |
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone. |
3 | -// $Id: new.inc.php,v 1.10 2011/01/25 15:01:01 henoheno Exp $ | |
3 | +// new.inc.php | |
4 | +// Copyright 2003-2017 PukiWiki Development Team | |
5 | +// License: GPL v2 or (at your option) any later version | |
4 | 6 | // |
5 | 7 | // New! plugin |
6 | 8 | // |
@@ -2,7 +2,7 @@ | ||
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone |
3 | 3 | // showrss.inc.php |
4 | 4 | // Copyright: |
5 | -// 2002-2016 PukiWiki Development Team | |
5 | +// 2002-2017 PukiWiki Development Team | |
6 | 6 | // 2002 PANDA <panda@arino.jp> |
7 | 7 | // (Original)hiro_do3ob@yahoo.co.jp |
8 | 8 | // License: GPL, same as PukiWiki |
@@ -282,14 +282,17 @@ class ShowRSS_XML | ||
282 | 282 | |
283 | 283 | } else if (isset($item['PUBDATE'])) { |
284 | 284 | $time = plugin_showrss_get_timestamp($item['PUBDATE']); |
285 | - | |
286 | - } else if (isset($item['DESCRIPTION']) && | |
287 | - ($description = trim($item['DESCRIPTION'])) != '' && | |
288 | - ($time = strtotime($description)) != -1) { | |
289 | - $time -= LOCALZONE; | |
290 | - | |
291 | 285 | } else { |
292 | - $time = time() - LOCALZONE; | |
286 | + $time_from_desc = FALSE; | |
287 | + if (isset($item['DESCRIPTION']) && | |
288 | + (($description = trim($item['DESCRIPTION'])) != '')) { | |
289 | + $time_from_desc = strtotime($description); | |
290 | + } | |
291 | + if ($time_from_desc !== FALSE && $time_from_desc !== -1) { | |
292 | + $time = $time_from_desc - LOCALZONE; | |
293 | + } else { | |
294 | + $time = time() - LOCALZONE; | |
295 | + } | |
293 | 296 | } |
294 | 297 | $item['_TIMESTAMP'] = $time; |
295 | 298 | $date = get_date('Y-m-d', $item['_TIMESTAMP']); |
@@ -314,7 +317,7 @@ function plugin_showrss_get_timestamp($str) | ||
314 | 317 | $matches = array(); |
315 | 318 | if (preg_match('/(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})(([+-])(\d{2}):(\d{2}))?/', $str, $matches)) { |
316 | 319 | $time = strtotime($matches[1] . ' ' . $matches[2]); |
317 | - if ($time == -1) { | |
320 | + if ($time === FALSE || $time === -1) { | |
318 | 321 | $time = UTIME; |
319 | 322 | } else if ($matches[3]) { |
320 | 323 | $diff = ($matches[5] * 60 + $matches[6]) * 60; |
@@ -323,6 +326,6 @@ function plugin_showrss_get_timestamp($str) | ||
323 | 326 | return $time; |
324 | 327 | } else { |
325 | 328 | $time = strtotime($str); |
326 | - return ($time == -1) ? UTIME : $time - LOCALZONE; | |
329 | + return ($time === FALSE || $time === -1) ? UTIME : $time - LOCALZONE; | |
327 | 330 | } |
328 | 331 | } |