UBBCentral
Posted By: M4TT Thread OP not matching IP Address - 02/26/2019 6:34 PM
Hi,

Lately, I've noticed that some posters are appearing as the OP, but are from completely different IP Addresses.

I've also posted on a thread and it showed that I was the OP, but wasn't the original poster...

https://tinyurl.com/yxsln7zx

Matt
Posted By: M4TT Re: Thread OP not matching IP Address - 02/26/2019 7:05 PM
I logged out and it makes me appear as the OP. Could it have something to do with an unregistered post?
Posted By: Ruben Re: Thread OP not matching IP Address - 02/26/2019 8:17 PM
Looks like you may have found a bug.
I just tried reply to last post and reply to topic as a guest.
They both show as op.
Posted By: isaac Re: Thread OP not matching IP Address - 02/26/2019 9:39 PM
OP generation is not based upon IP addresses. It is based upon the topic creator of the current thread. If you've merged threads together from multiple accounts, then there will be multiple OPs, as those accounts had each been the OP of their own thread before you merged them together.
Posted By: M4TT Re: Thread OP not matching IP Address - 02/26/2019 9:58 PM
Originally Posted by isaac
[...]If you've merged threads together from multiple accounts, then there will be multiple OPs, as those accounts had each been the OP of their own thread before you merged them together.


Hmm, hadn't merged any threads... Could this be because I installed a testing Ubb.threads forum using the same database under a different prefix?
Posted By: isaac Re: Thread OP not matching IP Address - 02/26/2019 10:26 PM
Each new topic gets a single line within the ubbt_TOPICS table.

FROM THE SCRIPT:
$opid = $topic_info['USER_ID'];

$topic_info['USER_ID'] is the USER_ID stored in the ubbt_TOPICS table for that TOPIC.

FROM THE TEMPLATE:
{if $postrow[post].userid eq $opid}OP{/if}
$postrow[post].userid is the USER_ID of that single post from the ubbt_POSTS table.


Conclusion, if the USER_ID of that single post matches the USER_ID of the TOPIC, then "OP" is displayed.

Feel free to open up both the script (scripts/showflat.inc.php @ ~ line 205) and the template (templates/default/post_side.tpl @ ~ line 101, and ~ line 127) and read it yourself.
Posted By: Gizmo Re: Thread OP not matching IP Address - 02/26/2019 10:45 PM
Anon users shouldn't have OP indicators, as every uid of a guest user would be uid #1.

You can edit the code from:
Code
{if $postrow[post].userid eq $opid}OP{/if}


To:
Code
{if $postrow[post].userid eq $opid && $postrow[post].userid neq '1'}OP{/if}


In:
Code
[gremelin@vnc ~]# grep -r "opid" /home/public_html/forum/
/home/public_html/forum/templates/default/post_gallery.tpl:{if $postrow[post].userid eq $opid}<span class="lmar post-op">OP</span>{/if}
/home/public_html/forum/templates/default/post_top.tpl:{if $postrow[post].userid eq $opid}<span class="post-op">OP</span>{/if}
/home/public_html/forum/templates/default/post_side.tpl:{if $postrow[post].userid eq $opid}<span class="post-op">OP</span>{/if}
/home/public_html/forum/templates/default/post_side.tpl:{if $postrow[post].userid eq $opid}<span class="post-op fr">OP</span>{/if}]
Posted By: isaac Re: Thread OP not matching IP Address - 02/26/2019 10:45 PM
Gizmo pointed out in IM, that all of your commenters are from users of the Anonymous account.

Within UBB.threads, Anonymous USER ID is always user 1 within the database.

Maybe the code should be updated to include, {if $postrow[post].userid ne '1'}OP{/if}
Posted By: isaac Re: Thread OP not matching IP Address - 02/26/2019 11:00 PM
Thanks Giz for the pointer. And thanks M4TT for drawing attention to this.

The OP logic has been updated to prevent posts from anonymous users from being tagged with OP indicators.
Posted By: M4TT Re: Thread OP not matching IP Address - 02/26/2019 11:20 PM
Excellent, thanks everyone! By change future unregistered/anonymous posts can utilize the OP feature via IP address?
Posted By: Gizmo Re: Thread OP not matching IP Address - 02/26/2019 11:22 PM
No, the feature is unavailable to anonymous users as it utilizes the UserID vs IP Address (as IP addresses are generally non-static).
Posted By: M4TT Re: Thread OP not matching IP Address - 02/27/2019 2:18 AM
Hey Gizmo,

I replaced the code in each file, it worked! However, the style for OP is missing.
Posted By: isaac Re: Thread OP not matching IP Address - 02/27/2019 3:58 AM
Originally Posted by M4TT
Hey Gizmo,

I replaced the code in each file, it worked! However, the style for OP is missing.

Not Gizmo, but I'm here now, and can reply for him smile

In the first section of his post, he gave examples of what Smarty code needs to be changed. Not direct replacements for stock code. He was using my simple examples as the base of his demonstration, rather than using actual stock code. This was intentional, as to demonstrate and focus on the root cause of the issue.


Modify the Smarty clauses, and keep the spans within the list as shown in the grep code window Gizmo posted.

IN THESE THREE STOCK TEMPLATE FILES -
templates/default/post_gallery.tpl (1x)
templates/default/post_top.tpl (1x)
templates/default/post_side.tpl (2x)

FIND -
{if $postrow[post].userid eq $opid}

REPLACE WITH -
{if $postrow[post].userid eq $opid && $postrow[post].userid neq '1'}
© 2019 UBB.threads PHP Forum Software Community