Revert "refactor global array"

This reverts commit 370ccbdb74.
This commit is contained in:
Michael Kaufmann
2018-12-22 08:15:31 +01:00
parent c800e89414
commit 7e39a7bc60
220 changed files with 2244 additions and 2227 deletions

View File

@@ -135,6 +135,8 @@ abstract class ApiCommand extends ApiParameter
*/
private function initLang()
{
global $lng;
// query the whole table
$result_stmt = \Froxlor\Database\Database::query("SELECT * FROM `" . TABLE_PANEL_LANGUAGE . "`");
@@ -177,7 +179,7 @@ abstract class ApiCommand extends ApiParameter
include_once \Froxlor\FileDir::makeSecurePath(\Froxlor\Froxlor::getInstallDir() . '/lng/lng_references.php');
// set array for ApiCommand
$this->lng = \Froxlor\I18N\Lang::getAll();
$this->lng = $lng;
}
/**

View File

@@ -424,12 +424,13 @@ class ConfigDaemon
if (preg_match('/^settings\.(.*)$/', $matches[1], $match)) {
return \Froxlor\Settings::Get($match[1]);
} elseif (preg_match('/^lng\.(.*)(?:\.(.*)(?:\.(.*)))$/U', $matches[1], $match)) {
global $lng;
if (isset($match[1]) && $match[1] != '' && isset($match[2]) && $match[2] != '' && isset($match[3]) && $match[3] != '') {
return \Froxlor\I18N\Lang::getAll()[$match[1]][$match[2]][$match[3]];
return $lng[$match[1]][$match[2]][$match[3]];
} elseif (isset($match[1]) && $match[1] != '' && isset($match[2]) && $match[2] != '') {
return \Froxlor\I18N\Lang::getAll()[$match[1]][$match[2]];
return $lng[$match[1]][$match[2]];
} elseif (isset($match[1]) && $match[1] != '') {
return \Froxlor\I18N\Lang::getAll()[$match[1]];
return $lng[$match[1]];
}
return '';
} elseif (preg_match('/^const\.(.*)$/', $matches[1], $match)) {

View File

@@ -137,12 +137,13 @@ class ConfigService
if (preg_match('/^settings\.(.*)$/', $matches[1], $match)) {
return \Froxlor\Settings::Get($match[1]);
} elseif (preg_match('/^lng\.(.*)(?:\.(.*)(?:\.(.*)))$/U', $matches[1], $match)) {
global $lng;
if (isset($match[1]) && $match[1] != '' && isset($match[2]) && $match[2] != '' && isset($match[3]) && $match[3] != '') {
return \Froxlor\I18N\Lang::getAll()[$match[1]][$match[2]][$match[3]];
return $lng[$match[1]][$match[2]][$match[3]];
} elseif (isset($match[1]) && $match[1] != '' && isset($match[2]) && $match[2] != '') {
return \Froxlor\I18N\Lang::getAll()[$match[1]][$match[2]];
return $lng[$match[1]][$match[2]];
} elseif (isset($match[1]) && $match[1] != '') {
return \Froxlor\I18N\Lang::getAll()[$match[1]];
return $lng[$match[1]];
}
return '';
}

View File

@@ -106,11 +106,11 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron
'varname' => 'trafficmaxpercent_subject'
);
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_subject = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : \Froxlor\I18N\Lang::getAll()['mails']['trafficmaxpercent']['subject']), $replace_arr));
$mail_subject = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject']), $replace_arr));
$result2_data['varname'] = 'trafficmaxpercent_mailbody';
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_body = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : \Froxlor\I18N\Lang::getAll()['mails']['trafficmaxpercent']['mailbody']), $replace_arr));
$mail_body = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['mailbody']), $replace_arr));
$_mailerror = false;
$mailerr_msg = "";
@@ -208,11 +208,11 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron
'varname' => 'trafficmaxpercent_subject'
);
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_subject = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : \Froxlor\I18N\Lang::getAll()['mails']['trafficmaxpercent']['subject']), $replace_arr));
$mail_subject = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject']), $replace_arr));
$resul2_data['varname'] = 'trafficmaxpercent_mailbody';
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_body = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : \Froxlor\I18N\Lang::getAll()['mails']['trafficmaxpercent']['mailbody']), $replace_arr));
$mail_body = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['mailbody']), $replace_arr));
$_mailerror = false;
$mailerr_msg = "";
@@ -405,11 +405,11 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron
'varname' => 'diskmaxpercent_subject'
);
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_subject = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : \Froxlor\I18N\Lang::getAll()['mails']['diskmaxpercent']['subject']), $replace_arr));
$mail_subject = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['subject']), $replace_arr));
$result2_data['varname'] = 'diskmaxpercent_mailbody';
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_body = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : \Froxlor\I18N\Lang::getAll()['mails']['diskmaxpercent']['mailbody']), $replace_arr));
$mail_body = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['mailbody']), $replace_arr));
$_mailerror = false;
$mailerr_msg = "";
@@ -498,11 +498,11 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron
'varname' => 'diskmaxpercent_subject'
);
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_subject = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : \Froxlor\I18N\Lang::getAll()['mails']['diskmaxpercent']['subject']), $replace_arr));
$mail_subject = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['subject']), $replace_arr));
$result2_data['varname'] = 'diskmaxpercent_mailbody';
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_body = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : \Froxlor\I18N\Lang::getAll()['mails']['diskmaxpercent']['mailbody']), $replace_arr));
$mail_body = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['mailbody']), $replace_arr));
$_mailerror = false;
$mailerr_msg = "";

View File

@@ -35,6 +35,8 @@ class Domain
*/
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);
@@ -42,7 +44,7 @@ class Domain
while ($rc = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
$codes[$rc['id']] = $rc['code'];
if ($add_desc) {
$codes[$rc['id']] .= ' (' . \Froxlor\I18N\Lang::getAll()['redirect_desc'][$rc['desc']] . ')';
$codes[$rc['id']] .= ' (' . $lng['redirect_desc'][$rc['desc']] . ')';
}
}
@@ -330,4 +332,4 @@ class Domain
}
return '';
}
}
}

View File

@@ -73,8 +73,9 @@ class IpAddr
public static function getSslIpPortCombinations()
{
global $lng;
return array(
'' => \Froxlor\I18N\Lang::getAll()['panel']['none_value']
'' => $lng['panel']['none_value']
) + self::getIpPortCombinations(true);
}
}
}

View File

@@ -381,6 +381,8 @@ class FileDir
*/
public static function makePathfield($path, $uid, $gid, $value = '', $dom = false)
{
global $lng;
$value = str_replace($path, '', $value);
$field = array();
@@ -427,20 +429,20 @@ class FileDir
// remove starting slash we added
// for the Dropdown, #225
$value = substr($value, 1);
// $field = \Froxlor\I18N\Lang::getAll()['panel']['toomanydirs'];
// $field = $lng['panel']['toomanydirs'];
$field = array(
'type' => 'text',
'value' => htmlspecialchars($value),
'note' => \Froxlor\I18N\Lang::getAll()['panel']['toomanydirs']
'note' => $lng['panel']['toomanydirs']
);
}
} else {
// $field = \Froxlor\I18N\Lang::getAll()['panel']['dirsmissing'];
// $field = $lng['panel']['dirsmissing'];
// $field = '<input type="hidden" name="path" value="/" />';
$field = array(
'type' => 'hidden',
'value' => '/',
'note' => \Froxlor\I18N\Lang::getAll()['panel']['dirsmissing']
'note' => $lng['panel']['dirsmissing']
);
}
}

View File

@@ -117,7 +117,7 @@ class PhpHelper
public static function loadConfigArrayDir()
{
// Workaround until we use gettext
global $theme;
global $lng, $theme;
// we now use dynamic function parameters
// so we can read from more than one directory

View File

@@ -188,18 +188,20 @@ class Cronjob
public static function getCronjobsLastRun()
{
global $lng;
$query = "SELECT `lastrun`, `desc_lng_key` FROM `" . TABLE_PANEL_CRONRUNS . "` WHERE `isactive` = '1' ORDER BY `cronfile` ASC";
$result = Database::query($query);
$cronjobs_last_run = '';
while ($row = $result->fetch(\PDO::FETCH_ASSOC)) {
$lastrun = \Froxlor\I18N\Lang::getAll()['cronjobs']['notyetrun'];
$lastrun = $lng['cronjobs']['notyetrun'];
if ($row['lastrun'] > 0) {
$lastrun = date('d.m.Y H:i:s', $row['lastrun']);
}
$text = \Froxlor\I18N\Lang::getAll()['crondesc'][$row['desc_lng_key']];
$text = $lng['crondesc'][$row['desc_lng_key']];
$value = $lastrun;
eval("\$cronjobs_last_run .= \"" . \Froxlor\UI\Template::getTemplate("index/overview_item") . "\";");
@@ -224,6 +226,8 @@ class Cronjob
public static function getOutstandingTasks()
{
global $lng;
$query = "SELECT * FROM `" . TABLE_PANEL_TASKS . "` ORDER BY `type` ASC";
$result = Database::query($query);
@@ -237,49 +241,49 @@ class Cronjob
// rebuilding webserver-configuration
if ($row['type'] == '1') {
$task_desc = \Froxlor\I18N\Lang::getAll()['tasks']['rebuild_webserverconfig'];
$task_desc = $lng['tasks']['rebuild_webserverconfig'];
} // adding new user/
elseif ($row['type'] == '2') {
$loginname = '';
if (is_array($row['data'])) {
$loginname = $row['data']['loginname'];
}
$task_desc = \Froxlor\I18N\Lang::getAll()['tasks']['adding_customer'];
$task_desc = $lng['tasks']['adding_customer'];
$task_desc = str_replace('%loginname%', $loginname, $task_desc);
} // rebuilding bind-configuration
elseif ($row['type'] == '4') {
$task_desc = \Froxlor\I18N\Lang::getAll()['tasks']['rebuild_bindconfig'];
$task_desc = $lng['tasks']['rebuild_bindconfig'];
} // creating ftp-user directory
elseif ($row['type'] == '5') {
$task_desc = \Froxlor\I18N\Lang::getAll()['tasks']['creating_ftpdir'];
$task_desc = $lng['tasks']['creating_ftpdir'];
} // deleting user-files
elseif ($row['type'] == '6') {
$loginname = '';
if (is_array($row['data'])) {
$loginname = $row['data']['loginname'];
}
$task_desc = \Froxlor\I18N\Lang::getAll()['tasks']['deleting_customerfiles'];
$task_desc = $lng['tasks']['deleting_customerfiles'];
$task_desc = str_replace('%loginname%', $loginname, $task_desc);
} // deleting email-account
elseif ($row['type'] == '7') {
$task_desc = \Froxlor\I18N\Lang::getAll()['tasks']['remove_emailacc_files'];
$task_desc = $lng['tasks']['remove_emailacc_files'];
} // deleting ftp-account
elseif ($row['type'] == '8') {
$task_desc = \Froxlor\I18N\Lang::getAll()['tasks']['remove_ftpacc_files'];
$task_desc = $lng['tasks']['remove_ftpacc_files'];
} // Set FS - quota
elseif ($row['type'] == '10') {
$task_desc = \Froxlor\I18N\Lang::getAll()['tasks']['diskspace_set_quota'];
$task_desc = $lng['tasks']['diskspace_set_quota'];
} // deleting user-files
elseif ($row['type'] == '20') {
$loginname = '';
if (is_array($row['data'])) {
$loginname = $row['data']['loginname'];
}
$task_desc = \Froxlor\I18N\Lang::getAll()['tasks']['backup_customerfiles'];
$task_desc = $lng['tasks']['backup_customerfiles'];
$task_desc = str_replace('%loginname%', $loginname, $task_desc);
} // re-generating of cron.d-file
elseif ($row['type'] == '99') {
$task_desc = \Froxlor\I18N\Lang::getAll()['tasks']['regenerating_crond'];
$task_desc = $lng['tasks']['regenerating_crond'];
} // unknown
else {
$task_desc = "ERROR: Unknown task type '" . $row['type'] . "'";
@@ -291,13 +295,13 @@ class Cronjob
}
if (trim($tasks) == '') {
$value .= '<li>' . \Froxlor\I18N\Lang::getAll()['tasks']['noneoutstanding'] . '</li>';
$value .= '<li>' . $lng['tasks']['noneoutstanding'] . '</li>';
} else {
$value .= $tasks;
}
$value .= '</ul>';
$text = \Froxlor\I18N\Lang::getAll()['tasks']['outstanding_tasks'];
$text = $lng['tasks']['outstanding_tasks'];
eval("\$outstanding_tasks = \"" . \Froxlor\UI\Template::getTemplate("index/overview_item") . "\";");
return $outstanding_tasks;
@@ -342,4 +346,4 @@ class Cronjob
die($message);
}
}
}

View File

@@ -116,9 +116,11 @@ class Crypt
*/
public static function getAvailablePasswordHashes()
{
global $lng;
// get available pwd-hases
$available_pwdhashes = array(
0 => \Froxlor\I18N\Lang::getAll()['serversettings']['systemdefault']
0 => $lng['serversettings']['systemdefault']
);
if (defined('CRYPT_MD5') && CRYPT_MD5 == 1) {
$available_pwdhashes[1] = 'MD5';

View File

@@ -217,7 +217,7 @@ class HTML
*/
public static function makeyesno($name, $yesvalue, $novalue = '', $yesselected = '', $disabled = false)
{
global $theme;
global $lng, $theme;
if ($disabled) {
$d = ' disabled="disabled"';
@@ -230,7 +230,7 @@ class HTML
}
return '<select class="dropdown_noborder" id="' . $name . '" name="' . $name . '"' . $d . '>
<option value="' . $yesvalue . '"' . ($yesselected ? ' selected="selected"' : '') . '>' . \Froxlor\I18N\Lang::getAll()['panel']['yes'] . '</option><option value="' . $novalue . '"' . ($yesselected ? '' : ' selected="selected"') . '>' . \Froxlor\I18N\Lang::getAll()['panel']['no'] . '</option></select>';
<option value="' . $yesvalue . '"' . ($yesselected ? ' selected="selected"' : '') . '>' . $lng['panel']['yes'] . '</option><option value="' . $novalue . '"' . ($yesselected ? '' : ' selected="selected"') . '>' . $lng['panel']['no'] . '</option></select>';
}
/**
@@ -264,8 +264,8 @@ class HTML
}
}
if (isset(\Froxlor\I18N\Lang::getAll()['question'][$text])) {
$text = \Froxlor\I18N\Lang::getAll()['question'][$text];
if (isset($lng['question'][$text])) {
$text = $lng['question'][$text];
}
$text = strtr($text, array(
@@ -287,12 +287,12 @@ class HTML
}
}
if (isset(\Froxlor\I18N\Lang::getAll()['question'][$text])) {
$text = \Froxlor\I18N\Lang::getAll()['question'][$text];
if (isset($lng['question'][$text])) {
$text = $lng['question'][$text];
}
if (isset(\Froxlor\I18N\Lang::getAll()['question'][$chk_text])) {
$chk_text = \Froxlor\I18N\Lang::getAll()['question'][$chk_text];
if (isset($lng['question'][$chk_text])) {
$chk_text = $lng['question'][$chk_text];
}
if ($show_checkbox) {
@@ -308,4 +308,4 @@ class HTML
eval("echo \"" . Template::getTemplate('misc/question_yesno_checkbox', '1') . "\";");
exit();
}
}
}

View File

@@ -29,7 +29,7 @@ class HtmlForm
public static function genHTMLForm($data = array())
{
global $theme;
global $lng, $theme;
$nob = false;
self::$_form = '';
@@ -233,7 +233,7 @@ class HtmlForm
*
* <code>
* $data = array(
* 'label' => \Froxlor\I18N\Lang::getAll()['customer']['email_imap'],
* 'label' => $lng['customer']['email_imap'],
* 'type' => 'checkbox',
* 'values' => array(
* array( 'label' => 'active',

View File

@@ -405,8 +405,8 @@ class Paging
$breakorws = ($break ? '<br />' : '&nbsp;');
foreach (array(
'asc' => \Froxlor\I18N\Lang::getAll()['panel']['ascending'],
'desc' => \Froxlor\I18N\Lang::getAll()['panel']['descending']
'asc' => $lng['panel']['ascending'],
'desc' => $lng['panel']['descending']
) as $sortordertype => $sortorderdescription) {
$orderoptions .= HTML::makeoption($sortorderdescription, $sortordertype, $this->sortorder, true, true);
}

View File

@@ -94,13 +94,13 @@ class Response
$link = '';
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']) !== false) {
$link = '<a href="' . htmlentities($_SERVER['HTTP_REFERER']) . '">' . \Froxlor\I18N\Lang::getAll()['panel']['back'] . '</a>';
$link = '<a href="' . htmlentities($_SERVER['HTTP_REFERER']) . '">' . $lng['panel']['back'] . '</a>';
}
$error = '';
foreach ($errors as $single_error) {
if (isset(\Froxlor\I18N\Lang::getAll()['error'][$single_error])) {
$single_error = \Froxlor\I18N\Lang::getAll()['error'][$single_error];
if (isset($lng['error'][$single_error])) {
$single_error = $lng['error'][$single_error];
$single_error = strtr($single_error, array(
'%s' => $replacer
));
@@ -129,7 +129,7 @@ class Response
$_SESSION['requestData'] = $_POST;
$link = '';
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']) !== false) {
$link = '<a href="' . htmlentities($_SERVER['HTTP_REFERER']) . '">' . \Froxlor\I18N\Lang::getAll()['panel']['back'] . '</a>';
$link = '<a href="' . htmlentities($_SERVER['HTTP_REFERER']) . '">' . $lng['panel']['back'] . '</a>';
}
$error = $message;
eval("echo \"" . Template::getTemplate('misc/error', '1') . "\";");
@@ -152,8 +152,8 @@ class Response
{
global $s, $header, $footer, $theme;
if (isset(\Froxlor\I18N\Lang::getAll()['success'][$success_message])) {
$success_message = strtr(\Froxlor\I18N\Lang::getAll()['success'][$success_message], array(
if (isset($lng['success'][$success_message])) {
$success_message = strtr($lng['success'][$success_message], array(
'%s' => htmlentities($replacer)
));
}