diff options
author | James Atkinson <thefinn@users.sourceforge.net> | 2001-09-03 07:52:57 +0000 |
---|---|---|
committer | James Atkinson <thefinn@users.sourceforge.net> | 2001-09-03 07:52:57 +0000 |
commit | e515d617ed1538b6c6c3f1e2abf262fbe6ccb2d7 (patch) | |
tree | 9c1e51f97bc84ffbed3ab4d010943c81d2d5357d | |
parent | 61a1e500525ee0c0a4fc807a33635d6f89d3b79b (diff) | |
download | forums-e515d617ed1538b6c6c3f1e2abf262fbe6ccb2d7.tar forums-e515d617ed1538b6c6c3f1e2abf262fbe6ccb2d7.tar.gz forums-e515d617ed1538b6c6c3f1e2abf262fbe6ccb2d7.tar.bz2 forums-e515d617ed1538b6c6c3f1e2abf262fbe6ccb2d7.tar.xz forums-e515d617ed1538b6c6c3f1e2abf262fbe6ccb2d7.zip |
Fixed bug #457835
git-svn-id: file:///svn/phpbb/trunk@976 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r-- | phpBB/includes/functions.php | 42 | ||||
-rw-r--r-- | phpBB/modcp.php | 98 |
2 files changed, 109 insertions, 31 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index f5f995c792..cc668e8f3a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -567,18 +567,18 @@ function validate_username($username) function sync($type, $id) { global $db; - + switch($type) { case 'all forums': - $sql = "SELECT forum_id + $sql = "SELECT forum_id FROM " . FORUMS_TABLE; if( !$result = $db->sql_query($sql) ) { message_die(GENERAL_ERROR, "Could not get forum IDs", "Error", __LINE__, __FILE__, $sql); } $rowset = $db->sql_fetchrowset($result); - + for($i = 0; $i < count($rowset); $i++) { sync("forum", $row[$i]['forum_id']); @@ -586,7 +586,7 @@ function sync($type, $id) break; case 'all topics': - $sql = "SELECT topic_id + $sql = "SELECT topic_id FROM " . TOPICS_TABLE; if( !$result = $db->sql_query($sql) ) { @@ -601,10 +601,10 @@ function sync($type, $id) break; case 'forum': - $sql = "SELECT MAX(p.post_id) AS last_post - FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t - WHERE p.forum_id = $id - AND p.topic_id = t.topic_id + $sql = "SELECT MAX(p.post_id) AS last_post + FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t + WHERE p.forum_id = $id + AND p.topic_id = t.topic_id AND t.topic_status <> " . TOPIC_MOVED; if( !$result = $db->sql_query($sql) ) { @@ -613,15 +613,15 @@ function sync($type, $id) if( $row = $db->sql_fetchrow($result) ) { - $last_post = $row['last_post']; + $last_post = ($row['last_post']) ? $row['last_post'] : 0; } else { $last_post = 0; } - $sql = "SELECT COUNT(post_id) AS total - FROM " . POSTS_TABLE . " + $sql = "SELECT COUNT(post_id) AS total + FROM " . POSTS_TABLE . " WHERE forum_id = $id"; if( !$result = $db->sql_query($sql) ) { @@ -629,8 +629,8 @@ function sync($type, $id) } $total_posts = ( $row = $db->sql_fetchrow($result) ) ? $row['total'] : 0; - $sql = "SELECT COUNT(topic_id) AS total - FROM " . TOPICS_TABLE . " + $sql = "SELECT COUNT(topic_id) AS total + FROM " . TOPICS_TABLE . " WHERE forum_id = $id"; if( !$result = $db->sql_query($sql) ) { @@ -638,8 +638,8 @@ function sync($type, $id) } $total_topics = ( $row = $db->sql_fetchrow($result) ) ? $row['total'] : 0; - $sql = "UPDATE " . FORUMS_TABLE . " - SET forum_last_post_id = $last_post, forum_posts = $total_posts, forum_topics = $total_topics + $sql = "UPDATE " . FORUMS_TABLE . " + SET forum_last_post_id = $last_post, forum_posts = $total_posts, forum_topics = $total_topics WHERE forum_id = $id"; if( !$result = $db->sql_query($sql) ) { @@ -648,8 +648,8 @@ function sync($type, $id) break; case 'topic': - $sql = "SELECT MAX(post_id) AS last_post - FROM " . POSTS_TABLE . " + $sql = "SELECT MAX(post_id) AS last_post + FROM " . POSTS_TABLE . " WHERE topic_id = $id"; if( !$result = $db->sql_query($sql) ) { @@ -665,8 +665,8 @@ function sync($type, $id) $last_post = 0; } - $sql = "SELECT COUNT(post_id) AS total - FROM " . POSTS_TABLE . " + $sql = "SELECT COUNT(post_id) AS total + FROM " . POSTS_TABLE . " WHERE topic_id = $id"; if( !$result = $db->sql_query($sql) ) { @@ -674,8 +674,8 @@ function sync($type, $id) } $total_posts = ( $row = $db->sql_fetchrow($result) ) ? $row['total'] - 1 : 0; - $sql = "UPDATE " . TOPICS_TABLE . " - SET topic_replies = $total_posts, topic_last_post_id = $last_post + $sql = "UPDATE " . TOPICS_TABLE . " + SET topic_replies = $total_posts, topic_last_post_id = $last_post WHERE topic_id = $id"; if( !$result = $db->sql_query($sql) ) { diff --git a/phpBB/modcp.php b/phpBB/modcp.php index 716965802e..e0ce70d9d5 100644 --- a/phpBB/modcp.php +++ b/phpBB/modcp.php @@ -11,6 +11,15 @@ * ***************************************************************************/ +/*************************************************************************** + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + ***************************************************************************/ + /** * Moderator Control Panel * @@ -31,6 +40,8 @@ $page_title = "Modertator Control Panel"; $forum_id = ($HTTP_POST_VARS[POST_FORUM_URL]) ? $HTTP_POST_VARS[POST_FORUM_URL] : $HTTP_GET_VARS[POST_FORUM_URL]; $topic_id = ($HTTP_POST_VARS[POST_TOPIC_URL]) ? $HTTP_POST_VARS[POST_TOPIC_URL] : $HTTP_GET_VARS[POST_TOPIC_URL]; + + if(empty($forum_id) || !isset($forum_id)) { $sql = "SELECT f.forum_id, f.forum_name, f.forum_topics @@ -207,12 +218,12 @@ switch($mode) message_die(GENERAL_ERROR, "Could not delete topics!", "Error", __LINE__, __FILE__, $delete_topics); } - if(!$result = $db->sql_query($moved_topics)) + if(!$result = $db->sql_query($moved_topics, END_TRANSACTION)) { message_die(GENERAL_ERROR, "Could not delete moved topics!", "Error", __LINE__, __FILE__, $moved_topics); } - sync("forum",$forum_id); + sync("forum", $forum_id); if($quick_op) { @@ -230,6 +241,10 @@ switch($mode) } else { + if(empty($HTTP_POST_VARS['preform_op']) && empty($topic_id)) + { + message_die(GENERAL_MESSAGE, $lang['None_selected'], $lang['Error']); + } $hidden_fields = '<input type="hidden" name="mode" value="'.$mode.'"><input type="hidden" name="'.POST_FORUM_URL.'" value="'.$forum_id.'"><input type="hidden" name="quick_op" value="'.$quick_op.'">'; if($HTTP_POST_VARS['preform_op']) { @@ -278,6 +293,7 @@ switch($mode) $sql_select = 'SELECT topic_title, topic_poster, + topic_status, topic_time FROM '. TOPICS_TABLE." WHERE @@ -289,6 +305,7 @@ switch($mode) else { $row = $db->sql_fetchrowset($result); + $ttitle = $row[0]['topic_title']; $tpost = $row[0]['topic_poster']; $ttime = $row[0]['topic_time']; @@ -362,6 +379,10 @@ switch($mode) } else { + if(empty($HTTP_POST_VARS['preform_op']) && empty($topic_id)) + { + message_die(GENERAL_MESSAGE, $lang['None_selected'], $lang['Error']); + } $hidden_fields = '<input type="hidden" name="mode" value="'.$mode.'"><input type="hidden" name="'.POST_FORUM_URL.'" value="'.$forum_id.'"><input type="hidden" name="quick_op" value="'.$quick_op.'">'; $hidden_fields .= $lang['New_forum'] . ': ' . make_forum_box('new_forum'). '</select><br><br>'; if($HTTP_POST_VARS['preform_op']) @@ -431,6 +452,10 @@ switch($mode) } else { + if(empty($HTTP_POST_VARS['preform_op']) && empty($topic_id)) + { + message_die(GENERAL_MESSAGE, $lang['None_selected'], $lang['Error']); + } $hidden_fields = '<input type="hidden" name="mode" value="'.$mode.'"><input type="hidden" name="'.POST_FORUM_URL.'" value="'.$forum_id.'"><input type="hidden" name="quick_op" value="'.$quick_op.'">'; if($HTTP_POST_VARS['preform_op']) { @@ -503,6 +528,11 @@ switch($mode) } else { + if(empty($HTTP_POST_VARS['preform_op']) && empty($topic_id)) + { + message_die(GENERAL_MESSAGE, $lang['None_selected'], $lang['Error']); + } + $hidden_fields = '<input type="hidden" name="mode" value="' . $mode . '"><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '"><input type="hidden" name="quick_op" value="' . $quick_op . '">'; if($HTTP_POST_VARS['preform_op']) @@ -565,8 +595,7 @@ switch($mode) $sql = "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type) - VALUES ('$subject', $first_poster, " . -$topic_time . ", $new_forum_id, " . TOPIC_UNLOCKED . ", " . POST_NORMAL . ")"; + VALUES ('$subject', $first_poster, " . $topic_time . ", $new_forum_id, " . TOPIC_UNLOCKED . ", " . POST_NORMAL . ")"; if(!$result = $db->sql_query($sql, BEGIN_TRANSACTION)) { message_die(GENERAL_ERROR, "Could not insert new topic", "", __LINE__, __FILE__, $sql); @@ -718,7 +747,53 @@ $topic_time . ", $new_forum_id, " . TOPIC_UNLOCKED . ", " . POST_NORMAL . ")"; $template->pparse("split_body"); } } - break; + break; + case 'ip': + $post_id = $HTTP_GET_VARS[POST_POST_URL]; + if(!$post_id) + { + message_die(GENERAL_ERROR, "Error, no post id found", "Error", __LINE__, __FILE__); + } + + // Look up relevent data for this post + $sql = "SELECT poster_ip, poster_id, post_username FROM ".POSTS_TABLE." WHERE post_id = $post_id"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Could not get poster IP information", "Error", __LINE__, __FILE__, $sql); + } + + $post_row = $db->sql_fetchrow($result); + + // Get other users who've posted under this IP + $sql = "SELECT u.username, u.user_id FROM " . USERS_TABLE ." u, " . POSTS_TABLE . " p WHERE p.poster_id = u.user_id AND p.poster_ip = '".$post_row['poster_ip']."'"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Could not get posters information based on IP", "Error", __LINE__, __FILE__, $sql); + } + + $poster_ids = $db->sql_fetchrowset($result); + sort($poster_ids); + + $posts = 0; + while(list($null, $userdata) = each($poster_ids)) + { + $username = $userdata['username']; + $user_id = $userdata['user_id']; + + if($username != $last_username && !empty($last_username)) + { + $other_users[] = array("username" => "$last_username", "user_id" => "$last_user_id", "posts" => "$posts"); + $posts = 1; + } + else + { + $posts += 1; + } + $last_username = $username; + $last_user_ip = $user_id; + } + + break; default: @@ -758,10 +833,15 @@ $topic_time . ", $new_forum_id, " . TOPIC_UNLOCKED . ", " . POST_NORMAL . ")"; for($x = 0; $x < $total_topics; $x++) { + $topic_title = ""; if($topics[$x]['topic_status'] == TOPIC_LOCKED) { $folder_image = "<img src=\"" . $images['folder_locked'] . "\" alt=\"Topic Locked\">"; } + else if($topics[$x]['topic_status'] == TOPIC_MOVED) + { + $topic_title = "<b>" . $lang['Topic_Moved'] . ":</b> "; + } else { $folder_image = "<img src=\"" . $images['folder'] . "\">"; @@ -769,15 +849,13 @@ $topic_time . ", $new_forum_id, " . TOPIC_UNLOCKED . ", " . POST_NORMAL . ")"; $topic_id = $topics[$x]['topic_id']; - $topic_title = ""; - if($topics[$x]['topic_type'] == POST_STICKY) { - $topic_title = $lang['Sticky'] . " "; + $topic_title = "<b>".$lang['Post_Sticky'] . ":</b> "; } else if($topics[$x]['topic_type'] == POST_ANNOUNCE) { - $topic_title = $lang['Annoucement'] . " "; + $topic_title = "<b>" . $lang['Post_Announcement'] . ":</b> "; } $topic_title .= stripslashes($topics[$x]['topic_title']); @@ -818,4 +896,4 @@ $topic_time . ", $new_forum_id, " . TOPIC_UNLOCKED . ", " . POST_NORMAL . ")"; include($phpbb_root_path . 'includes/page_tail.'.$phpEx); -?> +?>
\ No newline at end of file |