Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding "Dot Out" feature on PHP 8.1 #35

Open
MickeyTTT opened this issue Nov 6, 2023 · 11 comments
Open

Adding "Dot Out" feature on PHP 8.1 #35

MickeyTTT opened this issue Nov 6, 2023 · 11 comments

Comments

@MickeyTTT
Copy link

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

@MioVisman
Copy link
Owner

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).

@MickeyTTT
Copy link
Author

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>

@MioVisman
Copy link
Owner

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

@MickeyTTT
Copy link
Author

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

@MioVisman
Copy link
Owner

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)

@MickeyTTT
Copy link
Author

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
Copy link
Author

`<?php

$checkboxes = array();
if ($fid && $is_admmod)
$checkboxes[] = '<input type="checkbox" name="stick_topic" value="1" tabindex="'.($cur_index++).'"'.(isset($_POST['stick_topic']) ? ' checked="checked"' : '').' />'.$lang_common['Stick topic'].'
';
Dot out
if (!$pun_user['is_guest'])
{
if ($pun_config['o_smilies'] == '1')
$checkboxes[] = '<input type="checkbox" name="hide_smilies" value="1" tabindex="'.($cur_index++).'"'.(isset($_POST['hide_smilies']) ? ' checked="checked"' : '').' />'.$lang_post['Hide smilies'].'
';
`

@MioVisman
Copy link
Owner

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>';

@MickeyTTT
Copy link
Author

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

@MioVisman
Copy link
Owner

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

@MickeyTTT
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants