From e7c3370a043fe4f163fcc4b3b529d1c78093c0f2 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 19 Oct 2003 15:36:45 +0000 Subject: [PATCH] bump topic and orphan attachments changes here and there... git-svn-id: file:///svn/phpbb/trunk@4614 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/admin_attachments.php | 316 +++++++++++++++--- phpBB/adm/admin_board.php | 19 ++ phpBB/common.php | 1 - phpBB/includes/functions_admin.php | 9 +- phpBB/includes/functions_display.php | 4 +- phpBB/includes/functions_posting.php | 42 ++- phpBB/includes/message_parser.php | 19 +- phpBB/install/schemas/schema_data.sql | 2 + phpBB/language/en/lang_admin.php | 54 ++- phpBB/language/en/lang_main.php | 13 +- phpBB/posting.php | 134 +++++--- .../subSilver/template/viewtopic_body.html | 7 +- phpBB/viewtopic.php | 11 +- 13 files changed, 471 insertions(+), 160 deletions(-) diff --git a/phpBB/adm/admin_attachments.php b/phpBB/adm/admin_attachments.php index 78c7ec0c5e..bb61a592ef 100644 --- a/phpBB/adm/admin_attachments.php +++ b/phpBB/adm/admin_attachments.php @@ -24,6 +24,7 @@ define('IN_PHPBB', 1); $phpbb_root_path = '../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); require('pagestart.' . $phpEx); +include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); if (!$auth->acl_get('a_attach')) { @@ -85,7 +86,7 @@ while ($row = $db->sql_fetchrow($result)) if ($old_size != $new_size) { - // See, if we have a similar value of old_size in Extension Groups. If so, update these values. + // check for similar value of old_size in Extension Groups. If so, update these values. $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . " SET max_filesize = $new_size WHERE max_filesize = $old_size"; @@ -127,6 +128,14 @@ switch ($mode) case 'ext_groups': $l_title = 'EXTENSION_GROUPS_TITLE'; + break; + + case 'orphan': + $l_title = 'ORPHAN_ATTACHMENTS'; + break; + + default: + trigger_error('NO_MODE'); } adm_page_header($user->lang[$l_title]); @@ -174,7 +183,7 @@ if ($submit && $mode == 'extensions') { // Change Extensions ? $extension_change_list = (isset($_POST['extension_change_list'])) ? array_map('intval', $_POST['extension_change_list']) : array(); - $extension_explain_list = request_var('extension_explain_list', ''); //(isset($_POST['extension_explain_list'])) ? array_map('trim', $_POST['extension_explain_list']) : array(); + $extension_explain_list = request_var('extension_explain_list', ''); $group_select_list = (isset($_POST['group_select'])) ? array_map('intval', $_POST['group_select']) : array(); // Generate correct Change List @@ -209,11 +218,6 @@ if ($submit && $mode == 'extensions') if (sizeof($extension_id_list)) { - $sql = 'DELETE - FROM ' . EXTENSIONS_TABLE . ' - WHERE extension_id IN (' . implode(', ', $extension_id_list) . ')'; - $db->sql_query($sql); - $sql = 'SELECT extension FROM ' . EXTENSIONS_TABLE . ' WHERE extension_id IN (' . implode(', ', $extension_id_list) . ')'; @@ -226,12 +230,17 @@ if ($submit && $mode == 'extensions') } $db->sql_freeresult($result); + $sql = 'DELETE + FROM ' . EXTENSIONS_TABLE . ' + WHERE extension_id IN (' . implode(', ', $extension_id_list) . ')'; + $db->sql_query($sql); + add_log('admin', 'LOG_ATTACH_EXT_DEL', $extension_list); } // Add Extension ? - $add_extension = strtolower(request_var('add_extension', '')); //(isset($_POST['add_extension'])) ? strtolower(trim(strip_tags($_POST['add_extension']))) : ''; - $add_extension_explain = request_var('add_extension_explain', ''); //(isset($_POST['add_extension_explain'])) ? trim(strip_tags($_POST['add_extension_explain'])) : ''; + $add_extension = strtolower(request_var('add_extension', '')); + $add_extension_explain = request_var('add_extension_explain', ''); $add_extension_group = request_var('add_group_select', 0); $add = (isset($_POST['add_extension_check'])) ? TRUE : FALSE; @@ -241,7 +250,7 @@ if ($submit && $mode == 'extensions') { $sql = 'SELECT extension_id FROM ' . EXTENSIONS_TABLE . " - WHERE extension = '$add_extension'"; + WHERE extension = '" . $db->sql_escape($add_extension) . "'"; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) @@ -252,9 +261,13 @@ if ($submit && $mode == 'extensions') if (!sizeof($error)) { - $sql = 'INSERT INTO ' . EXTENSIONS_TABLE . " (group_id, extension, comment) - VALUES ($add_extension_group, '" . $db->sql_escape($add_extension) . "', '" . $db->sql_escape($add_extension_explain) . "')"; - $db->sql_query($sql); + $sql_ary = array( + 'group_id' => $add_extension_group, + 'extension' => $add_extension, + 'comment' => $add_extension_explain + ); + + $db->sql_query('INSERT INTO ' . EXTENSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); add_log('admin', 'LOG_ATTACH_EXT_ADD', $add_extension); } } @@ -270,13 +283,13 @@ if ($submit && $mode == 'ext_groups') { // Change Extension Groups ? $group_change_list = (isset($_POST['group_change_list'])) ? array_map('intval', $_POST['group_change_list']) : array(); - $extension_group_list = request_var('extension_group_list', ''); //(isset($_POST['extension_group_list'])) ? $_POST['extension_group_list'] : array(); + $extension_group_list = request_var('extension_group_list', ''); $group_allowed_list = (isset($_POST['allowed_list'])) ? array_flip(array_map('intval', $_POST['allowed_list'])) : array(); $download_mode_list = (isset($_POST['download_mode_list'])) ? array_map('intval', $_POST['download_mode_list']) : array(); $category_list = (isset($_POST['category_list'])) ? array_map('intval', $_POST['category_list']) : array(); - $upload_icon_list = request_var('upload_icon_list', ''); //(isset($_POST['upload_icon_list'])) ? $_POST['upload_icon_list'] : array(); + $upload_icon_list = request_var('upload_icon_list', ''); $filesize_list = (isset($_POST['max_filesize_list'])) ? array_map('intval', $_POST['max_filesize_list']) : array(); - $size_select_list = request_var('size_select_list', 'b'); //(isset($_POST['size_select_list'])) ? $_POST['size_select_list'] : array(); + $size_select_list = request_var('size_select_list', 'b'); foreach ($group_change_list as $group_id => $var) { @@ -302,16 +315,15 @@ if ($submit && $mode == 'ext_groups') if (sizeof($group_delete_list)) { - $l_group_list = ''; - $sql = 'SELECT group_name FROM ' . EXTENSION_GROUPS_TABLE . ' WHERE group_id IN (' . implode(', ', $group_delete_list) . ')'; $result = $db->sql_query($sql); + $l_group_list = array(); while ($row = $db->sql_fetchrow($result)) { - $l_group_list .= (($l_group_list != '') ? ', ' : '') . $row['group_name']; + $l_group_list[] = $row['group_name']; } $db->sql_freeresult($result); @@ -321,12 +333,12 @@ if ($submit && $mode == 'ext_groups') $db->sql_query($sql); // Set corresponding Extensions to a pending Group - $sql = "UPDATE " . EXTENSIONS_TABLE . " + $sql ='"UPDATE ' . EXTENSIONS_TABLE . ' SET group_id = 0 - WHERE group_id IN (" . implode(', ', $group_delete_list) . ")"; + WHERE group_id IN (' . implode(', ', $group_delete_list) . ')'; $db->sql_query($sql); - add_log('admin', 'LOG_ATTACH_EXTGROUP_DEL', $l_group_list); + add_log('admin', 'LOG_ATTACH_EXTGROUP_DEL', implode(', ', $l_group_list)); } // Add Extensions Group ? @@ -343,7 +355,8 @@ if ($submit && $mode == 'ext_groups') { // check Extension Group $sql = 'SELECT group_name - FROM ' . EXTENSION_GROUPS_TABLE; + FROM ' . EXTENSION_GROUPS_TABLE . " + WHERE group_name = '" . $db->sql_escape($extension_group) . "'"; $result = $db->sql_query_limit($sql, 1); if ($row = $db->sql_fetchrow($result)) @@ -410,7 +423,75 @@ if ($submit && $mode == 'ext_groups')

lang[$l_title . '_EXPLAIN']; ?>

-lang['LOG_ATTACH_ORPHAN_DEL'], implode(', ', $delete_files))); + $notify[] = sprintf($user->lang['LOG_ATTACH_ORPHAN_DEL'], implode(', ', $delete_files)); + } + + $upload_list = array(); + foreach ($add_files as $file) + { + if (!in_array($file, $delete_files) && $post_ids[$file]) + { + $upload_list[$post_ids[$file]] = $file; + } + } + unset($add_files); + + if (sizeof($upload_list)) + { +?> +

lang['UPLOADING_FILES']; ?>

+sql_query($sql); + + $forum_names = array(); + while ($row = $db->sql_fetchrow($result)) + { + $forum_names[$row['forum_id']] = $row['forum_name']; + } + $db->sql_freeresult($result); + + $sql = 'SELECT forum_id, topic_id, post_id + FROM ' . POSTS_TABLE . ' + WHERE post_id IN (' . implode(', ', array_keys($upload_list)) . ')'; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + echo sprintf($user->lang['UPLOADING_FILE_TO'], $upload_list[$row['post_id']], $row['post_id']) . '
'; + if (!$auth->acl_get('f_attach', $row['forum_id'])) + { + echo '' . sprintf($user->lang['UPLOAD_DENIED_FORUM'], $forum_names[$row['forum_id']]) . '

'; + } + else + { + upload_file($row['post_id'], $row['topic_id'], $row['forum_id'], $upload_dir, $upload_list[$row['post_id']]); + } + } + } +} + + if (sizeof($error)) { ?> @@ -433,14 +514,14 @@ if (sizeof($notify)) -
" method="post"> +">
   @@ -469,6 +550,7 @@ $select_pm_size_mode = size_select('pm_size', $pm_size);
sql_query($sql); $s_assigned_groups = array(); - while ($row = $db->sql_fetchrow($result)) { $s_assigned_groups[$row['cat_id']][] = $row['group_name']; } - + $db->sql_freeresult($result); + $display_inlined_yes = ($new['img_display_inlined']) ? 'checked="checked"' : ''; $display_inlined_no = (!$new['img_display_inlined']) ? 'checked="checked"' : ''; @@ -618,6 +701,7 @@ if ($mode == 'cats') $img) { - $filename_list .= ''; + $filename_list .= ''; } - $size = isset($_REQUEST['size']) ? intval($_REQUEST['size']) : 0; + $size = request_var('size', 0); if (!$size && !$submit) { @@ -817,6 +901,7 @@ if ($mode == 'ext_groups') } +// Extensions if ($mode == 'extensions') { ?> @@ -874,6 +959,97 @@ if ($mode == 'extensions') + + + +sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + unset($attach_filelist[$row['physical_filename']]); + } + $db->sql_freeresult($result); + +?> + + + + + + + + + + + + + + + + += 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); +?> + + + + + + + + + + + + + +
Orphan Attachments
 lang['FILENAME']; ?>  lang['FILESIZE']; ?>  lang['ATTACH_POST_ID']; ?>  lang['ATTACH_TO_POST']; ?>  lang['DELETE']; ?> 
ID:
  lang['MARK_ALL']; ?> :: lang['UNMARK_ALL']; ?>lang['MARK_ALL']; ?> :: lang['UNMARK_ALL']; ?>
+
@@ -1066,28 +1242,72 @@ function download_select($select_name, $group_id = FALSE) return($group_select); } -// Get supported Image types -function get_supported_image_types() +// Upload already uploaded file... huh? are you kidding? +function upload_file($post_id, $topic_id, $forum_id, $upload_dir, $filename) { - $types = array(); + global $message_parser, $db, $user; - if (@extension_loaded('gd')) + $message_parser->attachment_data = array(); + + $message_parser->filename_data['filecomment'] = ''; + $message_parser->filename_data['filename'] = $upload_dir . '/' . $filename; + + $filedata = upload_attachment($filename, true, $upload_dir . '/' . $filename); + + if ($filedata['post_attach'] && !sizeof($filedata['error'])) { - if (@function_exists('imagegif')) - { - $types[] = '1'; - } - if (@function_exists('imagejpeg')) - { - $types[] = '2'; - } - if (@function_exists('imagepng')) - { - $types[] = '3'; - } - } + $message_parser->attachment_data = array( + 'physical_filename' => $filedata['destination_filename'], + 'real_filename' => $filedata['filename'], + 'comment' => $message_parser->filename_data['filecomment'], + 'extension' => $filedata['extension'], + 'mimetype' => $filedata['mimetype'], + 'filesize' => $filedata['filesize'], + 'filetime' => $filedata['filetime'], + 'thumbnail' => $filedata['thumbnail'] + ); - return ($types); + $message_parser->filename_data['filecomment'] = ''; + $filedata['post_attach'] = FALSE; + + // Submit Attachment + $attach_sql = $message_parser->attachment_data; + + $db->sql_transaction(); + + $sql = 'INSERT INTO ' . ATTACHMENTS_DESC_TABLE . ' ' . $db->sql_build_array('INSERT', $attach_sql); + $db->sql_query($sql); + + $attach_sql = array( + 'attach_id' => $db->sql_nextid(), + 'post_id' => $post_id, + 'privmsgs_id' => 0, + 'user_id_from' => $user->data['user_id'], + 'user_id_to' => 0 + ); + + $sql = 'INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $attach_sql); + $db->sql_query($sql); + + $sql = 'UPDATE ' . POSTS_TABLE . " + SET post_attachment = 1 + WHERE post_id = $post_id"; + $db->sql_query($sql); + + $sql = 'UPDATE ' . TOPICS_TABLE . " + SET topic_attachment = 1 + WHERE topic_id = $topic_id"; + $db->sql_query($sql); + + $db->sql_transaction('commit'); + + add_log('admin', sprintf($user->lang['LOG_ATTACH_FILEUPLOAD'], $post_id, $filename)); + echo '' . $user->lang['SUCCESSFULLY_UPLOADED'] . '

'; + } + else if (sizeof($filedata['error'])) + { + echo '' . sprintf($user->lang['ADMIN_UPLOAD_ERROR'], implode("
\t", $filedata['error'])) . '


'; + } } ?> \ No newline at end of file diff --git a/phpBB/adm/admin_board.php b/phpBB/adm/admin_board.php index 06eb755f43..de3ef0ce45 100644 --- a/phpBB/adm/admin_board.php +++ b/phpBB/adm/admin_board.php @@ -97,6 +97,10 @@ while ($row = $db->sql_fetchrow($result)) $default_config[$config_name] = $config_value; $new[$config_name] = request_var($config_name, $default_config[$config_name]); + if ($config_name == 'bump_interval' && $submit) + { + $new['bump_interval'] = request_var('bump_interval', 0) . request_var('bump_type', ''); + } if ($submit) { @@ -375,6 +379,17 @@ switch ($mode) $display_last_edited_yes = ($new['display_last_edited']) ? 'checked="checked"' : ''; $display_last_edited_no = (!$new['display_last_edited']) ? 'checked="checked"' : ''; + + $bump_type = (string) preg_replace('#^[0-9]+([m|h|d])$#', '\1', $new['bump_interval']); + $bump_time = (int) preg_replace('#^([0-9]+)[m|h|d]$#', '\1', $new['bump_interval']); + + $s_bump_type = ''; + $types = array('m' => 'MINUTES', 'h' => 'HOURS', 'd' => 'DAYS'); + foreach ($types as $type => $lang) + { + $selected = ($type == $bump_type) ? 'selected="selected" ' : ''; + $s_bump_type .= ''; + } ?> lang['SITE_NAME']; ?>: @@ -433,6 +448,10 @@ switch ($mode) lang['FLOOD_INTERVAL']; ?>:
lang['FLOOD_INTERVAL_EXPLAIN']; ?> + + lang['BUMP_INTERVAL']; ?>:
lang['BUMP_INTERVAL_EXPLAIN']; ?> +   + lang['TOPICS_PER_PAGE']; ?>: diff --git a/phpBB/common.php b/phpBB/common.php index 731320e38f..0187566308 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -191,7 +191,6 @@ define('STYLES_IMAGE_TABLE', $table_prefix.'styles_imageset'); define('TOPICS_TABLE', $table_prefix.'topics'); define('TOPICS_TRACK_TABLE', $table_prefix.'topics_marking'); define('TOPICS_WATCH_TABLE', $table_prefix.'topics_watch'); -define('UCP_MODULES_TABLE', $table_prefix.'ucp_modules'); define('USER_GROUP_TABLE', $table_prefix.'user_group'); define('USERS_TABLE', $table_prefix.'users'); define('WORDS_TABLE', $table_prefix.'words'); diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 40991815a6..78c46bafd0 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -652,7 +652,8 @@ function delete_attachments($post_id_array = -1, $attach_id_array = -1, $page = $db->sql_freeresult($result); } - // TODO - Return number of deleted attachments + // TODO + // Return number of deleted attachments } function delete_topic_shadows($max_age, $forum_id = '', $auto_sync = TRUE) @@ -702,9 +703,11 @@ function delete_topic_shadows($max_age, $forum_id = '', $auto_sync = TRUE) // Delete File function phpbb_unlink($filename, $mode = 'file') { - global $config, $user; + global $config, $user, $phpbb_root_path; - $filename = ($mode == 'thumbnail') ? $config['upload_dir'] . '/thumbs/t_' . $filename : $config['upload_dir'] . '/' . $filename; + $upload_dir = ($config['upload_dir'][0] == '/' || ($config['upload_dir'][0] != '/' && $config['upload_dir'][1] == ':')) ? $config['upload_dir'] : $phpbb_root_path . $config['upload_dir']; + + $filename = ($mode == 'thumbnail') ? $upload_dir . '/thumbs/t_' . $filename : $upload_dir . '/' . $filename; $deleted = @unlink($filename); if (file_exists($filename)) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index e9bbb0d5b4..17ba765b8f 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -445,6 +445,8 @@ function display_attachments($attachment_data, &$update_count, $force_physical = break; } + $l_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'])); + $template_array = array_merge($additional_array, array( // 'IS_FLASH' => ($display_cat == SWF_CAT) ? true : false, 'IS_WM_STREAM' => ($display_cat == WM_CAT) ? true : false, @@ -461,7 +463,7 @@ function display_attachments($attachment_data, &$update_count, $force_physical = 'UPLOAD_IMG' => $upload_image, 'L_DOWNLOADED_VIEWED' => $l_downloaded_viewed, - 'L_DOWNLOAD_COUNT' => sprintf($user->lang['DOWNLOAD_NUMBER'], $attachment['download_count'])) + 'L_DOWNLOAD_COUNT' => $l_download_count) ); $template->assign_block_vars('postrow.attachment', $template_array); diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index f63b797373..677bdc08bd 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -47,7 +47,6 @@ function generate_smilies($mode, $forum_id) FROM ' . SMILIES_TABLE . ' WHERE display_on_posting = 0'; $result = $db->sql_query_limit($sql, 1, 0, 3600); - $row = $db->sql_fetchrow($result); if ($row = $db->sql_fetchrow($result)) { @@ -194,7 +193,7 @@ function update_last_post_information($type, $id) } // Upload Attachment - filedata is generated here -function upload_attachment($filename) +function upload_attachment($filename, $local = false, $local_storage = '') { global $auth, $user, $config, $db; @@ -208,8 +207,8 @@ function upload_attachment($filename) } $r_file = $filename; - $file = $_FILES['fileupload']['tmp_name']; - $filedata['mimetype'] = $_FILES['fileupload']['type']; + $file = (!$local) ? $_FILES['fileupload']['tmp_name'] : $local_storage; + $filedata['mimetype'] = (!$local) ? $_FILES['fileupload']['type'] : 'application/octet-stream'; // Opera add the name to the mime type $filedata['mimetype'] = ( strstr($filedata['mimetype'], '; name') ) ? str_replace(strstr($filedata['mimetype'], '; name'), '', $filedata['mimetype']) : $filedata['mimetype']; @@ -239,7 +238,7 @@ function upload_attachment($filename) } // check php upload-size - if ( ($file == 'none') ) + if ($file == 'none') { $filedata['error'][] = (@ini_get('upload_max_filesize') == '') ? $user->lang['ATTACHMENT_PHP_SIZE_NA'] : sprintf($user->lang['ATTACHMENT_PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize')); $filedata['post_attach'] = FALSE; @@ -304,6 +303,7 @@ function upload_attachment($filename) // Descide the Upload method $upload_mode = (@ini_get('open_basedir') || @ini_get('safe_mode')) ? 'move' : 'copy'; + $upload_mode = ($local) ? 'local' : $upload_mode; // Ok, upload the File $result = move_uploaded_attachment($upload_mode, $file, $filedata); @@ -319,40 +319,50 @@ function upload_attachment($filename) // Move/Upload File - could be used for Avatars too ? function move_uploaded_attachment($upload_mode, $source_filename, &$filedata) { - global $user, $config; + global $user, $config, $phpbb_root_path; + $upload_dir = ($config['upload_dir'][0] == '/' || ($config['upload_dir'][0] != '/' && $config['upload_dir'][1] == ':')) ? $config['upload_dir'] : $phpbb_root_path . $config['upload_dir']; $destination_filename = $filedata['destination_filename']; $thumbnail = (isset($filedata['thumbnail'])) ? $filedata['thumbnail'] : FALSE; switch ($upload_mode) { case 'copy': - if ( !@copy($source_filename, $config['upload_dir'] . '/' . $destination_filename) ) + if ( !@copy($source_filename, $upload_dir . '/' . $destination_filename) ) { - if ( !@move_uploaded_file($source_filename, $config['upload_dir'] . '/' . $destination_filename) ) + if ( !@move_uploaded_file($source_filename, $upload_dir . '/' . $destination_filename) ) { - return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], './' . $config['upload_dir'] . '/' . $destination_filename); + return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $upload_dir . '/' . $destination_filename); } } - @chmod($config['upload_dir'] . '/' . $destination_filename, 0666); + @chmod($upload_dir . '/' . $destination_filename, 0666); break; case 'move': - if ( !@move_uploaded_file($source_filename, $config['upload_dir'] . '/' . $destination_filename) ) + if ( !@move_uploaded_file($source_filename, $upload_dir . '/' . $destination_filename) ) { - if ( !@copy($source_file, $config['upload_dir'] . '/' . $destination_filename) ) + if ( !@copy($source_file, $upload_dir . '/' . $destination_filename) ) { - return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], './' . $config['upload_dir'] . '/' . $destination_filename); + return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $upload_dir . '/' . $destination_filename); } } - @chmod($config['upload_dir'] . '/' . $destination_filename, 0666); + @chmod($upload_dir . '/' . $destination_filename, 0666); + break; + + case 'local': + if (!@copy($source_filename, $upload_dir . '/' . $destination_filename)) + { + return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $upload_dir . '/' . $destination_filename); + } + @chmod($upload_dir . '/' . $destination_filename, 0666); + @unlink($source_filename); break; } if ($filedata['thumbnail']) { - $source = $config['upload_dir'] . '/' . $destination_filename; - $destination = $config['upload_dir'] . '/thumbs/t_' . $destination_filename; + $source = $upload_dir . '/' . $destination_filename; + $destination = $upload_dir . '/thumbs/t_' . $destination_filename; if (!create_thumbnail($source, $destination, $filedata['mimetype'])) { diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index bf1b0f0d53..92557fbb78 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -62,9 +62,8 @@ class parse_message // Do some general 'cleanup' first before processing message, // e.g. remove excessive newlines(?), smilies(?) // Transform \r\n and \r into \n - $match = array('#\r\n?#', '#sid=[a-z0-9]*?&?#', "#([\n][\s]+){3,}#"); + $match = array('#\r\n?#', '#sid=[a-z0-9]*?&?#', "#([\n][\s]+){3,}#"); $replace = array("\n", '', "\n\n"); - $this->message = trim(preg_replace($match, $replace, $this->message)); // Message length check @@ -78,17 +77,13 @@ class parse_message if ($bbcode) { $this->bbcode_init(); - if (!$allow_img) + $disallow = array('allow_img', 'allow_flash', 'allow_quote'); + foreach ($disallow as $bool) { - $this->bbcodes['img']['disabled'] = TRUE; - } - if (!$allow_flash) - { - $this->bbcodes['flash']['disabled'] = TRUE; - } - if (!$allow_quote) - { - $this->bbcodes['quote']['disabled'] = TRUE; + if (!$$bool) + { + $this->bbcodes[str_replace('allow_', '', $bool)]['disabled'] = TRUE; + } } $this->bbcode(); } diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 4133ec3e2f..c8cb5469f6 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -117,6 +117,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_yim_user',''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_yim_pass',''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('require_activation','0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('flood_interval','15'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('bump_interval','10h'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_interval','0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_filesize','6144'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_min_width','20'); @@ -169,6 +170,7 @@ INSERT INTO phpbb_auth_options (auth_option, is_local) VALUES ('f_quote', 1); INSERT INTO phpbb_auth_options (auth_option, is_local) VALUES ('f_edit', 1); INSERT INTO phpbb_auth_options (auth_option, is_local) VALUES ('f_lock', 1); INSERT INTO phpbb_auth_options (auth_option, is_local) VALUES ('f_delete', 1); +INSERT INTO phpbb_auth_options (auth_option, is_local) VALUES ('f_bump', 1); INSERT INTO phpbb_auth_options (auth_option, is_local) VALUES ('f_poll', 1); INSERT INTO phpbb_auth_options (auth_option, is_local) VALUES ('f_vote', 1); INSERT INTO phpbb_auth_options (auth_option, is_local) VALUES ('f_votechg', 1); diff --git a/phpBB/language/en/lang_admin.php b/phpBB/language/en/lang_admin.php index 2b41e8a503..5cca809f47 100644 --- a/phpBB/language/en/lang_admin.php +++ b/phpBB/language/en/lang_admin.php @@ -134,6 +134,13 @@ $lang += array( 'LOG_LOAD_CONFIG' => 'Altered load settings', 'LOG_ATTACH_CONFIG' => 'Altered attachment settings', + 'LOG_ATTACH_EXT_ADD' => 'Added or edited attachment extension
» %s', + 'LOG_ATTACH_EXT_DEL' => 'Removed attachment extension
» %s', + 'LOG_ATTACH_EXT_UPDATE' => 'Updated attachment extension
» %s', + 'LOG_ATTACH_EXTGROUP_ADD' => 'Added or edited extension group
» %s', + 'LOG_ATTACH_EXTGROUP_DEL' => 'Removed extension group
» %s', + 'LOG_ATTACH_FILEUPLOAD' => 'Orphan File uploaded to Post Number %1$d - %2$s', + 'LOG_ATTACH_ORPHAN_DEL' => 'Orphan Files deleted
» %s', 'log_prune_user_deac' => 'Users Deactivated
%s', 'log_prune_user_del_del'=> 'Users Pruned and Posts Deleted
%s', @@ -155,11 +162,6 @@ $lang += array( 'LOG_ACL_GROUP_ADD' => 'Edited Group permissions
» %s', 'LOG_ACL_PRESET_ADD' => 'Added or edited permission preset
» %s', 'LOG_ACL_PRESET_DEL' => 'Deleted permission preset
» %s', - 'LOG_ATTACH_EXT_ADD' => 'Added or edited attachment extension
» %s', - 'LOG_ATTACH_EXT_DEL' => 'Removed attachment extension
» %s', - 'LOG_ATTACH_EXT_UPDATE' => 'Updated attachment extension
» %s', - 'LOG_ATTACH_EXTGROUP_ADD' => 'Added or edited extension group
» %s', - 'LOG_ATTACH_EXTGROUP_DEL' => 'Removed extension group
» %s', 'LOG_FORUM_ADD' => 'Created new forum
» %s', 'LOG_FORUM_MOVE_UP' => 'Moved forum %s above %s', @@ -711,6 +713,8 @@ $lang += array( 'DISPLAY_LAST_EDITED_EXPLAIN' => 'Choose if the last edited by information to be displayed on posts', 'FLOOD_INTERVAL' => 'Flood Interval', 'FLOOD_INTERVAL_EXPLAIN' => 'Number of seconds a user must wait between posting new messages. To enable users to ignore this alter their permissions.', + 'BUMP_INTERVAL' => 'Bump Interval', + 'BUMP_INTERVAL_EXPLAIN' => 'Number of minutes, hours or days between the last post to a topic and the ability to bump this topic.', 'SEARCH_INTERVAL' => 'Search Flood Interval', 'SEARCH_INTERVAL_EXPLAIN' => 'Number of seconds users must wait between searches.', 'MIN_SEARCH_CHARS' => 'Min characters indexed by search', @@ -892,8 +896,10 @@ $lang += array( 'EXPORT_SMILE' => 'Create smilies pak', 'IMPORT_ICONS' => 'Install icons pak', 'EXPORT_ICONS' => 'Create icons pak', - 'ADD_SMILE' => 'Add smilie', - 'ADD_ICONS' => 'Add icon', + 'ADD_SMILE' => 'Add smilies', + 'ADD_ICONS' => 'Add icons', + 'EDIT_SMILE' => 'Edit smilies', + 'EDIT_ICONS' => 'Edit Icons', 'SMILE_NOT_DISPLAYED' => 'The following smilies are not displayed on the posting page', 'ICONS_NOT_DISPLAYED' => 'The following icons are not displayed on the posting page', 'EMOTION' => 'Emotion', @@ -911,11 +917,13 @@ $lang += array( 'SMILE_EMOTION' => 'Emotion', 'SMILE_ADD' => 'Add a new Smilie', 'SMILE_EDIT' => 'Edit Smilie', + 'SMILE_LOCATION'=> 'Smilie location', 'ICONS_CONFIG' => 'Icon configuration', 'ICONS_URL' => 'Icon image file', 'ICONS_HEIGHT' => 'Icon height', 'ICONS_WIDTH' => 'Icon width', 'ICONS_ORDER' => 'Icon order', + 'ICONS_LOCATION'=> 'Icon location', 'ICONS_ADD' => 'Add a new Icon', 'ICONS_EDIT' => 'Edit Icon', 'EXPORT_SMILE_EXPLAIN' => 'To create a package of your currently installed smilies, click %sHERE%s to download the emoticons.pak file. Once downloaded create a zip or tgz file containing all of your smilies plus this .pak configuration file.', @@ -1556,15 +1564,16 @@ $lang += array( // Admin logs $lang += array( - 'ADMIN_LOGS_EXPLAIN' => 'This lists all the actions carried out by board administrators. You can sort by username, date, IP or action. If you have appropriate permissions you can also clear individual operations or the log as a whole.', - 'MOD_LOGS_EXPLAIN' => 'This lists the actions carried out by board moderators, select a forum from the drop down list. You can sort by username, date, IP or action. If you have appropriate permissions you can also clear individual operations or the log as a whole.', - 'CRITICAL_LOGS_EXPLAIN' => 'This lists the actions carried out by the board itself. These log provides you with information you are able to use for solving specific problems, for example non-delivery of emails. You can sort by username, date, IP or action. If you have appropriate permissions you can also clear individual operations or the log as a whole.', - 'DISPLAY_LOG' => 'Display entries from previous', - 'ALL_ENTRIES' => 'All entries', - 'SORT_IP' => 'IP address', - 'SORT_DATE' => 'Date', - 'SORT_ACTION' => 'Log action', - 'NO_ENTRIES' => 'No log entries for this period', + 'ADMIN_LOGS_EXPLAIN' => 'This lists all the actions carried out by board administrators. You can sort by username, date, IP or action. If you have appropriate permissions you can also clear individual operations or the log as a whole.', + 'MOD_LOGS_EXPLAIN' => 'This lists the actions carried out by board moderators, select a forum from the drop down list. You can sort by username, date, IP or action. If you have appropriate permissions you can also clear individual operations or the log as a whole.', + 'CRITICAL_LOGS_EXPLAIN' => 'This lists the actions carried out by the board itself. These log provides you with information you are able to use for solving specific problems, for example non-delivery of emails. You can sort by username, date, IP or action. If you have appropriate permissions you can also clear individual operations or the log as a whole.', + 'DISPLAY_LOG' => 'Display entries from previous', + + 'ALL_ENTRIES' => 'All entries', + 'SORT_IP' => 'IP address', + 'SORT_DATE' => 'Date', + 'SORT_ACTION' => 'Log action', + 'NO_ENTRIES' => 'No log entries for this period', ); // Attachments @@ -1577,6 +1586,9 @@ $lang += array( 'ATTACH_CATS_URL' => 'Special Categories', 'ATTACH_EXTENSIONS_URL' => 'Extensions', 'ATTACH_EXT_GROUPS_URL' => 'Extension Groups', + 'ATTACH_ORPHAN_URL' => 'Orphan Attachments', + 'ORPHAN_ATTACHMENTS' => 'Orphan Attachments', // Title + 'ORPHAN_ATTACHMENTS_EXPLAIN'=> 'Here you are able to see files within the Attachments upload directory but not assigned to posts. This happens mostly if users are attaching files but not submitting the post. You are able to delete the files or attach them to existing posts. Attaching to posts requires a valid post id, you have to determine this id by yourself, this feature is mainly for those people wanting to upload files with another program and assigning those (mostly large) files to an existing post.', 'ATTACHMENT_SETTINGS' => 'Attachment Settings', 'ATTACHMENT_CONFIG_EXPLAIN' => 'Here you can configure the Main Settings for Attachments and the associated Special Categories.', @@ -1662,13 +1674,21 @@ $lang += array( 'EXTENSION_GROUP_EXIST' => 'The Extension Group %s already exist', 'MANAGE_EXTENSIONS' => 'Manage Extensions', - 'MANAGE_EXTENSIONS_EXPLAIN' => 'Here you can manage your allowed extensions. To activate your Extensions, please refer to the extension groups management panel. It is not recommended to add scripting extensions (such as php, php3, php4, phtml, pl, cgi, asp, aspx...)', + 'MANAGE_EXTENSIONS_EXPLAIN' => 'Here you can manage your allowed extensions. To activate your Extensions, please refer to the extension groups management panel. We strongly recommend not to allow scripting extensions (such as php, php3, php4, phtml, pl, cgi, asp, aspx...)', 'COMMENT' => 'Comment', 'EXTENSION' => 'Extension', 'ADD_EXTENSION' => 'Add extension', 'EXTENSIONS_UPDATED' => 'Extensions successfully updated', 'EXTENSION_EXIST' => 'The Extension %s already exist', 'NOT_ASSIGNED' => 'Not assigned', + + 'UPLOADING_FILES' => 'Uploading Files', + 'UPLOADING_FILE_TO' => 'Uploading File "%1$s" to Post Number %2$d...', + 'UPLOAD_DENIED_FORUM' => 'You do not have the permission to upload files to forum "%s"', + 'ATTACH_POST_ID' => 'Post ID', + 'ATTACH_TO_POST' => 'Attach file to post', + 'SUCCESSFULLY_UPLOADED' => 'Succeessfully uploaded', + 'ADMIN_UPLOAD_ERROR' => 'Errors while trying to attach file: %s' ); // Installation diff --git a/phpBB/language/en/lang_main.php b/phpBB/language/en/lang_main.php index 493e40b968..75d2c802da 100644 --- a/phpBB/language/en/lang_main.php +++ b/phpBB/language/en/lang_main.php @@ -47,6 +47,7 @@ $lang = array( 'AUTHOR' => 'Author', 'TIME' => 'Time', 'HOURS' => 'Hours', + 'MINUTES' => 'Minutes', 'MESSAGE' => 'Message', 'POST_TIME' => 'Post time', 'TOPIC_TIME' => 'Topic time', @@ -439,6 +440,7 @@ $lang += array( 'LOGIN_VIEWTOPIC' => 'The board administrator requires you to be registered and logged in to view this topic.', 'PRINT_TOPIC' => 'Print View', 'EMAIL_TOPIC' => 'Email Friend', + 'BUMP_TOPIC' => 'Bump Topic', 'VIEW_NEXT_TOPIC' => 'Next topic', 'VIEW_PREVIOUS_TOPIC' => 'Previous topic', 'VIEW_UNREAD_POST' => 'First unread post', @@ -548,7 +550,7 @@ $lang += array( 'TOPIC_REVIEW' => 'Topic review', 'TOPIC_ICON' => 'Topic icon', 'POST_ICON' => 'Post icon', - 'No_post_mode' => 'No post mode specified', + 'NO_POST_MODE' => 'No post mode specified', 'POST_TOPIC' => 'Post a new topic', 'POST_REPLY' => 'Post a reply', 'POST_TOPIC_AS' => 'Post topic as', @@ -567,10 +569,10 @@ $lang += array( 'LOCK_POST_EXPLAIN' => 'Prevent editing', 'CONFIRM_DELETE' => 'Are you sure you want to delete this post?', - 'Confirm_delete_poll' => 'Are you sure you want to delete this poll?', 'CANNOT_EDIT_TIME' => 'You can no longer edit or delete that post', 'CANNOT_EDIT_POST_LOCKED' => 'This post has been locked. You can no longer edit that post.', 'FLOOD_ERROR' => 'You cannot make another post so soon after your last.', + 'BUMP_ERROR' => 'You cannot bump this topic so soon after the last post.', 'EMPTY_SUBJECT' => 'You must specify a subject when posting a new topic.', 'To_long_subject' => 'The subject is too long it must be 60 characters or less.', 'EMPTY_MESSAGE' => 'You must enter a message when posting.', @@ -588,6 +590,7 @@ $lang += array( 'USER_CANNOT_EDIT' => 'You cannot edit posts in this forum', 'USER_CANNOT_DELETE' => 'You cannot delete posts in this forum', 'USER_CANNOT_REPORT' => 'You cannot report posts in this forum', + 'USER_CANNOT_BUMP' => 'You cannot bump topics in this forum', 'CANNOT_POST_STICKY' => 'Sorry but you cannot post sticky topics.', 'CANNOT_POST_ANNOUNCE' => 'Sorry but you cannot post announcements.', 'CANNOT_POST_NEWS' => 'Sorry but you cannot post news topics.', @@ -597,8 +600,6 @@ $lang += array( 'DELETE_OWN_POSTS' => 'Sorry but you can only delete your own posts.', 'ALREADY_DELETED' => 'Sorry but this message is already deleted.', - 'No_such_post' => 'There is no such post, please return and try again', - 'ADD_POLL' => 'Add a Poll', 'ADD_POLL_EXPLAIN' => 'If you do not want to add a poll to your topic leave the fields blank', 'POLL_QUESTION' => 'Poll question', @@ -647,7 +648,8 @@ $lang += array( 'POST_STORED' => 'Your message has been posted successfully', 'POST_STORED_MOD' => 'Your message has been saved but requires approval', - 'DELETED' => 'Your message has been deleted successfully', + 'POST_DELETED' => 'Your message has been deleted successfully', + 'TOPIC_BUMPED' => 'Topic has been bumped successfully', 'Poll_delete' => 'Your poll has been deleted successfully', 'Topic_reply_notification' => 'Topic Reply Notification', @@ -678,7 +680,6 @@ $lang += array( 'FILE_NOT_FOUND_404' => 'The file %s does not exist.', 'DOWNLOADED' => 'Downloaded', 'VIEWED' => 'Viewed', - 'DOWNLOAD_NUMBER' => '%d Time(s)', // replace %d with count <-- NEEDS CHANGING TO FOLLOWING 'DOWNLOAD_NONE' => '0 Times', // replace %d with count 'DOWNLOAD_COUNT' => '%d Time', // replace %d with count 'DOWNLOAD_COUNTS' => '%d Times', // replace %d with count diff --git a/phpBB/posting.php b/phpBB/posting.php index 6307549667..6349a4b474 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -71,6 +71,7 @@ switch ($mode) WHERE forum_id = $forum_id"; break; + case 'bump': case 'reply': if (!$topic_id) { @@ -107,7 +108,7 @@ switch ($mode) default: $sql = ''; - trigger_error('NO_MODE'); + trigger_error('NO_POST_MODE'); } $censors = array(); @@ -264,7 +265,6 @@ if (($forum_status == ITEM_LOCKED || $topic_status == ITEM_LOCKED) && !$auth->ac trigger_error($message); } - // Can we edit this post? if (($mode == 'edit' || $mode == 'delete') && !$auth->acl_get('m_edit', $forum_id) && $config['edit_time'] && $post_time < time() - $config['edit_time']) { @@ -313,12 +313,12 @@ if ($mode == 'delete' && (($poster_id == $user->data['user_id'] && $user->data[' if ($topic_first_post_id == $topic_last_post_id) { $meta_info = "viewforum.$phpEx$SID&f=$forum_id"; - $message = $user->lang['DELETED']; + $message = $user->lang['POST_DELETED']; } else { $meta_info = "viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&p=$next_post_id#$next_post_id"; - $message = $user->lang['DELETED'] . '

' . sprintf($user->lang['RETURN_TOPIC'], "", ''); + $message = $user->lang['POST_DELETED'] . '

' . sprintf($user->lang['RETURN_TOPIC'], "", ''); } meta_refresh(3, $meta_info); @@ -377,6 +377,55 @@ $flash_status = ($auth->acl_get('f_flash', $forum_id)) ? TRUE : FALSE; $quote_status = ($config['allow_quote'] && $auth->acl_get('f_quote', $forum_id)) ? TRUE : FALSE; +// Bump Topic +if ($mode == 'bump' && !$auth->acl_get('f_bump', $forum_id)) +{ + trigger_error('USER_CANNOT_BUMP'); +} +else if ($mode == 'bump') +{ + // Check bump time range, is the user really allowed to bump the topic at this time? + $bump_type = (string) preg_replace('#^[0-9]+([m|h|d])$#', '\1', $config['bump_time_range']); + $bump_time = (int) preg_replace('#^([0-9]+)[m|h|d]$#', '\1', $config['bump_time_range']); + $bump_time = ($bump_type == 'm') ? $bump_time*60 : (($bump_type == 'h') ? $bump_time*3600 : $bump_time*86400); + + if ($topic_last_post_time + $bump_time > time()) + { + trigger_error('BUMP_ERROR'); + } + + $current_time = time(); + + $db->sql_transaction(); + + $db->sql_query('UPDATE ' . POSTS_TABLE . " + SET post_time = $current_time + WHERE post_id = $topic_last_post_id + AND topic_id = $topic_id"); + + $db->sql_query('UPDATE ' . TOPICS_TABLE . " + SET topic_last_post_time = $current_time + WHERE topic_id = $topic_id"); + + $db->sql_query('UPDATE ' . FORUMS_TABLE . ' + SET ' . implode(', ', update_last_post_information('forum', $forum_id)) . " + WHERE forum_id = $forum_id"); + + $db->sql_query('UPDATE ' . USERS_TABLE . " + SET user_lastpost_time = $current_time + WHERE user_id = " . $user->data['user_id']); + + $db->sql_transaction('commit'); + + markread('post', $forum_id, $topic_id, $current_time); + + meta_refresh(3, "viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&p=$topic_last_post_id#$topic_last_post_id"); + + $message = $user->lang['TOPIC_BUMPED'] . '

' . sprintf($user->lang['VIEW_MESSAGE'], '", '') . '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + trigger_error($message); +} + + // Save Draft if (($save || isset($_POST['draft_save'])) && $user->data['user_id'] != ANONYMOUS && $auth->acl_get('u_savedrafts')) { @@ -467,11 +516,7 @@ if ($submit || $preview || $refresh) if ($poll_delete && (($mode == 'edit' && !empty($poll_options) && empty($poll_last_vote) && $poster_id == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))) { // Delete Poll - $sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . " - WHERE topic_id = $topic_id"; - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . " + $sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . ', ' . POLL_VOTES_TABLE . " WHERE topic_id = $topic_id"; $db->sql_query($sql); @@ -522,7 +567,7 @@ if ($submit || $preview || $refresh) if ($mode != 'edit' || $message_md5 != $post_checksum || $status_switch || $preview) { // Parse message - $message_parser->parse($enable_html, $enable_bbcode, $enable_urls, $enable_smilies, $img_status, $flash_status); + $message_parser->parse($enable_html, $enable_bbcode, $enable_urls, $enable_smilies, $img_status, $flash_status, $auth->acl_get('f_quote', $forum_id)); } $message_parser->parse_attachments($mode, $post_id, $submit, $preview, $refresh); @@ -1289,37 +1334,33 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id if (sizeof($update_notification['topic'])) { - $sql = 'UPDATE ' . TOPICS_WATCH_TABLE . " + $db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . " SET notify_status = 1 WHERE topic_id = $topic_id - AND user_id IN (" . implode(', ', $update_notification['topic']) . ")"; - $db->sql_query($sql); + AND user_id IN (" . implode(', ', $update_notification['topic']) . ")"); } if (sizeof($update_notification['forum'])) { - $sql = 'UPDATE ' . FORUMS_WATCH_TABLE . " + $db->sql_query('UPDATE ' . FORUMS_WATCH_TABLE . " SET notify_status = 1 WHERE forum_id = $forum_id - AND user_id IN (" . implode(', ', $update_notification['forum']) . ")"; - $db->sql_query($sql); + AND user_id IN (" . implode(', ', $update_notification['forum']) . ")"); } // Now delete the user_ids not authorized to receive notifications on this topic/forum if (sizeof($delete_ids['topic'])) { - $sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . " + $db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . " WHERE topic_id = $topic_id - AND user_id IN (" . implode(', ', $delete_ids['topic']) . ")"; - $db->sql_query($sql); + AND user_id IN (" . implode(', ', $delete_ids['topic']) . ")"); } if (sizeof($delete_ids['forum'])) { - $sql = 'DELETE FROM ' . FORUMS_WATCH_TABLE . " + $db->sql_query('DELETE FROM ' . FORUMS_WATCH_TABLE . " WHERE forum_id = $forum_id - AND user_id IN (" . implode(', ', $delete_ids['forum']) . ")"; - $db->sql_query($sql); + AND user_id IN (" . implode(', ', $delete_ids['forum']) . ")"); } $db->sql_transaction('commit'); @@ -1571,26 +1612,23 @@ function delete_post($mode, $post_id, $topic_id, $forum_id, $data) if (isset($sql_data['forum']) && $sql_data['forum'] != '') { - $sql = 'UPDATE ' . FORUMS_TABLE . ' + $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET ' . $sql_data['forum'] . " - WHERE forum_id = $forum_id"; - $db->sql_query($sql); + WHERE forum_id = $forum_id"); } if (isset($sql_data['topic']) && $sql_data['topic'] != '') { - $sql = 'UPDATE ' . TOPICS_TABLE . ' + $db->sql_query('UPDATE ' . TOPICS_TABLE . ' SET ' . $sql_data['topic'] . " - WHERE topic_id = $topic_id"; - $db->sql_query($sql); + WHERE topic_id = $topic_id"); } if (isset($sql_data['user']) && $sql_data['user'] != '') { - $sql = 'UPDATE ' . USERS_TABLE . ' + $db->sql_query('UPDATE ' . USERS_TABLE . ' SET ' . $sql_data['user'] . ' - WHERE user_id = ' . $data['poster_id']; - $db->sql_query($sql); + WHERE user_id = ' . $data['poster_id']); } $db->sql_transaction('commit'); @@ -1755,7 +1793,7 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_ break; } - $db->sql_transaction(); +// $db->sql_transaction(); // Submit new topic if ($post_mode == 'post') @@ -1838,19 +1876,17 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_ // Update the topics table if (isset($sql_data['topic']['sql'])) { - $sql = 'UPDATE ' . TOPICS_TABLE . ' + $db->sql_query('UPDATE ' . TOPICS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_data['topic']['sql']) . ' - WHERE topic_id = ' . $data['topic_id']; - $db->sql_query($sql); + WHERE topic_id = ' . $data['topic_id']); } // Update the posts table if (isset($sql_data['post']['sql'])) { - $sql = 'UPDATE ' . POSTS_TABLE . ' + $db->sql_query('UPDATE ' . POSTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_data['post']['sql']) . ' - WHERE post_id = ' . $data['post_id']; - $db->sql_query($sql); + WHERE post_id = ' . $data['post_id']); } // Update Poll Tables and Attachment Entries @@ -1959,7 +1995,7 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_ } - $db->sql_transaction('commit'); +// $db->sql_transaction('commit'); if ($post_mode == 'post' || $post_mode == 'reply' || $post_mode == 'edit_last_post') { @@ -2013,34 +2049,30 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_ if (implode('', $sql_data['post']['stat']) != '') { - $sql = 'UPDATE ' . POSTS_TABLE . ' + $db->sql_query('UPDATE ' . POSTS_TABLE . ' SET ' . implode(', ', $sql_data['post']['stat']) . ' - WHERE post_id = ' . $data['post_id']; - $db->sql_query($sql); + WHERE post_id = ' . $data['post_id']); } if (implode('', $sql_data['topic']['stat']) != '') { - $sql = 'UPDATE ' . TOPICS_TABLE . ' + $db->sql_query('UPDATE ' . TOPICS_TABLE . ' SET ' . implode(', ', $sql_data['topic']['stat']) . ' - WHERE topic_id = ' . $data['topic_id']; - $db->sql_query($sql); + WHERE topic_id = ' . $data['topic_id']); } if (implode('', $sql_data['forum']['stat']) != '') { - $sql = 'UPDATE ' . FORUMS_TABLE . ' + $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET ' . implode(', ', $sql_data['forum']['stat']) . ' - WHERE forum_id = ' . $data['forum_id']; - $db->sql_query($sql); + WHERE forum_id = ' . $data['forum_id']); } if (implode('', $sql_data['user']['stat']) != '') { - $sql = 'UPDATE ' . USERS_TABLE . ' + $db->sql_query('UPDATE ' . USERS_TABLE . ' SET ' . implode(', ', $sql_data['user']['stat']) . ' - WHERE user_id = ' . $user->data['user_id']; - $db->sql_query($sql); + WHERE user_id = ' . $user->data['user_id']); } // Fulltext parse diff --git a/phpBB/styles/subSilver/template/viewtopic_body.html b/phpBB/styles/subSilver/template/viewtopic_body.html index e08865e9dc..10fc0ccf8e 100644 --- a/phpBB/styles/subSilver/template/viewtopic_body.html +++ b/phpBB/styles/subSilver/template/viewtopic_body.html @@ -28,9 +28,10 @@ diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 7145badc3f..d8c4eb4ec0 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -162,7 +162,7 @@ if ($user->data['user_id'] != ANONYMOUS) // whereupon we join on the forum_id passed as a parameter ... this // is done so navigation, forum name, etc. remain consistent with where // user clicked to view a global topic -$sql = 'SELECT t.topic_id, t.forum_id, t.topic_title, t.topic_attachment, t.topic_status, t.topic_approved, ' . (($auth->acl_get('m_approve')) ? 't.topic_replies_real AS topic_replies' : 't.topic_replies') . ', t.topic_last_post_id, t.topic_poster, t.topic_time, t.topic_time_limit, t.topic_type, t.poll_max_options, t.poll_start, t.poll_length, t.poll_title, f.forum_name, f.forum_desc, f.forum_parents, f.parent_id, f.left_id, f.right_id, f.forum_status, f.forum_id, f.forum_style, f.forum_password' . $extra_fields . ' +$sql = 'SELECT t.topic_id, t.forum_id, t.topic_title, t.topic_attachment, t.topic_status, t.topic_approved, ' . (($auth->acl_get('m_approve')) ? 't.topic_replies_real AS topic_replies' : 't.topic_replies') . ', t.topic_last_post_id, t.topic_last_post_time, t.topic_poster, t.topic_time, t.topic_time_limit, t.topic_type, t.poll_max_options, t.poll_start, t.poll_length, t.poll_title, f.forum_name, f.forum_desc, f.forum_parents, f.parent_id, f.left_id, f.right_id, f.forum_status, f.forum_id, f.forum_style, f.forum_password' . $extra_fields . ' FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f' . $join_sql_table . " WHERE $join_sql AND (f.forum_id = t.forum_id @@ -446,6 +446,12 @@ if (sizeof($censors)) $topic_title = preg_replace($censors['match'], $censors['replace'], $topic_title); } +// Bump topic allowed? +$bump_type = (string) preg_replace('#^[0-9]+([m|h|d])$#', '\1', $config['bump_time_range']); +$bump_time = (int) preg_replace('#^([0-9]+)[m|h|d]$#', '\1', $config['bump_time_range']); +$bump_time = ($bump_type == 'm') ? $bump_time*60 : (($bump_type == 'h') ? $bump_time*3600 : $bump_time*86400); +unset($bump_type); + // Send vars to template $template->assign_vars(array( 'FORUM_ID' => $forum_id, @@ -501,7 +507,8 @@ $template->assign_vars(array( 'U_EMAIL_TOPIC' => ($auth->acl_get('f_email', $forum_id) && $config['email_enable']) ? "memberlist.$phpEx$SID&mode=email&t=$topic_id" : '', 'U_POST_NEW_TOPIC' => "posting.$phpEx$SID&mode=post&f=$forum_id", - 'U_POST_REPLY_TOPIC' => "posting.$phpEx$SID&mode=reply&f=$forum_id&t=$topic_id") + 'U_POST_REPLY_TOPIC' => "posting.$phpEx$SID&mode=reply&f=$forum_id&t=$topic_id", + 'U_BUMP_TOPIC' => ($topic_last_post_time + $bump_time < time() && $auth->acl_get('f_bump', $forum_id)) ? "posting.$phpEx$SID&mode=bump&f=$forum_id&t=$topic_id" : '') ); // Does this topic contain a poll?