diff --git a/phpBB/adm/style/acp_language.html b/phpBB/adm/style/acp_language.html
index 2897abc2bf..5779506339 100644
--- a/phpBB/adm/style/acp_language.html
+++ b/phpBB/adm/style/acp_language.html
@@ -111,12 +111,12 @@
-
+
-
+
+
+ « {L_BACK}
+ {L_UPLOAD_SETTINGS}
+
+
{L_ACP_LANGUAGE_PACKS}
diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php
index b0a52eb64d..8e9662b806 100644
--- a/phpBB/includes/acp/acp_language.php
+++ b/phpBB/includes/acp/acp_language.php
@@ -36,6 +36,8 @@ class acp_language
$action = (isset($_POST['update_details'])) ? 'update_details' : $action;
$action = (isset($_POST['download_file'])) ? 'download_file' : $action;
+ $action = (isset($_POST['upload_file'])) ? 'upload_file' : $action;
+ $action = (isset($_POST['upload_data'])) ? 'upload_data' : $action;
$action = (isset($_POST['submit_file'])) ? 'submit_file' : $action;
$action = (isset($_POST['remove_store'])) ? 'details' : $action;
@@ -55,8 +57,106 @@ class acp_language
$this->tpl_name = 'acp_language';
$this->page_title = 'ACP_LANGUAGE_PACKS';
+ $u_action = "{$phpbb_admin_path}index.$phpEx$SID&i=$id&mode=$mode";
+
+ if ($action == 'upload_data' && request_var('test_connection', ''))
+ {
+ $test_connection = false;
+
+ $action = 'upload_file';
+
+ $method = request_var('method', '');
+
+ include_once($phpbb_root_path . 'includes/functions_transfer.' . $phpEx);
+
+ switch ($method)
+ {
+ case 'ftp':
+ $transfer = new ftp(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', ''));
+ break;
+ default:
+ trigger_error($user->lang['INVALID_UPLOAD_METHOD']);
+ }
+
+ $test_connection = $transfer->open_session();
+ $transfer->close_session();
+ }
+
switch ($action)
{
+ case 'upload_data':
+ if (!$lang_id)
+ {
+ trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($u_action));
+ }
+
+ $sql = 'SELECT lang_iso FROM ' . LANG_TABLE . "
+ WHERE lang_id = $lang_id";
+ $result = $db->sql_query($sql);
+ $row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+
+ $file = request_var('file', '');
+ $dir = request_var('dir', '');
+
+ $old_file = '/' . $this->get_filename($row['lang_iso'], $dir, $file, false, true);
+ $lang_path = 'language/' . $row['lang_iso'] . '/' . (($dir) ? $dir . '/' : '');
+
+ include_once($phpbb_root_path . 'includes/functions_transfer.' . $phpEx);
+ $method = request_var('method', '');
+
+ switch ($method)
+ {
+ case 'ftp':
+ $transfer = new ftp(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', ''));
+ break;
+ default:
+ trigger_error($user->lang['INVALID_UPLOAD_METHOD']);
+ }
+
+ if (!$transfer->open_session())
+ {
+ trigger_error($user->lang['ERR_CONNECTING_SERVER'] . adm_back_link($this->u_action));
+ }
+
+ $transfer->rename($lang_path . $file, $lang_path . $file . '.bak');
+ $transfer->copy_file('store/' . $lang_path . $file, $lang_path . $file);
+ $transfer->close_session();
+
+ add_log('admin', 'LOG_LANGUAGE_FILE_REPLACED', $file);
+
+ trigger_error($user->lang['UPLOAD_COMPLETED']);
+ break;
+
+ case 'upload_file':
+ include_once($phpbb_root_path . 'includes/functions_transfer.' . $phpEx);
+
+ $method = request_var('method', '');
+
+ $requested_data = call_user_func(array($method, 'data'));
+ foreach ($requested_data as $data => $default)
+ {
+ $template->assign_block_vars('data', array(
+ 'DATA' => $data,
+ 'NAME' => $user->lang[strtoupper($method . '_' . $data)],
+ 'EXPLAIN' => $user->lang[strtoupper($method . '_' . $data) . '_EXPLAIN'],
+ 'DEFAULT' => $_REQUEST[$data] ? request_var($data, '') : $default
+ ));
+ }
+
+ $hidden_data = build_hidden_fields(array('file' => $this->language_file, 'dir' => $this->language_directory, 'method' => $method));
+
+ $template->assign_vars(array(
+ 'S_UPLOAD' => true,
+ 'NAME' => $method,
+ 'U_ACTION' => $this->u_action . "&id=$lang_id&action=upload_data",
+ 'HIDDEN' => $hidden_data,
+
+ 'S_CONNECTION_SUCCESS' => (request_var('test_connection', '') && $test_connection === true) ? true : false,
+ 'S_CONNECTION_FAILED' => (request_var('test_connection', '') && $test_connection === false) ? true : false
+ ));
+ break;
+
case 'update_details':
if (!$lang_id)
@@ -297,6 +397,17 @@ class acp_language
@unlink($phpbb_root_path . $store_filename);
}
+ include_once($phpbb_root_path . 'includes/functions_transfer.' . $phpEx);
+
+ $methods = transfer::methods();
+
+ foreach ($methods as $method)
+ {
+ $template->assign_block_vars('buttons', array(
+ 'VALUE' => $method
+ ));
+ }
+
$template->assign_vars(array(
'S_DETAILS' => true,
'U_ACTION' => $this->u_action . "&action=details&id=$lang_id",
@@ -305,6 +416,7 @@ class acp_language
'LANG_ENGLISH_NAME' => $lang_entries['lang_english_name'],
'LANG_ISO' => $lang_entries['lang_iso'],
'LANG_AUTHOR' => $lang_entries['lang_author'],
+ 'ALLOW_UPLOAD' => sizeof($methods)
)
);
@@ -824,6 +936,14 @@ class acp_language
*
*/
+/**
+* DO NOT CHANGE
+*/
+if (empty($lang) || !is_array($lang))
+{
+ $lang = array();
+}
+
// DEVELOPERS PLEASE NOTE
//
// Placeholders can now contain order information, e.g. instead of
@@ -836,16 +956,7 @@ class acp_language
';
$this->lang_header = '
-
-/**
-* DO NOT CHANGE
-*/
-if (empty($lang) || !is_array($lang))
-{
- $lang = array();
-}
-
-$lang += array(
+$lang = array_merge($lang, array(
';
// Language files in language root directory
diff --git a/phpBB/includes/functions_transfer.php b/phpBB/includes/functions_transfer.php
index a7e3277196..dca6391e4e 100644
--- a/phpBB/includes/functions_transfer.php
+++ b/phpBB/includes/functions_transfer.php
@@ -178,6 +178,18 @@ class transfer
return $this->_rmdir($dir);
}
+ /**
+ * Rename a file or folder
+ */
+ function rename($old_handle, $new_handle)
+ {
+ global $phpbb_root_path;
+
+ $old_handle = $this->root_path . '/' . str_replace($phpbb_root_path, '', $old_handle);
+
+ return $this->_rename($old_handle, $new_handle);
+ }
+
/**
* Open session
*/
@@ -228,9 +240,21 @@ class ftp extends transfer
$this->timeout = $timeout;
$this->root_path = (($root_path{0} != '/' ) ? '/' : '') . ((substr($root_path, -1, 1) == '/') ? substr($root_path, 0, -1) : $root_path);
+ // Init some needed values
+ transfer::transfer();
+
return;
}
+ /**
+ * Requests data
+ */
+ function data()
+ {
+ global $config;
+ return array('host' => 'localhost' , 'username' => 'anonymous', 'password' => '', 'root_path' => $config['script_path'], 'port' => 21, 'timeout' => 10);
+ }
+
/**
* Init FTP Session
*/
@@ -278,6 +302,14 @@ class ftp extends transfer
return @ftp_rmdir($this->connection, $dir);
}
+ /**
+ * Remove directory (RMDIR)
+ */
+ function _rename($old_handle, $new_handle)
+ {
+ return @ftp_rename($this->connection, $old_handle, $new_handle);
+ }
+
/**
* Change current working directory (CHDIR)
*/
@@ -296,9 +328,15 @@ class ftp extends transfer
*/
function _chmod($file, $perms)
{
- $chmod_cmd = 'CHMOD 0' . $perms . ' ' . $file;
- $err = $this->_site($chmod_cmd);
-
+ if (function_exists('ftp_chmod'))
+ {
+ $err = @ftp_chmod($this->connection, $perms, $file);
+ }
+ else
+ {
+ $chmod_cmd = 'CHMOD 0' . $perms . ' ' . $file;
+ $err = $this->_site($chmod_cmd);
+ }
return $err;
}
diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php
index e22559e8cb..d796137bf3 100644
--- a/phpBB/language/en/acp/common.php
+++ b/phpBB/language/en/acp/common.php
@@ -415,6 +415,7 @@ $lang = array_merge($lang, array(
'LOG_LANGUAGE_PACK_DELETED' => 'Deleted language pack
» %s',
'LOG_LANGUAGE_PACK_INSTALLED' => 'Installed language pack
» %s',
'LOG_LANGUAGE_PACK_UPDATED' => 'Updated language pack details
» %s',
+ 'LOG_LANGUAGE_FILE_REPLACED' => 'Replaced language file
» %s',
'LOG_MASS_EMAIL' => 'Sent mass email
» %s',
diff --git a/phpBB/language/en/acp/language.php b/phpBB/language/en/acp/language.php
index 26e1e86e5c..8cebfdf16a 100644
--- a/phpBB/language/en/acp/language.php
+++ b/phpBB/language/en/acp/language.php
@@ -37,10 +37,13 @@ $lang = array_merge($lang, array(
'FILE_CONTENTS' => 'File Contents',
'FILE_FROM_STORAGE' => 'File from storage folder',
+ 'TEST_CONNECTION' => 'Test Connection',
+
'HELP_FILES' => 'Help Files',
'INSTALLED_LANGUAGE_PACKS' => 'Installed language packs',
'INVALID_LANGUAGE_PACK' => 'The selected language pack seems to be not valid. Please verify the language pack and upload it again if necessary.',
+ 'INVALID_UPLOAD_METHOD' => 'The selected upload method is not valid, please choose a different method.',
'LANGUAGE_DETAILS_UPDATED' => 'Language details successfully updated',
'LANGUAGE_ENTRIES' => 'Language Entries',
@@ -74,12 +77,17 @@ $lang = array_merge($lang, array(
'SELECT_DOWNLOAD_FORMAT' => 'Select download format',
'SUBMIT_AND_DOWNLOAD' => 'Submit and Download File',
+ 'SUBMIT_AND_UPLOAD' => 'Submit and Upload File',
'THOSE_MISSING_LANG_FILES' => 'The following language files are missing from the %s language folder',
'THOSE_MISSING_LANG_VARIABLES' => 'The following language variables are missing from the %s language pack',
'UNINSTALLED_LANGUAGE_PACKS' => 'Uninstalled language packs',
+ 'UPLOAD_COMPLETED' => 'The upload has completed',
+ 'UPLOAD_METHOD' => 'Upload method',
+ 'UPLOAD_SETTINGS' => 'Upload settings',
+
'WRONG_LANGUAGE_FILE' => 'Selected language file is invalid',
));
diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php
index fa6032b8dc..7d495a7444 100644
--- a/phpBB/language/en/common.php
+++ b/phpBB/language/en/common.php
@@ -92,6 +92,8 @@ $lang = array_merge($lang, array(
'CLICK_VIEW_PRIVMSG' => 'Click %sHere%s to visit your Inbox',
'CONFIRM' => 'Confirm',
'CONGRATULATIONS' => 'Congratulations to',
+ 'CONNECTION_FAILED' => 'Connection failed',
+ 'CONNECTION_SUCCESS' => 'Connection was successful!',
'COOKIES_DELETED' => 'All Board Cookies successfully deleted.',
'CURRENT_TIME' => 'The time is %s',
@@ -119,6 +121,7 @@ $lang = array_merge($lang, array(
'EMAIL_ADDRESS' => 'Email address',
'EMPTY_SUBJECT' => 'You must specify a subject when posting a new topic.',
'ENABLED' => 'Enabled',
+ 'ERR_CONNECTING_SERVER' => 'Error connecting to the server',
'EXTENSION' => 'Extension',
'EXTENSION_DISABLED_AFTER_POSTING' => 'The extension %s has been deactivated and can no longer be displayed',
@@ -141,6 +144,19 @@ $lang = array_merge($lang, array(
'FORUM_RULES_LINK' => 'Please click to view the forum rules',
'FROM' => 'from',
+ 'FTP_HOST' => 'FTP Host',
+ 'FTP_HOST_EXPLAIN' => 'FTP Server used to connect your site',
+ 'FTP_PASSWORD' => 'FTP Password',
+ 'FTP_PASSWORD_EXPLAIN' => 'Password for your FTP Username',
+ 'FTP_PORT' => 'FTP Port',
+ 'FTP_PORT_EXPLAIN' => 'Port used to connect to your server',
+ 'FTP_ROOT_PATH' => 'Path to phpBB',
+ 'FTP_ROOT_PATH_EXPLAIN' => 'Path from the root to your phpBB board',
+ 'FTP_TIMEOUT' => 'FTP Timeout',
+ 'FTP_TIMEOUT_EXPLAIN' => 'The amount of time, in seconds, that the system will wait for a reply from your server',
+ 'FTP_USERNAME' => 'FTP Username',
+ 'FTP_USERNAME_EXPLAIN' => 'Username used to connect to your server',
+
'GO' => 'Go',
'GOTO_PAGE' => 'Goto page',
'GROUP' => 'Group',