Relative date and time functions

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@633 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2009-05-31 20:07:32 +00:00
parent 6d3b5935eb
commit 86a93514a7
2 changed files with 19 additions and 4 deletions

View file

@ -1,6 +1,7 @@
phpMinAdmin 1.11.0: phpMinAdmin 1.11.0:
Connection through socket by server :/path/to/socket Connection through socket by server :/path/to/socket
Display execution time in SQL query Display execution time in SQL query
Relative date and time functions
Version checker Version checker
Separate JavaScript functions Separate JavaScript functions
Always use the default style before the external one Always use the default style before the external one

View file

@ -25,14 +25,24 @@ function input($name, $field, $value, $separator = "</td><td>") { //! pass empty
if (preg_match('~char|date|time~', $field["type"])) { if (preg_match('~char|date|time~', $field["type"])) {
$options = (preg_match('~char~', $field["type"]) ? array("", "md5", "sha1", "password", "uuid") : array("", "now")); $options = (preg_match('~char~', $field["type"]) ? array("", "md5", "sha1", "password", "uuid") : array("", "now"));
} }
if (!isset($_GET["clone"]) && !isset($_GET["call"]) && preg_match('~int|float|double|decimal~', $field["type"])) { if (!isset($_GET["clone"]) && !isset($_GET["call"])) {
$options = array("", "+", "-"); if (preg_match('~int|float|double|decimal~', $field["type"])) {
$options = array("", "+", "-");
}
if (preg_match('~date~', $field["type"])) {
$options[] = "+ interval";
$options[] = "- interval";
}
if (preg_match('~time~', $field["type"])) {
$options[] = "addtime";
$options[] = "subtime";
}
} }
} }
if ($field["null"] || isset($_GET["default"])) { if ($field["null"] || isset($_GET["default"])) {
array_unshift($options, "NULL"); array_unshift($options, "NULL");
} }
echo (count($options) > 1 || isset($_GET["select"]) ? '<select name="function[' . $name . ']" tabindex="1">' . (isset($_GET["select"]) ? '<option value="orig">' . lang('original') . '</option>' : '') . optionlist($options, (isset($value) ? (string) $_POST["function"][$name] : null)) . '</select>' : "") . $separator; echo (count($options) > 1 || isset($_GET["select"]) ? '<select name="function[' . $name . ']">' . (isset($_GET["select"]) ? '<option value="orig">' . lang('original') . '</option>' : '') . optionlist($options, (isset($value) ? (string) $_POST["function"][$name] : null)) . '</select>' : "") . $separator;
if ($field["type"] == "set") { //! 64 bits if ($field["type"] == "set") { //! 64 bits
preg_match_all("~'((?:[^']+|'')*)'~", $field["length"], $matches); preg_match_all("~'((?:[^']+|'')*)'~", $field["length"], $matches);
foreach ($matches[1] as $i => $val) { foreach ($matches[1] as $i => $val) {
@ -74,8 +84,12 @@ function process_input($name, $field) {
return $value; return $value;
} elseif (preg_match('~^(now|uuid)$~', $function)) { } elseif (preg_match('~^(now|uuid)$~', $function)) {
return "$function()"; return "$function()";
} elseif (preg_match('~^(\\+|-)$~', $function)) { } elseif (preg_match('~^[+-]$~', $function)) {
return idf_escape($name) . " $function '" . $dbh->escape_string($value) . "'"; return idf_escape($name) . " $function '" . $dbh->escape_string($value) . "'";
} elseif (preg_match('~^[+-] interval$~', $function)) {
return idf_escape($name) . " $function " . (preg_match("~^([0-9]+|'[0-9.: -]') [A-Z_]+$~i", $value) ? $value : "'" . $dbh->escape_string($value) . "'") . "";
} elseif (preg_match('~^(addtime|subtime)$~', $function)) {
return "$function(" . idf_escape($name) . ", '" . $dbh->escape_string($value) . "')";
} elseif (preg_match('~^(md5|sha1|password)$~', $function)) { } elseif (preg_match('~^(md5|sha1|password)$~', $function)) {
return "$function('" . $dbh->escape_string($value) . "')"; return "$function('" . $dbh->escape_string($value) . "')";
} else { } else {