Till Brehm
2014-08-14 9edea9976bd605071e0694a90d704266c0b7e0f9
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'])) {
58     $file_content = "<?php\n";
59     foreach($_POST['records'] as $key => $val) {
60         $val = stripslashes($val);
b1ed92 61         $val = preg_replace('/(^|[^\\\\])((\\\\\\\\)*)"/', '$1$2\\"', $val);
7fe908 62         $val = str_replace('$', '', $val);
df7e6d 63         $file_content .= '$wb['."'$key'".'] = "'.$val.'";'."\n";
b7afde 64         $msg = 'File saved.';
T 65     }
66     $file_content .= "?>\n";
6b55a1 67     if($module == 'global') {
7fe908 68         file_put_contents(ISPC_LIB_PATH."/lang/$lang_file" , $file_content);
6b55a1 69     } else {
7fe908 70         file_put_contents(ISPC_WEB_PATH."/$module/lib/lang/$lang_file" , $file_content);
6b55a1 71     }
b7afde 72 }
T 73
74
7fe908 75 $app->tpl->setVar(array('module' => $module, 'lang_file' => $lang_file, 'lang' => $lang, 'msg' => $msg));
b7afde 76
6b55a1 77 if($module == 'global') {
7fe908 78     include ISPC_LIB_PATH."/lang/$lang_file";
bb2057 79     $file_path = ISPC_LIB_PATH."/lang/$lang_file";
6b55a1 80 } else {
7fe908 81     include ISPC_WEB_PATH."/$module/lib/lang/$lang_file";
73d9dd 82     $file_path = ISPC_WEB_PATH."/$module/lib/lang/$lang_file";
6b55a1 83 }
bb2057 84 $app->tpl->setVar("file_path", $file_path);
b7afde 85
T 86 $keyword_list = array();
87 if(isset($wb) && is_array($wb)) {
88     foreach($wb as $key => $val) {
7fe908 89         $keyword_list[] = array('key' => $key, 'val' => htmlentities($val, ENT_COMPAT | ENT_HTML401, 'UTF-8'));
b7afde 90     }
T 91
92     $app->tpl->setLoop('records', $keyword_list);
93     unset($wb);
94 }
95
96
7fe908 97 //* load language file
b7afde 98 $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_language_edit.lng';
7fe908 99 include $lng_file;
b7afde 100 $app->tpl->setVar($wb);
T 101
102 $app->tpl_defaults();
103 $app->tpl->pparse();
104
105
bb2057 106 ?>