diff --git a/phpBB/download.php b/phpBB/download.php
new file mode 100644
index 0000000000..f20612d58b
--- /dev/null
+++ b/phpBB/download.php
@@ -0,0 +1,374 @@
+ www.opentools.de
+// Partial Domain Names -> opentools.de
+//
+$sites = array(
+ $config['server_name'], // This is your domain
+ 'phpbb.com'
+);
+
+// This is the message displayed, if someone links to this site...
+$lang['Denied_Message'] = 'You are not authorized to view, download or link to this Site.';
+
+// End of editable area
+
+//
+// Parse the order and evaluate the array
+//
+
+$site = explode('?', $HTTP_SERVER_VARS['HTTP_REFERER']);
+$url = trim($site[0]);
+//$url = $HTTP_HOST;
+
+if ($url != '')
+{
+ $allowed = ($allow_deny_order == ALLOWED_DENIED) ? FALSE : TRUE;
+
+ for ($i = 0; $i < count($sites); $i++)
+ {
+ if (strstr($url, $sites[$i]))
+ {
+ $allowed = ($allow_deny_order == ALLOWED_DENIED) ? TRUE : FALSE;
+ break;
+ }
+ }
+}
+else
+{
+ $allowed = TRUE;
+}
+
+if ($allowed == FALSE)
+{
+ trigger_error($lang['Denied_Message']);
+}
+
+// Delete the following line, to uncomment this block
+*/
+
+$download_id = (isset($_REQUEST['id'])) ? intval($_REQUEST['id']) : -1;
+$thumbnail = (isset($_REQUEST['thumb'])) ? intval($_REQUEST['thumb']) : false;
+
+function send_file_to_browser($real_filename, $mimetype, $physical_filename, $upload_dir, $attach_id)
+{
+ global $_SERVER, $HTTP_USER_AGENT, $HTTP_SERVER_VARS, $user, $db, $config;
+
+ if ($config['upload_dir'] == '')
+ {
+ $filename = $physical_filename;
+ }
+ else
+ {
+ $filename = $config['upload_dir'] . '/' . $physical_filename;
+ }
+
+ $gotit = FALSE;
+
+ if (!intval($config['allow_ftp_upload']))
+ {
+ if (@!file_exists($filename))
+ {
+ trigger_error($user->lang['ERROR_NO_ATTACHMENT'] . "
" . sprintf($user->lang['FILE_NOT_FOUND_404'], $filename));
+ }
+ else
+ {
+ $gotit = TRUE;
+ }
+ }
+
+ // Determine the Browser the User is using, because of some nasty incompatibilities.
+ // borrowed from phpMyAdmin. :)
+ if (!empty($_SERVER['HTTP_USER_AGENT']))
+ {
+ $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
+ }
+ else if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT']))
+ {
+ $HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT'];
+ }
+ else if (!isset($HTTP_USER_AGENT))
+ {
+ $HTTP_USER_AGENT = '';
+ }
+
+ if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version))
+ {
+ $browser_version = $log_version[2];
+ $browser_agent = 'opera';
+ }
+ else if (ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version))
+ {
+ $browser_version = $log_version[1];
+ $browser_agent = 'ie';
+ }
+ else if (ereg('OmniWeb/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version))
+ {
+ $browser_version = $log_version[1];
+ $browser_agent = 'omniweb';
+ }
+ else if (ereg('Netscape([0-9]{1})', $HTTP_USER_AGENT, $log_version))
+ {
+ $browser_version = $log_version[1];
+ $browser_agent = 'netscape';
+ }
+ else if (ereg('Mozilla/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version))
+ {
+ $browser_version = $log_version[1];
+ $browser_agent = 'mozilla';
+ }
+ else if (ereg('Konqueror/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version))
+ {
+ $browser_version = $log_version[1];
+ $browser_agent = 'konqueror';
+ }
+ else
+ {
+ $browser_version = 0;
+ $browser_agent = 'other';
+ }
+
+ // Correct the Mime Type, if it's an octetstream
+ if ( ($mimetype == 'application/octet-stream') || ($mimetype == 'application/octetstream') )
+ {
+ if ( ($browser_agent == 'ie') || ($browser_agent == 'opera') )
+ {
+ $mimetype = 'application/octetstream';
+ }
+ else
+ {
+ $mimetype = 'application/octet-stream';
+ }
+ }
+
+ // Now the tricky part... let's dance
+ @ob_end_clean();
+ @ini_set('zlib.output_compression', 'Off');
+ header('Pragma: public');
+ header('Content-Transfer-Encoding: none');
+
+ // Send out the Headers
+ if ($browser_agent == 'ie')
+ {
+ header('Content-Type: ' . $mimetype);
+ header('Content-Disposition: inline; filename="' . $real_filename . '"');
+ }
+ else
+ {
+ header('Content-Type: ' . $mimetype . '; name="' . $real_filename . '"');
+ header('Content-Disposition: attachment; filename=' . $real_filename);
+ }
+
+ // Now send the File Contents to the Browser
+ if ($gotit)
+ {
+ $size = @filesize($filename);
+ if ($size)
+ {
+ header("Content-length: $size");
+ }
+ readfile($filename);
+ }
+/* else if ((!$gotit) && (intval($config['allow_ftp_upload'])))
+ {
+ $conn_id = attach_init_ftp();
+
+ $tmp_path = ( !@ini_get('safe_mode') ) ? '/tmp' : $config['upload_dir'] . '/tmp';
+ $tmp_filename = @tempnam($tmp_path, 't0000');
+
+ @unlink($tmp_filename);
+
+ $mode = FTP_BINARY;
+ if ( (preg_match("/text/i", $mimetype)) || (preg_match("/html/i", $mimetype)) )
+ {
+ $mode = FTP_ASCII;
+ }
+
+ $result = @ftp_get($conn_id, $tmp_filename, $filename, $mode);
+
+ if (!$result)
+ {
+ trigger_error($user->lang['ERROR_NO_ATTACHMENT'] . "
" . sprintf($user->lang['FILE_NOT_FOUND_404'], $filename));
+ }
+
+ @ftp_quit($conn_id);
+
+ $size = @filesize($tmp_filename);
+ if ($size)
+ {
+ header("Content-length: $size");
+ }
+ readfile($tmp_filename);
+ @unlink($tmp_filename);
+ }*/
+ else
+ {
+ trigger_error($user->lang['ERROR_NO_ATTACHMENT'] . "
" . sprintf($user->lang['FILE_NOT_FOUND_404'], $filename));
+ }
+
+ exit;
+}
+
+// Start session management
+$user->start();
+$user->setup();
+$auth->acl($user->data);
+
+if ($download_id == -1)
+{
+ trigger_error('NO_ATTACHMENT_SELECTED');
+}
+
+if (!$config['allow_attachments'])
+{
+ trigger_error('ATTACHMENT_FUNCTIONALITY_DISABLED');
+}
+
+$sql = 'SELECT *
+ FROM ' . ATTACHMENTS_DESC_TABLE . '
+ WHERE attach_id = ' . intval($download_id);
+$result = $db->sql_query($sql);
+
+if (!$attachment = $db->sql_fetchrow($result))
+{
+ trigger_error('ERROR_NO_ATTACHMENT');
+}
+
+// get forum_id for attachment authorization or private message authorization
+$authorised = FALSE;
+
+// Additional query, because of more than one attachment assigned to posts and private messages
+$sql = "SELECT a.*, p.forum_id
+ FROM " . ATTACHMENTS_TABLE . " a, " . POSTS_TABLE . " p
+ WHERE a.attach_id = " . $attachment['attach_id'] . "
+ AND (a.post_id = p.post_id OR a.post_id = 0)";
+$result = $db->sql_query($sql);
+
+$auth_pages = $db->sql_fetchrowset($result);
+
+for ($i = 0; $i < count($auth_pages) && $authorised == FALSE; $i++)
+{
+ if (intval($auth_pages[$i]['post_id']) != 0)
+ {
+ $forum_id = $auth_pages[$i]['forum_id'];
+
+ if ($auth->acl_get('f_download', $forum_id))
+ {
+ $authorised = TRUE;
+ }
+ }
+ else
+ {
+ if ( (intval($config['allow_pm_attach'])) && ( ($user->data['user_id'] == $auth_pages[$i]['user_id_2']) || ($user->data['user_id'] == $auth_pages[$i]['user_id_1'])) )
+ {
+ $authorised = TRUE;
+ }
+ }
+}
+
+if (!$authorised)
+{
+ trigger_error('SORRY_AUTH_VIEW_ATTACH');
+}
+
+$extensions = array();
+obtain_attach_extensions($extensions);
+
+// disallowed ?
+if ( (!in_array($attachment['extension'], $extensions['_allowed_'])) )
+{
+ trigger_error(sprintf($lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']));
+}
+
+$download_mode = intval($extensions[$attachment['extension']]['download_mode']);
+
+if ($thumbnail)
+{
+ $attachment['physical_filename'] = 'thumbs/t_' . $attachment['physical_filename'];
+}
+
+// Update download count
+if (!$thumbnail)
+{
+ $sql = 'UPDATE ' . ATTACHMENTS_DESC_TABLE . '
+ SET download_count = download_count + 1
+ WHERE attach_id = ' . $attachment['attach_id'];
+ $db->sql_query($sql);
+}
+
+// Determine the 'presenting'-method
+if ($download_mode == PHYSICAL_LINK)
+{
+ if (intval($config['allow_ftp_upload']) && $config['upload_dir'] == '')
+ {
+ trigger_error('Physical Download not possible with the current Attachment Setting');
+ }
+
+ redirect($config['upload_dir'] . '/' . $attachment['physical_filename']);
+}
+else
+{
+ if (intval($config['allow_ftp_upload']))
+ {
+ // We do not need a download path, we are not downloading physically
+ send_file_to_browser($attachment['real_filename'], $attachment['mimetype'], $attachment['physical_filename'] , '', $attachment['attach_id']);
+ exit();
+ }
+ else
+ {
+ send_file_to_browser($attachment['real_filename'], $attachment['mimetype'], $attachment['physical_filename'], $config['upload_dir'], $attachment['attach_id']);
+ exit();
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index fd9ae37841..cbce502231 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -796,6 +796,7 @@ function obtain_attach_extensions(&$extensions)
{
$extension = strtolower(trim($row['extension']));
+ $extensions['_allowed_'][] = $extension;
$extensions[$extension]['display_cat'] = intval($row['cat_id']);
$extensions[$extension]['download_mode'] = intval($row['download_mode']);
$extensions[$extension]['upload_icon'] = trim($row['upload_icon']);
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index eea3c611ca..3eaefe1b1b 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -574,7 +574,7 @@ function format_display($message, $html, $bbcode, $uid, $url, $smilies, $sig)
// Signature
$user_sig = ($sig && $config['allow_sig']) ? trim($user->data['user_sig']) : '';
- if ($user_sig != '' && $auth->acl_gets('f_sigs', 'm_', 'a_', $forum_id))
+ if ($user_sig != '' && $auth->acl_get('f_sigs', $forum_id))
{
if (!$auth->acl_get('f_html', $forum_id) && $user->data['user_allowhtml'])
{
@@ -733,7 +733,7 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
'topic_title' => stripslashes($subject),
'topic_time' => $current_time,
'topic_type' => $topic_type,
- 'topic_approved' => (($post_data['enable_moderate']) && !$auth->acl_gets('f_ignorequeue', 'm_', 'a_', $post_data['forum_id'])) ? 0 : 1,
+ 'topic_approved' => (($post_data['enable_moderate']) && !$auth->acl_get('f_ignorequeue', $post_data['forum_id'])) ? 0 : 1,
'icon_id' => $post_data['icon_id'],
'topic_attachment' => (sizeof($attachment_data['physical_filename'])) ? 1 : 0,
'topic_poster' => intval($user->data['user_id']),
@@ -765,7 +765,7 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
'icon_id' => $post_data['icon_id'],
'poster_ip' => $user->ip,
'post_time' => $current_time,
- 'post_approved' => ($post_data['enable_moderate'] && !$auth->acl_gets('f_ignorequeue', 'm_', 'a_', $post_data['forum_id'])) ? 0 : 1,
+ 'post_approved' => ($post_data['enable_moderate'] && !$auth->acl_get('f_ignorequeue', $post_data['forum_id'])) ? 0 : 1,
'post_edit_time' => ($mode == 'edit' && $post_data['poster_id'] == $user->data['user_id']) ? $current_time : 0,
'enable_sig' => $post_data['enable_sig'],
'enable_bbcode' => $post_data['enable_bbcode'],
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index e18abd6ce1..fcbc470b93 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -179,8 +179,6 @@ class parse_message
{
global $config, $_FILE, $_POST, $auth, $user;
- $config['max_attachments'] = 1;
-
$error = false;
$error_msg = '';
@@ -194,7 +192,7 @@ class parse_message
if ( $submit && ($mode == 'post' || $mode == 'reply' || $mode == 'edit') && $attachment_data['filename'] != '')
{
- if ( $num_attachments < $config['max_attachments'] || $auth->acl_get('m_', 'a_') )
+ if ( $num_attachments < $config['max_attachments'] ) //|| $auth->acl_gets('m_', 'a_', $forum_id) )
{
$filedata = upload_attachment($attachment_data['filename']);
@@ -326,7 +324,7 @@ class parse_message
if ((($add_file) || ($preview) ) && ($attachment_data['filename'] != '') )
{
- if ( $num_attachments < $config['max_attachments'] || $auth->acl_get('m_', 'a_') )
+ if ( $num_attachments < $config['max_attachments'] ) //|| $auth->acl_gets('m_', 'a_', $forum_id) )
{
$filedata = upload_attachment($attachment_data['filename']);
@@ -372,7 +370,7 @@ class parse_message
$err_msg = '';
// Process poll options
- if (!empty($poll_data['poll_option_text']) && (($auth->acl_get('f_poll', $forum_id) && !$poll_data['poll_last_vote']) || $auth->acl_gets('m_edit', 'a_', $forum_id)))
+ if (!empty($poll_data['poll_option_text']) && (($auth->acl_get('f_poll', $forum_id) && !$poll_data['poll_last_vote']) || $auth->acl_get('m_edit', $forum_id)))
{
if (($result = $this->parse($poll_data['poll_option_text'], $poll_data['enable_html'], $poll_data['enable_bbcode'], $poll_data['bbcode_uid'], $poll_data['enable_urls'], $poll_data['enable_smilies'], false)) != '')
{
diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php
index ceee724c81..079a40c0fe 100644
--- a/phpBB/includes/template.php
+++ b/phpBB/includes/template.php
@@ -247,6 +247,23 @@ class Template {
}
}
+ function merge_from_include($filename)
+ {
+ $handle = 'include_' . $this->include_counter++;
+
+ $this->filename[$handle] = $filename;
+ $this->files[$handle] = $this->make_filename($filename);
+
+ if (!file_exists($this->files[$handle]))
+ {
+ trigger_error("Template->pparse(): Couldn't load template file for handle $handle", E_USER_ERROR);
+ }
+
+ $content = implode('', @file($this->files[$handle]));
+
+ return ($content);
+ }
+
/**
* Root-level variable assignment. Adds to current assignments, overriding
* any existing variable assignment with the same name.
@@ -323,6 +340,14 @@ class Template {
*/
function compile($code, $do_not_echo = false, $retvar = '')
{
+ // Pull out all merging includes, to let them parse with the code
+ preg_match_all('##s', $code, $matches);
+ $merge_blocks = $matches[1];
+ foreach($merge_blocks as $filename)
+ {
+ $code = preg_replace('##s', $this->merge_from_include(trim($filename)), $code);
+ }
+
// Pull out all block/statement level elements and seperate
// plain text
preg_match_all('#(.*?)#s', $code, $matches);
diff --git a/phpBB/language/en/lang_main.php b/phpBB/language/en/lang_main.php
index 917fdaf9fa..1438e565ff 100644
--- a/phpBB/language/en/lang_main.php
+++ b/phpBB/language/en/lang_main.php
@@ -476,6 +476,11 @@ $lang = array(
'ATTACHMENT_TOO_BIG' => 'The Attachment is too big, maximum size is %1d %2s',
'ATTACH_QUOTA_REACHED' => 'Sorry, the total board attachment quota has been reached.',
+ 'EXTENSION_DISABLED_AFTER_POSTING' => 'The Extension \'%s\' has been deactivated by an board admin, therefore this Attachment is not displayed.', // used in Posts and PM's, replace %s with extension
+ 'DESCRIPTION' => 'Description',
+ 'DOWNLOAD' => 'Download',
+ 'FILESIZE' => 'Filesize',
+ 'FILE_NOT_FOUND_404' => '404 File Not Found: The File %s does not exist.',
'User_control_panel' => 'User Control Panel',
'UCP_Main' => 'Control Panel',
diff --git a/phpBB/posting.php b/phpBB/posting.php
index a3d81beae9..df9bd66025 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -327,22 +327,22 @@ if ($mode != 'post' && $user->data['user_id'] != ANONYMOUS)
// Collect general Permissions to be used within the complete page
$perm = array(
- 'm_lock' => $auth->acl_gets('m_lock', 'a_', $forum_id),
- 'm_edit' => $auth->acl_gets('m_edit', 'a_', $forum_id),
- 'm_delete' => $auth->acl_gets('m_delete', 'a_', $forum_id),
+ 'm_lock' => $auth->acl_get('m_lock', $forum_id),
+ 'm_edit' => $auth->acl_get('m_edit', $forum_id),
+ 'm_delete' => $auth->acl_get('m_delete', $forum_id),
'u_delete' => $auth->acl_get('f_delete', $forum_id),
- 'f_attach' => $auth->acl_get('f_attach', 'a_', $forum_id),
- 'f_news' => $auth->acl_gets('f_news', 'm_', 'a_', $forum_id),
- 'f_announce' => $auth->acl_gets('f_announce', 'm_', 'a_', $forum_id),
- 'f_sticky' => $auth->acl_gets('f_sticky', 'm_', 'a_', $forum_id),
- 'f_ignoreflood' => $auth->acl_gets('f_ignoreflood', 'm_', 'a_', $forum_id),
- 'f_sigs' => $auth->acl_gets('f_sigs', 'm_', 'a_', $forum_id),
- 'f_save' => $auth->acl_gets('f_save', 'm_', 'a_', $forum_id)
+ 'f_attach' => $auth->acl_get('f_attach', $forum_id),
+ 'f_news' => $auth->acl_get('f_news', $forum_id),
+ 'f_announce' => $auth->acl_get('f_announce', $forum_id),
+ 'f_sticky' => $auth->acl_get('f_sticky', $forum_id),
+ 'f_ignoreflood' => $auth->acl_get('f_ignoreflood', $forum_id),
+ 'f_sigs' => $auth->acl_get('f_sigs', $forum_id),
+ 'f_save' => $auth->acl_get('f_save', $forum_id)
);
-if ( (!$auth->acl_gets('f_' . $mode, 'm_', 'a_', $forum_id)) && ($forum_postable) )
+if ( (!$auth->acl_get('f_' . $mode, $forum_id)) && ($forum_postable) )
{
trigger_error($user->lang['USER_CANNOT_' . strtoupper($mode)]);
}
@@ -625,7 +625,7 @@ if ($preview)
$preview_subject = (sizeof($censors)) ? preg_replace($censors['match'], $censors['replace'], $subject) : $subject;
// Poll Preview
- if ( ( ($mode == 'post') || ( ($mode == 'edit') && ($post_id == $topic_first_post_id) && (empty($poll_last_vote)) )) && ( ($auth->acl_get('f_poll', $forum_id)) || ($auth->acl_gets('m_edit', 'a_', $forum_id)) ))
+ if ( ( ($mode == 'post') || ( ($mode == 'edit') && ($post_id == $topic_first_post_id) && (empty($poll_last_vote)) )) && ( ($auth->acl_get('f_poll', $forum_id)) || ($auth->acl_get('m_edit', $forum_id)) ))
{
decode_text($poll_title);
$preview_poll_title = format_display(stripslashes($poll_title), $enable_html, $enable_bbcode, $bbcode_uid, $enable_urls, $enable_smilies, false, false);
diff --git a/phpBB/templates/subSilver/viewtopic_attach_body.html b/phpBB/templates/subSilver/viewtopic_attach_body.html
new file mode 100644
index 0000000000..eb91497d1b
--- /dev/null
+++ b/phpBB/templates/subSilver/viewtopic_attach_body.html
@@ -0,0 +1,38 @@
+
+
+