aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/adm/admin_attachments.php39
-rw-r--r--phpBB/adm/admin_bbcodes.php52
-rw-r--r--phpBB/adm/admin_bots.php10
-rw-r--r--phpBB/adm/admin_styles.php2
-rw-r--r--phpBB/includes/functions.php30
-rw-r--r--phpBB/includes/functions_admin.php6
-rw-r--r--phpBB/includes/functions_posting.php10
-rw-r--r--phpBB/includes/functions_upload.php71
-rw-r--r--phpBB/includes/session.php19
-rw-r--r--phpBB/viewforum.php57
-rw-r--r--phpBB/viewtopic.php28
11 files changed, 205 insertions, 119 deletions
diff --git a/phpBB/adm/admin_attachments.php b/phpBB/adm/admin_attachments.php
index 74e2a76417..02a024f541 100644
--- a/phpBB/adm/admin_attachments.php
+++ b/phpBB/adm/admin_attachments.php
@@ -62,7 +62,6 @@ switch ($mode)
if ($mode == 'attach')
{
-
$config_sizes = array('max_filesize' => 'size', 'attachment_quota' => 'quota_size', 'max_filesize_pm' => 'pm_size');
foreach ($config_sizes as $cfg_key => $var)
{
@@ -271,7 +270,7 @@ if ($submit && $mode == 'ext_groups')
{
$sql = 'SELECT group_id
FROM ' . EXTENSION_GROUPS_TABLE . "
- WHERE LOWER(group_name) = '" . strtolower($new_group_name) . "'";
+ WHERE LOWER(group_name) = '" . $db->sql_escape(strtolower($new_group_name)) . "'";
$result = $db->sql_query($sql);
if ($db->sql_fetchrow($result))
{
@@ -286,8 +285,8 @@ if ($submit && $mode == 'ext_groups')
$upload_icon = request_var('upload_icon', 'no_image');
$size_select = request_var('size_select', 'b');
$forum_select = request_var('forum_select', false);
- $allowed_forums = isset($_REQUEST['allowed_forums']) ? array_map('intval', array_values($_REQUEST['allowed_forums'])) : array();
- $allow_in_pm = isset($_REQUEST['allow_in_pm']) ? true : false;
+ $allowed_forums = isset($_POST['allowed_forums']) ? array_map('intval', array_values($_POST['allowed_forums'])) : array();
+ $allow_in_pm = isset($_POST['allow_in_pm']) ? true : false;
$max_filesize = request_var('max_filesize', 0);
$max_filesize = ($size_select == 'kb') ? round($max_filesize * 1024) : (($size_select == 'mb') ? round($max_filesize * 1048576) : $max_filesize);
@@ -304,7 +303,7 @@ if ($submit && $mode == 'ext_groups')
$group_ary = array(
'group_name' => $group_name,
'cat_id' => request_var('special_category', ATTACHMENT_CATEGORY_NONE),
- 'allow_group' => (isset($_REQUEST['allow_group'])) ? 1 : 0,
+ 'allow_group' => (isset($_POST['allow_group'])) ? 1 : 0,
'download_mode' => request_var('download_mode', INLINE_LINK),
'upload_icon' => ($upload_icon == 'no_image') ? '' : $upload_icon,
'max_filesize' => $max_filesize,
@@ -362,8 +361,8 @@ if ($submit && $mode == 'ext_groups')
if ($submit && $mode == 'orphan')
{
- $delete_files = (isset($_REQUEST['delete'])) ? array_keys(request_var('delete', '')) : array();
- $add_files = (isset($_REQUEST['add'])) ? array_keys(request_var('add', '')) : array();
+ $delete_files = (isset($_POST['delete'])) ? array_keys(request_var('delete', '')) : array();
+ $add_files = (isset($_POST['add'])) ? array_keys(request_var('add', '')) : array();
$post_ids = request_var('post_id', 0);
foreach ($delete_files as $delete)
@@ -722,10 +721,10 @@ if ($mode == 'ext_groups')
$action = request_var('action', 'show');
$group_id = request_var('g', 0);
- $action = (isset($_REQUEST['add'])) ? 'add' : $action;
+ $action = (isset($_POST['add'])) ? 'add' : $action;
$action = (($action == 'add' || $action == 'edit') && $submit && !sizeof($error)) ? 'show' : $action;
- if (isset($_REQUEST['select_mode']))
+ if (isset($_POST['select_mode']))
{
$action = 'show';
}
@@ -746,7 +745,8 @@ if ($mode == 'ext_groups')
WHERE group_id = $group_id";
$result = $db->sql_query($sql);
$group_name = $db->sql_fetchfield('group_name', 0, $result);
-
+ $db->sql_freeresult($result);
+
$sql = 'DELETE
FROM ' . EXTENSION_GROUPS_TABLE . "
WHERE group_id = $group_id";
@@ -1131,7 +1131,7 @@ if ($mode == 'extensions')
<th>&nbsp;<?php echo $user->lang['ADD_EXTENSION']; ?>&nbsp;</th>
</tr>
<tr>
- <td class="row1" align="center" valign="middle"><input type="text" size="20" maxlength="100" name="add_extension" class="post" value="<?php echo $add_extension; ?>" /></td>
+ <td class="row1" align="center" valign="middle"><input type="text" size="20" maxlength="100" name="add_extension" class="post" value="<?php echo (isset($add_extension)) ? $add_extension : ''; ?>" /></td>
<td class="row2" align="center" valign="middle"><?php echo (($submit) ? group_select('add_group_select', $add_extension_group) : group_select('add_group_select')) ?></td>
<td class="row1" align="center" valign="middle"><input type="checkbox" name="add_extension_check" /></td>
</tr>
@@ -1279,7 +1279,7 @@ function marklist(match, name, status)
adm_page_footer();
// Build Select for category items
-function category_select($select_name, $group_id = FALSE)
+function category_select($select_name, $group_id = false)
{
global $db, $user;
@@ -1294,7 +1294,7 @@ function category_select($select_name, $group_id = FALSE)
{
$sql = 'SELECT cat_id
FROM ' . EXTENSION_GROUPS_TABLE . '
- WHERE group_id = ' . intval($group_id);
+ WHERE group_id = ' . (int) $group_id;
$result = $db->sql_query($sql);
$cat_type = (!($row = $db->sql_fetchrow($result))) ? ATTACHMENT_CATEGORY_NONE : $row['cat_id'];
@@ -1320,7 +1320,7 @@ function category_select($select_name, $group_id = FALSE)
}
// Extension group select
-function group_select($select_name, $default_group = '-1')
+function group_select($select_name, $default_group = false)
{
global $db, $user;
@@ -1342,9 +1342,9 @@ function group_select($select_name, $default_group = '-1')
$row['group_name'] = $user->lang['NOT_ASSIGNED'];
$group_name[] = $row;
- for ($i = 0; $i < count($group_name); $i++)
+ for ($i = 0; $i < sizeof($group_name); $i++)
{
- if ($default_group == '-1')
+ if ($default_group === false)
{
$selected = ($i == 0) ? ' selected="selected"' : '';
}
@@ -1375,7 +1375,7 @@ function download_select($select_name, $group_id = false)
{
$sql = "SELECT download_mode
FROM " . EXTENSION_GROUPS_TABLE . "
- WHERE group_id = " . intval($group_id);
+ WHERE group_id = " . (int) $group_id;
$result = $db->sql_query($sql);
$download_mode = (!($row = $db->sql_fetchrow($result))) ? INLINE_LINK : $row['download_mode'];
@@ -1400,7 +1400,7 @@ function download_select($select_name, $group_id = false)
return $group_select;
}
-/* Upload already uploaded file... huh? are you kidding?
+// Upload already uploaded file... huh? are you kidding?
function upload_file($post_id, $topic_id, $forum_id, $upload_dir, $filename)
{
global $message_parser, $db, $user, $phpbb_root_path;
@@ -1410,7 +1410,7 @@ function upload_file($post_id, $topic_id, $forum_id, $upload_dir, $filename)
$message_parser->filename_data['filecomment'] = '';
$message_parser->filename_data['filename'] = $phpbb_root_path . $upload_dir . '/' . basename($filename);
- $filedata = upload_attachment($forum_id, $filename, true, $phpbb_root_path . $upload_dir . '/' . basename($filename));
+ $filedata = upload_attachment('local', $forum_id, true, $phpbb_root_path . $upload_dir . '/' . basename($filename));
if ($filedata['post_attach'] && !sizeof($filedata['error']))
{
@@ -1460,7 +1460,6 @@ function upload_file($post_id, $topic_id, $forum_id, $upload_dir, $filename)
echo '<span style="color:red">' . sprintf($user->lang['ADMIN_UPLOAD_ERROR'], implode("<br />\t", $filedata['error'])) . '</span><br /><br />';
}
}
-*/
// Search Imagick
function search_imagemagick()
diff --git a/phpBB/adm/admin_bbcodes.php b/phpBB/adm/admin_bbcodes.php
index ebd82675aa..642e863d92 100644
--- a/phpBB/adm/admin_bbcodes.php
+++ b/phpBB/adm/admin_bbcodes.php
@@ -31,19 +31,19 @@ require('pagestart.' . $phpEx);
// Do we have general permissions?
if (!$auth->acl_get('a_bbcode'))
{
- trigger_error($user->lang['NO_ADMIN']);
+ trigger_error('NO_ADMIN');
}
// Set up general vars
-$mode = (!empty($_REQUEST['mode'])) ? $_REQUEST['mode'] : '';
-$bbcode_id = (!empty($_REQUEST['bbcode'])) ? intval($_REQUEST['bbcode']) : 0;
+$mode = request_var('mode', '');
+$bbcode_id = request_var('bbcode', 0);
// Set up mode-specific vars
switch ($mode)
{
case 'add':
$bbcode_match = $bbcode_tpl = '';
- break;
+ break;
case 'edit':
$sql = 'SELECT bbcode_match, bbcode_tpl
@@ -54,10 +54,11 @@ switch ($mode)
{
trigger_error('BBCODE_NOT_EXIST');
}
+ $db->sql_freeresult($result);
$bbcode_match = $row['bbcode_match'];
$bbcode_tpl = htmlspecialchars($row['bbcode_tpl']);
- break;
+ break;
case 'modify':
$sql = 'SELECT bbcode_id
@@ -68,13 +69,14 @@ switch ($mode)
{
trigger_error('BBCODE_NOT_EXIST');
}
+ $db->sql_freeresult($result);
// No break here
case 'create':
$bbcode_match = htmlspecialchars(stripslashes($_POST['bbcode_match']));
$bbcode_tpl = stripslashes($_POST['bbcode_tpl']);
- break;
+ break;
}
// Do major work
@@ -164,7 +166,7 @@ switch ($mode)
<?php
adm_page_footer();
- break;
+ break;
case 'modify':
case 'create':
@@ -173,13 +175,13 @@ switch ($mode)
$data = build_regexp($bbcode_match, $bbcode_tpl);
$sql_ary = array(
- 'bbcode_tag' => $data['bbcode_tag'],
- 'bbcode_match' => $bbcode_match,
- 'bbcode_tpl' => $bbcode_tpl,
- 'first_pass_match' => $data['first_pass_match'],
- 'first_pass_replace' => $data['first_pass_replace'],
- 'second_pass_match' => $data['second_pass_match'],
- 'second_pass_replace' => $data['second_pass_replace']
+ 'bbcode_tag' => $data['bbcode_tag'],
+ 'bbcode_match' => $bbcode_match,
+ 'bbcode_tpl' => $bbcode_tpl,
+ 'first_pass_match' => $data['first_pass_match'],
+ 'first_pass_replace' => $data['first_pass_replace'],
+ 'second_pass_match' => $data['second_pass_match'],
+ 'second_pass_replace' => $data['second_pass_replace']
);
if ($mode == 'create')
@@ -193,10 +195,12 @@ switch ($mode)
HAVING MIN(b2.bbcode_id) > b1.bbcode_id + 1
ORDER BY b1.bbcode_id ASC';
$result = $db->sql_query_limit($sql, 1);
+ $row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
- if ($row = $db->sql_fetchrow($result))
+ if ($row)
{
- $bbcode_id = $row['bbcode_id'] + 1;
+ $bbcode_id = $row['bbcode_id'] + 1;
}
else
{
@@ -204,6 +208,7 @@ switch ($mode)
FROM ' . BBCODES_TABLE;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
if (empty($row['min_id']) || $row['min_id'] >= NUM_CORE_BBCODES)
{
@@ -236,7 +241,7 @@ switch ($mode)
add_log('admin', $log_action, $data['bbcode_tag']);
trigger_error($lang);
- break;
+ break;
case 'delete':
$sql = 'SELECT bbcode_tag
@@ -249,6 +254,7 @@ switch ($mode)
$db->sql_query('DELETE FROM ' . BBCODES_TABLE . " WHERE bbcode_id = $bbcode_id");
add_log('admin', 'LOG_BBCODE_DELETE', $row['bbcode_tag']);
}
+ $db->sql_freeresult($result);
// No break here
@@ -287,6 +293,7 @@ switch ($mode)
</tr>
<?php
}
+ $db->sql_freeresult($result);
?>
@@ -414,13 +421,14 @@ function build_regexp($msg_bbcode, $msg_html)
$sp_replace = preg_replace('#\[/?' . $bbcode_tag . '#ie', "strtolower('\$0')", $sp_replace);
return array(
- 'bbcode_tag' => $bbcode_tag,
- 'first_pass_match' => $fp_match,
- 'first_pass_replace' => $fp_replace,
- 'second_pass_match' => $sp_match,
- 'second_pass_replace' => $sp_replace
+ 'bbcode_tag' => $bbcode_tag,
+ 'first_pass_match' => $fp_match,
+ 'first_pass_replace' => $fp_replace,
+ 'second_pass_match' => $sp_match,
+ 'second_pass_replace' => $sp_replace
);
}
// End Functions
// -----------------------------
+
?> \ No newline at end of file
diff --git a/phpBB/adm/admin_bots.php b/phpBB/adm/admin_bots.php
index 994d9ba634..92292ad0fc 100644
--- a/phpBB/adm/admin_bots.php
+++ b/phpBB/adm/admin_bots.php
@@ -59,6 +59,8 @@ switch ($action)
WHERE bot_id $id";
$db->sql_query($sql);
}
+
+ $cache->destroy('bots');
break;
case 'deactivate':
@@ -70,6 +72,8 @@ switch ($action)
WHERE bot_id $id";
$db->sql_query($sql);
}
+
+ $cache->destroy('bots');
break;
case 'delete':
@@ -105,6 +109,8 @@ switch ($action)
$db->sql_transaction('commit');
+ $cache->destroy('bots');
+
add_log('admin', 'LOG_BOT_DELETE', implode(', ', $bot_name_ary));
trigger_error($user->lang['BOT_DELETED']);
}
@@ -125,6 +131,7 @@ switch ($action)
{
$error[] = $user->lang['ERR_BOT_NO_MATCHES'];
}
+
if ($bot_ip && !preg_match('#^[\d\.,:]+$#', $bot_ip))
{
if (!$ip_list = gethostbynamel($bot_ip))
@@ -218,6 +225,8 @@ switch ($action)
$db->sql_transaction('commit');
+ $cache->destroy('bots');
+
add_log('admin', 'LOG_BOT_' . $log, $bot_name);
trigger_error($user->lang['BOT_' . $log]);
}
@@ -345,6 +354,7 @@ $sql = 'SELECT b.bot_id, b.bot_name, b.bot_active, u.user_lastvisit
ORDER BY u.user_lastvisit DESC';
$result = $db->sql_query($sql);
+$row_class = '';
while ($row = $db->sql_fetchrow($result))
{
$row_class = ($row_class == 'row1') ? 'row2' : 'row1';
diff --git a/phpBB/adm/admin_styles.php b/phpBB/adm/admin_styles.php
index 1d0d746f21..71a5058bbe 100644
--- a/phpBB/adm/admin_styles.php
+++ b/phpBB/adm/admin_styles.php
@@ -3051,7 +3051,7 @@ function install($type, $action, $id)
<tr>
<td class="row1" width="40%"><b><?php echo $user->lang[$l_type . '_NAME']; ?>:</b></td>
<td class="row2"><?php
- $style_name = 'proSilver';
+ $style_name = 'subSilver2';
$style_copyright = '(c) 2004 Tom Beddard';
echo ($action == 'add') ? '<input class="post" type="text" name="name" maxlength="30" size="30" value="' . $name . '" />' : '<b>' . ${$type . '_name'} . '</b>';
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 4c749eb354..d5accb90cf 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -1117,6 +1117,36 @@ function obtain_attach_extensions(&$extensions, $forum_id = false)
}
/**
+* Obtain active bots
+*/
+function obtain_bots(&$bots)
+{
+ global $db, $cache;
+
+ if ($cache->exists('bots'))
+ {
+ $bots = $cache->get('bots');
+ }
+ else
+ {
+ $sql = 'SELECT user_id, bot_agent, bot_ip
+ FROM ' . BOTS_TABLE . '
+ WHERE bot_active = 1';
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $bots[] = $row;
+ }
+ $db->sql_freeresult($result);
+
+ $cache->put('bots', $bots);
+ }
+
+ return;
+}
+
+/**
* Generate board url
*/
function generate_board_url()
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index ee97ffdc76..989d34a287 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -1492,9 +1492,9 @@ function remove_comments(&$output)
$linecount = sizeof($lines);
$in_comment = false;
- for($i = 0; $i < $linecount; $i++)
+ for ($i = 0; $i < $linecount; $i++)
{
- if (preg_match('#^\/\*#', preg_quote($lines[$i])))
+ if (trim($lines[$i]) == '/*')
{
$in_comment = true;
}
@@ -1504,7 +1504,7 @@ function remove_comments(&$output)
$output .= $lines[$i] . "\n";
}
- if (preg_match('#\*\/$#', preg_quote($lines[$i])))
+ if (trim($lines[$i]) == '*/')
{
$in_comment = false;
}
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index b53492a5a7..e1055cd5f8 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -148,10 +148,18 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage
include_once($phpbb_root_path . 'includes/functions_upload.php');
$upload = new fileupload();
- $filedata['post_attach'] = ($upload->is_valid($form_name)) ? true : false;
+ if (!$local)
+ {
+ $filedata['post_attach'] = ($upload->is_valid($form_name)) ? true : false;
+ }
+ else
+ {
+ $filedata['post_attach'] = true;
+ }
if (!$filedata['post_attach'])
{
+ $filedata['error'][] = 'No filedata found';
return $filedata;
}
diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php
index 250b948c7d..28041c87fa 100644
--- a/phpBB/includes/functions_upload.php
+++ b/phpBB/includes/functions_upload.php
@@ -56,6 +56,12 @@ class filespec
// Opera adds the name to the mime type
$this->mimetype = (strpos($this->mimetype, '; name') !== false) ? str_replace(strstr($this->mimetype, '; name'), '', $this->mimetype) : $this->mimetype;
+
+ if (!$this->mimetype)
+ {
+ $this->mimetype = 'application/octetstream';
+ }
+
$this->extension = array_pop(explode('.', strtolower($this->realname)));
// Try to get real filesize from temporary folder (not always working) ;)
@@ -122,7 +128,12 @@ class filespec
function is_uploaded()
{
- return (file_exists($this->filename) && is_uploaded_file($this->filename)) ? true : false;
+ if (!$this->local && !is_uploaded_file($this->filename))
+ {
+ return false;
+ }
+
+ return (file_exists($this->filename)) ? true : false;
}
function remove()
@@ -394,8 +405,64 @@ class fileupload
}
// Move file from another location to phpBB
- function local_upload($source_file)
+ function local_upload($source_file, $filedata = false)
{
+ global $user;
+
+ $form_name = 'local';
+
+ $_FILES[$form_name]['local_mode'] = true;
+ $_FILES[$form_name]['tmp_name'] = $source_file;
+
+ if ($filedata === false)
+ {
+ $_FILES[$form_name]['name'] = basename($source_file);
+ $_FILES[$form_name]['size'] = 0;
+ $_FILES[$form_name]['type'] = '';
+ }
+ else
+ {
+ $_FILES[$form_name]['name'] = $filedata['realname'];
+ $_FILES[$form_name]['size'] = $filedata['size'];
+ $_FILES[$form_name]['type'] = $filedata['type'];
+ }
+
+ $file = new filespec($_FILES[$form_name], $this);
+
+ if ($file->init_error)
+ {
+ $file->error[] = '';
+ return $file;
+ }
+
+ if (isset($_FILES[$form_name]['error']))
+ {
+ $error = $this->assign_internal_error($_FILES[$form_name]['error']);
+
+ if ($error !== false)
+ {
+ $file->error[] = $error;
+ return $file;
+ }
+ }
+
+ // PHP Upload filesize exceeded
+ if ($file->get('filename') == 'none')
+ {
+ $file->error[] = (@ini_get('upload_max_filesize') == '') ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize'));
+ return $file;
+ }
+
+ // Not correctly uploaded
+ if (!$file->is_uploaded())
+ {
+ $file->error[] = $user->lang[$this->error_prefix . 'NOT_UPLOADED'];
+ return $file;
+ }
+
+ $this->common_checks($file);
+
+ return $file;
}
/**
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index 768f1dddd1..c85fa7a393 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -138,12 +138,10 @@ class session
$bot = false;
// Pull bot information from DB and loop through it
- $sql = 'SELECT user_id, bot_agent, bot_ip
- FROM ' . BOTS_TABLE . '
- WHERE bot_active = 1';
- $result = $db->sql_query($sql);
+ $active_bots = array();
+ obtain_bots($active_bots);
- while ($row = $db->sql_fetchrow($result))
+ foreach ($active_bots as $row)
{
if ($row['bot_agent'] && preg_match('#' . preg_quote($row['bot_agent'], '#') . '#i', $this->browser))
{
@@ -168,7 +166,6 @@ class session
break;
}
}
- $db->sql_freeresult($result);
// Garbage collection ... remove old sessions updating user information
// if necessary. It means (potentially) 11 queries but only infrequently
@@ -586,7 +583,7 @@ class user extends session
$style = ($style) ? $style : ((!$config['override_user_style'] && $this->data['user_id'] != ANONYMOUS) ? $this->data['user_style'] : $config['default_style']);
}
- // TODO: DISTINCT making problems with DBMS not able to distinct TEXT fields
+ // TODO: DISTINCT making problems with DBMS not able to distinct TEXT fields, test grouping
switch (SQL_LAYER)
{
case 'mssql':
@@ -596,16 +593,18 @@ class user extends session
WHERE s.style_id IN ($style, " . $config['default_style'] . ')
AND t.template_id = s.template_id
AND c.theme_id = s.theme_id
- AND i.imageset_id = s.imageset_id';
+ AND i.imageset_id = s.imageset_id
+ GROUP BY s.style_id';
break;
default:
- $sql = 'SELECT DISTINCT s.style_id, t.*, c.*, i.*
+ $sql = 'SELECT s.style_id, t.*, c.*, i.*
FROM ' . STYLES_TABLE . ' s, ' . STYLES_TPL_TABLE . ' t, ' . STYLES_CSS_TABLE . ' c, ' . STYLES_IMAGE_TABLE . " i
WHERE s.style_id IN ($style, " . $config['default_style'] . ')
AND t.template_id = s.template_id
AND c.theme_id = s.theme_id
- AND i.imageset_id = s.imageset_id';
+ AND i.imageset_id = s.imageset_id
+ GROUP BY s.style_id';
break;
}
$result = $db->sql_query($sql, 3600);
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index 1ea022dc00..ac16b11e18 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -45,37 +45,23 @@ if (!$user->data['is_registered'])
}
else
{
- switch (SQL_LAYER)
+ if ($config['load_db_lastread'])
{
- case 'oracle':
- if ($config['load_db_lastread'])
- {
- }
- else
- {
- }
- break;
-
- default:
- if ($config['load_db_lastread'])
- {
- $sql_lastread = 'LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . '
- AND ft.forum_id = f.forum_id)';
- $lastread_select = ', ft.mark_time ';
- }
- else
- {
- $sql_lastread = $lastread_select = '';
-
- $tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_track'])) : array();
- }
+ $sql_lastread = 'LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . '
+ AND ft.forum_id = f.forum_id)';
+ $lastread_select = ', ft.mark_time ';
+ }
+ else
+ {
+ $sql_lastread = $lastread_select = '';
+ $tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_track'])) : array();
+ }
- $sql_from = ($sql_lastread) ? '((' . FORUMS_TABLE . ' f LEFT JOIN ' . FORUMS_WATCH_TABLE . ' fw ON (fw.forum_id = f.forum_id AND fw.user_id = ' . $user->data['user_id'] . ")) $sql_lastread)" : '(' . FORUMS_TABLE . ' f LEFT JOIN ' . FORUMS_WATCH_TABLE . ' fw ON (fw.forum_id = f.forum_id AND fw.user_id = ' . $user->data['user_id'] . '))';
+ $sql_from = ($sql_lastread) ? '((' . FORUMS_TABLE . ' f LEFT JOIN ' . FORUMS_WATCH_TABLE . ' fw ON (fw.forum_id = f.forum_id AND fw.user_id = ' . $user->data['user_id'] . ")) $sql_lastread)" : '(' . FORUMS_TABLE . ' f LEFT JOIN ' . FORUMS_WATCH_TABLE . ' fw ON (fw.forum_id = f.forum_id AND fw.user_id = ' . $user->data['user_id'] . '))';
- $sql = "SELECT f.*, fw.notify_status $lastread_select
- FROM $sql_from
- WHERE f.forum_id = $forum_id";
- }
+ $sql = "SELECT f.*, fw.notify_status $lastread_select
+ FROM $sql_from
+ WHERE f.forum_id = $forum_id";
}
$result = $db->sql_query($sql);
@@ -301,15 +287,7 @@ if ($forum_data['forum_type'] == FORUM_POST || ($forum_data['forum_flags'] & 16)
// Grab all topic data
$rowset = $announcement_list = $topic_list = array();
- switch (SQL_LAYER)
- {
- case 'oracle':
- break;
-
- default:
- $sql_from = (($config['load_db_lastread'] || $config['load_db_track']) && $user->data['is_registered']) ? '(' . TOPICS_TABLE . ' t LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . '))' : TOPICS_TABLE . ' t ';
- }
-
+ $sql_from = (($config['load_db_lastread'] || $config['load_db_track']) && $user->data['is_registered']) ? '(' . TOPICS_TABLE . ' t LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . '))' : TOPICS_TABLE . ' t ';
$sql_approved = ($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1';
$sql_select = (($config['load_db_lastread'] || $config['load_db_track']) && $user->data['is_registered']) ? ', tt.mark_type, tt.mark_time' : '';
@@ -355,10 +333,9 @@ if ($forum_data['forum_type'] == FORUM_POST || ($forum_data['forum_flags'] & 16)
}
// Obtain other topics
-// $sql_rownum = (SQL_LAYER != 'oracle') ? '' : ', ROWNUM rnum ';
- $sql_rownum = '';
$sql_where = ($forum_data['forum_type'] == FORUM_POST || !sizeof($active_forum_ary)) ? "= $forum_id" : 'IN (' . implode(', ', $active_forum_ary['forum_id']) . ')';
- $sql = "SELECT t.* $sql_select$sql_rownum
+
+ $sql = "SELECT t.* $sql_select
FROM $sql_from
WHERE t.forum_id $sql_where
AND t.topic_type NOT IN (" . POST_ANNOUNCE . ', ' . POST_GLOBAL . ")
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index c78d3c6849..9182333e72 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -169,22 +169,11 @@ $order_sql = (!$post_id) ? '' : 'GROUP BY p.post_id, t.topic_id, t.topic_title,
if ($user->data['is_registered'])
{
- switch (SQL_LAYER)
- {
- case 'oracle':
- case 'postgres':
- case 'mssql':
- case 'mssql-odbc':
- // TODO
- break;
-
- default:
- $extra_fields .= ', tw.notify_status' . (($config['allow_bookmarks']) ? ', bm.order_id as bookmarked' : '');
- $join_sql_table .= ' LEFT JOIN ' . TOPICS_WATCH_TABLE . ' tw ON (tw.user_id = ' . $user->data['user_id'] . '
- AND t.topic_id = tw.topic_id)';
- $join_sql_table .= ($config['allow_bookmarks']) ? ' LEFT JOIN ' . BOOKMARKS_TABLE . ' bm ON (bm.user_id = ' . $user->data['user_id'] . '
- AND t.topic_id = bm.topic_id)' : '';
- }
+ $extra_fields .= ', tw.notify_status' . (($config['allow_bookmarks']) ? ', bm.order_id as bookmarked' : '');
+ $join_sql_table .= ' LEFT JOIN ' . TOPICS_WATCH_TABLE . ' tw ON (tw.user_id = ' . $user->data['user_id'] . '
+ AND t.topic_id = tw.topic_id)';
+ $join_sql_table .= ($config['allow_bookmarks']) ? ' LEFT JOIN ' . BOOKMARKS_TABLE . ' bm ON (bm.user_id = ' . $user->data['user_id'] . '
+ AND t.topic_id = bm.topic_id)' : '';
}
// Join to forum table on topic forum_id unless topic forum_id is zero
@@ -743,8 +732,8 @@ if (empty($post_list))
}
$sql = 'SELECT u.username, u.user_id, u.user_colour, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_jabber, u.user_regdate, u.user_msnm, u.user_allow_viewemail, u.user_allow_viewonline, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, z.friend, z.foe, p.*
- FROM ((' . POSTS_TABLE . ' p
- LEFT JOIN ' . ZEBRA_TABLE . ' z ON (z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id)), ' . USERS_TABLE . ' u)
+ FROM (' . POSTS_TABLE . ' p
+ LEFT JOIN ' . ZEBRA_TABLE . ' z ON (z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id)), ' . USERS_TABLE . ' u
WHERE p.post_id IN (' . implode(', ', $post_list) . ')
AND u.user_id = p.poster_id';
$result = $db->sql_query($sql);
@@ -951,7 +940,6 @@ while ($row = $db->sql_fetchrow($result))
}
}
}
-while ($row = $db->sql_fetchrow($result));
$db->sql_freeresult($result);
// Load custom profile fields
@@ -1376,7 +1364,7 @@ function get_topic_last_read($topic_id, $forum_id)
FROM ' . TOPICS_TRACK_TABLE . '
WHERE user_id = ' . $user->data['user_id'] . "
AND topic_id = $topic_id";
- $result = $db->sql_query($sql, 1);
+ $result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);