even more function to class conversion

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2018-12-21 17:41:22 +01:00
parent b0e11f5708
commit 1b090377ee
61 changed files with 941 additions and 1389 deletions

View File

@@ -737,7 +737,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
), true, true);
$this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] deleted admin '" . $result['loginname'] . "'");
updateCounters();
\Froxlor\User::updateCounters();
return $this->response(200, "successfull", $result);
}
throw new \Exception("Not allowed to execute given command.", 403);

View File

@@ -666,7 +666,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
'FIRSTNAME' => $firstname,
'NAME' => $name,
'COMPANY' => $company,
'SALUTATION' => getCorrectUserSalutation(array(
'SALUTATION' => \Froxlor\User::getCorrectUserSalutation(array(
'firstname' => $firstname,
'name' => $name,
'company' => $company
@@ -696,7 +696,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
$this->mailer()->Subject = $mail_subject;
$this->mailer()->AltBody = $mail_body;
$this->mailer()->msgHTML(str_replace("\n", "<br />", $mail_body));
$this->mailer()->addAddress($email, getCorrectUserSalutation(array(
$this->mailer()->addAddress($email, \Froxlor\User::getCorrectUserSalutation(array(
'firstname' => $firstname,
'name' => $name,
'company' => $company
@@ -1662,7 +1662,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
), true, true);
// now, recalculate the resource-usage for the old and the new admin
updateCounters(false);
\Froxlor\User::updateCounters(false);
$this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] moved user '" . $c_result['loginname'] . "' from admin/reseller '" . $c_result['adminname'] . " to admin/reseller '" . $a_result['loginname'] . "'");

View File

@@ -74,15 +74,15 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
$path = \Froxlor\FileDir::makeCorrectDir($customer['documentroot'] . '/' . $path);
if (! empty($error404path)) {
$error404path = correctErrorDocument($error404path, true);
$error404path = $this->correctErrorDocument($error404path, true);
}
if (! empty($error403path)) {
$error403path = correctErrorDocument($error403path, true);
$error403path = $this->correctErrorDocument($error403path, true);
}
if (! empty($error500path)) {
$error500path = correctErrorDocument($error500path, true);
$error500path = $this->correctErrorDocument($error500path, true);
}
// check for duplicate path
@@ -236,15 +236,15 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
$error500path = $this->getParam('error500path', true, $result['error500path']);
if (! empty($error404path)) {
$error404path = correctErrorDocument($error404path, true);
$error404path = $this->correctErrorDocument($error404path, true);
}
if (! empty($error403path)) {
$error403path = correctErrorDocument($error403path, true);
$error403path = $this->correctErrorDocument($error403path, true);
}
if (! empty($error500path)) {
$error500path = correctErrorDocument($error500path, true);
$error500path = $this->correctErrorDocument($error500path, true);
}
if (($options_indexes != $result['options_indexes']) || ($error404path != $result['error404path']) || ($error403path != $result['error403path']) || ($error500path != $result['error500path']) || ($options_cgi != $result['options_cgi'])) {
@@ -378,4 +378,46 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
\Froxlor\System\Cronjob::inserttask('1');
return $this->response(200, "successfull", $result);
}
/**
* this functions validates a given value as ErrorDocument
* refs #267
*
* @param
* string error-document-string
* @param bool $throw_exception
*
* @return string error-document-string
*
*/
private function correctErrorDocument($errdoc = null, $throw_exception = false)
{
if ($errdoc !== null && $errdoc != '') {
// not a URL
if ((strtoupper(substr($errdoc, 0, 5)) != 'HTTP:' && strtoupper(substr($errdoc, 0, 6)) != 'HTTPS:') || ! \Froxlor\Validate\Form\Strings::validateUrl($errdoc)) {
// a file
if (substr($errdoc, 0, 1) != '"') {
$errdoc = \Froxlor\FileDir::makeCorrectFile($errdoc);
// apache needs a starting-slash (starting at the domains-docroot)
if (! substr($errdoc, 0, 1) == '/') {
$errdoc = '/' . $errdoc;
}
} // a string (check for ending ")
else {
// string won't work for lighty
if (Settings::Get('system.webserver') == 'lighttpd') {
\Froxlor\UI\Response::standard_error('stringerrordocumentnotvalidforlighty', '', $throw_exception);
} elseif (substr($errdoc, - 1) != '"') {
$errdoc .= '"';
}
}
} else {
if (Settings::Get('system.webserver') == 'lighttpd') {
\Froxlor\UI\Response::standard_error('urlerrordocumentnotvalidforlighty', '', $throw_exception);
}
}
}
return $errdoc;
}
}

View File

@@ -1617,7 +1617,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
\Froxlor\System\Cronjob::inserttask('11', $result['domain']);
$this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] deleted domain/subdomains (#" . $result['id'] . ")");
updateCounters();
\Froxlor\User::updateCounters();
\Froxlor\System\Cronjob::inserttask('1');
// Using nameserver, insert a task which rebuilds the server config
\Froxlor\System\Cronjob::inserttask('4');

View File

@@ -213,7 +213,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
$_mailerror = false;
$mailerr_msg = "";
try {
$this->mailer()->setFrom($admin['email'], getCorrectUserSalutation($admin));
$this->mailer()->setFrom($admin['email'], \Froxlor\User::getCorrectUserSalutation($admin));
$this->mailer()->Subject = $mail_subject;
$this->mailer()->AltBody = $mail_body;
$this->mailer()->msgHTML(str_replace("\n", "<br />", $mail_body));
@@ -243,11 +243,11 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
$_mailerror = false;
try {
$this->mailer()->setFrom($admin['email'], getCorrectUserSalutation($admin));
$this->mailer()->setFrom($admin['email'], \Froxlor\User::getCorrectUserSalutation($admin));
$this->mailer()->Subject = $mail_subject;
$this->mailer()->AltBody = $mail_body;
$this->mailer()->msgHTML(str_replace("\n", "<br />", $mail_body));
$this->mailer()->addAddress($idna_convert->encode($alternative_email), getCorrectUserSalutation($customer));
$this->mailer()->addAddress($idna_convert->encode($alternative_email), \Froxlor\User::getCorrectUserSalutation($customer));
$this->mailer()->send();
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();

View File

@@ -187,8 +187,8 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
if ($sendinfomail == 1) {
$replace_arr = array(
'SALUTATION' => getCorrectUserSalutation($customer),
'CUST_NAME' => getCorrectUserSalutation($customer), // < keep this for compatibility
'SALUTATION' => \Froxlor\User::getCorrectUserSalutation($customer),
'CUST_NAME' => \Froxlor\User::getCorrectUserSalutation($customer), // < keep this for compatibility
'USR_NAME' => $username,
'USR_PASS' => $password,
'USR_PATH' => \Froxlor\FileDir::makeCorrectDir(str_replace($customer['documentroot'], "/", $path))
@@ -204,7 +204,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
$this->mailer()->Subject = $mail_subject;
$this->mailer()->AltBody = $mail_body;
$this->mailer()->msgHTML(str_replace("\n", "<br />", $mail_body));
$this->mailer()->addAddress($customer['email'], getCorrectUserSalutation($customer));
$this->mailer()->addAddress($customer['email'], \Froxlor\User::getCorrectUserSalutation($customer));
$this->mailer()->send();
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();

View File

@@ -127,8 +127,8 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$userinfo = $customer;
$replace_arr = array(
'SALUTATION' => getCorrectUserSalutation($userinfo),
'CUST_NAME' => getCorrectUserSalutation($userinfo), // < keep this for compatibility
'SALUTATION' => \Froxlor\User::getCorrectUserSalutation($userinfo),
'CUST_NAME' => \Froxlor\User::getCorrectUserSalutation($userinfo), // < keep this for compatibility
'DB_NAME' => $username,
'DB_PASS' => $password,
'DB_DESC' => $databasedescription,
@@ -147,7 +147,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$this->mailer()->Subject = $mail_subject;
$this->mailer()->AltBody = $mail_body;
$this->mailer()->msgHTML(str_replace("\n", "<br />", $mail_body));
$this->mailer()->addAddress($userinfo['email'], getCorrectUserSalutation($userinfo));
$this->mailer()->addAddress($userinfo['email'], \Froxlor\User::getCorrectUserSalutation($userinfo));
$this->mailer()->send();
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();

View File

@@ -302,7 +302,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
));
if ($_doredirect) {
addRedirectToDomain($subdomain_id, $redirectcode);
\Froxlor\Domain\Domain::addRedirectToDomain($subdomain_id, $redirectcode);
}
\Froxlor\System\Cronjob::inserttask('1');
@@ -470,7 +470,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
$isemaildomain = $this->getBoolParam('isemaildomain', true, $result['isemaildomain']);
$openbasedir_path = $this->getParam('openbasedir_path', true, $result['openbasedir_path']);
$phpsettingid = $this->getParam('phpsettingid', true, $result['phpsettingid']);
$redirectcode = $this->getParam('redirectcode', true, getDomainRedirectId($id));
$redirectcode = $this->getParam('redirectcode', true, \Froxlor\Domain\Domain::getDomainRedirectId($id));
if (Settings::Get('system.use_ssl')) {
$ssl_redirect = $this->getBoolParam('ssl_redirect', true, $result['ssl_redirect']);
$letsencrypt = $this->getBoolParam('letsencrypt', true, $result['letsencrypt']);
@@ -586,7 +586,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
// handle redirect
if ($_doredirect) {
updateRedirectOfDomain($id, $redirectcode);
\Froxlor\Domain\Domain::updateRedirectOfDomain($id, $redirectcode);
}
if ($path != $result['documentroot'] || $isemaildomain != $result['isemaildomain'] || $wwwserveralias != $result['wwwserveralias'] || $iswildcarddomain != $result['iswildcarddomain'] || $aliasdomain != $result['aliasdomain'] || $openbasedir_path != $result['openbasedir_path'] || $ssl_redirect != $result['ssl_redirect'] || $letsencrypt != $result['letsencrypt'] || $hsts_maxage != $result['hsts'] || $hsts_sub != $result['hsts_sub'] || $hsts_preload != $result['hsts_preload'] || $phpsettingid != $result['phpsettingid']) {
@@ -855,7 +855,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
{
// check whether an URL was specified
$_doredirect = false;
if (! empty($url) && validateUrl($url)) {
if (! empty($url) && \Froxlor\Validate\Form\Strings::validateUrl($url)) {
$path = $url;
$_doredirect = true;
} else {
@@ -863,7 +863,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
}
// check whether path is a real path
if (! preg_match('/^https?\:\/\//', $path) || ! validateUrl($path)) {
if (! preg_match('/^https?\:\/\//', $path) || ! \Froxlor\Validate\Form\Strings::validateUrl($path)) {
if (strstr($path, ":") !== false) {
\Froxlor\UI\Response::standard_error('pathmaynotcontaincolon', '', true);
}

View File

@@ -144,7 +144,7 @@ class Apache extends HttpConfigBase
foreach ($statusCodes as $statusCode) {
if (Settings::Get('defaultwebsrverrhandler.err' . $statusCode) != '') {
$defhandler = Settings::Get('defaultwebsrverrhandler.err' . $statusCode);
if (! validateUrl($defhandler)) {
if (! \Froxlor\Validate\Form\Strings::validateUrl($defhandler)) {
if (substr($defhandler, 0, 1) != '"' && substr($defhandler, - 1, 1) != '"') {
$defhandler = '"' . \Froxlor\FileDir::makeCorrectFile($defhandler) . '"';
}
@@ -1025,7 +1025,7 @@ class Apache extends HttpConfigBase
$corrected_docroot = $domain['documentroot'];
// Get domain's redirect code
$code = getDomainRedirectCode($domain['id']);
$code = \Froxlor\Domain\Domain::getDomainRedirectCode($domain['id']);
$modrew_red = '';
if ($code != '') {
$modrew_red = ' [R=' . $code . ';L,NE]';
@@ -1190,7 +1190,7 @@ class Apache extends HttpConfigBase
foreach ($statusCodes as $statusCode) {
if (isset($row_diroptions['error' . $statusCode . 'path']) && $row_diroptions['error' . $statusCode . 'path'] != '') {
$defhandler = $row_diroptions['error' . $statusCode . 'path'];
if (! validateUrl($defhandler)) {
if (! \Froxlor\Validate\Form\Strings::validateUrl($defhandler)) {
if (substr($defhandler, 0, 1) != '"' && substr($defhandler, - 1, 1) != '"') {
$defhandler = '"' . \Froxlor\FileDir::makeCorrectFile($defhandler) . '"';
}

View File

@@ -316,7 +316,7 @@ class Lighttpd extends HttpConfigBase
}
$defhandler = Settings::Get('defaultwebsrverrhandler.err404');
if (! validateUrl($defhandler)) {
if (! \Froxlor\Validate\Form\Strings::validateUrl($defhandler)) {
$defhandler = \Froxlor\FileDir::makeCorrectFile($defhandler);
}
$this->lighttpd_data[$vhost_filename] = 'server.error-handler-404 = "' . $defhandler . '"';
@@ -483,7 +483,7 @@ class Lighttpd extends HttpConfigBase
$uri = $domain['documentroot'];
// Get domain's redirect code
$code = getDomainRedirectCode($domain['id']);
$code = \Froxlor\Domain\Domain::getDomainRedirectCode($domain['id']);
$vhost_content .= ' url.redirect-code = ' . $code . "\n";
$vhost_content .= ' url.redirect = (' . "\n";
@@ -701,7 +701,7 @@ class Lighttpd extends HttpConfigBase
if (! empty($row['error404path'])) {
$defhandler = $row['error404path'];
if (! validateUrl($defhandler)) {
if (! \Froxlor\Validate\Form\Strings::validateUrl($defhandler)) {
$defhandler = \Froxlor\FileDir::makeCorrectFile($domain['documentroot'] . '/' . $defhandler);
}
$error_string .= ' server.error-handler-404 = "' . $defhandler . '"' . "\n\n";

View File

@@ -116,7 +116,7 @@ class Nginx extends HttpConfigBase
foreach ($statusCodes as $statusCode) {
if (Settings::Get('defaultwebsrverrhandler.err' . $statusCode) != '') {
$defhandler = Settings::Get('defaultwebsrverrhandler.err' . $statusCode);
if (! validateUrl($defhandler)) {
if (! \Froxlor\Validate\Form\Strings::validateUrl($defhandler)) {
$defhandler = \Froxlor\FileDir::makeCorrectFile($defhandler);
}
$this->nginx_data[$vhosts_filename] .= 'error_page ' . $statusCode . ' ' . $defhandler . ';' . "\n";
@@ -499,7 +499,7 @@ class Nginx extends HttpConfigBase
}
// Get domain's redirect code
$code = getDomainRedirectCode($domain['id']);
$code = \Froxlor\Domain\Domain::getDomainRedirectCode($domain['id']);
$vhost_content .= "\t" . 'if ($request_uri !~ ^/.well-known/acme-challenge/[-\w]+$) {' . "\n";
$vhost_content .= "\t\t" . 'return ' . $code . ' ' . $uri . '$request_uri;' . "\n";
@@ -703,7 +703,7 @@ class Nginx extends HttpConfigBase
while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
if (! empty($row['error404path'])) {
$defhandler = $row['error404path'];
if (! validateUrl($defhandler)) {
if (! \Froxlor\Validate\Form\Strings::validateUrl($defhandler)) {
$defhandler = \Froxlor\FileDir::makeCorrectFile($defhandler);
}
$path_options .= "\t" . 'error_page 404 ' . $defhandler . ';' . "\n";
@@ -711,7 +711,7 @@ class Nginx extends HttpConfigBase
if (! empty($row['error403path'])) {
$defhandler = $row['error403path'];
if (! validateUrl($defhandler)) {
if (! \Froxlor\Validate\Form\Strings::validateUrl($defhandler)) {
$defhandler = \Froxlor\FileDir::makeCorrectFile($defhandler);
}
$path_options .= "\t" . 'error_page 403 ' . $defhandler . ';' . "\n";
@@ -719,7 +719,7 @@ class Nginx extends HttpConfigBase
if (! empty($row['error500path'])) {
$defhandler = $row['error500path'];
if (! validateUrl($defhandler)) {
if (! \Froxlor\Validate\Form\Strings::validateUrl($defhandler)) {
$defhandler = \Froxlor\FileDir::makeCorrectFile($defhandler);
}
$path_options .= "\t" . 'error_page 500 502 503 504 ' . $defhandler . ';' . "\n";

View File

@@ -63,7 +63,7 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron
'company' => $row['company']
);
$replace_arr = array(
'SALUTATION' => getCorrectUserSalutation($rep_userinfo),
'SALUTATION' => \Froxlor\User::getCorrectUserSalutation($rep_userinfo),
'NAME' => $row['name'], // < keep this for compatibility
'TRAFFIC' => round(($row['traffic'] / 1024), 2), /* traffic is stored in KB, template uses MB */
'TRAFFICUSED' => round(($row['traffic_used'] / 1024), 2), /* traffic is stored in KB, template uses MB */
@@ -362,7 +362,7 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron
'company' => $row['company']
);
$replace_arr = array(
'SALUTATION' => getCorrectUserSalutation($rep_userinfo),
'SALUTATION' => \Froxlor\User::getCorrectUserSalutation($rep_userinfo),
'NAME' => $row['name'], // < keep this for compatibility
'DISKAVAILABLE' => round(($row['diskspace'] / 1024), 2), /* traffic is stored in KB, template uses MB */
'DISKUSED' => round($row['diskspace_used'] / 1024, 2), /* traffic is stored in KB, template uses MB */

View File

@@ -6,6 +6,176 @@ use Froxlor\Database\Database;
class Domain
{
/**
* return an array of all enabled redirect-codes
*
* @return array array of enabled redirect-codes
*/
public static function getRedirectCodesArray()
{
$sql = "SELECT * FROM `" . TABLE_PANEL_REDIRECTCODES . "` WHERE `enabled` = '1' ORDER BY `id` ASC";
$result_stmt = Database::query($sql);
$codes = array();
while ($rc = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
$codes[] = $rc;
}
return $codes;
}
/**
* return an array of all enabled redirect-codes
* for the settings form
*
* @param bool $add_desc
* optional, default true, add the code-description
*
* @return array array of enabled redirect-codes
*/
public static function getRedirectCodes($add_desc = true)
{
global $lng;
$sql = "SELECT * FROM `" . TABLE_PANEL_REDIRECTCODES . "` WHERE `enabled` = '1' ORDER BY `id` ASC";
$result_stmt = Database::query($sql);
$codes = array();
while ($rc = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
$codes[$rc['id']] = $rc['code'];
if ($add_desc) {
$codes[$rc['id']] .= ' (' . $lng['redirect_desc'][$rc['desc']] . ')';
}
}
return $codes;
}
/**
* returns the redirect-code for a given
* domain-id
*
* @param integer $domainid
* id of the domain
*
* @return string redirect-code
*/
public static function getDomainRedirectCode($domainid = 0)
{
// get system default
$default = '301';
if (\Froxlor\Settings::Get('customredirect.enabled') == '1') {
$all_codes = self::getRedirectCodes(false);
$_default = $all_codes[\Froxlor\Settings::Get('customredirect.default')];
$default = ($_default == '---') ? $default : $_default;
}
$code = $default;
if ($domainid > 0) {
$result_stmt = Database::prepare("
SELECT `r`.`code` as `redirect`
FROM `" . TABLE_PANEL_REDIRECTCODES . "` `r`, `" . TABLE_PANEL_DOMAINREDIRECTS . "` `rc`
WHERE `r`.`id` = `rc`.`rid` and `rc`.`did` = :domainid
");
$result = Database::pexecute_first($result_stmt, array(
'domainid' => $domainid
));
if (is_array($result) && isset($result['redirect'])) {
$code = ($result['redirect'] == '---') ? $default : $result['redirect'];
}
}
return $code;
}
/**
* returns the redirect-id for a given
* domain-id
*
* @param integer $domainid
* id of the domain
*
* @return integer redirect-code-id
*/
public static function getDomainRedirectId($domainid = 0)
{
$code = 1;
if ($domainid > 0) {
$result_stmt = Database::prepare("
SELECT `r`.`id` as `redirect`
FROM `" . TABLE_PANEL_REDIRECTCODES . "` `r`, `" . TABLE_PANEL_DOMAINREDIRECTS . "` `rc`
WHERE `r`.`id` = `rc`.`rid` and `rc`.`did` = :domainid
");
$result = Database::pexecute_first($result_stmt, array(
'domainid' => $domainid
));
if (is_array($result) && isset($result['redirect'])) {
$code = (int) $result['redirect'];
}
}
return $code;
}
/**
* adds a redirectcode for a domain
*
* @param integer $domainid
* id of the domain to add the code for
* @param integer $redirect
* selected redirect-id
*
* @return null
*/
public static function addRedirectToDomain($domainid = 0, $redirect = 1)
{
if ($domainid > 0) {
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_DOMAINREDIRECTS . "` SET `rid` = :rid, `did` = :did
");
Database::pexecute($ins_stmt, array(
'rid' => $redirect,
'did' => $domainid
));
}
}
/**
* updates the redirectcode of a domain
* if redirect-code is false, nothing happens
*
* @param integer $domainid
* id of the domain to update
* @param integer $redirect
* selected redirect-id or false
*
* @return null
*/
public static function updateRedirectOfDomain($domainid = 0, $redirect = false)
{
if ($redirect == false) {
return;
}
if ($domainid > 0) {
$del_stmt = Database::prepare("
DELETE FROM `" . TABLE_PANEL_DOMAINREDIRECTS . "` WHERE `did` = :domainid
");
Database::pexecute($del_stmt, array(
'domainid' => $domainid
));
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_DOMAINREDIRECTS . "` SET `rid` = :rid, `did` = :did
");
Database::pexecute($ins_stmt, array(
'rid' => $redirect,
'did' => $domainid
));
}
}
/**
* check whether a domain has subdomains added as full-domains
* #329

View File

@@ -4,6 +4,185 @@ namespace Froxlor;
class PhpHelper
{
/**
* Wrapper around htmlentities to handle arrays, with the advantage that you
* can select which fields should be handled by htmlentities
*
* @param array $subject
* The subject array
* @param string $fields
* The fields which should be checked for, separated by spaces
* @param int $quote_style
* See php documentation about this
* @param string $charset
* See php documentation about this
*
* @return array The array with htmlentitie'd strings
* @author Florian Lippert <flo@syscp.org>
*/
public static function htmlentities_array($subject, $fields = '', $quote_style = ENT_QUOTES, $charset = 'UTF-8')
{
if (is_array($subject)) {
if (! is_array($fields)) {
$fields = array_trim(explode(' ', $fields));
}
foreach ($subject as $field => $value) {
if ((! is_array($fields) || empty($fields)) || (is_array($fields) && ! empty($fields) && in_array($field, $fields))) {
// Just call ourselve to manage multi-dimensional arrays
$subject[$field] = self::htmlentities_array($subject[$field], $fields, $quote_style, $charset);
}
}
} else {
$subject = htmlentities($subject, $quote_style, $charset);
}
return $subject;
}
/**
* Replaces Strings in an array, with the advantage that you
* can select which fields should be str_replace'd
*
* @param
* mixed String or array of strings to search for
* @param
* mixed String or array to replace with
* @param
* array The subject array
* @param
* string The fields which should be checked for, separated by spaces
* @return array The str_replace'd array
* @author Florian Lippert <flo@syscp.org>
*/
public static function str_replace_array($search, $replace, $subject, $fields = '')
{
if (is_array($subject)) {
$fields = array_trim(explode(' ', $fields));
foreach ($subject as $field => $value) {
if ((! is_array($fields) || empty($fields)) || (is_array($fields) && ! empty($fields) && in_array($field, $fields))) {
$subject[$field] = str_replace($search, $replace, $subject[$field]);
}
}
} else {
$subject = str_replace($search, $replace, $subject);
}
return $subject;
}
/**
* froxlor php error handler
*
* @param int $errno
* @param string $errstr
* @param string $errfile
* @param int $errline
* @param array $errcontext
*
* @return void|boolean
*/
public static function phpErrHandler($errno, $errstr, $errfile, $errline, $errcontext)
{
if (! (error_reporting() & $errno)) {
// This error code is not included in error_reporting
return;
}
if (! isset($_SERVER['SHELL']) || (isset($_SERVER['SHELL']) && $_SERVER['SHELL'] == '')) {
global $theme;
// fallback
if (empty($theme)) {
$theme = "Sparkle";
}
// prevent possible file-path-disclosure
$errfile = str_replace(\Froxlor\Froxlor::getInstallDir(), "", $errfile);
// if we're not on the shell, output a nicer error-message
$err_hint = file_get_contents(\Froxlor\Froxlor::getInstallDir() . '/templates/' . $theme . '/misc/phperrornice.tpl');
// replace values
$err_hint = str_replace("<TEXT>", '#' . $errno . ' ' . $errstr, $err_hint);
$err_hint = str_replace("<DEBUG>", $errfile . ':' . $errline, $err_hint);
// show
echo $err_hint;
// return true to ignore php standard error-handler
return true;
}
// of on shell, use the php standard error-handler
return false;
}
public static function loadConfigArrayDir()
{
// Workaround until we use gettext
global $lng, $theme;
// we now use dynamic function parameters
// so we can read from more than one directory
// and still be valid for old calls
$numargs = func_num_args();
if ($numargs <= 0) {
return null;
}
// variable that holds all dirs that will
// be parsed for inclusion
$configdirs = array();
// if one of the parameters is an array
// we assume that this is a list of
// setting-groups to be selected
$selection = null;
for ($x = 0; $x < $numargs; $x ++) {
$arg = func_get_arg($x);
if (is_array($arg) && isset($arg[0])) {
$selection = $arg;
} else {
$configdirs[] = $arg;
}
}
$data = array();
$data_files = array();
$has_data = false;
foreach ($configdirs as $data_dirname) {
if (is_dir($data_dirname)) {
$data_dirhandle = opendir($data_dirname);
while (false !== ($data_filename = readdir($data_dirhandle))) {
if ($data_filename != '.' && $data_filename != '..' && $data_filename != '' && substr($data_filename, - 4) == '.php') {
$data_files[] = $data_dirname . $data_filename;
}
}
$has_data = true;
}
}
if ($has_data) {
sort($data_files);
foreach ($data_files as $data_filename) {
$data = array_merge_recursive($data, include ($data_filename));
}
}
// if we have specific setting-groups
// to select, we'll handle this here
// (this is for multiserver-client settings)
$_data = array();
if ($selection != null && is_array($selection) && isset($selection[0])) {
$_data['groups'] = array();
foreach ($data['groups'] as $group => $data) {
if (in_array($group, $selection)) {
$_data['groups'][$group] = $data;
}
}
$data = $_data;
}
return $data;
}
/**
* ipv6 aware gethostbynamel function
*

View File

@@ -4,6 +4,106 @@ namespace Froxlor\UI;
class HTML
{
/**
* Build Navigation Sidebar
*
* @param
* array navigation data
* @param
* array userinfo the userinfo of the user
* @return string the content of the navigation bar
*
* @author Florian Lippert <flo@syscp.org>
*/
public static function buildNavigation($navigation, $userinfo)
{
global $theme;
$returnvalue = '';
// sanitize user-given input (url-manipulation)
if (isset($_GET['page']) && is_array($_GET['page'])) {
$_GET['page'] = (string) $_GET['page'][0];
}
if (isset($_GET['action']) && is_array($_GET['action'])) {
$_GET['action'] = (string) $_GET['action'][0];
}
foreach ($navigation as $box) {
if ((! isset($box['show_element']) || $box['show_element'] === true) && (! isset($box['required_resources']) || $box['required_resources'] == '' || (isset($userinfo[$box['required_resources']]) && ((int) $userinfo[$box['required_resources']] > 0 || $userinfo[$box['required_resources']] == '-1')))) {
$navigation_links = '';
foreach ($box['elements'] as $element_id => $element) {
if ((! isset($element['show_element']) || $element['show_element'] === true) && (! isset($element['required_resources']) || $element['required_resources'] == '' || (isset($userinfo[$element['required_resources']]) && ((int) $userinfo[$element['required_resources']] > 0 || $userinfo[$element['required_resources']] == '-1')))) {
$target = '';
$active = '';
$navurl = '#';
if (isset($element['url']) && trim($element['url']) != '') {
// append sid only to local
if (! preg_match('/^https?\:\/\//', $element['url']) && (isset($userinfo['hash']) && $userinfo['hash'] != '')) {
// generate sid with ? oder &
if (strpos($element['url'], '?') !== false) {
$element['url'] .= '&s=' . $userinfo['hash'];
} else {
$element['url'] .= '?s=' . $userinfo['hash'];
}
}
if (isset($element['new_window']) && $element['new_window'] == true) {
$target = ' target="_blank"';
}
if (isset($_GET['page']) && substr_count($element['url'], "page=" . $_GET['page']) > 0 && substr_count($element['url'], basename($_SERVER["SCRIPT_FILENAME"])) > 0 && isset($_GET['action']) && substr_count($element['url'], "action=" . $_GET['action']) > 0) {
$active = ' active';
} elseif (isset($_GET['page']) && substr_count($element['url'], "page=" . $_GET['page']) > 0 && substr_count($element['url'], basename($_SERVER["SCRIPT_FILENAME"])) > 0 && substr_count($element['url'], "action=") == 0 && ! isset($_GET['action'])) {
$active = ' active';
}
$navurl = htmlspecialchars($element['url']);
$navlabel = $element['label'];
} else {
$navlabel = $element['label'];
}
eval("\$navigation_links .= \"" . \Froxlor\UI\Template::getTemplate("navigation_link", 1) . "\";");
}
}
if ($navigation_links != '') {
$target = '';
if (isset($box['url']) && trim($box['url']) != '') {
// append sid only to local
if (! preg_match('/^https?\:\/\//', $box['url']) && (isset($userinfo['hash']) && $userinfo['hash'] != '')) {
// generate sid with ? oder &
if (strpos($box['url'], '?') !== false) {
$box['url'] .= '&s=' . $userinfo['hash'];
} else {
$box['url'] .= '?s=' . $userinfo['hash'];
}
}
if (isset($box['new_window']) && $box['new_window'] == true) {
$target = ' target="_blank"';
}
$navurl = htmlspecialchars($box['url']);
$navlabel = $box['label'];
} else {
$navurl = "#";
$navlabel = $box['label'];
}
eval("\$returnvalue .= \"" . \Froxlor\UI\Template::getTemplate("navigation_element", 1) . "\";");
}
}
}
return $returnvalue;
}
/**
* Return HTML Code for a checkbox
*

346
lib/Froxlor/User.php Normal file
View File

@@ -0,0 +1,346 @@
<?php
namespace Froxlor;
use Froxlor\Database\Database;
class User
{
/**
* Returns full style user details "Name, Firstname | Company"
*
* @param
* array An array with keys firstname, name and company
* @return string The full details
*
* @author Florian Lippert <flo@syscp.org>
*/
public static function getCorrectFullUserDetails($userinfo)
{
$returnval = '';
if (isset($userinfo['firstname']) && isset($userinfo['name']) && isset($userinfo['company'])) {
if ($userinfo['company'] == '') {
$returnval = $userinfo['name'] . ', ' . $userinfo['firstname'];
} else {
if ($userinfo['name'] != '' && $userinfo['firstname'] != '') {
$returnval = $userinfo['name'] . ', ' . $userinfo['firstname'] . ' | ' . $userinfo['company'];
} else {
$returnval = $userinfo['company'];
}
}
} elseif (isset($userinfo['name'])) {
$returnval = $userinfo['name'];
}
return $returnval;
}
/**
* Returns correct user salutation, either "Firstname Name" or "Company"
*
* @param
* array An array with keys firstname, name and company
* @return string The correct salutation
*
* @author Florian Lippert <flo@syscp.org>
*/
public static function getCorrectUserSalutation($userinfo)
{
$returnval = '';
if (isset($userinfo['firstname']) && isset($userinfo['name']) && isset($userinfo['company'])) {
// Always prefer firstname name
if ($userinfo['company'] != '' && $userinfo['name'] == '' && $userinfo['firstname'] == '') {
$returnval = $userinfo['company'];
} else {
$returnval = $userinfo['firstname'] . ' ' . $userinfo['name'];
}
}
return $returnval;
}
public static function getLanguages()
{
$result_stmt = \Froxlor\Database\Database::query("SELECT * FROM `" . TABLE_PANEL_LANGUAGE . "` ");
$languages_array = array();
while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
if (! isset($languages_array[$row['language']]) && ! in_array($row['language'], $languages_array)) {
$languages_array[$row['language']] = html_entity_decode($row['language']);
}
}
return $languages_array;
}
/**
* Function which updates all counters of used ressources in panel_admins and panel_customers
*
* @param
* bool Set to true to get an array with debug information
* @return array Contains debug information if parameter 'returndebuginfo' is set to true
*
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
*/
public static function updateCounters($returndebuginfo = false)
{
$returnval = array();
if ($returndebuginfo === true) {
$returnval = array(
'admins' => array(),
'customers' => array()
);
}
// Customers
$customers_stmt = Database::prepare('SELECT * FROM `' . TABLE_PANEL_CUSTOMERS . '` ORDER BY `customerid`');
Database::pexecute($customers_stmt);
$admin_resources = array();
while ($customer = $customers_stmt->fetch(\PDO::FETCH_ASSOC)) {
$cur_adm = $customer['adminid'];
// initialize admin-resources array for admin $customer['adminid']
if (! isset($admin_resources[$cur_adm])) {
$admin_resources[$cur_adm] = array();
}
self::_addResourceCountEx($admin_resources[$cur_adm], $customer, 'diskspace_used', 'diskspace');
self::_addResourceCountEx($admin_resources[$cur_adm], $customer, 'traffic_used', 'traffic_used'); // !!! yes, USED and USED
foreach (array(
'mysqls',
'ftps',
'emails',
'email_accounts',
'email_forwarders',
'email_quota',
'subdomains'
) as $field) {
_addResourceCount($admin_resources[$cur_adm], $customer, $field . '_used', $field);
}
$customer_mysqls_stmt = Database::prepare('SELECT COUNT(*) AS `number_mysqls` FROM `' . TABLE_PANEL_DATABASES . '`
WHERE `customerid` = :cid');
$customer_mysqls = Database::pexecute_first($customer_mysqls_stmt, array(
"cid" => $customer['customerid']
));
$customer['mysqls_used_new'] = (int) $customer_mysqls['number_mysqls'];
$customer_emails_stmt = Database::prepare('SELECT COUNT(*) AS `number_emails` FROM `' . TABLE_MAIL_VIRTUAL . '`
WHERE `customerid` = :cid');
$customer_emails = Database::pexecute_first($customer_emails_stmt, array(
"cid" => $customer['customerid']
));
$customer['emails_used_new'] = (int) $customer_emails['number_emails'];
$customer_emails_result_stmt = Database::prepare('SELECT `email`, `email_full`, `destination`, `popaccountid` AS `number_email_forwarders` FROM `' . TABLE_MAIL_VIRTUAL . '`
WHERE `customerid` = :cid');
Database::pexecute($customer_emails_result_stmt, array(
"cid" => $customer['customerid']
));
$customer_email_forwarders = 0;
$customer_email_accounts = 0;
while ($customer_emails_row = $customer_emails_result_stmt->fetch(\PDO::FETCH_ASSOC)) {
if ($customer_emails_row['destination'] != '') {
$customer_emails_row['destination'] = explode(' ', \Froxlor\FileDir::makeCorrectDestination($customer_emails_row['destination']));
$customer_email_forwarders += count($customer_emails_row['destination']);
if (in_array($customer_emails_row['email_full'], $customer_emails_row['destination'])) {
$customer_email_forwarders -= 1;
$customer_email_accounts ++;
}
}
}
$customer['email_accounts_used_new'] = $customer_email_accounts;
$customer['email_forwarders_used_new'] = $customer_email_forwarders;
$customer_ftps_stmt = Database::prepare('SELECT COUNT(*) AS `number_ftps` FROM `' . TABLE_FTP_USERS . '` WHERE `customerid` = :cid');
$customer_ftps = Database::pexecute_first($customer_ftps_stmt, array(
"cid" => $customer['customerid']
));
$customer['ftps_used_new'] = ((int) $customer_ftps['number_ftps'] - 1);
$customer_subdomains_stmt = Database::prepare('SELECT COUNT(*) AS `number_subdomains` FROM `' . TABLE_PANEL_DOMAINS . '` WHERE `customerid` = :cid AND `parentdomainid` <> "0"');
$customer_subdomains = Database::pexecute_first($customer_subdomains_stmt, array(
"cid" => $customer['customerid']
));
$customer['subdomains_used_new'] = (int) $customer_subdomains['number_subdomains'];
$customer_email_quota_stmt = Database::prepare('SELECT SUM(`quota`) AS `email_quota` FROM `' . TABLE_MAIL_USERS . '` WHERE `customerid` = :cid');
$customer_email_quota = Database::pexecute_first($customer_email_quota_stmt, array(
"cid" => $customer['customerid']
));
$customer['email_quota_used_new'] = (int) $customer_email_quota['email_quota'];
$stmt = Database::prepare('UPDATE `' . TABLE_PANEL_CUSTOMERS . '`
SET `mysqls_used` = :mysqls_used,
`emails_used` = :emails_used,
`email_accounts_used` = :email_accounts_used,
`email_forwarders_used` = :email_forwarders_used,
`email_quota_used` = :email_quota_used,
`ftps_used` = :ftps_used,
`subdomains_used` = :subdomains_used
WHERE `customerid` = :cid');
$params = array(
"mysqls_used" => $customer['mysqls_used_new'],
"emails_used" => $customer['emails_used_new'],
"email_accounts_used" => $customer['email_accounts_used_new'],
"email_forwarders_used" => $customer['email_forwarders_used_new'],
"email_quota_used" => $customer['email_quota_used_new'],
"ftps_used" => $customer['ftps_used_new'],
"subdomains_used" => $customer['subdomains_used_new'],
"cid" => $customer['customerid']
);
Database::pexecute($stmt, $params);
if ($returndebuginfo === true) {
$returnval['customers'][$customer['customerid']] = $customer;
}
}
// Admins
$admins_stmt = Database::prepare('SELECT * FROM `' . TABLE_PANEL_ADMINS . '` ORDER BY `adminid`');
Database::pexecute($admins_stmt, array());
while ($admin = $admins_stmt->fetch(\PDO::FETCH_ASSOC)) {
$admin_customers_stmt = Database::prepare('SELECT COUNT(*) AS `number_customers` FROM `' . TABLE_PANEL_CUSTOMERS . '` WHERE `adminid` = :aid');
$admin_customers = Database::pexecute_first($admin_customers_stmt, array(
"aid" => $admin['adminid']
));
$admin['customers_used_new'] = $admin_customers['number_customers'];
$admin_domains_stmt = Database::prepare('SELECT COUNT(*) AS `number_domains` FROM `' . TABLE_PANEL_DOMAINS . '` WHERE `adminid` = :aid AND `isemaildomain` = "1"');
$admin_domains = Database::pexecute_first($admin_domains_stmt, array(
"aid" => $admin['adminid']
));
$admin['domains_used_new'] = $admin_domains['number_domains'];
$cur_adm = $admin['adminid'];
if (! isset($admin_resources[$cur_adm])) {
$admin_resources[$cur_adm] = array();
}
foreach (array(
'diskspace_used',
'traffic_used',
'mysqls_used',
'ftps_used',
'emails_used',
'email_accounts_used',
'email_forwarders_used',
'email_quota_used',
'subdomains_used'
) as $field) {
self::_initArrField($field, $admin_resources[$cur_adm], 0);
$admin[$field . '_new'] = $admin_resources[$cur_adm][$field];
}
$stmt = Database::prepare('UPDATE `' . TABLE_PANEL_ADMINS . '`
SET `customers_used` = :customers_used,
`domains_used` = :domains_used,
`diskspace_used` = :diskspace_used,
`mysqls_used` = :mysqls_used,
`emails_used` = :emails_used,
`email_accounts_used` = :email_accounts_used,
`email_forwarders_used` = :email_forwarders_used,
`email_quota_used` = :email_quota_used,
`ftps_used` = :ftps_used,
`subdomains_used` = :subdomains_used,
`traffic_used` = :traffic_used
WHERE `adminid` = :aid');
$params = array(
"customers_used" => $admin['customers_used_new'],
"domains_used" => $admin['domains_used_new'],
"diskspace_used" => $admin['diskspace_used_new'],
"mysqls_used" => $admin['mysqls_used_new'],
"emails_used" => $admin['emails_used_new'],
"email_accounts_used" => $admin['email_accounts_used_new'],
"email_forwarders_used" => $admin['email_forwarders_used_new'],
"email_quota_used" => $admin['email_quota_used_new'],
"ftps_used" => $admin['ftps_used_new'],
"subdomains_used" => $admin['subdomains_used_new'],
"traffic_used" => $admin['traffic_used_new'],
"aid" => $admin['adminid']
);
Database::pexecute($stmt, $params);
if ($returndebuginfo === true) {
$returnval['admins'][$admin['adminid']] = $admin;
}
}
return $returnval;
}
/**
* if the customer does not have unlimited resources, add the used resources
* to the admin-resource-counter
*
* @param array $arr
* reference
* @param array $customer_arr
* @param string $used_field
* @param string $field
*
* @return void
*/
private static function _addResourceCount(&$arr, $customer_arr, $used_field = null, $field = null)
{
self::_initArrField($used_field, $arr, 0);
if ($customer_arr[$field] != '-1') {
$arr[$used_field] += intval($customer_arr[$used_field]);
}
}
/**
* if the customer does not have unlimited resources, add the used resources
* to the admin-resource-counter
* Special function wrapper for diskspace and traffic as they need to
* be calculated otherwise to get the -1 for unlimited
*
* @param array $arr
* reference
* @param array $customer_arr
* @param string $used_field
* @param string $field
*
* @return void
*/
private static function _addResourceCountEx(&$arr, $customer_arr, $used_field = null, $field = null)
{
self::_initArrField($used_field, $arr, 0);
if ($field == 'diskspace' && ($customer_arr[$field] / 1024) != '-1') {
$arr[$used_field] += intval($customer_arr[$used_field]);
} elseif ($field == 'traffic_used') {
$arr[$used_field] += intval($customer_arr[$used_field]);
}
}
/**
* initialize a field-value of an array if not yet initialized
*
* @param string $field
* @param array $arr
* reference
* @param int $init_value
*
* @return void
*/
private static function _initArrField($field = null, &$arr, $init_value = 0)
{
if (! isset($arr[$field])) {
$arr[$field] = $init_value;
}
}
}

View File

@@ -45,7 +45,7 @@ function validateFormFieldHiddenString($fieldname, $fielddata, $newfieldvalue)
if (isset($fielddata['string_type']) && $fielddata['string_type'] == 'mail') {
$returnvalue = (filter_var($newfieldvalue, FILTER_VALIDATE_EMAIL) == $newfieldvalue);
} elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'url') {
$returnvalue = validateUrl($newfieldvalue);
$returnvalue = \Froxlor\Validate\Form\Strings::validateUrl($newfieldvalue);
} elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'dir') {
// add trailing slash to validate path if needed
// refs #331
@@ -83,4 +83,4 @@ function validateFormFieldHiddenString($fieldname, $fielddata, $newfieldvalue)
} else {
return $returnvalue;
}
}
}

View File

@@ -1,59 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
/**
* this functions validates a given value as ErrorDocument
* refs #267
*
* @param
* string error-document-string
* @param bool $throw_exception
*
* @return string error-document-string
*
*/
function correctErrorDocument($errdoc = null, $throw_exception = false)
{
$idna_convert = new idna_convert_wrapper();
if ($errdoc !== null && $errdoc != '') {
// not a URL
if ((strtoupper(substr($errdoc, 0, 5)) != 'HTTP:' && strtoupper(substr($errdoc, 0, 6)) != 'HTTPS:') || ! validateUrl($errdoc)) {
// a file
if (substr($errdoc, 0, 1) != '"') {
$errdoc = \Froxlor\FileDir::makeCorrectFile($errdoc);
// apache needs a starting-slash (starting at the domains-docroot)
if (! substr($errdoc, 0, 1) == '/') {
$errdoc = '/' . $errdoc;
}
} // a string (check for ending ")
else {
// string won't work for lighty
if (Settings::Get('system.webserver') == 'lighttpd') {
\Froxlor\UI\Response::standard_error('stringerrordocumentnotvalidforlighty', '', $throw_exception);
} elseif (substr($errdoc, - 1) != '"') {
$errdoc .= '"';
}
}
} else {
if (Settings::Get('system.webserver') == 'lighttpd') {
\Froxlor\UI\Response::standard_error('urlerrordocumentnotvalidforlighty', '', $throw_exception);
}
}
}
return $errdoc;
}

View File

@@ -1,31 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function getLanguages()
{
$result_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_LANGUAGE . "` ");
$languages_array = array();
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if (! isset($languages_array[$row['language']]) && ! in_array($row['language'], $languages_array)) {
$languages_array[$row['language']] = html_entity_decode($row['language']);
}
}
return $languages_array;
}

View File

@@ -1,87 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function loadConfigArrayDir()
{
// Workaround until we use gettext
global $lng, $theme;
// we now use dynamic function parameters
// so we can read from more than one directory
// and still be valid for old calls
$numargs = func_num_args();
if ($numargs <= 0) {
return null;
}
// variable that holds all dirs that will
// be parsed for inclusion
$configdirs = array();
// if one of the parameters is an array
// we assume that this is a list of
// setting-groups to be selected
$selection = null;
for ($x = 0; $x < $numargs; $x ++) {
$arg = func_get_arg($x);
if (is_array($arg) && isset($arg[0])) {
$selection = $arg;
} else {
$configdirs[] = $arg;
}
}
$data = array();
$data_files = array();
$has_data = false;
foreach ($configdirs as $data_dirname) {
if (is_dir($data_dirname)) {
$data_dirhandle = opendir($data_dirname);
while (false !== ($data_filename = readdir($data_dirhandle))) {
if ($data_filename != '.' && $data_filename != '..' && $data_filename != '' && substr($data_filename, - 4) == '.php') {
$data_files[] = $data_dirname . $data_filename;
}
}
$has_data = true;
}
}
if ($has_data) {
sort($data_files);
foreach ($data_files as $data_filename) {
$data = array_merge_recursive($data, include ($data_filename));
}
}
// if we have specific setting-groups
// to select, we'll handle this here
// (this is for multiserver-client settings)
$_data = array();
if ($selection != null && is_array($selection) && isset($selection[0])) {
$_data['groups'] = array();
foreach ($data['groups'] as $group => $data) {
if (in_array($group, $selection)) {
$_data['groups'][$group] = $data;
}
}
$data = $_data;
}
return $data;
}

View File

@@ -1,44 +0,0 @@
<?php
/**
* froxlor php error handler
*
* @param int $errno
* @param string $errstr
* @param string $errfile
* @param int $errline
* @param array $errcontext
*
* @return void|boolean
*/
function phpErrHandler($errno, $errstr, $errfile, $errline, $errcontext)
{
if (! (error_reporting() & $errno)) {
// This error code is not included in error_reporting
return;
}
if (! isset($_SERVER['SHELL']) || (isset($_SERVER['SHELL']) && $_SERVER['SHELL'] == '')) {
global $theme;
// fallback
if (empty($theme)) {
$theme = "Sparkle";
}
// prevent possible file-path-disclosure
$errfile = str_replace(\Froxlor\Froxlor::getInstallDir(), "", $errfile);
// if we're not on the shell, output a nicer error-message
$err_hint = file_get_contents(\Froxlor\Froxlor::getInstallDir() . '/templates/' . $theme . '/misc/phperrornice.tpl');
// replace values
$err_hint = str_replace("<TEXT>", '#' . $errno . ' ' . $errstr, $err_hint);
$err_hint = str_replace("<DEBUG>", $errfile . ':' . $errline, $err_hint);
// show
echo $err_hint;
// return true to ignore php standard error-handler
return true;
}
// of on shell, use the php standard error-handler
return false;
}

View File

@@ -1,287 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
use Froxlor\Database\Database;
/**
* Function which updates all counters of used ressources in panel_admins and panel_customers
*
* @param
* bool Set to true to get an array with debug information
* @return array Contains debug information if parameter 'returndebuginfo' is set to true
*
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
*/
function updateCounters($returndebuginfo = false)
{
$returnval = array();
if ($returndebuginfo === true) {
$returnval = array(
'admins' => array(),
'customers' => array()
);
}
// Customers
$customers_stmt = Database::prepare('SELECT * FROM `' . TABLE_PANEL_CUSTOMERS . '` ORDER BY `customerid`');
Database::pexecute($customers_stmt);
$admin_resources = array();
while ($customer = $customers_stmt->fetch(PDO::FETCH_ASSOC)) {
$cur_adm = $customer['adminid'];
// initialize admin-resources array for admin $customer['adminid']
if (! isset($admin_resources[$cur_adm])) {
$admin_resources[$cur_adm] = array();
}
_addResourceCountEx($admin_resources[$cur_adm], $customer, 'diskspace_used', 'diskspace');
_addResourceCountEx($admin_resources[$cur_adm], $customer, 'traffic_used', 'traffic_used'); // !!! yes, USED and USED
foreach (array(
'mysqls',
'ftps',
'emails',
'email_accounts',
'email_forwarders',
'email_quota',
'subdomains'
) as $field) {
_addResourceCount($admin_resources[$cur_adm], $customer, $field . '_used', $field);
}
$customer_mysqls_stmt = Database::prepare('SELECT COUNT(*) AS `number_mysqls` FROM `' . TABLE_PANEL_DATABASES . '`
WHERE `customerid` = :cid');
$customer_mysqls = Database::pexecute_first($customer_mysqls_stmt, array(
"cid" => $customer['customerid']
));
$customer['mysqls_used_new'] = (int) $customer_mysqls['number_mysqls'];
$customer_emails_stmt = Database::prepare('SELECT COUNT(*) AS `number_emails` FROM `' . TABLE_MAIL_VIRTUAL . '`
WHERE `customerid` = :cid');
$customer_emails = Database::pexecute_first($customer_emails_stmt, array(
"cid" => $customer['customerid']
));
$customer['emails_used_new'] = (int) $customer_emails['number_emails'];
$customer_emails_result_stmt = Database::prepare('SELECT `email`, `email_full`, `destination`, `popaccountid` AS `number_email_forwarders` FROM `' . TABLE_MAIL_VIRTUAL . '`
WHERE `customerid` = :cid');
Database::pexecute($customer_emails_result_stmt, array(
"cid" => $customer['customerid']
));
$customer_email_forwarders = 0;
$customer_email_accounts = 0;
while ($customer_emails_row = $customer_emails_result_stmt->fetch(PDO::FETCH_ASSOC)) {
if ($customer_emails_row['destination'] != '') {
$customer_emails_row['destination'] = explode(' ', \Froxlor\FileDir::makeCorrectDestination($customer_emails_row['destination']));
$customer_email_forwarders += count($customer_emails_row['destination']);
if (in_array($customer_emails_row['email_full'], $customer_emails_row['destination'])) {
$customer_email_forwarders -= 1;
$customer_email_accounts ++;
}
}
}
$customer['email_accounts_used_new'] = $customer_email_accounts;
$customer['email_forwarders_used_new'] = $customer_email_forwarders;
$customer_ftps_stmt = Database::prepare('SELECT COUNT(*) AS `number_ftps` FROM `' . TABLE_FTP_USERS . '` WHERE `customerid` = :cid');
$customer_ftps = Database::pexecute_first($customer_ftps_stmt, array(
"cid" => $customer['customerid']
));
$customer['ftps_used_new'] = ((int) $customer_ftps['number_ftps'] - 1);
$customer_subdomains_stmt = Database::prepare('SELECT COUNT(*) AS `number_subdomains` FROM `' . TABLE_PANEL_DOMAINS . '` WHERE `customerid` = :cid AND `parentdomainid` <> "0"');
$customer_subdomains = Database::pexecute_first($customer_subdomains_stmt, array(
"cid" => $customer['customerid']
));
$customer['subdomains_used_new'] = (int) $customer_subdomains['number_subdomains'];
$customer_email_quota_stmt = Database::prepare('SELECT SUM(`quota`) AS `email_quota` FROM `' . TABLE_MAIL_USERS . '` WHERE `customerid` = :cid');
$customer_email_quota = Database::pexecute_first($customer_email_quota_stmt, array(
"cid" => $customer['customerid']
));
$customer['email_quota_used_new'] = (int) $customer_email_quota['email_quota'];
$stmt = Database::prepare('UPDATE `' . TABLE_PANEL_CUSTOMERS . '`
SET `mysqls_used` = :mysqls_used,
`emails_used` = :emails_used,
`email_accounts_used` = :email_accounts_used,
`email_forwarders_used` = :email_forwarders_used,
`email_quota_used` = :email_quota_used,
`ftps_used` = :ftps_used,
`subdomains_used` = :subdomains_used
WHERE `customerid` = :cid');
$params = array(
"mysqls_used" => $customer['mysqls_used_new'],
"emails_used" => $customer['emails_used_new'],
"email_accounts_used" => $customer['email_accounts_used_new'],
"email_forwarders_used" => $customer['email_forwarders_used_new'],
"email_quota_used" => $customer['email_quota_used_new'],
"ftps_used" => $customer['ftps_used_new'],
"subdomains_used" => $customer['subdomains_used_new'],
"cid" => $customer['customerid']
);
Database::pexecute($stmt, $params);
if ($returndebuginfo === true) {
$returnval['customers'][$customer['customerid']] = $customer;
}
}
// Admins
$admins_stmt = Database::prepare('SELECT * FROM `' . TABLE_PANEL_ADMINS . '` ORDER BY `adminid`');
Database::pexecute($admins_stmt, array());
while ($admin = $admins_stmt->fetch(PDO::FETCH_ASSOC)) {
$admin_customers_stmt = Database::prepare('SELECT COUNT(*) AS `number_customers` FROM `' . TABLE_PANEL_CUSTOMERS . '` WHERE `adminid` = :aid');
$admin_customers = Database::pexecute_first($admin_customers_stmt, array(
"aid" => $admin['adminid']
));
$admin['customers_used_new'] = $admin_customers['number_customers'];
$admin_domains_stmt = Database::prepare('SELECT COUNT(*) AS `number_domains` FROM `' . TABLE_PANEL_DOMAINS . '` WHERE `adminid` = :aid AND `isemaildomain` = "1"');
$admin_domains = Database::pexecute_first($admin_domains_stmt, array(
"aid" => $admin['adminid']
));
$admin['domains_used_new'] = $admin_domains['number_domains'];
$cur_adm = $admin['adminid'];
if (! isset($admin_resources[$cur_adm])) {
$admin_resources[$cur_adm] = array();
}
foreach (array(
'diskspace_used',
'traffic_used',
'mysqls_used',
'ftps_used',
'emails_used',
'email_accounts_used',
'email_forwarders_used',
'email_quota_used',
'subdomains_used'
) as $field) {
_initArrField($field, $admin_resources[$cur_adm], 0);
$admin[$field . '_new'] = $admin_resources[$cur_adm][$field];
}
$stmt = Database::prepare('UPDATE `' . TABLE_PANEL_ADMINS . '`
SET `customers_used` = :customers_used,
`domains_used` = :domains_used,
`diskspace_used` = :diskspace_used,
`mysqls_used` = :mysqls_used,
`emails_used` = :emails_used,
`email_accounts_used` = :email_accounts_used,
`email_forwarders_used` = :email_forwarders_used,
`email_quota_used` = :email_quota_used,
`ftps_used` = :ftps_used,
`subdomains_used` = :subdomains_used,
`traffic_used` = :traffic_used
WHERE `adminid` = :aid');
$params = array(
"customers_used" => $admin['customers_used_new'],
"domains_used" => $admin['domains_used_new'],
"diskspace_used" => $admin['diskspace_used_new'],
"mysqls_used" => $admin['mysqls_used_new'],
"emails_used" => $admin['emails_used_new'],
"email_accounts_used" => $admin['email_accounts_used_new'],
"email_forwarders_used" => $admin['email_forwarders_used_new'],
"email_quota_used" => $admin['email_quota_used_new'],
"ftps_used" => $admin['ftps_used_new'],
"subdomains_used" => $admin['subdomains_used_new'],
"traffic_used" => $admin['traffic_used_new'],
"aid" => $admin['adminid']
);
Database::pexecute($stmt, $params);
if ($returndebuginfo === true) {
$returnval['admins'][$admin['adminid']] = $admin;
}
}
return $returnval;
}
/**
* initialize a field-value of an array if not yet initialized
*
* @param string $field
* @param array $arr
* reference
* @param int $init_value
*
* @return void
*/
function _initArrField($field = null, &$arr, $init_value = 0)
{
if (! isset($arr[$field])) {
$arr[$field] = $init_value;
}
}
/**
* if the customer does not have unlimited resources, add the used resources
* to the admin-resource-counter
*
* @param array $arr
* reference
* @param array $customer_arr
* @param string $used_field
* @param string $field
*
* @return void
*/
function _addResourceCount(&$arr, $customer_arr, $used_field = null, $field = null)
{
_initArrField($used_field, $arr, 0);
if ($customer_arr[$field] != '-1') {
$arr[$used_field] += intval($customer_arr[$used_field]);
}
}
/**
* if the customer does not have unlimited resources, add the used resources
* to the admin-resource-counter
* Special function wrapper for diskspace and traffic as they need to
* be calculated otherwise to get the -1 for unlimited
*
* @param array $arr
* reference
* @param array $customer_arr
* @param string $used_field
* @param string $field
*
* @return void
*/
function _addResourceCountEx(&$arr, $customer_arr, $used_field = null, $field = null)
{
_initArrField($used_field, $arr, 0);
if ($field == 'diskspace' && ($customer_arr[$field] / 1024) != '-1') {
$arr[$used_field] += intval($customer_arr[$used_field]);
} elseif ($field == 'traffic_used') {
$arr[$used_field] += intval($customer_arr[$used_field]);
}
}

View File

@@ -1,93 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
/**
* Function showUpdateStep
*
* outputs and logs the current
* update progress
*
* @param
* string task/status
* @param
* bool needs_status (if false, a linebreak will be added)
*
* @return string formatted output and log-entry
*/
function showUpdateStep($task = null, $needs_status = true)
{
global $updatelog, $filelog;
if (! $needs_status)
echo "<b>";
// output
echo $task;
if (! $needs_status) {
echo "</b><br />";
}
$updatelog->logAction(ADM_ACTION, LOG_WARNING, $task);
$filelog->logAction(ADM_ACTION, LOG_WARNING, $task);
}
/**
* Function lastStepStatus
*
* outputs [OK] (success), [??] (warning) or [!!] (failure)
* of the last update-step
*
* @param
* int status (0 = success, 1 = warning, 2 = failure)
*
* @return string formatted output and log-entry
*/
function lastStepStatus($status = -1, $message = '')
{
global $updatelog, $filelog;
switch ($status) {
case 0:
$status_sign = ($message != '') ? '[' . $message . ']' : '[OK]';
$status_color = 'ok';
break;
case 1:
$status_sign = ($message != '') ? '[' . $message . ']' : '[??]';
$status_color = 'warn';
break;
case 2:
$status_sign = ($message != '') ? '[' . $message . ']' : '[!!]';
$status_color = 'err';
break;
default:
$status_sign = '[unknown]';
$status_color = 'unknown';
break;
}
// output
echo "<span class=\"update-step update-step-" . $status_color . "\">" . $status_sign . "</span><br />";
if ($status == - 1 || $status == 2) {
$updatelog->logAction(ADM_ACTION, LOG_WARNING, 'Attention - last update task failed!!!');
$filelog->logAction(ADM_ACTION, LOG_WARNING, 'Attention - last update task failed!!!');
} elseif ($status == 0 || $status == 1) {
$filelog->logAction(ADM_ACTION, LOG_WARNING, 'Success');
}
}

View File

@@ -1,185 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*/
/**
* return an array of all enabled redirect-codes
*
* @return array array of enabled redirect-codes
*/
function getRedirectCodesArray()
{
$sql = "SELECT * FROM `" . TABLE_PANEL_REDIRECTCODES . "` WHERE `enabled` = '1' ORDER BY `id` ASC";
$result_stmt = Database::query($sql);
$codes = array();
while ($rc = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$codes[] = $rc;
}
return $codes;
}
/**
* return an array of all enabled redirect-codes
* for the settings form
*
* @param bool $add_desc
* optional, default true, add the code-description
*
* @return array array of enabled redirect-codes
*/
function getRedirectCodes($add_desc = true)
{
global $lng;
$sql = "SELECT * FROM `" . TABLE_PANEL_REDIRECTCODES . "` WHERE `enabled` = '1' ORDER BY `id` ASC";
$result_stmt = Database::query($sql);
$codes = array();
while ($rc = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$codes[$rc['id']] = $rc['code'];
if ($add_desc) {
$codes[$rc['id']] .= ' (' . $lng['redirect_desc'][$rc['desc']] . ')';
}
}
return $codes;
}
/**
* returns the redirect-code for a given
* domain-id
*
* @param integer $domainid
* id of the domain
*
* @return string redirect-code
*/
function getDomainRedirectCode($domainid = 0)
{
// get system default
$default = '301';
if (Settings::Get('customredirect.enabled') == '1') {
$all_codes = getRedirectCodes(false);
$_default = $all_codes[Settings::Get('customredirect.default')];
$default = ($_default == '---') ? $default : $_default;
}
$code = $default;
if ($domainid > 0) {
$result_stmt = Database::prepare("
SELECT `r`.`code` as `redirect`
FROM `" . TABLE_PANEL_REDIRECTCODES . "` `r`, `" . TABLE_PANEL_DOMAINREDIRECTS . "` `rc`
WHERE `r`.`id` = `rc`.`rid` and `rc`.`did` = :domainid
");
$result = Database::pexecute_first($result_stmt, array(
'domainid' => $domainid
));
if (is_array($result) && isset($result['redirect'])) {
$code = ($result['redirect'] == '---') ? $default : $result['redirect'];
}
}
return $code;
}
/**
* returns the redirect-id for a given
* domain-id
*
* @param integer $domainid
* id of the domain
*
* @return integer redirect-code-id
*/
function getDomainRedirectId($domainid = 0)
{
$code = 1;
if ($domainid > 0) {
$result_stmt = Database::prepare("
SELECT `r`.`id` as `redirect`
FROM `" . TABLE_PANEL_REDIRECTCODES . "` `r`, `" . TABLE_PANEL_DOMAINREDIRECTS . "` `rc`
WHERE `r`.`id` = `rc`.`rid` and `rc`.`did` = :domainid
");
$result = Database::pexecute_first($result_stmt, array(
'domainid' => $domainid
));
if (is_array($result) && isset($result['redirect'])) {
$code = (int) $result['redirect'];
}
}
return $code;
}
/**
* adds a redirectcode for a domain
*
* @param integer $domainid
* id of the domain to add the code for
* @param integer $redirect
* selected redirect-id
*
* @return null
*/
function addRedirectToDomain($domainid = 0, $redirect = 1)
{
if ($domainid > 0) {
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_DOMAINREDIRECTS . "` SET `rid` = :rid, `did` = :did
");
Database::pexecute($ins_stmt, array(
'rid' => $redirect,
'did' => $domainid
));
}
}
/**
* updates the redirectcode of a domain
* if redirect-code is false, nothing happens
*
* @param integer $domainid
* id of the domain to update
* @param integer $redirect
* selected redirect-id or false
*
* @return null
*/
function updateRedirectOfDomain($domainid = 0, $redirect = false)
{
if ($redirect == false) {
return;
}
if ($domainid > 0) {
$del_stmt = Database::prepare("
DELETE FROM `" . TABLE_PANEL_DOMAINREDIRECTS . "` WHERE `did` = :domainid
");
Database::pexecute($del_stmt, array(
'domainid' => $domainid
));
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_DOMAINREDIRECTS . "` SET `rid` = :rid, `did` = :did
");
Database::pexecute($ins_stmt, array(
'rid' => $redirect,
'did' => $domainid
));
}
}

View File

@@ -1,118 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
/**
* Build Navigation Sidebar
*
* @param
* array navigation data
* @param
* array userinfo the userinfo of the user
* @return string the content of the navigation bar
*
* @author Florian Lippert <flo@syscp.org>
*/
function buildNavigation($navigation, $userinfo)
{
global $theme;
$returnvalue = '';
// sanitize user-given input (url-manipulation)
if (isset($_GET['page']) && is_array($_GET['page'])) {
$_GET['page'] = (string) $_GET['page'][0];
}
if (isset($_GET['action']) && is_array($_GET['action'])) {
$_GET['action'] = (string) $_GET['action'][0];
}
foreach ($navigation as $box) {
if ((! isset($box['show_element']) || $box['show_element'] === true) && (! isset($box['required_resources']) || $box['required_resources'] == '' || (isset($userinfo[$box['required_resources']]) && ((int) $userinfo[$box['required_resources']] > 0 || $userinfo[$box['required_resources']] == '-1')))) {
$navigation_links = '';
foreach ($box['elements'] as $element_id => $element) {
if ((! isset($element['show_element']) || $element['show_element'] === true) && (! isset($element['required_resources']) || $element['required_resources'] == '' || (isset($userinfo[$element['required_resources']]) && ((int) $userinfo[$element['required_resources']] > 0 || $userinfo[$element['required_resources']] == '-1')))) {
$target = '';
$active = '';
$navurl = '#';
if (isset($element['url']) && trim($element['url']) != '') {
// append sid only to local
if (! preg_match('/^https?\:\/\//', $element['url']) && (isset($userinfo['hash']) && $userinfo['hash'] != '')) {
// generate sid with ? oder &
if (strpos($element['url'], '?') !== false) {
$element['url'] .= '&s=' . $userinfo['hash'];
} else {
$element['url'] .= '?s=' . $userinfo['hash'];
}
}
if (isset($element['new_window']) && $element['new_window'] == true) {
$target = ' target="_blank"';
}
if (isset($_GET['page']) && substr_count($element['url'], "page=" . $_GET['page']) > 0 && substr_count($element['url'], basename($_SERVER["SCRIPT_FILENAME"])) > 0 && isset($_GET['action']) && substr_count($element['url'], "action=" . $_GET['action']) > 0) {
$active = ' active';
} elseif (isset($_GET['page']) && substr_count($element['url'], "page=" . $_GET['page']) > 0 && substr_count($element['url'], basename($_SERVER["SCRIPT_FILENAME"])) > 0 && substr_count($element['url'], "action=") == 0 && ! isset($_GET['action'])) {
$active = ' active';
}
$navurl = htmlspecialchars($element['url']);
$navlabel = $element['label'];
} else {
$navlabel = $element['label'];
}
eval("\$navigation_links .= \"" . \Froxlor\UI\Template::getTemplate("navigation_link", 1) . "\";");
}
}
if ($navigation_links != '') {
$target = '';
if (isset($box['url']) && trim($box['url']) != '') {
// append sid only to local
if (! preg_match('/^https?\:\/\//', $box['url']) && (isset($userinfo['hash']) && $userinfo['hash'] != '')) {
// generate sid with ? oder &
if (strpos($box['url'], '?') !== false) {
$box['url'] .= '&s=' . $userinfo['hash'];
} else {
$box['url'] .= '?s=' . $userinfo['hash'];
}
}
if (isset($box['new_window']) && $box['new_window'] == true) {
$target = ' target="_blank"';
}
$navurl = htmlspecialchars($box['url']);
$navlabel = $box['label'];
} else {
$navurl = "#";
$navlabel = $box['label'];
}
eval("\$returnvalue .= \"" . \Froxlor\UI\Template::getTemplate("navigation_element", 1) . "\";");
}
}
}
return $returnvalue;
}

View File

@@ -1,48 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
/**
* Returns full style user details "Name, Firstname | Company"
*
* @param
* array An array with keys firstname, name and company
* @return string The full details
*
* @author Florian Lippert <flo@syscp.org>
*/
function getCorrectFullUserDetails($userinfo)
{
$returnval = '';
if (isset($userinfo['firstname']) && isset($userinfo['name']) && isset($userinfo['company'])) {
if ($userinfo['company'] == '') {
$returnval = $userinfo['name'] . ', ' . $userinfo['firstname'];
} else {
if ($userinfo['name'] != '' && $userinfo['firstname'] != '') {
$returnval = $userinfo['name'] . ', ' . $userinfo['firstname'] . ' | ' . $userinfo['company'];
} else {
$returnval = $userinfo['company'];
}
}
} elseif (isset($userinfo['name'])) {
$returnval = $userinfo['name'];
}
return $returnval;
}

View File

@@ -1,44 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
/**
* Returns correct user salutation, either "Firstname Name" or "Company"
*
* @param
* array An array with keys firstname, name and company
* @return string The correct salutation
*
* @author Florian Lippert <flo@syscp.org>
*/
function getCorrectUserSalutation($userinfo)
{
$returnval = '';
if (isset($userinfo['firstname']) && isset($userinfo['name']) && isset($userinfo['company'])) {
// Always prefer firstname name
if ($userinfo['company'] != '' && $userinfo['name'] == '' && $userinfo['firstname'] == '') {
$returnval = $userinfo['company'];
} else {
$returnval = $userinfo['firstname'] . ' ' . $userinfo['name'];
}
}
return $returnval;
}

View File

@@ -1,38 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
/**
* Returns a double of the given value which isn't negative.
* Returns -1 if the given value was -1.
*
* @param
* any The value
* @return double The positive value
* @author Florian Lippert <flo@syscp.org>
*/
function doubleval_ressource($the_value)
{
$the_value = doubleval($the_value);
if ($the_value < 0 && $the_value != '-1') {
$the_value *= - 1;
}
return $the_value;
}

View File

@@ -1,63 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
/**
* Wrapper around html_entity_decode to handle arrays, with the advantage that you
* can select which fields should be handled by htmlentities and with advantage,
* that you can eliminate all html entities by setting complete=true
*
* @param
* array The subject array
* @param
* string The fields which should be checked for, separated by spaces
* @param
* bool Select true to use html_entity_decode_complete instead of html_entity_decode
* @param
* int See php documentation about this
* @param
* string See php documentation about this
* @return array The array with html_entity_decode'd strings
* @author Florian Lippert <flo@syscp.org>
*/
function html_entity_decode_array($subject, $fields = '', $complete = false, $quote_style = ENT_COMPAT, $charset = 'UTF-8')
{
if (is_array($subject)) {
if (! is_array($fields)) {
$fields = array_trim(explode(' ', $fields));
}
foreach ($subject as $field => $value) {
if ((! is_array($fields) || empty($fields)) || (is_array($fields) && ! empty($fields) && in_array($field, $fields))) {
/**
* Just call ourselve to manage multi-dimensional arrays
*/
$subject[$field] = html_entity_decode_array($subject[$field], $fields, $complete, $quote_style, $charset);
}
}
} else {
if ($complete == true) {
$subject = html_entity_decode_complete($subject, $quote_style, $charset);
} else {
$subject = html_entity_decode($subject, $quote_style, $charset);
}
}
return $subject;
}

View File

@@ -1,43 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
/**
* Calls html_entity_decode in a loop until the result doesn't differ from original anymore
*
* @param
* string The string in which the html entities should be eliminated.
* @return string The cleaned string
* @author Florian Lippert <flo@syscp.org>
*/
function html_entity_decode_complete($string)
{
global $theme;
if ($theme == 'Classic') {
while ($string != html_entity_decode($string)) {
$string = html_entity_decode($string);
}
} else {
while ($string != html_entity_decode($string, ENT_COMPAT | ENT_HTML5, 'UTF-8')) {
$string = html_entity_decode($string, ENT_COMPAT | ENT_HTML5, 'UTF-8');
}
}
return $string;
}

View File

@@ -1,56 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
/**
* Wrapper around htmlentities to handle arrays, with the advantage that you
* can select which fields should be handled by htmlentities
*
* @param
* array The subject array
* @param
* string The fields which should be checked for, separated by spaces
* @param
* int See php documentation about this
* @param
* string See php documentation about this
* @return array The array with htmlentitie'd strings
* @author Florian Lippert <flo@syscp.org>
*/
function htmlentities_array($subject, $fields = '', $quote_style = ENT_QUOTES, $charset = 'UTF-8')
{
if (is_array($subject)) {
if (! is_array($fields)) {
$fields = array_trim(explode(' ', $fields));
}
foreach ($subject as $field => $value) {
if ((! is_array($fields) || empty($fields)) || (is_array($fields) && ! empty($fields) && in_array($field, $fields))) {
/**
* Just call ourselve to manage multi-dimensional arrays
*/
$subject[$field] = htmlentities_array($subject[$field], $fields, $quote_style, $charset);
}
}
} else {
$subject = htmlentities($subject, $quote_style, $charset);
}
return $subject;
}

View File

@@ -1,49 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
/**
* Replaces Strings in an array, with the advantage that you
* can select which fields should be str_replace'd
*
* @param
* mixed String or array of strings to search for
* @param
* mixed String or array to replace with
* @param
* array The subject array
* @param
* string The fields which should be checked for, separated by spaces
* @return array The str_replace'd array
* @author Florian Lippert <flo@syscp.org>
*/
function str_replace_array($search, $replace, $subject, $fields = '')
{
if (is_array($subject)) {
$fields = array_trim(explode(' ', $fields));
foreach ($subject as $field => $value) {
if ((! is_array($fields) || empty($fields)) || (is_array($fields) && ! empty($fields) && in_array($field, $fields))) {
$subject[$field] = str_replace($search, $replace, $subject[$field]);
}
}
} else {
$subject = str_replace($search, $replace, $subject);
}
return $subject;
}

View File

@@ -1,63 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
/**
* Wrapper around stripslashes to handle arrays, with the advantage that you
* can select which fields should be handled by htmlentities and with advantage,
* that you can eliminate all slashes by setting complete=true
*
* @param
* array The subject array
* @param
* int See php documentation about this
* @param
* string See php documentation about this
* @param
* string The fields which should be checked for, separated by spaces
* @param
* bool Select true to use stripslashes_complete instead of stripslashes
* @return array The array with stripslashe'd strings
* @author Florian Lippert <flo@syscp.org>
*/
function stripslashes_array($subject, $fields = '', $complete = false)
{
if (is_array($subject)) {
if (! is_array($fields)) {
$fields = array_trim(explode(' ', $fields));
}
foreach ($subject as $field => $value) {
if ((! is_array($fields) || empty($fields)) || (is_array($fields) && ! empty($fields) && in_array($field, $fields))) {
/**
* Just call ourselve to manage multi-dimensional arrays
*/
$subject[$field] = stripslashes_array($subject[$field], $fields, $complete);
}
}
} else {
if ($complete == true) {
$subject = stripslashes_complete($subject);
} else {
$subject = stripslashes($subject);
}
}
return $subject;
}

View File

@@ -1,35 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
/**
* Calls stripslashes in a loop until the result doesn't differ from original anymore
*
* @param
* string The string in which the slashes should be eliminated.
* @return string The cleaned string
* @author Florian Lippert <flo@syscp.org>
*/
function stripslashes_complete($string)
{
while ($string != stripslashes($string)) {
$string = stripslashes($string);
}
return $string;
}

View File

@@ -1,40 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
/**
* Create a valid from/to - mailheader (remove carriage-returns)
*
* @param
* string The name of the recipient
* @param
* string The mailaddress
* @return string A valid header-entry
* @author Florian Aders <eleras@syscp.org>
*/
function buildValidMailFrom($name, $mailaddress)
{
$mailfrom = str_replace(array(
"\r",
"\n"
), '', $name) . ' <' . str_replace(array(
"\r",
"\n"
), '', $mailaddress) . '>';
return $mailfrom;
}

View File

@@ -110,7 +110,10 @@ if (! isset($sql) || ! is_array($sql)) {
* Includes the Functions
*/
require \Froxlor\Froxlor::getInstallDir() . '/lib/functions.php';
@set_error_handler('phpErrHandler');
@set_error_handler(array(
'\\Froxlor\\PhpHelper',
'phpErrHandler'
));
/**
* Includes the MySQL-Tabledefinitions etc.
@@ -416,10 +419,10 @@ if (AREA == 'admin' || AREA == 'customer') {
)
)
);
$navigation = buildNavigation($navigation_data['admin'], $userinfo);
$navigation = \Froxlor\UI\HTML::buildNavigation($navigation_data['admin'], $userinfo);
} else {
$navigation_data = loadConfigArrayDir('lib/navigation/');
$navigation = buildNavigation($navigation_data[AREA], $userinfo);
$navigation_data = \Froxlor\PhpHelper::loadConfigArrayDir('lib/navigation/');
$navigation = \Froxlor\UI\HTML::buildNavigation($navigation_data[AREA], $userinfo);
}
unset($navigation_data);
}