diff --git a/html/inc/forum_show.inc b/html/inc/forum_show.inc index 96ecb91099..aa36e1f0cb 100644 --- a/html/inc/forum_show.inc +++ b/html/inc/forum_show.inc @@ -85,8 +85,7 @@ function show_forum($category, $forum, $start, $sort_style, $logged_in_user) { } else { start_forum_table(array("", "Threads", "Posts", "Author", "Views", "Last post")); } - - $threads = getThreads($forum->id, $start, $threads_per_page, $sort_style); + $threads = getThreads($forum->id, $start, $threads_per_page, $sort_style, 0, 1); $n = 0; while ($thread = mysql_fetch_object($threads)) { @@ -106,9 +105,15 @@ function show_forum($category, $forum, $start, $sort_style, $logged_in_user) { if ($first_post->score*$first_post->votes<$logged_in_user->low_rating_threshold) { echo "\"Filtered"; } - if ($unread) { + if ($unread && !$thread->sticky) { echo "\"Unread"; } + elseif($unread) { + echo "\"Unread"; + } + elseif($thread->sticky) { + echo "\"Sticky\""; + } echo ""; } echo "id, "\">", cleanup_title($thread->title), "
"; @@ -144,7 +149,6 @@ function show_forum($category, $forum, $start, $sort_style, $logged_in_user) { echo ""; } - end_forum_table(); if ($forum->threads > $n) { diff --git a/html/user/forum_edit.php b/html/user/forum_edit.php index 854b554f52..14caf42d83 100644 --- a/html/user/forum_edit.php +++ b/html/user/forum_edit.php @@ -17,7 +17,7 @@ if ($_POST['submit']) { $thread = getThread($post->thread); if (time() > $post->timestamp + MAXIMUM_EDIT_TIME){ - echo "You can no longer edit this post.
Posts can only be edited at most ".(MAXIMUM_EDIT_TIME/60)." minutes after they have been created."; + echo "You can no longer edit this post.
Posts can only be edited at most ".(MAXIMUM_EDIT_TIME/60)." minutes after they have been created."; exit(); } if ($logged_in_user->id != $post->user) { @@ -42,7 +42,7 @@ $thread = getThread($post->thread); $forum = getForum($thread->forum); $category = getCategory($forum->category); if (time() > $post->timestamp + MAXIMUM_EDIT_TIME){ - echo "You can no longer edit this post.
Posts can only be edited at most ".(MAXIMUM_EDIT_TIME/60)." minutes after they have been created."; + echo "You can no longer edit this post.
Posts can only be edited at most ".(MAXIMUM_EDIT_TIME/60)." minutes after they have been created."; exit(); } diff --git a/html/user/forum_moderate_thread_action.php b/html/user/forum_moderate_thread_action.php index 5043520f09..9206230bf2 100644 --- a/html/user/forum_moderate_thread_action.php +++ b/html/user/forum_moderate_thread_action.php @@ -13,10 +13,17 @@ $user = get_logged_in_user(); $user = getForumPreferences($user); if (!post_str('action')) { - echo "You must specify an action..."; - exit(); + if (!get_str('action')){ + echo "You must specify an action..."; + exit(); + } else { + $action = get_str('action'); + } +} else { + $action = post_str('action'); } -$thread = getThread($_GET['thread']); + +$thread = getThread(get_int('thread')); if (!$thread){ // TODO: Standard error page echo "Invalid thread ID.
"; @@ -30,12 +37,18 @@ if (!isSpecialUser($user,0)) { exit(); } -if (post_str('action')=="hide"){ +if ($action=="hide"){ $result=mysql_query("update thread set hidden = ".post_int("category")." where id=".$thread->id); echo mysql_error(); -} elseif ($_POST['action']=="unhide"){ +} elseif ($action=="unhide"){ $result=mysql_query("update thread set hidden = 0 where id=".$thread->id); echo mysql_error(); +} elseif ($action=="sticky"){ + $result=mysql_query("update thread set sticky = 1 where id=".$thread->id); + echo mysql_error(); +} elseif ($action=="desticky"){ + $result=mysql_query("update thread set sticky = 0 where id=".$thread->id); + echo mysql_error(); /*} elseif ($_POST['action']=="move"){ if (getThread($_POST['threadid'])){ $result=mysql_query("update post set thread = ".intval($_POST['threadid'])." where id=".$post->id); diff --git a/html/user/forum_post.php b/html/user/forum_post.php index d8f0211021..7947114e2a 100644 --- a/html/user/forum_post.php +++ b/html/user/forum_post.php @@ -14,7 +14,20 @@ $forum = getForum($forumid); if (!$forum) { error_page("no such forum"); } - +if ($logged_in_user->total_credit<$forum->post_min_total_credit || $logged_in_user->expavg_credit<$forum->post_min_expavg_credit){ + //If user haven't got enough credit (according to forum regulations) + //We do not tell the (ab)user how much this is - no need to make it easy for them to break the system. + error_page( + "In order to create a new thread in ".$forum->title." you must have a certain amount of credit. + This is to prevent and protect against abuse of the system."); +} +if (time()-$logged_in_user->last_post<$forum->post_min_interval){ + //If the user is posting faster than forum regulations allow + //Tell the user to wait a while before creating any more posts + error_page( + "You cannot create any more threads right now. Please wait a while before trying again.
+ This delay has been enforced to protect against abuse of the system."); +} $title = post_str("title", true); $content = post_str("content", true); if ($title && $content) { diff --git a/html/user/forum_rate.php b/html/user/forum_rate.php index 0e9161b1f4..c9bd5b11cd 100644 --- a/html/user/forum_rate.php +++ b/html/user/forum_rate.php @@ -2,6 +2,8 @@ require_once('../inc/forum.inc'); require_once('../inc/util.inc'); +require_once('../inc/credit.inc'); + db_init(); @@ -26,9 +28,24 @@ if (!empty($_GET['post'])) { $user = get_logged_in_user(true); $user = getForumPreferences($user); + + // Temporary: + // Check the user's credit average to see if it is greater than 5, if not, + // treat them as though they have already rated the post. This should keep + // people from creating multiple accounts just to harass forum members. + // TODO: Use the forum table fields rate_min_total_credit and rate_min_expavg_credit + // to determine instead of hardcoded value. + $avg = $user->expavg_credit; + $avg_time = $user->expavg_time; + $now = time(0); + update_average($now, 0, 0, $avg, $avg_time); + + if ($avg<5){ + error_page("To rate a post you must have a certain amount of credit"); + } if (getHasRated($user,$postId)) { - echo "You have already rated this post."; + error_page("You have already rated this post once."); } else { $result = mysql_query("SELECT * FROM post WHERE id = $postId"); if ($result) { diff --git a/html/user/forum_reply.php b/html/user/forum_reply.php index e69c3ebd8e..85075463eb 100644 --- a/html/user/forum_reply.php +++ b/html/user/forum_reply.php @@ -9,6 +9,30 @@ db_init(); $logged_in_user = get_logged_in_user(true); $logged_in_user = getForumPreferences($logged_in_user); +$thread = getThread(get_int('thread')); +$forum = getForum($thread->forum); +$category = getCategory($forum->category); +$helpdesk = $category->is_helpdesk; + +if (!$thread){ + error("No such thread found"); +} +if ($logged_in_user->total_credit<$forum->post_min_total_credit || $logged_in_user->expavg_credit<$forum->post_min_expavg_credit){ + //If user haven't got enough credit (according to forum regulations) + //We do not tell the (ab)user how much this is - no need to make it easy for them to break the system. + error_page( + "In order to reply to a post in ".$forum->title." you must have a certain amount of credit. + This is to prevent and protect against abuse of the system."); +} +if (time()-$logged_in_user->last_post<$forum->post_min_interval){ + //If the user is posting faster than forum regulations allow + //Tell the user to wait a while before creating any more posts + error_page( + "You cannot reply to any more posts right now. Please wait a while before trying again.
+ This delay has been enforced to protect against abuse of the system."); +} + + if (!empty($_GET['thread']) && !empty($_POST['content'])) { $_GET['thread'] = stripslashes($_GET['thread']); @@ -41,10 +65,6 @@ if (!empty($_GET['post'])) { $post = getPost($_GET['post']); } -$thread = getThread($_GET['thread']); -$forum = getForum($thread->forum); -$category = getCategory($forum->category); -$helpdesk = $category->is_helpdesk; // TODO: Write a function for this. diff --git a/html/user/forum_thread.php b/html/user/forum_thread.php index 114cd7a713..11cd1f5570 100644 --- a/html/user/forum_thread.php +++ b/html/user/forum_thread.php @@ -114,7 +114,11 @@ if ($thread->hidden) { } if (isSpecialUser($logged_in_user,0)){ //If logged in users is moderator - echo "
id\">Delete this thread"; + echo "
id\">Delete this thread"; + if($thread->sticky) + { echo "
id\">De-sticky this thread"; } + else + { echo "
id\">Make this thread sticky"; } } echo "";