Bug #835252
This commit is contained in:
@@ -5,6 +5,11 @@ phpMyAdmin - Changelog
|
|||||||
$Id$
|
$Id$
|
||||||
$Source$
|
$Source$
|
||||||
|
|
||||||
|
2003-11-04 Garvin Hicking <me@supergarv.de>
|
||||||
|
* libraries/transformations/text_plain__dateformat.inc.php3:
|
||||||
|
Bug #835252: Now allow more timestamps. Minor modification of a patch
|
||||||
|
submitted by anonymous poster. Thanks!
|
||||||
|
|
||||||
2003-11-03 Garvin Hicking <me@supergarv.de>
|
2003-11-03 Garvin Hicking <me@supergarv.de>
|
||||||
* Documentation.html, tbl_row_delete.php3,
|
* Documentation.html, tbl_row_delete.php3,
|
||||||
libraries/display_tbl.lib.php3:
|
libraries/display_tbl.lib.php3:
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* For instructions, read the libraries/transformations/README file.
|
* For instructions, read the libraries/transformations/README file.
|
||||||
*
|
*
|
||||||
* The string ENTER_FILENAME_HERE shall be substituted with the filename without the '.inc.php3'
|
* The string ENTER_FILENAME_HERE shall be substituted with the filename without the '.inc.php'
|
||||||
* extension. For further information regarding naming conventions see the README file.
|
* extension. For further information regarding naming conventions see the README file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ if (!defined('PMA_TRANSFORMATION_TEXT_PLAIN__DATEFORMAT')){
|
|||||||
|
|
||||||
function PMA_transformation_text_plain__dateformat($buffer, $options = array()) {
|
function PMA_transformation_text_plain__dateformat($buffer, $options = array()) {
|
||||||
// possibly use a global transform and feed it with special options:
|
// possibly use a global transform and feed it with special options:
|
||||||
// include('./libraries/transformations/global.inc.php3');
|
// include('./libraries/transformations/global.inc.php');
|
||||||
|
|
||||||
// further operations on $buffer using the $options[] array.
|
// further operations on $buffer using the $options[] array.
|
||||||
if (!isset($options[0]) || $options[0] == '') {
|
if (!isset($options[0]) || $options[0] == '') {
|
||||||
@@ -29,19 +29,43 @@ if (!defined('PMA_TRANSFORMATION_TEXT_PLAIN__DATEFORMAT')){
|
|||||||
}
|
}
|
||||||
|
|
||||||
$timestamp = -1;
|
$timestamp = -1;
|
||||||
if (strstr($buffer, ':')) {
|
|
||||||
$timestamp = strtotime($buffer);
|
// Detect TIMESTAMP(6 | 8 | 10 | 12 | 14), (2 | 4) not supported here.
|
||||||
} elseif (strlen($buffer) == 14 && eregi('^[0-9]*$', $buffer)) {
|
if (preg_match('/^(\d{2}){3,7}$/', $buffer)) {
|
||||||
$d = array();
|
|
||||||
$d['year'] = substr($buffer, 0, 4);
|
if (strlen($buffer) == 14 || strlen($buffer) == 8) {
|
||||||
$d['month'] = substr($buffer, 4, 2);
|
$offset = 4;
|
||||||
$d['day'] = substr($buffer, 6, 2);
|
} else {
|
||||||
$d['hour'] = substr($buffer, 8, 2);
|
$offset = 2;
|
||||||
$d['minute'] = substr($buffer, 10, 2);
|
|
||||||
$d['second'] = substr($buffer, 12, 2);
|
|
||||||
$timestamp = mktime($d['hour'], $d['minute'], $d['second'], $d['month'], $d['day'], $d['year']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$d = array();
|
||||||
|
$d['year'] = substr($buffer, 0, $offset);
|
||||||
|
$d['month'] = substr($buffer, $offset, 2);
|
||||||
|
$d['day'] = substr($buffer, $offset + 2, 2);
|
||||||
|
$d['hour'] = substr($buffer, $offset + 4, 2);
|
||||||
|
$d['minute'] = substr($buffer, $offset + 6, 2);
|
||||||
|
$d['second'] = substr($buffer, $offset + 8, 2);
|
||||||
|
|
||||||
|
if (checkdate($d['month'], $d['day'], $d['year'])) {
|
||||||
|
$timestamp = mktime($d['hour'], $d['minute'], $d['second'], $d['month'], $d['day'], $d['year']);
|
||||||
|
}
|
||||||
|
// If all fails, assume one of the dozens of valid strtime() syntaxes (http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html)
|
||||||
|
} else {
|
||||||
|
$timestamp = strtotime($buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If all above failed, maybe it's a Unix timestamp already?
|
||||||
|
if ($timestamp < 0 && preg_match('/^[1-9]\d{1,9}$/', $buffer)) {
|
||||||
|
$timestamp = $buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there are still errors or the timestamp is invalid, mark timestamp invalid
|
||||||
|
if ($timestamp < 0 || !preg_match('/^[1-9]\d{1,9}$/', $timestamp)) {
|
||||||
|
$timestamp = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reformat a valid timestamp
|
||||||
if ($timestamp != -1) {
|
if ($timestamp != -1) {
|
||||||
$timestamp -= $options[0] * 60 * 60;
|
$timestamp -= $options[0] * 60 * 60;
|
||||||
$buffer = PMA_localisedDate($timestamp, $options[1]);
|
$buffer = PMA_localisedDate($timestamp, $options[1]);
|
||||||
@@ -50,3 +74,5 @@ if (!defined('PMA_TRANSFORMATION_TEXT_PLAIN__DATEFORMAT')){
|
|||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user