MyBB Community Forums

Full Version: Help with making anonymous posting plugin better
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello, i found an anonymous posting plugin 

https://github.com/ICFinanceSoc/MyBB-Post-Anonymoose

but i would like to add more features to it

with the current plugin after you posted anonymously you can still use the reply/multi-quote button to find out who posted 

[Image: oL5B1Gs.png]

http://test.blackmarke7.org/showthread.php?tid=1

also when you do a search you can see user's anonymously posted post

[Image: jWLCHib.png?1]

http://test.blackmarke7.org/search.php?a...user&uid=1

and finally when you posted anonymously and if its the last post it'll show who posted 

[Image: a8I7C2T.png]

http://test.blackmarke7.org/index.php

thx for your help!
You will need to hijack the quote, search, and cache system. Have you found specific troubles doing so?
(2018-12-06, 03:25 AM)Omar G. Wrote: [ -> ]You will need to hijack the quote, search, and cache system. Have you found specific troubles doing so?

Its more like I don't know where to start...
Oh, you will need to update the plugin code so that it hooks into the code that runs these features, such code should be around the followings:
https://github.com/mybb/mybb/blob/featur...g.php#L209 (quoting)
https://github.com/mybb/mybb/blob/featur...e.php#L848 (for last post forum link you might need to hijack this object instead, as I can remember if there is a "better" way)
https://github.com/mybb/mybb/blob/featur....php#L1240 (for searches, please note that the same hook is ran multiple times)

And that would be just the cases you mentioned, they may be far more, worse if you use a quite a number of plugins.

Feel free to check the documentation so you can get a pick if how the system works:
https://docs.mybb.com/1.8/development/plugins/

Hope that is useful.
(2018-12-06, 06:31 AM)Omar G. Wrote: [ -> ]Oh, you will need to update the plugin code so that it hooks into the code that runs these features, such code should be around the followings:
https://github.com/mybb/mybb/blob/featur...g.php#L209 (quoting)
https://github.com/mybb/mybb/blob/featur...e.php#L848 (for last post forum link you might need to hijack this object instead, as I can remember if there is a "better" way)
https://github.com/mybb/mybb/blob/featur....php#L1240 (for searches, please note that the same hook is ran multiple times)

And that would be just the cases you mentioned, they may be far more, worse if you use a quite a number of plugins.

Feel free to check the documentation so you can get a pick if how the system works:
https://docs.mybb.com/1.8/development/plugins/

Hope that is useful.

thx for the reply 
i'll do some research and report back when i have more
(2018-12-06, 06:31 AM)Omar G. Wrote: [ -> ]Oh, you will need to update the plugin code so that it hooks into the code that runs these features, such code should be around the followings:
https://github.com/mybb/mybb/blob/featur...g.php#L209 (quoting)
https://github.com/mybb/mybb/blob/featur...e.php#L848 (for last post forum link you might need to hijack this object instead, as I can remember if there is a "better" way)
https://github.com/mybb/mybb/blob/featur....php#L1240 (for searches, please note that the same hook is ran multiple times)

And that would be just the cases you mentioned, they may be far more, worse if you use a quite a number of plugins.

Feel free to check the documentation so you can get a pick if how the system works:
https://docs.mybb.com/1.8/development/plugins/

Hope that is useful.

hi Omar I've fix the quoting part by using your unquote first post plugin
i've successfully hooked the search

but i'm not sure how to accomplish the following part could you help me

(2018-12-06, 06:31 AM)Omar G. Wrote: [ -> ]https://github.com/mybb/mybb/blob/featur...e.php#L848 (for last post forum link you might need to hijack this object instead, as I can remember if there is a "better" way)
You want to hide or anonymize all last post links or specific links?
(2020-05-23, 02:18 AM)Omar G. Wrote: [ -> ]You want to hide or anonymize all last post links or specific links?

hi Omar just change the username to Anonymoose if the thread is posted as Anonymoose

also i notice in thread review it shows the username of the user that posted annonymously as well

so i try to hook newreply_threadreview_post with the following

$plugins->add_hook("newreply_threadreview_post", "thread_review");
function thread_review()
{
	global $mybb, $db, $templates;
	require_once "./global.php";
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;

	$tid = $mybb->get_input('tid', MyBB::INPUT_INT);
$thread = get_thread($tid);
$fid = (int)$thread['fid'];

// Get forum info
$forum = get_forum($fid);
	
		if(!$mybb->settings['postsperpage'] || (int)$mybb->settings['postsperpage'] < 1)
		{
			$mybb->settings['postsperpage'] = 20;
		}

		if(is_moderator($fid, "canviewunapprove") || $mybb->settings['showownunapproved'])
		{
			$visibility = "(visible='1' OR visible='0')";
		}
		else
		{
			$visibility = "visible='1'";
		}
		$query = $db->simple_select("posts", "COUNT(pid) AS post_count", "tid='{$tid}' AND {$visibility}");

		$numposts = $db->fetch_field($query, "post_count");

		if(!$mybb->settings['postsperpage'] || (int)$mybb->settings['postsperpage'] < 1)
		{
			$mybb->settings['postsperpage'] = 20;
		}

		if($numposts > $mybb->settings['postsperpage'])
		{
			$numposts = $mybb->settings['postsperpage'];
			$lang->thread_review_more = $lang->sprintf($lang->thread_review_more, $mybb->settings['postsperpage'], get_thread_link($tid));
			eval("\$reviewmore = \"".$templates->get("newreply_threadreview_more")."\";");
		}

		$query = $db->simple_select("posts", "pid", "tid='{$tid}' AND {$visibility}", array("order_by" => "dateline", "order_dir" => "desc", "limit" => $mybb->settings['postsperpage']));

		while($post = $db->fetch_array($query))
		{
			$pidin[] = $post['pid'];
		}

		$pidin = implode(",", $pidin);

		// Fetch attachments
		$query = $db->simple_select("attachments", "*", "pid IN ($pidin)");

		while($attachment = $db->fetch_array($query))
		{
			$attachcache[$attachment['pid']][$attachment['aid']] = $attachment;
		}
		
		$query = $db->query("
			SELECT p.*, u.username AS userusername
			FROM ".TABLE_PREFIX."posts p
			LEFT JOIN ".TABLE_PREFIX."users u ON (p.uid=u.uid)
			WHERE pid IN ($pidin)
			ORDER BY dateline DESC
		");

		$postsdone = 0;
		$altbg = "trow1";
		$reviewbits = '';
		while($post = $db->fetch_array($query))
		{

			if($post['userusername'])
			{
				$post['username'] = $post['userusername'];
			}

			$reviewpostdate = my_date('relative', $post['dateline']);

			$parser_options = array(
				"allow_html" => $forum['allowhtml'],
				"allow_mycode" => $forum['allowmycode'],
				"allow_smilies" => $forum['allowsmilies'],
				"allow_imgcode" => $forum['allowimgcode'],
				"allow_videocode" => $forum['allowvideocode'],
				"me_username" => $post['username'],
				"filter_badwords" => 1
			);

			if($post['smilieoff'] == 1)
			{
				$parser_options['allow_smilies'] = 0;
			}

			if($mybb->user['showimages'] != 1 && $mybb->user['uid'] != 0 || $mybb->settings['guestimages'] != 1 && $mybb->user['uid'] == 0)
			{
				$parser_options['allow_imgcode'] = 0;
			}

			if($mybb->user['showvideos'] != 1 && $mybb->user['uid'] != 0 || $mybb->settings['guestvideos'] != 1 && $mybb->user['uid'] == 0)
			{
				$parser_options['allow_videocode'] = 0;
			}

			$post['username'] = htmlspecialchars_uni($post['username']);

			if($post['visible'] != 1)
			{
				$altbg = "trow_shaded";
			}
			


/*//////////////////////////////////////////////////////////// change username to Anonymoose ///////////////////////////////////////////////*/
			if($post['optanon_posted'])
			{
				$post['username'] = 'Anonymoose';
			}
/*//////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////*/
			$post['message'] = $parser->parse_message($post['message'], $parser_options);
			get_post_attachments($post['pid'], $post);
			$reviewmessage = $post['message'];

			eval("\$reviewbits .= \"".$templates->get("newreply_threadreview_post")."\";");
			if($altbg == "trow1")
			{
				$altbg = "trow2";
			}
			else
			{
				$altbg = "trow1";
			}
		}
eval("\$threadreview = \"".$templates->get("newreply_threadreview")."\";");
}


but still shows the username not Anonymoose

[Image: b42hj5T.png]
(2020-05-23, 03:01 AM)8guawong Wrote: [ -> ]hi Omar just change the username to Anonymoose if the thread is posted as Anonymoose

But how do you know if a post was posted as "anonymoose"? Is that a post field? You basically just need to hook to build_forumbits_forum and create your own last post variable replacing the core one (I thought you could hijack the cache but apparently not all last post data is got from the cache).

Quote:also i notice in thread review it shows the username of the user that posted annonymously as well

$plugins->add_hook("newreply_threadreview_post", "thread_review");
function thread_review()
{
global $post, $lang;

$post['username'] = htmlspecialchars_uni($lang->whatever);
}
(2020-05-23, 03:51 AM)Omar G. Wrote: [ -> ]But how do you know if a post was posted as "anonymoose"? Is that a post field? You basically just need to hook to build_forumbits_forum and create your own last post variable replacing the core one (I thought you could hijack the cache but apparently not all last post data is got from the cache).

ok i'll try some more

(2020-05-23, 03:51 AM)Omar G. Wrote: [ -> ]
$plugins->add_hook("newreply_threadreview_post", "thread_review");
function thread_review()
{
global $post, $lang;

$post['username'] = htmlspecialchars_uni($lang->whatever);
}

thx Big Grin

Thanks Omar for your help!
I think I've got the forumbit part

here is the post

could you check to see if you can find out who posted it?  Blush


Nvm I found some stuff that needs to be fixed
Pages: 1 2