diff --git a/admin_domains.php b/admin_domains.php index a9a87645..bec5f65c 100644 --- a/admin_domains.php +++ b/admin_domains.php @@ -648,8 +648,8 @@ if ($page == 'domains' || $page == 'overview') { if (isset($_POST['send']) && $_POST['send'] == 'send') { $customerid = intval($_POST['customerid']); - $separator = validate($_POST['separator'], 'separator'); - $offset = (int) validate($_POST['offset'], 'offset', "/[0-9]/i"); + $separator = \Froxlor\Validate\Validate::validate($_POST['separator'], 'separator'); + $offset = (int) \Froxlor\Validate\Validate::validate($_POST['offset'], 'offset', "/[0-9]/i"); $file_name = $_FILES['file']['tmp_name']; diff --git a/admin_index.php b/admin_index.php index 64a8659b..5dd4a1bf 100644 --- a/admin_index.php +++ b/admin_index.php @@ -177,14 +177,14 @@ if ($page == 'overview') { } elseif ($page == 'change_password') { if (isset($_POST['send']) && $_POST['send'] == 'send') { - $old_password = validate($_POST['old_password'], 'old password'); + $old_password = \Froxlor\Validate\Validate::validate($_POST['old_password'], 'old password'); if (! validatePasswordLogin($userinfo, $old_password, TABLE_PANEL_ADMINS, 'adminid')) { \Froxlor\UI\Response::standard_error('oldpasswordnotcorrect'); } - $new_password = validate($_POST['new_password'], 'new password'); - $new_password_confirm = validate($_POST['new_password_confirm'], 'new password confirm'); + $new_password = \Froxlor\Validate\Validate::validate($_POST['new_password'], 'new password'); + $new_password_confirm = \Froxlor\Validate\Validate::validate($_POST['new_password_confirm'], 'new password confirm'); if ($old_password == '') { \Froxlor\UI\Response::standard_error(array( @@ -223,7 +223,7 @@ if ($page == 'overview') { } elseif ($page == 'change_language') { if (isset($_POST['send']) && $_POST['send'] == 'send') { - $def_language = validate($_POST['def_language'], 'default language'); + $def_language = \Froxlor\Validate\Validate::validate($_POST['def_language'], 'default language'); if (isset($languages[$def_language])) { try { @@ -267,7 +267,7 @@ if ($page == 'overview') { } elseif ($page == 'change_theme') { if (isset($_POST['send']) && $_POST['send'] == 'send') { - $theme = validate($_POST['theme'], 'theme'); + $theme = \Froxlor\Validate\Validate::validate($_POST['theme'], 'theme'); try { Admins::getLocal($userinfo, array( 'id' => $userinfo['adminid'], diff --git a/admin_plans.php b/admin_plans.php index 0f7d111c..a54bc3aa 100644 --- a/admin_plans.php +++ b/admin_plans.php @@ -102,8 +102,8 @@ if ($page == '' || $page == 'overview') { } elseif ($action == 'add') { if (isset($_POST['send']) && $_POST['send'] == 'send') { - $name = validate($_POST['name'], 'name'); - $description = validate(str_replace("\r\n", "\n", $_POST['description']), 'description', '/^[^\0]*$/'); + $name = \Froxlor\Validate\Validate::validate($_POST['name'], 'name'); + $description = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $_POST['description']), 'description', '/^[^\0]*$/'); $value_arr = array(); @@ -138,7 +138,7 @@ if ($page == '' || $page == 'overview') { } if (Settings::Get('system.mail_quota_enabled') == '1') { - $value_arr['email_quota'] = validate($_POST['email_quota'], 'email_quota', '/^\d+$/', 'vmailquotawrong', array( + $value_arr['email_quota'] = \Froxlor\Validate\Validate::validate($_POST['email_quota'], 'email_quota', '/^\d+$/', 'vmailquotawrong', array( '0', '' )); @@ -280,8 +280,8 @@ if ($page == '' || $page == 'overview') { if (isset($_POST['send']) && $_POST['send'] == 'send') { - $name = validate($_POST['name'], 'name'); - $description = validate(str_replace("\r\n", "\n", $_POST['description']), 'description', '/^[^\0]*$/'); + $name = \Froxlor\Validate\Validate::validate($_POST['name'], 'name'); + $description = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $_POST['description']), 'description', '/^[^\0]*$/'); $value_arr = array(); @@ -316,7 +316,7 @@ if ($page == '' || $page == 'overview') { } if (Settings::Get('system.mail_quota_enabled') == '1') { - $value_arr['email_quota'] = validate($_POST['email_quota'], 'email_quota', '/^\d+$/', 'vmailquotawrong', array( + $value_arr['email_quota'] = \Froxlor\Validate\Validate::validate($_POST['email_quota'], 'email_quota', '/^\d+$/', 'vmailquotawrong', array( '0', '' )); diff --git a/admin_templates.php b/admin_templates.php index 0f011077..911fb8c3 100644 --- a/admin_templates.php +++ b/admin_templates.php @@ -207,16 +207,16 @@ if ($action == '') { if (isset($_POST['prepare']) && $_POST['prepare'] == 'prepare') { // email templates - $language = htmlentities(validate($_POST['language'], 'language', '/^[^\r\n\0"\']+$/', 'nolanguageselect')); - $template = validate($_POST['template'], 'template'); + $language = htmlentities(\Froxlor\Validate\Validate::validate($_POST['language'], 'language', '/^[^\r\n\0"\']+$/', 'nolanguageselect')); + $template = \Froxlor\Validate\Validate::validate($_POST['template'], 'template'); $lng_bak = $lng; foreach ($langs['English'] as $key => $value) { - include_once makeSecurePath($value['file']); + include_once \Froxlor\FileDir::makeSecurePath($value['file']); } if ($language != 'English') { foreach ($langs[$language] as $key => $value) { - include makeSecurePath($value['file']); + include \Froxlor\FileDir::makeSecurePath($value['file']); } } @@ -234,10 +234,10 @@ if ($action == '') { eval("echo \"" . \Froxlor\UI\Template::getTemplate("templates/templates_add_2") . "\";"); } elseif (isset($_POST['send']) && $_POST['send'] == 'send') { // email templates - $language = htmlentities(validate($_POST['language'], 'language', '/^[^\r\n\0"\']+$/', 'nolanguageselect')); - $template = validate($_POST['template'], 'template'); - $subject = validate($_POST['subject'], 'subject', '/^[^\r\n\0]+$/', 'nosubjectcreate'); - $mailbody = validate($_POST['mailbody'], 'mailbody', '/^[^\0]+$/', 'nomailbodycreate'); + $language = htmlentities(\Froxlor\Validate\Validate::validate($_POST['language'], 'language', '/^[^\r\n\0"\']+$/', 'nolanguageselect')); + $template = \Froxlor\Validate\Validate::validate($_POST['template'], 'template'); + $subject = \Froxlor\Validate\Validate::validate($_POST['subject'], 'subject', '/^[^\r\n\0]+$/', 'nosubjectcreate'); + $mailbody = \Froxlor\Validate\Validate::validate($_POST['mailbody'], 'mailbody', '/^[^\0]+$/', 'nomailbodycreate'); $templates = array(); $result_stmt = Database::prepare(" SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` @@ -290,8 +290,8 @@ if ($action == '') { } } elseif (isset($_POST['filesend']) && $_POST['filesend'] == 'filesend') { // file templates - $template = validate($_POST['template'], 'template'); - $filecontent = validate($_POST['filecontent'], 'filecontent', '/^[^\0]+$/', 'filecontentnotset'); + $template = \Froxlor\Validate\Validate::validate($_POST['template'], 'template'); + $filecontent = \Froxlor\Validate\Validate::validate($_POST['filecontent'], 'filecontent', '/^[^\0]+$/', 'filecontentnotset'); $ins_stmt = Database::prepare(" INSERT INTO `" . TABLE_PANEL_TEMPLATES . "` SET @@ -399,8 +399,8 @@ if ($action == '') { if ($result['varname'] != '') { if (isset($_POST['send']) && $_POST['send'] == 'send') { - $subject = validate($_POST['subject'], 'subject', '/^[^\r\n\0]+$/', 'nosubjectcreate'); - $mailbody = validate($_POST['mailbody'], 'mailbody', '/^[^\0]+$/', 'nomailbodycreate'); + $subject = \Froxlor\Validate\Validate::validate($_POST['subject'], 'subject', '/^[^\r\n\0]+$/', 'nosubjectcreate'); + $mailbody = \Froxlor\Validate\Validate::validate($_POST['mailbody'], 'mailbody', '/^[^\0]+$/', 'nomailbodycreate'); $upd_stmt = Database::prepare(" UPDATE `" . TABLE_PANEL_TEMPLATES . "` SET @@ -470,7 +470,7 @@ if ($action == '') { // filetemplates if (isset($_POST['filesend']) && $_POST['filesend'] == 'filesend') { - $filecontent = validate($_POST['filecontent'], 'filecontent', '/^[^\0]+$/', 'filecontentnotset'); + $filecontent = \Froxlor\Validate\Validate::validate($_POST['filecontent'], 'filecontent', '/^[^\0]+$/', 'filecontentnotset'); $upd_stmt = Database::prepare(" UPDATE `" . TABLE_PANEL_TEMPLATES . "` SET `value` = :value diff --git a/customer_index.php b/customer_index.php index 6f7bff93..8dd06d22 100644 --- a/customer_index.php +++ b/customer_index.php @@ -119,7 +119,7 @@ if ($page == 'overview') { eval("echo \"" . \Froxlor\UI\Template::getTemplate('index/index') . "\";"); } elseif ($page == 'change_password') { if (isset($_POST['send']) && $_POST['send'] == 'send') { - $old_password = validate($_POST['old_password'], 'old password'); + $old_password = \Froxlor\Validate\Validate::validate($_POST['old_password'], 'old password'); if (! validatePasswordLogin($userinfo, $old_password, TABLE_PANEL_CUSTOMERS, 'customerid')) { \Froxlor\UI\Response::standard_error('oldpasswordnotcorrect'); } @@ -202,7 +202,7 @@ if ($page == 'overview') { } } elseif ($page == 'change_language') { if (isset($_POST['send']) && $_POST['send'] == 'send') { - $def_language = validate($_POST['def_language'], 'default language'); + $def_language = \Froxlor\Validate\Validate::validate($_POST['def_language'], 'default language'); if (isset($languages[$def_language])) { try { Customers::getLocal($userinfo, array( @@ -241,7 +241,7 @@ if ($page == 'overview') { } } elseif ($page == 'change_theme') { if (isset($_POST['send']) && $_POST['send'] == 'send') { - $theme = validate($_POST['theme'], 'theme'); + $theme = \Froxlor\Validate\Validate::validate($_POST['theme'], 'theme'); try { Customers::getLocal($userinfo, array( 'id' => $userinfo['customerid'], diff --git a/index.php b/index.php index a03a54a5..c0b28d19 100644 --- a/index.php +++ b/index.php @@ -104,8 +104,8 @@ if ($action == '2fa_entercode') { exit(); } elseif ($action == 'login') { if (isset($_POST['send']) && $_POST['send'] == 'send') { - $loginname = validate($_POST['loginname'], 'loginname'); - $password = validate($_POST['password'], 'password'); + $loginname = \Froxlor\Validate\Validate::validate($_POST['loginname'], 'loginname'); + $password = \Froxlor\Validate\Validate::validate($_POST['password'], 'password'); $stmt = Database::prepare("SELECT `loginname` AS `customer` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `loginname`= :loginname"); @@ -391,7 +391,7 @@ if ($action == 'forgotpwd') { $message = ''; if (isset($_POST['send']) && $_POST['send'] == 'send') { - $loginname = validate($_POST['loginname'], 'loginname'); + $loginname = \Froxlor\Validate\Validate::validate($_POST['loginname'], 'loginname'); $email = validateEmail($_POST['loginemail'], 'email'); $result_stmt = Database::prepare("SELECT `adminid`, `customerid`, `firstname`, `name`, `company`, `email`, `loginname`, `def_language`, `deactivated` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `loginname`= :loginname @@ -599,8 +599,8 @@ if ($action == 'resetpwd') { if ($result !== false) { if ($result['admin'] == 1) { - $new_password = validate($_POST['new_password'], 'new password'); - $new_password_confirm = validate($_POST['new_password_confirm'], 'new password confirm'); + $new_password = \Froxlor\Validate\Validate::validate($_POST['new_password'], 'new password'); + $new_password_confirm = \Froxlor\Validate\Validate::validate($_POST['new_password_confirm'], 'new password confirm'); } else { $new_password = validatePassword($_POST['new_password'], 'new password'); $new_password_confirm = validatePassword($_POST['new_password_confirm'], 'new password confirm'); @@ -671,7 +671,7 @@ function finishLogin($userinfo) $s = md5(uniqid(microtime(), 1)); if (isset($_POST['language'])) { - $language = validate($_POST['language'], 'language'); + $language = \Froxlor\Validate\Validate::validate($_POST['language'], 'language'); if ($language == 'profile') { $language = $userinfo['def_language']; } elseif (! isset($languages[$language])) { diff --git a/lib/Froxlor/Api/ApiCommand.php b/lib/Froxlor/Api/ApiCommand.php index 84c5bf5a..c8c5b3da 100644 --- a/lib/Froxlor/Api/ApiCommand.php +++ b/lib/Froxlor/Api/ApiCommand.php @@ -176,7 +176,7 @@ abstract class ApiCommand extends ApiParameter } // last but not least include language references file - include_once makeSecurePath(\Froxlor\Froxlor::getInstallDir() . '/lng/lng_references.php'); + include_once \Froxlor\FileDir::makeSecurePath(\Froxlor\Froxlor::getInstallDir() . '/lng/lng_references.php'); // set array for ApiCommand $this->lng = $lng; diff --git a/lib/Froxlor/Api/Commands/Admins.php b/lib/Froxlor/Api/Commands/Admins.php index 576575b4..cf141bf2 100644 --- a/lib/Froxlor/Api/Commands/Admins.php +++ b/lib/Froxlor/Api/Commands/Admins.php @@ -194,17 +194,17 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt $ipaddress = $this->getParam('ipaddress', true, - 1); // validation - $name = validate($name, 'name', '', '', array(), true); + $name = \Froxlor\Validate\Validate::validate($name, 'name', '', '', array(), true); $idna_convert = new \Froxlor\Idna\IdnaWrapper(); - $email = $idna_convert->encode(validate($email, 'email', '', '', array(), true)); - $def_language = validate($def_language, 'default language', '', '', array(), true); - $custom_notes = validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', '/^[^\0]*$/', '', array(), true); + $email = $idna_convert->encode(\Froxlor\Validate\Validate::validate($email, 'email', '', '', array(), true)); + $def_language = \Froxlor\Validate\Validate::validate($def_language, 'default language', '', '', array(), true); + $custom_notes = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', '/^[^\0]*$/', '', array(), true); if (Settings::Get('system.mail_quota_enabled') != '1') { $email_quota = - 1; } - $password = validate($password, 'password', '', '', array(), true); + $password = \Froxlor\Validate\Validate::validate($password, 'password', '', '', array(), true); // only check if not empty, // cause empty == generate password automatically if ($password != '') { @@ -488,13 +488,13 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt } // validation - $name = validate($name, 'name', '', '', array(), true); + $name = \Froxlor\Validate\Validate::validate($name, 'name', '', '', array(), true); $idna_convert = new \Froxlor\Idna\IdnaWrapper(); - $email = $idna_convert->encode(validate($email, 'email', '', '', array(), true)); - $def_language = validate($def_language, 'default language', '', '', array(), true); - $custom_notes = validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', '/^[^\0]*$/', '', array(), true); - $theme = validate($theme, 'theme', '', '', array(), true); - $password = validate($password, 'password', '', '', array(), true); + $email = $idna_convert->encode(\Froxlor\Validate\Validate::validate($email, 'email', '', '', array(), true)); + $def_language = \Froxlor\Validate\Validate::validate($def_language, 'default language', '', '', array(), true); + $custom_notes = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', '/^[^\0]*$/', '', array(), true); + $theme = \Froxlor\Validate\Validate::validate($theme, 'theme', '', '', array(), true); + $password = \Froxlor\Validate\Validate::validate($password, 'password', '', '', array(), true); if (Settings::Get('system.mail_quota_enabled') != '1') { $email_quota = - 1; diff --git a/lib/Froxlor/Api/Commands/Cronjobs.php b/lib/Froxlor/Api/Commands/Cronjobs.php index db951590..b72fc386 100644 --- a/lib/Froxlor/Api/Commands/Cronjobs.php +++ b/lib/Froxlor/Api/Commands/Cronjobs.php @@ -96,8 +96,8 @@ class Cronjobs extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceE if ($isactive != 1) { $isactive = 0; } - $interval_value = validate($interval_value, 'interval_value', '/^([0-9]+)$/Di', 'stringisempty', array(), true); - $interval_interval = validate($interval_interval, 'interval_interval', '', '', array(), true); + $interval_value = \Froxlor\Validate\Validate::validate($interval_value, 'interval_value', '/^([0-9]+)$/Di', 'stringisempty', array(), true); + $interval_interval = \Froxlor\Validate\Validate::validate($interval_interval, 'interval_interval', '', '', array(), true); // put together interval value $interval = $interval_value . ' ' . strtoupper($interval_interval); diff --git a/lib/Froxlor/Api/Commands/CustomerBackups.php b/lib/Froxlor/Api/Commands/CustomerBackups.php index 98f972e3..14aff9bb 100644 --- a/lib/Froxlor/Api/Commands/CustomerBackups.php +++ b/lib/Froxlor/Api/Commands/CustomerBackups.php @@ -74,7 +74,7 @@ class CustomerBackups extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re $customer = $this->getCustomerData(); // validation - $path = \Froxlor\FileDir::makeCorrectDir(validate($path, 'path', '', '', array(), true)); + $path = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Validate\Validate::validate($path, 'path', '', '', array(), true)); $userpath = $path; $path = \Froxlor\FileDir::makeCorrectDir($customer['documentroot'] . '/' . $path); diff --git a/lib/Froxlor/Api/Commands/Customers.php b/lib/Froxlor/Api/Commands/Customers.php index c0344d0c..8bf57b1e 100644 --- a/lib/Froxlor/Api/Commands/Customers.php +++ b/lib/Froxlor/Api/Commands/Customers.php @@ -254,25 +254,25 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource $loginname = $this->getParam('new_loginname', true, ''); // validation - $name = validate($name, 'name', '', '', array(), true); - $firstname = validate($firstname, 'first name', '', '', array(), true); - $company = validate($company, 'company', '', '', array(), true); - $street = validate($street, 'street', '', '', array(), true); - $zipcode = validate($zipcode, 'zipcode', '/^[0-9 \-A-Z]*$/', '', array(), true); - $city = validate($city, 'city', '', '', array(), true); - $phone = validate($phone, 'phone', '/^[0-9\- \+\(\)\/]*$/', '', array(), true); - $fax = validate($fax, 'fax', '/^[0-9\- \+\(\)\/]*$/', '', array(), true); + $name = \Froxlor\Validate\Validate::validate($name, 'name', '', '', array(), true); + $firstname = \Froxlor\Validate\Validate::validate($firstname, 'first name', '', '', array(), true); + $company = \Froxlor\Validate\Validate::validate($company, 'company', '', '', array(), true); + $street = \Froxlor\Validate\Validate::validate($street, 'street', '', '', array(), true); + $zipcode = \Froxlor\Validate\Validate::validate($zipcode, 'zipcode', '/^[0-9 \-A-Z]*$/', '', array(), true); + $city = \Froxlor\Validate\Validate::validate($city, 'city', '', '', array(), true); + $phone = \Froxlor\Validate\Validate::validate($phone, 'phone', '/^[0-9\- \+\(\)\/]*$/', '', array(), true); + $fax = \Froxlor\Validate\Validate::validate($fax, 'fax', '/^[0-9\- \+\(\)\/]*$/', '', array(), true); $idna_convert = new \Froxlor\Idna\IdnaWrapper(); - $email = $idna_convert->encode(validate($email, 'email', '', '', array(), true)); - $customernumber = validate($customernumber, 'customer number', '/^[A-Za-z0-9 \-]*$/Di', '', array(), true); - $def_language = validate($def_language, 'default language', '', '', array(), true); - $custom_notes = validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', '/^[^\0]*$/', '', array(), true); + $email = $idna_convert->encode(\Froxlor\Validate\Validate::validate($email, 'email', '', '', array(), true)); + $customernumber = \Froxlor\Validate\Validate::validate($customernumber, 'customer number', '/^[A-Za-z0-9 \-]*$/Di', '', array(), true); + $def_language = \Froxlor\Validate\Validate::validate($def_language, 'default language', '', '', array(), true); + $custom_notes = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', '/^[^\0]*$/', '', array(), true); if (Settings::Get('system.mail_quota_enabled') != '1') { $email_quota = - 1; } - $password = validate($password, 'password', '', '', array(), true); + $password = \Froxlor\Validate\Validate::validate($password, 'password', '', '', array(), true); // only check if not empty, // cause empty == generate password automatically if ($password != '') { @@ -306,7 +306,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource if ($loginname != '') { $accountnumber = intval(Settings::Get('system.lastaccountnumber')); - $loginname = validate($loginname, 'loginname', '/^[a-z][a-z0-9\-_]+$/i', '', array(), true); + $loginname = \Froxlor\Validate\Validate::validate($loginname, 'loginname', '/^[a-z][a-z0-9\-_]+$/i', '', array(), true); // Accounts which match systemaccounts are not allowed, filtering them if (preg_match('/^' . preg_quote(Settings::Get('customer.accountprefix'), '/') . '([0-9]+)/', $loginname)) { @@ -896,21 +896,21 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource // validation if ($this->isAdmin()) { $idna_convert = new \Froxlor\Idna\IdnaWrapper(); - $name = validate($name, 'name', '', '', array(), true); - $firstname = validate($firstname, 'first name', '', '', array(), true); - $company = validate($company, 'company', '', '', array(), true); - $street = validate($street, 'street', '', '', array(), true); - $zipcode = validate($zipcode, 'zipcode', '/^[0-9 \-A-Z]*$/', '', array(), true); - $city = validate($city, 'city', '', '', array(), true); - $phone = validate($phone, 'phone', '/^[0-9\- \+\(\)\/]*$/', '', array(), true); - $fax = validate($fax, 'fax', '/^[0-9\- \+\(\)\/]*$/', '', array(), true); - $email = $idna_convert->encode(validate($email, 'email', '', '', array(), true)); - $customernumber = validate($customernumber, 'customer number', '/^[A-Za-z0-9 \-]*$/Di', '', array(), true); - $custom_notes = validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', '/^[^\0]*$/', '', array(), true); + $name = \Froxlor\Validate\Validate::validate($name, 'name', '', '', array(), true); + $firstname = \Froxlor\Validate\Validate::validate($firstname, 'first name', '', '', array(), true); + $company = \Froxlor\Validate\Validate::validate($company, 'company', '', '', array(), true); + $street = \Froxlor\Validate\Validate::validate($street, 'street', '', '', array(), true); + $zipcode = \Froxlor\Validate\Validate::validate($zipcode, 'zipcode', '/^[0-9 \-A-Z]*$/', '', array(), true); + $city = \Froxlor\Validate\Validate::validate($city, 'city', '', '', array(), true); + $phone = \Froxlor\Validate\Validate::validate($phone, 'phone', '/^[0-9\- \+\(\)\/]*$/', '', array(), true); + $fax = \Froxlor\Validate\Validate::validate($fax, 'fax', '/^[0-9\- \+\(\)\/]*$/', '', array(), true); + $email = $idna_convert->encode(\Froxlor\Validate\Validate::validate($email, 'email', '', '', array(), true)); + $customernumber = \Froxlor\Validate\Validate::validate($customernumber, 'customer number', '/^[A-Za-z0-9 \-]*$/Di', '', array(), true); + $custom_notes = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', '/^[^\0]*$/', '', array(), true); $allowed_phpconfigs = array_map('intval', $allowed_phpconfigs); } - $def_language = validate($def_language, 'default language', '', '', array(), true); - $theme = validate($theme, 'theme', '', '', array(), true); + $def_language = \Froxlor\Validate\Validate::validate($def_language, 'default language', '', '', array(), true); + $theme = \Froxlor\Validate\Validate::validate($theme, 'theme', '', '', array(), true); if (Settings::Get('system.mail_quota_enabled') != '1') { $email_quota = - 1; diff --git a/lib/Froxlor/Api/Commands/DirOptions.php b/lib/Froxlor/Api/Commands/DirOptions.php index 1df4c97b..10af7a80 100644 --- a/lib/Froxlor/Api/Commands/DirOptions.php +++ b/lib/Froxlor/Api/Commands/DirOptions.php @@ -69,7 +69,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc $error500path = $this->getParam('error500path', true, ''); // validation - $path = \Froxlor\FileDir::makeCorrectDir(validate($path, 'path', '', '', array(), true)); + $path = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Validate\Validate::validate($path, 'path', '', '', array(), true)); $userpath = $path; $path = \Froxlor\FileDir::makeCorrectDir($customer['documentroot'] . '/' . $path); diff --git a/lib/Froxlor/Api/Commands/DirProtections.php b/lib/Froxlor/Api/Commands/DirProtections.php index c7975dcc..f44363cb 100644 --- a/lib/Froxlor/Api/Commands/DirProtections.php +++ b/lib/Froxlor/Api/Commands/DirProtections.php @@ -60,11 +60,11 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res $authname = $this->getParam('directory_authname', true, ''); // validation - $path = \Froxlor\FileDir::makeCorrectDir(validate($path, 'path', '', '', array(), true)); + $path = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Validate\Validate::validate($path, 'path', '', '', array(), true)); $path = \Froxlor\FileDir::makeCorrectDir($customer['documentroot'] . '/' . $path); - $username = validate($username, 'username', '/^[a-zA-Z0-9][a-zA-Z0-9\-_]+\$?$/', '', array(), true); - $authname = validate($authname, 'directory_authname', '/^[a-zA-Z0-9][a-zA-Z0-9\-_ ]+\$?$/', '', array(), true); - validate($password, 'password', '', '', array(), true); + $username = \Froxlor\Validate\Validate::validate($username, 'username', '/^[a-zA-Z0-9][a-zA-Z0-9\-_]+\$?$/', '', array(), true); + $authname = \Froxlor\Validate\Validate::validate($authname, 'directory_authname', '/^[a-zA-Z0-9][a-zA-Z0-9\-_ ]+\$?$/', '', array(), true); + \Froxlor\Validate\Validate::validate($password, 'password', '', '', array(), true); // check for duplicate usernames for the path $username_path_check_stmt = Database::prepare(" @@ -226,8 +226,8 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res $customer = $this->getCustomerData(); // validation - $authname = validate($authname, 'directory_authname', '/^[a-zA-Z0-9][a-zA-Z0-9\-_ ]+\$?$/', '', array(), true); - validate($password, 'password', '', '', array(), true); + $authname = \Froxlor\Validate\Validate::validate($authname, 'directory_authname', '/^[a-zA-Z0-9][a-zA-Z0-9\-_ ]+\$?$/', '', array(), true); + \Froxlor\Validate\Validate::validate($password, 'password', '', '', array(), true); $upd_query = ""; $upd_params = array( diff --git a/lib/Froxlor/Api/Commands/Domains.php b/lib/Froxlor/Api/Commands/Domains.php index ebcdf456..cac8b61e 100644 --- a/lib/Froxlor/Api/Commands/Domains.php +++ b/lib/Froxlor/Api/Commands/Domains.php @@ -1,8 +1,8 @@ encode(preg_replace(array( '/\:(\d)+$/', '/^https?\:\/\//' - ), '', validate($p_domain, 'domain'))); + ), '', \Froxlor\Validate\Validate::validate($p_domain, 'domain'))); // Check whether domain validation is enabled and if, validate the domain if (Settings::Get('system.validate_domain') && ! validateDomain($domain)) { @@ -278,7 +278,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn } $_documentroot = \Froxlor\FileDir::makeCorrectDir($customer['documentroot'] . $path_suffix); - $registration_date = validate($registration_date, 'registration_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', array( + $registration_date = \Froxlor\Validate\Validate::validate($registration_date, 'registration_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', array( '0000-00-00', '0', '' @@ -287,7 +287,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn $registration_date = null; } - $termination_date = validate($termination_date, 'termination_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', array( + $termination_date = \Froxlor\Validate\Validate::validate($termination_date, 'termination_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', array( '0000-00-00', '0', '' @@ -298,14 +298,14 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn if ($this->getUserDetail('change_serversettings') == '1') { if (Settings::Get('system.bind_enable') == '1') { - $zonefile = validate($zonefile, 'zonefile', '', '', array(), true); + $zonefile = \Froxlor\Validate\Validate::validate($zonefile, 'zonefile', '', '', array(), true); } else { $isbinddomain = 0; $zonefile = ''; } - $specialsettings = validate(str_replace("\r\n", "\n", $specialsettings), 'specialsettings', '/^[^\0]*$/', '', array(), true); - validate($documentroot, 'documentroot', '', '', array(), true); + $specialsettings = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $specialsettings), 'specialsettings', '/^[^\0]*$/', '', array(), true); + \Froxlor\Validate\Validate::validate($documentroot, 'documentroot', '', '', array(), true); // If path is empty and 'Use domain name as default value for DocumentRoot path' is enabled in settings, // set default path to subdomain or domain name @@ -346,11 +346,11 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn } if ((int) Settings::Get('system.mod_fcgid') == 1) { - $mod_fcgid_starter = validate($mod_fcgid_starter, 'mod_fcgid_starter', '/^[0-9]*$/', '', array( + $mod_fcgid_starter = \Froxlor\Validate\Validate::validate($mod_fcgid_starter, 'mod_fcgid_starter', '/^[0-9]*$/', '', array( '-1', '' ), true); - $mod_fcgid_maxrequests = validate($mod_fcgid_maxrequests, 'mod_fcgid_maxrequests', '/^[0-9]*$/', '', array( + $mod_fcgid_maxrequests = \Froxlor\Validate\Validate::validate($mod_fcgid_maxrequests, 'mod_fcgid_maxrequests', '/^[0-9]*$/', '', array( '-1', '' ), true); @@ -900,7 +900,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn $adminid = $result['adminid']; } - $registration_date = validate($registration_date, 'registration_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', array( + $registration_date = \Froxlor\Validate\Validate::validate($registration_date, 'registration_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', array( '0000-00-00', '0', '' @@ -908,7 +908,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn if ($registration_date == '0000-00-00') { $registration_date = null; } - $termination_date = validate($termination_date, 'termination_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', array( + $termination_date = \Froxlor\Validate\Validate::validate($termination_date, 'termination_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', array( '0000-00-00', '0', '' @@ -930,7 +930,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn if ($this->getUserDetail('change_serversettings') == '1') { if (Settings::Get('system.bind_enable') != '1') { - $zonefile = validate($zonefile, 'zonefile', '', '', array(), true); + $zonefile = \Froxlor\Validate\Validate::validate($zonefile, 'zonefile', '', '', array(), true); } else { $isbinddomain = $result['isbinddomain']; $zonefile = $result['zonefile']; @@ -940,8 +940,8 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn $dkim = $result['dkim']; } - $specialsettings = validate(str_replace("\r\n", "\n", $specialsettings), 'specialsettings', '/^[^\0]*$/', '', array(), true); - $documentroot = validate($documentroot, 'documentroot', '', '', array(), true); + $specialsettings = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $specialsettings), 'specialsettings', '/^[^\0]*$/', '', array(), true); + $documentroot = \Froxlor\Validate\Validate::validate($documentroot, 'documentroot', '', '', array(), true); // when moving customer and no path is specified, update would normally reuse the current document-root // which would point to the wrong customer, therefore we will re-create that directory @@ -995,11 +995,11 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn } if ((int) Settings::Get('system.mod_fcgid') == 1) { - $mod_fcgid_starter = validate($mod_fcgid_starter, 'mod_fcgid_starter', '/^[0-9]*$/', '', array( + $mod_fcgid_starter = \Froxlor\Validate\Validate::validate($mod_fcgid_starter, 'mod_fcgid_starter', '/^[0-9]*$/', '', array( '-1', '' ), true); - $mod_fcgid_maxrequests = validate($mod_fcgid_maxrequests, 'mod_fcgid_maxrequests', '/^[0-9]*$/', '', array( + $mod_fcgid_maxrequests = \Froxlor\Validate\Validate::validate($mod_fcgid_maxrequests, 'mod_fcgid_maxrequests', '/^[0-9]*$/', '', array( '-1', '' ), true); diff --git a/lib/Froxlor/Api/Commands/EmailAccounts.php b/lib/Froxlor/Api/Commands/EmailAccounts.php index ce2e194d..fe9efab2 100644 --- a/lib/Froxlor/Api/Commands/EmailAccounts.php +++ b/lib/Froxlor/Api/Commands/EmailAccounts.php @@ -64,7 +64,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso $sendinfomail = $this->getBoolParam('sendinfomail', true, 1); // validation - $quota = validate($quota, 'email_quota', '/^\d+$/', 'vmailquotawrong', array(), true); + $quota = \Froxlor\Validate\Validate::validate($quota, 'email_quota', '/^\d+$/', 'vmailquotawrong', array(), true); // get needed customer info to reduce the email-account-counter by one $customer = $this->getCustomerData('email_accounts'); @@ -84,7 +84,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso $email_full = $result['email_full']; $idna_convert = new \Froxlor\Idna\IdnaWrapper(); $username = $idna_convert->decode($email_full); - $password = validate($email_password, 'password', '', '', array(), true); + $password = \Froxlor\Validate\Validate::validate($email_password, 'password', '', '', array(), true); $password = validatePassword($password, true); if ($result['popaccountid'] != 0) { @@ -99,7 +99,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso // alternative email address to send info to if (Settings::Get('panel.sendalternativemail') == 1) { - $alternative_email = $idna_convert->encode(validate($alternative_email, 'alternative_email', '', '', array(), true)); + $alternative_email = $idna_convert->encode(\Froxlor\Validate\Validate::validate($alternative_email, 'alternative_email', '', '', array(), true)); if (! validateEmail($alternative_email)) { \Froxlor\UI\Response::standard_error('emailiswrong', $alternative_email, true); } @@ -335,7 +335,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso $customer = $this->getCustomerData(); // validation - $quota = validate($quota, 'email_quota', '/^\d+$/', 'vmailquotawrong', array(), true); + $quota = \Froxlor\Validate\Validate::validate($quota, 'email_quota', '/^\d+$/', 'vmailquotawrong', array(), true); $upd_query = ""; $upd_params = array( diff --git a/lib/Froxlor/Api/Commands/EmailForwarders.php b/lib/Froxlor/Api/Commands/EmailForwarders.php index 581429d8..2978b42b 100644 --- a/lib/Froxlor/Api/Commands/EmailForwarders.php +++ b/lib/Froxlor/Api/Commands/EmailForwarders.php @@ -1,8 +1,8 @@ encode(validate($domain, 'domain', '', '', array(), true)); + $domain = $idna_convert->encode(\Froxlor\Validate\Validate::validate($domain, 'domain', '', '', array(), true)); } // check domain and whether it's an email-enabled domain diff --git a/lib/Froxlor/Api/Commands/FpmDaemons.php b/lib/Froxlor/Api/Commands/FpmDaemons.php index d2dce946..0be5a266 100644 --- a/lib/Froxlor/Api/Commands/FpmDaemons.php +++ b/lib/Froxlor/Api/Commands/FpmDaemons.php @@ -1,7 +1,7 @@ getParam('limit_extensions', true, '.php'); // validation - $description = validate($description, 'description', '', '', array(), true); - $reload_cmd = validate($reload_cmd, 'reload_cmd', '', '', array(), true); - $config_dir = validate($config_dir, 'config_dir', '', '', array(), true); + $description = \Froxlor\Validate\Validate::validate($description, 'description', '', '', array(), true); + $reload_cmd = \Froxlor\Validate\Validate::validate($reload_cmd, 'reload_cmd', '', '', array(), true); + $config_dir = \Froxlor\Validate\Validate::validate($config_dir, 'config_dir', '', '', array(), true); if (! in_array($pmanager, array( 'static', 'dynamic', @@ -161,7 +161,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc if (empty($limit_extensions)) { $limit_extensions = '.php'; } - $limit_extensions = validate($limit_extensions, 'limit_extensions', '/^(\.[a-z]([a-z0-9]+)\ ?)+$/', '', array(), true); + $limit_extensions = \Froxlor\Validate\Validate::validate($limit_extensions, 'limit_extensions', '/^(\.[a-z]([a-z0-9]+)\ ?)+$/', '', array(), true); if (strlen($description) == 0 || strlen($description) > 50) { \Froxlor\UI\Response::standard_error('descriptioninvalid', '', true); @@ -264,9 +264,9 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc $limit_extensions = $this->getParam('limit_extensions', true, $result['limit_extensions']); // validation - $description = validate($description, 'description', '', '', array(), true); - $reload_cmd = validate($reload_cmd, 'reload_cmd', '', '', array(), true); - $config_dir = validate($config_dir, 'config_dir', '', '', array(), true); + $description = \Froxlor\Validate\Validate::validate($description, 'description', '', '', array(), true); + $reload_cmd = \Froxlor\Validate\Validate::validate($reload_cmd, 'reload_cmd', '', '', array(), true); + $config_dir = \Froxlor\Validate\Validate::validate($config_dir, 'config_dir', '', '', array(), true); if (! in_array($pmanager, array( 'static', 'dynamic', @@ -277,7 +277,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc if (empty($limit_extensions)) { $limit_extensions = '.php'; } - $limit_extensions = validate($limit_extensions, 'limit_extensions', '/^(\.[a-z]([a-z0-9]+)\ ?)+$/', '', array(), true); + $limit_extensions = \Froxlor\Validate\Validate::validate($limit_extensions, 'limit_extensions', '/^(\.[a-z]([a-z0-9]+)\ ?)+$/', '', array(), true); if (strlen($description) == 0 || strlen($description) > 50) { \Froxlor\UI\Response::standard_error('descriptioninvalid', '', true); diff --git a/lib/Froxlor/Api/Commands/Froxlor.php b/lib/Froxlor/Api/Commands/Froxlor.php index 5179ec68..755fc1e2 100644 --- a/lib/Froxlor/Api/Commands/Froxlor.php +++ b/lib/Froxlor/Api/Commands/Froxlor.php @@ -1,8 +1,8 @@ getParam('ftp_domain', true, ''); // validation - $password = validate($password, 'password', '', '', array(), true); + $password = \Froxlor\Validate\Validate::validate($password, 'password', '', '', array(), true); $password = validatePassword($password, true); - $description = validate(trim($description), 'description', '', '', array(), true); + $description = \Froxlor\Validate\Validate::validate(trim($description), 'description', '', '', array(), true); if (Settings::Get('system.allow_customer_shell') == '1') { - $shell = validate(trim($shell), 'shell', '', '', array(), true); + $shell = \Froxlor\Validate\Validate::validate(trim($shell), 'shell', '', '', array(), true); } else { $shell = "/bin/false"; } if (Settings::Get('customer.ftpatdomain') == '1') { - $ftpusername = validate(trim($ftpusername), 'username', '/^[a-zA-Z0-9][a-zA-Z0-9\-_]+\$?$/', '', array(), true); + $ftpusername = \Froxlor\Validate\Validate::validate(trim($ftpusername), 'username', '/^[a-zA-Z0-9][a-zA-Z0-9\-_]+\$?$/', '', array(), true); if (substr($ftpdomain, 0, 4) != 'xn--') { $idna_convert = new \Froxlor\Idna\IdnaWrapper(); - $ftpdomain = $idna_convert->encode(validate($ftpdomain, 'domain', '', '', array(), true)); + $ftpdomain = $idna_convert->encode(\Froxlor\Validate\Validate::validate($ftpdomain, 'domain', '', '', array(), true)); } } @@ -338,11 +338,11 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit $shell = $this->getParam('shell', true, $result['shell']); // validation - $password = validate($password, 'password', '', '', array(), true); - $description = validate(trim($description), 'description', '', '', array(), true); + $password = \Froxlor\Validate\Validate::validate($password, 'password', '', '', array(), true); + $description = \Froxlor\Validate\Validate::validate(trim($description), 'description', '', '', array(), true); if (Settings::Get('system.allow_customer_shell') == '1') { - $shell = validate(trim($shell), 'shell', '', '', array(), true); + $shell = \Froxlor\Validate\Validate::validate(trim($shell), 'shell', '', '', array(), true); } else { $shell = "/bin/false"; } diff --git a/lib/Froxlor/Api/Commands/IpsAndPorts.php b/lib/Froxlor/Api/Commands/IpsAndPorts.php index 2681637d..44f9fa54e 100644 --- a/lib/Froxlor/Api/Commands/IpsAndPorts.php +++ b/lib/Froxlor/Api/Commands/IpsAndPorts.php @@ -1,8 +1,8 @@ isAdmin() && $this->getUserDetail('change_serversettings')) { $ip = validate_ip2($this->getParam('ip'), false, 'invalidip', false, false, false, true); - $port = validate($this->getParam('port', true, 80), 'port', '/^(([1-9])|([1-9][0-9])|([1-9][0-9][0-9])|([1-9][0-9][0-9][0-9])|([1-5][0-9][0-9][0-9][0-9])|(6[0-4][0-9][0-9][0-9])|(65[0-4][0-9][0-9])|(655[0-2][0-9])|(6553[0-5]))$/Di', array( + $port = \Froxlor\Validate\Validate::validate($this->getParam('port', true, 80), 'port', '/^(([1-9])|([1-9][0-9])|([1-9][0-9][0-9])|([1-9][0-9][0-9][0-9])|([1-5][0-9][0-9][0-9][0-9])|(6[0-4][0-9][0-9][0-9])|(65[0-4][0-9][0-9])|(655[0-2][0-9])|(6553[0-5]))$/Di', array( 'stringisempty', 'myport' ), array(), true); $listen_statement = ! empty($this->getBoolParam('listen_statement', true, 0)) ? 1 : 0; $namevirtualhost_statement = ! empty($this->getBoolParam('namevirtualhost_statement', true, 0)) ? 1 : 0; $vhostcontainer = ! empty($this->getBoolParam('vhostcontainer', true, 0)) ? 1 : 0; - $specialsettings = validate(str_replace("\r\n", "\n", $this->getParam('specialsettings', true, '')), 'specialsettings', '/^[^\0]*$/', '', array(), true); + $specialsettings = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $this->getParam('specialsettings', true, '')), 'specialsettings', '/^[^\0]*$/', '', array(), true); $vhostcontainer_servername_statement = ! empty($this->getBoolParam('vhostcontainer_servername_statement', true, 1)) ? 1 : 0; - $default_vhostconf_domain = validate(str_replace("\r\n", "\n", $this->getParam('default_vhostconf_domain', true, '')), 'default_vhostconf_domain', '/^[^\0]*$/', '', array(), true); - $docroot = validate($this->getParam('docroot', true, ''), 'docroot', '', '', array(), true); + $default_vhostconf_domain = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $this->getParam('default_vhostconf_domain', true, '')), 'default_vhostconf_domain', '/^[^\0]*$/', '', array(), true); + $docroot = \Froxlor\Validate\Validate::validate($this->getParam('docroot', true, ''), 'docroot', '', '', array(), true); if ((int) Settings::Get('system.use_ssl') == 1) { $ssl = ! empty($this->getBoolParam('ssl', true, 0)) ? intval($this->getBoolParam('ssl', true, 0)) : 0; - $ssl_cert_file = validate($this->getParam('ssl_cert_file', $ssl, ''), 'ssl_cert_file', '', '', array(), true); - $ssl_key_file = validate($this->getParam('ssl_key_file', $ssl, ''), 'ssl_key_file', '', '', array(), true); - $ssl_ca_file = validate($this->getParam('ssl_ca_file', true, ''), 'ssl_ca_file', '', '', array(), true); - $ssl_cert_chainfile = validate($this->getParam('ssl_cert_chainfile', true, ''), 'ssl_cert_chainfile', '', '', array(), true); + $ssl_cert_file = \Froxlor\Validate\Validate::validate($this->getParam('ssl_cert_file', $ssl, ''), 'ssl_cert_file', '', '', array(), true); + $ssl_key_file = \Froxlor\Validate\Validate::validate($this->getParam('ssl_key_file', $ssl, ''), 'ssl_key_file', '', '', array(), true); + $ssl_ca_file = \Froxlor\Validate\Validate::validate($this->getParam('ssl_ca_file', true, ''), 'ssl_ca_file', '', '', array(), true); + $ssl_cert_chainfile = \Froxlor\Validate\Validate::validate($this->getParam('ssl_cert_chainfile', true, ''), 'ssl_cert_chainfile', '', '', array(), true); } else { $ssl = 0; $ssl_cert_file = ''; @@ -303,24 +303,24 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour )); $ip = validate_ip2($this->getParam('ip', true, $result['ip']), false, 'invalidip', false, false, false, true); - $port = validate($this->getParam('port', true, $result['port']), 'port', '/^(([1-9])|([1-9][0-9])|([1-9][0-9][0-9])|([1-9][0-9][0-9][0-9])|([1-5][0-9][0-9][0-9][0-9])|(6[0-4][0-9][0-9][0-9])|(65[0-4][0-9][0-9])|(655[0-2][0-9])|(6553[0-5]))$/Di', array( + $port = \Froxlor\Validate\Validate::validate($this->getParam('port', true, $result['port']), 'port', '/^(([1-9])|([1-9][0-9])|([1-9][0-9][0-9])|([1-9][0-9][0-9][0-9])|([1-5][0-9][0-9][0-9][0-9])|(6[0-4][0-9][0-9][0-9])|(65[0-4][0-9][0-9])|(655[0-2][0-9])|(6553[0-5]))$/Di', array( 'stringisempty', 'myport' ), array(), true); $listen_statement = $this->getBoolParam('listen_statement', true, $result['listen_statement']); $namevirtualhost_statement = $this->getBoolParam('namevirtualhost_statement', true, $result['namevirtualhost_statement']); $vhostcontainer = $this->getBoolParam('vhostcontainer', true, $result['vhostcontainer']); - $specialsettings = validate(str_replace("\r\n", "\n", $this->getParam('specialsettings', true, $result['specialsettings'])), 'specialsettings', '/^[^\0]*$/', '', array(), true); + $specialsettings = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $this->getParam('specialsettings', true, $result['specialsettings'])), 'specialsettings', '/^[^\0]*$/', '', array(), true); $vhostcontainer_servername_statement = $this->getParam('vhostcontainer_servername_statement', true, $result['vhostcontainer_servername_statement']); - $default_vhostconf_domain = validate(str_replace("\r\n", "\n", $this->getParam('default_vhostconf_domain', true, $result['default_vhostconf_domain'])), 'default_vhostconf_domain', '/^[^\0]*$/', '', array(), true); - $docroot = validate($this->getParam('docroot', true, $result['docroot']), 'docroot', '', '', array(), true); + $default_vhostconf_domain = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $this->getParam('default_vhostconf_domain', true, $result['default_vhostconf_domain'])), 'default_vhostconf_domain', '/^[^\0]*$/', '', array(), true); + $docroot = \Froxlor\Validate\Validate::validate($this->getParam('docroot', true, $result['docroot']), 'docroot', '', '', array(), true); if ((int) Settings::Get('system.use_ssl') == 1) { $ssl = $this->getBoolParam('ssl', true, $result['ssl']); - $ssl_cert_file = validate($this->getParam('ssl_cert_file', $ssl, $result['ssl_cert_file']), 'ssl_cert_file', '', '', array(), true); - $ssl_key_file = validate($this->getParam('ssl_key_file', $ssl, $result['ssl_key_file']), 'ssl_key_file', '', '', array(), true); - $ssl_ca_file = validate($this->getParam('ssl_ca_file', true, $result['ssl_ca_file']), 'ssl_ca_file', '', '', array(), true); - $ssl_cert_chainfile = validate($this->getParam('ssl_cert_chainfile', true, $result['ssl_cert_chainfile']), 'ssl_cert_chainfile', '', '', array(), true); + $ssl_cert_file = \Froxlor\Validate\Validate::validate($this->getParam('ssl_cert_file', $ssl, $result['ssl_cert_file']), 'ssl_cert_file', '', '', array(), true); + $ssl_key_file = \Froxlor\Validate\Validate::validate($this->getParam('ssl_key_file', $ssl, $result['ssl_key_file']), 'ssl_key_file', '', '', array(), true); + $ssl_ca_file = \Froxlor\Validate\Validate::validate($this->getParam('ssl_ca_file', true, $result['ssl_ca_file']), 'ssl_ca_file', '', '', array(), true); + $ssl_cert_chainfile = \Froxlor\Validate\Validate::validate($this->getParam('ssl_cert_chainfile', true, $result['ssl_cert_chainfile']), 'ssl_cert_chainfile', '', '', array(), true); } else { $ssl = 0; $ssl_cert_file = ''; diff --git a/lib/Froxlor/Api/Commands/Mysqls.php b/lib/Froxlor/Api/Commands/Mysqls.php index d410d8df..864dee0e 100644 --- a/lib/Froxlor/Api/Commands/Mysqls.php +++ b/lib/Froxlor/Api/Commands/Mysqls.php @@ -53,12 +53,12 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt $sendinfomail = $this->getBoolParam('sendinfomail', true, 0); // validation - $password = validate($password, 'password', '', '', array(), true); + $password = \Froxlor\Validate\Validate::validate($password, 'password', '', '', array(), true); $password = validatePassword($password, true); - $databasedescription = validate(trim($databasedescription), 'description', '', '', array(), true); + $databasedescription = \Froxlor\Validate\Validate::validate(trim($databasedescription), 'description', '', '', array(), true); // validate whether the dbserver exists - $dbserver = validate($dbserver, html_entity_decode($this->lng['mysql']['mysql_server']), '', '', 0, true); + $dbserver = \Froxlor\Validate\Validate::validate($dbserver, html_entity_decode($this->lng['mysql']['mysql_server']), '', '', 0, true); Database::needRoot(true, $dbserver); Database::needSqlData(); $sql_root = Database::getSqlData(); @@ -307,8 +307,8 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt $databasedescription = $this->getParam('description', true, ''); // validation - $password = validate($password, 'password', '', '', array(), true); - $databasedescription = validate(trim($databasedescription), 'description', '', '', array(), true); + $password = \Froxlor\Validate\Validate::validate($password, 'password', '', '', array(), true); + $databasedescription = \Froxlor\Validate\Validate::validate(trim($databasedescription), 'description', '', '', array(), true); // get needed customer info to reduce the mysql-usage-counter by one $customer = $this->getCustomerData(); diff --git a/lib/Froxlor/Api/Commands/PhpSettings.php b/lib/Froxlor/Api/Commands/PhpSettings.php index 01902e3b..f52c6578 100644 --- a/lib/Froxlor/Api/Commands/PhpSettings.php +++ b/lib/Froxlor/Api/Commands/PhpSettings.php @@ -1,8 +1,8 @@ getParam('limit_extensions', true, $def_fpmconfig['limit_extensions']); // validation - $description = validate($description, 'description', '', '', array(), true); - $phpsettings = validate(str_replace("\r\n", "\n", $phpsettings), 'phpsettings', '/^[^\0]*$/', '', array(), true); + $description = \Froxlor\Validate\Validate::validate($description, 'description', '', '', array(), true); + $phpsettings = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $phpsettings), 'phpsettings', '/^[^\0]*$/', '', array(), true); if (Settings::Get('system.mod_fcgid') == 1) { - $binary = \Froxlor\FileDir::makeCorrectFile(validate($binary, 'binary', '', '', array(), true)); - $file_extensions = validate($file_extensions, 'file_extensions', '/^[a-zA-Z0-9\s]*$/', '', array(), true); - $mod_fcgid_starter = validate($mod_fcgid_starter, 'mod_fcgid_starter', '/^[0-9]*$/', '', array( + $binary = \Froxlor\FileDir::makeCorrectFile(\Froxlor\Validate\Validate::validate($binary, 'binary', '', '', array(), true)); + $file_extensions = \Froxlor\Validate\Validate::validate($file_extensions, 'file_extensions', '/^[a-zA-Z0-9\s]*$/', '', array(), true); + $mod_fcgid_starter = \Froxlor\Validate\Validate::validate($mod_fcgid_starter, 'mod_fcgid_starter', '/^[0-9]*$/', '', array( '-1', '' ), true); - $mod_fcgid_maxrequests = validate($mod_fcgid_maxrequests, 'mod_fcgid_maxrequests', '/^[0-9]*$/', '', array( + $mod_fcgid_maxrequests = \Froxlor\Validate\Validate::validate($mod_fcgid_maxrequests, 'mod_fcgid_maxrequests', '/^[0-9]*$/', '', array( '-1', '' ), true); - $mod_fcgid_umask = validate($mod_fcgid_umask, 'mod_fcgid_umask', '/^[0-9]*$/', '', array(), true); + $mod_fcgid_umask = \Froxlor\Validate\Validate::validate($mod_fcgid_umask, 'mod_fcgid_umask', '/^[0-9]*$/', '', array(), true); // disable fpm stuff $fpm_config_id = 1; $fpm_enableslowlog = 0; @@ -257,8 +257,8 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour $fpm_pass_authorizationheader = 0; $override_fpmconfig = 0; } elseif (Settings::Get('phpfpm.enabled') == 1) { - $fpm_reqtermtimeout = validate($fpm_reqtermtimeout, 'phpfpm_reqtermtimeout', '/^([0-9]+)(|s|m|h|d)$/', '', array(), true); - $fpm_reqslowtimeout = validate($fpm_reqslowtimeout, 'phpfpm_reqslowtimeout', '/^([0-9]+)(|s|m|h|d)$/', '', array(), true); + $fpm_reqtermtimeout = \Froxlor\Validate\Validate::validate($fpm_reqtermtimeout, 'phpfpm_reqtermtimeout', '/^([0-9]+)(|s|m|h|d)$/', '', array(), true); + $fpm_reqslowtimeout = \Froxlor\Validate\Validate::validate($fpm_reqslowtimeout, 'phpfpm_reqslowtimeout', '/^([0-9]+)(|s|m|h|d)$/', '', array(), true); if (! in_array($pmanager, array( 'static', 'dynamic', @@ -269,7 +269,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour if (empty($limit_extensions)) { $limit_extensions = '.php'; } - $limit_extensions = validate($limit_extensions, 'limit_extensions', '/^(\.[a-z]([a-z0-9]+)\ ?)+$/', '', array(), true); + $limit_extensions = \Froxlor\Validate\Validate::validate($limit_extensions, 'limit_extensions', '/^(\.[a-z]([a-z0-9]+)\ ?)+$/', '', array(), true); // disable fcgid stuff $binary = '/usr/bin/php-cgi'; @@ -430,20 +430,20 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour $limit_extensions = $this->getParam('limit_extensions', true, $result['limit_extensions']); // validation - $description = validate($description, 'description', '', '', array(), true); - $phpsettings = validate(str_replace("\r\n", "\n", $phpsettings), 'phpsettings', '/^[^\0]*$/', '', array(), true); + $description = \Froxlor\Validate\Validate::validate($description, 'description', '', '', array(), true); + $phpsettings = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $phpsettings), 'phpsettings', '/^[^\0]*$/', '', array(), true); if (Settings::Get('system.mod_fcgid') == 1) { - $binary = \Froxlor\FileDir::makeCorrectFile(validate($binary, 'binary', '', '', array(), true)); - $file_extensions = validate($file_extensions, 'file_extensions', '/^[a-zA-Z0-9\s]*$/', '', array(), true); - $mod_fcgid_starter = validate($mod_fcgid_starter, 'mod_fcgid_starter', '/^[0-9]*$/', '', array( + $binary = \Froxlor\FileDir::makeCorrectFile(\Froxlor\Validate\Validate::validate($binary, 'binary', '', '', array(), true)); + $file_extensions = \Froxlor\Validate\Validate::validate($file_extensions, 'file_extensions', '/^[a-zA-Z0-9\s]*$/', '', array(), true); + $mod_fcgid_starter = \Froxlor\Validate\Validate::validate($mod_fcgid_starter, 'mod_fcgid_starter', '/^[0-9]*$/', '', array( '-1', '' ), true); - $mod_fcgid_maxrequests = validate($mod_fcgid_maxrequests, 'mod_fcgid_maxrequests', '/^[0-9]*$/', '', array( + $mod_fcgid_maxrequests = \Froxlor\Validate\Validate::validate($mod_fcgid_maxrequests, 'mod_fcgid_maxrequests', '/^[0-9]*$/', '', array( '-1', '' ), true); - $mod_fcgid_umask = validate($mod_fcgid_umask, 'mod_fcgid_umask', '/^[0-9]*$/', '', array(), true); + $mod_fcgid_umask = \Froxlor\Validate\Validate::validate($mod_fcgid_umask, 'mod_fcgid_umask', '/^[0-9]*$/', '', array(), true); // disable fpm stuff $fpm_config_id = 1; $fpm_enableslowlog = 0; @@ -452,8 +452,8 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour $fpm_pass_authorizationheader = 0; $override_fpmconfig = 0; } elseif (Settings::Get('phpfpm.enabled') == 1) { - $fpm_reqtermtimeout = validate($fpm_reqtermtimeout, 'phpfpm_reqtermtimeout', '/^([0-9]+)(|s|m|h|d)$/', '', array(), true); - $fpm_reqslowtimeout = validate($fpm_reqslowtimeout, 'phpfpm_reqslowtimeout', '/^([0-9]+)(|s|m|h|d)$/', '', array(), true); + $fpm_reqtermtimeout = \Froxlor\Validate\Validate::validate($fpm_reqtermtimeout, 'phpfpm_reqtermtimeout', '/^([0-9]+)(|s|m|h|d)$/', '', array(), true); + $fpm_reqslowtimeout = \Froxlor\Validate\Validate::validate($fpm_reqslowtimeout, 'phpfpm_reqslowtimeout', '/^([0-9]+)(|s|m|h|d)$/', '', array(), true); if (! in_array($pmanager, array( 'static', 'dynamic', @@ -464,7 +464,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour if (empty($limit_extensions)) { $limit_extensions = '.php'; } - $limit_extensions = validate($limit_extensions, 'limit_extensions', '/^(\.[a-z]([a-z0-9]+)\ ?)+$/', '', array(), true); + $limit_extensions = \Froxlor\Validate\Validate::validate($limit_extensions, 'limit_extensions', '/^(\.[a-z]([a-z0-9]+)\ ?)+$/', '', array(), true); // disable fcgid stuff $binary = '/usr/bin/php-cgi'; diff --git a/lib/Froxlor/Api/Commands/SubDomains.php b/lib/Froxlor/Api/Commands/SubDomains.php index c3750e33..f819093f 100644 --- a/lib/Froxlor/Api/Commands/SubDomains.php +++ b/lib/Froxlor/Api/Commands/SubDomains.php @@ -1,8 +1,8 @@ encode(preg_replace(array( '/\:(\d)+$/', '/^https?\:\/\//' - ), '', validate($subdomain, 'subdomain', '', 'subdomainiswrong', array(), true))); + ), '', \Froxlor\Validate\Validate::validate($subdomain, 'subdomain', '', 'subdomainiswrong', array(), true))); // merge the two parts together $completedomain = $subdomain . '.' . $domain; @@ -859,7 +859,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc $path = $url; $_doredirect = true; } else { - $path = validate($path, 'path', '', '', array(), true); + $path = \Froxlor\Validate\Validate::validate($path, 'path', '', '', array(), true); } // check whether path is a real path diff --git a/lib/Froxlor/Api/Commands/Traffic.php b/lib/Froxlor/Api/Commands/Traffic.php index 3dd26505..b12c6b80 100644 --- a/lib/Froxlor/Api/Commands/Traffic.php +++ b/lib/Froxlor/Api/Commands/Traffic.php @@ -1,7 +1,7 @@ _validate(); + $this->_\Froxlor\Validate\Validate::validate(); } /** @@ -24,7 +24,7 @@ class ConfigServicesAction extends \Froxlor\Cli\Action * * @throws \Exception */ - private function _validate() + private function _\Froxlor\Validate\Validate::validate() { $this->_checkConfigParam(true); $this->_parseConfig(); diff --git a/lib/Froxlor/Cli/Action/SwitchServerIpAction.php b/lib/Froxlor/Cli/Action/SwitchServerIpAction.php index ba2fa4a4..30b47ca4 100644 --- a/lib/Froxlor/Cli/Action/SwitchServerIpAction.php +++ b/lib/Froxlor/Cli/Action/SwitchServerIpAction.php @@ -14,7 +14,7 @@ class SwitchServerIpAction extends \Froxlor\Cli\Action public function run() { - $this->_validate(); + $this->_\Froxlor\Validate\Validate::validate(); } /** @@ -22,7 +22,7 @@ class SwitchServerIpAction extends \Froxlor\Cli\Action * * @throws \Exception */ - private function _validate() + private function _\Froxlor\Validate\Validate::validate() { $need_config = false; if (array_key_exists("list", $this->_args) || array_key_exists("switch", $this->_args)) { diff --git a/lib/Froxlor/System/Crypt.php b/lib/Froxlor/System/Crypt.php index aabc6077..f9597146 100644 --- a/lib/Froxlor/System/Crypt.php +++ b/lib/Froxlor/System/Crypt.php @@ -153,23 +153,23 @@ class Crypt public static function validatePassword($password = null, $json_response = false) { if (Settings::Get('panel.password_min_length') > 0) { - $password = validate($password, Settings::Get('panel.password_min_length'), '/^.{' . (int) Settings::Get('panel.password_min_length') . ',}$/D', 'notrequiredpasswordlength', array(), $json_response); + $password = \Froxlor\Validate\Validate::validate($password, Settings::Get('panel.password_min_length'), '/^.{' . (int) Settings::Get('panel.password_min_length') . ',}$/D', 'notrequiredpasswordlength', array(), $json_response); } if (Settings::Get('panel.password_regex') != '') { - $password = validate($password, Settings::Get('panel.password_regex'), Settings::Get('panel.password_regex'), 'notrequiredpasswordcomplexity', array(), $json_response); + $password = \Froxlor\Validate\Validate::validate($password, Settings::Get('panel.password_regex'), Settings::Get('panel.password_regex'), 'notrequiredpasswordcomplexity', array(), $json_response); } else { if (Settings::Get('panel.password_alpha_lower')) { - $password = validate($password, '/.*[a-z]+.*/', '/.*[a-z]+.*/', 'notrequiredpasswordcomplexity', array(), $json_response); + $password = \Froxlor\Validate\Validate::validate($password, '/.*[a-z]+.*/', '/.*[a-z]+.*/', 'notrequiredpasswordcomplexity', array(), $json_response); } if (Settings::Get('panel.password_alpha_upper')) { - $password = validate($password, '/.*[A-Z]+.*/', '/.*[A-Z]+.*/', 'notrequiredpasswordcomplexity', array(), $json_response); + $password = \Froxlor\Validate\Validate::validate($password, '/.*[A-Z]+.*/', '/.*[A-Z]+.*/', 'notrequiredpasswordcomplexity', array(), $json_response); } if (Settings::Get('panel.password_numeric')) { - $password = validate($password, '/.*[0-9]+.*/', '/.*[0-9]+.*/', 'notrequiredpasswordcomplexity', array(), $json_response); + $password = \Froxlor\Validate\Validate::validate($password, '/.*[0-9]+.*/', '/.*[0-9]+.*/', 'notrequiredpasswordcomplexity', array(), $json_response); } if (Settings::Get('panel.password_special_char_required')) { - $password = validate($password, '/.*[' . preg_quote(Settings::Get('panel.password_special_char')) . ']+.*/', '/.*[' . preg_quote(Settings::Get('panel.password_special_char')) . ']+.*/', 'notrequiredpasswordcomplexity', array(), $json_response); + $password = \Froxlor\Validate\Validate::validate($password, '/.*[' . preg_quote(Settings::Get('panel.password_special_char')) . ']+.*/', '/.*[' . preg_quote(Settings::Get('panel.password_special_char')) . ']+.*/', 'notrequiredpasswordcomplexity', array(), $json_response); } } diff --git a/lib/Froxlor/Validate/Validate.php b/lib/Froxlor/Validate/Validate.php index c35ef01a..c9786096 100644 --- a/lib/Froxlor/Validate/Validate.php +++ b/lib/Froxlor/Validate/Validate.php @@ -232,4 +232,4 @@ class Validate } return false; } -} \ No newline at end of file +} diff --git a/tests/Admins/AdminsTest.php b/tests/Admins/AdminsTest.php index 406b625a..e1fcb9f8 100644 --- a/tests/Admins/AdminsTest.php +++ b/tests/Admins/AdminsTest.php @@ -6,9 +6,9 @@ use Froxlor\Api\Commands\Admins; /** * - * @covers ApiCommand - * @covers ApiParameter - * @covers Admins + * @covers \Froxlor\Api\ApiCommand + * @covers \Froxlor\Api\ApiParameter + * @covers \Froxlor\Api\Commands\Admins */ class AdminsTest extends TestCase { diff --git a/tests/Cronjobs/CronjobsTest.php b/tests/Cronjobs/CronjobsTest.php index d5fc16d4..ac7012f8 100644 --- a/tests/Cronjobs/CronjobsTest.php +++ b/tests/Cronjobs/CronjobsTest.php @@ -9,7 +9,7 @@ use Froxlor\Api\Commands\Cronjobs; * * @covers \Froxlor\Api\ApiCommand * @covers \Froxlor\Api\ApiParameter - * @covers Cronjobs + * @covers \Froxlor\Api\Commands\Cronjobs */ class CronjobsTest extends TestCase { diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 1ccf5829..b16dd30b 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -35,6 +35,9 @@ require dirname(__DIR__) . '/vendor/autoload.php'; // include table definitions require dirname(__DIR__) . '/lib/tables.inc.php'; +// include consts +require dirname(__DIR__) . '/lib/functions/logger/constant.logger.php'; + use Froxlor\Database\Database; use Froxlor\Settings;