mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-18 23:14:41 +01:00
- fixed language pack management a bit (supporting backslashes)
- fixed ftp_fsock, also fixing a reported bug in there git-svn-id: file:///svn/phpbb/trunk@6139 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
fdd82e4c12
commit
98fc394eb3
@ -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";
|
||||
|
||||
$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";
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -2072,26 +2072,41 @@ 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;
|
||||
|
@ -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();
|
||||
@ -542,6 +542,16 @@ class ftp_fsock extends transfer
|
||||
return $this->_send_command('RMD', $dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -473,7 +473,7 @@ if ($save && $user->data['is_registered'] && $auth->acl_get('u_savedrafts'))
|
||||
't' => $topic_id,
|
||||
'subject' => $subject,
|
||||
'message' => $message,
|
||||
)
|
||||
), false
|
||||
);
|
||||
|
||||
confirm_box(false, 'SAVE_DRAFT', $s_hidden_fields);
|
||||
|
@ -49,7 +49,7 @@
|
||||
<td class="row2">
|
||||
<input name="group_type" type="radio" class="radio" id="group_type" value="{GROUP_TYPE_FREE}"{GROUP_FREE} /> {L_GROUP_OPEN}
|
||||
<input name="group_type" type="radio" class="radio" value="{GROUP_TYPE_OPEN}"{GROUP_OPEN} /> {L_GROUP_REQUEST}
|
||||
<input name="group_type" type="radio" class="radio" value="{GROUP_TYPE_CLOSE}"{GROUP_CLOSED} /> {L_GROUP_CLOSED}
|
||||
<input name="group_type" type="radio" class="radio" value="{GROUP_TYPE_CLOSED}"{GROUP_CLOSED} /> {L_GROUP_CLOSED}
|
||||
<input name="group_type" type="radio" class="radio" value="{GROUP_TYPE_HIDDEN}"{GROUP_HIDDEN} /> {L_GROUP_HIDDEN}
|
||||
</td>
|
||||
</tr>
|
||||
|
Loading…
x
Reference in New Issue
Block a user