|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
*
|
|
|
ef5584 |
* @package acp
|
|
|
ef5584 |
* @version $Id: acp_language.php 8780 2008-08-22 12:52:48Z acydburn $
|
|
|
ef5584 |
* @copyright (c) 2005 phpBB Group
|
|
|
ef5584 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
ef5584 |
*
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* @ignore
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
if (!defined('IN_PHPBB'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
exit;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* @package acp
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
class acp_language
|
|
|
ef5584 |
{
|
|
|
ef5584 |
var $u_action;
|
|
|
ef5584 |
var $main_files;
|
|
|
ef5584 |
var $language_header = '';
|
|
|
ef5584 |
var $lang_header = '';
|
|
|
ef5584 |
|
|
|
ef5584 |
var $language_file = '';
|
|
|
ef5584 |
var $language_directory = '';
|
|
|
ef5584 |
|
|
|
ef5584 |
function main($id, $mode)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $config, $db, $user, $auth, $template, $cache;
|
|
|
ef5584 |
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
|
|
|
ef5584 |
global $safe_mode, $file_uploads;
|
|
|
ef5584 |
|
|
|
ef5584 |
include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
$this->default_variables();
|
|
|
ef5584 |
|
|
|
ef5584 |
// Check and set some common vars
|
|
|
ef5584 |
|
|
|
ef5584 |
$action = (isset($_POST['update_details'])) ? 'update_details' : '';
|
|
|
ef5584 |
$action = (isset($_POST['download_file'])) ? 'download_file' : $action;
|
|
|
ef5584 |
$action = (isset($_POST['upload_file'])) ? 'upload_file' : $action;
|
|
|
ef5584 |
$action = (isset($_POST['upload_data'])) ? 'upload_data' : $action;
|
|
|
ef5584 |
$action = (isset($_POST['submit_file'])) ? 'submit_file' : $action;
|
|
|
ef5584 |
$action = (isset($_POST['remove_store'])) ? 'details' : $action;
|
|
|
ef5584 |
|
|
|
ef5584 |
$submit = (empty($action) && !isset($_POST['update']) && !isset($_POST['test_connection'])) ? false : true;
|
|
|
ef5584 |
$action = (empty($action)) ? request_var('action', '') : $action;
|
|
|
ef5584 |
|
|
|
ef5584 |
$form_name = 'acp_lang';
|
|
|
ef5584 |
add_form_key('acp_lang');
|
|
|
ef5584 |
|
|
|
ef5584 |
$lang_id = request_var('id', 0);
|
|
|
ef5584 |
if (isset($_POST['missing_file']))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$missing_file = request_var('missing_file', array('' => 0));
|
|
|
ef5584 |
list($_REQUEST['language_file'], ) = array_keys($missing_file);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$selected_lang_file = request_var('language_file', '|common.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
list($this->language_directory, $this->language_file) = explode('|', $selected_lang_file);
|
|
|
ef5584 |
|
|
|
ef5584 |
$this->language_directory = basename($this->language_directory);
|
|
|
ef5584 |
$this->language_file = basename($this->language_file);
|
|
|
ef5584 |
|
|
|
ef5584 |
$user->add_lang('acp/language');
|
|
|
ef5584 |
$this->tpl_name = 'acp_language';
|
|
|
ef5584 |
$this->page_title = 'ACP_LANGUAGE_PACKS';
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($submit && $action == 'upload_data' && request_var('test_connection', ''))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$test_connection = false;
|
|
|
ef5584 |
$action = 'upload_file';
|
|
|
ef5584 |
$method = request_var('method', '');
|
|
|
ef5584 |
|
|
|
ef5584 |
include_once($phpbb_root_path . 'includes/functions_transfer.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
switch ($method)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
case 'ftp':
|
|
|
ef5584 |
$transfer = new ftp(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', ''));
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'ftp_fsock':
|
|
|
ef5584 |
$transfer = new ftp_fsock(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', ''));
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
default:
|
|
|
ef5584 |
trigger_error($user->lang['INVALID_UPLOAD_METHOD'], E_USER_ERROR);
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$test_connection = $transfer->open_session();
|
|
|
ef5584 |
$transfer->close_session();
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
switch ($action)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
case 'upload_file':
|
|
|
ef5584 |
|
|
|
ef5584 |
include_once($phpbb_root_path . 'includes/functions_transfer.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
$method = request_var('method', '');
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!class_exists($method))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error('Method does not exist.', E_USER_ERROR);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$requested_data = call_user_func(array($method, 'data'));
|
|
|
ef5584 |
foreach ($requested_data as $data => $default)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_block_vars('data', array(
|
|
|
ef5584 |
'DATA' => $data,
|
|
|
ef5584 |
'NAME' => $user->lang[strtoupper($method . '_' . $data)],
|
|
|
ef5584 |
'EXPLAIN' => $user->lang[strtoupper($method . '_' . $data) . '_EXPLAIN'],
|
|
|
ef5584 |
'DEFAULT' => (!empty($_REQUEST[$data])) ? request_var($data, '') : $default
|
|
|
ef5584 |
));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$hidden_data = build_hidden_fields(array(
|
|
|
ef5584 |
'file' => $this->language_file,
|
|
|
ef5584 |
'dir' => $this->language_directory,
|
|
|
ef5584 |
'language_file' => $selected_lang_file,
|
|
|
ef5584 |
'method' => $method)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
$hidden_data .= build_hidden_fields(array('entry' => $_POST['entry']), true, STRIP);
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'S_UPLOAD' => true,
|
|
|
ef5584 |
'NAME' => $method,
|
|
|
ef5584 |
'U_ACTION' => $this->u_action . "&id=$lang_id&action=upload_data",
|
|
|
ef5584 |
'U_BACK' => $this->u_action . "&id=$lang_id&action=details&language_file=" . urlencode($selected_lang_file),
|
|
|
ef5584 |
'HIDDEN' => $hidden_data,
|
|
|
ef5584 |
|
|
|
ef5584 |
'S_CONNECTION_SUCCESS' => (request_var('test_connection', '') && $test_connection === true) ? true : false,
|
|
|
ef5584 |
'S_CONNECTION_FAILED' => (request_var('test_connection', '') && $test_connection !== true) ? true : false
|
|
|
ef5584 |
));
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'update_details':
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$submit || !check_form_key($form_name))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$lang_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'SELECT *
|
|
|
ef5584 |
FROM ' . LANG_TABLE . "
|
|
|
ef5584 |
WHERE lang_id = $lang_id";
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$row = $db->sql_fetchrow($result);
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql_ary = array(
|
|
|
ef5584 |
'lang_english_name' => request_var('lang_english_name', $row['lang_english_name']),
|
|
|
ef5584 |
'lang_local_name' => utf8_normalize_nfc(request_var('lang_local_name', $row['lang_local_name'], true)),
|
|
|
ef5584 |
'lang_author' => utf8_normalize_nfc(request_var('lang_author', $row['lang_author'], true)),
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
$db->sql_query('UPDATE ' . LANG_TABLE . '
|
|
|
ef5584 |
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
|
|
ef5584 |
WHERE lang_id = ' . $lang_id);
|
|
|
ef5584 |
|
|
|
ef5584 |
add_log('admin', 'LOG_LANGUAGE_PACK_UPDATED', $sql_ary['lang_english_name']);
|
|
|
ef5584 |
|
|
|
ef5584 |
trigger_error($user->lang['LANGUAGE_DETAILS_UPDATED'] . adm_back_link($this->u_action));
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'submit_file':
|
|
|
ef5584 |
case 'download_file':
|
|
|
ef5584 |
case 'upload_data':
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$submit || !check_form_key($form_name))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$lang_id || empty($_POST['entry']))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($this->language_directory != 'email' && !is_array($_POST['entry']))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$this->language_file || (!$this->language_directory && !in_array($this->language_file, $this->main_files)))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NO_FILE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'SELECT *
|
|
|
ef5584 |
FROM ' . LANG_TABLE . "
|
|
|
ef5584 |
WHERE lang_id = $lang_id";
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$row = $db->sql_fetchrow($result);
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$row)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Before we attempt to write anything let's check if the admin really chose a correct filename
|
|
|
ef5584 |
switch ($this->language_directory)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
case 'email':
|
|
|
ef5584 |
// Get email templates
|
|
|
ef5584 |
$email_files = filelist($phpbb_root_path . 'language/' . $row['lang_iso'], 'email', 'txt');
|
|
|
ef5584 |
$email_files = $email_files['email/'];
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!in_array($this->language_file, $email_files))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['WRONG_LANGUAGE_FILE'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'acp':
|
|
|
ef5584 |
// Get acp files
|
|
|
ef5584 |
$acp_files = filelist($phpbb_root_path . 'language/' . $row['lang_iso'], 'acp', $phpEx);
|
|
|
ef5584 |
$acp_files = $acp_files['acp/'];
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!in_array($this->language_file, $acp_files))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['WRONG_LANGUAGE_FILE'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'mods':
|
|
|
ef5584 |
// Get mod files
|
|
|
ef5584 |
$mods_files = filelist($phpbb_root_path . 'language/' . $row['lang_iso'], 'mods', $phpEx);
|
|
|
ef5584 |
$mods_files = (isset($mods_files['mods/'])) ? $mods_files['mods/'] : array();
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!in_array($this->language_file, $mods_files))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['WRONG_LANGUAGE_FILE'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
default:
|
|
|
ef5584 |
if (!in_array($this->language_file, $this->main_files))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['WRONG_LANGUAGE_FILE'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$safe_mode)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$mkdir_ary = array('language', 'language/' . $row['lang_iso']);
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($this->language_directory)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$mkdir_ary[] = 'language/' . $row['lang_iso'] . '/' . $this->language_directory;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($mkdir_ary as $dir)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$dir = $phpbb_root_path . 'store/' . $dir;
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!is_dir($dir))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!@mkdir($dir, 0777))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error("Could not create directory $dir", E_USER_ERROR);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
@chmod($dir, 0777);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Get target filename for storage folder
|
|
|
ef5584 |
$filename = $this->get_filename($row['lang_iso'], $this->language_directory, $this->language_file, true, true);
|
|
|
ef5584 |
$fp = @fopen($phpbb_root_path . $filename, 'wb');
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$fp)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
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);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($this->language_directory == 'email')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Email Template
|
|
|
ef5584 |
$entry = $this->prepare_lang_entry($_POST['entry'], false);
|
|
|
ef5584 |
fwrite($fp, $entry);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$name = (($this->language_directory) ? $this->language_directory . '_' : '') . $this->language_file;
|
|
|
ef5584 |
$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);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (strpos($this->language_file, 'help_') === 0)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Help File
|
|
|
ef5584 |
$header .= '$help = array(' . "\n";
|
|
|
ef5584 |
fwrite($fp, $header);
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($_POST['entry'] as $key => $value)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!is_array($value))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
continue;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$entry = "\tarray(\n";
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($value as $_key => $_value)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$entry .= "\t\t" . (int) $_key . "\t=> '" . $this->prepare_lang_entry($_value) . "',\n";
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$entry .= "\t),\n";
|
|
|
ef5584 |
fwrite($fp, $entry);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$footer = ");\n\n?>";
|
|
|
ef5584 |
fwrite($fp, $footer);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Language File
|
|
|
ef5584 |
$header .= $this->lang_header;
|
|
|
ef5584 |
fwrite($fp, $header);
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($_POST['entry'] as $key => $value)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$entry = $this->format_lang_array($key, $value);
|
|
|
ef5584 |
fwrite($fp, $entry);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$footer = "));\n\n?>";
|
|
|
ef5584 |
fwrite($fp, $footer);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
fclose($fp);
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($action == 'download_file')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
header('Pragma: no-cache');
|
|
|
ef5584 |
header('Content-Type: application/octetstream; name="' . $this->language_file . '"');
|
|
|
ef5584 |
header('Content-disposition: attachment; filename=' . $this->language_file);
|
|
|
ef5584 |
|
|
|
ef5584 |
$fp = @fopen($phpbb_root_path . $filename, 'rb');
|
|
|
ef5584 |
while ($buffer = fread($fp, 1024))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
echo $buffer;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
fclose($fp);
|
|
|
ef5584 |
|
|
|
ef5584 |
add_log('admin', 'LOG_LANGUAGE_FILE_SUBMITTED', $this->language_file);
|
|
|
ef5584 |
|
|
|
ef5584 |
exit;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else if ($action == 'upload_data')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'SELECT lang_iso
|
|
|
ef5584 |
FROM ' . LANG_TABLE . "
|
|
|
ef5584 |
WHERE lang_id = $lang_id";
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$row = $db->sql_fetchrow($result);
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
$file = request_var('file', '');
|
|
|
ef5584 |
$dir = request_var('dir', '');
|
|
|
ef5584 |
|
|
|
ef5584 |
$selected_lang_file = $dir . '|' . $file;
|
|
|
ef5584 |
|
|
|
ef5584 |
$old_file = '/' . $this->get_filename($row['lang_iso'], $dir, $file, false, true);
|
|
|
ef5584 |
$lang_path = 'language/' . $row['lang_iso'] . '/' . (($dir) ? $dir . '/' : '');
|
|
|
ef5584 |
|
|
|
ef5584 |
include_once($phpbb_root_path . 'includes/functions_transfer.' . $phpEx);
|
|
|
ef5584 |
$method = request_var('method', '');
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($method != 'ftp' && $method != 'ftp_fsock')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['INVALID_UPLOAD_METHOD'], E_USER_ERROR);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$transfer = new $method(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', ''));
|
|
|
ef5584 |
|
|
|
ef5584 |
if (($result = $transfer->open_session()) !== true)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
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);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$transfer->rename($lang_path . $file, $lang_path . $file . '.bak');
|
|
|
ef5584 |
$result = $transfer->copy_file('store/' . $lang_path . $file, $lang_path . $file);
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($result === false)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// If failed, try to rename again and print error out...
|
|
|
ef5584 |
$transfer->delete_file($lang_path . $file);
|
|
|
ef5584 |
$transfer->rename($lang_path . $file . '.bak', $lang_path . $file);
|
|
|
ef5584 |
|
|
|
ef5584 |
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);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$transfer->close_session();
|
|
|
ef5584 |
|
|
|
ef5584 |
// Remove from storage folder
|
|
|
ef5584 |
if (file_exists($phpbb_root_path . 'store/' . $lang_path . $file))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
@unlink($phpbb_root_path . 'store/' . $lang_path . $file);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
add_log('admin', 'LOG_LANGUAGE_FILE_REPLACED', $file);
|
|
|
ef5584 |
|
|
|
ef5584 |
trigger_error($user->lang['UPLOAD_COMPLETED'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id . '&language_file=' . urlencode($selected_lang_file)));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
add_log('admin', 'LOG_LANGUAGE_FILE_SUBMITTED', $this->language_file);
|
|
|
ef5584 |
$action = 'details';
|
|
|
ef5584 |
|
|
|
ef5584 |
// no break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'details':
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$lang_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$this->page_title = 'LANGUAGE_PACK_DETAILS';
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'SELECT *
|
|
|
ef5584 |
FROM ' . LANG_TABLE . '
|
|
|
ef5584 |
WHERE lang_id = ' . $lang_id;
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$lang_entries = $db->sql_fetchrow($result);
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
$lang_iso = $lang_entries['lang_iso'];
|
|
|
ef5584 |
$missing_vars = $missing_files = array();
|
|
|
ef5584 |
|
|
|
ef5584 |
// Get email templates
|
|
|
ef5584 |
$email_files = filelist($phpbb_root_path . 'language/' . $config['default_lang'], 'email', 'txt');
|
|
|
ef5584 |
$email_files = $email_files['email/'];
|
|
|
ef5584 |
|
|
|
ef5584 |
// Get acp files
|
|
|
ef5584 |
$acp_files = filelist($phpbb_root_path . 'language/' . $config['default_lang'], 'acp', $phpEx);
|
|
|
ef5584 |
$acp_files = $acp_files['acp/'];
|
|
|
ef5584 |
|
|
|
ef5584 |
// Get mod files
|
|
|
ef5584 |
$mods_files = filelist($phpbb_root_path . 'language/' . $config['default_lang'], 'mods', $phpEx);
|
|
|
ef5584 |
$mods_files = (isset($mods_files['mods/'])) ? $mods_files['mods/'] : array();
|
|
|
ef5584 |
|
|
|
ef5584 |
// Check if our current filename matches the files
|
|
|
ef5584 |
switch ($this->language_directory)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
case 'email':
|
|
|
ef5584 |
if (!in_array($this->language_file, $email_files))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['WRONG_LANGUAGE_FILE'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'acp':
|
|
|
ef5584 |
if (!in_array($this->language_file, $acp_files))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['WRONG_LANGUAGE_FILE'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'mods':
|
|
|
ef5584 |
if (!in_array($this->language_file, $mods_files))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['WRONG_LANGUAGE_FILE'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
default:
|
|
|
ef5584 |
if (!in_array($this->language_file, $this->main_files))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['WRONG_LANGUAGE_FILE'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (isset($_POST['remove_store']))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$store_filename = $this->get_filename($lang_iso, $this->language_directory, $this->language_file, true, true);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (file_exists($phpbb_root_path . $store_filename))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
@unlink($phpbb_root_path . $store_filename);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
include_once($phpbb_root_path . 'includes/functions_transfer.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
$methods = transfer::methods();
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($methods as $method)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_block_vars('buttons', array(
|
|
|
ef5584 |
'VALUE' => $method
|
|
|
ef5584 |
));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'S_DETAILS' => true,
|
|
|
ef5584 |
'U_ACTION' => $this->u_action . "&action=details&id=$lang_id",
|
|
|
ef5584 |
'U_BACK' => $this->u_action,
|
|
|
ef5584 |
'LANG_LOCAL_NAME' => $lang_entries['lang_local_name'],
|
|
|
ef5584 |
'LANG_ENGLISH_NAME' => $lang_entries['lang_english_name'],
|
|
|
ef5584 |
'LANG_ISO' => $lang_entries['lang_iso'],
|
|
|
ef5584 |
'LANG_AUTHOR' => $lang_entries['lang_author'],
|
|
|
ef5584 |
'ALLOW_UPLOAD' => sizeof($methods)
|
|
|
ef5584 |
)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
// If current lang is different from the default lang, then first try to grab missing/additional vars
|
|
|
ef5584 |
if ($lang_iso != $config['default_lang'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$is_missing_var = false;
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($this->main_files as $file)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (file_exists($phpbb_root_path . $this->get_filename($lang_iso, '', $file)))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$missing_vars[$file] = $this->compare_language_files($config['default_lang'], $lang_iso, '', $file);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($missing_vars[$file]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$is_missing_var = true;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$missing_files[] = $this->get_filename($lang_iso, '', $file);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Now go through acp/mods directories
|
|
|
ef5584 |
foreach ($acp_files as $file)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (file_exists($phpbb_root_path . $this->get_filename($lang_iso, 'acp', $file)))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$missing_vars['acp/' . $file] = $this->compare_language_files($config['default_lang'], $lang_iso, 'acp', $file);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($missing_vars['acp/' . $file]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$is_missing_var = true;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$missing_files[] = $this->get_filename($lang_iso, 'acp', $file);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($mods_files))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
foreach ($mods_files as $file)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (file_exists($phpbb_root_path . $this->get_filename($lang_iso, 'mods', $file)))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$missing_vars['mods/' . $file] = $this->compare_language_files($config['default_lang'], $lang_iso, 'mods', $file);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($missing_vars['mods/' . $file]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$is_missing_var = true;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$missing_files[] = $this->get_filename($lang_iso, 'mods', $file);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// More missing files... for example email templates?
|
|
|
ef5584 |
foreach ($email_files as $file)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!file_exists($phpbb_root_path . $this->get_filename($lang_iso, 'email', $file)))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$missing_files[] = $this->get_filename($lang_iso, 'email', $file);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($missing_files))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'S_MISSING_FILES' => true,
|
|
|
ef5584 |
'L_MISSING_FILES' => sprintf($user->lang['THOSE_MISSING_LANG_FILES'], $lang_entries['lang_local_name']),
|
|
|
ef5584 |
'MISSING_FILES' => implode(' ', $missing_files))
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($is_missing_var)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'S_MISSING_VARS' => true,
|
|
|
ef5584 |
'L_MISSING_VARS_EXPLAIN' => sprintf($user->lang['THOSE_MISSING_LANG_VARIABLES'], $lang_entries['lang_local_name']),
|
|
|
ef5584 |
'U_MISSING_ACTION' => $this->u_action . "&action=$action&id=$lang_id")
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($missing_vars as $file => $vars)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!sizeof($vars))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
continue;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_block_vars('missing', array(
|
|
|
ef5584 |
'FILE' => $file,
|
|
|
ef5584 |
'TPL' => $this->print_language_entries($vars, '', false),
|
|
|
ef5584 |
'KEY' => (strpos($file, '/') === false) ? '|' . $file : str_replace('/', '|', $file))
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Main language files
|
|
|
ef5584 |
$s_lang_options = '<option value="|common.' . $phpEx . '" class="sep">' . $user->lang['LANGUAGE_FILES'] . '</option>';
|
|
|
ef5584 |
foreach ($this->main_files as $file)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (strpos($file, 'help_') === 0)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
continue;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$prefix = (file_exists($phpbb_root_path . $this->get_filename($lang_iso, '', $file, true, true))) ? '* ' : '';
|
|
|
ef5584 |
|
|
|
ef5584 |
$selected = (!$this->language_directory && $this->language_file == $file) ? ' selected="selected"' : '';
|
|
|
ef5584 |
$s_lang_options .= '<option value="|' . $file . '"' . $selected . '>' . $prefix . $file . '</option>';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Help Files
|
|
|
ef5584 |
$s_lang_options .= '<option value="|common.' . $phpEx . '" class="sep">' . $user->lang['HELP_FILES'] . '</option>';
|
|
|
ef5584 |
foreach ($this->main_files as $file)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (strpos($file, 'help_') !== 0)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
continue;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$prefix = (file_exists($phpbb_root_path . $this->get_filename($lang_iso, '', $file, true, true))) ? '* ' : '';
|
|
|
ef5584 |
|
|
|
ef5584 |
$selected = (!$this->language_directory && $this->language_file == $file) ? ' selected="selected"' : '';
|
|
|
ef5584 |
$s_lang_options .= '<option value="|' . $file . '"' . $selected . '>' . $prefix . $file . '</option>';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Now every other language directory
|
|
|
ef5584 |
$check_files = array('email', 'acp', 'mods');
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($check_files as $check)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!sizeof(${$check . '_files'}))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
continue;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$s_lang_options .= '<option value="|common.' . $phpEx . '" class="sep">' . $user->lang[strtoupper($check) . '_FILES'] . '</option>';
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach (${$check . '_files'} as $file)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$prefix = (file_exists($phpbb_root_path . $this->get_filename($lang_iso, $check, $file, true, true))) ? '* ' : '';
|
|
|
ef5584 |
|
|
|
ef5584 |
$selected = ($this->language_directory == $check && $this->language_file == $file) ? ' selected="selected"' : '';
|
|
|
ef5584 |
$s_lang_options .= '<option value="' . $check . '|' . $file . '"' . $selected . '>' . $prefix . $file . '</option>';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Get Language Entries - if saved within store folder, we take this one (with the option to remove it)
|
|
|
ef5584 |
$lang = array();
|
|
|
ef5584 |
|
|
|
ef5584 |
$is_email_file = ($this->language_directory == 'email') ? true : false;
|
|
|
ef5584 |
$is_help_file = (strpos($this->language_file, 'help_') === 0) ? true : false;
|
|
|
ef5584 |
|
|
|
ef5584 |
$file_from_store = (file_exists($phpbb_root_path . $this->get_filename($lang_iso, $this->language_directory, $this->language_file, true, true))) ? true : false;
|
|
|
ef5584 |
$no_store_filename = $this->get_filename($lang_iso, $this->language_directory, $this->language_file);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$file_from_store && !file_exists($phpbb_root_path . $no_store_filename))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$print_message = sprintf($user->lang['MISSING_LANGUAGE_FILE'], $no_store_filename);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($is_email_file)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$lang = file_get_contents($phpbb_root_path . $this->get_filename($lang_iso, $this->language_directory, $this->language_file, $file_from_store));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$help = array();
|
|
|
ef5584 |
include($phpbb_root_path . $this->get_filename($lang_iso, $this->language_directory, $this->language_file, $file_from_store));
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($is_help_file)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$lang = $help;
|
|
|
ef5584 |
unset($help);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$print_message = (($this->language_directory) ? $this->language_directory . '/' : '') . $this->language_file;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Normal language pack entries
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'U_ENTRY_ACTION' => $this->u_action . "&action=details&id=$lang_id#entries",
|
|
|
ef5584 |
'S_EMAIL_FILE' => $is_email_file,
|
|
|
ef5584 |
'S_FROM_STORE' => $file_from_store,
|
|
|
ef5584 |
'S_LANG_OPTIONS' => $s_lang_options,
|
|
|
ef5584 |
'PRINT_MESSAGE' => $print_message,
|
|
|
ef5584 |
)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$is_email_file)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$tpl = '';
|
|
|
ef5584 |
$name = (($this->language_directory) ? $this->language_directory . '/' : '') . $this->language_file;
|
|
|
ef5584 |
|
|
|
ef5584 |
if (isset($missing_vars[$name]) && sizeof($missing_vars[$name]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$tpl .= $this->print_language_entries($missing_vars[$name], '* ');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$tpl .= $this->print_language_entries($lang);
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_var('TPL', $tpl);
|
|
|
ef5584 |
unset($tpl);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'LANG' => $lang)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
unset($lang);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
return;
|
|
|
ef5584 |
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'delete':
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$lang_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'SELECT *
|
|
|
ef5584 |
FROM ' . LANG_TABLE . '
|
|
|
ef5584 |
WHERE lang_id = ' . $lang_id;
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$row = $db->sql_fetchrow($result);
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($row['lang_iso'] == $config['default_lang'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NO_REMOVE_DEFAULT_LANG'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$db->sql_query('DELETE FROM ' . LANG_TABLE . ' WHERE lang_id = ' . $lang_id);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'UPDATE ' . USERS_TABLE . "
|
|
|
ef5584 |
SET user_lang = '" . $db->sql_escape($config['default_lang']) . "'
|
|
|
ef5584 |
WHERE user_lang = '" . $db->sql_escape($row['lang_iso']) . "'";
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
// We also need to remove the translated entries for custom profile fields - we want clean tables, don't we?
|
|
|
ef5584 |
$sql = 'DELETE FROM ' . PROFILE_LANG_TABLE . ' WHERE lang_id = ' . $lang_id;
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . ' WHERE lang_id = ' . $lang_id;
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . " WHERE image_lang = '" . $db->sql_escape($row['lang_iso']) . "'";
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
$cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE);
|
|
|
ef5584 |
|
|
|
ef5584 |
add_log('admin', 'LOG_LANGUAGE_PACK_DELETED', $row['lang_english_name']);
|
|
|
ef5584 |
|
|
|
ef5584 |
trigger_error(sprintf($user->lang['LANGUAGE_PACK_DELETED'], $row['lang_english_name']) . adm_back_link($this->u_action));
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'install':
|
|
|
ef5584 |
$lang_iso = request_var('iso', '');
|
|
|
ef5584 |
$lang_iso = basename($lang_iso);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$lang_iso || !file_exists("{$phpbb_root_path}language/$lang_iso/iso.txt"))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['LANGUAGE_PACK_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$file = file("{$phpbb_root_path}language/$lang_iso/iso.txt");
|
|
|
ef5584 |
|
|
|
ef5584 |
$lang_pack = array(
|
|
|
ef5584 |
'iso' => $lang_iso,
|
|
|
ef5584 |
'name' => trim(htmlspecialchars($file[0])),
|
|
|
ef5584 |
'local_name'=> trim(htmlspecialchars($file[1], ENT_COMPAT, 'UTF-8')),
|
|
|
ef5584 |
'author' => trim(htmlspecialchars($file[2], ENT_COMPAT, 'UTF-8'))
|
|
|
ef5584 |
);
|
|
|
ef5584 |
unset($file);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'SELECT lang_iso
|
|
|
ef5584 |
FROM ' . LANG_TABLE . "
|
|
|
ef5584 |
WHERE lang_iso = '" . $db->sql_escape($lang_iso) . "'";
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$row = $db->sql_fetchrow($result);
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($row)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['LANGUAGE_PACK_ALREADY_INSTALLED'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$lang_pack['name'] || !$lang_pack['local_name'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['INVALID_LANGUAGE_PACK'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Add language pack
|
|
|
ef5584 |
$sql_ary = array(
|
|
|
ef5584 |
'lang_iso' => $lang_pack['iso'],
|
|
|
ef5584 |
'lang_dir' => $lang_pack['iso'],
|
|
|
ef5584 |
'lang_english_name' => $lang_pack['name'],
|
|
|
ef5584 |
'lang_local_name' => $lang_pack['local_name'],
|
|
|
ef5584 |
'lang_author' => $lang_pack['author']
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
$db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
|
|
|
ef5584 |
$lang_id = $db->sql_nextid();
|
|
|
ef5584 |
|
|
|
ef5584 |
$valid_localized = array(
|
|
|
ef5584 |
'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',
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql_ary = array();
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'SELECT *
|
|
|
ef5584 |
FROM ' . STYLES_IMAGESET_TABLE;
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
while ($imageset_row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (@file_exists("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/{$lang_pack['iso']}/imageset.cfg"))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$cfg_data_imageset_data = parse_cfg_file("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/{$lang_pack['iso']}/imageset.cfg");
|
|
|
ef5584 |
foreach ($cfg_data_imageset_data as $image_name => $value)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (strpos($value, '*') !== false)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (substr($value, -1, 1) === '*')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
list($image_filename, $image_height) = explode('*', $value);
|
|
|
ef5584 |
$image_width = 0;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
list($image_filename, $image_height, $image_width) = explode('*', $value);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$image_filename = $value;
|
|
|
ef5584 |
$image_height = $image_width = 0;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (strpos($image_name, 'img_') === 0 && $image_filename)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$image_name = substr($image_name, 4);
|
|
|
ef5584 |
if (in_array($image_name, $valid_localized))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql_ary[] = array(
|
|
|
ef5584 |
'image_name' => (string) $image_name,
|
|
|
ef5584 |
'image_filename' => (string) $image_filename,
|
|
|
ef5584 |
'image_height' => (int) $image_height,
|
|
|
ef5584 |
'image_width' => (int) $image_width,
|
|
|
ef5584 |
'imageset_id' => (int) $imageset_row['imageset_id'],
|
|
|
ef5584 |
'image_lang' => (string) $lang_pack['iso'],
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($sql_ary))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary);
|
|
|
ef5584 |
$cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Now let's copy the default language entries for custom profile fields for this new language - makes admin's life easier.
|
|
|
ef5584 |
$sql = 'SELECT lang_id
|
|
|
ef5584 |
FROM ' . LANG_TABLE . "
|
|
|
ef5584 |
WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'";
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$default_lang_id = (int) $db->sql_fetchfield('lang_id');
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
// From the mysql documentation:
|
|
|
ef5584 |
// 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.
|
|
|
ef5584 |
// Due to this we stay on the safe side if we do the insertion "the manual way"
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'SELECT field_id, lang_name, lang_explain, lang_default_value
|
|
|
ef5584 |
FROM ' . PROFILE_LANG_TABLE . '
|
|
|
ef5584 |
WHERE lang_id = ' . $default_lang_id;
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$row['lang_id'] = $lang_id;
|
|
|
ef5584 |
$db->sql_query('INSERT INTO ' . PROFILE_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $row));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'SELECT field_id, option_id, field_type, lang_value
|
|
|
ef5584 |
FROM ' . PROFILE_FIELDS_LANG_TABLE . '
|
|
|
ef5584 |
WHERE lang_id = ' . $default_lang_id;
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$row['lang_id'] = $lang_id;
|
|
|
ef5584 |
$db->sql_query('INSERT INTO ' . PROFILE_FIELDS_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $row));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
add_log('admin', 'LOG_LANGUAGE_PACK_INSTALLED', $lang_pack['name']);
|
|
|
ef5584 |
|
|
|
ef5584 |
trigger_error(sprintf($user->lang['LANGUAGE_PACK_INSTALLED'], $lang_pack['name']) . adm_back_link($this->u_action));
|
|
|
ef5584 |
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'download':
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$lang_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'SELECT *
|
|
|
ef5584 |
FROM ' . LANG_TABLE . '
|
|
|
ef5584 |
WHERE lang_id = ' . $lang_id;
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$row = $db->sql_fetchrow($result);
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
$use_method = request_var('use_method', '');
|
|
|
ef5584 |
$methods = array('.tar');
|
|
|
ef5584 |
|
|
|
ef5584 |
$available_methods = array('.tar.gz' => 'zlib', '.tar.bz2' => 'bz2', '.zip' => 'zlib');
|
|
|
ef5584 |
foreach ($available_methods as $type => $module)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!@extension_loaded($module))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
continue;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$methods[] = $type;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Let the user decide in which format he wants to have the pack
|
|
|
ef5584 |
if (!$use_method)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->page_title = 'SELECT_DOWNLOAD_FORMAT';
|
|
|
ef5584 |
|
|
|
ef5584 |
$radio_buttons = '';
|
|
|
ef5584 |
foreach ($methods as $method)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$radio_buttons .= '<label><input type="radio"' . ((!$radio_buttons) ? ' id="use_method"' : '') . ' class="radio" value="' . $method . '" name="use_method" /> ' . $method . '</label>';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'S_SELECT_METHOD' => true,
|
|
|
ef5584 |
'U_BACK' => $this->u_action,
|
|
|
ef5584 |
'U_ACTION' => $this->u_action . "&action=$action&id=$lang_id",
|
|
|
ef5584 |
'RADIO_BUTTONS' => $radio_buttons)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
return;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!in_array($use_method, $methods))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$use_method = '.tar';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
include_once($phpbb_root_path . 'includes/functions_compress.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($use_method == '.zip')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$compress = new compress_zip('w', $phpbb_root_path . 'store/lang_' . $row['lang_iso'] . $use_method);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$compress = new compress_tar('w', $phpbb_root_path . 'store/lang_' . $row['lang_iso'] . $use_method, $use_method);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Get email templates
|
|
|
ef5584 |
$email_templates = filelist($phpbb_root_path . 'language/' . $row['lang_iso'], 'email', 'txt');
|
|
|
ef5584 |
$email_templates = $email_templates['email/'];
|
|
|
ef5584 |
|
|
|
ef5584 |
// Get acp files
|
|
|
ef5584 |
$acp_files = filelist($phpbb_root_path . 'language/' . $row['lang_iso'], 'acp', $phpEx);
|
|
|
ef5584 |
$acp_files = $acp_files['acp/'];
|
|
|
ef5584 |
|
|
|
ef5584 |
// Get mod files
|
|
|
ef5584 |
$mod_files = filelist($phpbb_root_path . 'language/' . $row['lang_iso'], 'mods', $phpEx);
|
|
|
ef5584 |
$mod_files = (isset($mod_files['mods/'])) ? $mod_files['mods/'] : array();
|
|
|
ef5584 |
|
|
|
ef5584 |
// Add main files
|
|
|
ef5584 |
$this->add_to_archive($compress, $this->main_files, $row['lang_iso']);
|
|
|
ef5584 |
|
|
|
ef5584 |
// Add search files if they exist...
|
|
|
ef5584 |
if (file_exists($phpbb_root_path . 'language/' . $row['lang_iso'] . '/search_ignore_words.' . $phpEx))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->add_to_archive($compress, array("search_ignore_words.$phpEx"), $row['lang_iso']);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (file_exists($phpbb_root_path . 'language/' . $row['lang_iso'] . '/search_synonyms.' . $phpEx))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->add_to_archive($compress, array("search_synonyms.$phpEx"), $row['lang_iso']);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Write files in folders
|
|
|
ef5584 |
$this->add_to_archive($compress, $email_templates, $row['lang_iso'], 'email');
|
|
|
ef5584 |
$this->add_to_archive($compress, $acp_files, $row['lang_iso'], 'acp');
|
|
|
ef5584 |
$this->add_to_archive($compress, $mod_files, $row['lang_iso'], 'mods');
|
|
|
ef5584 |
|
|
|
ef5584 |
// Write ISO File
|
|
|
ef5584 |
$iso_src = htmlspecialchars_decode($row['lang_english_name']) . "\n";
|
|
|
ef5584 |
$iso_src .= htmlspecialchars_decode($row['lang_local_name']) . "\n";
|
|
|
ef5584 |
$iso_src .= htmlspecialchars_decode($row['lang_author']);
|
|
|
ef5584 |
$compress->add_data($iso_src, 'language/' . $row['lang_iso'] . '/iso.txt');
|
|
|
ef5584 |
|
|
|
ef5584 |
// index.html files
|
|
|
ef5584 |
$compress->add_data('', 'language/' . $row['lang_iso'] . '/index.html');
|
|
|
ef5584 |
$compress->add_data('', 'language/' . $row['lang_iso'] . '/email/index.html');
|
|
|
ef5584 |
$compress->add_data('', 'language/' . $row['lang_iso'] . '/acp/index.html');
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($mod_files))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$compress->add_data('', 'language/' . $row['lang_iso'] . '/mods/index.html');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$compress->close();
|
|
|
ef5584 |
|
|
|
ef5584 |
$compress->download('lang_' . $row['lang_iso']);
|
|
|
ef5584 |
@unlink($phpbb_root_path . 'store/lang_' . $row['lang_iso'] . $use_method);
|
|
|
ef5584 |
|
|
|
ef5584 |
exit;
|
|
|
ef5584 |
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'SELECT user_lang, COUNT(user_lang) AS lang_count
|
|
|
ef5584 |
FROM ' . USERS_TABLE . '
|
|
|
ef5584 |
GROUP BY user_lang';
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
$lang_count = array();
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$lang_count[$row['user_lang']] = $row['lang_count'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'SELECT *
|
|
|
ef5584 |
FROM ' . LANG_TABLE . '
|
|
|
ef5584 |
ORDER BY lang_english_name';
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
$installed = array();
|
|
|
ef5584 |
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$installed[] = $row['lang_iso'];
|
|
|
ef5584 |
$tagstyle = ($row['lang_iso'] == $config['default_lang']) ? '*' : '';
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_block_vars('lang', array(
|
|
|
ef5584 |
'U_DETAILS' => $this->u_action . "&action=details&id={$row['lang_id']}",
|
|
|
ef5584 |
'U_DOWNLOAD' => $this->u_action . "&action=download&id={$row['lang_id']}",
|
|
|
ef5584 |
'U_DELETE' => $this->u_action . "&action=delete&id={$row['lang_id']}",
|
|
|
ef5584 |
|
|
|
ef5584 |
'ENGLISH_NAME' => $row['lang_english_name'],
|
|
|
ef5584 |
'TAG' => $tagstyle,
|
|
|
ef5584 |
'LOCAL_NAME' => $row['lang_local_name'],
|
|
|
ef5584 |
'ISO' => $row['lang_iso'],
|
|
|
ef5584 |
'USED_BY' => (isset($lang_count[$row['lang_iso']])) ? $lang_count[$row['lang_iso']] : 0,
|
|
|
ef5584 |
));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
$new_ary = $iso = array();
|
|
|
ef5584 |
$dp = @opendir("{$phpbb_root_path}language");
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($dp)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
while (($file = readdir($dp)) !== false)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($file[0] != '.' && file_exists("{$phpbb_root_path}language/$file/iso.txt"))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!in_array($file, $installed))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($iso = file("{$phpbb_root_path}language/$file/iso.txt"))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (sizeof($iso) == 3)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$new_ary[$file] = array(
|
|
|
ef5584 |
'iso' => $file,
|
|
|
ef5584 |
'name' => trim($iso[0]),
|
|
|
ef5584 |
'local_name'=> trim($iso[1]),
|
|
|
ef5584 |
'author' => trim($iso[2])
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
closedir($dp);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
unset($installed);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($new_ary))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
foreach ($new_ary as $iso => $lang_ary)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_block_vars('notinst', array(
|
|
|
ef5584 |
'ISO' => htmlspecialchars($lang_ary['iso']),
|
|
|
ef5584 |
'LOCAL_NAME' => htmlspecialchars($lang_ary['local_name'], ENT_COMPAT, 'UTF-8'),
|
|
|
ef5584 |
'NAME' => htmlspecialchars($lang_ary['name'], ENT_COMPAT, 'UTF-8'),
|
|
|
ef5584 |
'U_INSTALL' => $this->u_action . '&action=install&iso=' . urlencode($lang_ary['iso']))
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
unset($new_ary);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Set default language variables/header
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function default_variables()
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $phpEx;
|
|
|
ef5584 |
|
|
|
ef5584 |
$this->language_file_header = '
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
*
|
|
|
ef5584 |
* {FILENAME} [{LANG_NAME}]
|
|
|
ef5584 |
*
|
|
|
ef5584 |
* @package language
|
|
|
ef5584 |
* @version $' . 'Id: ' . '$
|
|
|
ef5584 |
* @copyright (c) ' . date('Y') . ' phpBB Group
|
|
|
ef5584 |
* @author {CHANGED} - {AUTHOR}
|
|
|
ef5584 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
ef5584 |
*
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* DO NOT CHANGE
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
if (!defined(\'IN_PHPBB\'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
exit;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (empty($lang) || !is_array($lang))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$lang = array();
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// DEVELOPERS PLEASE NOTE
|
|
|
ef5584 |
//
|
|
|
ef5584 |
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
|
|
|
ef5584 |
//
|
|
|
ef5584 |
// Placeholders can now contain order information, e.g. instead of
|
|
|
ef5584 |
// \'Page %s of %s\' you can (and should) write \'Page %1$s of %2$s\', this allows
|
|
|
ef5584 |
// translators to re-order the output of data while ensuring it remains correct
|
|
|
ef5584 |
//
|
|
|
ef5584 |
// You do not need this where single placeholders are used, e.g. \'Message %d\' is fine
|
|
|
ef5584 |
// equally where a string contains only two placeholders which are used to wrap text
|
|
|
ef5584 |
// in a url you again do not need to specify an order e.g., \'Click %sHERE%s\' is fine
|
|
|
ef5584 |
';
|
|
|
ef5584 |
|
|
|
ef5584 |
$this->lang_header = '
|
|
|
ef5584 |
$lang = array_merge($lang, array(
|
|
|
ef5584 |
';
|
|
|
ef5584 |
|
|
|
ef5584 |
// Language files in language root directory
|
|
|
ef5584 |
$this->main_files = array("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");
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Get filename/location of language file
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function get_filename($lang_iso, $directory, $filename, $check_store = false, $only_return_filename = false)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $phpbb_root_path, $safe_mode;
|
|
|
ef5584 |
|
|
|
ef5584 |
$check_filename = "language/$lang_iso/" . (($directory) ? $directory . '/' : '') . $filename;
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($check_store)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$check_store_filename = ($safe_mode) ? "store/langfile_{$lang_iso}" . (($directory) ? '_' . $directory : '') . "_{$filename}" : "store/language/$lang_iso/" . (($directory) ? $directory . '/' : '') . $filename;
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$only_return_filename && file_exists($phpbb_root_path . $check_store_filename))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
return $check_store_filename;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else if ($only_return_filename)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
return $check_store_filename;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
return $check_filename;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Add files to archive
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function add_to_archive(&$compress, $filelist, $lang_iso, $directory = '')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $phpbb_root_path;
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($filelist as $file)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Get source filename
|
|
|
ef5584 |
$source = $this->get_filename($lang_iso, $directory, $file, true);
|
|
|
ef5584 |
$destination = 'language/' . $lang_iso . '/' . (($directory) ? $directory . '/' : '') . $file;
|
|
|
ef5584 |
|
|
|
ef5584 |
// Add file to archive
|
|
|
ef5584 |
$compress->add_custom_file($phpbb_root_path . $source, $destination);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Little helper to add some hardcoded template bits
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function add_input_field()
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$keys = func_get_args();
|
|
|
ef5584 |
|
|
|
ef5584 |
$non_static = array_shift($keys);
|
|
|
ef5584 |
$value = array_shift($keys);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$non_static)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
return '' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// If more then 270 characters, then we present a textarea, else an input field
|
|
|
ef5584 |
$textarea = (utf8_strlen($value) > 270) ? true : false;
|
|
|
ef5584 |
$tpl = '';
|
|
|
ef5584 |
|
|
|
ef5584 |
$tpl .= ($textarea) ? '
|
|
|
ef5584 |
$tpl .= 'entry[' . implode('][', array_map('utf8_htmlspecialchars', $keys)) . ']"';
|
|
|
ef5584 |
|
|
|
ef5584 |
$tpl .= ($textarea) ? ' cols="80" rows="5" class="langvalue">' : ' class="langvalue" value="';
|
|
|
ef5584 |
$tpl .= htmlspecialchars($value, ENT_COMPAT, 'UTF-8');
|
|
|
ef5584 |
$tpl .= ($textarea) ? '</textarea>' : '" />';
|
|
|
ef5584 |
|
|
|
ef5584 |
return $tpl;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Print language entries
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function print_language_entries(&$lang_ary, $key_prefix = '', $input_field = true)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$tpl = '';
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($lang_ary as $key => $value)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (is_array($value))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Write key
|
|
|
ef5584 |
$tpl .= '
|
|
|
ef5584 |
|
|
|
ef5584 |
' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . '' . htmlspecialchars($key, ENT_COMPAT, 'UTF-8') . '
|
|
|
ef5584 |
';
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($value as $_key => $_value)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (is_array($_value))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Write key
|
|
|
ef5584 |
$tpl .= '
|
|
|
ef5584 |
|
|
|
ef5584 |
' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . ' ' . htmlspecialchars($_key, ENT_COMPAT, 'UTF-8') . '
|
|
|
ef5584 |
';
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($_value as $__key => $__value)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Write key
|
|
|
ef5584 |
$tpl .= '
|
|
|
ef5584 |
|
|
|
ef5584 |
' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . '' . htmlspecialchars($__key, ENT_COMPAT, 'UTF-8') . '
|
|
|
ef5584 |
';
|
|
|
ef5584 |
|
|
|
ef5584 |
$tpl .= $this->add_input_field($input_field, $__value, $key, $_key, $__key);
|
|
|
ef5584 |
|
|
|
ef5584 |
$tpl .= '
|
|
|
ef5584 |
';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Write key
|
|
|
ef5584 |
$tpl .= '
|
|
|
ef5584 |
|
|
|
ef5584 |
' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . '' . htmlspecialchars($_key, ENT_COMPAT, 'UTF-8') . '
|
|
|
ef5584 |
';
|
|
|
ef5584 |
|
|
|
ef5584 |
$tpl .= $this->add_input_field($input_field, $_value, $key, $_key);
|
|
|
ef5584 |
|
|
|
ef5584 |
$tpl .= '
|
|
|
ef5584 |
';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$tpl .= '
|
|
|
ef5584 |
|
|
|
ef5584 |
|
|
|
ef5584 |
';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Write key
|
|
|
ef5584 |
$tpl .= '
|
|
|
ef5584 |
|
|
|
ef5584 |
' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . '' . htmlspecialchars($key, ENT_COMPAT, 'UTF-8') . '
|
|
|
ef5584 |
';
|
|
|
ef5584 |
|
|
|
ef5584 |
$tpl .= $this->add_input_field($input_field, $value, $key);
|
|
|
ef5584 |
|
|
|
ef5584 |
$tpl .= '
|
|
|
ef5584 |
';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
return $tpl;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Compare two language files
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function compare_language_files($source_lang, $dest_lang, $directory, $file)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $phpbb_root_path, $phpEx;
|
|
|
ef5584 |
|
|
|
ef5584 |
$return_ary = array();
|
|
|
ef5584 |
|
|
|
ef5584 |
$lang = array();
|
|
|
ef5584 |
include("{$phpbb_root_path}language/{$source_lang}/" . (($directory) ? $directory . '/' : '') . $file);
|
|
|
ef5584 |
$lang_entry_src = $lang;
|
|
|
ef5584 |
|
|
|
ef5584 |
$lang = array();
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!file_exists($phpbb_root_path . $this->get_filename($dest_lang, $directory, $file, true)))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
return array();
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
include($phpbb_root_path . $this->get_filename($dest_lang, $directory, $file, true));
|
|
|
ef5584 |
|
|
|
ef5584 |
$lang_entry_dst = $lang;
|
|
|
ef5584 |
|
|
|
ef5584 |
unset($lang);
|
|
|
ef5584 |
|
|
|
ef5584 |
$diff_array_keys = array_diff(array_keys($lang_entry_src), array_keys($lang_entry_dst));
|
|
|
ef5584 |
unset($lang_entry_dst);
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($diff_array_keys as $key)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$return_ary[$key] = $lang_entry_src[$key];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
unset($lang_entry_src);
|
|
|
ef5584 |
|
|
|
ef5584 |
return $return_ary;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Return language string value for storage
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function prepare_lang_entry($text, $store = true)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$text = (STRIP) ? stripslashes($text) : $text;
|
|
|
ef5584 |
|
|
|
ef5584 |
// Adjust for storage...
|
|
|
ef5584 |
if ($store)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$text = str_replace("'", "\\'", str_replace('\\', '\\\\', $text));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
return $text;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Format language array for storage
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function format_lang_array($key, $value, $tabs = "\t")
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$entry = '';
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!is_array($value))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$entry .= "{$tabs}'" . $this->prepare_lang_entry($key) . "'\t=> '" . $this->prepare_lang_entry($value) . "',\n";
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$_tabs = $tabs . "\t";
|
|
|
ef5584 |
$entry .= "\n{$tabs}'" . $this->prepare_lang_entry($key) . "'\t=> array(\n";
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($value as $_key => $_value)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$entry .= $this->format_lang_array($_key, $_value, $_tabs);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$entry .= "{$tabs}),\n\n";
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
return $entry;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
?>
|