1
double1
Re: newBB, posts not marked as read for some users
  • 2004/5/29 8:40

  • double1

  • Just popping in

  • Posts: 8

  • Since: 2003/4/26


@ Fredrik: To be more precise on why this is happening, XOOPS uses cookies to mark a topic as read. The official specification for cookies is that they can maximally be 4Kb big. XOOPS serializes the topic when writing to the cookie, this practically means the cookie can on average hold about 100-150 different topcis. Once this amount is reached, no NEW topics can be written to the cookie. From this point the mark read/unread indicator will stop working correctly.

Erratic behaviour, where it updates read/unread status for some topics (the older) but not for others (new topics) is caused because the older topics might still be present in the cookie, making it possible to still change the read/unread flag on them.

Only solution to this problem is to clear your cookies, which will start with a clean sheet. You can also only delete the cookie related to the newbb forum, it's the cookie with name "newbb_topic_lastread".

Now this is a known problem with the current newbb implementation, that's why it's been suggested by other people earlier to use the database instead of cookies for marking topics read/unread.

Hopefully the programmers of the updated newbb will consider this. But I doubt if they will, since it puts more pressure on the database and loading times. Well, we'll see.

Hope this helped.



2
double1
Re: Why can't I read this Xoops Cookie with PHP in a block?
  • 2004/2/1 12:36

  • double1

  • Just popping in

  • Posts: 8

  • Since: 2003/4/26


I've been able to test your suggestion and it works perfect. Thank you sooo much for helping me out there! As a PHP newcomer I would have never figured it out otherwise... Luckily with these kind of steps forward my understanding will be improving

Is there any reason you know of why the XOOPS coders haven't set the $bbCookie path to '/' by default?

Thanks again, you made my weekend



3
double1
Re: Why can't I read this Xoops Cookie with PHP in a block?
  • 2004/1/24 16:07

  • double1

  • Just popping in

  • Posts: 8

  • Since: 2003/4/26


Thanks for your reply, that would certainly be a plausible explanation. If I understand you correctly: you mean that only .php files physically in the modules/newbb dir can access the cookie contents through the HTTP requests?

I've searched through the forum and Onokazu commented somewhere that the $bbCookie['path'], which viewtopic.php uses to write the cookie, is indeed modules/newbb.

I tried to test your assumption by moving the newbb_new.php one dir up, so from:
- modules/newbb/blocks/newbb_new.php
to
- modules/newbb/newbb_new.php

I then modified xoops_version.php to reflect the new location of the php file for the block, updated the forums module, tested if it took new variables from the newbb_new.php in the new location, which it did, and then added the cookie code.

Unfortunately it didn't change the situation, the cookiecontent var still doesn't return any value

On the assumption that I understood you correctly and that my testcase reflects that, we can then conclude that this isn't the cause of the problem?

This is really bugging me, hopefully a solution will pop up for this.

Anyway, thanks again for trying to help out.



Quote:
Dave_L wrote:
The problem may be that that cookie is set with the path modules/newbb, so it will only be visible to HTTP requests that contain that path.

related topic



4
double1
Why can't I read this Xoops Cookie with PHP in a block?
  • 2004/1/24 12:58

  • double1

  • Just popping in

  • Posts: 8

  • Since: 2003/4/26


Hi,

This is slowly driving me nuts, so I hope someone understands this problem.

I'm trying to read the contents of the "newbb_topic_lastread" cookie from the Recent Topics block, but I tried everything and it always return empty, while the cookie *does* exist.

I've added this code to the "newbb_new.php" code (it's in dir newbb/blocks):

$topic_lastread = !empty($HTTP_COOKIE_VARS['newbb_topic_lastread']) ? unserialize($HTTP_COOKIE_VARS['newbb_topic_lastread']) : array();

and

$topic['cookiecontent'] = $topic_lastread[$arr['topic_id']];

so that I can use the topic last read date in the Smarty template (newbb_block_new.html). I have tested other variables in the template and these DO show.

To be sure I defined $HTTP_COOKIE_VARS as Global within the newbb_new.php

The code then looks like this (added lines are in bold typeface):

Quote:
function b_newbb_new_show($options) {
global $HTTP_COOKIE_VARS;

$topic_lastread = !empty($HTTP_COOKIE_VARS['newbb_topic_lastread']) ? unserialize($HTTP_COOKIE_VARS['newbb_topic_lastread']) : array();

$db =& Database::getInstance();
$myts =& MyTextSanitizer::getInstance();
$block = array();
switch($options[2]) {
case 'views':
$order = 't.topic_views';
break;
case 'replies':
$order = 't.topic_replies';
break;
case 'time':
default:
$order = 't.topic_time';
break;
}
$query='SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.topic_time, t.topic_views, t.topic_replies, t.forum_id, f.forum_name FROM '.$db->prefix('bb_topics').' t, '.$db->prefix('bb_forums').' f WHERE f.forum_id=t.forum_id AND f.forum_type <> 1 ORDER BY '.$order.' DESC';
if (!$result = $db->query($query,$options[0],0)) {
return false;
}
if ( $options[1] != 0 ) {
$block['full_view'] = true;
} else {
$block['full_view'] = false;
}
$block['lang_forum'] = _MB_NEWBB_FORUM;
$block['lang_topic'] = _MB_NEWBB_TOPIC;
$block['lang_replies'] = _MB_NEWBB_RPLS;
$block['lang_views'] = _MB_NEWBB_VIEWS;
$block['lang_lastpost'] = _MB_NEWBB_LPOST;
$block['lang_visitforums'] = _MB_NEWBB_VSTFRMS;
while ($arr = $db->fetchArray($result)) {
$topic['forum_id'] = $arr['forum_id'];
$topic['forum_name'] = $myts->makeTboxData4Show($arr['forum_name']);
$topic['id'] = $arr['topic_id'];
$topic['title'] = $myts->makeTboxData4Show($arr['topic_title']);
$topic['replies'] = $arr['topic_replies'];
$topic['views'] = $arr['topic_views'];
$topic['cookiecontent'] = $topic_lastread[$arr['topic_id']];
$topic['post_id'] = $arr['topic_last_post_id'];
$lastpostername = $db->query("SELECT post_id, uid FROM ".$db->prefix("bb_posts")." WHERE post_id = ".$topic['post_id']);
while ($tmpdb=$db->fetchArray($lastpostername)) {
$tmpuser = XoopsUser::getUnameFromId($tmpdb['uid']);
if ( $options[1] != 0 ) {
$topic['time'] = formatTimestamp($arr['topic_time'],'m')." $tmpuser";
}
}
$block['topics'][] =& $topic;
unset($topic);
}
return $block;
}


Next I added "<{$topic.cookiecontent}>" to the Smarty Template of the Recent Topics Block, but whatever I do, the variable always show up empty!
Now I've used this method with other (global) variables in other blocks and it always worked well, but somehow reading the cookiecontent into a var is different from normal global variables as it just doesn't seem to get read!
I've checked if the cookie is available in my browser cache and it is (with a string of numbers as content), it also works when marking topics read in the newbb "viewtopics" module.

I've tried a number of other options (reordering the lines, defining as global, not defining as global, etc etc, but it's all to no avail)

What am I doing wrong??? It's driving me nuts spending hours trying to get this to work

Now I'm very new to PHP so I sincerely hope someone with experience in PHP can point me to the problem.

Thanks for any help,

Ross



5
double1
Re: Autologin - does it update xoopsmembers "last login date"
  • 2003/7/28 18:18

  • double1

  • Just popping in

  • Posts: 8

  • Since: 2003/4/26


Yes the code for the checkbox should be within the form tag, put it right after this:

<input type="hidden" name="xoops_redirect" value="<{$xoops_requesturi}>" />

More importantly, make sure you have set your cookie session to "custom" in your Admin Preferences -> General Settings -> Use custom session = YES, otherwise the hack won't work!

Btw, I tried Jan304's Login hack but for yours it should be the same.

Good luck



6
double1
Re: Autologin - does it update xoopsmembers "last login date"
  • 2003/7/20 22:59

  • double1

  • Just popping in

  • Posts: 8

  • Since: 2003/4/26


Hi Beyond

Thank you VERY VERY much! Your solution is exactly what I was looking for! I've waited a bit before replying, to test the modification over some days, but no problems whatsoever, excellent.

Thanks again, you really made my day. I wish I could by you a beer

Best regards,

Ross



7
double1
Re: Autologin - does it update xoopsmembers "last login date"
  • 2003/7/16 19:13

  • double1

  • Just popping in

  • Posts: 8

  • Since: 2003/4/26


Hi AndreyRa,

What I would like to know is if your autologin also updates the "Last Login Date" that is shown when you list members through the XOOPSMEMBERS module?

I'm currenly using the autologin from Jan's site (http://www.jan304.org ) and while it works great to keep people logged in, it doesn't update the "last Login Date" on the xoopsmembers module

This is really too bad, because now I can't know anymore when users last visited my site

Can you tell me if your hack doesn't suffer from this problem? I'd really like to know before I change to your hack

Thanks and best regards,

Ross




TopTop



Login

Who's Online

256 user(s) are online (178 user(s) are browsing Support Forums)


Members: 0


Guests: 256


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits