1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-13 12:35:06 +01:00

- change registration page language on-the-fly

- added download function to functions_compress as well as tiny bugfixes
- added local_name and author to iso.txt file


git-svn-id: file:///svn/phpbb/trunk@5074 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2005-01-23 23:02:10 +00:00
parent 055aef5003
commit 1613c37d91
7 changed files with 170 additions and 61 deletions

View File

@ -14,7 +14,7 @@
class compress
{
var $fp = 0;
function add_file($src, $src_rm_prefix = '', $src_add_prefix = '', $skip_files = '')
{
global $phpbb_root_path;
@ -63,7 +63,7 @@ class compress
$path = (substr($path, 0, 1) == '/') ? substr($path, 1) : $path;
$path = ($path && substr($path, -1) != '/') ? $path . '/' : $path;
$this->data("$src_path$path", '', filemtime("$phpbb_root_path$path"), true);
$this->data("$src_path$path", '', filemtime("$phpbb_root_path$src_path$path"), true);
}
foreach ($file_ary as $file)
@ -73,7 +73,7 @@ class compress
continue;
}
$this->data("$src_path$path$file", implode('', file("$phpbb_root_path$src$path$file")), filemtime("$phpbb_root_path$src$path$file"), false);
$this->data("$src_path$path$file", implode('', file("$phpbb_root_path$src_path$path$file")), filemtime("$phpbb_root_path$src_path$path$file"), false);
}
}
@ -374,6 +374,24 @@ class compress_zip extends compress
pack('V', $this->datasec_len) . // offset to start of central dir
"\x00\x00"; // .zip file comment length
}
function download($filename)
{
global $phpbb_root_path;
$mimetype = 'application/zip';
header('Pragma: no-cache');
header("Content-Type: $mimetype; name=\"$filename.zip\"");
header("Content-disposition: attachment; filename=$filename.zip");
$fp = fopen("{$phpbb_root_path}store/$filename.zip", 'rb');
while ($buffer = fread($fp, 1024))
{
echo $buffer;
}
fclose($fp);
}
}
// Tar/tar.gz compression routine
@ -384,6 +402,7 @@ class compress_tar extends compress
var $isbz = false;
var $filename = '';
var $mode = '';
var $type = '';
function compress_tar($mode, $file, $type = '')
{
@ -393,6 +412,7 @@ class compress_tar extends compress
$this->mode = &$mode;
$this->file = &$file;
$this->type = &$type;
$this->open();
}
@ -529,6 +549,7 @@ class compress_tar extends compress
$header .= pack("x247");
// Checksum
$checksum = 0;
for ($i = 0; $i < 512; $i++)
{
$b = unpack("c1char", substr($header, $i, 1));
@ -548,11 +569,46 @@ class compress_tar extends compress
unset($data);
}
function open($mode, $file)
function open()
{
$fzopen = ($this->isbz && function_exists('bzopen')) ? 'bzopen' : (($this->isgz && extension_loaded('zlib')) ? 'gzopen' : 'fopen');
return $this->fp = @$fzopen($this->file, $this->mode . 'b');
}
function download($filename)
{
global $phpbb_root_path;
switch ($this->type)
{
case 'tar':
$mimetype = 'application/x-tar';
break;
case 'tar.gz':
$mimetype = 'application/x-gzip';
break;
case 'tar.bz2':
$mimetype = 'application/x-bzip2';
break;
default:
$mimetype = 'application/octet-stream';
break;
}
header('Pragma: no-cache');
header("Content-Type: $mimetype; name=\"$filename.$this->type\"");
header("Content-disposition: attachment; filename=$filename.$this->type");
$fp = fopen("{$phpbb_root_path}store/$filename.$this->type", 'rb');
while ($buffer = fread($fp, 1024))
{
echo $buffer;
}
fclose($fp);
}
}
?>

View File

@ -523,7 +523,7 @@ class user extends session
$accept_lang = substr($accept_lang, 0, 2) . '_' . strtoupper(substr($accept_lang, 3, 2));
if (file_exists($phpbb_root_path . 'language/' . $accept_lang . "/common.$phpEx"))
{
$this->lang_name = $accept_lang;
$this->lang_name = $config['default_lang'] = $accept_lang;
$this->lang_path = $phpbb_root_path . 'language/' . $accept_lang . '/';
break;
}
@ -533,7 +533,7 @@ class user extends session
$accept_lang = substr($accept_lang, 0, 2);
if (file_exists($phpbb_root_path . 'language/' . $accept_lang . "/common.$phpEx"))
{
$this->lang_name = $accept_lang;
$this->lang_name = $config['default_lang'] = $accept_lang;
$this->lang_path = $phpbb_root_path . 'language/' . $accept_lang . '/';
break;
}

View File

@ -30,6 +30,17 @@ class ucp_register extends module
$coppa = (isset($_REQUEST['coppa'])) ? ((!empty($_REQUEST['coppa'])) ? 1 : 0) : false;
$agreed = (!empty($_POST['agreed'])) ? 1 : 0;
$submit = (isset($_POST['submit'])) ? true : false;
$change_lang = request_var('change_lang', '');
if ($change_lang)
{
$submit = false;
$lang = $change_lang;
$user->lang_name = $lang = $change_lang;
$user->lang_path = $phpbb_root_path . 'language/' . $lang . '/';
$user->lang = array();
$user->add_lang(array('common', 'ucp'));
}
$cp = new custom_profile();
@ -68,6 +79,27 @@ class ucp_register extends module
$this->display($user->lang['REGISTER'], 'ucp_agreement.html');
}
// If we change the language inline, we do not want to display errors, but pre-fill already filled out values
if ($change_lang)
{
$var_ary = array(
'username' => (string) '',
'password_confirm' => (string) '',
'new_password' => (string) '',
'cur_password' => (string) '',
'email' => (string) '',
'email_confirm' => (string) '',
'confirm_code' => (string) '',
'lang' => (string) $config['default_lang'],
'tz' => (float) $config['board_timezone'],
);
foreach ($var_ary as $var => $default)
{
$$var = request_var($var, $default);
}
}
// Check and initialize some variables if needed
if ($submit)
{
@ -272,7 +304,7 @@ class ucp_register extends module
{
include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx);
$messenger = new messenger();
$messenger = new messenger(false);
$messenger->template($email_template, $lang);
@ -335,8 +367,6 @@ class ucp_register extends module
}
$db->sql_freeresult($result);
}
$messenger->queue->save();
}
if ($config['require_activation'] == USER_ACTIVATION_NONE || !$config['email_enable'])
@ -353,53 +383,57 @@ class ucp_register extends module
}
$s_hidden_fields = '<input type="hidden" name="agreed" value="true" /><input type="hidden" name="coppa" value="' . $coppa . '" />';
$s_hidden_fields .= '<input type="hidden" name="change_lang" value="0" />';
$confirm_image = '';
// Visual Confirmation - Show images
if ($config['enable_confirm'])
{
$sql = 'SELECT session_id
FROM ' . SESSIONS_TABLE;
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
if (!$change_lang)
{
$sql_in = array();
do
{
$sql_in[] = "'" . $db->sql_escape($row['session_id']) . "'";
}
while ($row = $db->sql_fetchrow($result));
$sql = 'SELECT session_id
FROM ' . SESSIONS_TABLE;
$result = $db->sql_query($sql);
$sql = 'DELETE FROM ' . CONFIRM_TABLE . '
WHERE session_id NOT IN (' . implode(', ', $sql_in) . ')';
if ($row = $db->sql_fetchrow($result))
{
$sql_in = array();
do
{
$sql_in[] = "'" . $db->sql_escape($row['session_id']) . "'";
}
while ($row = $db->sql_fetchrow($result));
$sql = 'DELETE FROM ' . CONFIRM_TABLE . '
WHERE session_id NOT IN (' . implode(', ', $sql_in) . ')';
$db->sql_query($sql);
}
$db->sql_freeresult($result);
$sql = 'SELECT COUNT(session_id) AS attempts
FROM ' . CONFIRM_TABLE . "
WHERE session_id = '" . $db->sql_escape($user->session_id) . "'";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
if ($config['max_reg_attempts'] && $row['attempts'] >= $config['max_reg_attempts'])
{
trigger_error($user->lang['TOO_MANY_REGISTERS']);
}
}
$db->sql_freeresult($result);
$code = gen_rand_string(6);
$confirm_id = md5(uniqid($user_ip));
$sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'confirm_id' => (string) $confirm_id,
'session_id' => (string) $user->session_id,
'code' => (string) $code)
);
$db->sql_query($sql);
}
$db->sql_freeresult($result);
$sql = 'SELECT COUNT(session_id) AS attempts
FROM ' . CONFIRM_TABLE . "
WHERE session_id = '" . $db->sql_escape($user->session_id) . "'";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
if ($config['max_reg_attempts'] && $row['attempts'] >= $config['max_reg_attempts'])
{
trigger_error($user->lang['TOO_MANY_REGISTERS']);
}
}
$db->sql_freeresult($result);
$code = gen_rand_string(6);
$confirm_id = md5(uniqid($user_ip));
$sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'confirm_id' => (string) $confirm_id,
'session_id' => (string) $user->session_id,
'code' => (string) $code)
);
$db->sql_query($sql);
$confirm_image = (@extension_loaded('zlib')) ? "<img src=\"ucp.$phpEx$SID&amp;mode=confirm&amp;id=$confirm_id\" alt=\"\" title=\"\" />" : "<img src=\"ucp.$phpEx$SID&amp;mode=confirm&amp;id=$confirm_id&amp;c=1\" alt=\"\" title=\"\" /><img src=\"ucp.$phpEx$SID&amp;mode=confirm&amp;id=$confirm_id&amp;c=2\" alt=\"\" title=\"\" /><img src=\"ucp.$phpEx$SID&amp;mode=confirm&amp;id=$confirm_id&amp;c=3\" alt=\"\" title=\"\" /><img src=\"ucp.$phpEx$SID&amp;mode=confirm&amp;id=$confirm_id&amp;c=4\" alt=\"\" title=\"\" /><img src=\"ucp.$phpEx$SID&amp;mode=confirm&amp;id=$confirm_id&amp;c=5\" alt=\"\" title=\"\" /><img src=\"ucp.$phpEx$SID&amp;mode=confirm&amp;id=$confirm_id&amp;c=6\" alt=\"\" title=\"\" />";
$s_hidden_fields .= '<input type="hidden" name="confirm_id" value="' . $confirm_id . '" />';
@ -443,7 +477,7 @@ class ucp_register extends module
'S_CONFIRM_CODE' => ($config['enable_confirm']) ? true : false,
'S_COPPA' => $coppa,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_UCP_ACTION' => "ucp.$phpEx$SID&amp;mode=register")
'S_UCP_ACTION' => "{$phpbb_root_path}ucp.$phpEx$SID&amp;mode=register")
);
//

View File

@ -52,8 +52,7 @@ $lang += array(
'ACP_CAT_USERGROUP' => 'Users &amp; Groups',
'ACP_USERS_MANAGE' => 'Edit user data',
'DB_CAT' => 'Database',
@ -114,6 +113,10 @@ $lang += array(
'GROUP_MANAGE' => 'Manage groups',
'CUSTOM_PROFILE_FIELDS' => 'Profile fields',
'LANGUAGE_CAT' => 'Language',
'LANGUAGE_PACKS' => 'Language Packs',
'ADMINISTRATORS' => 'Administrators',
'USERNAMES_EXPLAIN' => 'Place each username on a seperate line',
'LOOK_UP_FORUM' => 'Select a Forum',
@ -280,6 +283,10 @@ $lang += array(
'LOG_BOT_ADDED' => '<b>New bot added</b><br />&#187; %s',
'LOG_BOT_UPDATED' => '<b>Existing bot updated</b><br />&#187; %s',
'LOG_BOT_DELETE' => '<b>Deleted bot</b><br />&#187; %s',
'LOG_DELETE_LANGUAGE_PACK' => '<b>Deleted language pack</b><br />&#187; %s',
'LOG_LANGUAGE_PACK_INSTALLED' => '<b>Installed language pack</b><br />&#187; %s',
'LOG_UPDATE_LANG_DETAILS' => '<b>Updated language pack details</b><br />&#187; %s',
);
// Index page

View File

@ -1 +1,3 @@
English [UK]
English [UK]
English [UK]
phpBB Group

View File

@ -1537,11 +1537,11 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
if ($post_mode == 'post')
{
$sql_data[TOPICS_TABLE]['sql'] = array(
'topic_first_post_id' => $data['post_id'],
'topic_last_post_id' => $data['post_id'],
'topic_last_post_time' => $current_time,
'topic_last_poster_id' => (int) $user->data['user_id'],
'topic_last_poster_name' => ($user->data['user_id'] == ANONYMOUS && $username) ? stripslashes($username) : $user->data['username']
'topic_first_post_id' => $data['post_id'],
'topic_last_post_id' => $data['post_id'],
'topic_last_post_time' => $current_time,
'topic_last_poster_id' => (int) $user->data['user_id'],
'topic_last_poster_name'=> ($user->data['user_id'] == ANONYMOUS && $username) ? stripslashes($username) : $user->data['username']
);
}
@ -1557,11 +1557,11 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $data['topic_id'];
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
// globalise
if ((int)$row['topic_type'] != POST_GLOBAL && $topic_type == POST_GLOBAL)
if ($row['topic_type'] != POST_GLOBAL && $topic_type == POST_GLOBAL)
{
// Decrement topic/post count
$make_global = true;
@ -1577,7 +1577,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$db->sql_query($sql);
}
// unglobalise
else if ((int)$row['topic_type'] == POST_GLOBAL && $topic_type != POST_GLOBAL)
else if ($row['topic_type'] == POST_GLOBAL && $topic_type != POST_GLOBAL)
{
// Increment topic/post count
$make_global = true;

View File

@ -2,7 +2,17 @@
<!-- INCLUDE overall_header.html -->
<form method="post" action="{S_UCP_ACTION}"><table width="80%" cellspacing="2" cellpadding="2" border="0" align="center">
<script language="Javascript" type="text/javascript">
<!--
function change_language(lang_iso)
{
document.forms['register'].change_lang.value = lang_iso;
document.forms['register'].submit.click();
}
//-->
</script>
<form name="register" method="post" action="{S_UCP_ACTION}"><table width="80%" cellspacing="2" cellpadding="2" border="0" align="center">
<tr>
<td class="nav"><a href="{U_INDEX}">{L_INDEX}</a></td>
</tr>
@ -47,7 +57,7 @@
</tr>
<tr>
<td class="row1"><b class="genmed">{L_LANGUAGE}: </b></td>
<td class="row2"><select name="lang">{S_LANG_OPTIONS}</select></td>
<td class="row2"><select name="lang" onchange="javascript:change_language(this.value);">{S_LANG_OPTIONS}</select></td>
</tr>
<tr>
<td class="row1"><b class="genmed">{L_TIMEZONE}: </b></td>