Skip to content

Commit b401c4c

Browse files
committed
Changes due to dependency of old system.
Minor bug in /web/add/user/index.php as we can't translate emaill in "user" language instead of admin
1 parent 02f6776 commit b401c4c

File tree

9 files changed

+16
-70
lines changed

9 files changed

+16
-70
lines changed

bin/v-change-sys-language

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ source $HESTIA/conf/hestia.conf
1919

2020

2121
is_language_valid() {
22-
if [ ! -e "$HESTIA/web/inc/i18n/$language.php" ]; then
22+
if [ ! -d "$HESTIA/web/locale/$language" ]; then
2323
echo "Error: language file $language doesn't exist"
2424
log_event "$E_NOTEXIST $ARGUMENTS"
2525
exit $E_NOTEXIST

web/add/user/index.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,17 @@
8181
// Send email to the new user
8282
if ((empty($_SESSION['error_msg'])) && (!empty($v_notify))) {
8383
$to = $_POST['v_notify'];
84-
$subject = _translate($_POST['v_language'],"Welcome to Hestia Control Panel");
84+
$subject = _("Welcome to Hestia Control Panel"); //currently not supported to use the account language
8585
$hostname = exec('hostname');
8686
unset($output);
87-
$from = _translate($_POST['v_language'],'MAIL_FROM',$hostname);
87+
$from = _('MAIL_FROM',$hostname); //currently not supported to use the account language
8888

8989
if (!empty($_POST['v_name'])) {
90-
$mailtext = _translate($_POST['v_language'],'GREETINGS_GORDON',$_POST['v_name']);
90+
$mailtext = _('GREETINGS_GORDON',$_POST['v_name']);
9191
} else {
92-
$mailtext = _translate($_POST['v_language'],'GREETINGS');
92+
$mailtext = _('GREETINGS');
9393
}
94-
$mailtext .= _translate($_POST['v_language'],'ACCOUNT_READY',$_SERVER['HTTP_HOST'],$_POST['v_username'],$_POST['v_password']);
94+
$mailtext .= _($_POST['v_language'],'ACCOUNT_READY',$_SERVER['HTTP_HOST'],$_POST['v_username'],$_POST['v_password']);
9595
send_email($to, $subject, $mailtext, $from);
9696
}
9797

web/inc/i18n.php

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,23 @@
11
<?php
22
// Functions for internationalization
33
// I18N support information here
4-
$language = 'nl_NL';
54

6-
putenv("LANGUAGE=$language");
5+
putenv("LANGUAGE=".$_SESSION['language']);
76
setlocale( LC_ALL, 'C.UTF-8' );
87

9-
$domain = 'messages';
8+
$domain = 'hestiacp';
109
$localedir = '/usr/local/hestia/web/locale';
1110
bindtextdomain($domain, $localedir);
1211
textdomain($domain);
1312

1413

15-
16-
/**
17-
* Translates string to given language in first parameter, key given in second parameter (dynamically loads required language). Works like spritf from second parameter
18-
* @global array $LANG Associative array of language pharses
19-
* @return string Translated string
20-
*/
21-
function _translate() {
22-
23-
}
24-
25-
/**
26-
* Translates string by a given key in first parameter to current session language. Works like sprintf
27-
* @global array $LANG Associative array of language pharses
28-
* @return string Translated string
29-
* @see _translate()
30-
*/
31-
32-
3314
/**
3415
* Detects user language from Accept-Language HTTP header.
3516
* @param string Fallback language (default: 'en')
3617
* @return string Language code (such as 'en' and 'ja')
3718
*/
38-
function detect_user_language($fallback='en') {
39-
19+
function detect_user_language($fallback='en_US') {
20+
4021
}
4122

4223
/**

web/inc/mail-wrapper.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
if (!empty( $data['config']['LANGUAGE'])) {
2424
$_SESSION['language'] = $data['config']['LANGUAGE'];
2525
} else {
26-
$_SESSION['language'] = 'en';
26+
$_SESSION['language'] = 'en_US';
2727
}
28-
require_once('/usr/local/hestia/web/inc/i18n/'.$_SESSION['language'].'.php');
2928

3029
// Define vars
3130
$from = 'Hestia Control Panel <hestia@'.gethostname().'>';

web/inc/main.php

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88

99
$i = 0;
1010

11-
require_once(dirname(__FILE__).'/i18n.php');
12-
13-
1411
// Saving user IPs to the session for preventing session hijacking
1512
$user_combined_ip = $_SERVER['REMOTE_ADDR'];
1613

@@ -47,6 +44,8 @@
4744
header("Location: /login/");
4845
exit;
4946
}
47+
// Load Hestia Config directly
48+
load_hestia_config();
5049

5150
// Check system settings
5251
if ((!isset($_SESSION['VERSION'])) && (!defined('NO_AUTH_REQUIRED'))) {
@@ -72,37 +71,15 @@
7271
}
7372
}
7473

75-
if (isset($_SESSION['language'])) {
76-
switch ($_SESSION['language']) {
77-
case 'ro':
78-
setlocale(LC_ALL, 'ro_RO.utf8');
79-
break;
80-
case 'ru':
81-
setlocale(LC_ALL, 'ru_RU.utf8');
82-
break;
83-
case 'ua':
84-
setlocale(LC_ALL, 'uk_UA.utf8');
85-
break;
86-
case 'es':
87-
setlocale(LC_ALL, 'es_ES.utf8');
88-
break;
89-
case 'ja':
90-
setlocale(LC_ALL, 'ja_JP.utf8');
91-
break;
92-
default:
93-
setlocale(LC_ALL, 'en_US.utf8');
94-
}
95-
}
96-
9774
if (isset($_SESSION['user'])) {
9875
$user = $_SESSION['user'];
99-
load_hestia_config();
10076
}
10177

10278
if (isset($_SESSION['look']) && ( $_SESSION['look'] != 'admin' )) {
10379
$user = $_SESSION['look'];
10480
}
10581

82+
require_once(dirname(__FILE__).'/i18n.php');
10683

10784
function check_error($return_var) {
10885
if ( $return_var > 0 ) {

web/js/i18n.js.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
session_start();
44

55
require_once($_SERVER['DOCUMENT_ROOT'].'/inc/i18n.php');
6-
7-
if (empty($_SESSION['language'])) {
8-
//$_SESSION['language'] = detect_user_language();
9-
}
106
?>
117

128
App.i18n.ARE_YOU_SURE = '<?=_('Are you sure?')?>';

web/login/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,13 @@ function authenticate_user(){
170170
$_SESSION['language'] = $lang;
171171
}
172172
else {
173-
$_SESSION['language'] = 'en';
173+
$_SESSION['language'] = 'en_US';
174174
}
175175
}
176176

177177
// Generate CSRF token
178178
$_SESSION['token'] = md5(uniqid(mt_rand(), true));
179-
require_once($_SERVER['DOCUMENT_ROOT'].'/inc/i18n/'.$_SESSION['language'].'.php');
179+
180180
require_once('../templates/header.html');
181181
if (empty($_POST['user'])) {
182182
require_once('../templates/login.html');

web/reset/index.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@
9494
}
9595
}
9696

97-
// Detect language
98-
if (empty($_SESSION['language'])) $_SESSION['language'] = detect_user_language();
99-
10097
if (empty($_GET['action'])) {
10198
require_once '../templates/header.html';
10299
require_once '../templates/reset_1.html';

web/reset2fa/index.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
// Main include
1111
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
1212

13-
// Detect language
14-
if (empty($_SESSION['language'])){
15-
$_SESSION['language'] = detect_user_language();
16-
}
1713
//Check values
1814
if(!empty($_POST['user']) && !empty($_POST['twofa'])){
1915
$error = true;

0 commit comments

Comments
 (0)