Use YYYY-MM-DD regex due to datepicker switch

This commit is contained in:
Mike Koch 2016-11-07 17:41:35 -05:00
parent ea8aac8d64
commit 49b8b44413
4 changed files with 7 additions and 8 deletions

View File

@ -139,8 +139,7 @@ foreach ($hesk_settings['custom_fields'] as $k=>$v) {
} elseif ($v['type'] == 'date') { } elseif ($v['type'] == 'date') {
$tmpvar[$k] = hesk_POST($k); $tmpvar[$k] = hesk_POST($k);
$_SESSION["as_$k"] = ''; $_SESSION["as_$k"] = '';
if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $tmpvar[$k])) {
if (preg_match("/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/", $tmpvar[$k])) {
$date = strtotime($tmpvar[$k] . ' t00:00:00'); $date = strtotime($tmpvar[$k] . ' t00:00:00');
$dmin = strlen($v['value']['dmin']) ? strtotime($v['value']['dmin'] . ' t00:00:00') : false; $dmin = strlen($v['value']['dmin']) ? strtotime($v['value']['dmin'] . ' t00:00:00') : false;
$dmax = strlen($v['value']['dmax']) ? strtotime($v['value']['dmax'] . ' t00:00:00') : false; $dmax = strlen($v['value']['dmax']) ? strtotime($v['value']['dmax'] . ' t00:00:00') : false;

View File

@ -287,7 +287,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
$dmin_type = $matches[3]; $dmin_type = $matches[3];
} }
// Minimum date is in "MM/DD/YYYY" format // Minimum date is in "MM/DD/YYYY" format
elseif (preg_match("/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/", $dmin)) elseif (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $dmin))
{ {
$dmin_rf = 1; $dmin_rf = 1;
} }
@ -359,7 +359,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
$dmax_type = $matches[3]; $dmax_type = $matches[3];
} }
// Minimum date is in "MM/DD/YYYY" format // Minimum date is in "MM/DD/YYYY" format
elseif (preg_match("/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/", $dmax)) elseif (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $dmax))
{ {
$dmax_rf = 1; $dmax_rf = 1;
} }
@ -1110,7 +1110,7 @@ function cf_validate()
{ {
$dmin = hesk_POST('dmin'); $dmin = hesk_POST('dmin');
if (preg_match("/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/", $dmin)) if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $dmin))
{ {
$cf['dmin'] = $dmin; $cf['dmin'] = $dmin;
} }
@ -1135,7 +1135,7 @@ function cf_validate()
{ {
$dmax = hesk_POST('dmax'); $dmax = hesk_POST('dmax');
if (preg_match("/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/", $dmax)) if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $dmax))
{ {
$cf['dmax'] = $dmax; $cf['dmax'] = $dmax;
} }

View File

@ -166,7 +166,7 @@ if (isset($_POST['save'])) {
$tmpvar[$k] = hesk_POST($k); $tmpvar[$k] = hesk_POST($k);
$_SESSION["as_$k"] = ''; $_SESSION["as_$k"] = '';
if (preg_match("/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/", $tmpvar[$k])) { if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $tmpvar[$k])) {
$date = strtotime($tmpvar[$k] . ' t00:00:00'); $date = strtotime($tmpvar[$k] . ' t00:00:00');
$dmin = strlen($v['value']['dmin']) ? strtotime($v['value']['dmin'] . ' t00:00:00') : false; $dmin = strlen($v['value']['dmin']) ? strtotime($v['value']['dmin'] . ' t00:00:00') : false;
$dmax = strlen($v['value']['dmax']) ? strtotime($v['value']['dmax'] . ' t00:00:00') : false; $dmax = strlen($v['value']['dmax']) ? strtotime($v['value']['dmax'] . ' t00:00:00') : false;

View File

@ -284,7 +284,7 @@ foreach ($hesk_settings['custom_fields'] as $k=>$v) {
$tmpvar[$k] = hesk_POST($k); $tmpvar[$k] = hesk_POST($k);
$_SESSION["c_$k"] = ''; $_SESSION["c_$k"] = '';
if (preg_match("/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/", $tmpvar[$k])) { if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $tmpvar[$k])) {
$date = strtotime($tmpvar[$k] . ' t00:00:00'); $date = strtotime($tmpvar[$k] . ' t00:00:00');
$dmin = strlen($v['value']['dmin']) ? strtotime($v['value']['dmin'] . ' t00:00:00') : false; $dmin = strlen($v['value']['dmin']) ? strtotime($v['value']['dmin'] . ' t00:00:00') : false;
$dmax = strlen($v['value']['dmax']) ? strtotime($v['value']['dmax'] . ' t00:00:00') : false; $dmax = strlen($v['value']['dmax']) ? strtotime($v['value']['dmax'] . ' t00:00:00') : false;