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_edit.htm'); |
|
45 |
|
|
46 |
$lang = $_REQUEST['lang']; |
|
47 |
$module = $_REQUEST['module']; |
|
48 |
$lang_file = $_REQUEST['lang_file']; |
|
49 |
|
|
50 |
if(!preg_match("/^[a-z]+$/i", $lang)) die('unallowed characters in language name.'); |
|
51 |
if(!preg_match("/^[a-z_]+$/i", $module)) die('unallowed characters in module name.'); |
|
52 |
if(!preg_match("/^[a-z\._]+$/i", $lang_file)) die('unallowed characters in language file name.'); |
|
53 |
|
|
54 |
$msg = ''; |
|
55 |
|
|
56 |
//* Save data |
|
57 |
if(isset($_POST['records']) && is_array($_POST['records'])) { |
5af0cf
|
58 |
|
TB |
59 |
//* CSRF Check |
|
60 |
$app->auth->csrf_token_check(); |
|
61 |
|
b7afde
|
62 |
$file_content = "<?php\n"; |
T |
63 |
foreach($_POST['records'] as $key => $val) { |
|
64 |
$val = stripslashes($val); |
b1ed92
|
65 |
$val = preg_replace('/(^|[^\\\\])((\\\\\\\\)*)"/', '$1$2\\"', $val); |
7fe908
|
66 |
$val = str_replace('$', '', $val); |
df7e6d
|
67 |
$file_content .= '$wb['."'$key'".'] = "'.$val.'";'."\n"; |
b7afde
|
68 |
$msg = 'File saved.'; |
T |
69 |
} |
|
70 |
$file_content .= "?>\n"; |
6b55a1
|
71 |
if($module == 'global') { |
7fe908
|
72 |
file_put_contents(ISPC_LIB_PATH."/lang/$lang_file" , $file_content); |
6b55a1
|
73 |
} else { |
7fe908
|
74 |
file_put_contents(ISPC_WEB_PATH."/$module/lib/lang/$lang_file" , $file_content); |
6b55a1
|
75 |
} |
b7afde
|
76 |
} |
T |
77 |
|
|
78 |
|
7fe908
|
79 |
$app->tpl->setVar(array('module' => $module, 'lang_file' => $lang_file, 'lang' => $lang, 'msg' => $msg)); |
b7afde
|
80 |
|
6b55a1
|
81 |
if($module == 'global') { |
7fe908
|
82 |
include ISPC_LIB_PATH."/lang/$lang_file"; |
bb2057
|
83 |
$file_path = ISPC_LIB_PATH."/lang/$lang_file"; |
6b55a1
|
84 |
} else { |
7fe908
|
85 |
include ISPC_WEB_PATH."/$module/lib/lang/$lang_file"; |
73d9dd
|
86 |
$file_path = ISPC_WEB_PATH."/$module/lib/lang/$lang_file"; |
6b55a1
|
87 |
} |
bb2057
|
88 |
$app->tpl->setVar("file_path", $file_path); |
b7afde
|
89 |
|
T |
90 |
$keyword_list = array(); |
|
91 |
if(isset($wb) && is_array($wb)) { |
|
92 |
foreach($wb as $key => $val) { |
7fe908
|
93 |
$keyword_list[] = array('key' => $key, 'val' => htmlentities($val, ENT_COMPAT | ENT_HTML401, 'UTF-8')); |
b7afde
|
94 |
} |
T |
95 |
|
|
96 |
$app->tpl->setLoop('records', $keyword_list); |
|
97 |
unset($wb); |
|
98 |
} |
|
99 |
|
5af0cf
|
100 |
//* SET csrf token |
TB |
101 |
$csrf_token = $app->auth->csrf_token_get('language_edit'); |
|
102 |
$app->tpl->setVar('_csrf_id',$csrf_token['csrf_id']); |
|
103 |
$app->tpl->setVar('_csrf_key',$csrf_token['csrf_key']); |
|
104 |
|
b7afde
|
105 |
|
7fe908
|
106 |
//* load language file |
b7afde
|
107 |
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_language_edit.lng'; |
7fe908
|
108 |
include $lng_file; |
b7afde
|
109 |
$app->tpl->setVar($wb); |
T |
110 |
|
|
111 |
$app->tpl_defaults(); |
|
112 |
$app->tpl->pparse(); |
|
113 |
|
|
114 |
|
bb2057
|
115 |
?> |