got rid of all global functions, I guess

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2018-12-22 13:28:51 +01:00
parent 28bb614489
commit 13aa19e5f4
54 changed files with 832 additions and 1534 deletions

View File

@@ -369,7 +369,7 @@ if ($page == 'overview') {
$domains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row_domain['domain']), $row_domain['id'], $result['aliasdomain']); $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') { if (Settings::Get('panel.pathedit') == 'Dropdown') {
$urlvalue = $result['documentroot']; $urlvalue = $result['documentroot'];
$pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);

View File

@@ -104,7 +104,8 @@ class FroxlorInstall
// check if we have a valid installation already // check if we have a valid installation already
$this->_checkUserdataFile(); $this->_checkUserdataFile();
// include the functions // 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 // include the MySQL-Table-Definitions
require $this->_basepath . '/lib/tables.inc.php'; require $this->_basepath . '/lib/tables.inc.php';
// include language // include language

View File

@@ -394,7 +394,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
{ {
if ($errdoc !== null && $errdoc != '') { if ($errdoc !== null && $errdoc != '') {
// not a URL // 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 // a file
if (substr($errdoc, 0, 1) != '"') { if (substr($errdoc, 0, 1) != '"') {
$errdoc = \Froxlor\FileDir::makeCorrectFile($errdoc); $errdoc = \Froxlor\FileDir::makeCorrectFile($errdoc);

View File

@@ -855,7 +855,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
{ {
// check whether an URL was specified // check whether an URL was specified
$_doredirect = false; $_doredirect = false;
if (! empty($url) && \Froxlor\Validate\Form\Strings::validateUrl($url)) { if (! empty($url) && \Froxlor\Validate\Form\Data::validateUrl($url)) {
$path = $url; $path = $url;
$_doredirect = true; $_doredirect = true;
} else { } else {
@@ -863,7 +863,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
} }
// check whether path is a real path // 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) { if (strstr($path, ":") !== false) {
\Froxlor\UI\Response::standard_error('pathmaynotcontaincolon', '', true); \Froxlor\UI\Response::standard_error('pathmaynotcontaincolon', '', true);
} }

View File

@@ -144,7 +144,7 @@ class Apache extends HttpConfigBase
foreach ($statusCodes as $statusCode) { foreach ($statusCodes as $statusCode) {
if (Settings::Get('defaultwebsrverrhandler.err' . $statusCode) != '') { if (Settings::Get('defaultwebsrverrhandler.err' . $statusCode) != '') {
$defhandler = 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) != '"') { if (substr($defhandler, 0, 1) != '"' && substr($defhandler, - 1, 1) != '"') {
$defhandler = '"' . \Froxlor\FileDir::makeCorrectFile($defhandler) . '"'; $defhandler = '"' . \Froxlor\FileDir::makeCorrectFile($defhandler) . '"';
} }
@@ -1190,7 +1190,7 @@ class Apache extends HttpConfigBase
foreach ($statusCodes as $statusCode) { foreach ($statusCodes as $statusCode) {
if (isset($row_diroptions['error' . $statusCode . 'path']) && $row_diroptions['error' . $statusCode . 'path'] != '') { if (isset($row_diroptions['error' . $statusCode . 'path']) && $row_diroptions['error' . $statusCode . 'path'] != '') {
$defhandler = $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) != '"') { if (substr($defhandler, 0, 1) != '"' && substr($defhandler, - 1, 1) != '"') {
$defhandler = '"' . \Froxlor\FileDir::makeCorrectFile($defhandler) . '"'; $defhandler = '"' . \Froxlor\FileDir::makeCorrectFile($defhandler) . '"';
} }

View File

@@ -316,7 +316,7 @@ class Lighttpd extends HttpConfigBase
} }
$defhandler = Settings::Get('defaultwebsrverrhandler.err404'); $defhandler = Settings::Get('defaultwebsrverrhandler.err404');
if (! \Froxlor\Validate\Form\Strings::validateUrl($defhandler)) { if (! \Froxlor\Validate\Form\Data::validateUrl($defhandler)) {
$defhandler = \Froxlor\FileDir::makeCorrectFile($defhandler); $defhandler = \Froxlor\FileDir::makeCorrectFile($defhandler);
} }
$this->lighttpd_data[$vhost_filename] = 'server.error-handler-404 = "' . $defhandler . '"'; $this->lighttpd_data[$vhost_filename] = 'server.error-handler-404 = "' . $defhandler . '"';
@@ -701,7 +701,7 @@ class Lighttpd extends HttpConfigBase
if (! empty($row['error404path'])) { if (! empty($row['error404path'])) {
$defhandler = $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); $defhandler = \Froxlor\FileDir::makeCorrectFile($domain['documentroot'] . '/' . $defhandler);
} }
$error_string .= ' server.error-handler-404 = "' . $defhandler . '"' . "\n\n"; $error_string .= ' server.error-handler-404 = "' . $defhandler . '"' . "\n\n";

View File

@@ -116,7 +116,7 @@ class Nginx extends HttpConfigBase
foreach ($statusCodes as $statusCode) { foreach ($statusCodes as $statusCode) {
if (Settings::Get('defaultwebsrverrhandler.err' . $statusCode) != '') { if (Settings::Get('defaultwebsrverrhandler.err' . $statusCode) != '') {
$defhandler = 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); $defhandler = \Froxlor\FileDir::makeCorrectFile($defhandler);
} }
$this->nginx_data[$vhosts_filename] .= 'error_page ' . $statusCode . ' ' . $defhandler . ';' . "\n"; $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)) { while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
if (! empty($row['error404path'])) { if (! empty($row['error404path'])) {
$defhandler = $row['error404path']; $defhandler = $row['error404path'];
if (! \Froxlor\Validate\Form\Strings::validateUrl($defhandler)) { if (! \Froxlor\Validate\Form\Data::validateUrl($defhandler)) {
$defhandler = \Froxlor\FileDir::makeCorrectFile($defhandler); $defhandler = \Froxlor\FileDir::makeCorrectFile($defhandler);
} }
$path_options .= "\t" . 'error_page 404 ' . $defhandler . ';' . "\n"; $path_options .= "\t" . 'error_page 404 ' . $defhandler . ';' . "\n";
@@ -711,7 +711,7 @@ class Nginx extends HttpConfigBase
if (! empty($row['error403path'])) { if (! empty($row['error403path'])) {
$defhandler = $row['error403path']; $defhandler = $row['error403path'];
if (! \Froxlor\Validate\Form\Strings::validateUrl($defhandler)) { if (! \Froxlor\Validate\Form\Data::validateUrl($defhandler)) {
$defhandler = \Froxlor\FileDir::makeCorrectFile($defhandler); $defhandler = \Froxlor\FileDir::makeCorrectFile($defhandler);
} }
$path_options .= "\t" . 'error_page 403 ' . $defhandler . ';' . "\n"; $path_options .= "\t" . 'error_page 403 ' . $defhandler . ';' . "\n";
@@ -719,7 +719,7 @@ class Nginx extends HttpConfigBase
if (! empty($row['error500path'])) { if (! empty($row['error500path'])) {
$defhandler = $row['error500path']; $defhandler = $row['error500path'];
if (! \Froxlor\Validate\Form\Strings::validateUrl($defhandler)) { if (! \Froxlor\Validate\Form\Data::validateUrl($defhandler)) {
$defhandler = \Froxlor\FileDir::makeCorrectFile($defhandler); $defhandler = \Froxlor\FileDir::makeCorrectFile($defhandler);
} }
$path_options .= "\t" . 'error_page 500 502 503 504 ' . $defhandler . ';' . "\n"; $path_options .= "\t" . 'error_page 500 502 503 504 ' . $defhandler . ';' . "\n";

View File

@@ -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!"); $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 * TRAFFIC AND DISKUSAGE MESSURE
*/ */
@@ -79,9 +77,9 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
$domainlist = array(); $domainlist = array();
$speciallogfile_domainlist = array(); $speciallogfile_domainlist = array();
$result_domainlist_stmt = Database::query(" $result_domainlist_stmt = Database::query("
SELECT `id`, `domain`, `customerid`, `parentdomainid`, `speciallogfile` SELECT `id`, `domain`, `customerid`, `parentdomainid`, `speciallogfile`
FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `aliasdomain` IS NULL AND `email_only` <> '1'; FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `aliasdomain` IS NULL AND `email_only` <> '1';
"); ");
while ($row_domainlist = $result_domainlist_stmt->fetch(\PDO::FETCH_ASSOC)) { while ($row_domainlist = $result_domainlist_stmt->fetch(\PDO::FETCH_ASSOC)) {

63
lib/Froxlor/UI/Data.php Normal file
View File

@@ -0,0 +1,63 @@
<?php
namespace Froxlor\UI;
class Data
{
public static function getFormFieldDataText($fieldname, $fielddata, &$input)
{
if (isset($input[$fieldname])) {
$newfieldvalue = str_replace("\r\n", "\n", $input[$fieldname]);
} else {
$newfieldvalue = $fielddata['default'];
}
return $newfieldvalue;
}
public static 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;
}
public static function getFormFieldDataInt($fieldname, $fielddata, &$input)
{
if (isset($input[$fieldname])) {
$newfieldvalue = (int) $input[$fieldname];
} else {
$newfieldvalue = (int) $fielddata['default'];
}
return $newfieldvalue;
}
public static function getFormFieldDataBool($fieldname, $fielddata, &$input)
{
if (isset($input[$fieldname]) && ($input[$fieldname] === '1' || $input[$fieldname] === 1 || $input[$fieldname] === true || strtolower($input[$fieldname]) === 'yes' || strtolower($input[$fieldname]) === 'ja')) {
$newfieldvalue = '1';
} else {
$newfieldvalue = '0';
}
return $newfieldvalue;
}
public static function manipulateFormFieldDataDate($fieldname, $fielddata, $newfieldvalue)
{
if (isset($fielddata['date_timestamp']) && $fielddata['date_timestamp'] === true) {
$newfieldvalue = strtotime($newfieldvalue);
}
return $newfieldvalue;
}
}

108
lib/Froxlor/UI/Fields.php Normal file
View File

@@ -0,0 +1,108 @@
<?php
namespace Froxlor\UI;
class Fields
{
public static 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;
}
public static 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;
}
public static 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 .= \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 = '<input type="hidden" name="' . $fieldname . '" value="' . htmlentities($fielddata['value']) . '" />';
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;
}
}

View File

@@ -9,28 +9,28 @@ class Form
public static function buildForm($form) public static function buildForm($form)
{ {
$fields = ''; $fields = '';
if (validateFormDefinition($form)) { if (validateFormDefinition($form)) {
foreach ($form['groups'] as $groupname => $groupdetails) { foreach ($form['groups'] as $groupname => $groupdetails) {
if (isset($groupdetails['title']) && $groupdetails['title'] != '') { if (isset($groupdetails['title']) && $groupdetails['title'] != '') {
$fields .= getFormGroupOutput($groupname, $groupdetails); $fields .= self::getFormGroupOutput($groupname, $groupdetails);
} }
if (validateFieldDefinition($groupdetails)) { if (validateFieldDefinition($groupdetails)) {
// Prefetch form fields // Prefetch form fields
foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { 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]; $form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname];
} }
// Collect form field output // Collect form field output
foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { foreach ($groupdetails['fields'] as $fieldname => $fielddetails) {
$fields .= getFormFieldOutput($fieldname, $fielddetails); $fields .= self::getFormFieldOutput($fieldname, $fielddetails);
} }
} }
} }
} }
return $fields; return $fields;
} }
@@ -43,7 +43,7 @@ class Form
// show overview // show overview
if ($part == '') { if ($part == '') {
if (isset($groupdetails['title']) && $groupdetails['title'] != '') { if (isset($groupdetails['title']) && $groupdetails['title'] != '') {
$fields .= getFormOverviewGroupOutput($groupname, $groupdetails); $fields .= self::getFormOverviewGroupOutput($groupname, $groupdetails);
} }
} // only show one section } // only show one section
elseif ($part != '' && ($groupname == $part || $part == 'all')) { elseif ($part != '' && ($groupname == $part || $part == 'all')) {
@@ -70,19 +70,19 @@ class Form
// if ($do_show) { // if ($do_show) {
if (isset($groupdetails['title']) && $groupdetails['title'] != '') { if (isset($groupdetails['title']) && $groupdetails['title'] != '') {
$fields .= getFormGroupOutput($groupname, $groupdetails); $fields .= self::getFormGroupOutput($groupname, $groupdetails);
} }
if (validateFieldDefinition($groupdetails)) { if (validateFieldDefinition($groupdetails)) {
// Prefetch form fields // Prefetch form fields
foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { 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]; $form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname];
} }
// Collect form field output // Collect form field output
foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { foreach ($groupdetails['fields'] as $fieldname => $fielddetails) {
$fields .= getFormFieldOutput($fieldname, $fielddetails); $fields .= self::getFormFieldOutput($fieldname, $fielddetails);
} }
} }
// } // }
@@ -92,4 +92,435 @@ class Form
return $fields; 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'] . ':&nbsp;';
$option .= '<select class="dropdown_noborder" name="' . $fieldname . '">';
$option .= $options;
$option .= '</select>';
$activated = true;
} else {
$option .= $lng['admin']['activated'] . ':&nbsp;';
$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('<select class', '<select disabled="disabled" class', $option);
}
}
eval("\$group = \"" . \Froxlor\UI\Template::getTemplate("settings/settings_overviewgroup") . "\";");
return $group;
}
public static function getFormFieldOutput($fieldname, $fielddata)
{
global $lng;
$returnvalue = '';
if (is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '' && method_exists('\\Froxlor\\UI\\Fields', 'getFormFieldOutput' . ucfirst($fielddata['type']))) {
if (isset($fielddata['label']) && is_array($fielddata['label'])) {
if (isset($fielddata['label']['title']) && isset($fielddata['label']['description'])) {
$fielddata['label'] = '<b>' . $fielddata['label']['title'] . '</b><br />' . $fielddata['label']['description'];
} else {
$fielddata['label'] = implode(' ', $fielddata['label']);
}
}
if (! isset($fielddata['value'])) {
if (isset($fielddata['default'])) {
$fielddata['value'] = $fielddata['default'];
} else {
$fielddata['value'] = null;
}
}
/**
* this part checks for the 'websrv_avail' entry in the settings-array
* 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($fielddata['websrv_avail']) && is_array($fielddata['websrv_avail'])) {
$websrv = Settings::Get('system.webserver');
if (! in_array($websrv, $fielddata['websrv_avail'])) {
$do_show = false;
$fielddata['label'] .= sprintf($lng['serversettings']['option_unavailable_websrv'], implode(", ", $fielddata['websrv_avail']));
}
}
// visible = Settings::Get('phpfpm.enabled') for example would result in false if not enabled
// and therefore not shown as intended. Only check if do_show is still true as it might
// be false due to websrv_avail
if (isset($fielddata['visible']) && $do_show) {
$do_show = $fielddata['visible'];
if (! $do_show) {
$fielddata['label'] .= $lng['serversettings']['option_unavailable'];
}
}
// if ($do_show) {
$returnvalue = call_user_func(array(
'\\Froxlor\\UI\\Fields',
'getFormFieldOutput' . ucfirst($fielddata['type'])
), $fieldname, $fielddata, $do_show);
// }
}
return $returnvalue;
}
public static function prefetchFormFieldData($fieldname, $fielddata)
{
$returnvalue = array();
if (is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '' && method_exists('\\Froxlor\\UI\\Fields', 'prefetchFormFieldData' . ucfirst($fielddata['type']))) {
$returnvalue = call_user_func(array(
'\\Froxlor\\UI\\Fields',
'prefetchFormFieldData' . ucfirst($fielddata['type'])
), $fieldname, $fielddata);
}
return $returnvalue;
}
public static function getFormFieldData($fieldname, $fielddata, &$input)
{
if (is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '' && method_exists('\\Froxlor\\UI\\Data', 'getFormFieldData' . ucfirst($fielddata['type']))) {
$gfdFunc = '\\Froxlor\\UI\\Data::getFormFieldData' . ucfirst($fielddata['type']);
$newfieldvalue = $gfdFunc($fieldname, $fielddata, $input);
} else {
if (isset($input[$fieldname])) {
$newfieldvalue = $input[$fieldname];
} elseif (isset($fielddata['default'])) {
$newfieldvalue = $fielddata['default'];
} else {
$newfieldvalue = false;
}
}
return trim($newfieldvalue);
}
public static function manipulateFormFieldData($fieldname, $fielddata, $newfieldvalue)
{
if (is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '' && method_exists('\\Froxlor\\UI\\Data', 'manipulateFormFieldData' . ucfirst($fielddata['type']))) {
$newfieldvalue = call_user_func(array(
'\\Froxlor\\UI\\Data',
'manipulateFormFieldData' . ucfirst($fielddata['type'])
), $fieldname, $fielddata, $newfieldvalue);
}
return $newfieldvalue;
}
public static function checkPlausibilityFormField($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
{
$returnvalue = '';
if (is_array($fielddata) && isset($fielddata['plausibility_check_method']) && $fielddata['plausibility_check_method'] != '' && method_exists($fielddata['plausibility_check_method'][0], $fielddata['plausibility_check_method'][1])) {
$returnvalue = call_user_func($fielddata['plausibility_check_method'], $fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues);
} else {
$returnvalue = false;
}
return $returnvalue;
}
private static 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;
}
}
} }

View File

@@ -0,0 +1,42 @@
<?php
namespace Froxlor\Validate;
class Form
{
public static function validateFormDefinition($form)
{
$returnvalue = false;
if (is_array($form) && ! empty($form) && isset($form['groups']) && is_array($form['groups']) && ! empty($form['groups'])) {
$returnvalue = true;
}
return $returnvalue;
}
public static function validateFieldDefinition($field)
{
$returnvalue = false;
if (is_array($field) && ! empty($field) && isset($field['fields']) && is_array($field['fields']) && ! empty($field['fields'])) {
$returnvalue = true;
}
return $returnvalue;
}
public static function validateFormField($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = '';
if (is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '' && method_exists('\\Froxlor\\Validate\\Form\\Data', 'validateFormField' . ucfirst($fielddata['type']))) {
$returnvalue = call_user_func(array(
'\\Froxlor\\Validate\\Form\\Data',
'validateFormField' . ucfirst($fielddata['type'])
), $fieldname, $fielddata, $newfieldvalue);
} else {
$returnvalue = 'validation method not found';
}
return $returnvalue;
}
}

View File

@@ -1,7 +1,7 @@
<?php <?php
namespace Froxlor\Validate\Form; namespace Froxlor\Validate\Form;
class Strings class Data
{ {
public static function validateFormFieldString($fieldname, $fielddata, $newfieldvalue) public static function validateFormFieldString($fieldname, $fielddata, $newfieldvalue)
@@ -183,4 +183,159 @@ class Strings
return false; return false;
} }
} }
public static function validateFormFieldBool($fieldname, $fielddata, $newfieldvalue)
{
if ($newfieldvalue === '1' || $newfieldvalue === 1 || $newfieldvalue === true || strtolower($newfieldvalue) === 'yes' || strtolower($newfieldvalue) === 'ja' || $newfieldvalue === '0' || $newfieldvalue === 0 || $newfieldvalue === false || strtolower($newfieldvalue) === 'no' || strtolower($newfieldvalue) === 'nein' || strtolower($newfieldvalue) === '') {
return true;
} else {
return 'noboolean';
}
}
public static function validateFormFieldDate($fieldname, $fielddata, $newfieldvalue)
{
if ($newfieldvalue == '0000-00-00' || preg_match('/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', $newfieldvalue)) {
$returnvalue = true;
} else {
$returnvalue = false;
}
return $returnvalue;
}
public static function validateFormFieldFile($fieldname, $fielddata, $newfieldvalue)
{
return true;
}
public static 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';
}
}
public static 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 = \Froxlor\Validate\Form\Data::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\Data::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;
}
}
public static 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;
}
public static 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';
}
}
public static function validateFormFieldText($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = 'stringformaterror';
if (preg_match('/^[^\0]*$/', $newfieldvalue)) {
$returnvalue = true;
}
return $returnvalue;
}
} }

View File

@@ -73,7 +73,8 @@ if (isset($sql['root_user']) && isset($sql['root_password']) && (! isset($sql_ro
} }
// Includes the Functions // 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';
// Includes the MySQL-Tabledefinitions etc. // Includes the MySQL-Tabledefinitions etc.
require \Froxlor\Froxlor::getInstallDir() . '/lib/tables.inc.php'; require \Froxlor\Froxlor::getInstallDir() . '/lib/tables.inc.php';

View File

@@ -1,127 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
$libdirname = dirname(__FILE__);
includeFunctions($libdirname . '/functions/');
function includeFunctions($dirname)
{
$dirhandle = opendir($dirname);
while (false !== ($filename = readdir($dirhandle))) {
if ($filename != '.' && $filename != '..' && $filename != '') {
if ((substr($filename, 0, 9) == 'function.' || substr($filename, 0, 9) == 'constant.') && substr($filename, - 4) == '.php') {
include ($dirname . $filename);
}
if (is_dir($dirname . $filename)) {
includeFunctions($dirname . $filename . '/');
}
}
}
closedir($dirhandle);
}
Autoloader::init();
/**
* Class Autoloader
*
* iterates through given directory and includes
* the file which matches $classname
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2013-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Autoloader
* @since 0.9.29.1
*/
class Autoloader
{
/**
* returns a new AutoLoader-object
*
* @return Autoloader
*/
public static function init()
{
return new self();
}
/**
* class constructor
*
* @return null
*/
public function __construct()
{
// register autoload.function
spl_autoload_register(array(
$this,
'doAutoload'
));
}
/**
* gets the class to load as parameter, searches the library-paths
* recursively for this class and includes it
*
* @param string $class
*
* @throws Exception
* @return boolean
*/
public function doAutoload($class)
{
// define the paths where to look for classes
$paths = array(
dirname(dirname(__FILE__)) . '/install/'
);
// don't load anything from a namespace, it's not our responsibility
if (strpos($class, "\\") !== false) {
return true;
}
// now iterate through the paths
foreach ($paths as $path) {
// valid directory?
if (is_dir($path)) {
// create RecursiveIteratorIterator
$its = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
// check every file
foreach ($its as $fullFileName => $it) {
// does it match the Filename pattern?
if (preg_match("/^(class|module|interface|abstract|)\.?$class\.php$/i", $it->getFilename())) {
// include the file and return from the loop
include_once $fullFileName;
return true;
}
}
} else {
// yikes - no valid directory to check
throw new Exception("Cannot autoload from directory '" . $path . "'. No such directory.");
}
}
// yikes - class not found
throw new Exception("Could not find class '" . $class . "'");
}
}

View File

@@ -1,28 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function getFormFieldDataBool($fieldname, $fielddata, &$input)
{
if (isset($input[$fieldname]) && ($input[$fieldname] === '1' || $input[$fieldname] === 1 || $input[$fieldname] === true || strtolower($input[$fieldname]) === 'yes' || strtolower($input[$fieldname]) === 'ja')) {
$newfieldvalue = '1';
} else {
$newfieldvalue = '0';
}
return $newfieldvalue;
}

View File

@@ -1,25 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function getFormFieldOutputBool($fieldname, $fielddata, $do_show = true)
{
$label = $fielddata['label'];
$boolswitch = makeYesNo($fieldname, '1', '0', $fielddata['value']);
eval("\$returnvalue = \"" . \Froxlor\UI\Template::getTemplate("formfields/bool", true) . "\";");
return $returnvalue;
}

View File

@@ -1,26 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function validateFormFieldBool($fieldname, $fielddata, $newfieldvalue)
{
if ($newfieldvalue === '1' || $newfieldvalue === 1 || $newfieldvalue === true || strtolower($newfieldvalue) === 'yes' || strtolower($newfieldvalue) === 'ja' || $newfieldvalue === '0' || $newfieldvalue === 0 || $newfieldvalue === false || strtolower($newfieldvalue) === 'no' || strtolower($newfieldvalue) === 'nein' || strtolower($newfieldvalue) === '') {
return true;
} else {
return 'noboolean';
}
}

View File

@@ -1,26 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
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 getFormFieldOutputString($fieldname, $fielddata, $do_show);
}

View File

@@ -1,26 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function manipulateFormFieldDataDate($fieldname, $fielddata, $newfieldvalue)
{
if (isset($fielddata['date_timestamp']) && $fielddata['date_timestamp'] === true) {
$newfieldvalue = strtotime($newfieldvalue);
}
return $newfieldvalue;
}

View File

@@ -1,28 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function validateFormFieldDate($fieldname, $fielddata, $newfieldvalue)
{
if ($newfieldvalue == '0000-00-00' || preg_match('/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', $newfieldvalue)) {
$returnvalue = true;
} else {
$returnvalue = false;
}
return $returnvalue;
}

View File

@@ -1,23 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
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;
}

View File

@@ -1,20 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function validateFormFieldFile($fieldname, $fielddata, $newfieldvalue)
{
return true;
}

View File

@@ -1,28 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function checkPlausibilityFormField($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
{
$returnvalue = '';
if (is_array($fielddata) && isset($fielddata['plausibility_check_method']) && $fielddata['plausibility_check_method'] != '' && function_exists($fielddata['plausibility_check_method'])) {
$returnvalue = call_user_func($fielddata['plausibility_check_method'], $fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues);
} else {
$returnvalue = false;
}
return $returnvalue;
}

View File

@@ -1,35 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function getFormFieldData($fieldname, $fielddata, &$input)
{
if (is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '' && function_exists('getFormFieldData' . ucfirst($fielddata['type']))) {
$gfdFunc = 'getFormFieldData' . ucfirst($fielddata['type']);
$newfieldvalue = $gfdFunc($fieldname, $fielddata, $input);
} else {
if (isset($input[$fieldname])) {
$newfieldvalue = $input[$fieldname];
} elseif (isset($fielddata['default'])) {
$newfieldvalue = $fielddata['default'];
} else {
$newfieldvalue = false;
}
}
return trim($newfieldvalue);
}

View File

@@ -1,71 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function getFormFieldOutput($fieldname, $fielddata)
{
global $lng;
$returnvalue = '';
if (is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '' && function_exists('getFormFieldOutput' . ucfirst($fielddata['type']))) {
if (isset($fielddata['label']) && is_array($fielddata['label'])) {
if (isset($fielddata['label']['title']) && isset($fielddata['label']['description'])) {
$fielddata['label'] = '<b>' . $fielddata['label']['title'] . '</b><br />' . $fielddata['label']['description'];
} else {
$fielddata['label'] = implode(' ', $fielddata['label']);
}
}
if (! isset($fielddata['value'])) {
if (isset($fielddata['default'])) {
$fielddata['value'] = $fielddata['default'];
} else {
$fielddata['value'] = null;
}
}
/**
* this part checks for the 'websrv_avail' entry in the settings-array
* 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($fielddata['websrv_avail']) && is_array($fielddata['websrv_avail'])) {
$websrv = Settings::Get('system.webserver');
if (! in_array($websrv, $fielddata['websrv_avail'])) {
$do_show = false;
$fielddata['label'] .= sprintf($lng['serversettings']['option_unavailable_websrv'], implode(", ", $fielddata['websrv_avail']));
}
}
// visible = Settings::Get('phpfpm.enabled') for example would result in false if not enabled
// and therefore not shown as intended. Only check if do_show is still true as it might
// be false due to websrv_avail
if (isset($fielddata['visible']) && $do_show) {
$do_show = $fielddata['visible'];
if (! $do_show) {
$fielddata['label'] .= $lng['serversettings']['option_unavailable'];
}
}
// if ($do_show) {
$returnvalue = call_user_func('getFormFieldOutput' . ucfirst($fielddata['type']), $fieldname, $fielddata, $do_show);
// }
}
return $returnvalue;
}

View File

@@ -1,83 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function getFormGroupOutput($groupname, $groupdetails)
{
global $lng, $theme;
eval("\$group = \"" . \Froxlor\UI\Template::getTemplate("settings/settings_group") . "\";");
return $group;
}
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 .= makeoption($vtitle, $value, Settings::Get($fielddetails['settinggroup'] . '.' . $fielddetails['varname']));
}
$option .= $fielddetails['label'] . ':&nbsp;';
$option .= '<select class="dropdown_noborder" name="' . $fieldname . '">';
$option .= $options;
$option .= '</select>';
$activated = true;
} else {
$option .= $lng['admin']['activated'] . ':&nbsp;';
$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('<select class', '<select disabled="disabled" class', $option);
}
}
eval("\$group = \"" . \Froxlor\UI\Template::getTemplate("settings/settings_overviewgroup") . "\";");
return $group;
}

View File

@@ -1,26 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function manipulateFormFieldData($fieldname, $fielddata, $newfieldvalue)
{
if (is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '' && function_exists('manipulateFormFieldData' . ucfirst($fielddata['type']))) {
$newfieldvalue = call_user_func('manipulateFormFieldData' . ucfirst($fielddata['type']), $fieldname, $fielddata, $newfieldvalue);
}
return $newfieldvalue;
}

View File

@@ -1,26 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function prefetchFormFieldData($fieldname, $fielddata)
{
$returnvalue = array();
if (is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '' && function_exists('prefetchFormFieldData' . ucfirst($fielddata['type']))) {
$returnvalue = call_user_func('prefetchFormFieldData' . ucfirst($fielddata['type']), $fieldname, $fielddata);
}
return $returnvalue;
}

View File

@@ -1,222 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function processForm(&$form, &$input, $url_params = array())
{
if (validateFormDefinition($form)) {
$submitted_fields = array();
$changed_fields = array();
$saved_fields = array();
foreach ($form['groups'] as $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));
$form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname];
}
}
}
foreach ($form['groups'] as $groupname => $groupdetails) {
if (validateFieldDefinition($groupdetails)) {
// Validate fields
foreach ($groupdetails['fields'] as $fieldname => $fielddetails) {
$newfieldvalue = getFormFieldData($fieldname, $fielddetails, $input);
if ($newfieldvalue != $fielddetails['value']) {
if (($error = 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 (validateFieldDefinition($groupdetails)) {
// Check fields for plausibility
foreach ($groupdetails['fields'] as $fieldname => $fielddetails) {
if (($plausibility_check = 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 (validateFieldDefinition($groupdetails)) {
// Save fields
foreach ($groupdetails['fields'] as $fieldname => $fielddetails) {
if (isset($changed_fields[$fieldname])) {
if (($saved_field = 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);
}
}
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 (validateFieldDefinition($groupdetails)) {
// Prefetch form fields
foreach ($groupdetails['fields'] as $fieldname => $fielddetails) {
if (! $only_enabledisable || ($only_enabledisable && isset($fielddetails['overview_option']))) {
$groupdetails['fields'][$fieldname] = 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 (validateFieldDefinition($groupdetails)) {
// Validate fields
foreach ($groupdetails['fields'] as $fieldname => $fielddetails) {
if (! $only_enabledisable || ($only_enabledisable && isset($fielddetails['overview_option']))) {
$newfieldvalue = getFormFieldData($fieldname, $fielddetails, $input);
if ($newfieldvalue != $fielddetails['value']) {
if (($error = 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 = 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 = 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);
}
}

View File

@@ -1,33 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
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;
}

View File

@@ -1,33 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
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;
}

View File

@@ -1,28 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function validateFieldDefinition($field)
{
$returnvalue = false;
if (is_array($field) && ! empty($field) && isset($field['fields']) && is_array($field['fields']) && ! empty($field['fields'])) {
$returnvalue = true;
}
return $returnvalue;
}

View File

@@ -1,28 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function validateFormDefinition($form)
{
$returnvalue = false;
if (is_array($form) && ! empty($form) && isset($form['groups']) && is_array($form['groups']) && ! empty($form['groups'])) {
$returnvalue = true;
}
return $returnvalue;
}

View File

@@ -1,28 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function validateFormField($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = '';
if (is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '' && function_exists('validateFormField' . ucfirst($fielddata['type']))) {
$returnvalue = call_user_func('validateFormField' . ucfirst($fielddata['type']), $fieldname, $fielddata, $newfieldvalue);
} else {
$returnvalue = 'validation method not found';
}
return $returnvalue;
}

View File

@@ -1,30 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function getFormFieldOutputHidden($fieldname, $fielddata)
{
$returnvalue = '<input type="hidden" name="' . $fieldname . '" value="' . htmlentities($fielddata['value']) . '" />';
if (isset($fielddata['label']) && $fielddata['label'] != '') {
$label = $fielddata['label'];
$value = htmlentities($fielddata['value']);
eval("\$returnvalue .= \"" . \Froxlor\UI\Template::getTemplate("formfields/hidden", true) . "\";");
}
return $returnvalue;
}

View File

@@ -1,31 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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';
}
}

View File

@@ -1,25 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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;
}

View File

@@ -1,86 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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;
}
}

View File

@@ -1,28 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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;
}

View File

@@ -1,22 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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);
}

View File

@@ -1,30 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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;
}

View File

@@ -1,32 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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;
}

View File

@@ -1,41 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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;
}

View File

@@ -1,28 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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;
}

View File

@@ -1,40 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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';
}
}

View File

@@ -1,25 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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;
}

View File

@@ -1,26 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Daniel Reichelt <hacking@nachtgeist.net> (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;
}

View File

@@ -1,25 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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;
}

View File

@@ -1,28 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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;
}

View File

@@ -1,35 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (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;
}
}

View File

@@ -109,7 +109,8 @@ if (! isset($sql) || ! is_array($sql)) {
/** /**
* Includes the Functions * 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( @set_error_handler(array(
'\\Froxlor\\PhpHelper', '\\Froxlor\\PhpHelper',
'phpErrHandler' 'phpErrHandler'