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')
lang[$l_type . '_NAME']; ?>: |
' : '' . ${$type . '_name'} . '';
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
@@ -1116,6 +1116,36 @@ function obtain_attach_extensions(&$extensions, $forum_id = false)
return;
}
+/**
+* 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
*/
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_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_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 = "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);
|