From 13aa19e5f497391d6b1cd86efb4136ec8fcae131 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Sat, 22 Dec 2018 13:28:51 +0100 Subject: [PATCH] got rid of all global functions, I guess Signed-off-by: Michael Kaufmann --- customer_domains.php | 2 +- install/lib/class.FroxlorInstall.php | 3 +- lib/Froxlor/Api/Commands/DirOptions.php | 2 +- lib/Froxlor/Api/Commands/SubDomains.php | 4 +- lib/Froxlor/Cron/Http/Apache.php | 4 +- lib/Froxlor/Cron/Http/Lighttpd.php | 4 +- lib/Froxlor/Cron/Http/Nginx.php | 8 +- lib/Froxlor/Cron/Traffic/TrafficCron.php | 8 +- lib/Froxlor/UI/Data.php | 63 +++ lib/Froxlor/UI/Fields.php | 108 +++++ lib/Froxlor/UI/Form.php | 453 +++++++++++++++++- lib/Froxlor/Validate/Form.php | 42 ++ .../Validate/Form/{Strings.php => Data.php} | 157 +++++- lib/cron_init.php | 3 +- lib/functions.php | 127 ----- .../{formfields => }/constant.formfields.php | 0 .../{logger => }/constant.logger.php | 0 .../bool/function.getFormFieldDataBool.php | 28 -- .../bool/function.getFormFieldOutputBool.php | 25 - .../bool/function.validateFormFieldBool.php | 26 - .../date/function.getFormFieldOutputDate.php | 26 - .../function.manipulateFormFieldDataDate.php | 26 - .../date/function.validateFormFieldDate.php | 28 -- .../file/function.getFormFieldOutputFile.php | 23 - .../file/function.validateFormFieldFile.php | 20 - .../function.checkPlausibilityFormField.php | 28 -- .../formfields/function.getFormFieldData.php | 35 -- .../function.getFormFieldOutput.php | 71 --- .../function.getFormGroupOutput.php | 83 ---- .../function.manipulateFormFieldData.php | 26 - .../function.prefetchFormFieldData.php | 26 - .../formfields/function.processForm.php | 222 --------- .../formfields/function.saveForm.php | 33 -- .../formfields/function.saveFormField.php | 33 -- .../function.validateFieldDefinition.php | 28 -- .../function.validateFormDefinition.php | 28 -- .../formfields/function.validateFormField.php | 28 -- .../function.getFormFieldOutputHidden.php | 30 -- .../function.validateFormFieldHidden.php | 31 -- .../function.getFormFieldOutputString.php | 25 - .../function.validateFormFieldString.php | 86 ---- .../int/function.getFormFieldDataInt.php | 28 -- .../int/function.getFormFieldOutputInt.php | 22 - .../int/function.validateFormFieldInt.php | 30 -- .../function.getFormFieldDataOption.php | 32 -- .../function.getFormFieldOutputOption.php | 41 -- .../function.prefetchFormFieldDataOption.php | 28 -- .../function.validateFormFieldOption.php | 40 -- .../function.getFormFieldOutputString.php | 25 - .../text/function.getFormFieldDataText.php | 26 - .../text/function.getFormFieldOutputText.php | 25 - .../text/function.validateFormFieldText.php | 28 -- .../function.array_merge_prefix.php | 35 -- lib/init.php | 3 +- 54 files changed, 832 insertions(+), 1534 deletions(-) create mode 100644 lib/Froxlor/UI/Data.php create mode 100644 lib/Froxlor/UI/Fields.php create mode 100644 lib/Froxlor/Validate/Form.php rename lib/Froxlor/Validate/Form/{Strings.php => Data.php} (53%) delete mode 100644 lib/functions.php rename lib/functions/{formfields => }/constant.formfields.php (100%) rename lib/functions/{logger => }/constant.logger.php (100%) delete mode 100644 lib/functions/formfields/bool/function.getFormFieldDataBool.php delete mode 100644 lib/functions/formfields/bool/function.getFormFieldOutputBool.php delete mode 100644 lib/functions/formfields/bool/function.validateFormFieldBool.php delete mode 100644 lib/functions/formfields/date/function.getFormFieldOutputDate.php delete mode 100644 lib/functions/formfields/date/function.manipulateFormFieldDataDate.php delete mode 100644 lib/functions/formfields/date/function.validateFormFieldDate.php delete mode 100644 lib/functions/formfields/file/function.getFormFieldOutputFile.php delete mode 100644 lib/functions/formfields/file/function.validateFormFieldFile.php delete mode 100644 lib/functions/formfields/function.checkPlausibilityFormField.php delete mode 100644 lib/functions/formfields/function.getFormFieldData.php delete mode 100644 lib/functions/formfields/function.getFormFieldOutput.php delete mode 100644 lib/functions/formfields/function.getFormGroupOutput.php delete mode 100644 lib/functions/formfields/function.manipulateFormFieldData.php delete mode 100644 lib/functions/formfields/function.prefetchFormFieldData.php delete mode 100644 lib/functions/formfields/function.processForm.php delete mode 100644 lib/functions/formfields/function.saveForm.php delete mode 100644 lib/functions/formfields/function.saveFormField.php delete mode 100644 lib/functions/formfields/function.validateFieldDefinition.php delete mode 100644 lib/functions/formfields/function.validateFormDefinition.php delete mode 100644 lib/functions/formfields/function.validateFormField.php delete mode 100644 lib/functions/formfields/hidden/function.getFormFieldOutputHidden.php delete mode 100644 lib/functions/formfields/hidden/function.validateFormFieldHidden.php delete mode 100644 lib/functions/formfields/hiddenstring/function.getFormFieldOutputString.php delete mode 100644 lib/functions/formfields/hiddenstring/function.validateFormFieldString.php delete mode 100644 lib/functions/formfields/int/function.getFormFieldDataInt.php delete mode 100644 lib/functions/formfields/int/function.getFormFieldOutputInt.php delete mode 100644 lib/functions/formfields/int/function.validateFormFieldInt.php delete mode 100644 lib/functions/formfields/option/function.getFormFieldDataOption.php delete mode 100644 lib/functions/formfields/option/function.getFormFieldOutputOption.php delete mode 100644 lib/functions/formfields/option/function.prefetchFormFieldDataOption.php delete mode 100644 lib/functions/formfields/option/function.validateFormFieldOption.php delete mode 100644 lib/functions/formfields/string/function.getFormFieldOutputString.php delete mode 100644 lib/functions/formfields/text/function.getFormFieldDataText.php delete mode 100644 lib/functions/formfields/text/function.getFormFieldOutputText.php delete mode 100644 lib/functions/formfields/text/function.validateFormFieldText.php delete mode 100644 lib/functions/phphelpers/function.array_merge_prefix.php diff --git a/customer_domains.php b/customer_domains.php index 44cc6227..f35ea53c 100644 --- a/customer_domains.php +++ b/customer_domains.php @@ -369,7 +369,7 @@ if ($page == 'overview') { $domains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row_domain['domain']), $row_domain['id'], $result['aliasdomain']); } - if (preg_match('/^https?\:\/\//', $result['documentroot']) && \Froxlor\Validate\Form\Strings::validateUrl($result['documentroot'])) { + if (preg_match('/^https?\:\/\//', $result['documentroot']) && \Froxlor\Validate\Form\Data::validateUrl($result['documentroot'])) { if (Settings::Get('panel.pathedit') == 'Dropdown') { $urlvalue = $result['documentroot']; $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); diff --git a/install/lib/class.FroxlorInstall.php b/install/lib/class.FroxlorInstall.php index 504d8b8e..60dee5d8 100644 --- a/install/lib/class.FroxlorInstall.php +++ b/install/lib/class.FroxlorInstall.php @@ -104,7 +104,8 @@ class FroxlorInstall // check if we have a valid installation already $this->_checkUserdataFile(); // include the functions - require $this->_basepath . '/lib/functions.php'; + require $this->_basepath . '/lib/functions/constant.formfields.php'; + require $this->_basepath . '/lib/functions/constant.logger.php'; // include the MySQL-Table-Definitions require $this->_basepath . '/lib/tables.inc.php'; // include language diff --git a/lib/Froxlor/Api/Commands/DirOptions.php b/lib/Froxlor/Api/Commands/DirOptions.php index 69c5ef9b..f4a894d7 100644 --- a/lib/Froxlor/Api/Commands/DirOptions.php +++ b/lib/Froxlor/Api/Commands/DirOptions.php @@ -394,7 +394,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc { if ($errdoc !== null && $errdoc != '') { // not a URL - if ((strtoupper(substr($errdoc, 0, 5)) != 'HTTP:' && strtoupper(substr($errdoc, 0, 6)) != 'HTTPS:') || ! \Froxlor\Validate\Form\Strings::validateUrl($errdoc)) { + if ((strtoupper(substr($errdoc, 0, 5)) != 'HTTP:' && strtoupper(substr($errdoc, 0, 6)) != 'HTTPS:') || ! \Froxlor\Validate\Form\Data::validateUrl($errdoc)) { // a file if (substr($errdoc, 0, 1) != '"') { $errdoc = \Froxlor\FileDir::makeCorrectFile($errdoc); diff --git a/lib/Froxlor/Api/Commands/SubDomains.php b/lib/Froxlor/Api/Commands/SubDomains.php index 6cfa5b85..047a0f66 100644 --- a/lib/Froxlor/Api/Commands/SubDomains.php +++ b/lib/Froxlor/Api/Commands/SubDomains.php @@ -855,7 +855,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc { // check whether an URL was specified $_doredirect = false; - if (! empty($url) && \Froxlor\Validate\Form\Strings::validateUrl($url)) { + if (! empty($url) && \Froxlor\Validate\Form\Data::validateUrl($url)) { $path = $url; $_doredirect = true; } else { @@ -863,7 +863,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc } // check whether path is a real path - if (! preg_match('/^https?\:\/\//', $path) || ! \Froxlor\Validate\Form\Strings::validateUrl($path)) { + if (! preg_match('/^https?\:\/\//', $path) || ! \Froxlor\Validate\Form\Data::validateUrl($path)) { if (strstr($path, ":") !== false) { \Froxlor\UI\Response::standard_error('pathmaynotcontaincolon', '', true); } diff --git a/lib/Froxlor/Cron/Http/Apache.php b/lib/Froxlor/Cron/Http/Apache.php index a5f9a74f..2327b986 100644 --- a/lib/Froxlor/Cron/Http/Apache.php +++ b/lib/Froxlor/Cron/Http/Apache.php @@ -144,7 +144,7 @@ class Apache extends HttpConfigBase foreach ($statusCodes as $statusCode) { if (Settings::Get('defaultwebsrverrhandler.err' . $statusCode) != '') { $defhandler = Settings::Get('defaultwebsrverrhandler.err' . $statusCode); - if (! \Froxlor\Validate\Form\Strings::validateUrl($defhandler)) { + if (! \Froxlor\Validate\Form\Data::validateUrl($defhandler)) { if (substr($defhandler, 0, 1) != '"' && substr($defhandler, - 1, 1) != '"') { $defhandler = '"' . \Froxlor\FileDir::makeCorrectFile($defhandler) . '"'; } @@ -1190,7 +1190,7 @@ class Apache extends HttpConfigBase foreach ($statusCodes as $statusCode) { if (isset($row_diroptions['error' . $statusCode . 'path']) && $row_diroptions['error' . $statusCode . 'path'] != '') { $defhandler = $row_diroptions['error' . $statusCode . 'path']; - if (! \Froxlor\Validate\Form\Strings::validateUrl($defhandler)) { + if (! \Froxlor\Validate\Form\Data::validateUrl($defhandler)) { if (substr($defhandler, 0, 1) != '"' && substr($defhandler, - 1, 1) != '"') { $defhandler = '"' . \Froxlor\FileDir::makeCorrectFile($defhandler) . '"'; } diff --git a/lib/Froxlor/Cron/Http/Lighttpd.php b/lib/Froxlor/Cron/Http/Lighttpd.php index 1d69a0c0..e4311c04 100644 --- a/lib/Froxlor/Cron/Http/Lighttpd.php +++ b/lib/Froxlor/Cron/Http/Lighttpd.php @@ -316,7 +316,7 @@ class Lighttpd extends HttpConfigBase } $defhandler = Settings::Get('defaultwebsrverrhandler.err404'); - if (! \Froxlor\Validate\Form\Strings::validateUrl($defhandler)) { + if (! \Froxlor\Validate\Form\Data::validateUrl($defhandler)) { $defhandler = \Froxlor\FileDir::makeCorrectFile($defhandler); } $this->lighttpd_data[$vhost_filename] = 'server.error-handler-404 = "' . $defhandler . '"'; @@ -701,7 +701,7 @@ class Lighttpd extends HttpConfigBase if (! empty($row['error404path'])) { $defhandler = $row['error404path']; - if (! \Froxlor\Validate\Form\Strings::validateUrl($defhandler)) { + if (! \Froxlor\Validate\Form\Data::validateUrl($defhandler)) { $defhandler = \Froxlor\FileDir::makeCorrectFile($domain['documentroot'] . '/' . $defhandler); } $error_string .= ' server.error-handler-404 = "' . $defhandler . '"' . "\n\n"; diff --git a/lib/Froxlor/Cron/Http/Nginx.php b/lib/Froxlor/Cron/Http/Nginx.php index 3f7c39fb..49503c63 100644 --- a/lib/Froxlor/Cron/Http/Nginx.php +++ b/lib/Froxlor/Cron/Http/Nginx.php @@ -116,7 +116,7 @@ class Nginx extends HttpConfigBase foreach ($statusCodes as $statusCode) { if (Settings::Get('defaultwebsrverrhandler.err' . $statusCode) != '') { $defhandler = Settings::Get('defaultwebsrverrhandler.err' . $statusCode); - if (! \Froxlor\Validate\Form\Strings::validateUrl($defhandler)) { + if (! \Froxlor\Validate\Form\Data::validateUrl($defhandler)) { $defhandler = \Froxlor\FileDir::makeCorrectFile($defhandler); } $this->nginx_data[$vhosts_filename] .= 'error_page ' . $statusCode . ' ' . $defhandler . ';' . "\n"; @@ -703,7 +703,7 @@ class Nginx extends HttpConfigBase while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) { if (! empty($row['error404path'])) { $defhandler = $row['error404path']; - if (! \Froxlor\Validate\Form\Strings::validateUrl($defhandler)) { + if (! \Froxlor\Validate\Form\Data::validateUrl($defhandler)) { $defhandler = \Froxlor\FileDir::makeCorrectFile($defhandler); } $path_options .= "\t" . 'error_page 404 ' . $defhandler . ';' . "\n"; @@ -711,7 +711,7 @@ class Nginx extends HttpConfigBase if (! empty($row['error403path'])) { $defhandler = $row['error403path']; - if (! \Froxlor\Validate\Form\Strings::validateUrl($defhandler)) { + if (! \Froxlor\Validate\Form\Data::validateUrl($defhandler)) { $defhandler = \Froxlor\FileDir::makeCorrectFile($defhandler); } $path_options .= "\t" . 'error_page 403 ' . $defhandler . ';' . "\n"; @@ -719,7 +719,7 @@ class Nginx extends HttpConfigBase if (! empty($row['error500path'])) { $defhandler = $row['error500path']; - if (! \Froxlor\Validate\Form\Strings::validateUrl($defhandler)) { + if (! \Froxlor\Validate\Form\Data::validateUrl($defhandler)) { $defhandler = \Froxlor\FileDir::makeCorrectFile($defhandler); } $path_options .= "\t" . 'error_page 500 502 503 504 ' . $defhandler . ';' . "\n"; diff --git a/lib/Froxlor/Cron/Traffic/TrafficCron.php b/lib/Froxlor/Cron/Traffic/TrafficCron.php index 1eb198a4..10b90893 100644 --- a/lib/Froxlor/Cron/Traffic/TrafficCron.php +++ b/lib/Froxlor/Cron/Traffic/TrafficCron.php @@ -69,8 +69,6 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron $cronlog->logAction(CRON_ACTION, LOG_INFO, $msg . " Not forking traffic-cron, this may take a long time!"); } - require_once \Froxlor\FileDir::makeCorrectFile(dirname(__FILE__) . '/TrafficCron.inc.functions.php'); - /** * TRAFFIC AND DISKUSAGE MESSURE */ @@ -79,9 +77,9 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron $domainlist = array(); $speciallogfile_domainlist = array(); $result_domainlist_stmt = Database::query(" - SELECT `id`, `domain`, `customerid`, `parentdomainid`, `speciallogfile` - FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `aliasdomain` IS NULL AND `email_only` <> '1'; -"); + SELECT `id`, `domain`, `customerid`, `parentdomainid`, `speciallogfile` + FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `aliasdomain` IS NULL AND `email_only` <> '1'; + "); while ($row_domainlist = $result_domainlist_stmt->fetch(\PDO::FETCH_ASSOC)) { diff --git a/lib/Froxlor/UI/Data.php b/lib/Froxlor/UI/Data.php new file mode 100644 index 00000000..9f53de49 --- /dev/null +++ b/lib/Froxlor/UI/Data.php @@ -0,0 +1,63 @@ + $title) { + $options .= \Froxlor\UI\HTML::makeoption($title, $value, $fielddata['value']); + } + eval("\$returnvalue = \"" . \Froxlor\UI\Template::getTemplate("formfields/option", true) . "\";"); + } + + return $returnvalue; + } + + public static function prefetchFormFieldDataOption($fieldname, $fielddata) + { + $returnvalue = array(); + + if ((! isset($fielddata['option_options']) || ! is_array($fielddata['option_options']) || empty($fielddata['option_options'])) && (isset($fielddata['option_options_method']))) { + $returnvalue['options'] = call_user_func($fielddata['option_options_method']); + } + + return $returnvalue; + } + + public static function getFormFieldOutputInt($fieldname, $fielddata, $do_show = true) + { + return self::getFormFieldOutputString($fieldname, $fielddata, $do_show); + } + + public static function getFormFieldOutputHiddenString($fieldname, $fielddata, $do_show = true) + { + $label = $fielddata['label']; + $value = htmlentities($fielddata['value']); + eval("\$returnvalue = \"" . \Froxlor\UI\Template::getTemplate("formfields/hiddenstring", true) . "\";"); + return $returnvalue; + } + + public static function getFormFieldOutputHidden($fieldname, $fielddata) + { + $returnvalue = ''; + + if (isset($fielddata['label']) && $fielddata['label'] != '') { + $label = $fielddata['label']; + $value = htmlentities($fielddata['value']); + eval("\$returnvalue .= \"" . \Froxlor\UI\Template::getTemplate("formfields/hidden", true) . "\";"); + } + + return $returnvalue; + } + + public static function getFormFieldOutputFile($fieldname, $fielddata, $do_show = true) + { + $label = $fielddata['label']; + $value = htmlentities($fielddata['value']); + eval("\$returnvalue = \"" . \Froxlor\UI\Template::getTemplate("formfields/text", true) . "\";"); + return $returnvalue; + } + + public static function getFormFieldOutputDate($fieldname, $fielddata, $do_show = true) + { + if (isset($fielddata['date_timestamp']) && $fielddata['date_timestamp'] === true) { + $fielddata['value'] = date('Y-m-d', $fielddata['value']); + } + + return self::getFormFieldOutputString($fieldname, $fielddata, $do_show); + } + + public static function getFormFieldOutputBool($fieldname, $fielddata, $do_show = true) + { + $label = $fielddata['label']; + $boolswitch = \Froxlor\UI\HTML::makeyesno($fieldname, '1', '0', $fielddata['value']); + eval("\$returnvalue = \"" . \Froxlor\UI\Template::getTemplate("formfields/bool", true) . "\";"); + return $returnvalue; + } +} \ No newline at end of file diff --git a/lib/Froxlor/UI/Form.php b/lib/Froxlor/UI/Form.php index 6f716d17..e894eb97 100644 --- a/lib/Froxlor/UI/Form.php +++ b/lib/Froxlor/UI/Form.php @@ -9,28 +9,28 @@ class Form public static function buildForm($form) { $fields = ''; - + if (validateFormDefinition($form)) { foreach ($form['groups'] as $groupname => $groupdetails) { if (isset($groupdetails['title']) && $groupdetails['title'] != '') { - $fields .= getFormGroupOutput($groupname, $groupdetails); + $fields .= self::getFormGroupOutput($groupname, $groupdetails); } - + if (validateFieldDefinition($groupdetails)) { // Prefetch form fields foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { - $groupdetails['fields'][$fieldname] = array_merge_prefix($fielddetails, $fielddetails['type'], prefetchFormFieldData($fieldname, $fielddetails)); + $groupdetails['fields'][$fieldname] = self::array_merge_prefix($fielddetails, $fielddetails['type'], prefetchFormFieldData($fieldname, $fielddetails)); $form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname]; } - + // Collect form field output foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { - $fields .= getFormFieldOutput($fieldname, $fielddetails); + $fields .= self::getFormFieldOutput($fieldname, $fielddetails); } } } } - + return $fields; } @@ -43,7 +43,7 @@ class Form // show overview if ($part == '') { if (isset($groupdetails['title']) && $groupdetails['title'] != '') { - $fields .= getFormOverviewGroupOutput($groupname, $groupdetails); + $fields .= self::getFormOverviewGroupOutput($groupname, $groupdetails); } } // only show one section elseif ($part != '' && ($groupname == $part || $part == 'all')) { @@ -70,19 +70,19 @@ class Form // if ($do_show) { if (isset($groupdetails['title']) && $groupdetails['title'] != '') { - $fields .= getFormGroupOutput($groupname, $groupdetails); + $fields .= self::getFormGroupOutput($groupname, $groupdetails); } if (validateFieldDefinition($groupdetails)) { // Prefetch form fields foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { - $groupdetails['fields'][$fieldname] = array_merge_prefix($fielddetails, $fielddetails['type'], prefetchFormFieldData($fieldname, $fielddetails)); + $groupdetails['fields'][$fieldname] = self::array_merge_prefix($fielddetails, $fielddetails['type'], prefetchFormFieldData($fieldname, $fielddetails)); $form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname]; } // Collect form field output foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { - $fields .= getFormFieldOutput($fieldname, $fielddetails); + $fields .= self::getFormFieldOutput($fieldname, $fielddetails); } } // } @@ -92,4 +92,435 @@ class Form return $fields; } + + function processForm(&$form, &$input, $url_params = array()) + { + if (\Froxlor\Validate\Form::validateFormDefinition($form)) { + $submitted_fields = array(); + $changed_fields = array(); + $saved_fields = array(); + + foreach ($form['groups'] as $groupname => $groupdetails) { + if (\Froxlor\Validate\Form::validateFieldDefinition($groupdetails)) { + // Prefetch form fields + foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { + $groupdetails['fields'][$fieldname] = self::array_merge_prefix($fielddetails, $fielddetails['type'], self::prefetchFormFieldData($fieldname, $fielddetails)); + $form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname]; + } + } + } + + foreach ($form['groups'] as $groupname => $groupdetails) { + if (\Froxlor\Validate\Form::validateFieldDefinition($groupdetails)) { + // Validate fields + foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { + $newfieldvalue = self::getFormFieldData($fieldname, $fielddetails, $input); + + if ($newfieldvalue != $fielddetails['value']) { + if (($error = \Froxlor\Validate\Form::validateFormField($fieldname, $fielddetails, $newfieldvalue)) !== true) { + \Froxlor\UI\Response::standard_error($error, $fieldname); + } else { + $changed_fields[$fieldname] = $newfieldvalue; + } + } + + $submitted_fields[$fieldname] = $newfieldvalue; + } + } + } + + foreach ($form['groups'] as $groupname => $groupdetails) { + if (\Froxlor\Validate\Form::validateFieldDefinition($groupdetails)) { + // Check fields for plausibility + foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { + if (($plausibility_check = self::checkPlausibilityFormField($fieldname, $fielddetails, $submitted_fields[$fieldname], $submitted_fields)) !== false) { + if (is_array($plausibility_check) && isset($plausibility_check[0])) { + if ($plausibility_check[0] == FORMFIELDS_PLAUSIBILITY_CHECK_OK) { + // Nothing to do here, everything's okay + } elseif ($plausibility_check[0] == FORMFIELDS_PLAUSIBILITY_CHECK_ERROR) { + unset($plausibility_check[0]); + $error = $plausibility_check[1]; + unset($plausibility_check[1]); + $targetname = implode(' ', $plausibility_check); + \Froxlor\UI\Response::standard_error($error, $targetname); + } elseif ($plausibility_check[0] == FORMFIELDS_PLAUSIBILITY_CHECK_QUESTION) { + unset($plausibility_check[0]); + $question = $plausibility_check[1]; + unset($plausibility_check[1]); + $targetname = implode(' ', $plausibility_check); + if (! isset($input[$question])) { + if (is_array($url_params) && isset($url_params['filename'])) { + $filename = $url_params['filename']; + unset($url_params['filename']); + } else { + $filename = ''; + } + \Froxlor\UI\HTML::ask_yesno($question, $filename, array_merge($url_params, $submitted_fields, array( + $question => $question + )), $targetname); + } + } else { + \Froxlor\UI\Response::standard_error('plausibilitychecknotunderstood'); + } + } + } + } + } + } + + foreach ($form['groups'] as $groupname => $groupdetails) { + if (\Froxlor\Validate\Form::validateFieldDefinition($groupdetails)) { + // Save fields + foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { + if (isset($changed_fields[$fieldname])) { + if (($saved_field = self::saveFormField($fieldname, $fielddetails, manipulateFormFieldData($fieldname, $fielddetails, $changed_fields[$fieldname]))) !== false) { + $saved_fields = array_merge($saved_fields, $saved_field); + } else { + \Froxlor\UI\Response::standard_error('errorwhensaving', $fieldname); + } + } + } + } + } + + // Save form + return self::saveForm($form, $saved_fields); + } + } + + function processFormEx(&$form, &$input, $url_params = array(), $part, $settings_all, $settings_part, $only_enabledisable) + { + if (validateFormDefinition($form)) { + $submitted_fields = array(); + $changed_fields = array(); + $saved_fields = array(); + + foreach ($form['groups'] as $groupname => $groupdetails) { + if (($settings_part && $part == $groupname) || $settings_all || $only_enabledisable) { + if (\Froxlor\Validate\Form::validateFieldDefinition($groupdetails)) { + // Prefetch form fields + foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { + if (! $only_enabledisable || ($only_enabledisable && isset($fielddetails['overview_option']))) { + $groupdetails['fields'][$fieldname] = self::array_merge_prefix($fielddetails, $fielddetails['type'], prefetchFormFieldData($fieldname, $fielddetails)); + $form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname]; + } + } + } + } + } + + foreach ($form['groups'] as $groupname => $groupdetails) { + if (($settings_part && $part == $groupname) || $settings_all || $only_enabledisable) { + if (\Froxlor\Validate\Form::validateFieldDefinition($groupdetails)) { + // Validate fields + foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { + if (! $only_enabledisable || ($only_enabledisable && isset($fielddetails['overview_option']))) { + $newfieldvalue = self::getFormFieldData($fieldname, $fielddetails, $input); + if ($newfieldvalue != $fielddetails['value']) { + if (($error = \Froxlor\Validate\Form::validateFormField($fieldname, $fielddetails, $newfieldvalue)) !== true) { + \Froxlor\UI\Response::standard_error($error, $fieldname); + } else { + $changed_fields[$fieldname] = $newfieldvalue; + } + } + + $submitted_fields[$fieldname] = $newfieldvalue; + } + } + } + } + } + + foreach ($form['groups'] as $groupname => $groupdetails) { + if (($settings_part && $part == $groupname) || $settings_all || $only_enabledisable) { + if (validateFieldDefinition($groupdetails)) { + // Check fields for plausibility + foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { + if (! $only_enabledisable || ($only_enabledisable && isset($fielddetails['overview_option']))) { + if (($plausibility_check = self::checkPlausibilityFormField($fieldname, $fielddetails, $submitted_fields[$fieldname], $submitted_fields)) !== false) { + if (is_array($plausibility_check) && isset($plausibility_check[0])) { + if ($plausibility_check[0] == FORMFIELDS_PLAUSIBILITY_CHECK_OK) { + // Nothing to do here, everything's okay + } elseif ($plausibility_check[0] == FORMFIELDS_PLAUSIBILITY_CHECK_ERROR) { + unset($plausibility_check[0]); + $error = $plausibility_check[1]; + unset($plausibility_check[1]); + $targetname = implode(' ', $plausibility_check); + \Froxlor\UI\Response::standard_error($error, $targetname); + } elseif ($plausibility_check[0] == FORMFIELDS_PLAUSIBILITY_CHECK_QUESTION) { + unset($plausibility_check[0]); + $question = $plausibility_check[1]; + unset($plausibility_check[1]); + $targetname = implode(' ', $plausibility_check); + if (! isset($input[$question])) { + if (is_array($url_params) && isset($url_params['filename'])) { + $filename = $url_params['filename']; + unset($url_params['filename']); + } else { + $filename = ''; + } + \Froxlor\UI\HTML::ask_yesno($question, $filename, array_merge($url_params, $submitted_fields, array( + $question => $question + )), $targetname); + } + } else { + \Froxlor\UI\Response::standard_error('plausibilitychecknotunderstood'); + } + } + } + } + } + } + } + } + + foreach ($form['groups'] as $groupname => $groupdetails) { + if (($settings_part && $part == $groupname) || $settings_all || $only_enabledisable) { + if (validateFieldDefinition($groupdetails)) { + // Save fields + foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { + if (! $only_enabledisable || ($only_enabledisable && isset($fielddetails['overview_option']))) { + if (isset($changed_fields[$fieldname])) { + if (($saved_field = self::saveFormField($fieldname, $fielddetails, manipulateFormFieldData($fieldname, $fielddetails, $changed_fields[$fieldname]))) !== false) { + $saved_fields = array_merge($saved_fields, $saved_field); + } else { + \Froxlor\UI\Response::standard_error('errorwhensaving', $fieldname); + } + } + } + } + } + } + } + + // Save form + return saveForm($form, $saved_fields); + } + } + + public static function saveForm($fielddata, $newfieldvalue) + { + $returnvalue = ''; + if (is_array($fielddata) && isset($fielddata['save_method']) && $fielddata['save_method'] != '') { + $returnvalue = call_user_func(array( + '\\Froxlor\\Settings\\Store', + $fielddata['save_method'] + ), $fielddata, $newfieldvalue); + } elseif (is_array($fielddata) && ! isset($fielddata['save_method'])) { + $returnvalue = true; + } else { + $returnvalue = false; + } + return $returnvalue; + } + + public static function saveFormField($fieldname, $fielddata, $newfieldvalue) + { + $returnvalue = ''; + if (is_array($fielddata) && isset($fielddata['save_method']) && $fielddata['save_method'] != '') { + $returnvalue = call_user_func(array( + '\\Froxlor\\Settings\\Store', + $fielddata['save_method'] + ), $fieldname, $fielddata, $newfieldvalue); + } elseif (is_array($fielddata) && ! isset($fielddata['save_method'])) { + $returnvalue = array(); + } else { + $returnvalue = false; + } + return $returnvalue; + } + + public static function getFormGroupOutput($groupname, $groupdetails) + { + global $lng, $theme; + eval("\$group = \"" . \Froxlor\UI\Template::getTemplate("settings/settings_group") . "\";"); + return $group; + } + + public static function getFormOverviewGroupOutput($groupname, $groupdetails) + { + global $lng, $filename, $s, $theme; + + $group = ''; + $title = $groupdetails['title']; + $part = $groupname; + + $activated = true; + $option = ''; + if (isset($groupdetails['fields'])) { + foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { + if (isset($fielddetails['overview_option']) && $fielddetails['overview_option'] == true) { + if ($fielddetails['type'] != 'option' && $fielddetails['type'] != 'bool') { + \Froxlor\UI\Response::standard_error('overviewsettingoptionisnotavalidfield'); + } + + if ($fielddetails['type'] == 'option') { + $options_array = $fielddetails['option_options']; + $options = ''; + foreach ($options_array as $value => $vtitle) { + $options .= \Froxlor\UI\HTML::makeoption($vtitle, $value, Settings::Get($fielddetails['settinggroup'] . '.' . $fielddetails['varname'])); + } + $option .= $fielddetails['label'] . ': '; + $option .= ''; + $activated = true; + } else { + $option .= $lng['admin']['activated'] . ': '; + $option .= \Froxlor\UI\HTML::makeyesno($fieldname, '1', '0', Settings::Get($fielddetails['settinggroup'] . '.' . $fielddetails['varname'])); + $activated = (int) Settings::Get($fielddetails['settinggroup'] . '.' . $fielddetails['varname']); + } + } + } + } + + /** + * this part checks for the 'websrv_avail' entry in the settings + * if found, we check if the current webserver is in the array. + * If this + * is not the case, we change the setting type to "hidden", #502 + */ + $do_show = true; + if (isset($groupdetails['websrv_avail']) && is_array($groupdetails['websrv_avail'])) { + $websrv = Settings::Get('system.webserver'); + if (! in_array($websrv, $groupdetails['websrv_avail'])) { + $do_show = false; + $title .= sprintf($lng['serversettings']['option_unavailable_websrv'], implode(", ", $groupdetails['websrv_avail'])); + // hack disabled flag into select-box + $option = str_replace(''; - $option .= $options; - $option .= ''; - $activated = true; - } else { - $option .= $lng['admin']['activated'] . ': '; - $option .= \Froxlor\UI\HTML::makeyesno($fieldname, '1', '0', Settings::Get($fielddetails['settinggroup'] . '.' . $fielddetails['varname'])); - $activated = (int) Settings::Get($fielddetails['settinggroup'] . '.' . $fielddetails['varname']); - } - } - } - } - - /** - * this part checks for the 'websrv_avail' entry in the settings - * if found, we check if the current webserver is in the array. - * If this - * is not the case, we change the setting type to "hidden", #502 - */ - $do_show = true; - if (isset($groupdetails['websrv_avail']) && is_array($groupdetails['websrv_avail'])) { - $websrv = Settings::Get('system.webserver'); - if (! in_array($websrv, $groupdetails['websrv_avail'])) { - $do_show = false; - $title .= sprintf($lng['serversettings']['option_unavailable_websrv'], implode(", ", $groupdetails['websrv_avail'])); - // hack disabled flag into select-box - $option = str_replace(''; - - if (isset($fielddata['label']) && $fielddata['label'] != '') { - $label = $fielddata['label']; - $value = htmlentities($fielddata['value']); - eval("\$returnvalue .= \"" . \Froxlor\UI\Template::getTemplate("formfields/hidden", true) . "\";"); - } - - return $returnvalue; -} diff --git a/lib/functions/formfields/hidden/function.validateFormFieldHidden.php b/lib/functions/formfields/hidden/function.validateFormFieldHidden.php deleted file mode 100644 index 0d498813..00000000 --- a/lib/functions/formfields/hidden/function.validateFormFieldHidden.php +++ /dev/null @@ -1,31 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ -function validateFormFieldHidden($fieldname, $fielddata, $newfieldvalue) -{ - /** - * don't show error on cronjob-timestamps changing - * because it might be possible that the cronjob ran - * while settings have been edited (bug #52) - */ - if ($newfieldvalue === $fielddata['value'] || $fieldname == 'system_last_tasks_run' || $fieldname == 'system_last_traffic_run' || $fieldname == 'system_lastcronrun') { - return true; - } else { - return 'hiddenfieldvaluechanged'; - } -} diff --git a/lib/functions/formfields/hiddenstring/function.getFormFieldOutputString.php b/lib/functions/formfields/hiddenstring/function.getFormFieldOutputString.php deleted file mode 100644 index 63e6ebf7..00000000 --- a/lib/functions/formfields/hiddenstring/function.getFormFieldOutputString.php +++ /dev/null @@ -1,25 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ -function getFormFieldOutputHiddenString($fieldname, $fielddata, $do_show = true) -{ - $label = $fielddata['label']; - $value = htmlentities($fielddata['value']); - eval("\$returnvalue = \"" . \Froxlor\UI\Template::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 deleted file mode 100644 index 8b2da25c..00000000 --- a/lib/functions/formfields/hiddenstring/function.validateFormFieldString.php +++ /dev/null @@ -1,86 +0,0 @@ - (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 = \Froxlor\Validate\Form\Strings::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 == \Froxlor\FileDir::makeCorrectDir($newfieldvalue)); - } elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'file') { - $returnvalue = ($newfieldvalue == \Froxlor\FileDir::makeCorrectFile($newfieldvalue)); - } elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'filedir') { - $returnvalue = (($newfieldvalue == \Froxlor\FileDir::makeCorrectDir($newfieldvalue)) || ($newfieldvalue == \Froxlor\FileDir::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; - } -} diff --git a/lib/functions/formfields/int/function.getFormFieldDataInt.php b/lib/functions/formfields/int/function.getFormFieldDataInt.php deleted file mode 100644 index cb53b6e9..00000000 --- a/lib/functions/formfields/int/function.getFormFieldDataInt.php +++ /dev/null @@ -1,28 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ -function getFormFieldDataInt($fieldname, $fielddata, &$input) -{ - if (isset($input[$fieldname])) { - $newfieldvalue = (int) $input[$fieldname]; - } else { - $newfieldvalue = (int) $fielddata['default']; - } - - return $newfieldvalue; -} diff --git a/lib/functions/formfields/int/function.getFormFieldOutputInt.php b/lib/functions/formfields/int/function.getFormFieldOutputInt.php deleted file mode 100644 index 500ec043..00000000 --- a/lib/functions/formfields/int/function.getFormFieldOutputInt.php +++ /dev/null @@ -1,22 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ -function getFormFieldOutputInt($fieldname, $fielddata, $do_show = true) -{ - return getFormFieldOutputString($fieldname, $fielddata, $do_show); -} diff --git a/lib/functions/formfields/int/function.validateFormFieldInt.php b/lib/functions/formfields/int/function.validateFormFieldInt.php deleted file mode 100644 index 3fa31656..00000000 --- a/lib/functions/formfields/int/function.validateFormFieldInt.php +++ /dev/null @@ -1,30 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ -function validateFormFieldInt($fieldname, $fielddata, $newfieldvalue) -{ - if (isset($fielddata['int_min']) && (int) $newfieldvalue < (int) $fielddata['int_min']) { - return ('intvaluetoolow'); - } - - if (isset($fielddata['int_max']) && (int) $newfieldvalue > (int) $fielddata['int_max']) { - return ('intvaluetoohigh'); - } - - return true; -} diff --git a/lib/functions/formfields/option/function.getFormFieldDataOption.php b/lib/functions/formfields/option/function.getFormFieldDataOption.php deleted file mode 100644 index bd92aec6..00000000 --- a/lib/functions/formfields/option/function.getFormFieldDataOption.php +++ /dev/null @@ -1,32 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ -function getFormFieldDataOption($fieldname, $fielddata, &$input) -{ - if (isset($input[$fieldname])) { - $newfieldvalue = $input[$fieldname]; - } else { - $newfieldvalue = $fielddata['default']; - } - - if (is_array($newfieldvalue)) { - $newfieldvalue = implode(',', $newfieldvalue); - } - - return $newfieldvalue; -} diff --git a/lib/functions/formfields/option/function.getFormFieldOutputOption.php b/lib/functions/formfields/option/function.getFormFieldOutputOption.php deleted file mode 100644 index e7a491d5..00000000 --- a/lib/functions/formfields/option/function.getFormFieldOutputOption.php +++ /dev/null @@ -1,41 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ -function getFormFieldOutputOption($fieldname, $fielddata, $do_show = true) -{ - $returnvalue = ''; - - if (isset($fielddata['option_options']) && is_array($fielddata['option_options']) && ! empty($fielddata['option_options'])) { - if (isset($fielddata['option_mode']) && $fielddata['option_mode'] == 'multiple') { - $multiple = true; - $fielddata['value'] = explode(',', $fielddata['value']); - } else { - $multiple = false; - } - - $label = $fielddata['label']; - $options_array = $fielddata['option_options']; - $options = ''; - foreach ($options_array as $value => $title) { - $options .= makeoption($title, $value, $fielddata['value']); - } - eval("\$returnvalue = \"" . \Froxlor\UI\Template::getTemplate("formfields/option", true) . "\";"); - } - - return $returnvalue; -} diff --git a/lib/functions/formfields/option/function.prefetchFormFieldDataOption.php b/lib/functions/formfields/option/function.prefetchFormFieldDataOption.php deleted file mode 100644 index b3254018..00000000 --- a/lib/functions/formfields/option/function.prefetchFormFieldDataOption.php +++ /dev/null @@ -1,28 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ -function prefetchFormFieldDataOption($fieldname, $fielddata) -{ - $returnvalue = array(); - - if ((! isset($fielddata['option_options']) || ! is_array($fielddata['option_options']) || empty($fielddata['option_options'])) && (isset($fielddata['option_options_method']) && function_exists($fielddata['option_options_method']))) { - $returnvalue['options'] = call_user_func($fielddata['option_options_method']); - } - - return $returnvalue; -} diff --git a/lib/functions/formfields/option/function.validateFormFieldOption.php b/lib/functions/formfields/option/function.validateFormFieldOption.php deleted file mode 100644 index 3b6f57be..00000000 --- a/lib/functions/formfields/option/function.validateFormFieldOption.php +++ /dev/null @@ -1,40 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ -function validateFormFieldOption($fieldname, $fielddata, $newfieldvalue) -{ - $returnvalue = true; - - if (isset($fielddata['option_mode']) && $fielddata['option_mode'] == 'multiple') { - $options = explode(',', $newfieldvalue); - foreach ($options as $option) { - $returnvalue = ($returnvalue && isset($fielddata['option_options'][$option])); - } - } else { - $returnvalue = isset($fielddata['option_options'][$newfieldvalue]); - } - - if ($returnvalue === true || $fielddata['visible'] == false) { - return true; - } else { - if (isset($fielddata['option_emptyallowed']) && $fielddata['option_emptyallowed']) { - return true; - } - return 'not in option'; - } -} diff --git a/lib/functions/formfields/string/function.getFormFieldOutputString.php b/lib/functions/formfields/string/function.getFormFieldOutputString.php deleted file mode 100644 index 78c5520e..00000000 --- a/lib/functions/formfields/string/function.getFormFieldOutputString.php +++ /dev/null @@ -1,25 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ -function getFormFieldOutputString($fieldname, $fielddata, $do_show = true) -{ - $label = $fielddata['label']; - $value = htmlentities($fielddata['value']); - eval("\$returnvalue = \"" . \Froxlor\UI\Template::getTemplate("formfields/string", true) . "\";"); - return $returnvalue; -} diff --git a/lib/functions/formfields/text/function.getFormFieldDataText.php b/lib/functions/formfields/text/function.getFormFieldDataText.php deleted file mode 100644 index 0f0aad70..00000000 --- a/lib/functions/formfields/text/function.getFormFieldDataText.php +++ /dev/null @@ -1,26 +0,0 @@ - (2016-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ -function getFormFieldDataText($fieldname, $fielddata, &$input) -{ - if (isset($input[$fieldname])) { - $newfieldvalue = str_replace("\r\n", "\n", $input[$fieldname]); - } else { - $newfieldvalue = $fielddata['default']; - } - - return $newfieldvalue; -} diff --git a/lib/functions/formfields/text/function.getFormFieldOutputText.php b/lib/functions/formfields/text/function.getFormFieldOutputText.php deleted file mode 100644 index d4f75a9e..00000000 --- a/lib/functions/formfields/text/function.getFormFieldOutputText.php +++ /dev/null @@ -1,25 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ -function getFormFieldOutputText($fieldname, $fielddata, $do_show = true) -{ - $label = $fielddata['label']; - $value = htmlentities($fielddata['value']); - eval("\$returnvalue = \"" . \Froxlor\UI\Template::getTemplate("formfields/text", true) . "\";"); - return $returnvalue; -} diff --git a/lib/functions/formfields/text/function.validateFormFieldText.php b/lib/functions/formfields/text/function.validateFormFieldText.php deleted file mode 100644 index a58b7988..00000000 --- a/lib/functions/formfields/text/function.validateFormFieldText.php +++ /dev/null @@ -1,28 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ -function validateFormFieldText($fieldname, $fielddata, $newfieldvalue) -{ - $returnvalue = 'stringformaterror'; - - if (preg_match('/^[^\0]*$/', $newfieldvalue)) { - $returnvalue = true; - } - - return $returnvalue; -} diff --git a/lib/functions/phphelpers/function.array_merge_prefix.php b/lib/functions/phphelpers/function.array_merge_prefix.php deleted file mode 100644 index eefcbe46..00000000 --- a/lib/functions/phphelpers/function.array_merge_prefix.php +++ /dev/null @@ -1,35 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ -function array_merge_prefix($array1, $key_prefix, $array2) -{ - if (is_array($array1) && is_array($array2)) { - if ($key_prefix != '') { - foreach ($array2 as $key => $value) { - $array1[$key_prefix . '_' . $key] = $value; - unset($array2[$key]); - } - unset($array2); - return $array1; - } else { - return array_merge($array1, $array2); - } - } else { - return $array1; - } -} diff --git a/lib/init.php b/lib/init.php index 381539c2..8f75a636 100644 --- a/lib/init.php +++ b/lib/init.php @@ -109,7 +109,8 @@ if (! isset($sql) || ! is_array($sql)) { /** * Includes the Functions */ -require \Froxlor\Froxlor::getInstallDir() . '/lib/functions.php'; +require \Froxlor\Froxlor::getInstallDir() . '/lib/functions/constant.formfields.php'; +require \Froxlor\Froxlor::getInstallDir() . '/lib/functions/constant.logger.php'; @set_error_handler(array( '\\Froxlor\\PhpHelper', 'phpErrHandler'