aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/bbcode.php6
-rw-r--r--phpBB/includes/captcha/plugins/captcha_abstract.php7
-rw-r--r--phpBB/includes/classes/session.php9
-rw-r--r--phpBB/includes/classes/template_compile.php8
-rw-r--r--phpBB/includes/classes/user.php2
-rw-r--r--phpBB/includes/constants.php2
-rw-r--r--phpBB/includes/core/system.php3
-rw-r--r--phpBB/includes/functions_admin.php27
-rw-r--r--phpBB/includes/functions_content.php2
-rw-r--r--phpBB/includes/functions_display.php2
-rw-r--r--phpBB/includes/functions_messenger.php19
-rw-r--r--phpBB/includes/functions_posting.php16
-rw-r--r--phpBB/includes/functions_privmsgs.php11
-rw-r--r--phpBB/includes/functions_transfer.php39
-rw-r--r--phpBB/includes/functions_upload.php39
-rw-r--r--phpBB/includes/functions_user.php5
-rw-r--r--phpBB/includes/message_parser.php6
-rw-r--r--phpBB/includes/search/fulltext_mysql.php6
-rw-r--r--phpBB/includes/search/fulltext_native.php31
19 files changed, 190 insertions, 50 deletions
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php
index d0cfd2f044..22aa43431e 100644
--- a/phpBB/includes/bbcode.php
+++ b/phpBB/includes/bbcode.php
@@ -1,4 +1,4 @@
-<?php
+18.04.2009<?php
/**
*
* @package phpBB3
@@ -509,12 +509,12 @@ class bbcode
else if (is_numeric($type))
{
$tpl = 'olist_open';
- $type = 'arabic-numbers';
+ $type = 'decimal';
}
else
{
$tpl = 'olist_open';
- $type = 'arabic-numbers';
+ $type = 'decimal';
}
return str_replace('{LIST_TYPE}', $type, $this->bbcode_tpl($tpl));
diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php
index 621fea414a..4f494b9c69 100644
--- a/phpBB/includes/captcha/plugins/captcha_abstract.php
+++ b/phpBB/includes/captcha/plugins/captcha_abstract.php
@@ -29,6 +29,8 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
protected $type;
protected $solved = false;
+ protected $min_chars = 4;
+ protected $max_chars = 7;
function init($type)
{
@@ -46,7 +48,7 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
function execute_demo()
{
- $this->code = gen_rand_string(mt_rand(5, 8));
+ $this->code = gen_rand_string(mt_rand($this->min_chars, $this->max_chars));
$this->seed = hexdec(substr(unique_id(), 4, 10));
// compute $seed % 0x7fffffff
@@ -188,10 +190,11 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
*/
protected function generate_code()
{
- $this->code = gen_rand_string(mt_rand(5, 8));
+ $this->code = gen_rand_string(mt_rand($this->min_chars, $this->max_chars));
$this->confirm_id = md5(unique_id(phpbb::$user->ip));
$this->seed = hexdec(substr(unique_id(), 4, 10));
$this->solved = false;
+
// compute $seed % 0x7fffffff
$this->seed -= 0x7fffffff * floor($this->seed / 0x7fffffff);
diff --git a/phpBB/includes/classes/session.php b/phpBB/includes/classes/session.php
index 05a2b60a66..ca54bae552 100644
--- a/phpBB/includes/classes/session.php
+++ b/phpBB/includes/classes/session.php
@@ -420,6 +420,15 @@ abstract class phpbb_session
}
}
+ // Something quite important: session_page always holds the *last* page visited, except for the *first* visit.
+ // We are not able to simply have an empty session_page btw, therefore we need to tell phpBB how to detect this special case.
+ // If the session id is empty, we have a completely new one and will set an "identifier" here. This identifier is able to be checked later.
+ if (empty($this->data['session_id']))
+ {
+ // This is a temporary variable, only set for the very first visit
+ $this->data['session_created'] = true;
+ }
+
$this->session_id = $this->data['session_id'] = md5(phpbb::$security->unique_id());
$sql_ary['session_id'] = (string) $this->session_id;
diff --git a/phpBB/includes/classes/template_compile.php b/phpBB/includes/classes/template_compile.php
index 3f6f82f5df..098d8f4817 100644
--- a/phpBB/includes/classes/template_compile.php
+++ b/phpBB/includes/classes/template_compile.php
@@ -187,8 +187,8 @@ class phpbb_template_filter extends php_user_filter
$this->compile_language_tags($text_blocks);
// This will handle the remaining root-level varrefs
- $text_blocks = preg_replace('#\{([a-z0-9\-_]*)\}#is', "<?php echo (isset(\$_rootref['\\1'])) ? \$_rootref['\\1'] : ''; ?>", $text_blocks);
- $text_blocks = preg_replace('#\{\$([a-z0-9\-_]*)\}#is', "<?php echo (isset(\$_tpldata['DEFINE']['.']['\\1'])) ? \$_tpldata['DEFINE']['.']['\\1'] : ''; ?>", $text_blocks);
+ $text_blocks = preg_replace('#\{([A-Z0-9\-_]+)\}#', "<?php echo (isset(\$_rootref['\\1'])) ? \$_rootref['\\1'] : ''; ?>", $text_blocks);
+ $text_blocks = preg_replace('#\{\$([A-Z0-9\-_]+)\}#', "<?php echo (isset(\$_tpldata['DEFINE']['.']['\\1'])) ? \$_tpldata['DEFINE']['.']['\\1'] : ''; ?>", $text_blocks);
return $text_blocks;
}
@@ -201,14 +201,14 @@ class phpbb_template_filter extends php_user_filter
// transform vars prefixed by L_ into their language variable pendant if nothing is set within the tpldata array
if (strpos($text_blocks, '{L_') !== false)
{
- $text_blocks = preg_replace('#\{L_([a-z0-9\-_]*)\}#is', "<?php echo (isset(\$_rootref['L_\\1'])) ? \$_rootref['L_\\1'] : (isset(\$_lang['\\1']) ? \$_lang['\\1'] : '{ \\1 }'); ?>", $text_blocks);
+ $text_blocks = preg_replace('#\{L_([A-Z0-9\-_]+)\}#', "<?php echo ((isset(\$_rootref['L_\\1'])) ? \$_rootref['L_\\1'] : ((isset(\$_lang['\\1'])) ? \$_lang['\\1'] : '{ \\1 }')); ?>", $text_blocks);
}
// Handle addslashed language variables prefixed with LA_
// If a template variable already exist, it will be used in favor of it...
if (strpos($text_blocks, '{LA_') !== false)
{
- $text_blocks = preg_replace('#\{LA_([a-z0-9\-_]*)\}#is', "<?php echo (isset(\$_rootref['LA_\\1'])) ? \$_rootref['LA_\\1'] : ((isset(\$_rootref['L_\\1'])) ? addslashes(\$_rootref['L_\\1']) : (isset(\$_lang['\\1']) ? addslashes(\$_lang['\\1']) : '{ \\1 }')); ?>", $text_blocks);
+ $text_blocks = preg_replace('#\{LA_([A-Z0-9\-_]+)\}#', "<?php echo ((isset(\$_rootref['LA_\\1'])) ? \$_rootref['LA_\\1'] : ((isset(\$_rootref['L_\\1'])) ? addslashes(\$_rootref['L_\\1']) : ((isset(\$_lang['\\1'])) ? addslashes(\$_lang['\\1']) : '{ \\1 }'))); ?>", $text_blocks);
}
}
diff --git a/phpBB/includes/classes/user.php b/phpBB/includes/classes/user.php
index e060bcda52..83e8fce4eb 100644
--- a/phpBB/includes/classes/user.php
+++ b/phpBB/includes/classes/user.php
@@ -953,7 +953,7 @@ class phpbb_user extends phpbb_session
return $img_data;
}
- $img_data['src'] = PHPBB_ROOT_PATH . 'styles/' . $this->theme['imageset_path'] . '/imageset/' . ($this->img_array[$img]['image_lang'] ? $this->img_array[$img]['image_lang'] .'/' : '') . $this->img_array[$img]['image_filename'];
+ $img_data['src'] = PHPBB_ROOT_PATH . 'styles/' . rawurlencode($this->theme['imageset_path']) . '/imageset/' . ($this->img_array[$img]['image_lang'] ? $this->img_array[$img]['image_lang'] .'/' : '') . $this->img_array[$img]['image_filename'];
$img_data['width'] = $this->img_array[$img]['image_width'];
$img_data['height'] = $this->img_array[$img]['image_height'];
}
diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php
index f4863bd24f..8fc06cb352 100644
--- a/phpBB/includes/constants.php
+++ b/phpBB/includes/constants.php
@@ -25,7 +25,7 @@ if (!defined('IN_PHPBB'))
*/
// phpBB Version
-define('PHPBB_VERSION', '3.1.0-dev');
+define('PHPBB_VERSION', '3.1.0-dev1');
// QA-related
// define('PHPBB_QA', 1);
diff --git a/phpBB/includes/core/system.php b/phpBB/includes/core/system.php
index 55dca1d311..5bb42e9ed4 100644
--- a/phpBB/includes/core/system.php
+++ b/phpBB/includes/core/system.php
@@ -107,6 +107,9 @@ class phpbb_system extends phpbb_plugin_support
if ($this->chmod_info['process'])
{
+ $file_uid = fileowner($filename);
+ $file_gid = filegroup($filename);
+
// Change owner
if (@chown($filename, $this->chmod_info['common_owner']))
{
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index ead47e4dba..884c5526c4 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -633,7 +633,24 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
return false;
}
- $where_clause = phpbb::$db->sql_in_set($where_type, array_map('intval', $where_ids));
+ $where_ids = array_map('intval', $where_ids);
+
+ // Split post deletion into chunks to overcome database limitations
+ if (sizeof($where_ids) >= 1001)
+ {
+ // Split into chunks of 1000
+ $chunks = array_chunk($where_ids, 1000);
+ $removed_posts = 0;
+
+ foreach ($chunks as $_where_ids)
+ {
+ $removed_posts += delete_posts($where_type, $_where_ids, $auto_sync, $posted_sync, $post_count_sync, $call_delete_topics);
+ }
+
+ return $removed_posts;
+ }
+
+ $where_clause = phpbb::$db->sql_in_set($where_type, $where_ids);
}
$approved_posts = 0;
@@ -646,10 +663,10 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
while ($row = phpbb::$db->sql_fetchrow($result))
{
- $post_ids[] = $row['post_id'];
- $poster_ids[] = $row['poster_id'];
- $topic_ids[] = $row['topic_id'];
- $forum_ids[] = $row['forum_id'];
+ $post_ids[] = (int) $row['post_id'];
+ $poster_ids[] = (int) $row['poster_id'];
+ $topic_ids[] = (int) $row['topic_id'];
+ $forum_ids[] = (int) $row['forum_id'];
if ($row['post_postcount'] && $post_count_sync && $row['post_approved'])
{
diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php
index 27d70a708c..64c915b7dd 100644
--- a/phpBB/includes/functions_content.php
+++ b/phpBB/includes/functions_content.php
@@ -1108,7 +1108,7 @@ function truncate_string($string, $max_length = 60, $max_store_length = 255, $al
array_pop($chars);
$string = implode('', $chars);
}
- while (utf8_strlen($string) > $max_store_length || !sizeof($chars));
+ while (!empty($chars) && utf8_strlen($string) > $max_store_length);
}
if ($strip_reply)
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index 18f23fbeea..cf12a60aec 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -234,7 +234,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
// Handle marking posts
if ($mark_read == 'forums' || $mark_read == 'all')
{
- $redirect = phpbb::$url->build_url('mark', 'hash');
+ $redirect = phpbb::$url->build_url(array('mark', 'hash'));
$token = request_var('hash', '');
if (phpbb::$security->check_link($token, 'global'))
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index a985a7b2ec..8d15e8a13f 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -176,7 +176,8 @@ class messenger
if (empty($this->tpl_msg[$template_lang . $template_file]))
{
- $tpl_file = PHPBB_ROOT_PATH . "language/$template_lang/email/$template_file.txt";
+ $tpl_file = (!empty(phpbb::$user->lang_path)) ? phpbb::$user->lang_path : PHPBB_ROOT_PATH . 'language/';
+ $tpl_file .= $template_lang . "/email/$template_file.txt";
if (!file_exists($tpl_file))
{
@@ -1401,9 +1402,10 @@ function mail_encode($str)
// define start delimimter, end delimiter and spacer
$start = "=?UTF-8?B?";
$end = "?=";
- $spacer = $end . ' ' . $start;
- $split_length = 64;
+ $delimiter = "\r\n ";
+ // Maximum length is 75. $split_length *must* be a multiple of 4, but <= 75 - strlen($start . $delimiter . $end)!!!
+ $split_length = 60;
$encoded_str = base64_encode($str);
// If encoded string meets the limits, we just return with the correct data.
@@ -1415,7 +1417,7 @@ function mail_encode($str)
// If there is only ASCII data, we just return what we want, correctly splitting the lines.
if (strlen($str) === utf8_strlen($str))
{
- return $start . implode($spacer, str_split($encoded_str, $split_length)) . $end;
+ return $start . implode($end . $delimiter . $start, str_split($encoded_str, $split_length)) . $end;
}
// UTF-8 data, compose encoded lines
@@ -1426,16 +1428,15 @@ function mail_encode($str)
{
$text = '';
- while (sizeof($array) && intval((strlen($text . current($array)) + 2) / 3) << 2 <= $split_length)
+ while (sizeof($array) && intval((strlen($text . $array[0]) + 2) / 3) << 2 <= $split_length)
{
- $text .= current($array);
- unset($array[key($array)]);
+ $text .= array_shift($array);
}
- $str .= $start . base64_encode($text) . $end . ' ';
+ $str .= $start . base64_encode($text) . $end . $delimiter;
}
- return substr($str, 0, -1);
+ return substr($str, 0, -strlen($delimiter));
}
?> \ No newline at end of file
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index baa2ab3180..1b5e434215 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -600,7 +600,7 @@ function create_thumbnail($source, $destination, $mimetype)
list($new_width, $new_height) = get_img_size_format($width, $height);
// Do not create a thumbnail if the resulting width/height is bigger than the original one
- if ($new_width > $width && $new_height > $height)
+ if ($new_width >= $width && $new_height >= $height)
{
return false;
}
@@ -1101,7 +1101,7 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
if (!$topic_notification && !$forum_notification)
{
- trigger_error('WRONG_NOTIFICATION_MODE');
+ trigger_error('NO_MODE');
}
if (($topic_notification && !phpbb::$config['allow_topic_notify']) || ($forum_notification && !phpbb::$config['allow_forum_notify']))
@@ -1708,6 +1708,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$sql_data[TOPICS_TABLE]['sql'] = array(
'topic_poster' => (int) phpbb::$user->data['user_id'],
'topic_time' => $current_time,
+ 'topic_last_view_time' => $current_time,
'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'],
'icon_id' => $data['icon_id'],
'topic_approved' => $post_approval,
@@ -1755,7 +1756,13 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
break;
case 'reply':
- $sql_data[TOPICS_TABLE]['stat'][] = 'topic_replies_real = topic_replies_real + 1, topic_bumped = 0, topic_bumper = 0' . (($post_approval) ? ', topic_replies = topic_replies + 1' : '') . ((!empty($data['attachment_data']) || (isset($data['topic_attachment']) && $data['topic_attachment'])) ? ', topic_attachment = 1' : '');
+ $sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_view_time = ' . $current_time . ',
+ topic_replies_real = topic_replies_real + 1,
+ topic_bumped = 0,
+ topic_bumper = 0' .
+ (($post_approval) ? ', topic_replies = topic_replies + 1' : '') .
+ ((!empty($data['attachment_data']) || (isset($data['topic_attachment']) && $data['topic_attachment'])) ? ', topic_attachment = 1' : '');
+
$sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . ((phpbb::$acl->acl_get('f_postcount', $data['forum_id']) && $post_approval) ? ', user_posts = user_posts + 1' : '');
if ($post_approval && $topic_type != POST_GLOBAL)
@@ -1794,6 +1801,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
'poll_max_options' => (isset($poll['poll_options'])) ? $poll['poll_max_options'] : 1,
'poll_length' => (isset($poll['poll_options'])) ? $poll_length : 0,
'poll_vote_change' => (isset($poll['poll_vote_change'])) ? $poll['poll_vote_change'] : 0,
+ 'topic_last_view_time' => $current_time,
'topic_attachment' => (!empty($data['attachment_data'])) ? 1 : (isset($data['topic_attachment']) ? $data['topic_attachment'] : 0),
);
@@ -1837,7 +1845,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
// Correctly set back the topic replies and forum posts... but only if the post was approved before.
if (!$post_approval && $data['post_approved'])
{
- $sql_data[TOPICS_TABLE]['stat'][] = 'topic_replies = topic_replies - 1';
+ $sql_data[TOPICS_TABLE]['stat'][] = 'topic_replies = topic_replies - 1, topic_last_view_time = ' . $current_time;
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - 1';
set_config_count('num_posts', -1, true);
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index de7a1e7d18..90060519db 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -1731,8 +1731,14 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
$url = append_sid('ucp', 'i=pm');
$next_history_pm = $previous_history_pm = $prev_id = 0;
- foreach ($rowset as $id => $row)
+ // Re-order rowset to be able to get the next/prev message rows...
+ $rowset = array_values($rowset);
+
+ for ($i = 0, $size = sizeof($rowset); $i < $size; $i++)
{
+ $row = &$rowset[$i];
+ $id = (int) $row['msg_id'];
+
$author_id = $row['author_id'];
$folder_id = (int) $row['folder_id'];
@@ -1763,8 +1769,7 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
if ($id == $msg_id)
{
- $next_history_pm = next($rowset);
- $next_history_pm = (sizeof($next_history_pm)) ? (int) $next_history_pm['msg_id'] : 0;
+ $next_history_pm = (isset($rowset[$i + 1])) ? (int) $rowset[$i + 1]['msg_id'] : 0;
$previous_history_pm = $prev_id;
}
diff --git a/phpBB/includes/functions_transfer.php b/phpBB/includes/functions_transfer.php
index 808f28a147..d7cb11cbf4 100644
--- a/phpBB/includes/functions_transfer.php
+++ b/phpBB/includes/functions_transfer.php
@@ -190,7 +190,7 @@ class transfer
$directory = $this->root_path . str_replace(PHPBB_ROOT_PATH, '', $directory);
$this->_chdir($directory);
- $result = $this->_ls('');
+ $result = $this->_ls();
if ($result !== false && is_array($result))
{
@@ -442,7 +442,24 @@ class ftp extends transfer
*/
private function _ls($dir = './')
{
- return @ftp_nlist($this->connection, $dir);
+ $list = @ftp_nlist($this->connection, $dir);
+
+ // Remove path if prepended
+ foreach ($list as $key => $item)
+ {
+ // Use same separator for item and dir
+ $item = str_replace('\\', '/', $item);
+ $dir = str_replace('\\', '/', $dir);
+
+ if (strpos($item, $dir) === 0)
+ {
+ $item = substr($item, strlen($dir));
+ }
+
+ $list[$key] = $item;
+ }
+
+ return $list;
}
/**
@@ -690,6 +707,24 @@ class ftp_fsock extends transfer
}
$this->_close_data_connection();
+ // Clear buffer
+ $this->_check_command();
+
+ // Remove path if prepended
+ foreach ($list as $key => $item)
+ {
+ // Use same separator for item and dir
+ $item = str_replace('\\', '/', $item);
+ $dir = str_replace('\\', '/', $dir);
+
+ if (strpos($item, $dir) === 0)
+ {
+ $item = substr($item, strlen($dir));
+ }
+
+ $list[$key] = $item;
+ }
+
return $list;
}
diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php
index 63c62215d1..363bfdd768 100644
--- a/phpBB/includes/functions_upload.php
+++ b/phpBB/includes/functions_upload.php
@@ -588,7 +588,18 @@ class fileupload
// PHP Upload filesize exceeded
if ($file->get('filename') == 'none')
{
- $file->error[] = (@ini_get('upload_max_filesize') == '') ? phpbb::$user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf(phpbb::$user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize'));
+ $max_filesize = @ini_get('upload_max_filesize');
+ $unit = 'MB';
+
+ if (!empty($max_filesize))
+ {
+ $unit = strtolower(substr($max_filesize, -1, 1));
+ $max_filesize = (int) $max_filesize;
+
+ $unit = ($unit == 'k') ? 'KB' : (($unit == 'g') ? 'GB' : 'MB');
+ }
+
+ $file->error[] = (empty($max_filesize)) ? phpbb::$user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : phpbb::$user->lang($this->error_prefix . 'PHP_SIZE_OVERRUN', $max_filesize, phpbb::$user->lang[$unit]);
return $file;
}
@@ -662,7 +673,18 @@ class fileupload
// PHP Upload filesize exceeded
if ($file->get('filename') == 'none')
{
- $file->error[] = (@ini_get('upload_max_filesize') == '') ? phpbb::$user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf(phpbb::$user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize'));
+ $max_filesize = @ini_get('upload_max_filesize');
+ $unit = 'MB';
+
+ if (!empty($max_filesize))
+ {
+ $unit = strtolower(substr($max_filesize, -1, 1));
+ $max_filesize = (int) $max_filesize;
+
+ $unit = ($unit == 'k') ? 'KB' : (($unit == 'g') ? 'GB' : 'MB');
+ }
+
+ $file->error[] = (empty($max_filesize)) ? phpbb::$user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : phpbb::$user->lang($this->error_prefix . 'PHP_SIZE_OVERRUN', $max_filesize, phpbb::$user->lang[$unit]);
return $file;
}
@@ -806,7 +828,18 @@ class fileupload
switch ($errorcode)
{
case 1:
- $error = (@ini_get('upload_max_filesize') == '') ? phpbb::$user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf(phpbb::$user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize'));
+ $max_filesize = @ini_get('upload_max_filesize');
+ $unit = 'MB';
+
+ if (!empty($max_filesize))
+ {
+ $unit = strtolower(substr($max_filesize, -1, 1));
+ $max_filesize = (int) $max_filesize;
+
+ $unit = ($unit == 'k') ? 'KB' : (($unit == 'g') ? 'GB' : 'MB');
+ }
+
+ $error = (empty($max_filesize)) ? phpbb::$user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : phpbb::$user->lang($this->error_prefix . 'PHP_SIZE_OVERRUN', $max_filesize, phpbb::$user->lang[$unit]);
break;
case 2:
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 58149b9527..5c22cfb4ef 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -2686,13 +2686,14 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false,
$temp_ary = array();
while ($row = phpbb::$db->sql_fetchrow($result))
{
- if ($default_groups[$row['user_id']] == $group_id && (!isset($temp_ary[$row['user_id']]) || array_search($row['group_name_clean'], $clean_group_order) < $temp_ary[$row['user_id']]))
+ if ($default_groups[$row['user_id']] == $group_id && (!isset($temp_ary[$row['user_id']]) || $group_order_id[$row['group_name']] < $temp_ary[$row['user_id']]))
{
$temp_ary[$row['user_id']] = $row['group_id'];
}
}
phpbb::$db->sql_freeresult($result);
+ // sql_where_ary holds the new default groups and their users
$sql_where_ary = array();
foreach ($temp_ary as $uid => $gid)
{
@@ -2704,7 +2705,7 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false,
{
if (isset($sql_where_ary[$gid]) && sizeof($sql_where_ary[$gid]))
{
- remove_default_rank($group_id, $sql_where_ary[$gid]);
+ remove_default_rank($gid, $sql_where_ary[$gid]);
remove_default_avatar($group_id, $sql_where_ary[$gid]);
group_set_user_default($gid, $sql_where_ary[$gid], $default_data_ary);
}
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index 9a13d2d14c..39c65e054d 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -1037,11 +1037,7 @@ class parse_message extends bbcode_firstpass
{
// Init BBCode UID
$this->bbcode_uid = substr(base_convert(unique_id(), 16, 36), 0, BBCODE_UID_LEN);
-
- if ($message)
- {
- $this->message = $message;
- }
+ $this->message = $message;
}
/**
diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php
index 6430e3b0b8..8c4b8f3c7d 100644
--- a/phpBB/includes/search/fulltext_mysql.php
+++ b/phpBB/includes/search/fulltext_mysql.php
@@ -110,6 +110,12 @@ class fulltext_mysql extends search_backend
preg_match_all('#(?:[^\p{L}\p{N}*"()]|^)([+\-|]?(?:[\p{L}\p{N}*"()]+\'?)*[\p{L}\p{N}*"()])(?:[^\p{L}\p{N}*"()]|$)#u', $split_keywords, $matches);
$this->split_words = $matches[1];
+ // We limit the number of allowed keywords to minimize load on the database
+ if (phpbb::$config['max_num_search_keywords'] && sizeof($this->split_words) > phpbb::$config['max_num_search_keywords'])
+ {
+ trigger_error(phpbb::$user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', phpbb::$config['max_num_search_keywords'], sizeof($this->split_words)));
+ }
+
// to allow phrase search, we need to concatenate quoted words
$tmp_split_words = array();
$phrase = '';
diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php
index 54854651a8..a2cb8936b5 100644
--- a/phpBB/includes/search/fulltext_native.php
+++ b/phpBB/includes/search/fulltext_native.php
@@ -163,6 +163,13 @@ class fulltext_native extends search_backend
);
$keywords = preg_replace($match, $replace, $keywords);
+ $num_keywords = sizeof(explode(' ', $keywords));
+
+ // We limit the number of allowed keywords to minimize load on the database
+ if (phpbb::$config['max_num_search_keywords'] && $num_keywords > phpbb::$config['max_num_search_keywords'])
+ {
+ trigger_error(phpbb::$user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', phpbb::$config['max_num_search_keywords'], $num_keywords));
+ }
// $keywords input format: each word separated by a space, words in a bracket are not separated
@@ -637,7 +644,11 @@ class fulltext_native extends search_backend
if (phpbb::$db->dbms_type === 'mysql')
{
- $sql_array['SELECT'] = 'SQL_CALC_FOUND_ROWS ' . $sql_array['SELECT'];
+ $sql_array_copy = $sql_array;
+
+ // $sql_array['SELECT'] = 'SQL_CALC_FOUND_ROWS ' . $sql_array['SELECT'];
+ $sql_array_copy['SELECT'] = 'SQL_CALC_FOUND_ROWS p.post_id ';
+
$is_mysql = true;
}
else
@@ -710,8 +721,14 @@ class fulltext_native extends search_backend
}
// if we use mysql and the total result count is not cached yet, retrieve it from the db
- if (!$total_results && $is_mysql)
+ if (!$total_results && $is_mysql && !empty($sql_array_copy))
{
+ $sql = phpbb::$db->sql_build_query('SELECT', $sql_array_copy);
+ unset($sql_array_copy);
+
+ phpbb::$db->sql_query($sql);
+ phpbb::$db->sql_freeresult($result);
+
$sql = 'SELECT FOUND_ROWS() as total_results';
$result = phpbb::$db->sql_query($sql);
$total_results = (int) phpbb::$db->sql_fetchfield('total_results');
@@ -831,8 +848,8 @@ class fulltext_native extends search_backend
{
if (phpbb::$db->dbms_type === 'mysql')
{
- $select = 'SQL_CALC_FOUND_ROWS ' . $select;
- $is_mysql = true;
+// $select = 'SQL_CALC_FOUND_ROWS ' . $select;
+ $is_mysql = true;
}
else
{
@@ -923,6 +940,12 @@ class fulltext_native extends search_backend
if (!$total_results && $is_mysql)
{
+ // Count rows for the executed queries. Replace $select within $sql with SQL_CALC_FOUND_ROWS, and run it.
+ $sql = str_replace('SELECT ' . $select, 'SELECT DISTINCT SQL_CALC_FOUND_ROWS p.post_id', $sql);
+
+ phpbb::$db->sql_query($sql);
+ phpbb::$db->sql_freeresult($result);
+
$sql = 'SELECT FOUND_ROWS() as total_results';
$result = phpbb::$db->sql_query($sql);
$total_results = (int) phpbb::$db->sql_fetchfield('total_results');