added preg-checks for profiles and config

This commit is contained in:
Roland Gruber 2004-09-26 15:45:40 +00:00
parent 941bd55d8f
commit 61dffc68ac
1 changed files with 114 additions and 92 deletions

View File

@ -221,52 +221,63 @@ class baseModule {
if ($this->meta['profile_checks'][$identifiers[$i]]['required'] && ($options[$identifiers[$i]][0] == '')) { if ($this->meta['profile_checks'][$identifiers[$i]]['required'] && ($options[$identifiers[$i]][0] == '')) {
$messages[] = $this->meta['profile_checks'][$identifiers[$i]]['required_message']; $messages[] = $this->meta['profile_checks'][$identifiers[$i]]['required_message'];
} }
// check by regular expression (case insensitive) switch ($this->meta['profile_checks'][$identifiers[$i]]['type']) {
if ($this->meta['profile_checks'][$identifiers[$i]]['type'] == 'regex_i') { // check by regular expression (from account.inc)
// ignore empty fileds case "ext_preg":
if ($options[$identifiers[$i]][0] == '') continue; // ignore empty fileds
if (! eregi($this->meta['profile_checks'][$identifiers[$i]]['regex'], $options[$identifiers[$i]][0])) { if ($options[$identifiers[$i]][0] == '') continue;
$messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message']; if (! get_preg($options[$identifiers[$i]][0], $this->meta['profile_checks'][$identifiers[$i]]['regex'])) {
} $messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message'];
} }
// check by regular expression (case sensitive) break;
elseif ($this->meta['profile_checks'][$identifiers[$i]]['type'] == 'regex') { // check by regular expression (case insensitive)
// ignore empty fileds case 'regex_i':
if ($options[$identifiers[$i]][0] == '') continue; // ignore empty fileds
if (! ereg($this->meta['profile_checks'][$identifiers[$i]]['regex'], $options[$identifiers[$i]][0])) { if ($options[$identifiers[$i]][0] == '') continue;
$messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message']; if (! eregi($this->meta['profile_checks'][$identifiers[$i]]['regex'], $options[$identifiers[$i]][0])) {
} $messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message'];
} }
// check by integer comparison (greater) break;
elseif ($this->meta['profile_checks'][$identifiers[$i]]['type'] == 'int_greater') { // check by regular expression (case sensitive)
// ignore if both fields are empty case 'regex':
if (($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0] == '')) continue; // ignore empty fileds
// print error message if only one field is empty if ($options[$identifiers[$i]][0] == '') continue;
if (($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0] == '') || ($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0] == '')) { if (! ereg($this->meta['profile_checks'][$identifiers[$i]]['regex'], $options[$identifiers[$i]][0])) {
$messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message']; $messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message'];
continue; }
} break;
// compare // check by integer comparison (greater)
if (!(intval($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0]) > intval($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0]))) { case 'int_greater':
$messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message']; // ignore if both fields are empty
} if (($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0] == '')) continue;
} // print error message if only one field is empty
// check by integer comparison (greater or equal) if (($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0] == '') || ($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0] == '')) {
elseif ($this->meta['profile_checks'][$identifiers[$i]]['type'] == 'int_greaterOrEqual') { $messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message'];
// ignore if both fields are empty continue;
if (($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0] == '')) continue; }
// print error message if only one field is empty // compare
if (($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0] == '') || ($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0] == '')) { if (!(intval($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0]) > intval($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0]))) {
$messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message']; $messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message'];
continue; }
} break;
// compare // check by integer comparison (greater or equal)
if (!(intval($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0]) >= intval($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0]))) { case 'int_greaterOrEqual':
$messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message']; // ignore if both fields are empty
} if (($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0] == '')) continue;
} // print error message if only one field is empty
else { if (($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0] == '') || ($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0] == '')) {
StatusMessage("ERROR", "Unsupported type!", $this->meta['profile_checks'][$identifiers[$i]]['type']); $messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message'];
continue;
}
// compare
if (!(intval($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0]) >= intval($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0]))) {
$messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message'];
}
break;
// print error message for invalid types
default:
StatusMessage("ERROR", "Unsupported type!", $this->meta['profile_checks'][$identifiers[$i]]['type']);
break;
} }
} }
} }
@ -320,52 +331,63 @@ class baseModule {
if ($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['required'] && ($options[$identifiers[$i]][0] == '')) { if ($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['required'] && ($options[$identifiers[$i]][0] == '')) {
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['required_message']; $messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['required_message'];
} }
// check by regular expression (case insensitive) switch ($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['type']) {
if ($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['type'] == 'regex_i') { // check by regular expression (from account.inc)
// ignore empty fileds case "ext_preg":
if ($options[$identifiers[$i]][0] == '') continue; // ignore empty fileds
if (! eregi($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['regex'], $options[$identifiers[$i]][0])) { if ($options[$identifiers[$i]][0] == '') continue;
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message']; if (! get_preg($options[$identifiers[$i]][0], $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['regex'])) {
} $messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
} }
// check by regular expression (case sensitive) break;
elseif ($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['type'] == 'regex') { // check by regular expression (case insensitive)
// ignore empty fileds case "regex_i":
if ($options[$identifiers[$i]][0] == '') continue; // ignore empty fileds
if (! ereg($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['regex'], $options[$identifiers[$i]][0])) { if ($options[$identifiers[$i]][0] == '') continue;
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message']; if (! eregi($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['regex'], $options[$identifiers[$i]][0])) {
} $messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
} }
// check by integer comparison (greater) break;
elseif ($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['type'] == 'int_greater') { // check by regular expression (case sensitive)
// ignore if both fields are empty case "regex":
if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) continue; // ignore empty fileds
// print error message if only one field is empty if ($options[$identifiers[$i]][0] == '') continue;
if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') || ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) { if (! ereg($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['regex'], $options[$identifiers[$i]][0])) {
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message']; $messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
continue; }
} break;
// compare // check by integer comparison (greater)
if (!(intval($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0]) > intval($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0]))) { case "int_greater":
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message']; // ignore if both fields are empty
} if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) continue;
} // print error message if only one field is empty
// check by integer comparison (greater or equal) if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') || ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) {
elseif ($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['type'] == 'int_greaterOrEqual') { $messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
// ignore if both fields are empty continue;
if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) continue; }
// print error message if only one field is empty // compare
if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') || ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) { if (!(intval($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0]) > intval($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0]))) {
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message']; $messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
continue; }
} break;
// compare // check by integer comparison (greater or equal)
if (!(intval($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0]) >= intval($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0]))) { case "int_greaterOrEqual":
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message']; // ignore if both fields are empty
} if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) continue;
} // print error message if only one field is empty
else { if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') || ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) {
StatusMessage("ERROR", "Unsupported type!", $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['type']); $messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
continue;
}
// compare
if (!(intval($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0]) >= intval($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0]))) {
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
}
break;
// print error message on undefined type
default:
StatusMessage("ERROR", "Unsupported type!", $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['type']);
break;
} }
} }
} }