Revert "refactor global array"

This reverts commit c5a58e3f36.
This commit is contained in:
Michael Kaufmann
2018-12-22 08:15:31 +01:00
parent 7e39a7bc60
commit 0401e6971a
68 changed files with 613 additions and 646 deletions

View File

@@ -124,11 +124,11 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
Database::needSqlData();
$sql_root = Database::getSqlData();
Database::needRoot(false);
\Froxlor\User::getAll() = $customer;
$userinfo = $customer;
$replace_arr = array(
'SALUTATION' => \Froxlor\User::getCorrectUserSalutation(\Froxlor\User::getAll()),
'CUST_NAME' => \Froxlor\User::getCorrectUserSalutation(\Froxlor\User::getAll()), // < 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,
@@ -137,9 +137,9 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
);
// get template for mail subject
$mail_subject = $this->getMailTemplate(\Froxlor\User::getAll(), 'mails', 'new_database_by_customer_subject', $replace_arr, $this->lng['mails']['new_database_by_customer']['subject']);
$mail_subject = $this->getMailTemplate($userinfo, 'mails', 'new_database_by_customer_subject', $replace_arr, $this->lng['mails']['new_database_by_customer']['subject']);
// get template for mail body
$mail_body = $this->getMailTemplate(\Froxlor\User::getAll(), 'mails', 'new_database_by_customer_mailbody', $replace_arr, $this->lng['mails']['new_database_by_customer']['mailbody']);
$mail_body = $this->getMailTemplate($userinfo, 'mails', 'new_database_by_customer_mailbody', $replace_arr, $this->lng['mails']['new_database_by_customer']['mailbody']);
$_mailerror = false;
$mailerr_msg = "";
@@ -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(\Froxlor\User::getAll()['email'], \Froxlor\User::getCorrectUserSalutation(\Froxlor\User::getAll()));
$this->mailer()->addAddress($userinfo['email'], \Froxlor\User::getCorrectUserSalutation($userinfo));
$this->mailer()->send();
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
@@ -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);
\Froxlor\UI\Response::standard_error('errorsendingmail', \Froxlor\User::getAll()['email'], true);
\Froxlor\UI\Response::standard_error('errorsendingmail', $userinfo['email'], true);
}
$this->mailer()->clearAddresses();

View File

@@ -145,6 +145,8 @@ abstract class BulkAction
protected function importEntity($data_array = null)
{
global $userinfo;
$module = '\\Froxlor\\Api\\Commands\\' . substr($this->api_call, 0, strpos($this->api_call, "."));
$function = substr($this->api_call, strpos($this->api_call, ".") + 1);
@@ -157,7 +159,7 @@ abstract class BulkAction
$result = null;
try {
$json_result = $module::getLocal(\Froxlor\User::getAll(), $new_data)->$function();
$json_result = $module::getLocal($userinfo, $new_data)->$function();
$result = json_decode($json_result, true)['data'];
} catch (\Exception $e) {
$this->errors[] = $e->getMessage();

View File

@@ -51,14 +51,17 @@ class DomainBulkAction extends BulkAction
{
$this->preImport();
if (\Froxlor\User::getAll()['domains'] == "-1") {
// get the admins userinfo to check for domains_used, etc.
global $userinfo;
if ($userinfo['domains'] == "-1") {
$dom_unlimited = true;
} else {
$dom_unlimited = false;
}
$domains_used = (int) \Froxlor\User::getAll()['domains_used'];
$domains_avail = (int) \Froxlor\User::getAll()['domains'];
$domains_used = (int) $userinfo['domains_used'];
$domains_avail = (int) $userinfo['domains'];
if (empty($separator) || strlen($separator) != 1) {
throw new \Exception("Invalid separator specified: '" . $separator . "'");

View File

@@ -350,7 +350,7 @@ class Database
*/
private static function _showerror($error, $showerror = true, $json_response = false, \PDOStatement $stmt = null)
{
global $theme;
global $userinfo, $theme, $linker;
// include userdata.inc.php
require \Froxlor\Froxlor::getInstallDir() . "/lib/userdata.inc.php";
@@ -445,7 +445,7 @@ class Database
$err_hint = str_replace("<CURRENT_YEAR>", date('Y', time()), $err_hint);
$err_report_html = '';
if (is_array(\Froxlor\User::getAll()) && ((\Froxlor\User::getAll()['adminsession'] == '1' && \Froxlor\Settings::Get('system.allow_error_report_admin') == '1') || (\Froxlor\User::getAll()['adminsession'] == '0' && \Froxlor\Settings::Get('system.allow_error_report_customer') == '1'))) {
if (is_array($userinfo) && (($userinfo['adminsession'] == '1' && \Froxlor\Settings::Get('system.allow_error_report_admin') == '1') || ($userinfo['adminsession'] == '0' && \Froxlor\Settings::Get('system.allow_error_report_customer') == '1'))) {
$err_report_html = '<a href="<LINK>" title="Click here to report error">Report error</a>';
$err_report_html = str_replace("<LINK>", $linker->getLink(array(
'section' => 'index',

View File

@@ -35,12 +35,13 @@ class IntegrityCheck
*/
public function __construct()
{
if (! isset(\Froxlor\User::getAll()) || ! is_array(\Froxlor\User::getAll())) {
\Froxlor\User::getAll() = array(
global $userinfo;
if (! isset($userinfo) || ! is_array($userinfo)) {
$userinfo = array(
'loginname' => 'integrity-check'
);
}
$this->_log = \Froxlor\FroxlorLogger::getInstanceOf(\Froxlor\User::getAll());
$this->_log = \Froxlor\FroxlorLogger::getInstanceOf($userinfo);
$this->available = get_class_methods($this);
unset($this->available[array_search('__construct', $this->available)]);
unset($this->available[array_search('checkAll', $this->available)]);

View File

@@ -29,14 +29,16 @@ class IpAddr
public static function getIpPortCombinations($ssl = false)
{
global $userinfo;
$additional_conditions_params = array();
$additional_conditions_array = array();
if (\Froxlor\User::getAll()['ip'] != '-1') {
if ($userinfo['ip'] != '-1') {
$admin_ip_stmt = Database::prepare("
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = IN (:ipid)
");
$myips = implode(",", json_decode(\Froxlor\User::getAll()['ip'], true));
$myips = implode(",", json_decode($userinfo['ip'], true));
Database::pexecute($admin_ip_stmt, array(
'ipid' => $myips
));

View File

@@ -1,27 +0,0 @@
<?php
namespace Froxlor\I18N;
class Lang
{
private static $lng = array();
/**
*
* @param array $lng
*/
public static function setLanguageArray($lng = array())
{
self::$lng = $lng;
}
/**
*
* @return array
*/
public static function getAll()
{
return self::$lng;
}
}

View File

@@ -7,10 +7,10 @@ class HTML
/**
* Build Navigation Sidebar
*
* @param array $navigation
* data
* @param array $userinfo
* the userinfo of the user
* @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>
@@ -254,7 +254,7 @@ class HTML
*/
public static function ask_yesno($text, $yesfile, $params = array(), $targetname = '', $back_nr = 1)
{
global $s, $header, $footer;
global $userinfo, $s, $header, $footer, $lng, $theme;
$hiddenparams = '';
@@ -277,7 +277,7 @@ class HTML
public static function ask_yesno_withcheckbox($text, $chk_text, $yesfile, $params = array(), $targetname = '', $show_checkbox = true)
{
global $s, $header, $footer, $theme;
global $userinfo, $s, $header, $footer, $lng, $theme;
$hiddenparams = '';

View File

@@ -26,6 +26,13 @@ namespace Froxlor\UI;
class Paging
{
/**
* Userinfo
*
* @var array
*/
private $userinfo = array();
/**
* MySQL-Table
*
@@ -102,15 +109,16 @@ class Paging
* Class constructor.
* Loads settings from request or from userdata and saves them to session.
*
* @param array $userinfo
* @param string $table
* Name of Table
* @param array $fields
* Fields, in format array( 'fieldname_in_mysql' => 'field_caption' )
* @param int $entriesperpage
* *deprecated* entries per page
* @param bool $natSorting
* *deprecated* Switch natsorting on/off (global, affects all calls of sort)
* @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

View File

@@ -81,7 +81,7 @@ class Response
*/
public static function standard_error($errors = '', $replacer = '', $throw_exception = false)
{
global $s, $header, $footer, $theme;
global $userinfo, $s, $header, $footer, $lng, $theme;
$_SESSION['requestData'] = $_POST;
$replacer = htmlentities($replacer);
@@ -125,7 +125,7 @@ class Response
public static function dynamic_error($message)
{
global $s, $header, $footer, $theme;
global $userinfo, $s, $header, $footer, $lng, $theme;
$_SESSION['requestData'] = $_POST;
$link = '';
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']) !== false) {
@@ -150,7 +150,7 @@ class Response
*/
public static function standard_success($success_message = '', $replacer = '', $params = array(), $throw_exception = false)
{
global $s, $header, $footer, $theme;
global $s, $header, $footer, $lng, $theme;
if (isset($lng['success'][$success_message])) {
$success_message = strtr($lng['success'][$success_message], array(

View File

@@ -6,26 +6,6 @@ use Froxlor\Database\Database;
class User
{
private static $userinfo = array();
/**
*
* @param array $userinfo
*/
public static function setUserinfoArray($userinfo = array())
{
self::$userinfo = $userinfo;
}
/**
*
* @return array
*/
public static function getAll()
{
return self::$userinfo;
}
/**
* Returns full style user details "Name, Firstname | Company"
*