aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/acp/acp_language.php139
-rw-r--r--phpBB/includes/functions.php39
-rw-r--r--phpBB/includes/functions_transfer.php28
3 files changed, 121 insertions, 85 deletions
diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php
index 9c32aa74db..78b6f89cd9 100644
--- a/phpBB/includes/acp/acp_language.php
+++ b/phpBB/includes/acp/acp_language.php
@@ -71,6 +71,10 @@ class acp_language
$transfer = new ftp(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', ''));
break;
+ case 'ftp_fsock':
+ $transfer = new ftp_fsock(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']);
}
@@ -97,23 +101,13 @@ class acp_language
));
}
- $entry = $_POST['entry'];
- foreach ($entry as $key => $value)
- {
- if (is_array($value))
- {
- foreach ($value as $key2 => $data)
- {
- $entry[$key][$key2] = htmlentities($data);
- }
- }
- else
- {
- $entry[$key] = htmlentities($value);
- }
- }
-
- $hidden_data = build_hidden_fields(array('file' => $this->language_file, 'dir' => $this->language_directory, 'method' => $method, 'entry' => $entry));
+ $hidden_data = build_hidden_fields(array(
+ 'file' => $this->language_file,
+ 'dir' => $this->language_directory,
+ 'method' => $method,
+ 'entry' => $_POST['entry']),
+ true
+ );
$template->assign_vars(array(
'S_UPLOAD' => true,
@@ -210,7 +204,7 @@ class acp_language
if ($this->language_directory == 'email')
{
// Email Template
- $entry = (STRIP) ? stripslashes($_POST['entry']) : $_POST['entry'];
+ $entry = $this->prepare_lang_entry($_POST['entry'], false);
fwrite($fp, $entry);
}
else
@@ -228,20 +222,17 @@ class acp_language
{
if (!is_array($value))
{
+ continue;
}
- else
- {
- $entry = "\tarray(\n";
-
- foreach ($value as $_key => $_value)
- {
- $_value = (STRIP) ? stripslashes($_value) : $_value;
- $entry .= "\t\t" . (int) $_key . "\t=> '" . str_replace("'", "\\'", $_value) . "',\n";
- }
- $entry .= "\t),\n";
+ $entry = "\tarray(\n";
+
+ foreach ($value as $_key => $_value)
+ {
+ $entry .= "\t\t" . (int) $_key . "\t=> '" . $this->prepare_lang_entry($_value) . "',\n";
}
+ $entry .= "\t),\n";
fwrite($fp, $entry);
}
}
@@ -253,45 +244,13 @@ class acp_language
foreach ($_POST['entry'] as $key => $value)
{
- if (!is_array($value))
- {
- $value = (STRIP) ? stripslashes($value) : $value;
- $entry = "\t'" . $key . "'\t=> '" . str_replace("'", "\\'", $value) . "',\n";
- }
- else
- {
- $entry = "\n\t'" . $key . "'\t=> array(\n";
-
- foreach ($value as $_key => $_value)
- {
- if (!is_array($_value))
- {
- $_value = (STRIP) ? stripslashes($_value) : $_value;
- $entry .= "\t\t'" . $_key . "'\t=> '" . str_replace("'", "\\'", $_value) . "',\n";
- }
- else
- {
- $entry .= "\n\t\t'" . $_key . "'\t=> array(\n";
-
- foreach ($_value as $__key => $__value)
- {
- $__value = (STRIP) ? stripslashes($__value) : $__value;
- $entry .= "\t\t\t'" . $__key . "'\t=> '" . str_replace("'", "\\'", $__value) . "',\n";
- }
-
- $entry .= "\t\t),\n\n";
- }
- }
-
- $entry .= "\t),\n\n";
- }
-
+ $entry = $this->format_lang_array($key, $value);
fwrite($fp, $entry);
- }
+ }
}
$footer = "));\n\n?>";
- fwrite($fp, $footer);
+ fwrite($fp, $footer);
}
fclose($fp);
@@ -313,7 +272,8 @@ class acp_language
}
else if ($action == 'upload_data')
{
- $sql = 'SELECT lang_iso FROM ' . LANG_TABLE . "
+ $sql = 'SELECT lang_iso
+ FROM ' . LANG_TABLE . "
WHERE lang_id = $lang_id";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
@@ -333,6 +293,11 @@ class acp_language
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;
+
+ case 'ftp_fsock':
+ $transfer = new ftp_fsock(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']);
}
@@ -346,6 +311,9 @@ class acp_language
$transfer->copy_file('store/' . $lang_path . $file, $lang_path . $file);
$transfer->close_session();
+ // Remove from storage folder
+ @unlink($phpbb_root_path . 'store/' . $lang_path . $file);
+
add_log('admin', 'LOG_LANGUAGE_FILE_REPLACED', $file);
trigger_error($user->lang['UPLOAD_COMPLETED']);
@@ -1232,6 +1200,49 @@ $lang = array_merge($lang, array(
return $return_ary;
}
+
+ /**
+ * Return language string value for storage
+ */
+ function prepare_lang_entry($text, $store = true)
+ {
+ $text = (STRIP) ? stripslashes($text) : $text;
+
+ // Adjust for storage...
+ if ($store)
+ {
+ $text = str_replace("'", "\\'", str_replace('\\', '\\\\', $text));
+ }
+
+ return $text;
+ }
+
+ /**
+ * Format language array for storage
+ */
+ function format_lang_array($key, $value, $tabs = "\t")
+ {
+ $entry = '';
+
+ if (!is_array($value))
+ {
+ $entry .= "{$tabs}'{$key}'\t=> '" . $this->prepare_lang_entry($value) . "',\n";
+ }
+ else
+ {
+ $_tabs = $tabs . "\t";
+ $entry .= "\n{$tabs}'{$key}'\t=> array(\n";
+
+ foreach ($value as $_key => $_value)
+ {
+ $entry .= $this->format_lang_array($_key, $_value, $_tabs);
+ }
+
+ $entry .= "{$tabs}),\n\n";
+ }
+
+ return $entry;
+ }
}
?> \ No newline at end of file
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 4f62fa3100..86f002d14e 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -2073,25 +2073,40 @@ function extension_allowed($forum_id, $extension, &$extensions)
// Little helpers
/**
+* Little helper for the build_hidden_fields function
+*/
+function _build_hidden_fields($key, $value, $specialchar)
+{
+ $hidden_fields = '';
+
+ if (!is_array($value))
+ {
+ $key = ($specialchar) ? htmlspecialchars($key) : $key;
+ $value = ($specialchar) ? htmlspecialchars($value) : $value;
+
+ $hidden_fields .= '<input type="hidden" name="' . $key . '" value="' . $value . '" />' . "\n";
+ }
+ else
+ {
+ foreach ($value as $_key => $_value)
+ {
+ $hidden_fields .= _build_hidden_fields($key . '[' . $_key . ']', $_value, $specialchar);
+ }
+ }
+
+ return $hidden_fields;
+}
+
+/**
* Build simple hidden fields from array
*/
-function build_hidden_fields($field_ary)
+function build_hidden_fields($field_ary, $specialchar = false)
{
$s_hidden_fields = '';
foreach ($field_ary as $name => $vars)
{
- if (is_array($vars))
- {
- foreach ($vars as $key => $value)
- {
- $s_hidden_fields .= '<input type="hidden" name="' . $name . '[' . $key . ']" value="' . $value . '" />';
- }
- }
- else
- {
- $s_hidden_fields .= '<input type="hidden" name="' . $name . '" value="' . $vars . '" />';
- }
+ $s_hidden_fields .= _build_hidden_fields($name, $vars, $specialchar);
}
return $s_hidden_fields;
diff --git a/phpBB/includes/functions_transfer.php b/phpBB/includes/functions_transfer.php
index 190447829f..d2cc95f728 100644
--- a/phpBB/includes/functions_transfer.php
+++ b/phpBB/includes/functions_transfer.php
@@ -245,7 +245,7 @@ class ftp extends transfer
// Make sure $this->root_path is layed out the same way as the $user->page['root_script_path'] value (/ at the end)
$this->root_path = str_replace('\\', '/', $this->root_path);
- $this->root_path = (($root_path{0} != '/' ) ? '/' : '') . ((substr($root_path, -1, 1) == '/') ? '' : '/') . $root_path;
+ $this->root_path = (($root_path{0} != '/' ) ? '/' : '') . $root_path . ((substr($root_path, -1, 1) == '/') ? '' : '/');
// Init some needed values
transfer::transfer();
@@ -321,7 +321,7 @@ class ftp extends transfer
}
/**
- * Remove directory (RMDIR)
+ * Rename file
* @access: private
*/
function _rename($old_handle, $new_handle)
@@ -460,7 +460,7 @@ class ftp_fsock extends transfer
// Make sure $this->root_path is layed out the same way as the $user->page['root_script_path'] value (prefixed with / and no / at the end)
$this->root_path = str_replace('\\', '/', $this->root_path);
- $this->root_path = (($root_path{0} != '/' ) ? '/' : '') . ((substr($root_path, -1, 1) == '/') ? '' : '/') . $root_path;
+ $this->root_path = (($root_path{0} != '/' ) ? '/' : '') . $root_path . ((substr($root_path, -1, 1) == '/') ? '' : '/');
// Init some needed values
transfer::transfer();
@@ -543,6 +543,16 @@ class ftp_fsock extends transfer
}
/**
+ * Rename File
+ * @access: private
+ */
+ function _rename($old_handle, $new_handle)
+ {
+ $this->_send_command('RNFR', $old_handle);
+ return $this->_send_command('RNTO', $new_handle);
+ }
+
+ /**
* Change current working directory (CHDIR)
* @access: private
*/
@@ -562,7 +572,7 @@ class ftp_fsock extends transfer
*/
function _chmod($file, $perms)
{
- return $this->_send_command('SITE CHMOD', $perms . ' ' . $file);;
+ return $this->_send_command('SITE CHMOD', $perms . ' ' . $file);
}
/**
@@ -579,19 +589,19 @@ class ftp_fsock extends transfer
return false;
}
- $this->_putcmd('STOR', $to_file, false);
-
// open the connection to send file over
if (!$this->_open_data_connection())
{
return false;
}
+ $this->_send_command('STOR', $to_file, false);
+
// send the file
$fp = @fopen($from_file, 'rb');
while (!@feof($fp))
{
- @fwrite($$this->data_connection, @fread($fp, 4096));
+ @fwrite($this->data_connection, @fread($fp, 4096));
}
@fclose($fp);
@@ -710,7 +720,7 @@ class ftp_fsock extends transfer
{
return false;
}
- @stream_set_timeout($$this->data_connection, $this->timeout);
+ @stream_set_timeout($this->data_connection, $this->timeout);
return true;
}
@@ -721,7 +731,7 @@ class ftp_fsock extends transfer
*/
function _close_data_connection()
{
- return @fclose($this->data_connecton);
+ return @fclose($this->data_connection);
}
/**