refactor UI functions
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -233,14 +233,14 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
||||
), true, true);
|
||||
|
||||
if (strtolower($loginname_check['loginname']) == strtolower($loginname) || strtolower($loginname_check_admin['loginname']) == strtolower($loginname)) {
|
||||
standard_error('loginnameexists', $loginname, true);
|
||||
\Froxlor\UI\Response::standard_error('loginnameexists', $loginname, true);
|
||||
} // Accounts which match systemaccounts are not allowed, filtering them
|
||||
elseif (preg_match('/^' . preg_quote(Settings::Get('customer.accountprefix'), '/') . '([0-9]+)/', $loginname)) {
|
||||
standard_error('loginnameissystemaccount', Settings::Get('customer.accountprefix'), true);
|
||||
\Froxlor\UI\Response::standard_error('loginnameissystemaccount', Settings::Get('customer.accountprefix'), true);
|
||||
} elseif (! validateUsername($loginname)) {
|
||||
standard_error('loginnameiswrong', $loginname, true);
|
||||
\Froxlor\UI\Response::standard_error('loginnameiswrong', $loginname, true);
|
||||
} elseif (! validateEmail($email)) {
|
||||
standard_error('emailiswrong', $email, true);
|
||||
\Froxlor\UI\Response::standard_error('emailiswrong', $email, true);
|
||||
} else {
|
||||
|
||||
if ($customers_see_all != '1') {
|
||||
@@ -505,7 +505,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
||||
}
|
||||
|
||||
if (! validateEmail($email)) {
|
||||
standard_error('emailiswrong', $email, true);
|
||||
\Froxlor\UI\Response::standard_error('emailiswrong', $email, true);
|
||||
} else {
|
||||
|
||||
if ($deactivated != '1') {
|
||||
@@ -670,7 +670,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
||||
|
||||
// don't be stupid
|
||||
if ($id == $this->getUserDetail('adminid')) {
|
||||
standard_error('youcantdeleteyourself', '', true);
|
||||
\Froxlor\UI\Response::standard_error('youcantdeleteyourself', '', true);
|
||||
}
|
||||
|
||||
// delete admin
|
||||
|
||||
@@ -272,7 +272,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
|
||||
private function addOrUpdateCertificate($domainid = 0, $ssl_cert_file = '', $ssl_key_file = '', $ssl_ca_file = '', $ssl_cert_chainfile = '', $do_insert = false)
|
||||
{
|
||||
if ($ssl_cert_file != '' && $ssl_key_file == '') {
|
||||
standard_error('sslcertificateismissingprivatekey', '', true);
|
||||
\Froxlor\UI\Response::standard_error('sslcertificateismissingprivatekey', '', true);
|
||||
}
|
||||
|
||||
$do_verify = true;
|
||||
@@ -295,7 +295,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
|
||||
// bool openssl_x509_check_private_key ( mixed $cert , mixed $key )
|
||||
// Checks whether the given key is the private key that corresponds to cert.
|
||||
if (openssl_x509_check_private_key($ssl_cert_file, $ssl_key_file) === false) {
|
||||
standard_error('sslcertificateinvalidcertkeypair', '', true);
|
||||
\Froxlor\UI\Response::standard_error('sslcertificateinvalidcertkeypair', '', true);
|
||||
}
|
||||
|
||||
// check optional stuff
|
||||
@@ -303,18 +303,18 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
|
||||
$ca_content = openssl_x509_parse($ssl_ca_file);
|
||||
if (! is_array($ca_content)) {
|
||||
// invalid
|
||||
standard_error('sslcertificateinvalidca', '', true);
|
||||
\Froxlor\UI\Response::standard_error('sslcertificateinvalidca', '', true);
|
||||
}
|
||||
}
|
||||
if ($ssl_cert_chainfile != '') {
|
||||
$chain_content = openssl_x509_parse($ssl_cert_chainfile);
|
||||
if (! is_array($chain_content)) {
|
||||
// invalid
|
||||
standard_error('sslcertificateinvalidchain', '', true);
|
||||
\Froxlor\UI\Response::standard_error('sslcertificateinvalidchain', '', true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
standard_error('sslcertificateinvalidcert', '', true);
|
||||
\Froxlor\UI\Response::standard_error('sslcertificateinvalidcert', '', true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class CustomerBackups extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re
|
||||
|
||||
// path cannot be the customers docroot
|
||||
if ($path == \Froxlor\FileDir::makeCorrectDir($customer['documentroot'])) {
|
||||
standard_error('backupfoldercannotbedocroot', '', true);
|
||||
\Froxlor\UI\Response::standard_error('backupfoldercannotbedocroot', '', true);
|
||||
}
|
||||
|
||||
if ($backup_dbs != '1') {
|
||||
|
||||
@@ -297,11 +297,11 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
|
||||
$traffic = $traffic * 1024 * 1024;
|
||||
|
||||
if (((($this->getUserDetail('diskspace_used') + $diskspace) > $this->getUserDetail('diskspace')) && ($this->getUserDetail('diskspace') / 1024) != '-1') || ((($this->getUserDetail('mysqls_used') + $mysqls) > $this->getUserDetail('mysqls')) && $this->getUserDetail('mysqls') != '-1') || ((($this->getUserDetail('emails_used') + $emails) > $this->getUserDetail('emails')) && $this->getUserDetail('emails') != '-1') || ((($this->getUserDetail('email_accounts_used') + $email_accounts) > $this->getUserDetail('email_accounts')) && $this->getUserDetail('email_accounts') != '-1') || ((($this->getUserDetail('email_forwarders_used') + $email_forwarders) > $this->getUserDetail('email_forwarders')) && $this->getUserDetail('email_forwarders') != '-1') || ((($this->getUserDetail('email_quota_used') + $email_quota) > $this->getUserDetail('email_quota')) && $this->getUserDetail('email_quota') != '-1' && Settings::Get('system.mail_quota_enabled') == '1') || ((($this->getUserDetail('ftps_used') + $ftps) > $this->getUserDetail('ftps')) && $this->getUserDetail('ftps') != '-1') || ((($this->getUserDetail('subdomains_used') + $subdomains) > $this->getUserDetail('subdomains')) && $this->getUserDetail('subdomains') != '-1') || (($diskspace / 1024) == '-1' && ($this->getUserDetail('diskspace') / 1024) != '-1') || ($mysqls == '-1' && $this->getUserDetail('mysqls') != '-1') || ($emails == '-1' && $this->getUserDetail('emails') != '-1') || ($email_accounts == '-1' && $this->getUserDetail('email_accounts') != '-1') || ($email_forwarders == '-1' && $this->getUserDetail('email_forwarders') != '-1') || ($email_quota == '-1' && $this->getUserDetail('email_quota') != '-1' && Settings::Get('system.mail_quota_enabled') == '1') || ($ftps == '-1' && $this->getUserDetail('ftps') != '-1') || ($subdomains == '-1' && $this->getUserDetail('subdomains') != '-1')) {
|
||||
standard_error('youcantallocatemorethanyouhave', '', true);
|
||||
\Froxlor\UI\Response::standard_error('youcantallocatemorethanyouhave', '', true);
|
||||
}
|
||||
|
||||
if (! validateEmail($email)) {
|
||||
standard_error('emailiswrong', $email, true);
|
||||
\Froxlor\UI\Response::standard_error('emailiswrong', $email, true);
|
||||
} else {
|
||||
|
||||
if ($loginname != '') {
|
||||
@@ -310,12 +310,12 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
|
||||
|
||||
// Accounts which match systemaccounts are not allowed, filtering them
|
||||
if (preg_match('/^' . preg_quote(Settings::Get('customer.accountprefix'), '/') . '([0-9]+)/', $loginname)) {
|
||||
standard_error('loginnameissystemaccount', Settings::Get('customer.accountprefix'), true);
|
||||
\Froxlor\UI\Response::standard_error('loginnameissystemaccount', Settings::Get('customer.accountprefix'), true);
|
||||
}
|
||||
|
||||
// Additional filtering for Bug #962
|
||||
if (function_exists('posix_getpwnam') && ! in_array("posix_getpwnam", explode(",", ini_get('disable_functions'))) && posix_getpwnam($loginname)) {
|
||||
standard_error('loginnameissystemaccount', Settings::Get('customer.accountprefix'), true);
|
||||
\Froxlor\UI\Response::standard_error('loginnameissystemaccount', Settings::Get('customer.accountprefix'), true);
|
||||
}
|
||||
} else {
|
||||
$accountnumber = intval(Settings::Get('system.lastaccountnumber')) + 1;
|
||||
@@ -341,12 +341,12 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
|
||||
), true, true);
|
||||
|
||||
if (strtolower($loginname_check['loginname']) == strtolower($loginname) || strtolower($loginname_check_admin['loginname']) == strtolower($loginname)) {
|
||||
standard_error('loginnameexists', $loginname, true);
|
||||
\Froxlor\UI\Response::standard_error('loginnameexists', $loginname, true);
|
||||
} elseif (! validateUsername($loginname, Settings::Get('panel.unix_names'), 14 - strlen(Settings::Get('customer.mysqlprefix')))) {
|
||||
if (strlen($loginname) > 14 - strlen(Settings::Get('customer.mysqlprefix'))) {
|
||||
standard_error('loginnameiswrong2', 14 - strlen(Settings::Get('customer.mysqlprefix')), true);
|
||||
\Froxlor\UI\Response::standard_error('loginnameiswrong2', 14 - strlen(Settings::Get('customer.mysqlprefix')), true);
|
||||
} else {
|
||||
standard_error('loginnameiswrong', $loginname, true);
|
||||
\Froxlor\UI\Response::standard_error('loginnameiswrong', $loginname, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
|
||||
$documentroot = \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.documentroot_prefix') . '/' . $loginname);
|
||||
|
||||
if (file_exists($documentroot)) {
|
||||
standard_error('documentrootexists', $documentroot, true);
|
||||
\Froxlor\UI\Response::standard_error('documentrootexists', $documentroot, true);
|
||||
}
|
||||
|
||||
if ($createstdsubdomain != '1') {
|
||||
@@ -712,7 +712,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
|
||||
|
||||
if ($_mailerror) {
|
||||
$this->logger()->logAction(ADM_ACTION, LOG_ERR, "[API] Error sending mail: " . $mailerr_msg);
|
||||
standard_error('errorsendingmail', $email, true);
|
||||
\Froxlor\UI\Response::standard_error('errorsendingmail', $email, true);
|
||||
}
|
||||
|
||||
$this->mailer()->clearAddresses();
|
||||
@@ -926,16 +926,16 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
|
||||
$traffic = $traffic * 1024 * 1024;
|
||||
|
||||
if (((($this->getUserDetail('diskspace_used') + $diskspace - $result['diskspace']) > $this->getUserDetail('diskspace')) && ($this->getUserDetail('diskspace') / 1024) != '-1') || ((($this->getUserDetail('mysqls_used') + $mysqls - $result['mysqls']) > $this->getUserDetail('mysqls')) && $this->getUserDetail('mysqls') != '-1') || ((($this->getUserDetail('emails_used') + $emails - $result['emails']) > $this->getUserDetail('emails')) && $this->getUserDetail('emails') != '-1') || ((($this->getUserDetail('email_accounts_used') + $email_accounts - $result['email_accounts']) > $this->getUserDetail('email_accounts')) && $this->getUserDetail('email_accounts') != '-1') || ((($this->getUserDetail('email_forwarders_used') + $email_forwarders - $result['email_forwarders']) > $this->getUserDetail('email_forwarders')) && $this->getUserDetail('email_forwarders') != '-1') || ((($this->getUserDetail('email_quota_used') + $email_quota - $result['email_quota']) > $this->getUserDetail('email_quota')) && $this->getUserDetail('email_quota') != '-1' && Settings::Get('system.mail_quota_enabled') == '1') || ((($this->getUserDetail('ftps_used') + $ftps - $result['ftps']) > $this->getUserDetail('ftps')) && $this->getUserDetail('ftps') != '-1') || ((($this->getUserDetail('subdomains_used') + $subdomains - $result['subdomains']) > $this->getUserDetail('subdomains')) && $this->getUserDetail('subdomains') != '-1') || (($diskspace / 1024) == '-1' && ($this->getUserDetail('diskspace') / 1024) != '-1') || ($mysqls == '-1' && $this->getUserDetail('mysqls') != '-1') || ($emails == '-1' && $this->getUserDetail('emails') != '-1') || ($email_accounts == '-1' && $this->getUserDetail('email_accounts') != '-1') || ($email_forwarders == '-1' && $this->getUserDetail('email_forwarders') != '-1') || ($email_quota == '-1' && $this->getUserDetail('email_quota') != '-1' && Settings::Get('system.mail_quota_enabled') == '1') || ($ftps == '-1' && $this->getUserDetail('ftps') != '-1') || ($subdomains == '-1' && $this->getUserDetail('subdomains') != '-1')) {
|
||||
standard_error('youcantallocatemorethanyouhave', '', true);
|
||||
\Froxlor\UI\Response::standard_error('youcantallocatemorethanyouhave', '', true);
|
||||
}
|
||||
|
||||
if ($email == '') {
|
||||
standard_error(array(
|
||||
\Froxlor\UI\Response::standard_error(array(
|
||||
'stringisempty',
|
||||
'emailadd'
|
||||
), '', true);
|
||||
} elseif (! validateEmail($email)) {
|
||||
standard_error('emailiswrong', $email, true);
|
||||
\Froxlor\UI\Response::standard_error('emailiswrong', $email, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1322,7 +1322,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
|
||||
'adminid' => $move_to_admin
|
||||
));
|
||||
if ($move_result != true) {
|
||||
standard_error('moveofcustomerfailed', $move_result, true);
|
||||
\Froxlor\UI\Response::standard_error('moveofcustomerfailed', $move_result, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
||||
|
||||
// duplicate check
|
||||
if ($path_dupe_check['path'] == $path) {
|
||||
standard_error('errordocpathdupe', $userpath, true);
|
||||
\Froxlor\UI\Response::standard_error('errordocpathdupe', $userpath, true);
|
||||
}
|
||||
|
||||
// insert the entry
|
||||
|
||||
@@ -88,9 +88,9 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res
|
||||
|
||||
// duplicate check
|
||||
if ($username_path_check['username'] == $username && $username_path_check['path'] == $path) {
|
||||
standard_error('userpathcombinationdupe', '', true);
|
||||
\Froxlor\UI\Response::standard_error('userpathcombinationdupe', '', true);
|
||||
} elseif ($password == $username) {
|
||||
standard_error('passwordshouldnotbeusername', '', true);
|
||||
\Froxlor\UI\Response::standard_error('passwordshouldnotbeusername', '', true);
|
||||
}
|
||||
|
||||
// insert the entry
|
||||
@@ -236,7 +236,7 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res
|
||||
);
|
||||
if (! empty($password)) {
|
||||
if ($password == $result['username']) {
|
||||
standard_error('passwordshouldnotbeusername', '', true);
|
||||
\Froxlor\UI\Response::standard_error('passwordshouldnotbeusername', '', true);
|
||||
}
|
||||
if (CRYPT_STD_DES == 1) {
|
||||
$saltfordescrypt = substr(md5(uniqid(microtime(), 1)), 4, 2);
|
||||
|
||||
@@ -73,7 +73,7 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
|
||||
}
|
||||
|
||||
if ($result['subisbinddomain'] != '1') {
|
||||
standard_error('dns_domain_nodns', '', true);
|
||||
\Froxlor\UI\Response::standard_error('dns_domain_nodns', '', true);
|
||||
}
|
||||
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
@@ -326,7 +326,7 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
|
||||
}
|
||||
|
||||
if ($result['subisbinddomain'] != '1') {
|
||||
standard_error('dns_domain_nodns', '', true);
|
||||
\Froxlor\UI\Response::standard_error('dns_domain_nodns', '', true);
|
||||
}
|
||||
|
||||
$zone = createDomainZone($id);
|
||||
|
||||
@@ -232,11 +232,11 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
|
||||
|
||||
// validation
|
||||
if ($p_domain == Settings::Get('system.hostname')) {
|
||||
standard_error('admin_domain_emailsystemhostname', '', true);
|
||||
\Froxlor\UI\Response::standard_error('admin_domain_emailsystemhostname', '', true);
|
||||
}
|
||||
|
||||
if (substr($p_domain, 0, 4) == 'xn--') {
|
||||
standard_error('domain_nopunycode', '', true);
|
||||
\Froxlor\UI\Response::standard_error('domain_nopunycode', '', true);
|
||||
}
|
||||
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
@@ -247,7 +247,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
|
||||
|
||||
// Check whether domain validation is enabled and if, validate the domain
|
||||
if (Settings::Get('system.validate_domain') && ! validateDomain($domain)) {
|
||||
standard_error(array(
|
||||
\Froxlor\UI\Response::standard_error(array(
|
||||
'stringiswrong',
|
||||
'mydomain'
|
||||
), '', true);
|
||||
@@ -265,7 +265,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
|
||||
'adminid' => $adminid
|
||||
), true, true);
|
||||
if (empty($admin)) {
|
||||
dynamic_error("Selected admin cannot have any more domains or could not be found");
|
||||
\Froxlor\UI\Response::dynamic_error("Selected admin cannot have any more domains or could not be found");
|
||||
}
|
||||
unset($admin);
|
||||
}
|
||||
@@ -342,7 +342,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
|
||||
), true, true);
|
||||
|
||||
if (! isset($phpsettingid_check['id']) || $phpsettingid_check['id'] == '0' || $phpsettingid_check['id'] != $phpsettingid) {
|
||||
standard_error('phpsettingidwrong', '', true);
|
||||
\Froxlor\UI\Response::standard_error('phpsettingidwrong', '', true);
|
||||
}
|
||||
|
||||
if ((int) Settings::Get('system.mod_fcgid') == 1) {
|
||||
@@ -408,12 +408,12 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
|
||||
|
||||
// We can't enable let's encrypt for wildcard - domains if using acme-v1
|
||||
if ($serveraliasoption == '0' && $letsencrypt == '1' && Settings::Get('system.leapiversion') == '1') {
|
||||
standard_error('nowildcardwithletsencrypt', '', true);
|
||||
\Froxlor\UI\Response::standard_error('nowildcardwithletsencrypt', '', true);
|
||||
}
|
||||
// if using acme-v2 we cannot issue wildcard-certificates
|
||||
// because they currently only support the dns-01 challenge
|
||||
if ($serveraliasoption == '0' && $letsencrypt == '1' && Settings::Get('system.leapiversion') == '2') {
|
||||
standard_error('nowildcardwithletsencryptv2', '', true);
|
||||
\Froxlor\UI\Response::standard_error('nowildcardwithletsencryptv2', '', true);
|
||||
}
|
||||
|
||||
// Temporarily deactivate ssl_redirect until Let's Encrypt certificate was generated
|
||||
@@ -423,7 +423,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
|
||||
|
||||
if (! preg_match('/^https?\:\/\//', $documentroot)) {
|
||||
if (strstr($documentroot, ":") !== false) {
|
||||
standard_error('pathmaynotcontaincolon', '', true);
|
||||
\Froxlor\UI\Response::standard_error('pathmaynotcontaincolon', '', true);
|
||||
} else {
|
||||
$documentroot = \Froxlor\FileDir::makeCorrectDir($documentroot);
|
||||
}
|
||||
@@ -481,7 +481,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
|
||||
}
|
||||
|
||||
if (count($ipandports) == 0) {
|
||||
standard_error('noipportgiven', '', true);
|
||||
\Froxlor\UI\Response::standard_error('noipportgiven', '', true);
|
||||
}
|
||||
|
||||
if ($email_only == '1') {
|
||||
@@ -504,21 +504,21 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
|
||||
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
if ($domain == '') {
|
||||
standard_error(array(
|
||||
\Froxlor\UI\Response::standard_error(array(
|
||||
'stringisempty',
|
||||
'mydomain'
|
||||
), '', true);
|
||||
} elseif ($documentroot == '') {
|
||||
standard_error(array(
|
||||
\Froxlor\UI\Response::standard_error(array(
|
||||
'stringisempty',
|
||||
'mydocumentroot'
|
||||
), '', true);
|
||||
} elseif ($customerid == 0) {
|
||||
standard_error('adduserfirst', '', true);
|
||||
\Froxlor\UI\Response::standard_error('adduserfirst', '', true);
|
||||
} elseif (strtolower($domain_check['domain']) == strtolower($domain)) {
|
||||
standard_error('domainalreadyexists', $idna_convert->decode($domain), true);
|
||||
\Froxlor\UI\Response::standard_error('domainalreadyexists', $idna_convert->decode($domain), true);
|
||||
} elseif ($aliasdomain_check['id'] != $aliasdomain) {
|
||||
standard_error('domainisaliasorothercustomer', '', true);
|
||||
\Froxlor\UI\Response::standard_error('domainisaliasorothercustomer', '', true);
|
||||
} else {
|
||||
$wwwserveralias = ($serveraliasoption == '1') ? '1' : '0';
|
||||
$iswildcarddomain = ($serveraliasoption == '0') ? '1' : '0';
|
||||
@@ -866,7 +866,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
|
||||
}
|
||||
$customer = Database::pexecute_first($customer_stmt, $params, true, true);
|
||||
if (empty($customer) || $customer['customerid'] != $customerid) {
|
||||
standard_error('customerdoesntexist', '', true);
|
||||
\Froxlor\UI\Response::standard_error('customerdoesntexist', '', true);
|
||||
}
|
||||
} else {
|
||||
$customerid = $result['customerid'];
|
||||
@@ -891,7 +891,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
|
||||
), true, true);
|
||||
|
||||
if (empty($admin) || $admin['adminid'] != $adminid) {
|
||||
standard_error('admindoesntexist', '', true);
|
||||
\Froxlor\UI\Response::standard_error('admindoesntexist', '', true);
|
||||
}
|
||||
} else {
|
||||
$adminid = $result['adminid'];
|
||||
@@ -966,7 +966,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
|
||||
}
|
||||
|
||||
if (! preg_match('/^https?\:\/\//', $documentroot) && strstr($documentroot, ":") !== false) {
|
||||
standard_error('pathmaynotcontaincolon', '', true);
|
||||
\Froxlor\UI\Response::standard_error('pathmaynotcontaincolon', '', true);
|
||||
}
|
||||
} else {
|
||||
$isbinddomain = $result['isbinddomain'];
|
||||
@@ -991,7 +991,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
|
||||
), true, true);
|
||||
|
||||
if (! isset($phpsettingid_check['id']) || $phpsettingid_check['id'] == '0' || $phpsettingid_check['id'] != $phpsettingid) {
|
||||
standard_error('phpsettingidwrong', '', true);
|
||||
\Froxlor\UI\Response::standard_error('phpsettingidwrong', '', true);
|
||||
}
|
||||
|
||||
if ((int) Settings::Get('system.mod_fcgid') == 1) {
|
||||
@@ -1048,12 +1048,12 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
|
||||
|
||||
// We can't enable let's encrypt for wildcard domains when using acme-v1
|
||||
if ($serveraliasoption == '0' && $letsencrypt == '1' && Settings::Get('system.leapiversion') == '1') {
|
||||
standard_error('nowildcardwithletsencrypt', '', true);
|
||||
\Froxlor\UI\Response::standard_error('nowildcardwithletsencrypt', '', true);
|
||||
}
|
||||
// if using acme-v2 we cannot issue wildcard-certificates
|
||||
// because they currently only support the dns-01 challenge
|
||||
if ($serveraliasoption == '0' && $letsencrypt == '1' && Settings::Get('system.leapiversion') == '2') {
|
||||
standard_error('nowildcardwithletsencryptv2', '', true);
|
||||
\Froxlor\UI\Response::standard_error('nowildcardwithletsencryptv2', '', true);
|
||||
}
|
||||
|
||||
// Temporarily deactivate ssl_redirect until Let's Encrypt certificate was generated
|
||||
@@ -1121,11 +1121,11 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
|
||||
}
|
||||
|
||||
if (count($ipandports) == 0) {
|
||||
standard_error('noipportgiven', '', true);
|
||||
\Froxlor\UI\Response::standard_error('noipportgiven', '', true);
|
||||
}
|
||||
|
||||
if ($aliasdomain_check['id'] != $aliasdomain) {
|
||||
standard_error('domainisaliasorothercustomer', '', true);
|
||||
\Froxlor\UI\Response::standard_error('domainisaliasorothercustomer', '', true);
|
||||
}
|
||||
|
||||
if ($issubof <= 0) {
|
||||
@@ -1685,7 +1685,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
|
||||
), $aip_param);
|
||||
$ipandport_check = Database::pexecute_first($ipandport_check_stmt, $ip_params, true, true);
|
||||
if (! isset($ipandport_check['id']) || $ipandport_check['id'] == '0' || $ipandport_check['id'] != $ipandport) {
|
||||
standard_error('ipportdoesntexist', '', true);
|
||||
\Froxlor\UI\Response::standard_error('ipportdoesntexist', '', true);
|
||||
} else {
|
||||
$ipandports[] = $ipandport;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
|
||||
|
||||
// check for imap||pop3 == 1, see #1298
|
||||
if ($customer['imap'] != '1' && $customer['pop3'] != '1') {
|
||||
standard_error('notallowedtouseaccounts', '', true);
|
||||
\Froxlor\UI\Response::standard_error('notallowedtouseaccounts', '', true);
|
||||
}
|
||||
|
||||
// get email address
|
||||
@@ -91,8 +91,8 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
|
||||
throw new \Exception("Email address '" . $email_full . "' has already an account assigned.", 406);
|
||||
}
|
||||
|
||||
if (\Froxlor\Validate\Validate::checkMailAccDeletionState($email_full)) {
|
||||
standard_error(array(
|
||||
if (\Froxlor\Validate\Check::checkMailAccDeletionState($email_full)) {
|
||||
\Froxlor\UI\Response::standard_error(array(
|
||||
'mailaccistobedeleted'
|
||||
), $email_full, true);
|
||||
}
|
||||
@@ -101,7 +101,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
|
||||
if (Settings::Get('panel.sendalternativemail') == 1) {
|
||||
$alternative_email = $idna_convert->encode(validate($alternative_email, 'alternative_email', '', '', array(), true));
|
||||
if (! validateEmail($alternative_email)) {
|
||||
standard_error('emailiswrong', $alternative_email, true);
|
||||
\Froxlor\UI\Response::standard_error('emailiswrong', $alternative_email, true);
|
||||
}
|
||||
} else {
|
||||
$alternative_email = '';
|
||||
@@ -110,7 +110,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
|
||||
// validate quota if enabled
|
||||
if (Settings::Get('system.mail_quota_enabled') == 1) {
|
||||
if ($customer['email_quota'] != '-1' && ($quota == 0 || ($quota + $customer['email_quota_used']) > $customer['email_quota'])) {
|
||||
standard_error('allocatetoomuchquota', $quota, true);
|
||||
\Froxlor\UI\Response::standard_error('allocatetoomuchquota', $quota, true);
|
||||
}
|
||||
} else {
|
||||
// disable
|
||||
@@ -118,7 +118,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
|
||||
}
|
||||
|
||||
if ($password == $email_full) {
|
||||
standard_error('passwordshouldnotbeusername', '', true);
|
||||
\Froxlor\UI\Response::standard_error('passwordshouldnotbeusername', '', true);
|
||||
}
|
||||
|
||||
// encrypt the password
|
||||
@@ -229,7 +229,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
|
||||
|
||||
if ($_mailerror) {
|
||||
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_ERR, "[API] Error sending mail: " . $mailerr_msg);
|
||||
standard_error('errorsendingmail', $email_full, true);
|
||||
\Froxlor\UI\Response::standard_error('errorsendingmail', $email_full, true);
|
||||
}
|
||||
|
||||
$this->mailer()->clearAddresses();
|
||||
@@ -259,7 +259,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
|
||||
|
||||
if ($_mailerror) {
|
||||
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_ERR, "[API] Error sending mail: " . $mailerr_msg);
|
||||
standard_error(array(
|
||||
\Froxlor\UI\Response::standard_error(array(
|
||||
'errorsendingmail'
|
||||
), $alternative_email, true);
|
||||
}
|
||||
@@ -344,7 +344,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
|
||||
);
|
||||
if (! empty($password)) {
|
||||
if ($password == $result['email_full']) {
|
||||
standard_error('passwordshouldnotbeusername', '', true);
|
||||
\Froxlor\UI\Response::standard_error('passwordshouldnotbeusername', '', true);
|
||||
}
|
||||
$password = validatePassword($password, true);
|
||||
$cryptPassword = \Froxlor\System\Crypt::makeCryptPassword($password);
|
||||
@@ -358,7 +358,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
|
||||
if (Settings::Get('system.mail_quota_enabled') == 1) {
|
||||
if ($quota != $result['quota']) {
|
||||
if ($customer['email_quota'] != '-1' && ($quota == 0 || ($quota + $customer['email_quota_used'] - $result['quota']) > $customer['email_quota'])) {
|
||||
standard_error('allocatetoomuchquota', $quota, true);
|
||||
\Froxlor\UI\Response::standard_error('allocatetoomuchquota', $quota, true);
|
||||
}
|
||||
if (! empty($upd_query)) {
|
||||
$upd_query .= ", ";
|
||||
|
||||
@@ -70,11 +70,11 @@ class EmailForwarders extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re
|
||||
$destination = trim($destination);
|
||||
|
||||
if (! validateEmail($destination)) {
|
||||
standard_error('destinationiswrong', $destination, true);
|
||||
\Froxlor\UI\Response::standard_error('destinationiswrong', $destination, true);
|
||||
} elseif ($destination == $result['email']) {
|
||||
standard_error('destinationalreadyexistasmail', $destination, true);
|
||||
\Froxlor\UI\Response::standard_error('destinationalreadyexistasmail', $destination, true);
|
||||
} elseif (in_array($destination, $result['destination_array'])) {
|
||||
standard_error('destinationalreadyexist', $destination, true);
|
||||
\Froxlor\UI\Response::standard_error('destinationalreadyexist', $destination, true);
|
||||
}
|
||||
|
||||
// get needed customer info to reduce the email-forwarder-counter by one
|
||||
|
||||
@@ -66,7 +66,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
||||
'domainname' => $domain
|
||||
));
|
||||
if ($domain_check['isemaildomain'] == 0) {
|
||||
standard_error('maindomainnonexist', $domain, true);
|
||||
\Froxlor\UI\Response::standard_error('maindomainnonexist', $domain, true);
|
||||
}
|
||||
|
||||
if (Settings::Get('catchall.catchall_enabled') != '1') {
|
||||
@@ -87,7 +87,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
||||
|
||||
// validate it
|
||||
if (! validateEmail($email_full)) {
|
||||
standard_error('emailiswrong', $email_full, true);
|
||||
\Froxlor\UI\Response::standard_error('emailiswrong', $email_full, true);
|
||||
}
|
||||
|
||||
// get needed customer info to reduce the email-address-counter by one
|
||||
@@ -107,9 +107,9 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
||||
$email_check = Database::pexecute_first($stmt, $params, true, true);
|
||||
|
||||
if (strtolower($email_check['email_full']) == strtolower($email_full)) {
|
||||
standard_error('emailexistalready', $email_full, true);
|
||||
\Froxlor\UI\Response::standard_error('emailexistalready', $email_full, true);
|
||||
} elseif ($email_check['email'] == $email) {
|
||||
standard_error('youhavealreadyacatchallforthisdomain', '', true);
|
||||
\Froxlor\UI\Response::standard_error('youhavealreadyacatchallforthisdomain', '', true);
|
||||
}
|
||||
|
||||
$stmt = Database::prepare("
|
||||
@@ -209,7 +209,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
||||
// if enabling catchall is not allowed by settings, we do not need
|
||||
// to run update()
|
||||
if (Settings::Get('catchall.catchall_enabled') != '1') {
|
||||
standard_error(array(
|
||||
\Froxlor\UI\Response::standard_error(array(
|
||||
'operationnotpermitted',
|
||||
'featureisdisabled'
|
||||
), 'catchall', true);
|
||||
|
||||
@@ -165,7 +165,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
||||
$limit_extensions = validate($limit_extensions, 'limit_extensions', '/^(\.[a-z]([a-z0-9]+)\ ?)+$/', '', array(), true);
|
||||
|
||||
if (strlen($description) == 0 || strlen($description) > 50) {
|
||||
standard_error('descriptioninvalid', '', true);
|
||||
\Froxlor\UI\Response::standard_error('descriptioninvalid', '', true);
|
||||
}
|
||||
|
||||
$ins_stmt = Database::prepare("
|
||||
@@ -281,7 +281,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
||||
$limit_extensions = validate($limit_extensions, 'limit_extensions', '/^(\.[a-z]([a-z0-9]+)\ ?)+$/', '', array(), true);
|
||||
|
||||
if (strlen($description) == 0 || strlen($description) > 50) {
|
||||
standard_error('descriptioninvalid', '', true);
|
||||
\Froxlor\UI\Response::standard_error('descriptioninvalid', '', true);
|
||||
}
|
||||
|
||||
$upd_stmt = Database::prepare("
|
||||
@@ -341,7 +341,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
||||
$id = $this->getParam('id');
|
||||
|
||||
if ($id == 1) {
|
||||
standard_error('cannotdeletedefaultphpconfig', '', true);
|
||||
\Froxlor\UI\Response::standard_error('cannotdeletedefaultphpconfig', '', true);
|
||||
}
|
||||
|
||||
$result = $this->apiCall('FpmDaemons.get', array(
|
||||
|
||||
@@ -87,7 +87,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand
|
||||
'additional_info' => $message_addinfo
|
||||
));
|
||||
} else {
|
||||
standard_error('customized_version', '', true);
|
||||
\Froxlor\UI\Response::standard_error('customized_version', '', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
|
||||
|
||||
if (Settings::Get('customer.ftpatdomain') == '1') {
|
||||
if ($ftpusername == '') {
|
||||
standard_error(array(
|
||||
\Froxlor\UI\Response::standard_error(array(
|
||||
'stringisempty',
|
||||
'username'
|
||||
), '', true);
|
||||
@@ -109,7 +109,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
|
||||
), true, true);
|
||||
|
||||
if ($ftpdomain_check && $ftpdomain_check['domain'] != $ftpdomain) {
|
||||
standard_error('maindomainnonexist', $ftpdomain, true);
|
||||
\Froxlor\UI\Response::standard_error('maindomainnonexist', $ftpdomain, true);
|
||||
}
|
||||
$username = $ftpusername . "@" . $ftpdomain;
|
||||
} else {
|
||||
@@ -124,9 +124,9 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
|
||||
), true, true);
|
||||
|
||||
if (! empty($username_check) && $username_check['username'] = $username) {
|
||||
standard_error('usernamealreadyexists', $username, true);
|
||||
\Froxlor\UI\Response::standard_error('usernamealreadyexists', $username, true);
|
||||
} elseif ($username == $password) {
|
||||
standard_error('passwordshouldnotbeusername', '', true);
|
||||
\Froxlor\UI\Response::standard_error('passwordshouldnotbeusername', '', true);
|
||||
} else {
|
||||
$path = \Froxlor\FileDir::makeCorrectDir($customer['documentroot'] . '/' . $path);
|
||||
$cryptPassword = \Froxlor\System\Crypt::makeCryptPassword($password);
|
||||
@@ -216,7 +216,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
|
||||
|
||||
if ($_mailerror) {
|
||||
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_ERR, "[API] Error sending mail: " . $mailerr_msg);
|
||||
standard_error('errorsendingmail', $customer['email'], true);
|
||||
\Froxlor\UI\Response::standard_error('errorsendingmail', $customer['email'], true);
|
||||
}
|
||||
|
||||
$this->mailer()->clearAddresses();
|
||||
@@ -356,7 +356,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
|
||||
$password = validatePassword($password, true);
|
||||
|
||||
if ($password == $result['username']) {
|
||||
standard_error('passwordshouldnotbeusername', '', true);
|
||||
\Froxlor\UI\Response::standard_error('passwordshouldnotbeusername', '', true);
|
||||
}
|
||||
$cryptPassword = \Froxlor\System\Crypt::makeCryptPassword($password);
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
|
||||
));
|
||||
|
||||
if ($result_checkfordouble['id'] != '') {
|
||||
standard_error('myipnotdouble', '', true);
|
||||
\Froxlor\UI\Response::standard_error('myipnotdouble', '', true);
|
||||
}
|
||||
|
||||
$ins_stmt = Database::prepare("
|
||||
@@ -390,9 +390,9 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
|
||||
}
|
||||
|
||||
if ($result['ip'] != $ip && $result['ip'] == Settings::Get('system.ipaddress') && $result_sameipotherport['id'] == '') {
|
||||
standard_error('cantchangesystemip', '', true);
|
||||
\Froxlor\UI\Response::standard_error('cantchangesystemip', '', true);
|
||||
} elseif ($result_checkfordouble['id'] != '' && $result_checkfordouble['id'] != $id) {
|
||||
standard_error('myipnotdouble', '', true);
|
||||
\Froxlor\UI\Response::standard_error('myipnotdouble', '', true);
|
||||
} else {
|
||||
|
||||
$upd_stmt = Database::prepare("
|
||||
@@ -506,13 +506,13 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
|
||||
$this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] deleted IP/port '" . $result['ip'] . ":" . $result['port'] . "'");
|
||||
return $this->response(200, "successfull", $result);
|
||||
} else {
|
||||
standard_error('cantdeletesystemip', '', true);
|
||||
\Froxlor\UI\Response::standard_error('cantdeletesystemip', '', true);
|
||||
}
|
||||
} else {
|
||||
standard_error('cantdeletedefaultip', '', true);
|
||||
\Froxlor\UI\Response::standard_error('cantdeletedefaultip', '', true);
|
||||
}
|
||||
} else {
|
||||
standard_error('ipstillhasdomains', '', true);
|
||||
\Froxlor\UI\Response::standard_error('ipstillhasdomains', '', true);
|
||||
}
|
||||
}
|
||||
throw new \Exception("Not allowed to execute given command.", 403);
|
||||
|
||||
@@ -84,7 +84,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
||||
|
||||
// we've checked against the password in dbm->createDatabase
|
||||
if ($username == false) {
|
||||
standard_error('passwordshouldnotbeusername', '', true);
|
||||
\Froxlor\UI\Response::standard_error('passwordshouldnotbeusername', '', true);
|
||||
}
|
||||
|
||||
// add database info to froxlor
|
||||
@@ -159,7 +159,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
||||
|
||||
if ($_mailerror) {
|
||||
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_ERR, "[API] Error sending mail: " . $mailerr_msg);
|
||||
standard_error('errorsendingmail', $userinfo['email'], true);
|
||||
\Froxlor\UI\Response::standard_error('errorsendingmail', $userinfo['email'], true);
|
||||
}
|
||||
|
||||
$this->mailer()->clearAddresses();
|
||||
@@ -318,7 +318,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
||||
$password = validatePassword($password, true);
|
||||
|
||||
if ($password == $result['databasename']) {
|
||||
standard_error('passwordshouldnotbeusername', '', true);
|
||||
\Froxlor\UI\Response::standard_error('passwordshouldnotbeusername', '', true);
|
||||
}
|
||||
|
||||
// Begin root-session
|
||||
|
||||
@@ -280,7 +280,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
|
||||
}
|
||||
|
||||
if (strlen($description) == 0 || strlen($description) > 50) {
|
||||
standard_error('descriptioninvalid', '', true);
|
||||
\Froxlor\UI\Response::standard_error('descriptioninvalid', '', true);
|
||||
}
|
||||
|
||||
$ins_stmt = Database::prepare("
|
||||
@@ -475,7 +475,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
|
||||
}
|
||||
|
||||
if (strlen($description) == 0 || strlen($description) > 50) {
|
||||
standard_error('descriptioninvalid', '', true);
|
||||
\Froxlor\UI\Response::standard_error('descriptioninvalid', '', true);
|
||||
}
|
||||
|
||||
$upd_stmt = Database::prepare("
|
||||
@@ -560,11 +560,11 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
|
||||
));
|
||||
|
||||
if ((Settings::Get('system.mod_fcgid') == '1' && Settings::Get('system.mod_fcgid_defaultini_ownvhost') == $id) || (Settings::Get('phpfpm.enabled') == '1' && Settings::Get('phpfpm.vhost_defaultini') == $id)) {
|
||||
standard_error('cannotdeletehostnamephpconfig', '', true);
|
||||
\Froxlor\UI\Response::standard_error('cannotdeletehostnamephpconfig', '', true);
|
||||
}
|
||||
|
||||
if ((Settings::Get('system.mod_fcgid') == '1' && Settings::Get('system.mod_fcgid_defaultini') == $id) || (Settings::Get('phpfpm.enabled') == '1' && Settings::Get('phpfpm.defaultini') == $id)) {
|
||||
standard_error('cannotdeletedefaultphpconfig', '', true);
|
||||
\Froxlor\UI\Response::standard_error('cannotdeletedefaultphpconfig', '', true);
|
||||
}
|
||||
|
||||
// set php-config to default for all domains using the
|
||||
|
||||
@@ -91,7 +91,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
||||
|
||||
// validation
|
||||
if (substr($subdomain, 0, 4) == 'xn--') {
|
||||
standard_error('domain_nopunycode', '', true);
|
||||
\Froxlor\UI\Response::standard_error('domain_nopunycode', '', true);
|
||||
}
|
||||
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
@@ -104,13 +104,13 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
||||
$completedomain = $subdomain . '.' . $domain;
|
||||
|
||||
if (Settings::Get('system.validate_domain') && ! validateDomain($completedomain)) {
|
||||
standard_error(array(
|
||||
\Froxlor\UI\Response::standard_error(array(
|
||||
'stringiswrong',
|
||||
'mydomain'
|
||||
), '', true);
|
||||
}
|
||||
if ($completedomain == Settings::Get('system.hostname')) {
|
||||
standard_error('admin_domain_emailsystemhostname', '', true);
|
||||
\Froxlor\UI\Response::standard_error('admin_domain_emailsystemhostname', '', true);
|
||||
}
|
||||
|
||||
// check whether the domain already exists
|
||||
@@ -128,7 +128,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
||||
|
||||
if ($completedomain_check) {
|
||||
// no exception so far - domain exists
|
||||
standard_error('domainexistalready', $completedomain, true);
|
||||
\Froxlor\UI\Response::standard_error('domainexistalready', $completedomain, true);
|
||||
}
|
||||
|
||||
// alias domain checked?
|
||||
@@ -152,7 +152,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
||||
"customerid" => $customer['customerid']
|
||||
), true, true);
|
||||
if ($aliasdomain_check['id'] != $aliasdomain) {
|
||||
standard_error('domainisaliasorothercustomer', '', true);
|
||||
\Froxlor\UI\Response::standard_error('domainisaliasorothercustomer', '', true);
|
||||
}
|
||||
\Froxlor\Domain\Domain::triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger());
|
||||
}
|
||||
@@ -181,13 +181,13 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
||||
|
||||
if (! $domain_check) {
|
||||
// the given main-domain
|
||||
standard_error('maindomainnonexist', $domain, true);
|
||||
\Froxlor\UI\Response::standard_error('maindomainnonexist', $domain, true);
|
||||
} elseif ($subdomain == 'www' && $domain_check['wwwserveralias'] == '1') {
|
||||
// you cannot add 'www' as subdomain when the maindomain generates a www-alias
|
||||
standard_error('wwwnotallowed', '', true);
|
||||
\Froxlor\UI\Response::standard_error('wwwnotallowed', '', true);
|
||||
} elseif (strtolower($completedomain_check['domain']) == strtolower($completedomain)) {
|
||||
// the domain does already exist as main-domain
|
||||
standard_error('domainexistalready', $completedomain, true);
|
||||
\Froxlor\UI\Response::standard_error('domainexistalready', $completedomain, true);
|
||||
}
|
||||
|
||||
// if allowed, check for 'is email domain'-flag
|
||||
@@ -204,7 +204,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
||||
$ssl_redirect = '1';
|
||||
$_doredirect = true;
|
||||
} else {
|
||||
standard_error('sslredirectonlypossiblewithsslipport', '', true);
|
||||
\Froxlor\UI\Response::standard_error('sslredirectonlypossiblewithsslipport', '', true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
||||
if (\Froxlor\Domain\Domain::domainHasSslIpPort($domain_check['id']) == true) {
|
||||
$letsencrypt = '1';
|
||||
} else {
|
||||
standard_error('letsencryptonlypossiblewithsslipport', '', true);
|
||||
\Froxlor\UI\Response::standard_error('letsencryptonlypossiblewithsslipport', '', true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,7 +508,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
||||
"customerid" => $customer['customerid']
|
||||
), true, true);
|
||||
if ($aliasdomain_check['id'] != $aliasdomain) {
|
||||
standard_error('domainisaliasorothercustomer', '', true);
|
||||
\Froxlor\UI\Response::standard_error('domainisaliasorothercustomer', '', true);
|
||||
}
|
||||
\Froxlor\Domain\Domain::triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger());
|
||||
}
|
||||
@@ -540,7 +540,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
||||
$ssl_redirect = '1';
|
||||
$_doredirect = true;
|
||||
} else {
|
||||
standard_error('sslredirectonlypossiblewithsslipport', '', true);
|
||||
\Froxlor\UI\Response::standard_error('sslredirectonlypossiblewithsslipport', '', true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -550,18 +550,18 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
||||
if (\Froxlor\Domain\Domain::domainHasSslIpPort($result['id']) == true) {
|
||||
$letsencrypt = '1';
|
||||
} else {
|
||||
standard_error('letsencryptonlypossiblewithsslipport', '', true);
|
||||
\Froxlor\UI\Response::standard_error('letsencryptonlypossiblewithsslipport', '', true);
|
||||
}
|
||||
}
|
||||
|
||||
// We can't enable let's encrypt for wildcard - domains when using acme-v1
|
||||
if ($iswildcarddomain == '1' && $letsencrypt == '1' && Settings::Get('system.leapiversion') == '1') {
|
||||
standard_error('nowildcardwithletsencrypt');
|
||||
\Froxlor\UI\Response::standard_error('nowildcardwithletsencrypt');
|
||||
}
|
||||
// if using acme-v2 we cannot issue wildcard-certificates
|
||||
// because they currently only support the dns-01 challenge
|
||||
if ($iswildcarddomain == '0' && $letsencrypt == '1' && Settings::Get('system.leapiversion') == '2') {
|
||||
standard_error('nowildcardwithletsencryptv2');
|
||||
\Froxlor\UI\Response::standard_error('nowildcardwithletsencryptv2');
|
||||
}
|
||||
|
||||
// Temporarily deactivate ssl_redirect until Let's Encrypt certificate was generated
|
||||
@@ -772,7 +772,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
||||
), true, true);
|
||||
|
||||
if ($emails['count'] != '0') {
|
||||
standard_error('domains_cantdeletedomainwithemail', '', true);
|
||||
\Froxlor\UI\Response::standard_error('domains_cantdeletedomainwithemail', '', true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -864,7 +864,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
||||
// check whether path is a real path
|
||||
if (! preg_match('/^https?\:\/\//', $path) || ! validateUrl($path)) {
|
||||
if (strstr($path, ":") !== false) {
|
||||
standard_error('pathmaynotcontaincolon', '', true);
|
||||
\Froxlor\UI\Response::standard_error('pathmaynotcontaincolon', '', true);
|
||||
}
|
||||
// If path is empty or '/' and 'Use domain name as default value for DocumentRoot path' is enabled in settings,
|
||||
// set default path to subdomain or domain name
|
||||
|
||||
@@ -399,8 +399,7 @@ class TasksCron extends \Froxlor\Cron\FroxlorCron
|
||||
{
|
||||
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, 'TasksCron: Task10 started - setting filesystem quota');
|
||||
|
||||
// @fixme
|
||||
$usedquota = getFilesystemQuota();
|
||||
$usedquota = \Froxlor\FileDir::getFilesystemQuota();
|
||||
|
||||
// Check whether we really have entries to check
|
||||
if (is_array($usedquota) && count($usedquota) > 0) {
|
||||
|
||||
@@ -150,7 +150,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
|
||||
|
||||
// We are using the file-system quota, this will speed up the diskusage - collection
|
||||
if (Settings::Get('system.diskquota_enabled')) {
|
||||
$usedquota = getFilesystemQuota();
|
||||
$usedquota = \Froxlor\FileDir::getFilesystemQuota();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,12 +33,12 @@ class Dns
|
||||
|
||||
if ($domain) {
|
||||
if ($domain['isbinddomain'] != '1') {
|
||||
standard_error('dns_domain_nodns');
|
||||
\Froxlor\UI\Response::standard_error('dns_domain_nodns');
|
||||
}
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
return $idna_convert->decode($domain['domain']);
|
||||
}
|
||||
standard_error('dns_notfoundorallowed');
|
||||
\Froxlor\UI\Response::standard_error('dns_notfoundorallowed');
|
||||
}
|
||||
|
||||
public static function createDomainZone($domain_id, $froxlorhostname = false, $isMainButSubTo = false)
|
||||
|
||||
@@ -141,18 +141,35 @@ class FileDir
|
||||
*
|
||||
* @return boolean|array
|
||||
*/
|
||||
public static function checkDisallowedPaths($path = null) {
|
||||
|
||||
public static function checkDisallowedPaths($path = null)
|
||||
{
|
||||
|
||||
/*
|
||||
* disallow base-directories and /
|
||||
*/
|
||||
$disallowed_values = array(
|
||||
"/", "/bin/", "/boot/", "/dev/", "/etc/", "/home/", "/lib/", "/lib32/", "/lib64/",
|
||||
"/opt/", "/proc/", "/root/", "/run/", "/sbin/", "/sys/", "/tmp/", "/usr/", "/var/"
|
||||
"/",
|
||||
"/bin/",
|
||||
"/boot/",
|
||||
"/dev/",
|
||||
"/etc/",
|
||||
"/home/",
|
||||
"/lib/",
|
||||
"/lib32/",
|
||||
"/lib64/",
|
||||
"/opt/",
|
||||
"/proc/",
|
||||
"/root/",
|
||||
"/run/",
|
||||
"/sbin/",
|
||||
"/sys/",
|
||||
"/tmp/",
|
||||
"/usr/",
|
||||
"/var/"
|
||||
);
|
||||
|
||||
|
||||
$path = self::makeCorrectDir($path);
|
||||
|
||||
|
||||
// check if it's a disallowed path
|
||||
if (in_array($path, $disallowed_values)) {
|
||||
return false;
|
||||
@@ -559,6 +576,55 @@ class FileDir
|
||||
return 'chattr ' . (($remove === true) ? '-i ' : '+i ');
|
||||
}
|
||||
}
|
||||
|
||||
public static function getFilesystemQuota()
|
||||
{
|
||||
|
||||
// enabled at all?
|
||||
if (Settings::Get('system.diskquota_enabled')) {
|
||||
|
||||
// set linux defaults
|
||||
$repquota_params = "-np";
|
||||
// $quota_line_regex = "/^#([0-9]+)\s*[+-]{2}\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)/i";
|
||||
$quota_line_regex = "/^#([0-9]+)\s+[+-]{2}\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/i";
|
||||
|
||||
// check for freebsd - which needs other values
|
||||
if (self::isFreeBSD()) {
|
||||
$repquota_params = "-nu";
|
||||
$quota_line_regex = "/^([0-9]+)\s+[+-]{2}\s+(\d+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\S+)/i";
|
||||
}
|
||||
|
||||
// Fetch all quota in the desired partition
|
||||
exec(Settings::Get('system.diskquota_repquota_path') . " " . $repquota_params . " " . escapeshellarg(Settings::Get('system.diskquota_customer_partition')), $repquota);
|
||||
|
||||
$usedquota = array();
|
||||
foreach ($repquota as $tmpquota) {
|
||||
|
||||
// Let's see if the line matches a quota - line
|
||||
if (preg_match($quota_line_regex, $tmpquota, $matches)) {
|
||||
|
||||
// It matches - put it into an array with userid as key (for easy lookup later)
|
||||
$usedquota[$matches[1]] = array(
|
||||
'block' => array(
|
||||
'used' => $matches[2],
|
||||
'soft' => $matches[3],
|
||||
'hard' => $matches[4],
|
||||
'grace' => (isFreeBSD() ? '0' : $matches[5])
|
||||
),
|
||||
'file' => array(
|
||||
'used' => $matches[6],
|
||||
'soft' => $matches[7],
|
||||
'hard' => $matches[8],
|
||||
'grace' => (isFreeBSD() ? '0' : $matches[9])
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $usedquota;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -204,7 +204,7 @@ class Cronjob
|
||||
$text = $lng['crondesc'][$row['desc_lng_key']];
|
||||
$value = $lastrun;
|
||||
|
||||
eval("\$cronjobs_last_run .= \"" . getTemplate("index/overview_item") . "\";");
|
||||
eval("\$cronjobs_last_run .= \"" . \Froxlor\UI\Template::getTemplate("index/overview_item") . "\";");
|
||||
}
|
||||
|
||||
return $cronjobs_last_run;
|
||||
@@ -302,7 +302,7 @@ class Cronjob
|
||||
|
||||
$value .= '</ul>';
|
||||
$text = $lng['tasks']['outstanding_tasks'];
|
||||
eval("\$outstanding_tasks = \"" . getTemplate("index/overview_item") . "\";");
|
||||
eval("\$outstanding_tasks = \"" . \Froxlor\UI\Template::getTemplate("index/overview_item") . "\";");
|
||||
|
||||
return $outstanding_tasks;
|
||||
}
|
||||
|
||||
211
lib/Froxlor/UI/HTML.php
Normal file
211
lib/Froxlor/UI/HTML.php
Normal file
@@ -0,0 +1,211 @@
|
||||
<?php
|
||||
namespace Froxlor\UI;
|
||||
|
||||
class HTML
|
||||
{
|
||||
|
||||
/**
|
||||
* Return HTML Code for a checkbox
|
||||
*
|
||||
* @param string $name
|
||||
* The fieldname
|
||||
* @param string $title
|
||||
* The captions
|
||||
* @param string $value
|
||||
* The Value which will be returned
|
||||
* @param bool $break
|
||||
* Add a <br /> at the end of the checkbox
|
||||
* @param string $selvalue
|
||||
* Values which will be selected by default
|
||||
* @param bool $title_trusted
|
||||
* Whether the title may contain html or not
|
||||
* @param bool $value_trusted
|
||||
* Whether the value may contain html or not
|
||||
*
|
||||
* @return string HTML Code
|
||||
*/
|
||||
public static function makecheckbox($name, $title, $value, $break = false, $selvalue = null, $title_trusted = false, $value_trusted = false)
|
||||
{
|
||||
if ($selvalue !== NULL && $value == $selvalue) {
|
||||
$checked = 'checked="checked"';
|
||||
} else if (isset($_SESSION['requestData'][$name])) {
|
||||
$checked = 'checked="checked"';
|
||||
} else {
|
||||
$checked = '';
|
||||
}
|
||||
|
||||
if (! $title_trusted) {
|
||||
$title = htmlspecialchars($title);
|
||||
}
|
||||
|
||||
if (! $value_trusted) {
|
||||
$value = htmlspecialchars($value);
|
||||
}
|
||||
|
||||
$checkbox = '<label class="nobr"><input type="checkbox" name="' . $name . '" value="' . $value . '" ' . $checked . ' /> ' . $title . '</label>';
|
||||
|
||||
if ($break) {
|
||||
$checkbox .= '<br />';
|
||||
}
|
||||
|
||||
return $checkbox;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return HTML Code for an option within a <select>
|
||||
*
|
||||
* @param string $title
|
||||
* The caption
|
||||
* @param string $value
|
||||
* The Value which will be returned
|
||||
* @param string $selvalue
|
||||
* Values which will be selected by default.
|
||||
* @param bool $title_trusted
|
||||
* Whether the title may contain html or not
|
||||
* @param bool $value_trusted
|
||||
* Whether the value may contain html or not
|
||||
* @param int $id
|
||||
* @param bool $disabled
|
||||
*
|
||||
* @return string HTML Code
|
||||
*/
|
||||
public static function makeoption($title, $value, $selvalue = null, $title_trusted = false, $value_trusted = false, $id = null, $disabled = false)
|
||||
{
|
||||
if ($selvalue !== null && ((is_array($selvalue) && in_array($value, $selvalue)) || $value == $selvalue)) {
|
||||
$selected = 'selected="selected"';
|
||||
} else {
|
||||
$selected = '';
|
||||
}
|
||||
|
||||
if ($disabled) {
|
||||
$selected .= ' disabled="disabled"';
|
||||
}
|
||||
|
||||
if (! $title_trusted) {
|
||||
$title = htmlspecialchars($title);
|
||||
}
|
||||
|
||||
if (! $value_trusted) {
|
||||
$value = htmlspecialchars($value);
|
||||
}
|
||||
|
||||
$id_str = ' ';
|
||||
if ($id !== null) {
|
||||
$id_str = 'id="' . $id . '"';
|
||||
}
|
||||
|
||||
$option = '<option value="' . $value . '" ' . $id_str . $selected . ' >' . $title . '</option>';
|
||||
return $option;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML Code for two radio buttons with two choices: yes and no
|
||||
*
|
||||
* @param
|
||||
* string Name of HTML-Variable
|
||||
* @param
|
||||
* string Value which will be returned if user chooses yes
|
||||
* @param
|
||||
* string Value which will be returned if user chooses no
|
||||
* @param
|
||||
* string Value which is chosen by default
|
||||
* @param
|
||||
* bool Whether this element is disabled or not (default: false)
|
||||
* @return string HTML Code
|
||||
* @author Florian Lippert <flo@syscp.org> (2003-2009)
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
*/
|
||||
public static function makeyesno($name, $yesvalue, $novalue = '', $yesselected = '', $disabled = false)
|
||||
{
|
||||
global $lng, $theme;
|
||||
|
||||
if ($disabled) {
|
||||
$d = ' disabled="disabled"';
|
||||
} else {
|
||||
$d = '';
|
||||
}
|
||||
|
||||
if (isset($_SESSION['requestData'])) {
|
||||
$yesselected = $yesselected & $_SESSION['requestData'][$name];
|
||||
}
|
||||
|
||||
return '<select class="dropdown_noborder" id="' . $name . '" name="' . $name . '"' . $d . '>
|
||||
<option value="' . $yesvalue . '"' . ($yesselected ? ' selected="selected"' : '') . '>' . $lng['panel']['yes'] . '</option><option value="' . $novalue . '"' . ($yesselected ? '' : ' selected="selected"') . '>' . $lng['panel']['no'] . '</option></select>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints Question on screen
|
||||
*
|
||||
* @param string $text
|
||||
* The question
|
||||
* @param string $yesfile
|
||||
* File which will be called with POST if user clicks yes
|
||||
* @param array $params
|
||||
* Values which will be given to $yesfile. Format: array(variable1=>value1, variable2=>value2, variable3=>value3)
|
||||
* @param string $targetname
|
||||
* Name of the target eg Domain or eMail address etc.
|
||||
* @param int $back_nr
|
||||
* Number of steps to go back when "No" is pressed
|
||||
*
|
||||
* @author Florian Lippert <flo@syscp.org>
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
*
|
||||
* @return string outputs parsed question_yesno template
|
||||
*/
|
||||
public static function ask_yesno($text, $yesfile, $params = array(), $targetname = '', $back_nr = 1)
|
||||
{
|
||||
global $userinfo, $s, $header, $footer, $lng, $theme;
|
||||
|
||||
$hiddenparams = '';
|
||||
|
||||
if (is_array($params)) {
|
||||
foreach ($params as $field => $value) {
|
||||
$hiddenparams .= '<input type="hidden" name="' . htmlspecialchars($field) . '" value="' . htmlspecialchars($value) . '" />' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($lng['question'][$text])) {
|
||||
$text = $lng['question'][$text];
|
||||
}
|
||||
|
||||
$text = strtr($text, array(
|
||||
'%s' => $targetname
|
||||
));
|
||||
eval("echo \"" . Template::getTemplate('misc/question_yesno', '1') . "\";");
|
||||
exit();
|
||||
}
|
||||
|
||||
public static function ask_yesno_withcheckbox($text, $chk_text, $yesfile, $params = array(), $targetname = '', $show_checkbox = true)
|
||||
{
|
||||
global $userinfo, $s, $header, $footer, $lng, $theme;
|
||||
|
||||
$hiddenparams = '';
|
||||
|
||||
if (is_array($params)) {
|
||||
foreach ($params as $field => $value) {
|
||||
$hiddenparams .= '<input type="hidden" name="' . htmlspecialchars($field) . '" value="' . htmlspecialchars($value) . '" />' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($lng['question'][$text])) {
|
||||
$text = $lng['question'][$text];
|
||||
}
|
||||
|
||||
if (isset($lng['question'][$chk_text])) {
|
||||
$chk_text = $lng['question'][$chk_text];
|
||||
}
|
||||
|
||||
if ($show_checkbox) {
|
||||
$checkbox = self::makecheckbox('delete_userfiles', $chk_text, '1', false, '0', true, true);
|
||||
} else {
|
||||
$checkbox = '<input type="hidden" name="delete_userfiles" value="0" />' . "\n";
|
||||
;
|
||||
}
|
||||
|
||||
$text = strtr($text, array(
|
||||
'%s' => $targetname
|
||||
));
|
||||
eval("echo \"" . Template::getTemplate('misc/question_yesno_checkbox', '1') . "\";");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
349
lib/Froxlor/UI/HtmlForm.php
Normal file
349
lib/Froxlor/UI/HtmlForm.php
Normal file
@@ -0,0 +1,349 @@
|
||||
<?php
|
||||
namespace Froxlor\UI;
|
||||
|
||||
/**
|
||||
* 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 Classes
|
||||
*
|
||||
*/
|
||||
|
||||
class HtmlForm
|
||||
{
|
||||
/**
|
||||
* internal tmp-variable to store form
|
||||
* @var string
|
||||
*/
|
||||
private static $_form = '';
|
||||
private static $_filename = '';
|
||||
|
||||
public static function genHTMLForm($data = array())
|
||||
{
|
||||
global $lng, $theme;
|
||||
$nob = false;
|
||||
|
||||
self::$_form = '';
|
||||
|
||||
foreach($data as $fdata)
|
||||
{
|
||||
$sections = $fdata['sections'];
|
||||
|
||||
foreach($sections as $section)
|
||||
{
|
||||
/*
|
||||
* here be section title & image
|
||||
*/
|
||||
$title = $section['title'];
|
||||
$image = $section['image'];
|
||||
|
||||
if(isset($section['visible']) && $section['visible'] === false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($section['nobuttons']) || $section['nobuttons'] == false) {
|
||||
eval("self::\$_form .= \"" . Template::getTemplate("misc/form/table_section", "1") . "\";");
|
||||
} else {
|
||||
$nob = true;
|
||||
}
|
||||
|
||||
$nexto = false;
|
||||
foreach($section['fields'] as $fieldname => $fielddata)
|
||||
{
|
||||
if(isset($fielddata['visible']) && $fielddata['visible'] === false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($nexto === false || (isset($fielddata['next_to']) && $nexto['field'] != $fielddata['next_to'])) {
|
||||
$label = $fielddata['label'];
|
||||
$desc = (isset($fielddata['desc']) ? $fielddata['desc'] : '');
|
||||
$style = (isset($fielddata['style']) ? ' class="'.$fielddata['style'].'"' : '');
|
||||
$mandatory = self::_getMandatoryFlag($fielddata);
|
||||
$data_field = self::_parseDataField($fieldname, $fielddata);
|
||||
if (isset($fielddata['has_nextto'])) {
|
||||
$nexto = array('field' => $fieldname);
|
||||
$data_field.='{NEXTTOFIELD_'.$fieldname.'}';
|
||||
} else {
|
||||
$nexto = false;
|
||||
}
|
||||
eval("self::\$_form .= \"" . Template::getTemplate("misc/form/table_row", "1") . "\";");
|
||||
} else {
|
||||
$data_field = self::_parseDataField($fieldname, $fielddata);
|
||||
$data_field = str_replace("\t", "", $data_field);
|
||||
$data_field = $fielddata['next_to_prefix'].$data_field;
|
||||
self::$_form = str_replace(
|
||||
'{NEXTTOFIELD_'.$fielddata['next_to'].'}',
|
||||
$data_field,
|
||||
self::$_form
|
||||
);
|
||||
$nexto = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add save/reset buttons at the end of the form
|
||||
if (!$nob) {
|
||||
eval("self::\$_form .= \"" . Template::getTemplate("misc/form/table_end", "1") . "\";");
|
||||
}
|
||||
|
||||
return self::$_form;
|
||||
}
|
||||
|
||||
private static function _parseDataField($fieldname, $data = array())
|
||||
{
|
||||
switch($data['type'])
|
||||
{
|
||||
case 'text':
|
||||
return self::_textBox($fieldname, $data); break;
|
||||
case 'textul':
|
||||
return self::_textBox($fieldname, $data, 'text', true); break;
|
||||
case 'password':
|
||||
return self::_textBox($fieldname, $data, 'password'); break;
|
||||
case 'hidden':
|
||||
return self::_textBox($fieldname, $data, 'hidden'); break;
|
||||
case 'yesno':
|
||||
return self::_yesnoBox($data); break;
|
||||
case 'select':
|
||||
return self::_selectBox($fieldname, $data); break;
|
||||
case 'label':
|
||||
return self::_labelField($data); break;
|
||||
case 'textarea':
|
||||
return self::_textArea($fieldname, $data); break;
|
||||
case 'checkbox':
|
||||
return self::_checkbox($fieldname, $data); break;
|
||||
case 'file':
|
||||
return self::_file($fieldname, $data); break;
|
||||
case 'int':
|
||||
return self::_int($fieldname, $data); break;
|
||||
}
|
||||
}
|
||||
|
||||
private static function _getMandatoryFlag($data = array())
|
||||
{
|
||||
if(isset($data['mandatory']))
|
||||
{
|
||||
return ' <span class="red">*</span>';
|
||||
}
|
||||
elseif(isset($data['mandatory_ex']))
|
||||
{
|
||||
return ' <span class="red">**</span>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
private static function _textBox($fieldname = '', $data = array(), $type = 'text', $unlimited = false)
|
||||
{
|
||||
$return = '';
|
||||
$extras = '';
|
||||
if(isset($data['maxlength'])) {
|
||||
$extras .= ' maxlength="'.$data['maxlength'].'"';
|
||||
}
|
||||
if(isset($data['size'])) {
|
||||
$extras .= ' size="'.$data['size'].'"';
|
||||
}
|
||||
if(isset($data['autocomplete'])) {
|
||||
$extras .= ' autocomplete="'.$data['autocomplete'].'"';
|
||||
}
|
||||
|
||||
// add support to save reloaded forms
|
||||
if (isset($data['value'])) {
|
||||
$value = $data['value'];
|
||||
} elseif (isset($_SESSION['requestData'][$fieldname])) {
|
||||
$value = $_SESSION['requestData'][$fieldname];
|
||||
} else {
|
||||
$value = '';
|
||||
}
|
||||
|
||||
$ulfield = ($unlimited == true ? ' '.$data['ul_field'] : '');
|
||||
if(isset($data['display']) && $data['display'] != '')
|
||||
{
|
||||
$ulfield = '<strong>'.$data['display'].'</strong>';
|
||||
}
|
||||
|
||||
eval("\$return = \"" . Template::getTemplate("misc/form/input_text", "1") . "\";");
|
||||
return $return;
|
||||
}
|
||||
|
||||
private static function _textArea($fieldname = '', $data = array())
|
||||
{
|
||||
$return = '';
|
||||
$extras = '';
|
||||
if(isset($data['cols'])) {
|
||||
$extras .= ' cols="'.$data['cols'].'"';
|
||||
}
|
||||
if(isset($data['rows'])) {
|
||||
$extras .= ' rows="'.$data['rows'].'"';
|
||||
}
|
||||
|
||||
// add support to save reloaded forms
|
||||
if (isset($data['value'])) {
|
||||
$value = $data['value'];
|
||||
} elseif (isset($_SESSION['requestData'][$fieldname])) {
|
||||
$value = $_SESSION['requestData'][$fieldname];
|
||||
} else {
|
||||
$value = '';
|
||||
}
|
||||
trim($value);
|
||||
|
||||
eval("\$return = \"" . Template::getTemplate("misc/form/input_textarea", "1") . "\";");
|
||||
return $return;
|
||||
}
|
||||
|
||||
private static function _yesnoBox($data = array())
|
||||
{
|
||||
return $data['yesno_var'];
|
||||
}
|
||||
|
||||
private static function _labelField($data = array())
|
||||
{
|
||||
return $data['value'];
|
||||
}
|
||||
|
||||
private static function _selectBox($fieldname = '', $data = array())
|
||||
{
|
||||
// add support to save reloaded forms
|
||||
if (isset($data['select_var'])) {
|
||||
$select_var = $data['select_var'];
|
||||
} elseif (isset($_SESSION['requestData'][$fieldname])) {
|
||||
$select_var = $_SESSION['requestData'][$fieldname];
|
||||
} else {
|
||||
$select_var = '';
|
||||
}
|
||||
|
||||
return '<select
|
||||
id="'.$fieldname.'"
|
||||
name="'.$fieldname.'"
|
||||
'.(isset($data['class']) ? ' class="'.$data['class'] .'" ' : '').'
|
||||
>'
|
||||
.$select_var.
|
||||
'</select>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to generate checkboxes.
|
||||
*
|
||||
* <code>
|
||||
* $data = array(
|
||||
* 'label' => $lng['customer']['email_imap'],
|
||||
* 'type' => 'checkbox',
|
||||
* 'values' => array(
|
||||
* array( 'label' => 'active',
|
||||
* 'value' => '1'
|
||||
* )
|
||||
* ),
|
||||
* 'value' => array('1'),
|
||||
* 'mandatory' => true
|
||||
* )
|
||||
* </code>
|
||||
*
|
||||
* @param string $fieldname contains the fieldname
|
||||
* @param array $data contains the data array
|
||||
*/
|
||||
public static function _checkbox($fieldname = '', $data = array()) {
|
||||
// $data['value'] contains checked items
|
||||
|
||||
$checked = array();
|
||||
if (isset($data['value'])) {
|
||||
$checked = $data['value'];
|
||||
}
|
||||
|
||||
if (isset($_SESSION['requestData'])) {
|
||||
if(isset($_SESSION['requestData'][$fieldname])) {
|
||||
$checked = array($_SESSION['requestData'][$fieldname]);
|
||||
}
|
||||
}
|
||||
|
||||
// default value is none, so the checkbox isn't an array
|
||||
$isArray = '';
|
||||
|
||||
if (count($data['values']) > 1 || (isset($data['is_array']) && $data['is_array'] == 1)) {
|
||||
$isArray = '[]';
|
||||
}
|
||||
|
||||
// will contain the output
|
||||
$output = "";
|
||||
foreach($data['values'] as $val) {
|
||||
$key = $val['label'];
|
||||
// is this box checked?
|
||||
$isChecked = '';
|
||||
if (is_array($checked) && count($checked) > 0) {
|
||||
foreach($checked as $tmp) {
|
||||
if ($tmp == $val['value']) {
|
||||
$isChecked = ' checked="checked" ';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$output .= '<label>';
|
||||
if (empty($isArray)) {
|
||||
$output .= '<input type="hidden" name="'.$fieldname.'" value="0" />';
|
||||
}
|
||||
$output .= '<input type="checkbox" name="'.$fieldname.$isArray.'" value="'.$val['value'].'" '.$isChecked.'/>';
|
||||
$output .= $key.'</label>';
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
private static function _file($fieldname = '', $data = array())
|
||||
{
|
||||
$return = '';
|
||||
$extras = '';
|
||||
if(isset($data['maxlength'])) {
|
||||
$extras .= ' maxlength="'.$data['maxlength'].'"';
|
||||
}
|
||||
|
||||
// add support to save reloaded forms
|
||||
if (isset($data['value'])) {
|
||||
$value = $data['value'];
|
||||
} elseif (isset($_SESSION['requestData'][$fieldname])) {
|
||||
$value = $_SESSION['requestData'][$fieldname];
|
||||
} else {
|
||||
$value = '';
|
||||
}
|
||||
|
||||
if(isset($data['display']) && $data['display'] != '')
|
||||
{
|
||||
$ulfield = '<strong>'.$data['display'].'</strong>';
|
||||
}
|
||||
|
||||
eval("\$return = \"" . Template::getTemplate("misc/form/input_file", "1") . "\";");
|
||||
return $return;
|
||||
}
|
||||
|
||||
private static function _int($fieldname = '', $data = array())
|
||||
{
|
||||
$return = '';
|
||||
$extras = '';
|
||||
if(isset($data['int_min'])) {
|
||||
$extras .= ' min="'.$data['int_min'].'"';
|
||||
}
|
||||
if(isset($data['int_max'])) {
|
||||
$extras .= ' max="'.$data['int_max'].'"';
|
||||
}
|
||||
|
||||
// add support to save reloaded forms
|
||||
if (isset($data['value'])) {
|
||||
$value = $data['value'];
|
||||
} elseif (isset($_SESSION['requestData'][$fieldname])) {
|
||||
$value = $_SESSION['requestData'][$fieldname];
|
||||
} else {
|
||||
$value = '';
|
||||
}
|
||||
|
||||
$type = 'number';
|
||||
$ulfield = '';
|
||||
eval("\$return = \"" . Template::getTemplate("misc/form/input_text", "1") . "\";");
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
173
lib/Froxlor/UI/Linker.php
Normal file
173
lib/Froxlor/UI/Linker.php
Normal file
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
namespace Froxlor\UI;
|
||||
|
||||
/**
|
||||
* 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 Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Panel
|
||||
*
|
||||
*/
|
||||
class Linker
|
||||
{
|
||||
|
||||
private $protocol = '';
|
||||
|
||||
private $username = '';
|
||||
|
||||
private $password = '';
|
||||
|
||||
private $hostname = '';
|
||||
|
||||
private $port = 80;
|
||||
|
||||
private $filename = 'index.php';
|
||||
|
||||
private $args = array();
|
||||
|
||||
public function __construct($file = 'index.php', $sessionid = '', $hostname = '', $protocol = '', $port = '', $username = '', $password = '')
|
||||
{
|
||||
// Set the basic parts of our URL
|
||||
$this->protocol = $protocol;
|
||||
$this->username = $username;
|
||||
$this->password = $password;
|
||||
$this->hostname = $hostname;
|
||||
$this->port = $port;
|
||||
$this->filename = $file;
|
||||
// @TODO: Remove this
|
||||
$this->args['s'] = $sessionid;
|
||||
}
|
||||
|
||||
public function __set($key, $value)
|
||||
{
|
||||
switch (strtolower($key)) {
|
||||
case 'protocol':
|
||||
$this->protocol = $value;
|
||||
break;
|
||||
case 'username':
|
||||
$this->username = $value;
|
||||
break;
|
||||
case 'password':
|
||||
$this->password = $value;
|
||||
break;
|
||||
case 'hostname':
|
||||
$this->hostname = $value;
|
||||
break;
|
||||
case 'port':
|
||||
$this->port = $value;
|
||||
break;
|
||||
case 'filename':
|
||||
$this->filename = $value;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function add($key, $value)
|
||||
{
|
||||
// Add a new value to our parameters (overwrite = enabled)
|
||||
$this->args[$key] = $value;
|
||||
}
|
||||
|
||||
public function del($key)
|
||||
{
|
||||
// If the key exists in our array -> delete it
|
||||
if (isset($this->args[$key])) {
|
||||
unset($this->args[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
public function delAll()
|
||||
{
|
||||
// Just resetting the array
|
||||
// Until the sessionid can be removed: save it
|
||||
// @TODO: Remove this
|
||||
$this->args = array(
|
||||
's' => $this->args['s']
|
||||
);
|
||||
}
|
||||
|
||||
public function getLink()
|
||||
{
|
||||
$link = '';
|
||||
|
||||
// Build the basic URL
|
||||
if (strlen($this->protocol) > 0 && strlen($this->hostname) > 0) {
|
||||
$link = $this->protocol . '://';
|
||||
}
|
||||
|
||||
// Let's see if we shall use a username in the URL
|
||||
// This is only available if a hostname is used as well
|
||||
if (strlen($this->username) > 0 && strlen($this->hostname) > 0) {
|
||||
$link .= urlencode($this->username);
|
||||
|
||||
// Maybe we even have to append a password?
|
||||
if ($this->password != '') {
|
||||
$link .= ':' . urlencode($this->password);
|
||||
}
|
||||
|
||||
// At least a username was given, add the @ to allow appending the hostname
|
||||
$link .= '@';
|
||||
}
|
||||
|
||||
// Add hostname, port and filename to the URL
|
||||
if (strlen($this->hostname) > 0) {
|
||||
$link .= $this->hostname;
|
||||
|
||||
// A port may only be used if hostname is used as well
|
||||
if (strlen($this->port) > 0) {
|
||||
$link .= ':' . $this->port;
|
||||
}
|
||||
}
|
||||
|
||||
// Overwrite $this->args with parameters of this function (if necessary)
|
||||
if (func_num_args() == 1 && is_array(func_get_arg(0))) {
|
||||
$arguments = func_get_arg(0);
|
||||
$this->args = array_merge($this->args, $arguments);
|
||||
}
|
||||
|
||||
// temporary until frontcontroller exists
|
||||
// We got a section in the URL -> morph AREA and section into filename
|
||||
// @TODO: Remove this
|
||||
if (isset($this->args['section']) && strlen($this->args['section']) > 0) {
|
||||
$link .= AREA . '_' . $this->args['section'] . '.php';
|
||||
unset($this->args['section']);
|
||||
} else {
|
||||
// filename has a prefixed slash
|
||||
$link .= $this->filename;
|
||||
}
|
||||
|
||||
// Let's see if we are done (no arguments in query)
|
||||
if (count($this->args) == 0) {
|
||||
return $link;
|
||||
}
|
||||
|
||||
// We have parameters, add them with a "?"
|
||||
$link .= "?";
|
||||
|
||||
// Loop through arguments and add them to the link
|
||||
foreach ($this->args as $key => $value) {
|
||||
// For all but the first argument, prepend "&"
|
||||
if (substr($link, - 1) != "?") {
|
||||
$link .= "&";
|
||||
}
|
||||
|
||||
// Encode parameters and add them to the link
|
||||
$link .= urlencode($key) . '=' . urlencode($value);
|
||||
}
|
||||
|
||||
// Reset our class for further use
|
||||
$this->delAll();
|
||||
return $link;
|
||||
}
|
||||
}
|
||||
520
lib/Froxlor/UI/Paging.php
Normal file
520
lib/Froxlor/UI/Paging.php
Normal file
@@ -0,0 +1,520 @@
|
||||
<?php
|
||||
namespace Froxlor\UI;
|
||||
|
||||
/**
|
||||
* 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 Classes
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class to manage paging system
|
||||
*
|
||||
* @package Functions
|
||||
*/
|
||||
class Paging
|
||||
{
|
||||
|
||||
/**
|
||||
* Userinfo
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $userinfo = array();
|
||||
|
||||
/**
|
||||
* MySQL-Table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $table = '';
|
||||
|
||||
/**
|
||||
* Fields with description which should be selectable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $fields = array();
|
||||
|
||||
/**
|
||||
* Entries per page
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $entriesperpage = 0;
|
||||
|
||||
/**
|
||||
* Number of entries of table
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $entries = 0;
|
||||
|
||||
/**
|
||||
* Sortorder, asc or desc
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $sortorder = 'asc';
|
||||
|
||||
/**
|
||||
* Sortfield
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $sortfield = '';
|
||||
|
||||
/**
|
||||
* Searchfield
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $searchfield = '';
|
||||
|
||||
/**
|
||||
* Searchtext
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $searchtext = '';
|
||||
|
||||
/**
|
||||
* Pagenumber
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $pageno = 0;
|
||||
|
||||
/**
|
||||
* Switch natsorting on/off
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $natSorting = false;
|
||||
|
||||
private $_limit = 0;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
* Loads settings from request or from userdata and saves them to session.
|
||||
*
|
||||
* @param
|
||||
* array userinfo
|
||||
* @param
|
||||
* string Name of Table
|
||||
* @param
|
||||
* array Fields, in format array( 'fieldname_in_mysql' => 'field_caption' )
|
||||
* @param
|
||||
* int *deprecated* entries per page
|
||||
* @param
|
||||
* bool *deprecated* Switch natsorting on/off (global, affects all calls of sort)
|
||||
* @param int $default_field
|
||||
* default sorting-field-index
|
||||
* @param string $default_order
|
||||
* default sorting order 'asc' or 'desc'
|
||||
*
|
||||
*/
|
||||
public function __construct($userinfo, $table, $fields, $entriesperpage = 0, $natSorting = false, $default_field = 0, $default_order = 'asc', $limit = 0)
|
||||
{
|
||||
|
||||
// entries per page and natsorting-flag are not
|
||||
// passed as parameter anymore, because these are
|
||||
// from the settings anyway
|
||||
$entriesperpage = \Froxlor\Settings::Get('panel.paging');
|
||||
$natSorting = \Froxlor\Settings::Get('panel.natsorting');
|
||||
|
||||
$this->userinfo = $userinfo;
|
||||
|
||||
if (! is_array($this->userinfo['lastpaging'])) {
|
||||
$this->userinfo['lastpaging'] = json_decode($this->userinfo['lastpaging'], true);
|
||||
}
|
||||
|
||||
$this->table = $table;
|
||||
$this->fields = $fields;
|
||||
$this->entriesperpage = $entriesperpage;
|
||||
$this->natSorting = $natSorting;
|
||||
$checklastpaging = (isset($this->userinfo['lastpaging']['table']) && $this->userinfo['lastpaging']['table'] == $this->table);
|
||||
$this->userinfo['lastpaging']['table'] = $this->table;
|
||||
|
||||
if (isset($_REQUEST['sortorder']) && (strtolower($_REQUEST['sortorder']) == 'desc' || strtolower($_REQUEST['sortorder']) == 'asc')) {
|
||||
$this->sortorder = strtolower($_REQUEST['sortorder']);
|
||||
} else {
|
||||
|
||||
if ($checklastpaging && isset($this->userinfo['lastpaging']['sortorder']) && (strtolower($this->userinfo['lastpaging']['sortorder']) == 'desc' || strtolower($this->userinfo['lastpaging']['sortorder']) == 'asc')) {
|
||||
$this->sortorder = strtolower($this->userinfo['lastpaging']['sortorder']);
|
||||
} else {
|
||||
$this->sortorder = $default_order;
|
||||
}
|
||||
}
|
||||
|
||||
$this->userinfo['lastpaging']['sortorder'] = $this->sortorder;
|
||||
|
||||
if (isset($_REQUEST['sortfield']) && isset($fields[$_REQUEST['sortfield']])) {
|
||||
$this->sortfield = $_REQUEST['sortfield'];
|
||||
} else {
|
||||
if ($checklastpaging && isset($this->userinfo['lastpaging']['sortfield']) && isset($fields[$this->userinfo['lastpaging']['sortfield']])) {
|
||||
$this->sortfield = $this->userinfo['lastpaging']['sortfield'];
|
||||
} else {
|
||||
$fieldnames = array_keys($fields);
|
||||
$this->sortfield = $fieldnames[$default_field];
|
||||
}
|
||||
}
|
||||
|
||||
$this->userinfo['lastpaging']['sortfield'] = $this->sortfield;
|
||||
|
||||
if (isset($_REQUEST['searchfield']) && isset($fields[$_REQUEST['searchfield']])) {
|
||||
$this->searchfield = $_REQUEST['searchfield'];
|
||||
} else {
|
||||
if ($checklastpaging && isset($this->userinfo['lastpaging']['searchfield']) && isset($fields[$this->userinfo['lastpaging']['searchfield']])) {
|
||||
$this->searchfield = $this->userinfo['lastpaging']['searchfield'];
|
||||
} else {
|
||||
$fieldnames = array_keys($fields);
|
||||
$this->searchfield = $fieldnames[0];
|
||||
}
|
||||
}
|
||||
|
||||
$this->userinfo['lastpaging']['searchfield'] = $this->searchfield;
|
||||
|
||||
if (isset($_REQUEST['searchtext']) && (preg_match('/[-_@\p{L}\p{N}*.]+$/u', $_REQUEST['searchtext']) || $_REQUEST['searchtext'] === '')) {
|
||||
$this->searchtext = trim($_REQUEST['searchtext']);
|
||||
} else {
|
||||
if ($checklastpaging && isset($this->userinfo['lastpaging']['searchtext']) && preg_match('/[-_@\p{L}\p{N}*.]+$/u', $this->userinfo['lastpaging']['searchtext'])) {
|
||||
$this->searchtext = $this->userinfo['lastpaging']['searchtext'];
|
||||
} else {
|
||||
$this->searchtext = '';
|
||||
}
|
||||
}
|
||||
|
||||
$this->userinfo['lastpaging']['searchtext'] = $this->searchtext;
|
||||
|
||||
if (isset($_REQUEST['pageno']) && intval($_REQUEST['pageno']) != 0) {
|
||||
$this->pageno = intval($_REQUEST['pageno']);
|
||||
} else {
|
||||
if ($checklastpaging && isset($this->userinfo['lastpaging']['pageno']) && intval($this->userinfo['lastpaging']['pageno']) != 0) {
|
||||
$this->pageno = intval($this->userinfo['lastpaging']['pageno']);
|
||||
} else {
|
||||
$this->pageno = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$this->userinfo['lastpaging']['pageno'] = $this->pageno;
|
||||
$upd_stmt = \Froxlor\Database\Database::prepare("
|
||||
UPDATE `" . TABLE_PANEL_SESSIONS . "` SET
|
||||
`lastpaging` = :lastpaging
|
||||
WHERE `hash` = :hash AND `userid` = :userid
|
||||
AND `ipaddress` = :ipaddr AND `useragent` = :ua
|
||||
AND `adminsession` = :adminsession
|
||||
");
|
||||
$upd_data = array(
|
||||
'lastpaging' => json_encode($this->userinfo['lastpaging']),
|
||||
'hash' => $userinfo['hash'],
|
||||
'userid' => $userinfo['userid'],
|
||||
'ipaddr' => $userinfo['ipaddress'],
|
||||
'ua' => $userinfo['useragent'],
|
||||
'adminsession' => $userinfo['adminsession']
|
||||
);
|
||||
\Froxlor\Database\Database::pexecute($upd_stmt, $upd_data);
|
||||
|
||||
$this->_limit = $limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets number of entries and adjusts pageno if the number of entries doesn't correspond to the pageno.
|
||||
*
|
||||
* @param
|
||||
* int entries
|
||||
*/
|
||||
public function setEntries($entries)
|
||||
{
|
||||
$this->entries = $entries;
|
||||
|
||||
if (($this->pageno - 1) * $this->entriesperpage > $this->entries) {
|
||||
$this->pageno = 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a row should be displayed or not, used in loops
|
||||
*
|
||||
* @param
|
||||
* int number of row
|
||||
* @return bool to display or not to display, that's the question
|
||||
*/
|
||||
public function checkDisplay($count)
|
||||
{
|
||||
$begin = (intval($this->pageno) - 1) * intval($this->entriesperpage);
|
||||
$end = (intval($this->pageno) * intval($this->entriesperpage));
|
||||
return (($count >= $begin && $count < $end) || $this->entriesperpage == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns condition code for sql query
|
||||
*
|
||||
* @param
|
||||
* bool should returned condition code start with WHERE (false) or AND (true)?
|
||||
* @return string the condition code
|
||||
*/
|
||||
public function getSqlWhere($append = false)
|
||||
{
|
||||
if ($this->searchtext != '') {
|
||||
if ($append == true) {
|
||||
$condition = ' AND ';
|
||||
} else {
|
||||
$condition = ' WHERE ';
|
||||
}
|
||||
|
||||
$searchfield = explode('.', $this->searchfield);
|
||||
foreach ($searchfield as $id => $field) {
|
||||
if (substr($field, - 1, 1) != '`') {
|
||||
$field .= '`';
|
||||
}
|
||||
|
||||
if ($field{0} != '`') {
|
||||
$field = '`' . $field;
|
||||
}
|
||||
|
||||
$searchfield[$id] = $field;
|
||||
}
|
||||
|
||||
$searchfield = implode('.', $searchfield);
|
||||
|
||||
$ops = array(
|
||||
'<',
|
||||
'>',
|
||||
'='
|
||||
);
|
||||
|
||||
// check if we use an operator or not
|
||||
$useOper = 0;
|
||||
$oper = "=";
|
||||
if (in_array(substr($this->searchtext, 0, 1), $ops)) {
|
||||
$useOper = 1;
|
||||
$oper = substr($this->searchtext, 0, 1);
|
||||
}
|
||||
|
||||
// check for diskspace and whether searchtext is a number
|
||||
// in any other case the logical-operators would make no sense
|
||||
if (strpos($searchfield, 'diskspace') > 0 && is_numeric(substr($this->searchtext, $useOper))) {
|
||||
// anything with diskspace is *1024
|
||||
$searchtext = ((int) substr($this->searchtext, $useOper)) * 1024;
|
||||
$useOper = 1;
|
||||
} elseif (strpos($searchfield, 'traffic') > 0 && is_numeric(substr($this->searchtext, $useOper))) {
|
||||
// anything with traffic is *1024*1024
|
||||
$searchtext = ((int) substr($this->searchtext, $useOper)) * 1024 * 1024;
|
||||
$useOper = 1;
|
||||
} else {
|
||||
// any other field
|
||||
$searchtext = substr($this->searchtext, $useOper);
|
||||
}
|
||||
|
||||
if ($useOper == 1 && is_numeric(substr($this->searchtext, $useOper))) {
|
||||
// now as we use >, < or = we use the given operator and not LIKE
|
||||
$condition .= $searchfield . " " . $oper . " " . \Froxlor\Database\Database::quote($searchtext);
|
||||
} else {
|
||||
$searchtext = str_replace('*', '%', $this->searchtext);
|
||||
// append wildcards if user did not enter any
|
||||
if (strpos($searchtext, '%') === false)
|
||||
$searchtext = '%' . $searchtext . '%';
|
||||
$condition .= $searchfield . " LIKE " . \Froxlor\Database\Database::quote($searchtext);
|
||||
}
|
||||
} else {
|
||||
$condition = '';
|
||||
}
|
||||
|
||||
return $condition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns "order by"-code for sql query
|
||||
*
|
||||
* @param
|
||||
* bool Switch natsorting on/off (local, affects just this call)
|
||||
* @return string the "order by"-code
|
||||
*/
|
||||
public function getSqlOrderBy($natSorting = null)
|
||||
{
|
||||
$sortfield = explode('.', $this->sortfield);
|
||||
foreach ($sortfield as $id => $field) {
|
||||
if (substr($field, - 1, 1) != '`') {
|
||||
$field .= '`';
|
||||
}
|
||||
|
||||
if ($field{0} != '`') {
|
||||
$field = '`' . $field;
|
||||
}
|
||||
|
||||
$sortfield[$id] = $field;
|
||||
}
|
||||
|
||||
$sortfield = implode('.', $sortfield);
|
||||
$sortorder = strtoupper($this->sortorder);
|
||||
|
||||
if ($natSorting == true || ($natSorting === null && $this->natSorting == true)) {
|
||||
// Acts similar to php's natsort(), found in one comment at http://my.opera.com/cpr/blog/show.dml/160556
|
||||
$sortcode = "ORDER BY CONCAT( IF( ASCII( LEFT( " . $sortfield . ", 5 ) ) > 57,
|
||||
LEFT( " . $sortfield . ", 1 ), 0 ),
|
||||
IF( ASCII( RIGHT( " . $sortfield . ", 1 ) ) > 57,
|
||||
LPAD( " . $sortfield . ", 255, '0' ),
|
||||
LPAD( CONCAT( " . $sortfield . ", '-' ), 255, '0' )
|
||||
)) " . $sortorder;
|
||||
} else {
|
||||
$sortcode = 'ORDER BY ' . $sortfield . ' ' . $sortorder;
|
||||
}
|
||||
|
||||
return $sortcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently not used
|
||||
*
|
||||
* @return string always empty
|
||||
*/
|
||||
public function getSqlLimit()
|
||||
{
|
||||
if ($this->_limit > 0) {
|
||||
$_offset = ($this->pageno - 1) * $this->_limit;
|
||||
return ' LIMIT ' . $_offset . ',' . $this->_limit;
|
||||
}
|
||||
/**
|
||||
* currently not in use
|
||||
*/
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns html code for sorting field
|
||||
*
|
||||
* @param
|
||||
* array Language array
|
||||
* @return string the html sortcode
|
||||
*/
|
||||
public function getHtmlSortCode($lng, $break = false)
|
||||
{
|
||||
$sortcode = '';
|
||||
$fieldoptions = '';
|
||||
$orderoptions = '';
|
||||
|
||||
foreach ($this->fields as $fieldname => $fieldcaption) {
|
||||
$fieldoptions .= HTML::makeoption($fieldcaption, $fieldname, $this->sortfield, true, true);
|
||||
}
|
||||
|
||||
$breakorws = ($break ? '<br />' : ' ');
|
||||
foreach (array(
|
||||
'asc' => $lng['panel']['ascending'],
|
||||
'desc' => $lng['panel']['descending']
|
||||
) as $sortordertype => $sortorderdescription) {
|
||||
$orderoptions .= HTML::makeoption($sortorderdescription, $sortordertype, $this->sortorder, true, true);
|
||||
}
|
||||
|
||||
eval("\$sortcode =\"" . Template::getTemplate("misc/htmlsortcode", '1') . "\";");
|
||||
return $sortcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns html code for sorting arrows
|
||||
*
|
||||
* @param
|
||||
* string URL to use as base for links
|
||||
* @param
|
||||
* string If set, only this field will be returned
|
||||
* @return mixed An array or a string (if field is set) of html code of arrows
|
||||
*/
|
||||
public function getHtmlArrowCode($baseurl, $field = '')
|
||||
{
|
||||
global $theme;
|
||||
|
||||
if ($field != '' && isset($this->fields[$field])) {
|
||||
$baseurl = htmlspecialchars($baseurl);
|
||||
$fieldname = htmlspecialchars($field);
|
||||
eval("\$arrowcode =\"" . Template::getTemplate("misc/htmlarrowcode", '1') . "\";");
|
||||
} else {
|
||||
$baseurl = htmlspecialchars($baseurl);
|
||||
$arrowcode = array();
|
||||
foreach ($this->fields as $fieldname => $fieldcaption) {
|
||||
$fieldname = htmlspecialchars($fieldname);
|
||||
eval("\$arrowcode[\$fieldname] =\"" . Template::getTemplate("misc/htmlarrowcode", '1') . "\";");
|
||||
}
|
||||
}
|
||||
|
||||
return $arrowcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns html code for searching field
|
||||
*
|
||||
* @param
|
||||
* array Language array
|
||||
* @return string the html searchcode
|
||||
*/
|
||||
public function getHtmlSearchCode($lng)
|
||||
{
|
||||
$searchcode = '';
|
||||
$fieldoptions = '';
|
||||
$searchtext = htmlspecialchars($this->searchtext);
|
||||
foreach ($this->fields as $fieldname => $fieldcaption) {
|
||||
$fieldoptions .= HTML::makeoption($fieldcaption, $fieldname, $this->searchfield, true, true);
|
||||
}
|
||||
eval("\$searchcode =\"" . Template::getTemplate("misc/htmlsearchcode", '1') . "\";");
|
||||
return $searchcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns html code for paging
|
||||
*
|
||||
* @param
|
||||
* string URL to use as base for links
|
||||
* @return string the html pagingcode
|
||||
*/
|
||||
public function getHtmlPagingCode($baseurl)
|
||||
{
|
||||
if ($this->entriesperpage == 0) {
|
||||
return '';
|
||||
} else {
|
||||
$pages = intval($this->entries / $this->entriesperpage);
|
||||
}
|
||||
|
||||
if ($this->entries % $this->entriesperpage != 0) {
|
||||
$pages ++;
|
||||
}
|
||||
|
||||
if ($pages > 1) {
|
||||
|
||||
$start = $this->pageno - 4;
|
||||
if ($start < 1) {
|
||||
$start = 1;
|
||||
}
|
||||
|
||||
$stop = $this->pageno + 4;
|
||||
if ($stop > $pages) {
|
||||
$stop = $pages;
|
||||
}
|
||||
|
||||
$pagingcode = '<a href="' . htmlspecialchars($baseurl) . '&pageno=1">«</a> <a href="' . htmlspecialchars($baseurl) . '&pageno=' . ((intval($this->pageno) - 1) == 0 ? '1' : intval($this->pageno) - 1) . '"><</a> ';
|
||||
for ($i = $start; $i <= $stop; $i ++) {
|
||||
if ($i != $this->pageno) {
|
||||
$pagingcode .= ' <a href="' . htmlspecialchars($baseurl) . '&pageno=' . $i . '">' . $i . '</a> ';
|
||||
} else {
|
||||
$pagingcode .= ' <strong>' . $i . '</strong> ';
|
||||
}
|
||||
}
|
||||
$pagingcode .= ' <a href="' . htmlspecialchars($baseurl) . '&pageno=' . ((intval($this->pageno) + 1) > $pages ? $pages : intval($this->pageno) + 1) . '">></a> <a href="' . $baseurl . '&pageno=' . $pages . '">»</a>';
|
||||
} else {
|
||||
$pagingcode = '';
|
||||
}
|
||||
|
||||
return $pagingcode;
|
||||
}
|
||||
}
|
||||
181
lib/Froxlor/UI/Response.php
Normal file
181
lib/Froxlor/UI/Response.php
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
namespace Froxlor\UI;
|
||||
|
||||
class Response
|
||||
{
|
||||
|
||||
/**
|
||||
* Sends an header ( 'Location ...' ) to the browser.
|
||||
*
|
||||
* @param string $destination
|
||||
* Destination
|
||||
* @param array $get_variables
|
||||
* Get-Variables
|
||||
* @param boolean $isRelative
|
||||
* if the target we are creating for a redirect
|
||||
* should be a relative or an absolute url
|
||||
*
|
||||
* @return boolean false if params is not an array
|
||||
*/
|
||||
public static function redirectTo($destination, $get_variables = null, $isRelative = true)
|
||||
{
|
||||
global $s;
|
||||
|
||||
if (is_array($get_variables)) {
|
||||
if (isset($get_variables['s'])) {
|
||||
$linker = new Linker($destination, $get_variables['s']);
|
||||
} else {
|
||||
$linker = new Linker($destination, $s);
|
||||
}
|
||||
|
||||
foreach ($get_variables as $key => $value) {
|
||||
$linker->add($key, $value);
|
||||
}
|
||||
|
||||
if ($isRelative) {
|
||||
$linker->protocol = '';
|
||||
$linker->hostname = '';
|
||||
$path = './';
|
||||
} else {
|
||||
if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
|
||||
$linker->protocol = 'https';
|
||||
} else {
|
||||
$linker->protocol = 'http';
|
||||
}
|
||||
|
||||
$linker->hostname = $_SERVER['HTTP_HOST'];
|
||||
|
||||
if (dirname($_SERVER['PHP_SELF']) == '/') {
|
||||
$path = '/';
|
||||
} else {
|
||||
$path = dirname($_SERVER['PHP_SELF']) . '/';
|
||||
}
|
||||
$linker->filename = $path . $destination;
|
||||
}
|
||||
header('Location: ' . $linker->getLink());
|
||||
exit();
|
||||
} elseif ($get_variables == null) {
|
||||
if ($isRelative) {
|
||||
$linker = new Linker($destination, $s);
|
||||
} else {
|
||||
$linker = new Linker($destination);
|
||||
}
|
||||
header('Location: ' . $linker->getLink());
|
||||
exit();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints one ore more errormessages on screen
|
||||
*
|
||||
* @param array $errors
|
||||
* Errormessages
|
||||
* @param string $replacer
|
||||
* A %s in the errormessage will be replaced by this string.
|
||||
* @param bool $throw_exception
|
||||
*
|
||||
* @author Florian Lippert <flo@syscp.org>
|
||||
* @author Ron Brand <ron.brand@web.de>
|
||||
*/
|
||||
public static function standard_error($errors = '', $replacer = '', $throw_exception = false)
|
||||
{
|
||||
global $userinfo, $s, $header, $footer, $lng, $theme;
|
||||
|
||||
$_SESSION['requestData'] = $_POST;
|
||||
$replacer = htmlentities($replacer);
|
||||
|
||||
if (! is_array($errors)) {
|
||||
$errors = array(
|
||||
$errors
|
||||
);
|
||||
}
|
||||
|
||||
$link = '';
|
||||
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']) !== false) {
|
||||
$link = '<a href="' . htmlentities($_SERVER['HTTP_REFERER']) . '">' . $lng['panel']['back'] . '</a>';
|
||||
}
|
||||
|
||||
$error = '';
|
||||
foreach ($errors as $single_error) {
|
||||
if (isset($lng['error'][$single_error])) {
|
||||
$single_error = $lng['error'][$single_error];
|
||||
$single_error = strtr($single_error, array(
|
||||
'%s' => $replacer
|
||||
));
|
||||
} else {
|
||||
$error = 'Unknown Error (' . $single_error . '): ' . $replacer;
|
||||
break;
|
||||
}
|
||||
|
||||
if (empty($error)) {
|
||||
$error = $single_error;
|
||||
} else {
|
||||
$error .= ' ' . $single_error;
|
||||
}
|
||||
}
|
||||
|
||||
if ($throw_exception) {
|
||||
throw new \Exception(strip_tags($error), 400);
|
||||
}
|
||||
eval("echo \"" . Template::getTemplate('misc/error', '1') . "\";");
|
||||
exit();
|
||||
}
|
||||
|
||||
public static function dynamic_error($message)
|
||||
{
|
||||
global $userinfo, $s, $header, $footer, $lng, $theme;
|
||||
$_SESSION['requestData'] = $_POST;
|
||||
$link = '';
|
||||
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']) !== false) {
|
||||
$link = '<a href="' . htmlentities($_SERVER['HTTP_REFERER']) . '">' . $lng['panel']['back'] . '</a>';
|
||||
}
|
||||
$error = $message;
|
||||
eval("echo \"" . Template::getTemplate('misc/error', '1') . "\";");
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints one ore more errormessages on screen
|
||||
*
|
||||
* @param array $success_message
|
||||
* Errormessages
|
||||
* @param string $replacer
|
||||
* A %s in the errormessage will be replaced by this string.
|
||||
* @param array $params
|
||||
* @param bool $throw_exception
|
||||
*
|
||||
* @author Florian Lippert <flo@syscp.org>
|
||||
*/
|
||||
public static function standard_success($success_message = '', $replacer = '', $params = array(), $throw_exception = false)
|
||||
{
|
||||
global $s, $header, $footer, $lng, $theme;
|
||||
|
||||
if (isset($lng['success'][$success_message])) {
|
||||
$success_message = strtr($lng['success'][$success_message], array(
|
||||
'%s' => htmlentities($replacer)
|
||||
));
|
||||
}
|
||||
|
||||
if ($throw_exception) {
|
||||
throw new \Exception(strip_tags($success_message), 200);
|
||||
}
|
||||
|
||||
if (is_array($params) && isset($params['filename'])) {
|
||||
$redirect_url = $params['filename'] . '?s=' . $s;
|
||||
unset($params['filename']);
|
||||
|
||||
foreach ($params as $varname => $value) {
|
||||
if ($value != '') {
|
||||
$redirect_url .= '&' . $varname . '=' . $value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$redirect_url = '';
|
||||
}
|
||||
|
||||
eval("echo \"" . Template::getTemplate('misc/success', '1') . "\";");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
125
lib/Froxlor/UI/Template.php
Normal file
125
lib/Froxlor/UI/Template.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
namespace Froxlor\UI;
|
||||
|
||||
class Template
|
||||
{
|
||||
|
||||
/**
|
||||
* returns an array for the settings-array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getThemes()
|
||||
{
|
||||
$themespath = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Froxlor::getInstallDir() . '/templates/');
|
||||
$themes_available = array();
|
||||
|
||||
if (is_dir($themespath)) {
|
||||
$its = new \DirectoryIterator($themespath);
|
||||
|
||||
foreach ($its as $it) {
|
||||
if ($it->isDir() && $it->getFilename() != '.' && $it->getFilename() != '..' && $it->getFilename() != 'misc') {
|
||||
$theme = $themespath . $it->getFilename();
|
||||
if (file_exists($theme . '/config.json')) {
|
||||
$themeconfig = json_decode(file_get_contents($theme . '/config.json'), true);
|
||||
if (array_key_exists('variants', $themeconfig) && is_array($themeconfig['variants'])) {
|
||||
foreach ($themeconfig['variants'] as $variant => $data) {
|
||||
if ($variant == "default") {
|
||||
$themes_available[$it->getFilename()] = $it->getFilename();
|
||||
} elseif (array_key_exists('description', $data)) {
|
||||
$themes_available[$it->getFilename() . '_' . $variant] = $data['description'];
|
||||
} else {
|
||||
$themes_available[$it->getFilename() . '_' . $variant] = $it->getFilename() . ' (' . $variant . ')';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$themes_available[$it->getFilename()] = $it->getFilename();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $themes_available;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get template from filesystem
|
||||
*
|
||||
* @param
|
||||
* string Templatename
|
||||
* @param
|
||||
* string noarea If area should be used to get template
|
||||
* @return string The Template
|
||||
* @author Florian Lippert <flo@syscp.org>
|
||||
*/
|
||||
public static function getTemplate($template, $noarea = 0)
|
||||
{
|
||||
global $templatecache, $theme;
|
||||
|
||||
$fallback_theme = 'Sparkle';
|
||||
|
||||
if (! isset($theme) || $theme == '') {
|
||||
$theme = $fallback_theme;
|
||||
}
|
||||
|
||||
if ($noarea != 1) {
|
||||
$template = AREA . '/' . $template;
|
||||
}
|
||||
|
||||
if (! isset($templatecache[$theme][$template])) {
|
||||
|
||||
$filename = \Froxlor\Froxlor::getInstallDir() . 'templates/' . $theme . '/' . $template . '.tpl';
|
||||
|
||||
// check the current selected theme for the template
|
||||
$templatefile = self::_checkAndParseTpl($filename);
|
||||
|
||||
if ($templatefile == false && $theme != $fallback_theme) {
|
||||
// check fallback
|
||||
$_filename = \Froxlor\Froxlor::getInstallDir() . 'templates/' . $fallback_theme . '/' . $template . '.tpl';
|
||||
$templatefile = self::_checkAndParseTpl($_filename);
|
||||
|
||||
if ($templatefile == false) {
|
||||
// check for old layout
|
||||
$_filename = \Froxlor\Froxlor::getInstallDir() . 'templates/' . $template . '.tpl';
|
||||
$templatefile = self::_checkAndParseTpl($_filename);
|
||||
|
||||
if ($templatefile == false) {
|
||||
// not found
|
||||
$templatefile = 'TEMPLATE NOT FOUND: ' . $filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output = $templatefile;
|
||||
$templatecache[$theme][$template] = $output;
|
||||
}
|
||||
|
||||
return $templatecache[$theme][$template];
|
||||
}
|
||||
|
||||
/**
|
||||
* check whether a tpl file exists and if so, return it's content or else return false
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return string|bool content on success, else false
|
||||
*/
|
||||
private static function _checkAndParseTpl($filename)
|
||||
{
|
||||
$templatefile = "";
|
||||
|
||||
if (file_exists($filename) && is_readable($filename)) {
|
||||
|
||||
$templatefile = addcslashes(file_get_contents($filename), '"\\');
|
||||
|
||||
// loop through template more than once in case we have an "if"-statement in another one
|
||||
while (preg_match('/<if[ \t]*(.*)>(.*)(<\/if>|<else>(.*)<\/if>)/Uis', $templatefile)) {
|
||||
$templatefile = preg_replace('/<if[ \t]*(.*)>(.*)(<\/if>|<else>(.*)<\/if>)/Uis', '".( ($1) ? ("$2") : ("$4") )."', $templatefile);
|
||||
$templatefile = str_replace('\\\\', '\\', $templatefile);
|
||||
}
|
||||
|
||||
return $templatefile;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
205
lib/Froxlor/Validate/Check.php
Normal file
205
lib/Froxlor/Validate/Check.php
Normal file
@@ -0,0 +1,205 @@
|
||||
<?php
|
||||
namespace Froxlor\Validate;
|
||||
|
||||
use Froxlor\Settings;
|
||||
|
||||
class Check
|
||||
{
|
||||
|
||||
public static function checkFcgidPhpFpm($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
|
||||
{
|
||||
$returnvalue = array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_OK
|
||||
);
|
||||
|
||||
$check_array = array(
|
||||
'system_mod_fcgid_enabled' => array(
|
||||
'other_post_field' => 'system_phpfpm_enabled',
|
||||
'other_enabled' => 'phpfpm.enabled',
|
||||
'other_enabled_lng' => 'phpfpmstillenabled',
|
||||
'deactivate' => array(
|
||||
'phpfpm.enabled_ownvhost' => 0
|
||||
)
|
||||
),
|
||||
'system_phpfpm_enabled' => array(
|
||||
'other_post_field' => 'system_mod_fcgid_enabled',
|
||||
'other_enabled' => 'system.mod_fcgid',
|
||||
'other_enabled_lng' => 'fcgidstillenabled',
|
||||
'deactivate' => array(
|
||||
'system.mod_fcgid_ownvhost' => 0
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// interface is to be enabled
|
||||
if ((int) $newfieldvalue == 1) {
|
||||
// check for POST value of the other field == 1 (active)
|
||||
if (isset($_POST[$check_array[$fieldname]['other_post_field']]) && (int) $_POST[$check_array[$fieldname]['other_post_field']] == 1) {
|
||||
// the other interface is activated already and STAYS activated
|
||||
if ((int) Settings::Get($check_array[$fieldname]['other_enabled']) == 1) {
|
||||
$returnvalue = array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
|
||||
$check_array[$fieldname]['other_enabled_lng']
|
||||
);
|
||||
} else {
|
||||
// fcgid is being validated before fpm -> "ask" fpm about its state
|
||||
if ($fieldname == 'system_mod_fcgid_enabled') {
|
||||
$returnvalue = self::checkFcgidPhpFpm('system_phpfpm_enabled', null, $check_array[$fieldname]['other_post_field'], null);
|
||||
} else {
|
||||
// not, bot are nogo
|
||||
$returnvalue = $returnvalue = array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
|
||||
'fcgidandphpfpmnogoodtogether'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (in_array(FORMFIELDS_PLAUSIBILITY_CHECK_OK, $returnvalue)) {
|
||||
// be sure to deactivate the other one for the froxlor-vhost
|
||||
// to avoid having a settings-deadlock
|
||||
foreach ($check_array[$fieldname]['deactivate'] as $setting => $value) {
|
||||
Settings::Set($setting, $value, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $returnvalue;
|
||||
}
|
||||
|
||||
public function checkMysqlAccessHost($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
|
||||
{
|
||||
$mysql_access_host_array = array_map('trim', explode(',', $newfieldvalue));
|
||||
|
||||
foreach ($mysql_access_host_array as $host_entry) {
|
||||
|
||||
if (Validate::validate_ip2($host_entry, true, 'invalidip', true, true) == false && Validate::validateDomain($host_entry) == false && Validate::validateLocalHostname($host_entry) == false && $host_entry != '%') {
|
||||
return array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
|
||||
'invalidmysqlhost',
|
||||
$host_entry
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_OK
|
||||
);
|
||||
}
|
||||
|
||||
public static function checkHostname($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
|
||||
{
|
||||
if (0 == strlen(trim($newfieldvalue)) || Validate::validateDomain($newfieldvalue) === false) {
|
||||
return array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
|
||||
'invalidhostname'
|
||||
);
|
||||
} else {
|
||||
return array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_OK
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check whether an email account is to be deleted
|
||||
* reference: #1519
|
||||
*
|
||||
* @return bool true if the domain is to be deleted, false otherwise
|
||||
*
|
||||
*/
|
||||
public static function checkMailAccDeletionState($email_addr = null)
|
||||
{
|
||||
// example data of task 7: a:2:{s:9:"loginname";s:4:"webX";s:5:"email";s:20:"deleteme@example.tld";}
|
||||
|
||||
// check for task
|
||||
$result_tasks_stmt = \Froxlor\Database\Database::prepare("
|
||||
SELECT * FROM `" . TABLE_PANEL_TASKS . "` WHERE `type` = '7' AND `data` LIKE :emailaddr
|
||||
");
|
||||
\Froxlor\Database\Database::pexecute($result_tasks_stmt, array(
|
||||
'emailaddr' => "%" . $email_addr . "%"
|
||||
));
|
||||
$num_results = \Froxlor\Database\Database::num_rows();
|
||||
|
||||
// is there a task for deleting this email account?
|
||||
if ($num_results > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function checkPathConflicts($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
|
||||
{
|
||||
if ((int) Settings::Get('system.mod_fcgid') == 1) {
|
||||
// fcgid-configdir has changed -> check against customer-doc-prefix
|
||||
if ($fieldname == "system_mod_fcgid_configdir") {
|
||||
$newdir = \Froxlor\FileDir::makeCorrectDir($newfieldvalue);
|
||||
$cdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.documentroot_prefix'));
|
||||
} // customer-doc-prefix has changed -> check against fcgid-configdir
|
||||
elseif ($fieldname == "system_documentroot_prefix") {
|
||||
$newdir = \Froxlor\FileDir::makeCorrectDir($newfieldvalue);
|
||||
$cdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.mod_fcgid_configdir'));
|
||||
}
|
||||
|
||||
// neither dir can be within the other nor can they be equal
|
||||
if (substr($newdir, 0, strlen($cdir)) == $cdir || substr($cdir, 0, strlen($newdir)) == $newdir || $newdir == $cdir) {
|
||||
$returnvalue = array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
|
||||
'fcgidpathcannotbeincustomerdoc'
|
||||
);
|
||||
} else {
|
||||
$returnvalue = array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_OK
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$returnvalue = array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_OK
|
||||
);
|
||||
}
|
||||
|
||||
return $returnvalue;
|
||||
}
|
||||
|
||||
public static function checkPhpInterfaceSetting($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
|
||||
{
|
||||
$returnvalue = array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_OK
|
||||
);
|
||||
|
||||
if ((int) Settings::Get('system.mod_fcgid') == 1) {
|
||||
// fcgid only works for apache and lighttpd
|
||||
if (strtolower($newfieldvalue) != 'apache2' && strtolower($newfieldvalue) != 'lighttpd') {
|
||||
$returnvalue = array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
|
||||
'fcgidstillenableddeadlock'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $returnvalue;
|
||||
}
|
||||
|
||||
public static function checkUsername($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
|
||||
{
|
||||
if (! isset($allnewfieldvalues['customer_mysqlprefix'])) {
|
||||
$allnewfieldvalues['customer_mysqlprefix'] = Settings::Get('customer.mysqlprefix');
|
||||
}
|
||||
|
||||
$returnvalue = array();
|
||||
if (validateUsername($newfieldvalue, Settings::Get('panel.unix_names'), 14 - strlen($allnewfieldvalues['customer_mysqlprefix'])) === true) {
|
||||
$returnvalue = array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_OK
|
||||
);
|
||||
} else {
|
||||
$errmsg = 'accountprefixiswrong';
|
||||
if ($fieldname == 'customer_mysqlprefix') {
|
||||
$errmsg = 'mysqlprefixiswrong';
|
||||
}
|
||||
$returnvalue = array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
|
||||
$errmsg
|
||||
);
|
||||
}
|
||||
return $returnvalue;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
<?php
|
||||
namespace Froxlor\Validate;
|
||||
|
||||
use Froxlor\Settings;
|
||||
|
||||
class Validate
|
||||
{
|
||||
|
||||
@@ -62,7 +60,7 @@ class Validate
|
||||
$lng = 'stringformaterror';
|
||||
}
|
||||
|
||||
standard_error($lng, $fieldname, $throw_exception);
|
||||
\Froxlor\UI\Response::standard_error($lng, $fieldname, $throw_exception);
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -72,7 +70,7 @@ class Validate
|
||||
* @param string $ip
|
||||
* ip-address to check
|
||||
* @param bool $return_bool
|
||||
* whether to return bool or call standard_error()
|
||||
* whether to return bool or call \Froxlor\UI\Response::standard_error()
|
||||
* @param string $lng
|
||||
* index for error-message (if $return_bool is false)
|
||||
* @param bool $allow_localhost
|
||||
@@ -100,7 +98,7 @@ class Validate
|
||||
if ($return_bool) {
|
||||
return false;
|
||||
} else {
|
||||
standard_error($lng, $ip, $throw_exception);
|
||||
\Froxlor\UI\Response::standard_error($lng, $ip, $throw_exception);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
@@ -119,7 +117,7 @@ class Validate
|
||||
if ($return_bool) {
|
||||
return false;
|
||||
} else {
|
||||
standard_error($lng, $ip, $throw_exception);
|
||||
\Froxlor\UI\Response::standard_error($lng, $ip, $throw_exception);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
@@ -152,20 +150,6 @@ class Validate
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function checkHostname($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
|
||||
{
|
||||
if (0 == strlen(trim($newfieldvalue)) || self::validateDomain($newfieldvalue) === false) {
|
||||
return array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
|
||||
'invalidhostname'
|
||||
);
|
||||
} else {
|
||||
return array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_OK
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* validate a local-hostname by regex
|
||||
*
|
||||
@@ -182,33 +166,6 @@ class Validate
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* check whether an email account is to be deleted
|
||||
* reference: #1519
|
||||
*
|
||||
* @return bool true if the domain is to be deleted, false otherwise
|
||||
*
|
||||
*/
|
||||
public static function checkMailAccDeletionState($email_addr = null)
|
||||
{
|
||||
// example data of task 7: a:2:{s:9:"loginname";s:4:"webX";s:5:"email";s:20:"deleteme@example.tld";}
|
||||
|
||||
// check for task
|
||||
$result_tasks_stmt = \Froxlor\Database\Database::prepare("
|
||||
SELECT * FROM `" . TABLE_PANEL_TASKS . "` WHERE `type` = '7' AND `data` LIKE :emailaddr
|
||||
");
|
||||
\Froxlor\Database\Database::pexecute($result_tasks_stmt, array(
|
||||
'emailaddr' => "%" . $email_addr . "%"
|
||||
));
|
||||
$num_results = \Froxlor\Database\Database::num_rows();
|
||||
|
||||
// is there a task for deleting this email account?
|
||||
if ($num_results > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if an emailaddress is in correct format or not
|
||||
*
|
||||
@@ -222,30 +179,6 @@ class Validate
|
||||
return filter_var($email, FILTER_VALIDATE_EMAIL);
|
||||
}
|
||||
|
||||
public static function checkUsername($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
|
||||
{
|
||||
if (! isset($allnewfieldvalues['customer_mysqlprefix'])) {
|
||||
$allnewfieldvalues['customer_mysqlprefix'] = Settings::Get('customer.mysqlprefix');
|
||||
}
|
||||
|
||||
$returnvalue = array();
|
||||
if (validateUsername($newfieldvalue, Settings::Get('panel.unix_names'), 14 - strlen($allnewfieldvalues['customer_mysqlprefix'])) === true) {
|
||||
$returnvalue = array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_OK
|
||||
);
|
||||
} else {
|
||||
$errmsg = 'accountprefixiswrong';
|
||||
if ($fieldname == 'customer_mysqlprefix') {
|
||||
$errmsg = 'mysqlprefixiswrong';
|
||||
}
|
||||
$returnvalue = array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
|
||||
$errmsg
|
||||
);
|
||||
}
|
||||
return $returnvalue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if an username is in correct format or not.
|
||||
*
|
||||
@@ -268,153 +201,6 @@ class Validate
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* validates a given regex
|
||||
*
|
||||
* @param string $regex
|
||||
* regex to validate
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function checkValidRegEx($regex = null)
|
||||
{
|
||||
if ($regex == null || $regex == '') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static function checkPathConflicts($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
|
||||
{
|
||||
if ((int) Settings::Get('system.mod_fcgid') == 1) {
|
||||
// fcgid-configdir has changed -> check against customer-doc-prefix
|
||||
if ($fieldname == "system_mod_fcgid_configdir") {
|
||||
$newdir = \Froxlor\FileDir::makeCorrectDir($newfieldvalue);
|
||||
$cdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.documentroot_prefix'));
|
||||
} // customer-doc-prefix has changed -> check against fcgid-configdir
|
||||
elseif ($fieldname == "system_documentroot_prefix") {
|
||||
$newdir = \Froxlor\FileDir::makeCorrectDir($newfieldvalue);
|
||||
$cdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.mod_fcgid_configdir'));
|
||||
}
|
||||
|
||||
// neither dir can be within the other nor can they be equal
|
||||
if (substr($newdir, 0, strlen($cdir)) == $cdir || substr($cdir, 0, strlen($newdir)) == $newdir || $newdir == $cdir) {
|
||||
$returnvalue = array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
|
||||
'fcgidpathcannotbeincustomerdoc'
|
||||
);
|
||||
} else {
|
||||
$returnvalue = array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_OK
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$returnvalue = array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_OK
|
||||
);
|
||||
}
|
||||
|
||||
return $returnvalue;
|
||||
}
|
||||
|
||||
public static function checkPhpInterfaceSetting($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
|
||||
{
|
||||
$returnvalue = array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_OK
|
||||
);
|
||||
|
||||
if ((int) Settings::Get('system.mod_fcgid') == 1) {
|
||||
// fcgid only works for apache and lighttpd
|
||||
if (strtolower($newfieldvalue) != 'apache2' && strtolower($newfieldvalue) != 'lighttpd') {
|
||||
$returnvalue = array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
|
||||
'fcgidstillenableddeadlock'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $returnvalue;
|
||||
}
|
||||
|
||||
public static function checkFcgidPhpFpm($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
|
||||
{
|
||||
$returnvalue = array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_OK
|
||||
);
|
||||
|
||||
$check_array = array(
|
||||
'system_mod_fcgid_enabled' => array(
|
||||
'other_post_field' => 'system_phpfpm_enabled',
|
||||
'other_enabled' => 'phpfpm.enabled',
|
||||
'other_enabled_lng' => 'phpfpmstillenabled',
|
||||
'deactivate' => array(
|
||||
'phpfpm.enabled_ownvhost' => 0
|
||||
)
|
||||
),
|
||||
'system_phpfpm_enabled' => array(
|
||||
'other_post_field' => 'system_mod_fcgid_enabled',
|
||||
'other_enabled' => 'system.mod_fcgid',
|
||||
'other_enabled_lng' => 'fcgidstillenabled',
|
||||
'deactivate' => array(
|
||||
'system.mod_fcgid_ownvhost' => 0
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// interface is to be enabled
|
||||
if ((int) $newfieldvalue == 1) {
|
||||
// check for POST value of the other field == 1 (active)
|
||||
if (isset($_POST[$check_array[$fieldname]['other_post_field']]) && (int) $_POST[$check_array[$fieldname]['other_post_field']] == 1) {
|
||||
// the other interface is activated already and STAYS activated
|
||||
if ((int) Settings::Get($check_array[$fieldname]['other_enabled']) == 1) {
|
||||
$returnvalue = array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
|
||||
$check_array[$fieldname]['other_enabled_lng']
|
||||
);
|
||||
} else {
|
||||
// fcgid is being validated before fpm -> "ask" fpm about its state
|
||||
if ($fieldname == 'system_mod_fcgid_enabled') {
|
||||
$returnvalue = checkFcgidPhpFpm('system_phpfpm_enabled', null, $check_array[$fieldname]['other_post_field'], null);
|
||||
} else {
|
||||
// not, bot are nogo
|
||||
$returnvalue = $returnvalue = array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
|
||||
'fcgidandphpfpmnogoodtogether'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (in_array(FORMFIELDS_PLAUSIBILITY_CHECK_OK, $returnvalue)) {
|
||||
// be sure to deactivate the other one for the froxlor-vhost
|
||||
// to avoid having a settings-deadlock
|
||||
foreach ($check_array[$fieldname]['deactivate'] as $setting => $value) {
|
||||
Settings::Set($setting, $value, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $returnvalue;
|
||||
}
|
||||
|
||||
public function checkMysqlAccessHost($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
|
||||
{
|
||||
$mysql_access_host_array = array_map('trim', explode(',', $newfieldvalue));
|
||||
|
||||
foreach ($mysql_access_host_array as $host_entry) {
|
||||
|
||||
if (self::validate_ip2($host_entry, true, 'invalidip', true, true) == false && self::validateDomain($host_entry) == false && self::validateLocalHostname($host_entry) == false && $host_entry != '%') {
|
||||
return array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
|
||||
'invalidmysqlhost',
|
||||
$host_entry
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
FORMFIELDS_PLAUSIBILITY_CHECK_OK
|
||||
);
|
||||
}
|
||||
|
||||
public static function validateSqlInterval($interval = null)
|
||||
{
|
||||
if (! $interval === null || $interval != '') {
|
||||
|
||||
@@ -89,9 +89,7 @@ class Autoloader {
|
||||
|
||||
// define the paths where to look for classes
|
||||
$paths = array(
|
||||
dirname(__FILE__) . '/',
|
||||
dirname(dirname(__FILE__)) . '/scripts/',
|
||||
dirname(dirname(__FILE__)) . '/install/',
|
||||
dirname(dirname(__FILE__)) . '/install/'
|
||||
);
|
||||
|
||||
// don't load anything from a namespace, it's not our responsibility
|
||||
|
||||
@@ -21,6 +21,6 @@ function getFormFieldOutputBool($fieldname, $fielddata, $do_show = true)
|
||||
{
|
||||
$label = $fielddata['label'];
|
||||
$boolswitch = makeYesNo($fieldname, '1', '0', $fielddata['value']);
|
||||
eval("\$returnvalue = \"" . getTemplate("formfields/bool", true) . "\";");
|
||||
eval("\$returnvalue = \"" . \Froxlor\UI\Template::getTemplate("formfields/bool", true) . "\";");
|
||||
return $returnvalue;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,6 @@ function getFormFieldOutputFile($fieldname, $fielddata, $do_show = true)
|
||||
{
|
||||
$label = $fielddata['label'];
|
||||
$value = htmlentities($fielddata['value']);
|
||||
eval("\$returnvalue = \"" . getTemplate("formfields/text", true) . "\";");
|
||||
eval("\$returnvalue = \"" . \Froxlor\UI\Template::getTemplate("formfields/text", true) . "\";");
|
||||
return $returnvalue;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
function getFormGroupOutput($groupname, $groupdetails) {
|
||||
|
||||
global $lng, $theme;
|
||||
eval("\$group = \"" . getTemplate("settings/settings_group") . "\";");
|
||||
eval("\$group = \"" . \Froxlor\UI\Template::getTemplate("settings/settings_group") . "\";");
|
||||
return $group;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ function getFormOverviewGroupOutput($groupname, $groupdetails) {
|
||||
if($fielddetails['type'] != 'option'
|
||||
&& $fielddetails['type'] != 'bool')
|
||||
{
|
||||
standard_error('overviewsettingoptionisnotavalidfield');
|
||||
\Froxlor\UI\Response::standard_error('overviewsettingoptionisnotavalidfield');
|
||||
}
|
||||
|
||||
if($fielddetails['type'] == 'option')
|
||||
@@ -87,7 +87,7 @@ function getFormOverviewGroupOutput($groupname, $groupdetails) {
|
||||
}
|
||||
}
|
||||
|
||||
eval("\$group = \"" . getTemplate("settings/settings_overviewgroup") . "\";");
|
||||
eval("\$group = \"" . \Froxlor\UI\Template::getTemplate("settings/settings_overviewgroup") . "\";");
|
||||
|
||||
return $group;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ function processForm(&$form, &$input, $url_params = array())
|
||||
{
|
||||
if(($error = validateFormField($fieldname, $fielddetails, $newfieldvalue)) !== true)
|
||||
{
|
||||
standard_error($error, $fieldname);
|
||||
\Froxlor\UI\Response::standard_error($error, $fieldname);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -85,7 +85,7 @@ function processForm(&$form, &$input, $url_params = array())
|
||||
$error = $plausibility_check[1];
|
||||
unset($plausibility_check[1]);
|
||||
$targetname = implode(' ', $plausibility_check);
|
||||
standard_error($error, $targetname);
|
||||
\Froxlor\UI\Response::standard_error($error, $targetname);
|
||||
}
|
||||
elseif($plausibility_check[0] == FORMFIELDS_PLAUSIBILITY_CHECK_QUESTION)
|
||||
{
|
||||
@@ -109,7 +109,7 @@ function processForm(&$form, &$input, $url_params = array())
|
||||
}
|
||||
else
|
||||
{
|
||||
standard_error('plausibilitychecknotunderstood');
|
||||
\Froxlor\UI\Response::standard_error('plausibilitychecknotunderstood');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,7 @@ function processForm(&$form, &$input, $url_params = array())
|
||||
}
|
||||
else
|
||||
{
|
||||
standard_error('errorwhensaving', $fieldname);
|
||||
\Froxlor\UI\Response::standard_error('errorwhensaving', $fieldname);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -193,7 +193,7 @@ function processFormEx(&$form, &$input, $url_params = array(), $part, $settings_
|
||||
{
|
||||
if(($error = validateFormField($fieldname, $fielddetails, $newfieldvalue)) !== true)
|
||||
{
|
||||
standard_error($error, $fieldname);
|
||||
\Froxlor\UI\Response::standard_error($error, $fieldname);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -236,7 +236,7 @@ function processFormEx(&$form, &$input, $url_params = array(), $part, $settings_
|
||||
$error = $plausibility_check[1];
|
||||
unset($plausibility_check[1]);
|
||||
$targetname = implode(' ', $plausibility_check);
|
||||
standard_error($error, $targetname);
|
||||
\Froxlor\UI\Response::standard_error($error, $targetname);
|
||||
}
|
||||
elseif($plausibility_check[0] == FORMFIELDS_PLAUSIBILITY_CHECK_QUESTION)
|
||||
{
|
||||
@@ -260,7 +260,7 @@ function processFormEx(&$form, &$input, $url_params = array(), $part, $settings_
|
||||
}
|
||||
else
|
||||
{
|
||||
standard_error('plausibilitychecknotunderstood');
|
||||
\Froxlor\UI\Response::standard_error('plausibilitychecknotunderstood');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -292,7 +292,7 @@ function processFormEx(&$form, &$input, $url_params = array(), $part, $settings_
|
||||
}
|
||||
else
|
||||
{
|
||||
standard_error('errorwhensaving', $fieldname);
|
||||
\Froxlor\UI\Response::standard_error('errorwhensaving', $fieldname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ function getFormFieldOutputHidden($fieldname, $fielddata)
|
||||
{
|
||||
$label = $fielddata['label'];
|
||||
$value = htmlentities($fielddata['value']);
|
||||
eval("\$returnvalue .= \"" . getTemplate("formfields/hidden", true) . "\";");
|
||||
eval("\$returnvalue .= \"" . \Froxlor\UI\Template::getTemplate("formfields/hidden", true) . "\";");
|
||||
}
|
||||
|
||||
return $returnvalue;
|
||||
|
||||
@@ -21,6 +21,6 @@ function getFormFieldOutputHiddenString($fieldname, $fielddata, $do_show = true)
|
||||
{
|
||||
$label = $fielddata['label'];
|
||||
$value = htmlentities($fielddata['value']);
|
||||
eval("\$returnvalue = \"" . getTemplate("formfields/hiddenstring", true) . "\";");
|
||||
eval("\$returnvalue = \"" . \Froxlor\UI\Template::getTemplate("formfields/hiddenstring", true) . "\";");
|
||||
return $returnvalue;
|
||||
}
|
||||
@@ -20,6 +20,6 @@
|
||||
function getFormFieldOutputLabel($fieldname, $fielddata)
|
||||
{
|
||||
$label = $fielddata['label'];
|
||||
eval("\$returnvalue = \"" . getTemplate("formfields/label", true) . "\";");
|
||||
eval("\$returnvalue = \"" . \Froxlor\UI\Template::getTemplate("formfields/label", true) . "\";");
|
||||
return $returnvalue;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ function getFormFieldOutputOption($fieldname, $fielddata, $do_show = true)
|
||||
{
|
||||
$options .= makeoption($title, $value, $fielddata['value']);
|
||||
}
|
||||
eval("\$returnvalue = \"" . getTemplate("formfields/option", true) . "\";");
|
||||
eval("\$returnvalue = \"" . \Froxlor\UI\Template::getTemplate("formfields/option", true) . "\";");
|
||||
}
|
||||
|
||||
return $returnvalue;
|
||||
|
||||
@@ -21,6 +21,6 @@ function getFormFieldOutputString($fieldname, $fielddata, $do_show = true)
|
||||
{
|
||||
$label = $fielddata['label'];
|
||||
$value = htmlentities($fielddata['value']);
|
||||
eval("\$returnvalue = \"" . getTemplate("formfields/string", true) . "\";");
|
||||
eval("\$returnvalue = \"" . \Froxlor\UI\Template::getTemplate("formfields/string", true) . "\";");
|
||||
return $returnvalue;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,6 @@ function getFormFieldOutputText($fieldname, $fielddata, $do_show = true)
|
||||
{
|
||||
$label = $fielddata['label'];
|
||||
$value = htmlentities($fielddata['value']);
|
||||
eval("\$returnvalue = \"" . getTemplate("formfields/text", true) . "\";");
|
||||
eval("\$returnvalue = \"" . \Froxlor\UI\Template::getTemplate("formfields/text", true) . "\";");
|
||||
return $returnvalue;
|
||||
}
|
||||
|
||||
@@ -47,14 +47,14 @@ function correctErrorDocument($errdoc = null, $throw_exception = false) {
|
||||
else {
|
||||
// string won't work for lighty
|
||||
if (Settings::Get('system.webserver') == 'lighttpd') {
|
||||
standard_error('stringerrordocumentnotvalidforlighty', '', $throw_exception);
|
||||
\Froxlor\UI\Response::standard_error('stringerrordocumentnotvalidforlighty', '', $throw_exception);
|
||||
} elseif(substr($errdoc, -1) != '"') {
|
||||
$errdoc .= '"';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (Settings::Get('system.webserver') == 'lighttpd') {
|
||||
standard_error('urlerrordocumentnotvalidforlighty', '', $throw_exception);
|
||||
\Froxlor\UI\Response::standard_error('urlerrordocumentnotvalidforlighty', '', $throw_exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ function buildNavigation($navigation, $userinfo) {
|
||||
$navlabel = $element['label'];
|
||||
}
|
||||
|
||||
eval("\$navigation_links .= \"" . getTemplate("navigation_link", 1) . "\";");
|
||||
eval("\$navigation_links .= \"" . \Froxlor\UI\Template::getTemplate("navigation_link", 1) . "\";");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ function buildNavigation($navigation, $userinfo) {
|
||||
$navlabel = $box['label'];
|
||||
}
|
||||
|
||||
eval("\$returnvalue .= \"" . getTemplate("navigation_element", 1) . "\";");
|
||||
eval("\$returnvalue .= \"" . \Froxlor\UI\Template::getTemplate("navigation_element", 1) . "\";");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ if ($language != 'English') {
|
||||
include_once \Froxlor\FileDir::makeSecurePath('lng/lng_references.php');
|
||||
|
||||
// Initialize our new link - class
|
||||
$linker = new linker('index.php', $s);
|
||||
$linker = new \Froxlor\UI\Linker('index.php', $s);
|
||||
|
||||
/**
|
||||
* global Theme-variable
|
||||
@@ -359,7 +359,7 @@ if ($nosession == 1 && AREA != 'login') {
|
||||
"script" => basename($_SERVER["SCRIPT_NAME"]),
|
||||
"qrystr" => $_SERVER["QUERY_STRING"]
|
||||
);
|
||||
redirectTo('index.php', $params);
|
||||
\Froxlor\UI\Response::redirectTo('index.php', $params);
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -441,10 +441,10 @@ if (array_key_exists('css', $_themeoptions['variants'][$themevariant]) && is_arr
|
||||
}
|
||||
}
|
||||
}
|
||||
eval("\$header = \"" . getTemplate('header', '1') . "\";");
|
||||
eval("\$header = \"" . \Froxlor\UI\Template::getTemplate('header', '1') . "\";");
|
||||
|
||||
$current_year = date('Y', time());
|
||||
eval("\$footer = \"" . getTemplate('footer', '1') . "\";");
|
||||
eval("\$footer = \"" . \Froxlor\UI\Template::getTemplate('footer', '1') . "\";");
|
||||
|
||||
unset($js);
|
||||
unset($css);
|
||||
|
||||
Reference in New Issue
Block a user