commit | author | age
|
b7afde
|
1 |
<?php |
T |
2 |
/* |
|
3 |
Copyright (c) 2008, Till Brehm, projektfarm Gmbh |
|
4 |
All rights reserved. |
|
5 |
|
|
6 |
Redistribution and use in source and binary forms, with or without modification, |
|
7 |
are permitted provided that the following conditions are met: |
|
8 |
|
|
9 |
* Redistributions of source code must retain the above copyright notice, |
|
10 |
this list of conditions and the following disclaimer. |
|
11 |
* Redistributions in binary form must reproduce the above copyright notice, |
|
12 |
this list of conditions and the following disclaimer in the documentation |
|
13 |
and/or other materials provided with the distribution. |
|
14 |
* Neither the name of ISPConfig nor the names of its contributors |
|
15 |
may be used to endorse or promote products derived from this software without |
|
16 |
specific prior written permission. |
|
17 |
|
|
18 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
|
19 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
20 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
21 |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
|
22 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
23 |
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
24 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
25 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
26 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
27 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
28 |
*/ |
|
29 |
|
7fe908
|
30 |
require_once '../../lib/config.inc.php'; |
MC |
31 |
require_once '../../lib/app.inc.php'; |
b7afde
|
32 |
|
910093
|
33 |
//* Check permissions for module |
T |
34 |
$app->auth->check_module_permissions('admin'); |
9edea9
|
35 |
$app->auth->check_security_permissions('admin_allow_langedit'); |
b7afde
|
36 |
|
T |
37 |
//* This is only allowed for administrators |
|
38 |
if(!$app->auth->is_admin()) die('only allowed for administrators.'); |
91624b
|
39 |
if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mode.'); |
b7afde
|
40 |
|
T |
41 |
$app->uses('tpl'); |
|
42 |
|
|
43 |
$app->tpl->newTemplate('form.tpl.htm'); |
|
44 |
$app->tpl->setInclude('content_tpl', 'templates/language_add.htm'); |
|
45 |
|
|
46 |
//* reading languages |
|
47 |
$language_option = ''; |
|
48 |
$error = ''; |
|
49 |
$msg = ''; |
7fe908
|
50 |
$selected_language = (isset($_REQUEST['lng_select']))?substr($_REQUEST['lng_select'], 0, 2):'en'; |
6b55a1
|
51 |
if(!preg_match("/^[a-z]{2}$/i", $selected_language)) die('unallowed characters in selected language name.'); |
T |
52 |
|
7fe908
|
53 |
$handle = opendir(ISPC_ROOT_PATH.'/lib/lang/'); |
MC |
54 |
while ($file = readdir($handle)) { |
|
55 |
if ($file != '.' && $file != '..') { |
|
56 |
$tmp_lng = substr($file, 0, -4); |
b7afde
|
57 |
if($tmp_lng !='') { |
T |
58 |
$selected = ($tmp_lng == $selected_language)?'SELECTED':''; |
|
59 |
$language_option .= "<option value='$tmp_lng' $selected>$tmp_lng</option>"; |
|
60 |
if(isset($_POST['lng_new']) && $_POST['lng_new'] == $tmp_lng) $error = 'Language exists already.'; |
|
61 |
} |
|
62 |
} |
|
63 |
} |
7fe908
|
64 |
$app->tpl->setVar('language_option', $language_option); |
MC |
65 |
$app->tpl->setVar('error', $error); |
b7afde
|
66 |
|
T |
67 |
if(isset($_POST['lng_new']) && strlen($_POST['lng_new']) == 2 && $error == '') { |
5af0cf
|
68 |
|
TB |
69 |
//* CSRF Check |
|
70 |
$app->auth->csrf_token_check(); |
|
71 |
|
b7afde
|
72 |
$lng_new = $_POST['lng_new']; |
T |
73 |
if(!preg_match("/^[a-z]{2}$/i", $lng_new)) die('unallowed characters in language name.'); |
7fe908
|
74 |
|
4cb79a
|
75 |
//* Copy the main language file |
7fe908
|
76 |
copy(ISPC_LIB_PATH."/lang/$selected_language.lng", ISPC_LIB_PATH."/lang/$lng_new.lng"); |
MC |
77 |
|
b7afde
|
78 |
//* Make a copy of every language file |
T |
79 |
$bgcolor = '#FFFFFF'; |
|
80 |
$language_files_list = array(); |
7fe908
|
81 |
$handle = @opendir(ISPC_WEB_PATH); |
MC |
82 |
while ($file = @readdir($handle)) { |
|
83 |
if ($file != '.' && $file != '..') { |
|
84 |
if(@is_dir(ISPC_WEB_PATH.'/'.$file.'/lib/lang')) { |
b7afde
|
85 |
$handle2 = opendir(ISPC_WEB_PATH.'/'.$file.'/lib/lang'); |
7fe908
|
86 |
while ($lang_file = @readdir($handle2)) { |
MC |
87 |
if ($lang_file != '.' && $lang_file != '..' && substr($lang_file, 0, 2) == $selected_language) { |
|
88 |
$new_lang_file = $lng_new.substr($lang_file, 2); |
b7afde
|
89 |
//echo ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$lang_file.' ## '.ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$new_lang_file; |
7fe908
|
90 |
copy(ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$lang_file, ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$new_lang_file); |
b7afde
|
91 |
$msg = 'Added new language '.$lng_new; |
T |
92 |
} |
|
93 |
} |
|
94 |
} |
|
95 |
} |
|
96 |
} |
|
97 |
} |
|
98 |
|
7fe908
|
99 |
$app->tpl->setVar('msg', $msg); |
b7afde
|
100 |
|
5af0cf
|
101 |
//* SET csrf token |
TB |
102 |
$csrf_token = $app->auth->csrf_token_get('language_add'); |
|
103 |
$app->tpl->setVar('_csrf_id',$csrf_token['csrf_id']); |
|
104 |
$app->tpl->setVar('_csrf_key',$csrf_token['csrf_key']); |
|
105 |
|
7fe908
|
106 |
//* load language file |
b7afde
|
107 |
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_language_add.lng'; |
7fe908
|
108 |
include $lng_file; |
b7afde
|
109 |
$app->tpl->setVar($wb); |
T |
110 |
|
|
111 |
$app->tpl_defaults(); |
|
112 |
$app->tpl->pparse(); |
|
113 |
|
|
114 |
|
7fe908
|
115 |
?> |