Marius Cramer
2014-08-13 42539643c396f9d8865dcf9a51b13dc869709d16
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');
b7afde 35
T 36 //* This is only allowed for administrators
37 if(!$app->auth->is_admin()) die('only allowed for administrators.');
91624b 38 if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mode.');
b7afde 39
T 40 $app->uses('tpl');
41
42 $app->tpl->newTemplate('form.tpl.htm');
43 $app->tpl->setInclude('content_tpl', 'templates/language_edit.htm');
44
45 $lang = $_REQUEST['lang'];
46 $module = $_REQUEST['module'];
47 $lang_file = $_REQUEST['lang_file'];
48
49 if(!preg_match("/^[a-z]+$/i", $lang)) die('unallowed characters in language name.');
50 if(!preg_match("/^[a-z_]+$/i", $module)) die('unallowed characters in module name.');
51 if(!preg_match("/^[a-z\._]+$/i", $lang_file)) die('unallowed characters in language file name.');
52
53 $msg = '';
54
55 //* Save data
56 if(isset($_POST['records']) && is_array($_POST['records'])) {
57     $file_content = "<?php\n";
58     foreach($_POST['records'] as $key => $val) {
59         $val = stripslashes($val);
b1ed92 60         $val = preg_replace('/(^|[^\\\\])((\\\\\\\\)*)"/', '$1$2\\"', $val);
7fe908 61         $val = str_replace('$', '', $val);
df7e6d 62         $file_content .= '$wb['."'$key'".'] = "'.$val.'";'."\n";
b7afde 63         $msg = 'File saved.';
T 64     }
65     $file_content .= "?>\n";
6b55a1 66     if($module == 'global') {
7fe908 67         file_put_contents(ISPC_LIB_PATH."/lang/$lang_file" , $file_content);
6b55a1 68     } else {
7fe908 69         file_put_contents(ISPC_WEB_PATH."/$module/lib/lang/$lang_file" , $file_content);
6b55a1 70     }
b7afde 71 }
T 72
73
7fe908 74 $app->tpl->setVar(array('module' => $module, 'lang_file' => $lang_file, 'lang' => $lang, 'msg' => $msg));
b7afde 75
6b55a1 76 if($module == 'global') {
7fe908 77     include ISPC_LIB_PATH."/lang/$lang_file";
bb2057 78     $file_path = ISPC_LIB_PATH."/lang/$lang_file";
6b55a1 79 } else {
7fe908 80     include ISPC_WEB_PATH."/$module/lib/lang/$lang_file";
73d9dd 81     $file_path = ISPC_WEB_PATH."/$module/lib/lang/$lang_file";
6b55a1 82 }
bb2057 83 $app->tpl->setVar("file_path", $file_path);
b7afde 84
T 85 $keyword_list = array();
86 if(isset($wb) && is_array($wb)) {
87     foreach($wb as $key => $val) {
7fe908 88         $keyword_list[] = array('key' => $key, 'val' => htmlentities($val, ENT_COMPAT | ENT_HTML401, 'UTF-8'));
b7afde 89     }
T 90
91     $app->tpl->setLoop('records', $keyword_list);
92     unset($wb);
93 }
94
95
7fe908 96 //* load language file
b7afde 97 $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_language_edit.lng';
7fe908 98 include $lng_file;
b7afde 99 $app->tpl->setVar($wb);
T 100
101 $app->tpl_defaults();
102 $app->tpl->pparse();
103
104
bb2057 105 ?>