You are not logged in.

#1 2017-12-13 17:26:53

garry
Administrator
Registered: 2017-07-29
Posts: 126

FluxBB mod, that moves reported posts off the board

As the subject explains, this is a modified misc.php , it has been modified so that when a member reports a post that they think is spam,
the post is moved off the board. I have modified the misc.php, using some code written by : "Zero-Tolerance",
The mod is relatively simple, I am still waiting for the approved version, so am not posting any code just yet,... but any way, this will
be the place/topic.
===== important disclaimer=====
Both of these mods are entirely experimental,  I have tried them, and they seem ok, how ever they are needing more testing and
review, it would be best to try them on a off line, local host board rather the a on line production forum. In any event only those that  are experienced with standard precaution procedures, like making copies of your original working files first, etc.
You should be some what familiar with fluxBB, and php code, before trying them. We, both the author and myself are not responsible
for any problems that might occur. We are available though, as well as other, if any one does have problems or questions, and comments.
And will try to help solve any issues, if need be. In a nut shell "Use at you own risk". We do welcome, and hope a few others will help with testing these, and can use them, so that is the purpose of these topics,and sharing the code here.
====================== End disclaimer ======================================

Offline

#2 2017-12-13 20:49:32

garry
Administrator
Registered: 2017-07-29
Posts: 126

Re: FluxBB mod, that moves reported posts off the board

Ok, here is the code, and the instructions, the file that is modified is misc.php

It needs to be inserted before the
redirect('viewforum.php
line, which I think is line 265 in misc.php.
The code I modified is v1.5.10, which I think is the version you
mentioned you are running on SFS.
You might want to add some warning text in the form you posted, perhaps
just before the <input type="submit"
line.

	// ---- additions to move SPAM posts to SPAM BOX forum -- version 4
	// define('PUN_DEBUG', 1); // handy when you're trying to get things to work

		$result = $db->query('SELECT id FROM '.$db->prefix.'forums AS f WHERE forum_name =\'Spam Box\'') or error('Unable to find forum', __FILE__, __LINE__, $db->error());
		$forum_data = $db->fetch_assoc($result);

		$move_to_forum = $forum_data['id'];
		if (!isset($move_to_forum))
			$move_to_forum = 0;
			
		$posts = $post_id;
		$fid = $forum_id;
		$tid = $topic_id;
		$num_posts_splitted = 1;

		// Get earliest posted time from the posts of poster. If any are more than a day old, then we don't automatically move the post (to limit abuse)

		// find poster
		$result = $db->query('SELECT p.poster_id FROM '.$db->prefix.'posts AS p WHERE id ='.$post_id) or error('Unable to get poster', __FILE__, __LINE__, $db->error());
		$poster_data = $db->fetch_assoc($result);
		$poster_id = $poster_data['poster_id'];

		// find poster's oldest post that is not already in the spam box
		$result = $db->query('SELECT MIN(p.posted) AS posted FROM '.$db->prefix.'posts AS p LEFT JOIN '.$db->prefix.'topics AS t ON t.id = p.topic_id WHERE t.forum_id <> '.$move_to_forum.' AND poster_id ='.$poster_id) or error('Unable to get posters posts', __FILE__, __LINE__, $db->error());
		$post_data = $db->fetch_assoc($result);

		if ($move_to_forum && $post_data['posted'] > time() - 24 * 60 * 60) // make sure we have a suitably named staff forum, and the first post by the poster is not too old
		{
			
			$result = $db->query('SELECT subject, num_replies FROM '.$db->prefix.'topics WHERE id='.$tid) or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
			$topic_data = $db->fetch_assoc($result);
			
			if ($topic_data['num_replies'] > 0)
			{
				$new_subject = $topic_data['subject'];

				// ---- This part is copied from moderate.php
				
				// Get data from the new first post
				$result = $db->query('SELECT p.id, p.poster, p.posted FROM '.$db->prefix.'posts AS p WHERE id IN('.$posts.') ORDER BY p.id ASC LIMIT 1') or error('Unable to get first post', __FILE__, __LINE__, $db->error());
				$first_post_data = $db->fetch_assoc($result);

				// Create the new topic
				$db->query('INSERT INTO '.$db->prefix.'topics (poster, subject, posted, first_post_id, forum_id) VALUES (\''.$db->escape($first_post_data['poster']).'\', \''.$db->escape($new_subject).'\', '.$first_post_data['posted'].', '.$first_post_data['id'].', '.$move_to_forum.')') or error('Unable to create new topic', __FILE__, __LINE__, $db->error());
				$new_tid = $db->insert_id();

				// Move the posts to the new topic
				$db->query('UPDATE '.$db->prefix.'posts SET topic_id='.$new_tid.' WHERE id IN('.$posts.')') or error('Unable to move posts into new topic', __FILE__, __LINE__, $db->error());

				// DONT Apply every subscription to both topics
				//	$db->query('INSERT INTO '.$db->prefix.'topic_subscriptions (user_id, topic_id) SELECT user_id, '.$new_tid.' FROM '.$db->prefix.'topic_subscriptions WHERE topic_id='.$tid) or error('Unable to copy existing subscriptions', __FILE__, __LINE__, $db->error());

				// Get last_post, last_post_id, and last_poster from the topic and update it
				$result = $db->query('SELECT id, poster, posted FROM '.$db->prefix.'posts WHERE topic_id='.$tid.' ORDER BY id DESC LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
				$last_post_data = $db->fetch_assoc($result);
				$db->query('UPDATE '.$db->prefix.'topics SET last_post='.$last_post_data['posted'].', last_post_id='.$last_post_data['id'].', last_poster=\''.$db->escape($last_post_data['poster']).'\', num_replies=num_replies-'.$num_posts_splitted.' WHERE id='.$tid) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
			
				// Get last_post, last_post_id, and last_poster from the new topic and update it
				$result = $db->query('SELECT id, poster, posted FROM '.$db->prefix.'posts WHERE topic_id='.$new_tid.' ORDER BY id DESC LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
				$last_post_data = $db->fetch_assoc($result);
				$db->query('UPDATE '.$db->prefix.'topics SET last_post='.$last_post_data['posted'].', last_post_id='.$last_post_data['id'].', last_poster=\''.$db->escape($last_post_data['poster']).'\', num_replies='.($num_posts_splitted-1).' WHERE id='.$new_tid) or error('Unable to update topic2', __FILE__, __LINE__, $db->error());

				update_forum($fid);
				update_forum($move_to_forum);

				// ----
			}
			else
			{
				$db->query('UPDATE '.$db->prefix.'topics SET forum_id='.$move_to_forum.' WHERE id='.$tid) or error('Unable to update topic', __FILE__, __LINE__, $db->error());

				update_forum($fid);
				update_forum($move_to_forum);
			}
		}
		
	// ----

There is a discussion, at SFS, if you are all ready registered there:
https://www.stopforumspam.com/forum/pro … p?id=38507
This is viewable only if you are a registered member at SFS,

Offline

Board footer

Powered by FluxBB