diff --git a/lib/functions/formfields/hiddenstring/function.getFormFieldOutputString.php b/lib/functions/formfields/hiddenstring/function.getFormFieldOutputString.php new file mode 100644 index 00000000..9331fccd --- /dev/null +++ b/lib/functions/formfields/hiddenstring/function.getFormFieldOutputString.php @@ -0,0 +1,26 @@ + (2003-2009) + * @author Froxlor team (2010-) + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package Functions + * + */ + +function getFormFieldOutputHiddenString($fieldname, $fielddata) +{ + $label = $fielddata['label']; + $value = htmlentities($fielddata['value']); + eval("\$returnvalue = \"" . getTemplate("formfields/hiddenstring", true) . "\";"); + return $returnvalue; +} \ No newline at end of file diff --git a/lib/functions/formfields/hiddenstring/function.validateFormFieldString.php b/lib/functions/formfields/hiddenstring/function.validateFormFieldString.php new file mode 100644 index 00000000..3847b5f4 --- /dev/null +++ b/lib/functions/formfields/hiddenstring/function.validateFormFieldString.php @@ -0,0 +1,115 @@ + (2003-2009) + * @author Froxlor team (2010-) + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package Functions + * + */ + +function validateFormFieldHiddenString($fieldname, $fielddata, $newfieldvalue) +{ + if(isset($fielddata['string_delimiter']) && $fielddata['string_delimiter'] != '') + { + $newfieldvalues = explode($fielddata['string_delimiter'], $newfieldvalue); + unset($fielddata['string_delimiter']); + + $returnvalue = true; + foreach($newfieldvalues as $single_newfieldvalue) + { + /** + * don't use tabs in value-fields, #81 + */ + $single_newfieldvalue = str_replace("\t", " ", $single_newfieldvalue); + $single_returnvalue = validateFormFieldString($fieldname, $fielddata, $single_newfieldvalue); + if($single_returnvalue !== true) + { + $returnvalue = $single_returnvalue; + break; + } + } + } + else + { + $returnvalue = false; + + /** + * don't use tabs in value-fields, #81 + */ + $newfieldvalue = str_replace("\t", " ", $newfieldvalue); + + if(isset($fielddata['string_type']) && $fielddata['string_type'] == 'mail') + { + $returnvalue = (filter_var($newfieldvalue, FILTER_VALIDATE_EMAIL) == $newfieldvalue); + } + elseif(isset($fielddata['string_type']) && $fielddata['string_type'] == 'url') + { + $returnvalue = validateUrl($newfieldvalue); + } + elseif(isset($fielddata['string_type']) && $fielddata['string_type'] == 'dir') + { + // add trailing slash to validate path if needed + // refs #331 + if(substr($newfieldvalue, -1) != '/') { + $newfieldvalue.= '/'; + } + $returnvalue = ($newfieldvalue == makeCorrectDir($newfieldvalue)); + } + elseif(isset($fielddata['string_type']) && $fielddata['string_type'] == 'file') + { + $returnvalue = ($newfieldvalue == makeCorrectFile($newfieldvalue)); + } + elseif(isset($fielddata['string_type']) && $fielddata['string_type'] == 'filedir') + { + $returnvalue = (($newfieldvalue == makeCorrectDir($newfieldvalue)) || ($newfieldvalue == makeCorrectFile($newfieldvalue))); + } + elseif(preg_match('/^[^\r\n\t\f\0]*$/D', $newfieldvalue)) + { + $returnvalue = true; + } + + if(isset($fielddata['string_regexp']) && $fielddata['string_regexp'] != '') + { + if(preg_match($fielddata['string_regexp'], $newfieldvalue)) + { + $returnvalue = true; + } + else + { + $returnvalue = false; + } + } + + if(isset($fielddata['string_emptyallowed']) && $fielddata['string_emptyallowed'] === true && $newfieldvalue === '') + { + $returnvalue = true; + } + elseif(isset($fielddata['string_emptyallowed']) && $fielddata['string_emptyallowed'] === false && $newfieldvalue === '') + { + $returnvalue = 'stringmustntbeempty'; + } + } + + if($returnvalue === true) + { + return true; + } + elseif($returnvalue === false) + { + return 'stringformaterror'; + } + else + { + return $returnvalue; + } +} \ No newline at end of file diff --git a/templates/Classic/formfields/hiddenstring.tpl b/templates/Classic/formfields/hiddenstring.tpl new file mode 100644 index 00000000..972265e6 --- /dev/null +++ b/templates/Classic/formfields/hiddenstring.tpl @@ -0,0 +1,4 @@ + + {$label} + + \ No newline at end of file diff --git a/templates/Froxlor/formfields/hiddenstring.tpl b/templates/Froxlor/formfields/hiddenstring.tpl new file mode 100644 index 00000000..4552c600 --- /dev/null +++ b/templates/Froxlor/formfields/hiddenstring.tpl @@ -0,0 +1,4 @@ + + {$label} + + \ No newline at end of file