diff --git a/interface/lib/classes/tform_base.inc.php b/interface/lib/classes/tform_base.inc.php index e6174d2da763556a2a3f94f8ad4ccb57fba3cbbd..bd9f70a626ef308391f5a0f8ef3ae04a35507311 100644 --- a/interface/lib/classes/tform_base.inc.php +++ b/interface/lib/classes/tform_base.inc.php @@ -152,9 +152,9 @@ class tform_base { $wb = $app->functions->array_merge($wb_global, $wb); } if(isset($wb_global)) unset($wb_global); - + $this->wordbook = $wb; - + $app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'] . ':on_after_formdef', $this); $this->dateformat = $app->lng('conf_format_dateshort'); @@ -323,7 +323,7 @@ class tform_base { return $this->getAuthSQL('r', $matches[1]); } */ - + /** * Get the key => value array of a form filled from a datasource definitiom * @@ -339,12 +339,12 @@ class tform_base { function applyValueLimit($limit, $values, $current_value = '') { global $app; - + // we mas have multiple limits, therefore we explode by ; first // Example: "system:sites:web_php_options;client:web_php_options" $limits = explode(';',$limit); - - + + foreach($limits as $limit) { $limit_parts = explode(':', $limit); @@ -399,7 +399,7 @@ class tform_base { $tmp_key = $limit_parts[2]; $allowed = $allowed = explode(',',$tmp_conf[$tmp_key]); } - + // add the current value to the allowed array $allowed[] = $current_value; @@ -438,7 +438,7 @@ class tform_base { $csrf_token = $app->auth->csrf_token_get($this->formDef['name']); $_csrf_id = $csrf_token['csrf_id']; $_csrf_value = $csrf_token['csrf_key']; - + $this->formDef['tabs'][$tab]['fields']['_csrf_id'] = array( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', @@ -454,7 +454,7 @@ class tform_base { $record['_csrf_id'] = $_csrf_id; $record['_csrf_key'] = $_csrf_value; /* CSRF PROTECTION */ - + $new_record = array(); if($action == 'EDIT') { $record = $this->decode($record, $tab); @@ -589,7 +589,7 @@ class tform_base { $new_record[$key] = $this->_getDateHTML($key, $dt_value); break; - + default: if(isset($record[$key])) { $new_record[$key] = $app->functions->htmlentities($record[$key]); @@ -701,7 +701,7 @@ class tform_base { $new_record[$key] = $this->_getDateTimeHTML($key, $dt_value, $display_seconds); break; - + case 'DATE': $dt_value = (isset($field['default'])) ? $field['default'] : 0; @@ -750,7 +750,7 @@ class tform_base { unset($_POST); unset($record); } - + if(isset($_SESSION['_csrf_timeout']) && is_array($_SESSION['_csrf_timeout'])) { $to_unset = array(); foreach($_SESSION['_csrf_timeout'] as $_csrf_id => $timeout) { @@ -767,7 +767,7 @@ class tform_base { } /* CSRF PROTECTION */ } - + $new_record = array(); if(is_array($record)) { foreach($fields as $key => $field) { @@ -1065,6 +1065,29 @@ class tform_base { } unset($error); break; + case 'ISEMAILADDRESS': + $error = false; + if($validator['allowempty'] != 'y') $validator['allowempty'] = 'n'; + if($validator['allowempty'] == 'y' && $field_value == '') { + //* Do nothing + } else { + if(function_exists('filter_var')) { + if(filter_var($field_value, FILTER_VALIDATE_EMAIL) === false) { + $error = true; + } + if ($error) { + $errmsg = $validator['errmsg']; + if(isset($this->wordbook[$errmsg])) { + $this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n"; + } else { + $this->errorMessage .= $errmsg."<br />\r\n"; + } + } + + } else $this->errorMessage .= "function filter_var missing <br />\r\n"; + } + unset($error); + break; case 'ISINT': if(function_exists('filter_var') && $field_value < PHP_INT_MAX) { //if($field_value != '' && filter_var($field_value, FILTER_VALIDATE_INT, array("options" => array('min_range'=>0))) === false) { @@ -1198,7 +1221,7 @@ class tform_base { } } break; - + case 'ISDATETIME': /* Checks a datetime value against the date format of the current language */ if($validator['allowempty'] != 'y') $validator['allowempty'] = 'n'; @@ -1216,7 +1239,7 @@ class tform_base { } } break; - + case 'RANGE': //* Checks if the value is within the given range or above / below a value //* Range examples: < 10 = ":10", between 2 and 10 = "2:10", above 5 = "5:". @@ -1281,7 +1304,7 @@ class tform_base { $sql_update = ''; $record = $this->encode($record, $tab, true); - + if(($this->primary_id_override > 0)) { $sql_insert_key .= '`'.$this->formDef["db_table_idx"].'`, '; $sql_insert_val .= $this->primary_id_override.", "; diff --git a/interface/web/client/form/client.tform.php b/interface/web/client/form/client.tform.php index 5b45ffb972f58734121c712bc9e55a0b3caab92f..17b9e623b66cda763d4db8561d101b5f33fcad8d 100644 --- a/interface/web/client/form/client.tform.php +++ b/interface/web/client/form/client.tform.php @@ -390,8 +390,8 @@ $form["tabs"]['address'] = array ( 2 => array( 'event' => 'SAVE', 'type' => 'TOLOWER') ), - 'validators' => array ( - 0 => array ( 'type' => 'ISEMAIL', 'errmsg'=> 'email_error_isemail'), + 'validators' => array ( + 0 => array ( 'type' => 'ISEMAILADDRESS', 'errmsg'=> 'email_error_isemail'), 1 => array ( 'type' => 'NOTEMPTY', 'errmsg'=> 'email_error_empty'), ), @@ -621,7 +621,7 @@ $form["tabs"]['address'] = array ( 'type' => 'TOLOWER') ), 'validators' => array ( - 0 => array ( 'type' => 'ISEMAIL', 'allowempty' => 'y', 'errmsg'=> 'email_error_isemail'), + 0 => array ( 'type' => 'ISEMAILADDRESS', 'allowempty' => 'y', 'errmsg'=> 'email_error_isemail'), ), 'default' => '', 'value' => '', diff --git a/interface/web/mail/form/mail_domain_catchall.tform.php b/interface/web/mail/form/mail_domain_catchall.tform.php index 72261e05e0f7d496dc7581f7683ad027fa42c5d7..c43aeb333902a9abe52bb1f7e0f1c5da0d8aa009 100644 --- a/interface/web/mail/form/mail_domain_catchall.tform.php +++ b/interface/web/mail/form/mail_domain_catchall.tform.php @@ -113,7 +113,7 @@ $form["tabs"]['catchall'] = array ( 'valuefield' => 'email' ), */ - 'validators' => array ( 0 => array ( 'type' => 'ISEMAIL', + 'validators' => array ( 0 => array ( 'type' => 'ISEMAILADDRESS', 'errmsg'=> 'destination_error_isemail'), ), 'value' => '',