diff options
| author | Meik Sievertsen <acydburn@phpbb.com> | 2006-12-24 13:11:54 +0000 |
|---|---|---|
| committer | Meik Sievertsen <acydburn@phpbb.com> | 2006-12-24 13:11:54 +0000 |
| commit | ae1cb0316e6c19d62f0579e9cef52f11df081bcf (patch) | |
| tree | d5e0900486aeb6ac91b957ce2ac47a4d55cdddc7 /phpBB/includes | |
| parent | 9cc0b364bcc9473d0b1f4656db9008a55921918b (diff) | |
| download | forums-ae1cb0316e6c19d62f0579e9cef52f11df081bcf.tar forums-ae1cb0316e6c19d62f0579e9cef52f11df081bcf.tar.gz forums-ae1cb0316e6c19d62f0579e9cef52f11df081bcf.tar.bz2 forums-ae1cb0316e6c19d62f0579e9cef52f11df081bcf.tar.xz forums-ae1cb0316e6c19d62f0579e9cef52f11df081bcf.zip | |
some fixes today
- most important change is the consolidation of the display attachment functions; merging them together to have one function we need to call.
git-svn-id: file:///svn/phpbb/trunk@6803 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
| -rw-r--r-- | phpBB/includes/acp/acp_bots.php | 22 | ||||
| -rwxr-xr-x | phpBB/includes/acp/acp_inactive.php | 20 | ||||
| -rw-r--r-- | phpBB/includes/functions.php | 296 | ||||
| -rw-r--r-- | phpBB/includes/functions_display.php | 268 | ||||
| -rw-r--r-- | phpBB/includes/functions_messenger.php | 14 | ||||
| -rw-r--r-- | phpBB/includes/functions_module.php | 11 | ||||
| -rw-r--r-- | phpBB/includes/functions_user.php | 43 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_queue.php | 12 | ||||
| -rw-r--r-- | phpBB/includes/mcp/mcp_topic.php | 15 | ||||
| -rw-r--r-- | phpBB/includes/message_parser.php | 100 | ||||
| -rw-r--r-- | phpBB/includes/session.php | 29 | ||||
| -rw-r--r-- | phpBB/includes/ucp/ucp_pm_compose.php | 33 | ||||
| -rw-r--r-- | phpBB/includes/ucp/ucp_pm_viewmessage.php | 10 |
13 files changed, 482 insertions, 391 deletions
diff --git a/phpBB/includes/acp/acp_bots.php b/phpBB/includes/acp/acp_bots.php index 7e1c31dc44..72fb40216d 100644 --- a/phpBB/includes/acp/acp_bots.php +++ b/phpBB/includes/acp/acp_bots.php @@ -181,17 +181,17 @@ class acp_bots } $user_id = user_add(array( - 'user_type' => (int) USER_IGNORE, - 'group_id' => (int) $group_row['group_id'], - 'username' => (string) $bot_row['bot_name'], - 'user_regdate' => time(), - 'user_password' => '', - 'user_colour' => (string) $group_row['group_colour'], - 'user_email' => '', - 'user_lang' => (string) $bot_row['bot_lang'], - 'user_style' => (int) $bot_row['bot_style'], - 'user_options' => 0) - ); + 'user_type' => (int) USER_IGNORE, + 'group_id' => (int) $group_row['group_id'], + 'username' => (string) $bot_row['bot_name'], + 'user_regdate' => time(), + 'user_password' => '', + 'user_colour' => (string) $group_row['group_colour'], + 'user_email' => '', + 'user_lang' => (string) $bot_row['bot_lang'], + 'user_style' => (int) $bot_row['bot_style'], + 'user_allow_massemail' => 0, + )); $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( 'user_id' => (int) $user_id, diff --git a/phpBB/includes/acp/acp_inactive.php b/phpBB/includes/acp/acp_inactive.php index 84387b4f5c..5663979f1c 100755 --- a/phpBB/includes/acp/acp_inactive.php +++ b/phpBB/includes/acp/acp_inactive.php @@ -26,6 +26,8 @@ class acp_inactive global $config, $db, $user, $auth, $template; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix; + include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + $user->add_lang('memberlist'); $action = request_var('action', ''); @@ -43,7 +45,8 @@ class acp_inactive { case 'activate': case 'delete': - $sql = 'SELECT username + + $sql = 'SELECT user_id, username FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $mark); $result = $db->sql_query($sql); @@ -51,13 +54,12 @@ class acp_inactive $user_affected = array(); while ($row = $db->sql_fetchrow($result)) { - $user_affected[] = $row['username']; + $user_affected[$row['user_id']] = $row['username']; } $db->sql_freeresult($result); if ($action == 'activate') { - include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx); user_active_flip('activate', $mark); } else if ($action == 'delete') @@ -67,14 +69,14 @@ class acp_inactive trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); } - $sql = 'DELETE FROM ' . USER_GROUP_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $mark); - $db->sql_query($sql); - $sql = 'DELETE FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $mark); - $db->sql_query($sql); - - add_log('admin', 'LOG_INACTIVE_' . strtoupper($action), implode(', ', $user_affected)); + foreach ($mark as $user_id) + { + user_delete('retain', $user_id, $user_affected[$user_id]); + } } + add_log('admin', 'LOG_INACTIVE_' . strtoupper($action), implode(', ', $user_affected)); + break; case 'remind': diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 323590b269..aa5c766764 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1887,6 +1887,12 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa // append/replace SID (may change during the session for AOL users) $redirect = reapply_sid($redirect); + // Special case... the user is effectively banned, but we allow founders to login + if (defined('IN_CHECK_BAN') && $result['user_row']['user_type'] != USER_FOUNDER) + { + return; + } + meta_refresh(3, $redirect); trigger_error($message . '<br /><br />' . sprintf($l_redirect, '<a href="' . $redirect . '">', '</a>')); } @@ -2439,24 +2445,288 @@ function smiley_text($text, $force_option = false) } /** -* Inline Attachment processing +* General attachment parsing +* +* @param int $forum_id The forum id the attachments are displayed in (0 for private messages) +* @param string &$message The post/private message +* @param array &$attachments The attachments to parse for (inline) display. The attachments array will hold templated data after parsing. +* @param array &$update_count The attachment counts to be updated - will be filled +* @param bool $preview If set to true the attachments are parsed for preview. Within preview mode the comments are fetched from the given $attachments array and not fetched from the database. */ -function parse_inline_attachments(&$text, &$attachments, &$update_count, $forum_id = 0, $preview = false) +function parse_attachments($forum_id, &$message, &$attachments, &$update_count, $preview = false) { - global $config, $user; + if (!sizeof($attachments)) + { + return; + } + + global $template, $cache, $user; + global $extensions, $config, $phpbb_root_path, $phpEx; + + // + $force_physical = false; + $compiled_attachments = array(); + + if (!isset($template->filename['attachment_tpl'])) + { + $template->set_filenames(array( + 'attachment_tpl' => 'attachment.html') + ); + } + + if (empty($extensions) || !is_array($extensions)) + { + $extensions = $cache->obtain_attach_extensions(); + } + + // Look for missing attachment information... + $attach_ids = array(); + foreach ($attachments as $pos => $attachment) + { + // If is_orphan is set, we need to retrieve the attachments again... + if (!isset($attachment['extension']) && !isset($attachment['physical_filename'])) + { + $attach_ids[(int) $attachment['attach_id']] = $pos; + } + } + + // Grab attachments (security precaution) + if (sizeof($attach_ids)) + { + global $db; + + $new_attachment_data = array(); + + $sql = 'SELECT * + FROM ' . ATTACHMENTS_TABLE . ' + WHERE ' . $db->sql_in_set('attach_id', array_keys($attach_ids)); + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + if (!isset($attach_ids[$row['attach_id']])) + { + continue; + } + + // If we preview attachments we will set some retrieved values here + if ($preview) + { + $row['attach_comment'] = $attachments[$attach_ids[$row['attach_id']]]['attach_comment']; + } - if (!function_exists('display_attachments')) + $new_attachment_data[$attach_ids[$row['attach_id']]] = $row; + } + $db->sql_freeresult($result); + + $attachments = $new_attachment_data; + unset($new_attachment_data); + } + + // Sort correctly + if ($config['display_order']) + { + // Ascending sort + krsort($attachments); + } + else { - global $phpbb_root_path, $phpEx; - include("{$phpbb_root_path}includes/functions_display.$phpEx"); + // Descending sort + ksort($attachments); + } + + foreach ($attachments as $attachment) + { + if (!sizeof($attachment)) + { + continue; + } + + // We need to reset/empty the _file block var, because this function might be called more than once + $template->destroy_block_vars('_file'); + + $block_array = array(); + + // Some basics... + $attachment['extension'] = strtolower(trim($attachment['extension'])); + $filename = $phpbb_root_path . $config['upload_path'] . '/' . basename($attachment['physical_filename']); + $thumbnail_filename = $phpbb_root_path . $config['upload_path'] . '/thumb_' . basename($attachment['physical_filename']); + + $upload_icon = ''; + + if (isset($extensions[$attachment['extension']])) + { + if ($user->img('icon_topic_attach', '') && !$extensions[$attachment['extension']]['upload_icon']) + { + $upload_icon = $user->img('icon_topic_attach', ''); + } + else if ($extensions[$attachment['extension']]['upload_icon']) + { + $upload_icon = '<img src="' . $phpbb_root_path . $config['upload_icons_path'] . '/' . trim($extensions[$attachment['extension']]['upload_icon']) . '" alt="" />'; + } + } + + $filesize = $attachment['filesize']; + $size_lang = ($filesize >= 1048576) ? $user->lang['MB'] : ( ($filesize >= 1024) ? $user->lang['KB'] : $user->lang['BYTES'] ); + $filesize = ($filesize >= 1048576) ? round((round($filesize / 1048576 * 100) / 100), 2) : (($filesize >= 1024) ? round((round($filesize / 1024 * 100) / 100), 2) : $filesize); + + $comment = str_replace("\n", '<br />', censor_text($attachment['attach_comment'])); + + $block_array += array( + 'UPLOAD_ICON' => $upload_icon, + 'FILESIZE' => $filesize, + 'SIZE_LANG' => $size_lang, + 'DOWNLOAD_NAME' => basename($attachment['real_filename']), + 'COMMENT' => $comment, + ); + + $denied = false; + + if (!extension_allowed($forum_id, $attachment['extension'], $extensions)) + { + $denied = true; + + $block_array += array( + 'S_DENIED' => true, + 'DENIED_MESSAGE' => sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']) + ); + } + + if (!$denied) + { + $l_downloaded_viewed = $download_link = ''; + $display_cat = $extensions[$attachment['extension']]['display_cat']; + + if ($display_cat == ATTACHMENT_CATEGORY_IMAGE) + { + if ($attachment['thumbnail']) + { + $display_cat = ATTACHMENT_CATEGORY_THUMB; + } + else + { + if ($config['img_display_inlined']) + { + if ($config['img_link_width'] || $config['img_link_height']) + { + list($width, $height) = @getimagesize($filename); + + $display_cat = (!$width && !$height) ? ATTACHMENT_CATEGORY_IMAGE : (($width <= $config['img_link_width'] && $height <= $config['img_link_height']) ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE); + } + } + else + { + $display_cat = ATTACHMENT_CATEGORY_NONE; + } + } + } + + $download_link = (!$force_physical && $attachment['attach_id']) ? append_sid("{$phpbb_root_path}download.$phpEx", 'id=' . $attachment['attach_id'] . '&f=' . $forum_id) : $filename; + + switch ($display_cat) + { + // Images + case ATTACHMENT_CATEGORY_IMAGE: + $l_downloaded_viewed = $user->lang['VIEWED']; + + $block_array += array( + 'S_IMAGE' => true, + ); + + $update_count[] = $attachment['attach_id']; + break; + + // Images, but display Thumbnail + case ATTACHMENT_CATEGORY_THUMB: + $l_downloaded_viewed = $user->lang['VIEWED']; + $thumbnail_link = (!$force_physical && $attachment['attach_id']) ? append_sid("{$phpbb_root_path}download.$phpEx", 'id=' . $attachment['attach_id'] . '&t=1&f=' . $forum_id) : $thumbnail_filename; + + $block_array += array( + 'S_THUMBNAIL' => true, + 'THUMB_IMAGE' => $thumbnail_link, + ); + break; + + // Windows Media Streams + case ATTACHMENT_CATEGORY_WM: + $l_downloaded_viewed = $user->lang['VIEWED']; + + // Giving the filename directly because within the wm object all variables are in local context making it impossible + // to validate against a valid session (all params can differ) + $download_link = $filename; + + $block_array += array( + 'U_FORUM' => generate_board_url(), + 'S_WM_FILE' => true, + ); + + // Viewed/Heared File ... update the download count + $update_count[] = $attachment['attach_id']; + break; + + // Real Media Streams + case ATTACHMENT_CATEGORY_RM: + case ATTACHMENT_CATEGORY_QUICKTIME: + $l_downloaded_viewed = $user->lang['VIEWED']; + + $block_array += array( + 'S_RM_FILE' => ($display_cat == ATTACHMENT_CATEGORY_RM) ? true : false, + 'S_QUICKTIME_FILE' => ($display_cat == ATTACHMENT_CATEGORY_QUICKTIME) ? true : false, + 'U_FORUM' => generate_board_url(), + 'ATTACH_ID' => $attachment['attach_id'], + ); + + // Viewed/Heared File ... update the download count + $update_count[] = $attachment['attach_id']; + break; + + // Macromedia Flash Files + case ATTACHMENT_CATEGORY_FLASH: + list($width, $height) = @getimagesize($filename); + + $l_downloaded_viewed = $user->lang['VIEWED']; + + $block_array += array( + 'S_FLASH_FILE' => true, + 'WIDTH' => $width, + 'HEIGHT' => $height, + ); + + // Viewed/Heared File ... update the download count + $update_count[] = $attachment['attach_id']; + break; + + default: + $l_downloaded_viewed = $user->lang['DOWNLOADED']; + + $block_array += array( + 'S_FILE' => true, + ); + break; + } + + $l_download_count = (!isset($attachment['download_count']) || $attachment['download_count'] == 0) ? $user->lang['DOWNLOAD_NONE'] : (($attachment['download_count'] == 1) ? sprintf($user->lang['DOWNLOAD_COUNT'], $attachment['download_count']) : sprintf($user->lang['DOWNLOAD_COUNTS'], $attachment['download_count'])); + + $block_array += array( + 'U_DOWNLOAD_LINK' => $download_link, + 'L_DOWNLOADED_VIEWED' => $l_downloaded_viewed, + 'L_DOWNLOAD_COUNT' => $l_download_count + ); + } + + $template->assign_block_vars('_file', $block_array); + + $compiled_attachments[] = $template->assign_display('attachment_tpl'); } - $attachments = display_attachments($forum_id, NULL, $attachments, $update_count, false, true); + $attachments = $compiled_attachments; + unset($compiled_attachments); + $tpl_size = sizeof($attachments); $unset_tpl = array(); - preg_match_all('#<!\-\- ia([0-9]+) \-\->(.*?)<!\-\- ia\1 \-\->#', $text, $matches, PREG_PATTERN_ORDER); + preg_match_all('#<!\-\- ia([0-9]+) \-\->(.*?)<!\-\- ia\1 \-\->#', $message, $matches, PREG_PATTERN_ORDER); $replace = array(); foreach ($matches[0] as $num => $capture) @@ -2472,10 +2742,16 @@ function parse_inline_attachments(&$text, &$attachments, &$update_count, $forum_ if (isset($replace['from'])) { - $text = str_replace($replace['from'], $replace['to'], $text); + $message = str_replace($replace['from'], $replace['to'], $message); } - return array_unique($unset_tpl); + $unset_tpl = array_unique($unset_tpl); + + // Needed to let not display the inlined attachments at the end of the post again + foreach ($unset_tpl as $index) + { + unset($attachments[$index]); + } } /** diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 4c16029803..242eb871ae 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -689,274 +689,6 @@ function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$fold } /** -* Display Attachments -*/ -function display_attachments($forum_id, $blockname, &$attachment_data, &$update_count, $force_physical = false, $return = false) -{ - global $template, $cache, $user; - global $extensions, $config, $phpbb_root_path, $phpEx; - - $return_tpl = array(); - - $template->set_filenames(array( - 'attachment_tpl' => 'attachment.html') - ); - - if (!sizeof($attachment_data)) - { - return array(); - } - - if (empty($extensions) || !is_array($extensions)) - { - $extensions = $cache->obtain_attach_extensions(); - } - - // Look for missing attachment information... - $attach_ids = array(); - foreach ($attachment_data as $pos => $attachment) - { - // If is_orphan is set, we need to retrieve the attachments again... - if (!isset($attachment['extension']) && !isset($attachment['physical_filename'])) - { - $attach_ids[(int) $attachment['attach_id']] = $pos; - } - } - - if (sizeof($attach_ids)) - { - global $db; - - $attachment_data = array(); - - $sql = 'SELECT * - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('attach_id', array_keys($attach_ids)); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (!isset($attach_ids[$row['attach_id']])) - { - continue; - } - - $attachment_data[$attach_ids[$row['attach_id']]] = $row; - } - $db->sql_freeresult($result); - } - - // Sort correctly (please note that the attachment_data array itself get changed by this - if ($config['display_order']) - { - // Ascending sort - krsort($attachment_data); - } - else - { - // Descending sort - ksort($attachment_data); - } - - foreach ($attachment_data as $attachment) - { - if (!sizeof($attachment)) - { - continue; - } - - // We need to reset/empty the _file block var, because this function might be called more than once - $template->destroy_block_vars('_file'); - - $block_array = array(); - - // Some basics... - $attachment['extension'] = strtolower(trim($attachment['extension'])); - $filename = $phpbb_root_path . $config['upload_path'] . '/' . basename($attachment['physical_filename']); - $thumbnail_filename = $phpbb_root_path . $config['upload_path'] . '/thumb_' . basename($attachment['physical_filename']); - - $upload_icon = ''; - - if (isset($extensions[$attachment['extension']])) - { - if ($user->img('icon_topic_attach', '') && !$extensions[$attachment['extension']]['upload_icon']) - { - $upload_icon = $user->img('icon_topic_attach', ''); - } - else if ($extensions[$attachment['extension']]['upload_icon']) - { - $upload_icon = '<img src="' . $phpbb_root_path . $config['upload_icons_path'] . '/' . trim($extensions[$attachment['extension']]['upload_icon']) . '" alt="" />'; - } - } - - $filesize = $attachment['filesize']; - $size_lang = ($filesize >= 1048576) ? $user->lang['MB'] : ( ($filesize >= 1024) ? $user->lang['KB'] : $user->lang['BYTES'] ); - $filesize = ($filesize >= 1048576) ? round((round($filesize / 1048576 * 100) / 100), 2) : (($filesize >= 1024) ? round((round($filesize / 1024 * 100) / 100), 2) : $filesize); - - $comment = str_replace("\n", '<br />', censor_text($attachment['attach_comment'])); - - $block_array += array( - 'UPLOAD_ICON' => $upload_icon, - 'FILESIZE' => $filesize, - 'SIZE_LANG' => $size_lang, - 'DOWNLOAD_NAME' => basename($attachment['real_filename']), - 'COMMENT' => $comment, - ); - - $denied = false; - - if (!extension_allowed($forum_id, $attachment['extension'], $extensions)) - { - $denied = true; - - $block_array += array( - 'S_DENIED' => true, - 'DENIED_MESSAGE' => sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']) - ); - } - - if (!$denied) - { - $l_downloaded_viewed = $download_link = ''; - $display_cat = $extensions[$attachment['extension']]['display_cat']; - - if ($display_cat == ATTACHMENT_CATEGORY_IMAGE) - { - if ($attachment['thumbnail']) - { - $display_cat = ATTACHMENT_CATEGORY_THUMB; - } - else - { - if ($config['img_display_inlined']) - { - if ($config['img_link_width'] || $config['img_link_height']) - { - list($width, $height) = @getimagesize($filename); - - $display_cat = (!$width && !$height) ? ATTACHMENT_CATEGORY_IMAGE : (($width <= $config['img_link_width'] && $height <= $config['img_link_height']) ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE); - } - } - else - { - $display_cat = ATTACHMENT_CATEGORY_NONE; - } - } - } - - $download_link = (!$force_physical && $attachment['attach_id']) ? append_sid("{$phpbb_root_path}download.$phpEx", 'id=' . $attachment['attach_id'] . '&f=' . $forum_id) : $filename; - - switch ($display_cat) - { - // Images - case ATTACHMENT_CATEGORY_IMAGE: - $l_downloaded_viewed = $user->lang['VIEWED']; - - $block_array += array( - 'S_IMAGE' => true, - ); - - $update_count[] = $attachment['attach_id']; - break; - - // Images, but display Thumbnail - case ATTACHMENT_CATEGORY_THUMB: - $l_downloaded_viewed = $user->lang['VIEWED']; - $thumbnail_link = (!$force_physical && $attachment['attach_id']) ? append_sid("{$phpbb_root_path}download.$phpEx", 'id=' . $attachment['attach_id'] . '&t=1&f=' . $forum_id) : $thumbnail_filename; - - $block_array += array( - 'S_THUMBNAIL' => true, - 'THUMB_IMAGE' => $thumbnail_link, - ); - break; - - // Windows Media Streams - case ATTACHMENT_CATEGORY_WM: - $l_downloaded_viewed = $user->lang['VIEWED']; - - // Giving the filename directly because within the wm object all variables are in local context making it impossible - // to validate against a valid session (all params can differ) - $download_link = $filename; - - $block_array += array( - 'U_FORUM' => generate_board_url(), - 'S_WM_FILE' => true, - ); - - // Viewed/Heared File ... update the download count - $update_count[] = $attachment['attach_id']; - break; - - // Real Media Streams - case ATTACHMENT_CATEGORY_RM: - case ATTACHMENT_CATEGORY_QUICKTIME: - $l_downloaded_viewed = $user->lang['VIEWED']; - - $block_array += array( - 'S_RM_FILE' => ($display_cat == ATTACHMENT_CATEGORY_RM) ? true : false, - 'S_QUICKTIME_FILE' => ($display_cat == ATTACHMENT_CATEGORY_QUICKTIME) ? true : false, - 'U_FORUM' => generate_board_url(), - 'ATTACH_ID' => $attachment['attach_id'], - ); - - // Viewed/Heared File ... update the download count - $update_count[] = $attachment['attach_id']; - break; - - // Macromedia Flash Files - case ATTACHMENT_CATEGORY_FLASH: - list($width, $height) = @getimagesize($filename); - - $l_downloaded_viewed = $user->lang['VIEWED']; - - $block_array += array( - 'S_FLASH_FILE' => true, - 'WIDTH' => $width, - 'HEIGHT' => $height, - ); - - // Viewed/Heared File ... update the download count - $update_count[] = $attachment['attach_id']; - break; - - default: - $l_downloaded_viewed = $user->lang['DOWNLOADED']; - - $block_array += array( - 'S_FILE' => true, - ); - break; - } - - $l_download_count = (!isset($attachment['download_count']) || $attachment['download_count'] == 0) ? $user->lang['DOWNLOAD_NONE'] : (($attachment['download_count'] == 1) ? sprintf($user->lang['DOWNLOAD_COUNT'], $attachment['download_count']) : sprintf($user->lang['DOWNLOAD_COUNTS'], $attachment['download_count'])); - - $block_array += array( - 'U_DOWNLOAD_LINK' => $download_link, - 'L_DOWNLOADED_VIEWED' => $l_downloaded_viewed, - 'L_DOWNLOAD_COUNT' => $l_download_count - ); - } - - $template->assign_block_vars('_file', $block_array); - - $tpl = $template->assign_display('attachment_tpl'); - - if (!$return) - { - $template->assign_block_vars($blockname, array( - 'DISPLAY_ATTACHMENT' => $tpl) - ); - } - else - { - $return_tpl[] = $tpl; - } - } - - return $return_tpl; -} - -/** * Assign/Build custom bbcodes for display in screens supporting using of bbcodes * The custom bbcodes buttons will be placed within the template block 'custom_codes' */ diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 7296a8c283..f2ad76f892 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -45,9 +45,21 @@ class messenger */ function to($address, $realname = '') { + global $config; + $pos = isset($this->addresses['to']) ? sizeof($this->addresses['to']) : 0; + $this->addresses['to'][$pos]['email'] = trim($address); - $this->addresses['to'][$pos]['name'] = trim($realname); + + // If empty sendmail_path on windows, PHP changes the to line + if (!$config['smtp_delivery'] && strpos(strtolower(PHP_OS), 'win') === 0) + { + $this->addresses['to'][$pos]['name'] = ''; + } + else + { + $this->addresses['to'][$pos]['name'] = trim($realname); + } } /** diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index 22312b8d76..ca47ef2f89 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -69,6 +69,11 @@ class p_master $cache->put('_modules_' . $this->p_class, $this->module_cache); } + if (empty($this->module_cache)) + { + $this->module_cache = array('modules' => array(), 'parents' => array()); + } + // We "could" build a true tree with this function - maybe mod authors want to use this... // Functions for traversing and manipulating the tree are not available though // We might re-structure the module system to use true trees in 3.2.x... @@ -370,7 +375,7 @@ class p_master if (defined('IN_ADMIN')) { // Not being able to overwrite ;) - $this->module->u_action = append_sid("{$phpbb_admin_path}index.$phpEx", "i={$this->p_id}") . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}"; + $this->module->u_action = append_sid("{$phpbb_admin_path}index.$phpEx", "i={$this->p_name}") . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}"; } else { @@ -384,7 +389,7 @@ class p_master $this->module->u_action = $phpbb_root_path . (($user->page['page_dir']) ? $user->page['page_dir'] . '/' : '') . $user->page['page_name']; } - $this->module->u_action = append_sid($this->module->u_action, "i={$this->p_id}") . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}"; + $this->module->u_action = append_sid($this->module->u_action, "i={$this->p_name}") . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}"; } // Assign the module path for re-usage @@ -394,7 +399,7 @@ class p_master // Users are able to call the main method after this function to be able to assign additional parameters manually if ($execute_module) { - $this->module->main(($this->p_name) ? $this->p_name : $this->p_id, $this->p_mode); + $this->module->main($this->p_name, $this->p_mode); } return; diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 55725b2cfd..1d11f00298 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -275,6 +275,18 @@ function user_delete($mode, $user_id, $post_username = false) global $cache, $config, $db, $user, $auth; global $phpbb_root_path, $phpEx; + $sql = 'SELECT * + FROM ' . USERS_TABLE . ' + WHERE user_id = ' . $user_id; + $result = $db->sql_query($sql); + $user_row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$user_row) + { + return false; + } + $db->sql_transaction('begin'); switch ($mode) @@ -312,18 +324,12 @@ function user_delete($mode, $user_id, $post_username = false) $db->sql_query($sql); // Since we change every post by this author, we need to count this amount towards the anonymous user - $sql = 'SELECT user_posts - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . $user_id; - $result = $db->sql_query($sql); - $num_posts = (int) $db->sql_fetchfield('user_posts'); - $db->sql_freeresult($result); // Update the post count for the anonymous user - if ($num_posts) + if ($user_row['user_posts']) { $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_posts = user_posts + ' . $num_posts . ' + SET user_posts = user_posts + ' . $user_row['user_posts'] . ' WHERE user_id = ' . ANONYMOUS; $db->sql_query($sql); } @@ -333,7 +339,7 @@ function user_delete($mode, $user_id, $post_username = false) if (!function_exists('delete_posts')) { - include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); + include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); } $sql = 'SELECT topic_id, COUNT(post_id) AS total_posts @@ -391,8 +397,6 @@ function user_delete($mode, $user_id, $post_username = false) $cache->destroy('sql', MODERATOR_CACHE_TABLE); - include_once($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); - // Remove any undelivered mails... $sql = 'SELECT msg_id, user_id FROM ' . PRIVMSGS_TO_TABLE . ' @@ -456,7 +460,11 @@ function user_delete($mode, $user_id, $post_username = false) update_last_username(); } - set_config('num_users', $config['num_users'] - 1, true); + // Decrement number of users if this user is active + if ($user_row['user_type'] != USER_INACTIVE && $user_row['user_type'] != USER_IGNORE) + { + set_config('num_users', $config['num_users'] - 1, true); + } $db->sql_transaction('commit'); @@ -1247,7 +1255,7 @@ function validate_email($email) { list(, $domain) = explode('@', $email); - if (phpbb_checkdnsrr($domain, 'MX') === false) + if (phpbb_checkdnsrr($domain, 'A') === false && phpbb_checkdnsrr($domain, 'MX') === false) { return 'DOMAIN_NO_MX_RECORD'; } @@ -1603,12 +1611,19 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow $sql = 'UPDATE ' . GROUPS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE group_id = $group_id"; + $db->sql_query($sql); + + // Since we may update the name too, we need to do this on other tables too... + $sql = 'UPDATE ' . MODERATOR_CACHE_TABLE . " + SET group_name = '" . $db->sql_escape($sql_ary['group_name']) . "' + WHERE group_id = $group_id"; + $db->sql_query($sql); } else { $sql = 'INSERT INTO ' . GROUPS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); + $db->sql_query($sql); } - $db->sql_query($sql); if (!$group_id) { diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 3fd7e6d856..48756c640e 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -50,11 +50,11 @@ class mcp_queue if ($action == 'approve') { - approve_post($post_id_list, $mode); + approve_post($post_id_list, 'queue', $mode); } else { - disapprove_post($post_id_list, $mode); + disapprove_post($post_id_list, 'queue', $mode); } break; @@ -372,7 +372,7 @@ class mcp_queue /** * Approve Post/Topic */ -function approve_post($post_id_list, $mode) +function approve_post($post_id_list, $id, $mode) { global $db, $template, $user, $config; global $phpEx, $phpbb_root_path; @@ -386,7 +386,7 @@ function approve_post($post_id_list, $mode) $success_msg = ''; $s_hidden_fields = build_hidden_fields(array( - 'i' => 'queue', + 'i' => $id, 'mode' => $mode, 'post_id_list' => $post_id_list, 'action' => 'approve', @@ -617,7 +617,7 @@ function approve_post($post_id_list, $mode) /** * Disapprove Post/Topic */ -function disapprove_post($post_id_list, $mode) +function disapprove_post($post_id_list, $id, $mode) { global $db, $template, $user, $config; global $phpEx, $phpbb_root_path; @@ -633,7 +633,7 @@ function disapprove_post($post_id_list, $mode) $success_msg = $additional_msg = ''; $s_hidden_fields = build_hidden_fields(array( - 'i' => 'queue', + 'i' => $id, 'mode' => $mode, 'post_id_list' => $post_id_list, 'action' => 'disapprove', diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index bc0d18afbd..4ad8efeda3 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -57,6 +57,21 @@ function mcp_topic_view($id, $mode, $action) $subject = $topic_info['topic_title']; } + // Approve posts? + if ($action == 'approve' && $auth->acl_get('m_approve', $topic_info['forum_id'])) + { + include($phpbb_root_path . 'includes/mcp/mcp_queue.' . $phpEx); + include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); + include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); + + if (!sizeof($post_id_list)) + { + trigger_error('NO_POST_SELECTED'); + } + + approve_post($post_id_list, $id, $mode); + } + // Jumpbox, sort selects and that kind of things make_jumpbox($url . "&i=$id&mode=forum_view", $topic_info['forum_id'], false, 'm_'); $where_sql = ($action == 'reports') ? 'WHERE post_reported = 1 AND ' : 'WHERE'; diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 251e736a14..c139af5ef7 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -1213,7 +1213,22 @@ class parse_message extends bbcode_firstpass $add_file = (isset($_POST['add_file'])) ? true : false; $delete_file = (isset($_POST['delete_file'])) ? true : false; - $edit_comment = (isset($_POST['edit_comment'])) ? true : false; + + // First of all adjust comments if changed + $actual_comment_list = utf8_normalize_nfc(request_var('comment_list', array(''), true)); + + foreach ($actual_comment_list as $comment_key => $comment) + { + if (!isset($this->attachment_data[$comment_key])) + { + continue; + } + + if ($this->attachment_data[$comment_key]['attach_comment'] != $actual_comment_list[$comment_key]) + { + $this->attachment_data[$comment_key]['attach_comment'] = $actual_comment_list[$comment_key]; + } + } $cfg = array(); $cfg['max_attachments'] = ($is_message) ? $config['max_attachments_pm'] : $config['max_attachments']; @@ -1284,7 +1299,6 @@ class parse_message extends bbcode_firstpass if (!empty($this->attachment_data[$index])) { - // delete selected attachment if ($this->attachment_data[$index]['is_orphan']) { @@ -1321,59 +1335,47 @@ class parse_message extends bbcode_firstpass $this->attachment_data = array_values($this->attachment_data); } } - else if ($edit_comment || $add_file || $preview) + else if (($add_file || $preview) && $upload_file) { - if ($edit_comment) - { - $actual_comment_list = utf8_normalize_nfc(request_var('comment_list', array(''), true)); - - $edit_comment = request_var('edit_comment', array(0 => '')); - $edit_comment = key($edit_comment); - $this->attachment_data[$edit_comment]['attach_comment'] = $actual_comment_list[$edit_comment]; - } - - if (($add_file || $preview) && $upload_file) + if ($num_attachments < $cfg['max_attachments'] || $auth->acl_gets('m_', 'a_', $forum_id)) { - if ($num_attachments < $cfg['max_attachments'] || $auth->acl_gets('m_', 'a_', $forum_id)) - { - $filedata = upload_attachment($form_name, $forum_id, false, '', $is_message); - $error = array_merge($error, $filedata['error']); + $filedata = upload_attachment($form_name, $forum_id, false, '', $is_message); + $error = array_merge($error, $filedata['error']); - if (!sizeof($error)) - { - $sql_ary = array( - 'physical_filename' => $filedata['physical_filename'], - 'attach_comment' => $this->filename_data['filecomment'], - 'real_filename' => $filedata['real_filename'], - 'extension' => $filedata['extension'], - 'mimetype' => $filedata['mimetype'], - 'filesize' => $filedata['filesize'], - 'filetime' => $filedata['filetime'], - 'thumbnail' => $filedata['thumbnail'], - 'is_orphan' => 1, - 'in_message' => ($is_message) ? 1 : 0, - 'poster_id' => $user->data['user_id'], - ); - - $db->sql_query('INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - - $new_entry = array( - 'attach_id' => $db->sql_nextid(), - 'is_orphan' => 1, - 'real_filename' => $filedata['real_filename'], - 'attach_comment'=> $this->filename_data['filecomment'], - ); - - $this->attachment_data = array_merge(array(0 => $new_entry), $this->attachment_data); - $this->message = preg_replace('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#e', "'[attachment='.(\\1 + 1).']\\2[/attachment]'", $this->message); - $this->filename_data['filecomment'] = ''; - } - } - else + if (!sizeof($error)) { - $error[] = sprintf($user->lang['TOO_MANY_ATTACHMENTS'], $cfg['max_attachments']); + $sql_ary = array( + 'physical_filename' => $filedata['physical_filename'], + 'attach_comment' => $this->filename_data['filecomment'], + 'real_filename' => $filedata['real_filename'], + 'extension' => $filedata['extension'], + 'mimetype' => $filedata['mimetype'], + 'filesize' => $filedata['filesize'], + 'filetime' => $filedata['filetime'], + 'thumbnail' => $filedata['thumbnail'], + 'is_orphan' => 1, + 'in_message' => ($is_message) ? 1 : 0, + 'poster_id' => $user->data['user_id'], + ); + + $db->sql_query('INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); + + $new_entry = array( + 'attach_id' => $db->sql_nextid(), + 'is_orphan' => 1, + 'real_filename' => $filedata['real_filename'], + 'attach_comment'=> $this->filename_data['filecomment'], + ); + + $this->attachment_data = array_merge(array(0 => $new_entry), $this->attachment_data); + $this->message = preg_replace('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#e', "'[attachment='.(\\1 + 1).']\\2[/attachment]'", $this->message); + $this->filename_data['filecomment'] = ''; } } + else + { + $error[] = sprintf($user->lang['TOO_MANY_ATTACHMENTS'], $cfg['max_attachments']); + } } } diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index e11245ec0c..5ab9cf618d 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -651,7 +651,7 @@ class session * and update the users information from the relevant session data. It will then * grab guest user information. */ - function session_kill() + function session_kill($new_session = true) { global $SID, $_SID, $db, $config, $phpbb_root_path, $phpEx; @@ -712,7 +712,10 @@ class session $this->session_id = $_SID = ''; // To make sure a valid session is created we create one for the anonymous user - $this->session_create(ANONYMOUS); + if ($new_session) + { + $this->session_create(ANONYMOUS); + } return true; } @@ -820,6 +823,11 @@ class session { global $config, $db; + if (defined('IN_CHECK_BAN')) + { + return; + } + $banned = false; $sql = 'SELECT ban_ip, ban_userid, ban_email, ban_exclude, ban_give_reason, ban_end @@ -927,6 +935,23 @@ class session $this->session_kill(); } + // We show a login box here to allow founders accessing the board if banned by IP + if (defined('IN_LOGIN') && $this->data['user_id'] == ANONYMOUS) + { + global $phpEx; + + // Set as a precaution to allow login_box() handling this case correctly as well as this function not being executed again. + define('IN_CHECK_BAN', 1); + + $this->setup('ucp'); + $this->data['is_registered'] = $this->data['is_bot'] = false; + + login_box("index.$phpEx"); + + // The false here is needed, else the user is able to circumvent the ban. + $this->session_kill(false); + } + // Determine which message to output $till_date = ($ban_row['ban_end']) ? $this->format_date($ban_row['ban_end']) : ''; $message = ($ban_row['ban_end']) ? 'BOARD_BAN_TIME' : 'BOARD_BAN_PERM'; diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index 8fa5de090f..0dd85c06ae 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -48,7 +48,7 @@ function compose_pm($id, $mode, $action) $add_to = (isset($_REQUEST['add_to'])) ? true : false; $add_bcc = (isset($_REQUEST['add_bcc'])) ? true : false; - $refresh = isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['edit_comment']) || $save || $load + $refresh = isset($_POST['add_file']) || isset($_POST['delete_file']) || $save || $load || $remove_u || $remove_g || $add_to || $add_bcc; $action = ($delete && !$preview && !$refresh && $submit) ? 'delete' : $action; @@ -514,14 +514,17 @@ function compose_pm($id, $mode, $action) } // Subject defined - if (!$subject && !($remove_u || $remove_g || $add_to || $add_bcc)) + if ($submit) { - $error[] = $user->lang['EMPTY_SUBJECT']; - } + if (!$subject) + { + $error[] = $user->lang['EMPTY_SUBJECT']; + } - if (!sizeof($address_list)) - { - $error[] = $user->lang['NO_RECIPIENT']; + if (!sizeof($address_list)) + { + $error[] = $user->lang['NO_RECIPIENT']; + } } if (sizeof($message_parser->warn_msg) && !($remove_u || $remove_g || $add_to || $add_bcc)) @@ -597,10 +600,20 @@ function compose_pm($id, $mode, $action) // Attachment Preview if (sizeof($message_parser->attachment_data)) { - $extensions = $update_count = array(); - $template->assign_var('S_HAS_ATTACHMENTS', true); - display_attachments(0, 'attachment', $message_parser->attachment_data, $update_count); + + $update_count = array(); + $attachment_data = $message_parser->attachment_data; + + parse_attachments(0, $preview_message, $attachment_data, $update_count, true); + + foreach ($attachment_data as $i => $attachment) + { + $template->assign_block_vars('attachment', array( + 'DISPLAY_ATTACHMENT' => $attachment) + ); + } + unset($attachment_data); } $preview_subject = censor_text($subject); diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index 2ddd5766d4..d87acfee69 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -117,16 +117,10 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) } // Assign inline attachments - if (isset($attachments) && sizeof($attachments)) + if (!empty($attachments)) { $update_count = array(); - $unset_attachments = parse_inline_attachments($message, $attachments, $update_count, 0); - - // Needed to let not display the inlined attachments at the end of the message again - foreach ($unset_attachments as $index) - { - unset($attachments[$index]); - } + parse_attachments(0, $message, $attachments, $update_count); // Update the attachment download counts if (sizeof($update_count)) |
