FluxBB_by_Visman icon indicating copy to clipboard operation
FluxBB_by_Visman copied to clipboard

Adding "Dot Out" feature on PHP 8.1

Open MickeyTTT opened this issue 1 year ago • 11 comments

Hi Visman, I had a board that was pre 8.1 PHP my host upgraded and broke my board. So I had to start over again with the new board.

The old board had a feature called Dot out, that would let a registered member post anonymously without logging out.

I was hoping you could give me some guidance on making this work on my new board.

Below is what it looked like.

https://www.f4bbs.com/1.PNG

https://www.f4bbs.com/2.PNG

https://www.f4bbs.com/3.PNG

MickeyTTT avatar Nov 06 '23 01:11 MickeyTTT

Hi! You need to look at the code of the post.php file (most likely) on an old version of the engine. There you added a handler for this checkbox, which replaced the user with a guest (if I understood you correctly).

MioVisman avatar Nov 06 '23 02:11 MioVisman

Does this look like it? </div> <div id="brdmenu" class="inbox"> <input type="checkbox" id="brdmenu-checkbox" style="display: none;" /> <label for="brdmenu-checkbox" id="brdmenu-button"></label> <ul>

MickeyTTT avatar Nov 06 '23 17:11 MickeyTTT

Look for the substring 'dotout', something similar to $_POST['dotout']

MioVisman avatar Nov 06 '23 17:11 MioVisman

if (isset($_POST['dotout'])) { $pun_user['g_id']=4;$pun_user['username']="."; $pun_user['id'] =1;$pun_user['g_id'] =3; } I am using version 1.5.11 does this look like it would work with https://www.f4bbs.com/2.PNG

Or is something else missing? I assume the order that the user name and group change is to, prevent errors?

Thanks

MickeyTTT avatar Nov 09 '23 05:11 MickeyTTT

Probably you need to use a different approach, rather than correcting the user as a guest. Something like this:

  1. For replies in the topic:
	if (!$pun_user['is_guest'])
	{
		$username = $pun_user['username'];
		$email = $pun_user['email'];
	}

replace to

	if (!$pun_user['is_guest'])
	{
		$username = isset($_POST['dotout']) ? '.' : $pun_user['username'];
		$email = $pun_user['email'];
	}
// START Merge Post
		if (isset($pun_config['o_merge_timeout']) && !$pun_user['is_guest'] && !$fid && (($is_admmod && !empty($_POST['merge'])) || !$is_admmod) && $cur_posting['poster_id']!=NULL && $cur_posting['message']!=NULL && ($now - $cur_posting['posted'])<$pun_config['o_merge_timeout'] && (pun_strlen($cur_posting['message'].$message) + 100 < PUN_MAX_POSTSIZE))

repalace to

// START Merge Post
		if (!isset($_POST['dotout']) && isset($pun_config['o_merge_timeout']) && !$pun_user['is_guest'] && !$fid && (($is_admmod && !empty($_POST['merge'])) || !$is_admmod) && $cur_posting['poster_id']!=NULL && $cur_posting['message']!=NULL && ($now - $cur_posting['posted'])<$pun_config['o_merge_timeout'] && (pun_strlen($cur_posting['message'].$message) + 100 < PUN_MAX_POSTSIZE))
				// Insert the new post
					$db->query('INSERT INTO '.$db->prefix.'posts (poster, poster_id, poster_ip, message, hide_smilies, posted, topic_id, user_agent) VALUES (\''.$db->escape($username).'\', '.$pun_user['id'].', \''.$db->escape(get_remote_address()).'\', \''.$db->escape($message).'\', '.$hide_smilies.', '.$now.', '.$tid.', \''.$db->escape($http_uagent).'\')') or error('Unable to create post', __FILE__, __LINE__, $db->error());

replace to

				// Insert the new post
					$db->query('INSERT INTO '.$db->prefix.'posts (poster, poster_id, poster_ip, message, hide_smilies, posted, topic_id, user_agent) VALUES (\''.$db->escape($username).'\', '.(isset($_POST['dotout']) ? '1' : $pun_user['id']).', \''.$db->escape(get_remote_address()).'\', \''.$db->escape($message).'\', '.$hide_smilies.', '.$now.', '.$tid.', \''.$db->escape($http_uagent).'\')') or error('Unable to create post', __FILE__, __LINE__, $db->error());

  1. For new topic:
				// Create the post ("topic post")
				$db->query('INSERT INTO '.$db->prefix.'posts (poster, poster_id, poster_ip, message, hide_smilies, posted, topic_id, user_agent) VALUES (\''.$db->escape($username).'\', '.$pun_user['id'].', \''.$db->escape(get_remote_address()).'\', \''.$db->escape($message).'\', '.$hide_smilies.', '.$now.', '.$new_tid.', \''.$db->escape($http_uagent).'\')') or error('Unable to create post', __FILE__, __LINE__, $db->error());

replace to

				// Create the post ("topic post")
				$db->query('INSERT INTO '.$db->prefix.'posts (poster, poster_id, poster_ip, message, hide_smilies, posted, topic_id, user_agent) VALUES (\''.$db->escape($username).'\', '.(isset($_POST['dotout']) ? '1' : $pun_user['id']).', \''.$db->escape(get_remote_address()).'\', \''.$db->escape($message).'\', '.$hide_smilies.', '.$now.', '.$new_tid.', \''.$db->escape($http_uagent).'\')') or error('Unable to create post', __FILE__, __LINE__, $db->error());

  1. Common
			// START Merge post
			// not sum - Visman
			if (!$merged && $cur_posting['no_sum_mess'] == 0)

replace to

			// START Merge post
			// not sum - Visman
			if (!isset($_POST['dotout']) && !$merged && $cur_posting['no_sum_mess'] == 0)

MioVisman avatar Nov 09 '23 07:11 MioVisman

Thank you for all of your help. I made all of the changes. but when I try and add <label><input type="checkbox" name="dotout" value="dotout">Dot out</label> To post I keep getting syntax errors. I'm trying to put it after. $checkboxes[] = '<label><input type="checkbox" name="subscribe" value="1" tabindex="'.($cur_index++).'"'.($subscr_checked ? ' checked="checked"' : '').' />'.($is_subscribed ? $lang_post['Stay subscribed'] : $lang_post['Subscribe']).'<br /></label>';

MickeyTTT avatar Nov 09 '23 23:11 MickeyTTT

`<?php

$checkboxes = array(); if ($fid && $is_admmod) $checkboxes[] = ''; if (!$pun_user['is_guest']) { if ($pun_config['o_smilies'] == '1') $checkboxes[] = ''; `

MickeyTTT avatar Nov 10 '23 00:11 MickeyTTT

after

	if ($is_admmod && $fid) // StickFP - Visman
		$checkboxes[] = '<label><input type="checkbox" name="stickfp" value="1" tabindex="'.($cur_index++).'"'.((isset($_POST['stickfp'])) ? ' checked="checked"' : '').' />'.$lang_post['Stick first post'].'<br /></label>';

add

	$checkboxes[] = '<label><input type="checkbox" name="dotout" value="1" tabindex="'.($cur_index++).'"'.((isset($_POST['dotout'])) ? ' checked="checked"' : '').' />Dot out<br /></label>';

MioVisman avatar Nov 10 '23 02:11 MioVisman

Sorry, I cant figure out what I am doing wrong.

` }

if ($is_admmod && !$fid && isset($pun_config['o_merge_timeout']) && $pun_config['o_merge_timeout'] > 0) // Merge mod - Visman
	$checkboxes[] = '<label><input type="checkbox" name="merge" value="1" tabindex="'.($cur_index++).'"'.((isset($_POST['merge']) || (!isset($_POST['merge']) && !isset($_POST['form_sent']))) ? ' checked="checked"' : '').' />'.$lang_post['Merge posts'].'<br /></label>';
if ($is_admmod && $fid) // StickFP - Visman
	$checkboxes[] = '<label><input type="checkbox" name="stickfp" value="1" tabindex="'.($cur_index++).'"'.((isset($_POST['stickfp'])) ? ' checked="checked"' : '').' />'.$lang_post['Stick first post'].'<br /></label>';
            $checkboxes[] = '<label><input type="checkbox" name="dotout" value="1" tabindex="'.($cur_index++).'"'.((isset($_POST['dotout'])) ? ' checked="checked"' : '').' />Dot out<br /></label>';

}

                         Parse error: syntax error, unexpected token "<", expecting end of file in /home/public/F4BBS/post.php on line 730 `

Thanks

MickeyTTT avatar Nov 10 '23 06:11 MickeyTTT

No error in line

	$checkboxes[] = '<label><input type="checkbox" name="dotout" value="1" tabindex="'.($cur_index++).'"'.((isset($_POST['dotout'])) ? ' checked="checked"' : '').' />Dot out<br /></label>';

donout

MioVisman avatar Nov 10 '23 06:11 MioVisman

Thank you very much for all your help. We have everything working now. It would have been impossible without you. F4 thanks you for this feature.

MickeyTTT avatar Nov 11 '23 17:11 MickeyTTT