1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-10-14 00:17:03 +02:00

Merge most changes from 3.0.x branch since the 25th december.

(Captcha changes for refreshing captcha image not included)

git-svn-id: file:///svn/phpbb/trunk@9404 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen
2009-03-22 16:34:26 +00:00
parent fac9c024ff
commit 4cbf6bc703
80 changed files with 2491 additions and 916 deletions

View File

@@ -89,7 +89,7 @@ class phpbb_acm_file extends phpbb_acm_abstract
if ($fp = @fopen($filename, 'wb'))
{
@flock($fp, LOCK_EX);
fwrite($fp, "<?php\n\$expired = (time() > " . (time() + $ttl) . ") ? true : false;\nif (\$expired) { return; }\n\$data = " . (sizeof($data) ? "unserialize(" . var_export(serialize($data), true) . ");" : 'array();'));
fwrite($fp, "<?php\nif (!defined('IN_PHPBB')) exit;\n\$expired = (time() > " . (time() + $ttl) . ") ? true : false;\nif (\$expired) { return; }\n\$data = " . (sizeof($data) ? "unserialize(" . var_export(serialize($data), true) . ");" : 'array();'));
@flock($fp, LOCK_UN);
fclose($fp);
@@ -163,7 +163,7 @@ class phpbb_acm_file extends phpbb_acm_abstract
if ($fp = @fopen($filename, 'wb'))
{
@flock($fp, LOCK_EX);
fwrite($fp, "<?php\n\$this->vars = unserialize(" . var_export(serialize($this->vars), true) . ");\n\$this->var_expires = unserialize(" . var_export(serialize($this->var_expires), true) . ");");
fwrite($fp, "<?php\nif (!defined('IN_PHPBB')) exit;\n\$this->vars = unserialize(" . var_export(serialize($this->vars), true) . ");\n\$this->var_expires = unserialize(" . var_export(serialize($this->var_expires), true) . ");");
@flock($fp, LOCK_UN);
fclose($fp);
@@ -174,10 +174,13 @@ class phpbb_acm_file extends phpbb_acm_abstract
// Now, this occurred how often? ... phew, just tell the user then...
if (!@is_writable($this->cache_dir))
{
trigger_error($this->cache_dir . ' is NOT writable.', E_USER_ERROR);
// We need to use die() here, because else we may encounter an infinite loop (the message handler calls $cache->unload())
die($this->cache_dir . ' is NOT writable.');
exit;
}
trigger_error('Not able to open ' . $filename, E_USER_ERROR);
die('Not able to open ' . $filename);
exit;
}
$this->is_modified = false;

View File

@@ -232,13 +232,19 @@ function validate_session_apache(&$user)
if (!isset($_SERVER['PHP_AUTH_USER']))
{
return false;
$php_auth_user = '';
set_var($php_auth_user, $_SERVER['PHP_AUTH_USER'], 'string', true);
return ($php_auth_user === $user['username']) ? true : false;
}
$php_auth_user = '';
set_var($php_auth_user, $_SERVER['PHP_AUTH_USER'], 'string', true);
// PHP_AUTH_USER is not set. A valid session is now determined by the user type (anonymous/bot or not)
if ($user['user_type'] == USER_IGNORE)
{
return true;
}
return ($php_auth_user === $user['username']) ? true : false;
return false;
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1192,6 +1192,11 @@ abstract class phpbb_session
foreach (explode(',', $row['bot_ip']) as $bot_ip)
{
if (!trim($bot_ip))
{
continue;
}
if (strpos($this->system['ip'], $bot_ip) === 0)
{
$bot = (int) $row['user_id'];

View File

@@ -17,7 +17,7 @@ if (!defined('IN_PHPBB'))
}
/**
* Code from pear.php.net, Text_Diff-1.0.0 package
* Code from pear.php.net, Text_Diff-1.1.0 package
* http://pear.php.net/package/Text_Diff/
*
* Modified by phpBB Group to meet our coding standards
@@ -60,6 +60,48 @@ class diff
return $this->_edits;
}
/**
* returns the number of new (added) lines in a given diff.
*
* @since Text_Diff 1.1.0
*
* @return integer The number of new lines
*/
function count_added_lines()
{
$count = 0;
foreach ($this->_edits as $edit)
{
if (is_a($edit, 'diff_op_add') || is_a($edit, 'diff_op_change'))
{
$count += $edit->nfinal();
}
}
return $count;
}
/**
* Returns the number of deleted (removed) lines in a given diff.
*
* @since Text_Diff 1.1.0
*
* @return integer The number of deleted lines
*/
function count_deleted_lines()
{
$count = 0;
foreach ($this->_edits as $edit)
{
if (is_a($edit, 'diff_op_delete') || is_a($edit, 'diff_op_change'))
{
$count += $edit->norig();
}
}
return $count;
}
/**
* Computes a reversed diff.
*
@@ -427,31 +469,35 @@ class diff3 extends diff
}
/**
* Return merged output
* Return number of conflicts
*/
function get_num_conflicts()
{
$conflicts = 0;
foreach ($this->_edits as $edit)
{
if ($edit->is_conflict())
{
$conflicts++;
}
}
return $conflicts;
}
/**
* Get conflicts content for download. This is generally a merged file, but preserving conflicts and adding explanations to it.
* A user could then go through this file, search for the conflicts and changes the code accordingly.
*
* @param string $label1 the cvs file version/label from the original set of lines
* @param string $label2 the cvs file version/label from the new set of lines
* @param string $label_sep the explanation between label1 and label2 - more of a helper for the user
* @param bool $get_conflicts if set to true only the number of conflicts is returned
* @param bool $merge_new if set to true the merged output will have the new file contents on a conflicting merge
*
* @return mixed the merged output
*/
function merged_output($label1 = 'CURRENT_FILE', $label2 = 'NEW_FILE', $label_sep = 'DIFF_SEP_EXPLAIN', $get_conflicts = false, $merge_new = false)
function get_conflicts_content($label1 = 'CURRENT_FILE', $label2 = 'NEW_FILE', $label_sep = 'DIFF_SEP_EXPLAIN')
{
if ($get_conflicts)
{
foreach ($this->_edits as $edit)
{
if ($edit->is_conflict())
{
$this->_conflicting_blocks++;
}
}
return $this->_conflicting_blocks;
}
$label1 = (!empty(phpbb::$user->lang[$label1])) ? phpbb::$user->lang[$label1] : $label1;
$label2 = (!empty(phpbb::$user->lang[$label2])) ? phpbb::$user->lang[$label2] : $label2;
$label_sep = (!empty(phpbb::$user->lang[$label_sep])) ? phpbb::$user->lang[$label_sep] : $label_sep;
@@ -462,15 +508,12 @@ class diff3 extends diff
{
if ($edit->is_conflict())
{
if (!$merge_new)
{
$lines = array_merge($lines, array('<<<<<<<' . ($label1 ? ' ' . $label1 : '')), $edit->final1, array('=======' . ($label_sep ? ' ' . $label_sep : '')), $edit->final2, array('>>>>>>>' . ($label2 ? ' ' . $label2 : '')));
}
else
{
$lines = array_merge($lines, $edit->final1);
}
$this->_conflicting_blocks++;
// Start conflict label
$label_start = array('<<<<<<< ' . $label1);
$label_mid = array('======= ' . $label_sep);
$label_end = array('>>>>>>> ' . $label2);
$lines = array_merge($lines, $label_start, $edit->final1, $label_mid, $edit->final2, $label_end);
}
else
{

View File

@@ -17,7 +17,7 @@ if (!defined('IN_PHPBB'))
}
/**
* Code from pear.php.net, Text_Diff-1.0.0 package
* Code from pear.php.net, Text_Diff-1.1.0 package
* http://pear.php.net/package/Text_Diff/ (native engine)
*
* Modified by phpBB Group to meet our coding standards

View File

@@ -17,7 +17,7 @@ if (!defined('IN_PHPBB'))
}
/**
* Code from pear.php.net, Text_Diff-1.0.0 package
* Code from pear.php.net, Text_Diff-1.1.0 package
* http://pear.php.net/package/Text_Diff/
*
* Modified by phpBB Group to meet our coding standards

View File

@@ -79,6 +79,35 @@ function set_config($config_name, $config_value, $is_dynamic = false)
}
}
/**
* Set dynamic config value with arithmetic operation.
*/
function set_config_count($config_name, $increment, $is_dynamic = false)
{
switch (phpbb::$db->sql_layer)
{
case 'firebird':
$sql_update = 'CAST(CAST(config_value as integer) + ' . (int) $increment . ' as CHAR)';
break;
case 'postgres':
$sql_update = 'int4(config_value) + ' . (int) $increment;
break;
// MySQL, SQlite, mssql, mssql_odbc, oracle
default:
$sql_update = 'config_value + ' . (int) $increment;
break;
}
phpbb::$db->sql_query('UPDATE ' . CONFIG_TABLE . ' SET config_value = ' . $sql_update . " WHERE config_name = '" . phpbb::$db->sql_escape($config_name) . "'");
if (!$is_dynamic)
{
phpbb::$acm->destroy('#config');
}
}
/**
* Return formatted string for filesizes
* @todo move those functions to a helper class?
@@ -314,7 +343,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
$sql_update = array();
while ($row = phpbb::$db->sql_fetchrow($result))
{
$sql_update[] = $row['forum_id'];
$sql_update[] = (int) $row['forum_id'];
}
phpbb::$db->sql_freeresult($result);

View File

@@ -602,7 +602,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
if ($approved_topics)
{
set_config('num_topics', phpbb::$config['num_topics'] - $approved_topics, true);
set_config_count('num_topics', $approved_topics * (-1), true);
}
return $return;
@@ -757,7 +757,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
if ($approved_posts)
{
set_config('num_posts', phpbb::$config['num_posts'] - $approved_posts, true);
set_config_count('num_posts', $approved_posts * (-1), true);
}
// We actually remove topics now to not be inconsistent (the delete_topics function calls this function too)
@@ -793,11 +793,14 @@ function delete_attachments($mode, $ids, $resync = true)
return false;
}
$sql_where = '';
switch ($mode)
{
case 'post':
case 'message':
$sql_id = 'post_msg_id';
$sql_where = ' AND in_message = ' . ($mode == 'message' ? 1 : 0);
break;
case 'topic':
@@ -821,6 +824,9 @@ function delete_attachments($mode, $ids, $resync = true)
$sql = 'SELECT post_msg_id, topic_id, in_message, physical_filename, thumbnail, filesize, is_orphan
FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . phpbb::$db->sql_in_set($sql_id, $ids);
$sql .= $sql_where;
$result = phpbb::$db->sql_query($sql);
while ($row = phpbb::$db->sql_fetchrow($result))
@@ -846,6 +852,9 @@ function delete_attachments($mode, $ids, $resync = true)
// Delete attachments
$sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . phpbb::$db->sql_in_set($sql_id, $ids);
$sql .= $sql_where;
phpbb::$db->sql_query($sql);
$num_deleted = phpbb::$db->sql_affectedrows();
@@ -873,8 +882,8 @@ function delete_attachments($mode, $ids, $resync = true)
if ($space_removed || $files_removed)
{
set_config('upload_dir_size', phpbb::$config['upload_dir_size'] - $space_removed, true);
set_config('num_files', phpbb::$config['num_files'] - $files_removed, true);
set_config_count('upload_dir_size', $space_removed * (-1), true);
set_config_count('num_files', $files_removed * (-1), true);
}
// If we do not resync, we do not need to adjust any message, post, topic or user entries

View File

@@ -932,6 +932,8 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,
'S_THUMBNAIL' => true,
'THUMB_IMAGE' => $thumbnail_link,
);
$update_count[] = $attachment['attach_id'];
break;
// Windows Media Streams
@@ -978,6 +980,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,
'S_FLASH_FILE' => true,
'WIDTH' => $width,
'HEIGHT' => $height,
'U_VIEW_LINK' => $download_link . '&amp;view=1',
);
// Viewed/Heared File ... update the download count
@@ -1153,7 +1156,7 @@ function get_username_string($mode, $user_id, $username, $username_colour = '',
switch ($mode)
{
case 'full':
case 'noprofile':
case 'no_profile':
case 'colour':
// Build correct username colour

View File

@@ -838,6 +838,12 @@ function display_custom_bbcodes()
$i = 0;
while ($row = phpbb::$db->sql_fetchrow($result))
{
// If the helpline is defined within the language file, we will use the localised version, else just use the database entry...
if (isset(phpbb::$user->lang[strtoupper($row['bbcode_helpline'])]))
{
$row['bbcode_helpline'] = phpbb::$user->lang[strtoupper($row['bbcode_helpline'])];
}
phpbb::$template->assign_block_vars('custom_tags', array(
'BBCODE_NAME' => "'[{$row['bbcode_tag']}]', '[/" . str_replace('=', '', $row['bbcode_tag']) . "]'",
'BBCODE_ID' => $num_predefined_bbcodes + ($i * 2),

View File

@@ -53,6 +53,11 @@ class messenger
*/
function to($address, $realname = '')
{
if (!trim($address))
{
return;
}
$pos = isset($this->addresses['to']) ? sizeof($this->addresses['to']) : 0;
$this->addresses['to'][$pos]['email'] = trim($address);
@@ -73,6 +78,11 @@ class messenger
*/
function cc($address, $realname = '')
{
if (!trim($address))
{
return;
}
$pos = isset($this->addresses['cc']) ? sizeof($this->addresses['cc']) : 0;
$this->addresses['cc'][$pos]['email'] = trim($address);
$this->addresses['cc'][$pos]['name'] = trim($realname);
@@ -83,6 +93,11 @@ class messenger
*/
function bcc($address, $realname = '')
{
if (!trim($address))
{
return;
}
$pos = isset($this->addresses['bcc']) ? sizeof($this->addresses['bcc']) : 0;
$this->addresses['bcc'][$pos]['email'] = trim($address);
$this->addresses['bcc'][$pos]['name'] = trim($realname);
@@ -94,7 +109,7 @@ class messenger
function im($address, $realname = '')
{
// IM-Addresses could be empty
if (!$address)
if (!trim($address))
{
return;
}
@@ -324,15 +339,12 @@ class messenger
$headers[] = 'X-MimeOLE: phpBB3';
$headers[] = 'X-phpBB-Origin: phpbb://' . str_replace(array('http://', 'https://'), array('', ''), generate_board_url());
// We use \n here instead of \r\n because our smtp mailer is adjusting it to \r\n automatically, whereby the php mail function only works
// if using \n.
if (sizeof($this->extra_headers))
{
$headers[] = implode("\n", $this->extra_headers);
$headers = array_merge($headers, $this->extra_headers);
}
return implode("\n", $headers);
return $headers;
}
/**
@@ -345,6 +357,13 @@ class messenger
return false;
}
// Addresses to send to?
if (empty($this->addresses) || (empty($this->addresses['to']) && empty($this->addresses['cc']) && empty($this->addresses['bcc'])))
{
// Send was successful. ;)
return true;
}
$use_queue = false;
if (phpbb::$config['email_package_size'] && $this->use_queue)
{
@@ -396,6 +415,10 @@ class messenger
}
else
{
// We use the EOL character for the OS here because the PHP mail function does not correctly transform line endings. On Windows SMTP is used (SMTP is \r\n), on UNIX a command is used...
// Reference: http://bugs.php.net/bug.php?id=15841
$headers = implode(PHP_EOL, $headers);
ob_start();
$result = phpbb::$config['email_function_name']($mail_to, mail_encode($this->subject), wordwrap(utf8_wordwrap($this->msg), 997, "\n", true), $headers);
$err_msg = ob_get_clean();
@@ -433,7 +456,8 @@ class messenger
if (empty($this->addresses['im']))
{
return false;
// Send was successful. ;)
return true;
}
$use_queue = false;
@@ -630,7 +654,7 @@ class queue
else
{
ob_start();
$result = phpbb::$config['email_function_name']($to, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers);
$result = phpbb::$config['email_function_name']($to, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), implode(PHP_EOL, $headers));
$err_msg = ob_get_clean();
}
@@ -682,7 +706,7 @@ class queue
if ($fp = @fopen($this->cache_file, 'wb'))
{
@flock($fp, LOCK_EX);
fwrite($fp, "<?php\n\$this->queue_data = unserialize(" . var_export(serialize($this->queue_data), true) . ");\n\n?>");
fwrite($fp, "<?php\nif (!defined('IN_PHPBB')) exit;\n\$this->queue_data = unserialize(" . var_export(serialize($this->queue_data), true) . ");\n\n?>");
@flock($fp, LOCK_UN);
fclose($fp);
@@ -723,7 +747,7 @@ class queue
if ($fp = @fopen($this->cache_file, 'w'))
{
@flock($fp, LOCK_EX);
fwrite($fp, "<?php\n\$this->queue_data = unserialize(" . var_export(serialize($this->data), true) . ");\n\n?>");
fwrite($fp, "<?php\nif (!defined('IN_PHPBB')) exit;\n\$this->queue_data = unserialize(" . var_export(serialize($this->data), true) . ");\n\n?>");
@flock($fp, LOCK_UN);
fclose($fp);
@@ -735,38 +759,35 @@ class queue
/**
* Replacement or substitute for PHP's mail command
*/
function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '')
function smtpmail($addresses, $subject, $message, &$err_msg, $headers = false)
{
// Fix any bare linefeeds in the message to make it RFC821 Compliant.
$message = preg_replace("#(?<!\r)\n#si", "\r\n", $message);
if ($headers != '')
if ($headers !== false)
{
if (is_array($headers))
if (!is_array($headers))
{
$headers = (sizeof($headers) > 1) ? join("\n", $headers) : $headers[0];
// Make sure there are no bare linefeeds in the headers
$headers = preg_replace('#(?<!\r)\n#si', "\n", $headers);
$headers = explode("\n", $headers);
}
$headers = chop($headers);
// Make sure there are no bare linefeeds in the headers
$headers = preg_replace('#(?<!\r)\n#si', "\r\n", $headers);
// Ok this is rather confusing all things considered,
// but we have to grab bcc and cc headers and treat them differently
// Something we really didn't take into consideration originally
$header_array = explode("\r\n", $headers);
$headers = '';
$headers_used = array();
foreach ($header_array as $header)
foreach ($headers as $header)
{
if (strpos(strtolower($header), 'cc:') === 0 || strpos(strtolower($header), 'bcc:') === 0)
{
$header = '';
continue;
}
$headers .= ($header != '') ? $header . "\r\n" : '';
$headers_used[] = trim($header);
}
$headers = chop($headers);
$headers = chop(implode("\r\n", $headers_used));
}
if (trim($subject) == '')
@@ -922,7 +943,10 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '')
}
// Now any custom headers....
$smtp->server_send("$headers\r\n");
if ($headers !== false)
{
$smtp->server_send("$headers\r\n");
}
// Ok now we are ready for the message...
$smtp->server_send($message);
@@ -1039,7 +1063,7 @@ class smtp_class
public function log_into_server($hostname, $username, $password, $default_auth_method)
{
$err_msg = '';
$local_host = (function_exists('php_uname')) ? php_uname('n') : phpbb::$user->system['host'];
$local_host = (function_exists('php_uname')) ? gethostbyaddr(gethostbyname(php_uname('n'))) : phpbb::$user->system['host'];
// If we are authenticating through pop-before-smtp, we
// have to login ones before we get authenticated

View File

@@ -615,7 +615,7 @@ function create_thumbnail($source, $destination, $mimetype)
phpbb::$config['img_imagick'] .= '/';
}
@passthru(escapeshellcmd(phpbb::$config['img_imagick']) . 'convert' . ((defined('PHP_OS') && preg_match('#^win#i', PHP_OS)) ? '.exe' : '') . ' -quality 85 -antialias -sample ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $destination) . '"');
@passthru(escapeshellcmd(phpbb::$config['img_imagick']) . 'convert' . ((defined('PHP_OS') && preg_match('#^win#i', PHP_OS)) ? '.exe' : '') . ' -quality 85 -geometry ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" "' . str_replace('\\', '/', $destination) . '"');
if (file_exists($destination))
{
@@ -940,13 +940,20 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
}
$sql = phpbb::$db->sql_build_query('SELECT', array(
'SELECT' => 'u.username, u.user_id, u.user_colour, p.*',
'SELECT' => 'u.username, u.user_id, u.user_colour, p.*, z.friend, z.foe',
'FROM' => array(
USERS_TABLE => 'u',
POSTS_TABLE => 'p',
),
'LEFT_JOIN' => array(
array(
'FROM' => array(ZEBRA_TABLE => 'z'),
'ON' => 'z.user_id = ' . phpbb::$user->data['user_id'] . ' AND z.zebra_id = p.poster_id'
)
),
'WHERE' => phpbb::$db->sql_in_set('p.post_id', $post_list) . '
AND u.user_id = p.poster_id'
));
@@ -1037,6 +1044,9 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
$post_subject = censor_text($post_subject);
$post_anchor = ($mode == 'post_review') ? 'ppr' . $row['post_id'] : 'pr' . $row['post_id'];
$u_show_post = append_sid('viewtopic', "f=$forum_id&amp;t=$topic_id&amp;p={$row['post_id']}&amp;view=show#p{$row['post_id']}");
phpbb::$template->assign_block_vars($mode . '_row', array(
'POST_AUTHOR_FULL' => get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'POST_AUTHOR_COLOUR' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
@@ -1044,6 +1054,9 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
'U_POST_AUTHOR' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false,
'S_FRIEND' => ($row['friend']) ? true : false,
'S_IGNORE_POST' => ($row['foe']) ? true : false,
'L_IGNORE_POST' => ($row['foe']) ? phpbb::$user->lang('POST_BY_FOE', get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), "<a href=\"{$u_show_post}\" onclick=\"dE('{$post_anchor}', 1); return false;\">", '</a>') : '',
'POST_SUBJECT' => $post_subject,
'MINI_POST_IMG' => phpbb::$user->img('icon_post_target', 'POST'),
@@ -1708,11 +1721,23 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
if (isset($poll['poll_options']) && !empty($poll['poll_options']))
{
$poll_start = ($poll['poll_start']) ? $poll['poll_start'] : $current_time;
$poll_length = $poll['poll_length'] * 86400;
if ($poll_length < 0)
{
$poll_start = $poll_start + $poll_length;
if ($poll_start < 0)
{
$poll_start = 0;
}
$poll_length = 1;
}
$sql_data[TOPICS_TABLE]['sql'] = array_merge($sql_data[TOPICS_TABLE]['sql'], array(
'poll_title' => $poll['poll_title'],
'poll_start' => ($poll['poll_start']) ? $poll['poll_start'] : $current_time,
'poll_start' => $poll_start,
'poll_max_options' => $poll['poll_max_options'],
'poll_length' => ($poll['poll_length'] * 86400),
'poll_length' => $poll_length,
'poll_vote_change' => $poll['poll_vote_change'])
);
}
@@ -1741,6 +1766,20 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
case 'edit_topic':
case 'edit_first_post':
if (isset($poll['poll_options']) && !empty($poll['poll_options']))
{
$poll_start = ($poll['poll_start']) ? $poll['poll_start'] : $current_time;
$poll_length = $poll['poll_length'] * 86400;
if ($poll_length < 0)
{
$poll_start = $poll_start + $poll_length;
if ($poll_start < 0)
{
$poll_start = 0;
}
$poll_length = 1;
}
}
$sql_data[TOPICS_TABLE]['sql'] = array(
'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'],
@@ -1751,9 +1790,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
'topic_type' => $topic_type,
'topic_time_limit' => ($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) ? ($data['topic_time_limit'] * 86400) : 0,
'poll_title' => (isset($poll['poll_options'])) ? $poll['poll_title'] : '',
'poll_start' => (isset($poll['poll_options'])) ? (($poll['poll_start']) ? $poll['poll_start'] : $current_time) : 0,
'poll_start' => (isset($poll['poll_options'])) ? $poll_start : 0,
'poll_max_options' => (isset($poll['poll_options'])) ? $poll['poll_max_options'] : 1,
'poll_length' => (isset($poll['poll_options'])) ? ($poll['poll_length'] * 86400) : 0,
'poll_length' => (isset($poll['poll_options'])) ? $poll_length : 0,
'poll_vote_change' => (isset($poll['poll_vote_change'])) ? $poll['poll_vote_change'] : 0,
'topic_attachment' => (!empty($data['attachment_data'])) ? 1 : (isset($data['topic_attachment']) ? $data['topic_attachment'] : 0),
@@ -1780,8 +1819,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics = forum_topics - 1';
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - ' . ($topic_row['topic_replies'] + 1);
set_config('num_topics', phpbb::$config['num_topics'] - 1, true);
set_config('num_posts', phpbb::$config['num_posts'] - ($topic_row['topic_replies'] + 1), true);
set_config_count('num_topics', -1, true);
set_config_count('num_posts', ($topic_row['topic_replies'] + 1) * (-1), true);
// Only decrement this post, since this is the one non-approved now
if (phpbb::$acl->acl_get('f_postcount', $data['forum_id']))
@@ -1801,7 +1840,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_replies = topic_replies - 1';
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - 1';
set_config('num_posts', phpbb::$config['num_posts'] - 1, true);
set_config_count('num_posts', -1, true);
if (phpbb::$acl->acl_get('f_postcount', $data['forum_id']))
{
@@ -2068,8 +2107,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
if ($space_taken && $files_added)
{
set_config('upload_dir_size', phpbb::$config['upload_dir_size'] + $space_taken, true);
set_config('num_files', phpbb::$config['num_files'] + $files_added, true);
set_config_count('upload_dir_size', $space_taken, true);
set_config_count('num_files', $files_added, true);
}
}
@@ -2302,13 +2341,13 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
{
if ($post_mode == 'post')
{
set_config('num_topics', phpbb::$config['num_topics'] + 1, true);
set_config('num_posts', phpbb::$config['num_posts'] + 1, true);
set_config_count('num_topics', 1, true);
set_config_count('num_posts', 1, true);
}
if ($post_mode == 'reply')
{
set_config('num_posts', phpbb::$config['num_posts'] + 1, true);
set_config_count('num_posts', 1, true);
}
}

View File

@@ -1541,8 +1541,8 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
if ($space_taken && $files_added)
{
set_config('upload_dir_size', phpbb::$config['upload_dir_size'] + $space_taken, true);
set_config('num_files', phpbb::$config['num_files'] + $files_added, true);
set_config_count('upload_dir_size', $space_taken, true);
set_config_count('num_files', $files_added, true);
}
}

View File

@@ -37,8 +37,8 @@ class custom_profile
switch ($mode)
{
case 'register':
// If the field is required we show it on the registration page and do not show hidden fields
$sql_where .= ' AND (f.field_show_on_reg = 1 OR f.field_required = 1) AND f.field_hide = 0';
// If the field is required we show it on the registration page
$sql_where .= ' AND f.field_show_on_reg = 1';
break;
case 'profile':

View File

@@ -272,7 +272,7 @@ function user_add($user_row, $cp_data = false)
{
set_config('newest_user_id', $user_id, true);
set_config('newest_username', $user_row['username'], true);
set_config('num_users', phpbb::$config['num_users'] + 1, true);
set_config_count('num_users', 1, true);
$sql = 'SELECT group_colour
FROM ' . GROUPS_TABLE . '
@@ -479,7 +479,7 @@ function user_delete($mode, $user_id, $post_username = false)
phpbb::$db->sql_transaction('begin');
$table_ary = array(USERS_TABLE, USER_GROUP_TABLE, TOPICS_WATCH_TABLE, FORUMS_WATCH_TABLE, ACL_USERS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, FORUMS_TRACK_TABLE, PROFILE_FIELDS_DATA_TABLE, MODERATOR_CACHE_TABLE, DRAFTS_TABLE, BOOKMARKS_TABLE);
$table_ary = array(USERS_TABLE, USER_GROUP_TABLE, TOPICS_WATCH_TABLE, FORUMS_WATCH_TABLE, ACL_USERS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, FORUMS_TRACK_TABLE, PROFILE_FIELDS_DATA_TABLE, MODERATOR_CACHE_TABLE, DRAFTS_TABLE, BOOKMARKS_TABLE, SESSIONS_KEYS_TABLE);
foreach ($table_ary as $table)
{
@@ -490,6 +490,16 @@ function user_delete($mode, $user_id, $post_username = false)
phpbb::$acm->destroy_sql(MODERATOR_CACHE_TABLE);
// Delete the user_id from the banlist
$sql = 'DELETE FROM ' . BANLIST_TABLE . '
WHERE ban_userid = ' . $user_id;
phpbb::$db->sql_query($sql);
// Delete the user_id from the session table
$sql = 'DELETE FROM ' . SESSIONS_TABLE . '
WHERE session_user_id = ' . $user_id;
phpbb::$db->sql_query($sql);
// Remove any undelivered mails...
$sql = 'SELECT msg_id, user_id
FROM ' . PRIVMSGS_TO_TABLE . '
@@ -558,7 +568,7 @@ function user_delete($mode, $user_id, $post_username = false)
// Decrement number of users if this user is active
if ($user_row['user_type'] != phpbb::USER_INACTIVE && $user_row['user_type'] != phpbb::USER_IGNORE)
{
set_config('num_users', phpbb::$config['num_users'] - 1, true);
set_config_count('num_users', -1, true);
}
return false;
@@ -637,12 +647,12 @@ function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL)
if ($deactivated)
{
set_config('num_users', phpbb::$config['num_users'] - $deactivated, true);
set_config_count('num_users', $deactivated * (-1), true);
}
if ($activated)
{
set_config('num_users', phpbb::$config['num_users'] + $activated, true);
set_config_count('num_users', $activated, true);
}
// Update latest username
@@ -1117,6 +1127,8 @@ function user_unban($mode, $ban)
/**
* Whois facility
*
* @link http://tools.ietf.org/html/rfc3912 RFC3912: WHOIS Protocol Specification
*/
function user_ipwhois($ip)
{
@@ -1129,16 +1141,10 @@ function user_ipwhois($ip)
return '';
}
$match = array(
'#RIPE\.NET#is' => 'whois.ripe.net',
'#whois\.apnic\.net#is' => 'whois.apnic.net',
'#nic\.ad\.jp#is' => 'whois.nic.ad.jp',
'#whois\.registro\.br#is' => 'whois.registro.br'
);
if (($fsk = @fsockopen('whois.arin.net', 43)))
{
fputs($fsk, "$ip\n");
// CRLF as per RFC3912
fputs($fsk, "$ip\r\n");
while (!feof($fsk))
{
$ipwhois .= fgets($fsk, 1024);
@@ -1146,22 +1152,38 @@ function user_ipwhois($ip)
@fclose($fsk);
}
foreach (array_keys($match) as $server)
$match = array();
// Test for referrals from ARIN to other whois databases, roll on rwhois
if (preg_match('#ReferralServer: whois://(.+)#im', $ipwhois, $match))
{
if (preg_match($server, $ipwhois))
if (strpos($match[1], ':') !== false)
{
$ipwhois = '';
if (($fsk = @fsockopen($match[$server], 43)))
{
fputs($fsk, "$ip\n");
while (!feof($fsk))
{
$ipwhois .= fgets($fsk, 1024);
}
@fclose($fsk);
}
break;
$pos = strrpos($match[1], ':');
$server = substr($match[1], 0, $pos);
$port = (int) substr($match[1], $pos + 1);
unset($pos);
}
else
{
$server = $match[1];
$port = 43;
}
$buffer = '';
if (($fsk = @fsockopen($server, $port)))
{
fputs($fsk, "$ip\r\n");
while (!feof($fsk))
{
$buffer .= fgets($fsk, 1024);
}
@fclose($fsk);
}
// Use the result from ARIN if we don't get any result here
$ipwhois = (empty($buffer)) ? $ipwhois : $buffer;
}
$ipwhois = htmlspecialchars($ipwhois);
@@ -2591,7 +2613,14 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false,
*/
function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $group_name = false)
{
$group_order = array('ADMINISTRATORS', 'GLOBAL_MODERATORS', 'REGISTERED_COPPA', 'REGISTERED', 'BOTS', 'GUESTS');
if (phpbb::$config['coppa_enable'])
{
$group_order = array('ADMINISTRATORS', 'GLOBAL_MODERATORS', 'REGISTERED_COPPA', 'REGISTERED', 'BOTS', 'GUESTS');
}
else
{
$group_order = array('ADMINISTRATORS', 'GLOBAL_MODERATORS', 'REGISTERED', 'BOTS', 'GUESTS');
}
// We need both username and user_id info
$result = user_get_id_name($user_id_ary, $username_ary);

View File

@@ -684,6 +684,7 @@ class bbcode_firstpass extends bbcode
* [quote="[i]test[/i]"]test[/quote] (correct: parsed)
* [quote="[quote]test[/quote]"]test[/quote] (correct: parsed - Username displayed as [quote]test[/quote])
* #20735 - [quote]test[/[/b]quote] test [/quote][/quote] test - (correct: quoted: "test[/[/b]quote] test" / non-quoted: "[/quote] test" - also failed if layout distorted)
* #40565 - [quote="a"]a[/quote][quote="a]a[/quote] (correct: first quote tag parsed, second quote tag unparsed)
*/
$in = str_replace("\r\n", "\n", str_replace('\"', '"', trim($in)));
@@ -694,7 +695,7 @@ class bbcode_firstpass extends bbcode
}
// To let the parser not catch tokens within quote_username quotes we encode them before we start this...
$in = preg_replace('#quote=&quot;(.*?)&quot;\]#ie', "'quote=&quot;' . str_replace(array('[', ']'), array('&#91;', '&#93;'), '\$1') . '&quot;]'", $in);
$in = preg_replace('#quote=&quot;(.*?)&quot;\]#ie', "'quote=&quot;' . str_replace(array('[', ']', '\\\"'), array('&#91;', '&#93;', '\"'), '\$1') . '&quot;]'", $in);
$tok = ']';
$out = '[';
@@ -847,6 +848,8 @@ class bbcode_firstpass extends bbcode
}
while ($in);
$out .= $buffer;
if (sizeof($close_tags))
{
$out .= '[' . implode('][', $close_tags) . ']';
@@ -1085,13 +1088,6 @@ class parse_message extends bbcode_firstpass
}
}
// Check for "empty" message
if ($mode !== 'sig' && utf8_clean_string($this->message) === '')
{
$this->warn_msg[] = phpbb::$user->lang['TOO_FEW_CHARS'];
return (!$update_this_message) ? $return_message : $this->warn_msg;
}
// Prepare BBcode (just prepares some tags for better parsing)
if ($allow_bbcode && strpos($this->message, '[') !== false)
{
@@ -1134,6 +1130,14 @@ class parse_message extends bbcode_firstpass
}
}
// Check for "empty" message. We do not check here for maximum length, because bbcode, smilies, etc. can add to the length.
// The maximum length check happened before any parsings.
if ($mode !== 'sig' && utf8_clean_string($this->message) === '')
{
$this->warn_msg[] = $user->lang['TOO_FEW_CHARS'];
return (!$update_this_message) ? $return_message : $this->warn_msg;
}
// Check number of links
if (phpbb::$config['max_' . $mode . '_urls'] && $num_urls > phpbb::$config['max_' . $mode . '_urls'])
{