ElkArte Community

Title: Strange behaviour with "who's online"
Post by: Jorin on July 14, 2014, 02:56:12 am
Not sure if it's a bug: "Who's online" says user A is visiting his profile. I klick on the link to his profile, and there it says user A is looking at my profile. Going back to "Who's online": User A ist visiting his profile. Going to his profile it says he's looking at my profile. :o
Title: Re: Strange behaviour with "who's online"
Post by: emanuele on July 14, 2014, 07:04:00 am
Not easy to solve... well, it could be easy to workaround, there is to add a bit to the url in the menu array (and maybe other places), but it would just be a way to "trick" the system a bit more, not to really solve the problem.

The action a user is doing is determined by the last url he visited.
In the case you are describing, User A is visiting the url:
Code: [Select]
http://www.elkarte.net/community/index.php?action=profile
When User B visits User A's profile, Elk finds the URL above in the log and starts trying to understand what the user is doing.
Normally, if Elk finds the bit: "u=123", then it's able to identify that User B is watching the profile of the user with id "123", but in that case, there is no "u" param in the url, so Elk thinks "without the u-bits, the user is watching his own profile".

To fix the problem it would be necessary to check if the current user is the owner of the profile, maybe change in Who.subs.php:
Code: [Select]
				// Whose?  Their own?
if (empty($actions['u']))
$actions['u'] = $url[1];
to
Code: [Select]
				// Whose?  Their own?
if (empty($actions['u']))
{
$memID = currentMemberID();
if ($memID == $user_info['id'])
$actions['u'] = $url[1];
else
$actions['u'] = $memID;
}
could work... maybe, not tested at all.
Title: Re: Strange behaviour with "who's online"
Post by: Spuds on July 14, 2014, 09:50:41 am
I think thats a good idea, tried it and its not quite right though?   Humm maybe it is, now I'm confused who I'm looking at :P  Do need to include profile.subs
Title: Re: Strange behaviour with "who's online"
Post by: emanuele on July 14, 2014, 10:03:07 am
Guessed so... lol
Title: Re: Strange behaviour with "who's online"
Post by: Spuds on July 18, 2014, 10:33:31 am
Did we want to add this in for RC2 ?
Title: Re: Strange behaviour with "who's online"
Post by: emanuele on July 18, 2014, 11:20:22 am
It's a bit of a shot in the dark, but if you trust that code...
Title: Re: Strange behaviour with "who's online"
Post by: Spuds on July 19, 2014, 09:02:19 am
Shot in the dark added ...