add date/datetime input fields to relevant formfields
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
namespace Froxlor\Ajax;
|
||||
|
||||
use Exception;
|
||||
use DateTime;
|
||||
use Froxlor\Config\ConfigDisplay;
|
||||
use Froxlor\Config\ConfigParser;
|
||||
use Froxlor\CurrentUser;
|
||||
@@ -233,7 +234,7 @@ class Ajax
|
||||
{
|
||||
$keyid = isset($_POST['id']) ? (int)$_POST['id'] : 0;
|
||||
$allowed_from = isset($_POST['allowed_from']) ? $_POST['allowed_from'] : "";
|
||||
$valid_until = isset($_POST['valid_until']) ? (int)$_POST['valid_until'] : -1;
|
||||
$valid_until = isset($_POST['valid_until']) ? $_POST['valid_until'] : "";
|
||||
|
||||
// validate allowed_from
|
||||
if (!empty($allowed_from)) {
|
||||
@@ -260,8 +261,10 @@ class Ajax
|
||||
$allowed_from = implode(",", array_unique($ip_list));
|
||||
}
|
||||
|
||||
if ($valid_until <= 0 || !is_numeric($valid_until)) {
|
||||
$valid_until = -1;
|
||||
if (!empty($valid_until)) {
|
||||
$valid_until_db = DateTime::createFromFormat('Y-m-d\TH:i', $valid_until)->format('U');
|
||||
} else {
|
||||
$valid_until_db = -1;
|
||||
}
|
||||
|
||||
$upd_stmt = Database::prepare("
|
||||
@@ -277,7 +280,7 @@ class Ajax
|
||||
Database::pexecute($upd_stmt, [
|
||||
'keyid' => $keyid,
|
||||
'af' => $allowed_from,
|
||||
'vu' => $valid_until,
|
||||
'vu' => $valid_until_db,
|
||||
'aid' => $this->userinfo['adminid'],
|
||||
'cid' => $cid
|
||||
]);
|
||||
|
||||
@@ -403,7 +403,7 @@ class Domains extends ApiCommand implements ResourceEntity
|
||||
$documentroot = $_documentroot;
|
||||
}
|
||||
|
||||
$registration_date = Validate::validate($registration_date, 'registration_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', [
|
||||
$registration_date = Validate::validate($registration_date, 'registration_date', Validate::REGEX_YYYY_MM_DD, '', [
|
||||
'0000-00-00',
|
||||
'0',
|
||||
''
|
||||
@@ -412,7 +412,7 @@ class Domains extends ApiCommand implements ResourceEntity
|
||||
$registration_date = null;
|
||||
}
|
||||
|
||||
$termination_date = Validate::validate($termination_date, 'termination_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', [
|
||||
$termination_date = Validate::validate($termination_date, 'termination_date', Validate::REGEX_YYYY_MM_DD, '', [
|
||||
'0000-00-00',
|
||||
'0',
|
||||
''
|
||||
@@ -1291,7 +1291,7 @@ class Domains extends ApiCommand implements ResourceEntity
|
||||
$adminid = $result['adminid'];
|
||||
}
|
||||
|
||||
$registration_date = Validate::validate($registration_date, 'registration_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', [
|
||||
$registration_date = Validate::validate($registration_date, 'registration_date', Validate::REGEX_YYYY_MM_DD, '', [
|
||||
'0000-00-00',
|
||||
'0',
|
||||
''
|
||||
@@ -1299,7 +1299,7 @@ class Domains extends ApiCommand implements ResourceEntity
|
||||
if ($registration_date == '0000-00-00' || empty($registration_date)) {
|
||||
$registration_date = null;
|
||||
}
|
||||
$termination_date = Validate::validate($termination_date, 'termination_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', [
|
||||
$termination_date = Validate::validate($termination_date, 'termination_date', Validate::REGEX_YYYY_MM_DD, '', [
|
||||
'0000-00-00',
|
||||
'0',
|
||||
''
|
||||
|
||||
@@ -43,6 +43,8 @@ class Validate
|
||||
|
||||
const REGEX_DESC_TEXT = '/^[^\0\r\n<>]*$/';
|
||||
|
||||
const REGEX_YYYY_MM_DD = '/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/';
|
||||
|
||||
/**
|
||||
* Validates the given string by matching against the pattern, prints an error on failure and exits
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user