|
indvdum@0
|
1 |
<?php
|
|
indvdum@0
|
2 |
/**
|
|
indvdum@0
|
3 |
*
|
|
indvdum@0
|
4 |
* @package acp
|
|
indvdum@0
|
5 |
* @version $Id$
|
|
indvdum@0
|
6 |
* @copyright (c) 2005 phpBB Group
|
|
indvdum@0
|
7 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
indvdum@0
|
8 |
*
|
|
indvdum@0
|
9 |
*/
|
|
indvdum@0
|
10 |
|
|
indvdum@0
|
11 |
/**
|
|
indvdum@0
|
12 |
* @ignore
|
|
indvdum@0
|
13 |
*/
|
|
indvdum@0
|
14 |
if (!defined('IN_PHPBB'))
|
|
indvdum@0
|
15 |
{
|
|
indvdum@0
|
16 |
exit;
|
|
indvdum@0
|
17 |
}
|
|
indvdum@0
|
18 |
|
|
indvdum@0
|
19 |
/**
|
|
indvdum@0
|
20 |
* @package acp
|
|
indvdum@0
|
21 |
*/
|
|
indvdum@0
|
22 |
class acp_language
|
|
indvdum@0
|
23 |
{
|
|
indvdum@0
|
24 |
var $u_action;
|
|
indvdum@0
|
25 |
var $main_files;
|
|
indvdum@0
|
26 |
var $language_header = '';
|
|
indvdum@0
|
27 |
var $lang_header = '';
|
|
indvdum@0
|
28 |
|
|
indvdum@0
|
29 |
var $language_file = '';
|
|
indvdum@0
|
30 |
var $language_directory = '';
|
|
indvdum@0
|
31 |
|
|
indvdum@0
|
32 |
function main($id, $mode)
|
|
indvdum@0
|
33 |
{
|
|
indvdum@0
|
34 |
global $config, $db, $user, $auth, $template, $cache;
|
|
indvdum@0
|
35 |
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
|
|
indvdum@0
|
36 |
global $safe_mode, $file_uploads;
|
|
indvdum@0
|
37 |
|
|
indvdum@0
|
38 |
include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
|
indvdum@0
|
39 |
|
|
indvdum@0
|
40 |
$this->default_variables();
|
|
indvdum@0
|
41 |
|
|
indvdum@0
|
42 |
// Check and set some common vars
|
|
indvdum@0
|
43 |
|
|
indvdum@0
|
44 |
$action = (isset($_POST['update_details'])) ? 'update_details' : '';
|
|
indvdum@0
|
45 |
$action = (isset($_POST['download_file'])) ? 'download_file' : $action;
|
|
indvdum@0
|
46 |
$action = (isset($_POST['upload_file'])) ? 'upload_file' : $action;
|
|
indvdum@0
|
47 |
$action = (isset($_POST['upload_data'])) ? 'upload_data' : $action;
|
|
indvdum@0
|
48 |
$action = (isset($_POST['submit_file'])) ? 'submit_file' : $action;
|
|
indvdum@0
|
49 |
$action = (isset($_POST['remove_store'])) ? 'details' : $action;
|
|
indvdum@0
|
50 |
|
|
indvdum@0
|
51 |
$submit = (empty($action) && !isset($_POST['update']) && !isset($_POST['test_connection'])) ? false : true;
|
|
indvdum@0
|
52 |
$action = (empty($action)) ? request_var('action', '') : $action;
|
|
indvdum@0
|
53 |
|
|
indvdum@0
|
54 |
$form_name = 'acp_lang';
|
|
indvdum@0
|
55 |
add_form_key('acp_lang');
|
|
indvdum@0
|
56 |
|
|
indvdum@0
|
57 |
$lang_id = request_var('id', 0);
|
|
indvdum@0
|
58 |
if (isset($_POST['missing_file']))
|
|
indvdum@0
|
59 |
{
|
|
indvdum@0
|
60 |
$missing_file = request_var('missing_file', array('' => 0));
|
|
indvdum@0
|
61 |
list($_REQUEST['language_file'], ) = array_keys($missing_file);
|
|
indvdum@0
|
62 |
}
|
|
indvdum@0
|
63 |
|
|
indvdum@0
|
64 |
$selected_lang_file = request_var('language_file', '|common.' . $phpEx);
|
|
indvdum@0
|
65 |
|
|
indvdum@0
|
66 |
list($this->language_directory, $this->language_file) = explode('|', $selected_lang_file);
|
|
indvdum@0
|
67 |
|
|
indvdum@0
|
68 |
$this->language_directory = basename($this->language_directory);
|
|
indvdum@0
|
69 |
$this->language_file = basename($this->language_file);
|
|
indvdum@0
|
70 |
|
|
indvdum@0
|
71 |
$user->add_lang('acp/language');
|
|
indvdum@0
|
72 |
$this->tpl_name = 'acp_language';
|
|
indvdum@0
|
73 |
$this->page_title = 'ACP_LANGUAGE_PACKS';
|
|
indvdum@0
|
74 |
|
|
indvdum@0
|
75 |
if ($submit && $action == 'upload_data' && request_var('test_connection', ''))
|
|
indvdum@0
|
76 |
{
|
|
indvdum@0
|
77 |
$test_connection = false;
|
|
indvdum@0
|
78 |
$action = 'upload_file';
|
|
indvdum@0
|
79 |
$method = request_var('method', '');
|
|
indvdum@0
|
80 |
|
|
indvdum@0
|
81 |
include_once($phpbb_root_path . 'includes/functions_transfer.' . $phpEx);
|
|
indvdum@0
|
82 |
|
|
indvdum@0
|
83 |
switch ($method)
|
|
indvdum@0
|
84 |
{
|
|
indvdum@0
|
85 |
case 'ftp':
|
|
indvdum@0
|
86 |
$transfer = new ftp(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', ''));
|
|
indvdum@0
|
87 |
break;
|
|
indvdum@0
|
88 |
|
|
indvdum@0
|
89 |
case 'ftp_fsock':
|
|
indvdum@0
|
90 |
$transfer = new ftp_fsock(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', ''));
|
|
indvdum@0
|
91 |
break;
|
|
indvdum@0
|
92 |
|
|
indvdum@0
|
93 |
default:
|
|
indvdum@0
|
94 |
trigger_error($user->lang['INVALID_UPLOAD_METHOD'], E_USER_ERROR);
|
|
indvdum@0
|
95 |
break;
|
|
indvdum@0
|
96 |
}
|
|
indvdum@0
|
97 |
|
|
indvdum@0
|
98 |
$test_connection = $transfer->open_session();
|
|
indvdum@0
|
99 |
$transfer->close_session();
|
|
indvdum@0
|
100 |
}
|
|
indvdum@0
|
101 |
|
|
indvdum@0
|
102 |
switch ($action)
|
|
indvdum@0
|
103 |
{
|
|
indvdum@0
|
104 |
case 'upload_file':
|
|
indvdum@0
|
105 |
|
|
indvdum@0
|
106 |
include_once($phpbb_root_path . 'includes/functions_transfer.' . $phpEx);
|
|
indvdum@0
|
107 |
|
|
indvdum@0
|
108 |
$method = request_var('method', '');
|
|
indvdum@0
|
109 |
|
|
indvdum@0
|
110 |
if (!class_exists($method))
|
|
indvdum@0
|
111 |
{
|
|
indvdum@0
|
112 |
trigger_error('Method does not exist.', E_USER_ERROR);
|
|
indvdum@0
|
113 |
}
|
|
indvdum@0
|
114 |
|
|
indvdum@0
|
115 |
$requested_data = call_user_func(array($method, 'data'));
|
|
indvdum@0
|
116 |
foreach ($requested_data as $data => $default)
|
|
indvdum@0
|
117 |
{
|
|
indvdum@0
|
118 |
$template->assign_block_vars('data', array(
|
|
indvdum@0
|
119 |
'DATA' => $data,
|
|
indvdum@0
|
120 |
'NAME' => $user->lang[strtoupper($method . '_' . $data)],
|
|
indvdum@0
|
121 |
'EXPLAIN' => $user->lang[strtoupper($method . '_' . $data) . '_EXPLAIN'],
|
|
indvdum@0
|
122 |
'DEFAULT' => (!empty($_REQUEST[$data])) ? request_var($data, '') : $default
|
|
indvdum@0
|
123 |
));
|
|
indvdum@0
|
124 |
}
|
|
indvdum@0
|
125 |
|
|
indvdum@0
|
126 |
$hidden_data = build_hidden_fields(array(
|
|
indvdum@0
|
127 |
'file' => $this->language_file,
|
|
indvdum@0
|
128 |
'dir' => $this->language_directory,
|
|
indvdum@0
|
129 |
'language_file' => $selected_lang_file,
|
|
indvdum@0
|
130 |
'method' => $method)
|
|
indvdum@0
|
131 |
);
|
|
indvdum@0
|
132 |
|
|
indvdum@0
|
133 |
$hidden_data .= build_hidden_fields(array('entry' => $_POST['entry']), true, STRIP);
|
|
indvdum@0
|
134 |
|
|
indvdum@0
|
135 |
$template->assign_vars(array(
|
|
indvdum@0
|
136 |
'S_UPLOAD' => true,
|
|
indvdum@0
|
137 |
'NAME' => $method,
|
|
indvdum@0
|
138 |
'U_ACTION' => $this->u_action . "&id=$lang_id&action=upload_data",
|
|
indvdum@0
|
139 |
'U_BACK' => $this->u_action . "&id=$lang_id&action=details&language_file=" . urlencode($selected_lang_file),
|
|
indvdum@0
|
140 |
'HIDDEN' => $hidden_data,
|
|
indvdum@0
|
141 |
|
|
indvdum@0
|
142 |
'S_CONNECTION_SUCCESS' => (request_var('test_connection', '') && $test_connection === true) ? true : false,
|
|
indvdum@0
|
143 |
'S_CONNECTION_FAILED' => (request_var('test_connection', '') && $test_connection !== true) ? true : false
|
|
indvdum@0
|
144 |
));
|
|
indvdum@0
|
145 |
break;
|
|
indvdum@0
|
146 |
|
|
indvdum@0
|
147 |
case 'update_details':
|
|
indvdum@0
|
148 |
|
|
indvdum@0
|
149 |
if (!$submit || !check_form_key($form_name))
|
|
indvdum@0
|
150 |
{
|
|
indvdum@0
|
151 |
trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING);
|
|
indvdum@0
|
152 |
}
|
|
indvdum@0
|
153 |
|
|
indvdum@0
|
154 |
if (!$lang_id)
|
|
indvdum@0
|
155 |
{
|
|
indvdum@0
|
156 |
trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
indvdum@0
|
157 |
}
|
|
indvdum@0
|
158 |
|
|
indvdum@0
|
159 |
$sql = 'SELECT *
|
|
indvdum@0
|
160 |
FROM ' . LANG_TABLE . "
|
|
indvdum@0
|
161 |
WHERE lang_id = $lang_id";
|
|
indvdum@0
|
162 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
163 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
164 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
165 |
|
|
indvdum@0
|
166 |
$sql_ary = array(
|
|
indvdum@0
|
167 |
'lang_english_name' => request_var('lang_english_name', $row['lang_english_name']),
|
|
indvdum@0
|
168 |
'lang_local_name' => utf8_normalize_nfc(request_var('lang_local_name', $row['lang_local_name'], true)),
|
|
indvdum@0
|
169 |
'lang_author' => utf8_normalize_nfc(request_var('lang_author', $row['lang_author'], true)),
|
|
indvdum@0
|
170 |
);
|
|
indvdum@0
|
171 |
|
|
indvdum@0
|
172 |
$db->sql_query('UPDATE ' . LANG_TABLE . '
|
|
indvdum@0
|
173 |
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
|
indvdum@0
|
174 |
WHERE lang_id = ' . $lang_id);
|
|
indvdum@0
|
175 |
|
|
indvdum@0
|
176 |
add_log('admin', 'LOG_LANGUAGE_PACK_UPDATED', $sql_ary['lang_english_name']);
|
|
indvdum@0
|
177 |
|
|
indvdum@0
|
178 |
trigger_error($user->lang['LANGUAGE_DETAILS_UPDATED'] . adm_back_link($this->u_action));
|
|
indvdum@0
|
179 |
break;
|
|
indvdum@0
|
180 |
|
|
indvdum@0
|
181 |
case 'submit_file':
|
|
indvdum@0
|
182 |
case 'download_file':
|
|
indvdum@0
|
183 |
case 'upload_data':
|
|
indvdum@0
|
184 |
|
|
indvdum@0
|
185 |
if (!$submit || !check_form_key($form_name))
|
|
indvdum@0
|
186 |
{
|
|
indvdum@0
|
187 |
trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING);
|
|
indvdum@0
|
188 |
}
|
|
indvdum@0
|
189 |
|
|
indvdum@0
|
190 |
if (!$lang_id || empty($_POST['entry']))
|
|
indvdum@0
|
191 |
{
|
|
indvdum@0
|
192 |
trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
indvdum@0
|
193 |
}
|
|
indvdum@0
|
194 |
|
|
indvdum@0
|
195 |
if ($this->language_directory != 'email' && !is_array($_POST['entry']))
|
|
indvdum@0
|
196 |
{
|
|
indvdum@0
|
197 |
trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
indvdum@0
|
198 |
}
|
|
indvdum@0
|
199 |
|
|
indvdum@0
|
200 |
if (!$this->language_file || (!$this->language_directory && !in_array($this->language_file, $this->main_files)))
|
|
indvdum@0
|
201 |
{
|
|
indvdum@0
|
202 |
trigger_error($user->lang['NO_FILE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
indvdum@0
|
203 |
}
|
|
indvdum@0
|
204 |
|
|
indvdum@0
|
205 |
$sql = 'SELECT *
|
|
indvdum@0
|
206 |
FROM ' . LANG_TABLE . "
|
|
indvdum@0
|
207 |
WHERE lang_id = $lang_id";
|
|
indvdum@0
|
208 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
209 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
210 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
211 |
|
|
indvdum@0
|
212 |
if (!$row)
|
|
indvdum@0
|
213 |
{
|
|
indvdum@0
|
214 |
trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
indvdum@0
|
215 |
}
|
|
indvdum@0
|
216 |
|
|
indvdum@0
|
217 |
// Before we attempt to write anything let's check if the admin really chose a correct filename
|
|
indvdum@0
|
218 |
switch ($this->language_directory)
|
|
indvdum@0
|
219 |
{
|
|
indvdum@0
|
220 |
case 'email':
|
|
indvdum@0
|
221 |
// Get email templates
|
|
indvdum@0
|
222 |
$email_files = filelist($phpbb_root_path . 'language/' . $row['lang_iso'], 'email', 'txt');
|
|
indvdum@0
|
223 |
$email_files = $email_files['email/'];
|
|
indvdum@0
|
224 |
|
|
indvdum@0
|
225 |
if (!in_array($this->language_file, $email_files))
|
|
indvdum@0
|
226 |
{
|
|
indvdum@0
|
227 |
trigger_error($user->lang['WRONG_LANGUAGE_FILE'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id), E_USER_WARNING);
|
|
indvdum@0
|
228 |
}
|
|
indvdum@0
|
229 |
break;
|
|
indvdum@0
|
230 |
|
|
indvdum@0
|
231 |
case 'acp':
|
|
indvdum@0
|
232 |
// Get acp files
|
|
indvdum@0
|
233 |
$acp_files = filelist($phpbb_root_path . 'language/' . $row['lang_iso'], 'acp', $phpEx);
|
|
indvdum@0
|
234 |
$acp_files = $acp_files['acp/'];
|
|
indvdum@0
|
235 |
|
|
indvdum@0
|
236 |
if (!in_array($this->language_file, $acp_files))
|
|
indvdum@0
|
237 |
{
|
|
indvdum@0
|
238 |
trigger_error($user->lang['WRONG_LANGUAGE_FILE'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id), E_USER_WARNING);
|
|
indvdum@0
|
239 |
}
|
|
indvdum@0
|
240 |
break;
|
|
indvdum@0
|
241 |
|
|
indvdum@0
|
242 |
case 'mods':
|
|
indvdum@0
|
243 |
// Get mod files
|
|
indvdum@0
|
244 |
$mods_files = filelist($phpbb_root_path . 'language/' . $row['lang_iso'], 'mods', $phpEx);
|
|
indvdum@0
|
245 |
$mods_files = (isset($mods_files['mods/'])) ? $mods_files['mods/'] : array();
|
|
indvdum@0
|
246 |
|
|
indvdum@0
|
247 |
if (!in_array($this->language_file, $mods_files))
|
|
indvdum@0
|
248 |
{
|
|
indvdum@0
|
249 |
trigger_error($user->lang['WRONG_LANGUAGE_FILE'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id), E_USER_WARNING);
|
|
indvdum@0
|
250 |
}
|
|
indvdum@0
|
251 |
break;
|
|
indvdum@0
|
252 |
|
|
indvdum@0
|
253 |
default:
|
|
indvdum@0
|
254 |
if (!in_array($this->language_file, $this->main_files))
|
|
indvdum@0
|
255 |
{
|
|
indvdum@0
|
256 |
trigger_error($user->lang['WRONG_LANGUAGE_FILE'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id), E_USER_WARNING);
|
|
indvdum@0
|
257 |
}
|
|
indvdum@0
|
258 |
break;
|
|
indvdum@0
|
259 |
}
|
|
indvdum@0
|
260 |
|
|
indvdum@0
|
261 |
if (!$safe_mode)
|
|
indvdum@0
|
262 |
{
|
|
indvdum@0
|
263 |
$mkdir_ary = array('language', 'language/' . $row['lang_iso']);
|
|
indvdum@0
|
264 |
|
|
indvdum@0
|
265 |
if ($this->language_directory)
|
|
indvdum@0
|
266 |
{
|
|
indvdum@0
|
267 |
$mkdir_ary[] = 'language/' . $row['lang_iso'] . '/' . $this->language_directory;
|
|
indvdum@0
|
268 |
}
|
|
indvdum@0
|
269 |
|
|
indvdum@0
|
270 |
foreach ($mkdir_ary as $dir)
|
|
indvdum@0
|
271 |
{
|
|
indvdum@0
|
272 |
$dir = $phpbb_root_path . 'store/' . $dir;
|
|
indvdum@0
|
273 |
|
|
indvdum@0
|
274 |
if (!is_dir($dir))
|
|
indvdum@0
|
275 |
{
|
|
indvdum@0
|
276 |
if (!@mkdir($dir, 0777))
|
|
indvdum@0
|
277 |
{
|
|
indvdum@0
|
278 |
trigger_error("Could not create directory $dir", E_USER_ERROR);
|
|
indvdum@0
|
279 |
}
|
|
indvdum@0
|
280 |
@chmod($dir, 0777);
|
|
indvdum@0
|
281 |
}
|
|
indvdum@0
|
282 |
}
|
|
indvdum@0
|
283 |
}
|
|
indvdum@0
|
284 |
|
|
indvdum@0
|
285 |
// Get target filename for storage folder
|
|
indvdum@0
|
286 |
$filename = $this->get_filename($row['lang_iso'], $this->language_directory, $this->language_file, true, true);
|
|
indvdum@0
|
287 |
$fp = @fopen($phpbb_root_path . $filename, 'wb');
|
|
indvdum@0
|
288 |
|
|
indvdum@0
|
289 |
if (!$fp)
|
|
indvdum@0
|
290 |
{
|
|
indvdum@0
|
291 |
trigger_error(sprintf($user->lang['UNABLE_TO_WRITE_FILE'], $filename) . adm_back_link($this->u_action . '&id=' . $lang_id . '&action=details&language_file=' . urlencode($selected_lang_file)), E_USER_WARNING);
|
|
indvdum@0
|
292 |
}
|
|
indvdum@0
|
293 |
|
|
indvdum@0
|
294 |
if ($this->language_directory == 'email')
|
|
indvdum@0
|
295 |
{
|
|
indvdum@0
|
296 |
// Email Template
|
|
indvdum@0
|
297 |
$entry = $this->prepare_lang_entry($_POST['entry'], false);
|
|
indvdum@0
|
298 |
fwrite($fp, $entry);
|
|
indvdum@0
|
299 |
}
|
|
indvdum@0
|
300 |
else
|
|
indvdum@0
|
301 |
{
|
|
indvdum@0
|
302 |
$name = (($this->language_directory) ? $this->language_directory . '_' : '') . $this->language_file;
|
|
indvdum@0
|
303 |
$header = str_replace(array('{FILENAME}', '{LANG_NAME}', '{CHANGED}', '{AUTHOR}'), array($name, $row['lang_english_name'], date('Y-m-d', time()), $row['lang_author']), $this->language_file_header);
|
|
indvdum@0
|
304 |
|
|
indvdum@0
|
305 |
if (strpos($this->language_file, 'help_') === 0)
|
|
indvdum@0
|
306 |
{
|
|
indvdum@0
|
307 |
// Help File
|
|
indvdum@0
|
308 |
$header .= '$help = array(' . "\n";
|
|
indvdum@0
|
309 |
fwrite($fp, $header);
|
|
indvdum@0
|
310 |
|
|
indvdum@0
|
311 |
foreach ($_POST['entry'] as $key => $value)
|
|
indvdum@0
|
312 |
{
|
|
indvdum@0
|
313 |
if (!is_array($value))
|
|
indvdum@0
|
314 |
{
|
|
indvdum@0
|
315 |
continue;
|
|
indvdum@0
|
316 |
}
|
|
indvdum@0
|
317 |
|
|
indvdum@0
|
318 |
$entry = "\tarray(\n";
|
|
indvdum@0
|
319 |
|
|
indvdum@0
|
320 |
foreach ($value as $_key => $_value)
|
|
indvdum@0
|
321 |
{
|
|
indvdum@0
|
322 |
$entry .= "\t\t" . (int) $_key . "\t=> '" . $this->prepare_lang_entry($_value) . "',\n";
|
|
indvdum@0
|
323 |
}
|
|
indvdum@0
|
324 |
|
|
indvdum@0
|
325 |
$entry .= "\t),\n";
|
|
indvdum@0
|
326 |
fwrite($fp, $entry);
|
|
indvdum@0
|
327 |
}
|
|
indvdum@0
|
328 |
|
|
indvdum@0
|
329 |
$footer = ");\n\n?>";
|
|
indvdum@0
|
330 |
fwrite($fp, $footer);
|
|
indvdum@0
|
331 |
}
|
|
indvdum@0
|
332 |
else
|
|
indvdum@0
|
333 |
{
|
|
indvdum@0
|
334 |
// Language File
|
|
indvdum@0
|
335 |
$header .= $this->lang_header;
|
|
indvdum@0
|
336 |
fwrite($fp, $header);
|
|
indvdum@0
|
337 |
|
|
indvdum@0
|
338 |
foreach ($_POST['entry'] as $key => $value)
|
|
indvdum@0
|
339 |
{
|
|
indvdum@0
|
340 |
$entry = $this->format_lang_array($key, $value);
|
|
indvdum@0
|
341 |
fwrite($fp, $entry);
|
|
indvdum@0
|
342 |
}
|
|
indvdum@0
|
343 |
|
|
indvdum@0
|
344 |
$footer = "));\n\n?>";
|
|
indvdum@0
|
345 |
fwrite($fp, $footer);
|
|
indvdum@0
|
346 |
}
|
|
indvdum@0
|
347 |
}
|
|
indvdum@0
|
348 |
|
|
indvdum@0
|
349 |
fclose($fp);
|
|
indvdum@0
|
350 |
|
|
indvdum@0
|
351 |
if ($action == 'download_file')
|
|
indvdum@0
|
352 |
{
|
|
indvdum@0
|
353 |
header('Pragma: no-cache');
|
|
indvdum@0
|
354 |
header('Content-Type: application/octetstream; name="' . $this->language_file . '"');
|
|
indvdum@0
|
355 |
header('Content-disposition: attachment; filename=' . $this->language_file);
|
|
indvdum@0
|
356 |
|
|
indvdum@0
|
357 |
$fp = @fopen($phpbb_root_path . $filename, 'rb');
|
|
indvdum@0
|
358 |
while ($buffer = fread($fp, 1024))
|
|
indvdum@0
|
359 |
{
|
|
indvdum@0
|
360 |
echo $buffer;
|
|
indvdum@0
|
361 |
}
|
|
indvdum@0
|
362 |
fclose($fp);
|
|
indvdum@0
|
363 |
|
|
indvdum@0
|
364 |
add_log('admin', 'LOG_LANGUAGE_FILE_SUBMITTED', $this->language_file);
|
|
indvdum@0
|
365 |
|
|
indvdum@0
|
366 |
exit;
|
|
indvdum@0
|
367 |
}
|
|
indvdum@0
|
368 |
else if ($action == 'upload_data')
|
|
indvdum@0
|
369 |
{
|
|
indvdum@0
|
370 |
$sql = 'SELECT lang_iso
|
|
indvdum@0
|
371 |
FROM ' . LANG_TABLE . "
|
|
indvdum@0
|
372 |
WHERE lang_id = $lang_id";
|
|
indvdum@0
|
373 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
374 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
375 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
376 |
|
|
indvdum@0
|
377 |
$file = request_var('file', '');
|
|
indvdum@0
|
378 |
$dir = request_var('dir', '');
|
|
indvdum@0
|
379 |
|
|
indvdum@0
|
380 |
$selected_lang_file = $dir . '|' . $file;
|
|
indvdum@0
|
381 |
|
|
indvdum@0
|
382 |
$old_file = '/' . $this->get_filename($row['lang_iso'], $dir, $file, false, true);
|
|
indvdum@0
|
383 |
$lang_path = 'language/' . $row['lang_iso'] . '/' . (($dir) ? $dir . '/' : '');
|
|
indvdum@0
|
384 |
|
|
indvdum@0
|
385 |
include_once($phpbb_root_path . 'includes/functions_transfer.' . $phpEx);
|
|
indvdum@0
|
386 |
$method = request_var('method', '');
|
|
indvdum@0
|
387 |
|
|
indvdum@0
|
388 |
if ($method != 'ftp' && $method != 'ftp_fsock')
|
|
indvdum@0
|
389 |
{
|
|
indvdum@0
|
390 |
trigger_error($user->lang['INVALID_UPLOAD_METHOD'], E_USER_ERROR);
|
|
indvdum@0
|
391 |
}
|
|
indvdum@0
|
392 |
|
|
indvdum@0
|
393 |
$transfer = new $method(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', ''));
|
|
indvdum@0
|
394 |
|
|
indvdum@0
|
395 |
if (($result = $transfer->open_session()) !== true)
|
|
indvdum@0
|
396 |
{
|
|
indvdum@0
|
397 |
trigger_error($user->lang[$result] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id . '&language_file=' . urlencode($selected_lang_file)), E_USER_WARNING);
|
|
indvdum@0
|
398 |
}
|
|
indvdum@0
|
399 |
|
|
indvdum@0
|
400 |
$transfer->rename($lang_path . $file, $lang_path . $file . '.bak');
|
|
indvdum@0
|
401 |
$result = $transfer->copy_file('store/' . $lang_path . $file, $lang_path . $file);
|
|
indvdum@0
|
402 |
|
|
indvdum@0
|
403 |
if ($result === false)
|
|
indvdum@0
|
404 |
{
|
|
indvdum@0
|
405 |
// If failed, try to rename again and print error out...
|
|
indvdum@0
|
406 |
$transfer->delete_file($lang_path . $file);
|
|
indvdum@0
|
407 |
$transfer->rename($lang_path . $file . '.bak', $lang_path . $file);
|
|
indvdum@0
|
408 |
|
|
indvdum@0
|
409 |
trigger_error($user->lang['UPLOAD_FAILED'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id . '&language_file=' . urlencode($selected_lang_file)), E_USER_WARNING);
|
|
indvdum@0
|
410 |
}
|
|
indvdum@0
|
411 |
|
|
indvdum@0
|
412 |
$transfer->close_session();
|
|
indvdum@0
|
413 |
|
|
indvdum@0
|
414 |
// Remove from storage folder
|
|
indvdum@0
|
415 |
if (file_exists($phpbb_root_path . 'store/' . $lang_path . $file))
|
|
indvdum@0
|
416 |
{
|
|
indvdum@0
|
417 |
@unlink($phpbb_root_path . 'store/' . $lang_path . $file);
|
|
indvdum@0
|
418 |
}
|
|
indvdum@0
|
419 |
|
|
indvdum@0
|
420 |
add_log('admin', 'LOG_LANGUAGE_FILE_REPLACED', $file);
|
|
indvdum@0
|
421 |
|
|
indvdum@0
|
422 |
trigger_error($user->lang['UPLOAD_COMPLETED'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id . '&language_file=' . urlencode($selected_lang_file)));
|
|
indvdum@0
|
423 |
}
|
|
indvdum@0
|
424 |
|
|
indvdum@0
|
425 |
add_log('admin', 'LOG_LANGUAGE_FILE_SUBMITTED', $this->language_file);
|
|
indvdum@0
|
426 |
$action = 'details';
|
|
indvdum@0
|
427 |
|
|
indvdum@0
|
428 |
// no break;
|
|
indvdum@0
|
429 |
|
|
indvdum@0
|
430 |
case 'details':
|
|
indvdum@0
|
431 |
|
|
indvdum@0
|
432 |
if (!$lang_id)
|
|
indvdum@0
|
433 |
{
|
|
indvdum@0
|
434 |
trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
indvdum@0
|
435 |
}
|
|
indvdum@0
|
436 |
|
|
indvdum@0
|
437 |
$this->page_title = 'LANGUAGE_PACK_DETAILS';
|
|
indvdum@0
|
438 |
|
|
indvdum@0
|
439 |
$sql = 'SELECT *
|
|
indvdum@0
|
440 |
FROM ' . LANG_TABLE . '
|
|
indvdum@0
|
441 |
WHERE lang_id = ' . $lang_id;
|
|
indvdum@0
|
442 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
443 |
$lang_entries = $db->sql_fetchrow($result);
|
|
indvdum@0
|
444 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
445 |
|
|
indvdum@0
|
446 |
$lang_iso = $lang_entries['lang_iso'];
|
|
indvdum@0
|
447 |
$missing_vars = $missing_files = array();
|
|
indvdum@0
|
448 |
|
|
indvdum@0
|
449 |
// Get email templates
|
|
indvdum@0
|
450 |
$email_files = filelist($phpbb_root_path . 'language/' . $config['default_lang'], 'email', 'txt');
|
|
indvdum@0
|
451 |
$email_files = $email_files['email/'];
|
|
indvdum@0
|
452 |
|
|
indvdum@0
|
453 |
// Get acp files
|
|
indvdum@0
|
454 |
$acp_files = filelist($phpbb_root_path . 'language/' . $config['default_lang'], 'acp', $phpEx);
|
|
indvdum@0
|
455 |
$acp_files = $acp_files['acp/'];
|
|
indvdum@0
|
456 |
|
|
indvdum@0
|
457 |
// Get mod files
|
|
indvdum@0
|
458 |
$mods_files = filelist($phpbb_root_path . 'language/' . $config['default_lang'], 'mods', $phpEx);
|
|
indvdum@0
|
459 |
$mods_files = (isset($mods_files['mods/'])) ? $mods_files['mods/'] : array();
|
|
indvdum@0
|
460 |
|
|
indvdum@0
|
461 |
// Check if our current filename matches the files
|
|
indvdum@0
|
462 |
switch ($this->language_directory)
|
|
indvdum@0
|
463 |
{
|
|
indvdum@0
|
464 |
case 'email':
|
|
indvdum@0
|
465 |
if (!in_array($this->language_file, $email_files))
|
|
indvdum@0
|
466 |
{
|
|
indvdum@0
|
467 |
trigger_error($user->lang['WRONG_LANGUAGE_FILE'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id), E_USER_WARNING);
|
|
indvdum@0
|
468 |
}
|
|
indvdum@0
|
469 |
break;
|
|
indvdum@0
|
470 |
|
|
indvdum@0
|
471 |
case 'acp':
|
|
indvdum@0
|
472 |
if (!in_array($this->language_file, $acp_files))
|
|
indvdum@0
|
473 |
{
|
|
indvdum@0
|
474 |
trigger_error($user->lang['WRONG_LANGUAGE_FILE'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id), E_USER_WARNING);
|
|
indvdum@0
|
475 |
}
|
|
indvdum@0
|
476 |
break;
|
|
indvdum@0
|
477 |
|
|
indvdum@0
|
478 |
case 'mods':
|
|
indvdum@0
|
479 |
if (!in_array($this->language_file, $mods_files))
|
|
indvdum@0
|
480 |
{
|
|
indvdum@0
|
481 |
trigger_error($user->lang['WRONG_LANGUAGE_FILE'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id), E_USER_WARNING);
|
|
indvdum@0
|
482 |
}
|
|
indvdum@0
|
483 |
break;
|
|
indvdum@0
|
484 |
|
|
indvdum@0
|
485 |
default:
|
|
indvdum@0
|
486 |
if (!in_array($this->language_file, $this->main_files))
|
|
indvdum@0
|
487 |
{
|
|
indvdum@0
|
488 |
trigger_error($user->lang['WRONG_LANGUAGE_FILE'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id), E_USER_WARNING);
|
|
indvdum@0
|
489 |
}
|
|
indvdum@0
|
490 |
}
|
|
indvdum@0
|
491 |
|
|
indvdum@0
|
492 |
if (isset($_POST['remove_store']))
|
|
indvdum@0
|
493 |
{
|
|
indvdum@0
|
494 |
$store_filename = $this->get_filename($lang_iso, $this->language_directory, $this->language_file, true, true);
|
|
indvdum@0
|
495 |
|
|
indvdum@0
|
496 |
if (file_exists($phpbb_root_path . $store_filename))
|
|
indvdum@0
|
497 |
{
|
|
indvdum@0
|
498 |
@unlink($phpbb_root_path . $store_filename);
|
|
indvdum@0
|
499 |
}
|
|
indvdum@0
|
500 |
}
|
|
indvdum@0
|
501 |
|
|
indvdum@0
|
502 |
include_once($phpbb_root_path . 'includes/functions_transfer.' . $phpEx);
|
|
indvdum@0
|
503 |
|
|
indvdum@0
|
504 |
$methods = transfer::methods();
|
|
indvdum@0
|
505 |
|
|
indvdum@0
|
506 |
foreach ($methods as $method)
|
|
indvdum@0
|
507 |
{
|
|
indvdum@0
|
508 |
$template->assign_block_vars('buttons', array(
|
|
indvdum@0
|
509 |
'VALUE' => $method
|
|
indvdum@0
|
510 |
));
|
|
indvdum@0
|
511 |
}
|
|
indvdum@0
|
512 |
|
|
indvdum@0
|
513 |
$template->assign_vars(array(
|
|
indvdum@0
|
514 |
'S_DETAILS' => true,
|
|
indvdum@0
|
515 |
'U_ACTION' => $this->u_action . "&action=details&id=$lang_id",
|
|
indvdum@0
|
516 |
'U_BACK' => $this->u_action,
|
|
indvdum@0
|
517 |
'LANG_LOCAL_NAME' => $lang_entries['lang_local_name'],
|
|
indvdum@0
|
518 |
'LANG_ENGLISH_NAME' => $lang_entries['lang_english_name'],
|
|
indvdum@0
|
519 |
'LANG_ISO' => $lang_entries['lang_iso'],
|
|
indvdum@0
|
520 |
'LANG_AUTHOR' => $lang_entries['lang_author'],
|
|
indvdum@0
|
521 |
'ALLOW_UPLOAD' => sizeof($methods)
|
|
indvdum@0
|
522 |
)
|
|
indvdum@0
|
523 |
);
|
|
indvdum@0
|
524 |
|
|
indvdum@0
|
525 |
// If current lang is different from the default lang, then first try to grab missing/additional vars
|
|
indvdum@0
|
526 |
if ($lang_iso != $config['default_lang'])
|
|
indvdum@0
|
527 |
{
|
|
indvdum@0
|
528 |
$is_missing_var = false;
|
|
indvdum@0
|
529 |
|
|
indvdum@0
|
530 |
foreach ($this->main_files as $file)
|
|
indvdum@0
|
531 |
{
|
|
indvdum@0
|
532 |
if (file_exists($phpbb_root_path . $this->get_filename($lang_iso, '', $file)))
|
|
indvdum@0
|
533 |
{
|
|
indvdum@0
|
534 |
$missing_vars[$file] = $this->compare_language_files($config['default_lang'], $lang_iso, '', $file);
|
|
indvdum@0
|
535 |
|
|
indvdum@0
|
536 |
if (sizeof($missing_vars[$file]))
|
|
indvdum@0
|
537 |
{
|
|
indvdum@0
|
538 |
$is_missing_var = true;
|
|
indvdum@0
|
539 |
}
|
|
indvdum@0
|
540 |
}
|
|
indvdum@0
|
541 |
else
|
|
indvdum@0
|
542 |
{
|
|
indvdum@0
|
543 |
$missing_files[] = $this->get_filename($lang_iso, '', $file);
|
|
indvdum@0
|
544 |
}
|
|
indvdum@0
|
545 |
}
|
|
indvdum@0
|
546 |
|
|
indvdum@0
|
547 |
// Now go through acp/mods directories
|
|
indvdum@0
|
548 |
foreach ($acp_files as $file)
|
|
indvdum@0
|
549 |
{
|
|
indvdum@0
|
550 |
if (file_exists($phpbb_root_path . $this->get_filename($lang_iso, 'acp', $file)))
|
|
indvdum@0
|
551 |
{
|
|
indvdum@0
|
552 |
$missing_vars['acp/' . $file] = $this->compare_language_files($config['default_lang'], $lang_iso, 'acp', $file);
|
|
indvdum@0
|
553 |
|
|
indvdum@0
|
554 |
if (sizeof($missing_vars['acp/' . $file]))
|
|
indvdum@0
|
555 |
{
|
|
indvdum@0
|
556 |
$is_missing_var = true;
|
|
indvdum@0
|
557 |
}
|
|
indvdum@0
|
558 |
}
|
|
indvdum@0
|
559 |
else
|
|
indvdum@0
|
560 |
{
|
|
indvdum@0
|
561 |
$missing_files[] = $this->get_filename($lang_iso, 'acp', $file);
|
|
indvdum@0
|
562 |
}
|
|
indvdum@0
|
563 |
}
|
|
indvdum@0
|
564 |
|
|
indvdum@0
|
565 |
if (sizeof($mods_files))
|
|
indvdum@0
|
566 |
{
|
|
indvdum@0
|
567 |
foreach ($mods_files as $file)
|
|
indvdum@0
|
568 |
{
|
|
indvdum@0
|
569 |
if (file_exists($phpbb_root_path . $this->get_filename($lang_iso, 'mods', $file)))
|
|
indvdum@0
|
570 |
{
|
|
indvdum@0
|
571 |
$missing_vars['mods/' . $file] = $this->compare_language_files($config['default_lang'], $lang_iso, 'mods', $file);
|
|
indvdum@0
|
572 |
|
|
indvdum@0
|
573 |
if (sizeof($missing_vars['mods/' . $file]))
|
|
indvdum@0
|
574 |
{
|
|
indvdum@0
|
575 |
$is_missing_var = true;
|
|
indvdum@0
|
576 |
}
|
|
indvdum@0
|
577 |
}
|
|
indvdum@0
|
578 |
else
|
|
indvdum@0
|
579 |
{
|
|
indvdum@0
|
580 |
$missing_files[] = $this->get_filename($lang_iso, 'mods', $file);
|
|
indvdum@0
|
581 |
}
|
|
indvdum@0
|
582 |
}
|
|
indvdum@0
|
583 |
}
|
|
indvdum@0
|
584 |
|
|
indvdum@0
|
585 |
// More missing files... for example email templates?
|
|
indvdum@0
|
586 |
foreach ($email_files as $file)
|
|
indvdum@0
|
587 |
{
|
|
indvdum@0
|
588 |
if (!file_exists($phpbb_root_path . $this->get_filename($lang_iso, 'email', $file)))
|
|
indvdum@0
|
589 |
{
|
|
indvdum@0
|
590 |
$missing_files[] = $this->get_filename($lang_iso, 'email', $file);
|
|
indvdum@0
|
591 |
}
|
|
indvdum@0
|
592 |
}
|
|
indvdum@0
|
593 |
|
|
indvdum@0
|
594 |
if (sizeof($missing_files))
|
|
indvdum@0
|
595 |
{
|
|
indvdum@0
|
596 |
$template->assign_vars(array(
|
|
indvdum@0
|
597 |
'S_MISSING_FILES' => true,
|
|
indvdum@0
|
598 |
'L_MISSING_FILES' => sprintf($user->lang['THOSE_MISSING_LANG_FILES'], $lang_entries['lang_local_name']),
|
|
indvdum@0
|
599 |
'MISSING_FILES' => implode('<br />', $missing_files))
|
|
indvdum@0
|
600 |
);
|
|
indvdum@0
|
601 |
}
|
|
indvdum@0
|
602 |
|
|
indvdum@0
|
603 |
if ($is_missing_var)
|
|
indvdum@0
|
604 |
{
|
|
indvdum@0
|
605 |
$template->assign_vars(array(
|
|
indvdum@0
|
606 |
'S_MISSING_VARS' => true,
|
|
indvdum@0
|
607 |
'L_MISSING_VARS_EXPLAIN' => sprintf($user->lang['THOSE_MISSING_LANG_VARIABLES'], $lang_entries['lang_local_name']),
|
|
indvdum@0
|
608 |
'U_MISSING_ACTION' => $this->u_action . "&action=$action&id=$lang_id")
|
|
indvdum@0
|
609 |
);
|
|
indvdum@0
|
610 |
|
|
indvdum@0
|
611 |
foreach ($missing_vars as $file => $vars)
|
|
indvdum@0
|
612 |
{
|
|
indvdum@0
|
613 |
if (!sizeof($vars))
|
|
indvdum@0
|
614 |
{
|
|
indvdum@0
|
615 |
continue;
|
|
indvdum@0
|
616 |
}
|
|
indvdum@0
|
617 |
|
|
indvdum@0
|
618 |
$template->assign_block_vars('missing', array(
|
|
indvdum@0
|
619 |
'FILE' => $file,
|
|
indvdum@0
|
620 |
'TPL' => $this->print_language_entries($vars, '', false),
|
|
indvdum@0
|
621 |
'KEY' => (strpos($file, '/') === false) ? '|' . $file : str_replace('/', '|', $file))
|
|
indvdum@0
|
622 |
);
|
|
indvdum@0
|
623 |
}
|
|
indvdum@0
|
624 |
}
|
|
indvdum@0
|
625 |
}
|
|
indvdum@0
|
626 |
|
|
indvdum@0
|
627 |
// Main language files
|
|
indvdum@0
|
628 |
$s_lang_options = '<option value="|common.' . $phpEx . '" class="sep">' . $user->lang['LANGUAGE_FILES'] . '</option>';
|
|
indvdum@0
|
629 |
foreach ($this->main_files as $file)
|
|
indvdum@0
|
630 |
{
|
|
indvdum@0
|
631 |
if (strpos($file, 'help_') === 0)
|
|
indvdum@0
|
632 |
{
|
|
indvdum@0
|
633 |
continue;
|
|
indvdum@0
|
634 |
}
|
|
indvdum@0
|
635 |
|
|
indvdum@0
|
636 |
$prefix = (file_exists($phpbb_root_path . $this->get_filename($lang_iso, '', $file, true, true))) ? '* ' : '';
|
|
indvdum@0
|
637 |
|
|
indvdum@0
|
638 |
$selected = (!$this->language_directory && $this->language_file == $file) ? ' selected="selected"' : '';
|
|
indvdum@0
|
639 |
$s_lang_options .= '<option value="|' . $file . '"' . $selected . '>' . $prefix . $file . '</option>';
|
|
indvdum@0
|
640 |
}
|
|
indvdum@0
|
641 |
|
|
indvdum@0
|
642 |
// Help Files
|
|
indvdum@0
|
643 |
$s_lang_options .= '<option value="|common.' . $phpEx . '" class="sep">' . $user->lang['HELP_FILES'] . '</option>';
|
|
indvdum@0
|
644 |
foreach ($this->main_files as $file)
|
|
indvdum@0
|
645 |
{
|
|
indvdum@0
|
646 |
if (strpos($file, 'help_') !== 0)
|
|
indvdum@0
|
647 |
{
|
|
indvdum@0
|
648 |
continue;
|
|
indvdum@0
|
649 |
}
|
|
indvdum@0
|
650 |
|
|
indvdum@0
|
651 |
$prefix = (file_exists($phpbb_root_path . $this->get_filename($lang_iso, '', $file, true, true))) ? '* ' : '';
|
|
indvdum@0
|
652 |
|
|
indvdum@0
|
653 |
$selected = (!$this->language_directory && $this->language_file == $file) ? ' selected="selected"' : '';
|
|
indvdum@0
|
654 |
$s_lang_options .= '<option value="|' . $file . '"' . $selected . '>' . $prefix . $file . '</option>';
|
|
indvdum@0
|
655 |
}
|
|
indvdum@0
|
656 |
|
|
indvdum@0
|
657 |
// Now every other language directory
|
|
indvdum@0
|
658 |
$check_files = array('email', 'acp', 'mods');
|
|
indvdum@0
|
659 |
|
|
indvdum@0
|
660 |
foreach ($check_files as $check)
|
|
indvdum@0
|
661 |
{
|
|
indvdum@0
|
662 |
if (!sizeof(${$check . '_files'}))
|
|
indvdum@0
|
663 |
{
|
|
indvdum@0
|
664 |
continue;
|
|
indvdum@0
|
665 |
}
|
|
indvdum@0
|
666 |
|
|
indvdum@0
|
667 |
$s_lang_options .= '<option value="|common.' . $phpEx . '" class="sep">' . $user->lang[strtoupper($check) . '_FILES'] . '</option>';
|
|
indvdum@0
|
668 |
|
|
indvdum@0
|
669 |
foreach (${$check . '_files'} as $file)
|
|
indvdum@0
|
670 |
{
|
|
indvdum@0
|
671 |
$prefix = (file_exists($phpbb_root_path . $this->get_filename($lang_iso, $check, $file, true, true))) ? '* ' : '';
|
|
indvdum@0
|
672 |
|
|
indvdum@0
|
673 |
$selected = ($this->language_directory == $check && $this->language_file == $file) ? ' selected="selected"' : '';
|
|
indvdum@0
|
674 |
$s_lang_options .= '<option value="' . $check . '|' . $file . '"' . $selected . '>' . $prefix . $file . '</option>';
|
|
indvdum@0
|
675 |
}
|
|
indvdum@0
|
676 |
}
|
|
indvdum@0
|
677 |
|
|
indvdum@0
|
678 |
// Get Language Entries - if saved within store folder, we take this one (with the option to remove it)
|
|
indvdum@0
|
679 |
$lang = array();
|
|
indvdum@0
|
680 |
|
|
indvdum@0
|
681 |
$is_email_file = ($this->language_directory == 'email') ? true : false;
|
|
indvdum@0
|
682 |
$is_help_file = (strpos($this->language_file, 'help_') === 0) ? true : false;
|
|
indvdum@0
|
683 |
|
|
indvdum@0
|
684 |
$file_from_store = (file_exists($phpbb_root_path . $this->get_filename($lang_iso, $this->language_directory, $this->language_file, true, true))) ? true : false;
|
|
indvdum@0
|
685 |
$no_store_filename = $this->get_filename($lang_iso, $this->language_directory, $this->language_file);
|
|
indvdum@0
|
686 |
|
|
indvdum@0
|
687 |
if (!$file_from_store && !file_exists($phpbb_root_path . $no_store_filename))
|
|
indvdum@0
|
688 |
{
|
|
indvdum@0
|
689 |
$print_message = sprintf($user->lang['MISSING_LANGUAGE_FILE'], $no_store_filename);
|
|
indvdum@0
|
690 |
}
|
|
indvdum@0
|
691 |
else
|
|
indvdum@0
|
692 |
{
|
|
indvdum@0
|
693 |
if ($is_email_file)
|
|
indvdum@0
|
694 |
{
|
|
indvdum@0
|
695 |
$lang = file_get_contents($phpbb_root_path . $this->get_filename($lang_iso, $this->language_directory, $this->language_file, $file_from_store));
|
|
indvdum@0
|
696 |
}
|
|
indvdum@0
|
697 |
else
|
|
indvdum@0
|
698 |
{
|
|
indvdum@0
|
699 |
$help = array();
|
|
indvdum@0
|
700 |
include($phpbb_root_path . $this->get_filename($lang_iso, $this->language_directory, $this->language_file, $file_from_store));
|
|
indvdum@0
|
701 |
|
|
indvdum@0
|
702 |
if ($is_help_file)
|
|
indvdum@0
|
703 |
{
|
|
indvdum@0
|
704 |
$lang = $help;
|
|
indvdum@0
|
705 |
unset($help);
|
|
indvdum@0
|
706 |
}
|
|
indvdum@0
|
707 |
}
|
|
indvdum@0
|
708 |
|
|
indvdum@0
|
709 |
$print_message = (($this->language_directory) ? $this->language_directory . '/' : '') . $this->language_file;
|
|
indvdum@0
|
710 |
}
|
|
indvdum@0
|
711 |
|
|
indvdum@0
|
712 |
// Normal language pack entries
|
|
indvdum@0
|
713 |
$template->assign_vars(array(
|
|
indvdum@0
|
714 |
'U_ENTRY_ACTION' => $this->u_action . "&action=details&id=$lang_id#entries",
|
|
indvdum@0
|
715 |
'S_EMAIL_FILE' => $is_email_file,
|
|
indvdum@0
|
716 |
'S_FROM_STORE' => $file_from_store,
|
|
indvdum@0
|
717 |
'S_LANG_OPTIONS' => $s_lang_options,
|
|
indvdum@0
|
718 |
'PRINT_MESSAGE' => $print_message,
|
|
indvdum@0
|
719 |
)
|
|
indvdum@0
|
720 |
);
|
|
indvdum@0
|
721 |
|
|
indvdum@0
|
722 |
if (!$is_email_file)
|
|
indvdum@0
|
723 |
{
|
|
indvdum@0
|
724 |
$tpl = '';
|
|
indvdum@0
|
725 |
$name = (($this->language_directory) ? $this->language_directory . '/' : '') . $this->language_file;
|
|
indvdum@0
|
726 |
|
|
indvdum@0
|
727 |
if (isset($missing_vars[$name]) && sizeof($missing_vars[$name]))
|
|
indvdum@0
|
728 |
{
|
|
indvdum@0
|
729 |
$tpl .= $this->print_language_entries($missing_vars[$name], '* ');
|
|
indvdum@0
|
730 |
}
|
|
indvdum@0
|
731 |
|
|
indvdum@0
|
732 |
$tpl .= $this->print_language_entries($lang);
|
|
indvdum@0
|
733 |
|
|
indvdum@0
|
734 |
$template->assign_var('TPL', $tpl);
|
|
indvdum@0
|
735 |
unset($tpl);
|
|
indvdum@0
|
736 |
}
|
|
indvdum@0
|
737 |
else
|
|
indvdum@0
|
738 |
{
|
|
indvdum@0
|
739 |
$template->assign_vars(array(
|
|
indvdum@0
|
740 |
'LANG' => $lang)
|
|
indvdum@0
|
741 |
);
|
|
indvdum@0
|
742 |
|
|
indvdum@0
|
743 |
unset($lang);
|
|
indvdum@0
|
744 |
}
|
|
indvdum@0
|
745 |
|
|
indvdum@0
|
746 |
return;
|
|
indvdum@0
|
747 |
|
|
indvdum@0
|
748 |
break;
|
|
indvdum@0
|
749 |
|
|
indvdum@0
|
750 |
case 'delete':
|
|
indvdum@0
|
751 |
|
|
indvdum@0
|
752 |
if (!$lang_id)
|
|
indvdum@0
|
753 |
{
|
|
indvdum@0
|
754 |
trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
indvdum@0
|
755 |
}
|
|
indvdum@0
|
756 |
|
|
indvdum@0
|
757 |
$sql = 'SELECT *
|
|
indvdum@0
|
758 |
FROM ' . LANG_TABLE . '
|
|
indvdum@0
|
759 |
WHERE lang_id = ' . $lang_id;
|
|
indvdum@0
|
760 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
761 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
762 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
763 |
|
|
indvdum@0
|
764 |
if ($row['lang_iso'] == $config['default_lang'])
|
|
indvdum@0
|
765 |
{
|
|
indvdum@0
|
766 |
trigger_error($user->lang['NO_REMOVE_DEFAULT_LANG'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
indvdum@0
|
767 |
}
|
|
indvdum@0
|
768 |
|
|
indvdum@0
|
769 |
if (confirm_box(true))
|
|
indvdum@0
|
770 |
{
|
|
indvdum@0
|
771 |
$db->sql_query('DELETE FROM ' . LANG_TABLE . ' WHERE lang_id = ' . $lang_id);
|
|
indvdum@0
|
772 |
|
|
indvdum@0
|
773 |
$sql = 'UPDATE ' . USERS_TABLE . "
|
|
indvdum@0
|
774 |
SET user_lang = '" . $db->sql_escape($config['default_lang']) . "'
|
|
indvdum@0
|
775 |
WHERE user_lang = '" . $db->sql_escape($row['lang_iso']) . "'";
|
|
indvdum@0
|
776 |
$db->sql_query($sql);
|
|
indvdum@0
|
777 |
|
|
indvdum@0
|
778 |
// We also need to remove the translated entries for custom profile fields - we want clean tables, don't we?
|
|
indvdum@0
|
779 |
$sql = 'DELETE FROM ' . PROFILE_LANG_TABLE . ' WHERE lang_id = ' . $lang_id;
|
|
indvdum@0
|
780 |
$db->sql_query($sql);
|
|
indvdum@0
|
781 |
|
|
indvdum@0
|
782 |
$sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . ' WHERE lang_id = ' . $lang_id;
|
|
indvdum@0
|
783 |
$db->sql_query($sql);
|
|
indvdum@0
|
784 |
|
|
indvdum@0
|
785 |
$sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . " WHERE image_lang = '" . $db->sql_escape($row['lang_iso']) . "'";
|
|
indvdum@0
|
786 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
787 |
|
|
indvdum@0
|
788 |
$cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE);
|
|
indvdum@0
|
789 |
|
|
indvdum@0
|
790 |
add_log('admin', 'LOG_LANGUAGE_PACK_DELETED', $row['lang_english_name']);
|
|
indvdum@0
|
791 |
|
|
indvdum@0
|
792 |
trigger_error(sprintf($user->lang['LANGUAGE_PACK_DELETED'], $row['lang_english_name']) . adm_back_link($this->u_action));
|
|
indvdum@0
|
793 |
}
|
|
indvdum@0
|
794 |
else
|
|
indvdum@0
|
795 |
{
|
|
indvdum@0
|
796 |
$s_hidden_fields = array(
|
|
indvdum@0
|
797 |
'i' => $id,
|
|
indvdum@0
|
798 |
'mode' => $mode,
|
|
indvdum@0
|
799 |
'action' => $action,
|
|
indvdum@0
|
800 |
'id' => $lang_id,
|
|
indvdum@0
|
801 |
);
|
|
indvdum@0
|
802 |
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields));
|
|
indvdum@0
|
803 |
}
|
|
indvdum@0
|
804 |
break;
|
|
indvdum@0
|
805 |
|
|
indvdum@0
|
806 |
case 'install':
|
|
indvdum@0
|
807 |
$lang_iso = request_var('iso', '');
|
|
indvdum@0
|
808 |
$lang_iso = basename($lang_iso);
|
|
indvdum@0
|
809 |
|
|
indvdum@0
|
810 |
if (!$lang_iso || !file_exists("{$phpbb_root_path}language/$lang_iso/iso.txt"))
|
|
indvdum@0
|
811 |
{
|
|
indvdum@0
|
812 |
trigger_error($user->lang['LANGUAGE_PACK_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
indvdum@0
|
813 |
}
|
|
indvdum@0
|
814 |
|
|
indvdum@0
|
815 |
$file = file("{$phpbb_root_path}language/$lang_iso/iso.txt");
|
|
indvdum@0
|
816 |
|
|
indvdum@0
|
817 |
$lang_pack = array(
|
|
indvdum@0
|
818 |
'iso' => $lang_iso,
|
|
indvdum@0
|
819 |
'name' => trim(htmlspecialchars($file[0])),
|
|
indvdum@0
|
820 |
'local_name'=> trim(htmlspecialchars($file[1], ENT_COMPAT, 'UTF-8')),
|
|
indvdum@0
|
821 |
'author' => trim(htmlspecialchars($file[2], ENT_COMPAT, 'UTF-8'))
|
|
indvdum@0
|
822 |
);
|
|
indvdum@0
|
823 |
unset($file);
|
|
indvdum@0
|
824 |
|
|
indvdum@0
|
825 |
$sql = 'SELECT lang_iso
|
|
indvdum@0
|
826 |
FROM ' . LANG_TABLE . "
|
|
indvdum@0
|
827 |
WHERE lang_iso = '" . $db->sql_escape($lang_iso) . "'";
|
|
indvdum@0
|
828 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
829 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
830 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
831 |
|
|
indvdum@0
|
832 |
if ($row)
|
|
indvdum@0
|
833 |
{
|
|
indvdum@0
|
834 |
trigger_error($user->lang['LANGUAGE_PACK_ALREADY_INSTALLED'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
indvdum@0
|
835 |
}
|
|
indvdum@0
|
836 |
|
|
indvdum@0
|
837 |
if (!$lang_pack['name'] || !$lang_pack['local_name'])
|
|
indvdum@0
|
838 |
{
|
|
indvdum@0
|
839 |
trigger_error($user->lang['INVALID_LANGUAGE_PACK'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
indvdum@0
|
840 |
}
|
|
indvdum@0
|
841 |
|
|
indvdum@0
|
842 |
// Add language pack
|
|
indvdum@0
|
843 |
$sql_ary = array(
|
|
indvdum@0
|
844 |
'lang_iso' => $lang_pack['iso'],
|
|
indvdum@0
|
845 |
'lang_dir' => $lang_pack['iso'],
|
|
indvdum@0
|
846 |
'lang_english_name' => $lang_pack['name'],
|
|
indvdum@0
|
847 |
'lang_local_name' => $lang_pack['local_name'],
|
|
indvdum@0
|
848 |
'lang_author' => $lang_pack['author']
|
|
indvdum@0
|
849 |
);
|
|
indvdum@0
|
850 |
|
|
indvdum@0
|
851 |
$db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
|
|
indvdum@0
|
852 |
$lang_id = $db->sql_nextid();
|
|
indvdum@0
|
853 |
|
|
indvdum@0
|
854 |
$valid_localized = array(
|
|
indvdum@0
|
855 |
'icon_back_top', 'icon_contact_aim', 'icon_contact_email', 'icon_contact_icq', 'icon_contact_jabber', 'icon_contact_msnm', 'icon_contact_pm', 'icon_contact_yahoo', 'icon_contact_www', 'icon_post_delete', 'icon_post_edit', 'icon_post_info', 'icon_post_quote', 'icon_post_report', 'icon_user_online', 'icon_user_offline', 'icon_user_profile', 'icon_user_search', 'icon_user_warn', 'button_pm_forward', 'button_pm_new', 'button_pm_reply', 'button_topic_locked', 'button_topic_new', 'button_topic_reply',
|
|
indvdum@0
|
856 |
);
|
|
indvdum@0
|
857 |
|
|
indvdum@0
|
858 |
$sql_ary = array();
|
|
indvdum@0
|
859 |
|
|
indvdum@0
|
860 |
$sql = 'SELECT *
|
|
indvdum@0
|
861 |
FROM ' . STYLES_IMAGESET_TABLE;
|
|
indvdum@0
|
862 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
863 |
while ($imageset_row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
864 |
{
|
|
indvdum@0
|
865 |
if (@file_exists("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/{$lang_pack['iso']}/imageset.cfg"))
|
|
indvdum@0
|
866 |
{
|
|
indvdum@0
|
867 |
$cfg_data_imageset_data = parse_cfg_file("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/{$lang_pack['iso']}/imageset.cfg");
|
|
indvdum@0
|
868 |
foreach ($cfg_data_imageset_data as $image_name => $value)
|
|
indvdum@0
|
869 |
{
|
|
indvdum@0
|
870 |
if (strpos($value, '*') !== false)
|
|
indvdum@0
|
871 |
{
|
|
indvdum@0
|
872 |
if (substr($value, -1, 1) === '*')
|
|
indvdum@0
|
873 |
{
|
|
indvdum@0
|
874 |
list($image_filename, $image_height) = explode('*', $value);
|
|
indvdum@0
|
875 |
$image_width = 0;
|
|
indvdum@0
|
876 |
}
|
|
indvdum@0
|
877 |
else
|
|
indvdum@0
|
878 |
{
|
|
indvdum@0
|
879 |
list($image_filename, $image_height, $image_width) = explode('*', $value);
|
|
indvdum@0
|
880 |
}
|
|
indvdum@0
|
881 |
}
|
|
indvdum@0
|
882 |
else
|
|
indvdum@0
|
883 |
{
|
|
indvdum@0
|
884 |
$image_filename = $value;
|
|
indvdum@0
|
885 |
$image_height = $image_width = 0;
|
|
indvdum@0
|
886 |
}
|
|
indvdum@0
|
887 |
|
|
indvdum@0
|
888 |
if (strpos($image_name, 'img_') === 0 && $image_filename)
|
|
indvdum@0
|
889 |
{
|
|
indvdum@0
|
890 |
$image_name = substr($image_name, 4);
|
|
indvdum@0
|
891 |
if (in_array($image_name, $valid_localized))
|
|
indvdum@0
|
892 |
{
|
|
indvdum@0
|
893 |
$sql_ary[] = array(
|
|
indvdum@0
|
894 |
'image_name' => (string) $image_name,
|
|
indvdum@0
|
895 |
'image_filename' => (string) $image_filename,
|
|
indvdum@0
|
896 |
'image_height' => (int) $image_height,
|
|
indvdum@0
|
897 |
'image_width' => (int) $image_width,
|
|
indvdum@0
|
898 |
'imageset_id' => (int) $imageset_row['imageset_id'],
|
|
indvdum@0
|
899 |
'image_lang' => (string) $lang_pack['iso'],
|
|
indvdum@0
|
900 |
);
|
|
indvdum@0
|
901 |
}
|
|
indvdum@0
|
902 |
}
|
|
indvdum@0
|
903 |
}
|
|
indvdum@0
|
904 |
}
|
|
indvdum@0
|
905 |
}
|
|
indvdum@0
|
906 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
907 |
|
|
indvdum@0
|
908 |
if (sizeof($sql_ary))
|
|
indvdum@0
|
909 |
{
|
|
indvdum@0
|
910 |
$db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary);
|
|
indvdum@0
|
911 |
$cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE);
|
|
indvdum@0
|
912 |
}
|
|
indvdum@0
|
913 |
|
|
indvdum@0
|
914 |
// Now let's copy the default language entries for custom profile fields for this new language - makes admin's life easier.
|
|
indvdum@0
|
915 |
$sql = 'SELECT lang_id
|
|
indvdum@0
|
916 |
FROM ' . LANG_TABLE . "
|
|
indvdum@0
|
917 |
WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'";
|
|
indvdum@0
|
918 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
919 |
$default_lang_id = (int) $db->sql_fetchfield('lang_id');
|
|
indvdum@0
|
920 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
921 |
|
|
indvdum@0
|
922 |
// We want to notify the admin that custom profile fields need to be updated for the new language.
|
|
indvdum@0
|
923 |
$notify_cpf_update = false;
|
|
indvdum@0
|
924 |
|
|
indvdum@0
|
925 |
// From the mysql documentation:
|
|
indvdum@0
|
926 |
// Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14.
|
|
indvdum@0
|
927 |
// Due to this we stay on the safe side if we do the insertion "the manual way"
|
|
indvdum@0
|
928 |
|
|
indvdum@0
|
929 |
$sql = 'SELECT field_id, lang_name, lang_explain, lang_default_value
|
|
indvdum@0
|
930 |
FROM ' . PROFILE_LANG_TABLE . '
|
|
indvdum@0
|
931 |
WHERE lang_id = ' . $default_lang_id;
|
|
indvdum@0
|
932 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
933 |
|
|
indvdum@0
|
934 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
935 |
{
|
|
indvdum@0
|
936 |
$row['lang_id'] = $lang_id;
|
|
indvdum@0
|
937 |
$db->sql_query('INSERT INTO ' . PROFILE_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $row));
|
|
indvdum@0
|
938 |
$notify_cpf_update = true;
|
|
indvdum@0
|
939 |
}
|
|
indvdum@0
|
940 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
941 |
|
|
indvdum@0
|
942 |
$sql = 'SELECT field_id, option_id, field_type, lang_value
|
|
indvdum@0
|
943 |
FROM ' . PROFILE_FIELDS_LANG_TABLE . '
|
|
indvdum@0
|
944 |
WHERE lang_id = ' . $default_lang_id;
|
|
indvdum@0
|
945 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
946 |
|
|
indvdum@0
|
947 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
948 |
{
|
|
indvdum@0
|
949 |
$row['lang_id'] = $lang_id;
|
|
indvdum@0
|
950 |
$db->sql_query('INSERT INTO ' . PROFILE_FIELDS_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $row));
|
|
indvdum@0
|
951 |
$notify_cpf_update = true;
|
|
indvdum@0
|
952 |
}
|
|
indvdum@0
|
953 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
954 |
|
|
indvdum@0
|
955 |
add_log('admin', 'LOG_LANGUAGE_PACK_INSTALLED', $lang_pack['name']);
|
|
indvdum@0
|
956 |
|
|
indvdum@0
|
957 |
$message = sprintf($user->lang['LANGUAGE_PACK_INSTALLED'], $lang_pack['name']);
|
|
indvdum@0
|
958 |
$message .= ($notify_cpf_update) ? '<br /><br />' . $user->lang['LANGUAGE_PACK_CPF_UPDATE'] : '';
|
|
indvdum@0
|
959 |
trigger_error($message . adm_back_link($this->u_action));
|
|
indvdum@0
|
960 |
|
|
indvdum@0
|
961 |
break;
|
|
indvdum@0
|
962 |
|
|
indvdum@0
|
963 |
case 'download':
|
|
indvdum@0
|
964 |
|
|
indvdum@0
|
965 |
if (!$lang_id)
|
|
indvdum@0
|
966 |
{
|
|
indvdum@0
|
967 |
trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
indvdum@0
|
968 |
}
|
|
indvdum@0
|
969 |
|
|
indvdum@0
|
970 |
$sql = 'SELECT *
|
|
indvdum@0
|
971 |
FROM ' . LANG_TABLE . '
|
|
indvdum@0
|
972 |
WHERE lang_id = ' . $lang_id;
|
|
indvdum@0
|
973 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
974 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
975 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
976 |
|
|
indvdum@0
|
977 |
$use_method = request_var('use_method', '');
|
|
indvdum@0
|
978 |
$methods = array('.tar');
|
|
indvdum@0
|
979 |
|
|
indvdum@0
|
980 |
$available_methods = array('.tar.gz' => 'zlib', '.tar.bz2' => 'bz2', '.zip' => 'zlib');
|
|
indvdum@0
|
981 |
foreach ($available_methods as $type => $module)
|
|
indvdum@0
|
982 |
{
|
|
indvdum@0
|
983 |
if (!@extension_loaded($module))
|
|
indvdum@0
|
984 |
{
|
|
indvdum@0
|
985 |
continue;
|
|
indvdum@0
|
986 |
}
|
|
indvdum@0
|
987 |
|
|
indvdum@0
|
988 |
$methods[] = $type;
|
|
indvdum@0
|
989 |
}
|
|
indvdum@0
|
990 |
|
|
indvdum@0
|
991 |
// Let the user decide in which format he wants to have the pack
|
|
indvdum@0
|
992 |
if (!$use_method)
|
|
indvdum@0
|
993 |
{
|
|
indvdum@0
|
994 |
$this->page_title = 'SELECT_DOWNLOAD_FORMAT';
|
|
indvdum@0
|
995 |
|
|
indvdum@0
|
996 |
$radio_buttons = '';
|
|
indvdum@0
|
997 |
foreach ($methods as $method)
|
|
indvdum@0
|
998 |
{
|
|
indvdum@0
|
999 |
$radio_buttons .= '<label><input type="radio"' . ((!$radio_buttons) ? ' id="use_method"' : '') . ' class="radio" value="' . $method . '" name="use_method" /> ' . $method . '</label>';
|
|
indvdum@0
|
1000 |
}
|
|
indvdum@0
|
1001 |
|
|
indvdum@0
|
1002 |
$template->assign_vars(array(
|
|
indvdum@0
|
1003 |
'S_SELECT_METHOD' => true,
|
|
indvdum@0
|
1004 |
'U_BACK' => $this->u_action,
|
|
indvdum@0
|
1005 |
'U_ACTION' => $this->u_action . "&action=$action&id=$lang_id",
|
|
indvdum@0
|
1006 |
'RADIO_BUTTONS' => $radio_buttons)
|
|
indvdum@0
|
1007 |
);
|
|
indvdum@0
|
1008 |
|
|
indvdum@0
|
1009 |
return;
|
|
indvdum@0
|
1010 |
}
|
|
indvdum@0
|
1011 |
|
|
indvdum@0
|
1012 |
if (!in_array($use_method, $methods))
|
|
indvdum@0
|
1013 |
{
|
|
indvdum@0
|
1014 |
$use_method = '.tar';
|
|
indvdum@0
|
1015 |
}
|
|
indvdum@0
|
1016 |
|
|
indvdum@0
|
1017 |
include_once($phpbb_root_path . 'includes/functions_compress.' . $phpEx);
|
|
indvdum@0
|
1018 |
|
|
indvdum@0
|
1019 |
if ($use_method == '.zip')
|
|
indvdum@0
|
1020 |
{
|
|
indvdum@0
|
1021 |
$compress = new compress_zip('w', $phpbb_root_path . 'store/lang_' . $row['lang_iso'] . $use_method);
|
|
indvdum@0
|
1022 |
}
|
|
indvdum@0
|
1023 |
else
|
|
indvdum@0
|
1024 |
{
|
|
indvdum@0
|
1025 |
$compress = new compress_tar('w', $phpbb_root_path . 'store/lang_' . $row['lang_iso'] . $use_method, $use_method);
|
|
indvdum@0
|
1026 |
}
|
|
indvdum@0
|
1027 |
|
|
indvdum@0
|
1028 |
// Get email templates
|
|
indvdum@0
|
1029 |
$email_templates = filelist($phpbb_root_path . 'language/' . $row['lang_iso'], 'email', 'txt');
|
|
indvdum@0
|
1030 |
$email_templates = $email_templates['email/'];
|
|
indvdum@0
|
1031 |
|
|
indvdum@0
|
1032 |
// Get acp files
|
|
indvdum@0
|
1033 |
$acp_files = filelist($phpbb_root_path . 'language/' . $row['lang_iso'], 'acp', $phpEx);
|
|
indvdum@0
|
1034 |
$acp_files = $acp_files['acp/'];
|
|
indvdum@0
|
1035 |
|
|
indvdum@0
|
1036 |
// Get mod files
|
|
indvdum@0
|
1037 |
$mod_files = filelist($phpbb_root_path . 'language/' . $row['lang_iso'], 'mods', $phpEx);
|
|
indvdum@0
|
1038 |
$mod_files = (isset($mod_files['mods/'])) ? $mod_files['mods/'] : array();
|
|
indvdum@0
|
1039 |
|
|
indvdum@0
|
1040 |
// Add main files
|
|
indvdum@0
|
1041 |
$this->add_to_archive($compress, $this->main_files, $row['lang_iso']);
|
|
indvdum@0
|
1042 |
|
|
indvdum@0
|
1043 |
// Add search files if they exist...
|
|
indvdum@0
|
1044 |
if (file_exists($phpbb_root_path . 'language/' . $row['lang_iso'] . '/search_ignore_words.' . $phpEx))
|
|
indvdum@0
|
1045 |
{
|
|
indvdum@0
|
1046 |
$this->add_to_archive($compress, array("search_ignore_words.$phpEx"), $row['lang_iso']);
|
|
indvdum@0
|
1047 |
}
|
|
indvdum@0
|
1048 |
|
|
indvdum@0
|
1049 |
if (file_exists($phpbb_root_path . 'language/' . $row['lang_iso'] . '/search_synonyms.' . $phpEx))
|
|
indvdum@0
|
1050 |
{
|
|
indvdum@0
|
1051 |
$this->add_to_archive($compress, array("search_synonyms.$phpEx"), $row['lang_iso']);
|
|
indvdum@0
|
1052 |
}
|
|
indvdum@0
|
1053 |
|
|
indvdum@0
|
1054 |
// Write files in folders
|
|
indvdum@0
|
1055 |
$this->add_to_archive($compress, $email_templates, $row['lang_iso'], 'email');
|
|
indvdum@0
|
1056 |
$this->add_to_archive($compress, $acp_files, $row['lang_iso'], 'acp');
|
|
indvdum@0
|
1057 |
$this->add_to_archive($compress, $mod_files, $row['lang_iso'], 'mods');
|
|
indvdum@0
|
1058 |
|
|
indvdum@0
|
1059 |
// Write ISO File
|
|
indvdum@0
|
1060 |
$iso_src = htmlspecialchars_decode($row['lang_english_name']) . "\n";
|
|
indvdum@0
|
1061 |
$iso_src .= htmlspecialchars_decode($row['lang_local_name']) . "\n";
|
|
indvdum@0
|
1062 |
$iso_src .= htmlspecialchars_decode($row['lang_author']);
|
|
indvdum@0
|
1063 |
$compress->add_data($iso_src, 'language/' . $row['lang_iso'] . '/iso.txt');
|
|
indvdum@0
|
1064 |
|
|
indvdum@0
|
1065 |
// index.htm files
|
|
indvdum@0
|
1066 |
$compress->add_data('', 'language/' . $row['lang_iso'] . '/index.htm');
|
|
indvdum@0
|
1067 |
$compress->add_data('', 'language/' . $row['lang_iso'] . '/email/index.htm');
|
|
indvdum@0
|
1068 |
$compress->add_data('', 'language/' . $row['lang_iso'] . '/acp/index.htm');
|
|
indvdum@0
|
1069 |
|
|
indvdum@0
|
1070 |
if (sizeof($mod_files))
|
|
indvdum@0
|
1071 |
{
|
|
indvdum@0
|
1072 |
$compress->add_data('', 'language/' . $row['lang_iso'] . '/mods/index.htm');
|
|
indvdum@0
|
1073 |
}
|
|
indvdum@0
|
1074 |
|
|
indvdum@0
|
1075 |
$compress->close();
|
|
indvdum@0
|
1076 |
|
|
indvdum@0
|
1077 |
$compress->download('lang_' . $row['lang_iso']);
|
|
indvdum@0
|
1078 |
@unlink($phpbb_root_path . 'store/lang_' . $row['lang_iso'] . $use_method);
|
|
indvdum@0
|
1079 |
|
|
indvdum@0
|
1080 |
exit;
|
|
indvdum@0
|
1081 |
|
|
indvdum@0
|
1082 |
break;
|
|
indvdum@0
|
1083 |
}
|
|
indvdum@0
|
1084 |
|
|
indvdum@0
|
1085 |
$sql = 'SELECT user_lang, COUNT(user_lang) AS lang_count
|
|
indvdum@0
|
1086 |
FROM ' . USERS_TABLE . '
|
|
indvdum@0
|
1087 |
GROUP BY user_lang';
|
|
indvdum@0
|
1088 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1089 |
|
|
indvdum@0
|
1090 |
$lang_count = array();
|
|
indvdum@0
|
1091 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
1092 |
{
|
|
indvdum@0
|
1093 |
$lang_count[$row['user_lang']] = $row['lang_count'];
|
|
indvdum@0
|
1094 |
}
|
|
indvdum@0
|
1095 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1096 |
|
|
indvdum@0
|
1097 |
$sql = 'SELECT *
|
|
indvdum@0
|
1098 |
FROM ' . LANG_TABLE . '
|
|
indvdum@0
|
1099 |
ORDER BY lang_english_name';
|
|
indvdum@0
|
1100 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1101 |
|
|
indvdum@0
|
1102 |
$installed = array();
|
|
indvdum@0
|
1103 |
|
|
indvdum@0
|
1104 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
1105 |
{
|
|
indvdum@0
|
1106 |
$installed[] = $row['lang_iso'];
|
|
indvdum@0
|
1107 |
$tagstyle = ($row['lang_iso'] == $config['default_lang']) ? '*' : '';
|
|
indvdum@0
|
1108 |
|
|
indvdum@0
|
1109 |
$template->assign_block_vars('lang', array(
|
|
indvdum@0
|
1110 |
'U_DETAILS' => $this->u_action . "&action=details&id={$row['lang_id']}",
|
|
indvdum@0
|
1111 |
'U_DOWNLOAD' => $this->u_action . "&action=download&id={$row['lang_id']}",
|
|
indvdum@0
|
1112 |
'U_DELETE' => $this->u_action . "&action=delete&id={$row['lang_id']}",
|
|
indvdum@0
|
1113 |
|
|
indvdum@0
|
1114 |
'ENGLISH_NAME' => $row['lang_english_name'],
|
|
indvdum@0
|
1115 |
'TAG' => $tagstyle,
|
|
indvdum@0
|
1116 |
'LOCAL_NAME' => $row['lang_local_name'],
|
|
indvdum@0
|
1117 |
'ISO' => $row['lang_iso'],
|
|
indvdum@0
|
1118 |
'USED_BY' => (isset($lang_count[$row['lang_iso']])) ? $lang_count[$row['lang_iso']] : 0,
|
|
indvdum@0
|
1119 |
));
|
|
indvdum@0
|
1120 |
}
|
|
indvdum@0
|
1121 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1122 |
|
|
indvdum@0
|
1123 |
$new_ary = $iso = array();
|
|
indvdum@0
|
1124 |
$dp = @opendir("{$phpbb_root_path}language");
|
|
indvdum@0
|
1125 |
|
|
indvdum@0
|
1126 |
if ($dp)
|
|
indvdum@0
|
1127 |
{
|
|
indvdum@0
|
1128 |
while (($file = readdir($dp)) !== false)
|
|
indvdum@0
|
1129 |
{
|
|
indvdum@0
|
1130 |
if ($file[0] == '.' || !is_dir($phpbb_root_path . 'language/' . $file))
|
|
indvdum@0
|
1131 |
{
|
|
indvdum@0
|
1132 |
continue;
|
|
indvdum@0
|
1133 |
}
|
|
indvdum@0
|
1134 |
|
|
indvdum@0
|
1135 |
if (file_exists("{$phpbb_root_path}language/$file/iso.txt"))
|
|
indvdum@0
|
1136 |
{
|
|
indvdum@0
|
1137 |
if (!in_array($file, $installed))
|
|
indvdum@0
|
1138 |
{
|
|
indvdum@0
|
1139 |
if ($iso = file("{$phpbb_root_path}language/$file/iso.txt"))
|
|
indvdum@0
|
1140 |
{
|
|
indvdum@0
|
1141 |
if (sizeof($iso) == 3)
|
|
indvdum@0
|
1142 |
{
|
|
indvdum@0
|
1143 |
$new_ary[$file] = array(
|
|
indvdum@0
|
1144 |
'iso' => $file,
|
|
indvdum@0
|
1145 |
'name' => trim($iso[0]),
|
|
indvdum@0
|
1146 |
'local_name'=> trim($iso[1]),
|
|
indvdum@0
|
1147 |
'author' => trim($iso[2])
|
|
indvdum@0
|
1148 |
);
|
|
indvdum@0
|
1149 |
}
|
|
indvdum@0
|
1150 |
}
|
|
indvdum@0
|
1151 |
}
|
|
indvdum@0
|
1152 |
}
|
|
indvdum@0
|
1153 |
}
|
|
indvdum@0
|
1154 |
closedir($dp);
|
|
indvdum@0
|
1155 |
}
|
|
indvdum@0
|
1156 |
|
|
indvdum@0
|
1157 |
unset($installed);
|
|
indvdum@0
|
1158 |
|
|
indvdum@0
|
1159 |
if (sizeof($new_ary))
|
|
indvdum@0
|
1160 |
{
|
|
indvdum@0
|
1161 |
foreach ($new_ary as $iso => $lang_ary)
|
|
indvdum@0
|
1162 |
{
|
|
indvdum@0
|
1163 |
$template->assign_block_vars('notinst', array(
|
|
indvdum@0
|
1164 |
'ISO' => htmlspecialchars($lang_ary['iso']),
|
|
indvdum@0
|
1165 |
'LOCAL_NAME' => htmlspecialchars($lang_ary['local_name'], ENT_COMPAT, 'UTF-8'),
|
|
indvdum@0
|
1166 |
'NAME' => htmlspecialchars($lang_ary['name'], ENT_COMPAT, 'UTF-8'),
|
|
indvdum@0
|
1167 |
'U_INSTALL' => $this->u_action . '&action=install&iso=' . urlencode($lang_ary['iso']))
|
|
indvdum@0
|
1168 |
);
|
|
indvdum@0
|
1169 |
}
|
|
indvdum@0
|
1170 |
}
|
|
indvdum@0
|
1171 |
|
|
indvdum@0
|
1172 |
unset($new_ary);
|
|
indvdum@0
|
1173 |
}
|
|
indvdum@0
|
1174 |
|
|
indvdum@0
|
1175 |
|
|
indvdum@0
|
1176 |
/**
|
|
indvdum@0
|
1177 |
* Set default language variables/header
|
|
indvdum@0
|
1178 |
*/
|
|
indvdum@0
|
1179 |
function default_variables()
|
|
indvdum@0
|
1180 |
{
|
|
indvdum@0
|
1181 |
global $phpEx;
|
|
indvdum@0
|
1182 |
|
|
indvdum@0
|
1183 |
$this->language_file_header = '<?php
|
|
indvdum@0
|
1184 |
/**
|
|
indvdum@0
|
1185 |
*
|
|
indvdum@0
|
1186 |
* {FILENAME} [{LANG_NAME}]
|
|
indvdum@0
|
1187 |
*
|
|
indvdum@0
|
1188 |
* @package language
|
|
indvdum@0
|
1189 |
* @version $' . 'Id: ' . '$
|
|
indvdum@0
|
1190 |
* @copyright (c) ' . date('Y') . ' phpBB Group
|
|
indvdum@0
|
1191 |
* @author {CHANGED} - {AUTHOR}
|
|
indvdum@0
|
1192 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
indvdum@0
|
1193 |
*
|
|
indvdum@0
|
1194 |
*/
|
|
indvdum@0
|
1195 |
|
|
indvdum@0
|
1196 |
/**
|
|
indvdum@0
|
1197 |
* DO NOT CHANGE
|
|
indvdum@0
|
1198 |
*/
|
|
indvdum@0
|
1199 |
if (!defined(\'IN_PHPBB\'))
|
|
indvdum@0
|
1200 |
{
|
|
indvdum@0
|
1201 |
exit;
|
|
indvdum@0
|
1202 |
}
|
|
indvdum@0
|
1203 |
|
|
indvdum@0
|
1204 |
if (empty($lang) || !is_array($lang))
|
|
indvdum@0
|
1205 |
{
|
|
indvdum@0
|
1206 |
$lang = array();
|
|
indvdum@0
|
1207 |
}
|
|
indvdum@0
|
1208 |
|
|
indvdum@0
|
1209 |
// DEVELOPERS PLEASE NOTE
|
|
indvdum@0
|
1210 |
//
|
|
indvdum@0
|
1211 |
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
|
|
indvdum@0
|
1212 |
//
|
|
indvdum@0
|
1213 |
// Placeholders can now contain order information, e.g. instead of
|
|
indvdum@0
|
1214 |
// \'Page %s of %s\' you can (and should) write \'Page %1$s of %2$s\', this allows
|
|
indvdum@0
|
1215 |
// translators to re-order the output of data while ensuring it remains correct
|
|
indvdum@0
|
1216 |
//
|
|
indvdum@0
|
1217 |
// You do not need this where single placeholders are used, e.g. \'Message %d\' is fine
|
|
indvdum@0
|
1218 |
// equally where a string contains only two placeholders which are used to wrap text
|
|
indvdum@0
|
1219 |
// in a url you again do not need to specify an order e.g., \'Click %sHERE%s\' is fine
|
|
indvdum@0
|
1220 |
';
|
|
indvdum@0
|
1221 |
|
|
indvdum@0
|
1222 |
$this->lang_header = '
|
|
indvdum@0
|
1223 |
$lang = array_merge($lang, array(
|
|
indvdum@0
|
1224 |
';
|
|
indvdum@0
|
1225 |
|
|
indvdum@0
|
1226 |
// Language files in language root directory
|
|
indvdum@0
|
1227 |
$this->main_files = array("captcha_qa.$phpEx", "captcha_recaptcha.$phpEx", "common.$phpEx", "groups.$phpEx", "install.$phpEx", "mcp.$phpEx", "memberlist.$phpEx", "posting.$phpEx", "search.$phpEx", "ucp.$phpEx", "viewforum.$phpEx", "viewtopic.$phpEx", "help_bbcode.$phpEx", "help_faq.$phpEx");
|
|
indvdum@0
|
1228 |
}
|
|
indvdum@0
|
1229 |
|
|
indvdum@0
|
1230 |
/**
|
|
indvdum@0
|
1231 |
* Get filename/location of language file
|
|
indvdum@0
|
1232 |
*/
|
|
indvdum@0
|
1233 |
function get_filename($lang_iso, $directory, $filename, $check_store = false, $only_return_filename = false)
|
|
indvdum@0
|
1234 |
{
|
|
indvdum@0
|
1235 |
global $phpbb_root_path, $safe_mode;
|
|
indvdum@0
|
1236 |
|
|
indvdum@0
|
1237 |
$check_filename = "language/$lang_iso/" . (($directory) ? $directory . '/' : '') . $filename;
|
|
indvdum@0
|
1238 |
|
|
indvdum@0
|
1239 |
if ($check_store)
|
|
indvdum@0
|
1240 |
{
|
|
indvdum@0
|
1241 |
$check_store_filename = ($safe_mode) ? "store/langfile_{$lang_iso}" . (($directory) ? '_' . $directory : '') . "_{$filename}" : "store/language/$lang_iso/" . (($directory) ? $directory . '/' : '') . $filename;
|
|
indvdum@0
|
1242 |
|
|
indvdum@0
|
1243 |
if (!$only_return_filename && file_exists($phpbb_root_path . $check_store_filename))
|
|
indvdum@0
|
1244 |
{
|
|
indvdum@0
|
1245 |
return $check_store_filename;
|
|
indvdum@0
|
1246 |
}
|
|
indvdum@0
|
1247 |
else if ($only_return_filename)
|
|
indvdum@0
|
1248 |
{
|
|
indvdum@0
|
1249 |
return $check_store_filename;
|
|
indvdum@0
|
1250 |
}
|
|
indvdum@0
|
1251 |
}
|
|
indvdum@0
|
1252 |
|
|
indvdum@0
|
1253 |
return $check_filename;
|
|
indvdum@0
|
1254 |
}
|
|
indvdum@0
|
1255 |
|
|
indvdum@0
|
1256 |
/**
|
|
indvdum@0
|
1257 |
* Add files to archive
|
|
indvdum@0
|
1258 |
*/
|
|
indvdum@0
|
1259 |
function add_to_archive(&$compress, $filelist, $lang_iso, $directory = '')
|
|
indvdum@0
|
1260 |
{
|
|
indvdum@0
|
1261 |
global $phpbb_root_path;
|
|
indvdum@0
|
1262 |
|
|
indvdum@0
|
1263 |
foreach ($filelist as $file)
|
|
indvdum@0
|
1264 |
{
|
|
indvdum@0
|
1265 |
// Get source filename
|
|
indvdum@0
|
1266 |
$source = $this->get_filename($lang_iso, $directory, $file, true);
|
|
indvdum@0
|
1267 |
$destination = 'language/' . $lang_iso . '/' . (($directory) ? $directory . '/' : '') . $file;
|
|
indvdum@0
|
1268 |
|
|
indvdum@0
|
1269 |
// Add file to archive
|
|
indvdum@0
|
1270 |
$compress->add_custom_file($phpbb_root_path . $source, $destination);
|
|
indvdum@0
|
1271 |
}
|
|
indvdum@0
|
1272 |
}
|
|
indvdum@0
|
1273 |
|
|
indvdum@0
|
1274 |
/**
|
|
indvdum@0
|
1275 |
* Little helper to add some hardcoded template bits
|
|
indvdum@0
|
1276 |
*/
|
|
indvdum@0
|
1277 |
function add_input_field()
|
|
indvdum@0
|
1278 |
{
|
|
indvdum@0
|
1279 |
$keys = func_get_args();
|
|
indvdum@0
|
1280 |
|
|
indvdum@0
|
1281 |
$non_static = array_shift($keys);
|
|
indvdum@0
|
1282 |
$value = utf8_normalize_nfc(array_shift($keys));
|
|
indvdum@0
|
1283 |
|
|
indvdum@0
|
1284 |
if (!$non_static)
|
|
indvdum@0
|
1285 |
{
|
|
indvdum@0
|
1286 |
return '<strong>' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '</strong>';
|
|
indvdum@0
|
1287 |
}
|
|
indvdum@0
|
1288 |
|
|
indvdum@0
|
1289 |
// If more then 270 characters, then we present a textarea, else an input field
|
|
indvdum@0
|
1290 |
$textarea = (utf8_strlen($value) > 270) ? true : false;
|
|
indvdum@0
|
1291 |
$tpl = '';
|
|
indvdum@0
|
1292 |
|
|
indvdum@0
|
1293 |
$tpl .= ($textarea) ? '<textarea name="' : '<input type="text" name="';
|
|
indvdum@0
|
1294 |
$tpl .= 'entry[' . implode('][', array_map('utf8_htmlspecialchars', $keys)) . ']"';
|
|
indvdum@0
|
1295 |
|
|
indvdum@0
|
1296 |
$tpl .= ($textarea) ? ' cols="80" rows="5" class="langvalue">' : ' class="langvalue" value="';
|
|
indvdum@0
|
1297 |
$tpl .= htmlspecialchars($value, ENT_COMPAT, 'UTF-8');
|
|
indvdum@0
|
1298 |
$tpl .= ($textarea) ? '</textarea>' : '" />';
|
|
indvdum@0
|
1299 |
|
|
indvdum@0
|
1300 |
return $tpl;
|
|
indvdum@0
|
1301 |
}
|
|
indvdum@0
|
1302 |
|
|
indvdum@0
|
1303 |
/**
|
|
indvdum@0
|
1304 |
* Print language entries
|
|
indvdum@0
|
1305 |
*/
|
|
indvdum@0
|
1306 |
function print_language_entries(&$lang_ary, $key_prefix = '', $input_field = true)
|
|
indvdum@0
|
1307 |
{
|
|
indvdum@0
|
1308 |
$tpl = '';
|
|
indvdum@0
|
1309 |
|
|
indvdum@0
|
1310 |
foreach ($lang_ary as $key => $value)
|
|
indvdum@0
|
1311 |
{
|
|
indvdum@0
|
1312 |
if (is_array($value))
|
|
indvdum@0
|
1313 |
{
|
|
indvdum@0
|
1314 |
// Write key
|
|
indvdum@0
|
1315 |
$tpl .= '
|
|
indvdum@0
|
1316 |
<tr>
|
|
indvdum@0
|
1317 |
<td class="row3" colspan="2">' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . '<strong>' . htmlspecialchars($key, ENT_COMPAT, 'UTF-8') . '</strong></td>
|
|
indvdum@0
|
1318 |
</tr>';
|
|
indvdum@0
|
1319 |
|
|
indvdum@0
|
1320 |
foreach ($value as $_key => $_value)
|
|
indvdum@0
|
1321 |
{
|
|
indvdum@0
|
1322 |
if (is_array($_value))
|
|
indvdum@0
|
1323 |
{
|
|
indvdum@0
|
1324 |
// Write key
|
|
indvdum@0
|
1325 |
$tpl .= '
|
|
indvdum@0
|
1326 |
<tr>
|
|
indvdum@0
|
1327 |
<td class="row3" colspan="2">' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . ' <strong>' . htmlspecialchars($_key, ENT_COMPAT, 'UTF-8') . '</strong></td>
|
|
indvdum@0
|
1328 |
</tr>';
|
|
indvdum@0
|
1329 |
|
|
indvdum@0
|
1330 |
foreach ($_value as $__key => $__value)
|
|
indvdum@0
|
1331 |
{
|
|
indvdum@0
|
1332 |
// Write key
|
|
indvdum@0
|
1333 |
$tpl .= '
|
|
indvdum@0
|
1334 |
<tr>
|
|
indvdum@0
|
1335 |
<td class="row1" style="white-space: nowrap;">' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . '<strong>' . htmlspecialchars($__key, ENT_COMPAT, 'UTF-8') . '</strong></td>
|
|
indvdum@0
|
1336 |
<td class="row2">';
|
|
indvdum@0
|
1337 |
|
|
indvdum@0
|
1338 |
$tpl .= $this->add_input_field($input_field, $__value, $key, $_key, $__key);
|
|
indvdum@0
|
1339 |
|
|
indvdum@0
|
1340 |
$tpl .= '</td>
|
|
indvdum@0
|
1341 |
</tr>';
|
|
indvdum@0
|
1342 |
}
|
|
indvdum@0
|
1343 |
}
|
|
indvdum@0
|
1344 |
else
|
|
indvdum@0
|
1345 |
{
|
|
indvdum@0
|
1346 |
// Write key
|
|
indvdum@0
|
1347 |
$tpl .= '
|
|
indvdum@0
|
1348 |
<tr>
|
|
indvdum@0
|
1349 |
<td class="row1" style="white-space: nowrap;">' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . '<strong>' . htmlspecialchars($_key, ENT_COMPAT, 'UTF-8') . '</strong></td>
|
|
indvdum@0
|
1350 |
<td class="row2">';
|
|
indvdum@0
|
1351 |
|
|
indvdum@0
|
1352 |
$tpl .= $this->add_input_field($input_field, $_value, $key, $_key);
|
|
indvdum@0
|
1353 |
|
|
indvdum@0
|
1354 |
$tpl .= '</td>
|
|
indvdum@0
|
1355 |
</tr>';
|
|
indvdum@0
|
1356 |
}
|
|
indvdum@0
|
1357 |
}
|
|
indvdum@0
|
1358 |
|
|
indvdum@0
|
1359 |
$tpl .= '
|
|
indvdum@0
|
1360 |
<tr>
|
|
indvdum@0
|
1361 |
<td class="spacer" colspan="2"> </td>
|
|
indvdum@0
|
1362 |
</tr>';
|
|
indvdum@0
|
1363 |
}
|
|
indvdum@0
|
1364 |
else
|
|
indvdum@0
|
1365 |
{
|
|
indvdum@0
|
1366 |
// Write key
|
|
indvdum@0
|
1367 |
$tpl .= '
|
|
indvdum@0
|
1368 |
<tr>
|
|
indvdum@0
|
1369 |
<td class="row1" style="white-space: nowrap;">' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . '<strong>' . htmlspecialchars($key, ENT_COMPAT, 'UTF-8') . '</strong></td>
|
|
indvdum@0
|
1370 |
<td class="row2">';
|
|
indvdum@0
|
1371 |
|
|
indvdum@0
|
1372 |
$tpl .= $this->add_input_field($input_field, $value, $key);
|
|
indvdum@0
|
1373 |
|
|
indvdum@0
|
1374 |
$tpl .= '</td>
|
|
indvdum@0
|
1375 |
</tr>';
|
|
indvdum@0
|
1376 |
}
|
|
indvdum@0
|
1377 |
}
|
|
indvdum@0
|
1378 |
|
|
indvdum@0
|
1379 |
return $tpl;
|
|
indvdum@0
|
1380 |
}
|
|
indvdum@0
|
1381 |
|
|
indvdum@0
|
1382 |
/**
|
|
indvdum@0
|
1383 |
* Compare two language files
|
|
indvdum@0
|
1384 |
*/
|
|
indvdum@0
|
1385 |
function compare_language_files($source_lang, $dest_lang, $directory, $file)
|
|
indvdum@0
|
1386 |
{
|
|
indvdum@0
|
1387 |
global $phpbb_root_path, $phpEx;
|
|
indvdum@0
|
1388 |
|
|
indvdum@0
|
1389 |
$return_ary = array();
|
|
indvdum@0
|
1390 |
|
|
indvdum@0
|
1391 |
$lang = array();
|
|
indvdum@0
|
1392 |
include("{$phpbb_root_path}language/{$source_lang}/" . (($directory) ? $directory . '/' : '') . $file);
|
|
indvdum@0
|
1393 |
$lang_entry_src = $lang;
|
|
indvdum@0
|
1394 |
|
|
indvdum@0
|
1395 |
$lang = array();
|
|
indvdum@0
|
1396 |
|
|
indvdum@0
|
1397 |
if (!file_exists($phpbb_root_path . $this->get_filename($dest_lang, $directory, $file, true)))
|
|
indvdum@0
|
1398 |
{
|
|
indvdum@0
|
1399 |
return array();
|
|
indvdum@0
|
1400 |
}
|
|
indvdum@0
|
1401 |
|
|
indvdum@0
|
1402 |
include($phpbb_root_path . $this->get_filename($dest_lang, $directory, $file, true));
|
|
indvdum@0
|
1403 |
|
|
indvdum@0
|
1404 |
$lang_entry_dst = $lang;
|
|
indvdum@0
|
1405 |
|
|
indvdum@0
|
1406 |
unset($lang);
|
|
indvdum@0
|
1407 |
|
|
indvdum@0
|
1408 |
$diff_array_keys = array_diff(array_keys($lang_entry_src), array_keys($lang_entry_dst));
|
|
indvdum@0
|
1409 |
unset($lang_entry_dst);
|
|
indvdum@0
|
1410 |
|
|
indvdum@0
|
1411 |
foreach ($diff_array_keys as $key)
|
|
indvdum@0
|
1412 |
{
|
|
indvdum@0
|
1413 |
$return_ary[$key] = $lang_entry_src[$key];
|
|
indvdum@0
|
1414 |
}
|
|
indvdum@0
|
1415 |
|
|
indvdum@0
|
1416 |
unset($lang_entry_src);
|
|
indvdum@0
|
1417 |
|
|
indvdum@0
|
1418 |
return $return_ary;
|
|
indvdum@0
|
1419 |
}
|
|
indvdum@0
|
1420 |
|
|
indvdum@0
|
1421 |
/**
|
|
indvdum@0
|
1422 |
* Return language string value for storage
|
|
indvdum@0
|
1423 |
*/
|
|
indvdum@0
|
1424 |
function prepare_lang_entry($text, $store = true)
|
|
indvdum@0
|
1425 |
{
|
|
indvdum@0
|
1426 |
$text = (STRIP) ? stripslashes($text) : $text;
|
|
indvdum@0
|
1427 |
|
|
indvdum@0
|
1428 |
// Adjust for storage...
|
|
indvdum@0
|
1429 |
if ($store)
|
|
indvdum@0
|
1430 |
{
|
|
indvdum@0
|
1431 |
$text = str_replace("'", "\\'", str_replace('\\', '\\\\', $text));
|
|
indvdum@0
|
1432 |
}
|
|
indvdum@0
|
1433 |
|
|
indvdum@0
|
1434 |
return $text;
|
|
indvdum@0
|
1435 |
}
|
|
indvdum@0
|
1436 |
|
|
indvdum@0
|
1437 |
/**
|
|
indvdum@0
|
1438 |
* Format language array for storage
|
|
indvdum@0
|
1439 |
*/
|
|
indvdum@0
|
1440 |
function format_lang_array($key, $value, $tabs = "\t")
|
|
indvdum@0
|
1441 |
{
|
|
indvdum@0
|
1442 |
$entry = '';
|
|
indvdum@0
|
1443 |
|
|
indvdum@0
|
1444 |
if (!is_array($value))
|
|
indvdum@0
|
1445 |
{
|
|
indvdum@0
|
1446 |
$entry .= "{$tabs}'" . $this->prepare_lang_entry($key) . "'\t=> '" . $this->prepare_lang_entry($value) . "',\n";
|
|
indvdum@0
|
1447 |
}
|
|
indvdum@0
|
1448 |
else
|
|
indvdum@0
|
1449 |
{
|
|
indvdum@0
|
1450 |
$_tabs = $tabs . "\t";
|
|
indvdum@0
|
1451 |
$entry .= "\n{$tabs}'" . $this->prepare_lang_entry($key) . "'\t=> array(\n";
|
|
indvdum@0
|
1452 |
|
|
indvdum@0
|
1453 |
foreach ($value as $_key => $_value)
|
|
indvdum@0
|
1454 |
{
|
|
indvdum@0
|
1455 |
$entry .= $this->format_lang_array($_key, $_value, $_tabs);
|
|
indvdum@0
|
1456 |
}
|
|
indvdum@0
|
1457 |
|
|
indvdum@0
|
1458 |
$entry .= "{$tabs}),\n\n";
|
|
indvdum@0
|
1459 |
}
|
|
indvdum@0
|
1460 |
|
|
indvdum@0
|
1461 |
return $entry;
|
|
indvdum@0
|
1462 |
}
|
|
indvdum@0
|
1463 |
}
|
|
indvdum@0
|
1464 |
|
|
indvdum@0
|
1465 |
?> |