Topic: Improved New Message 1.0

##
##
##        Mod title:  Improved New Message (INM)
##
##      Mod version:  1.0
##   Works on PunBB:  1.0.x
##     Release date:  2004-05-18
##           Author:  Kristoffer Jansson (jansson@cactuz.nu)
##
##      Description:  This mod extends the new messege function. It will now update when you read the topic.
## 
##   Affected files:  include/functions.php
##                    index.php
##                    viewforum.php
##                    viewtopic.php
##
##       Affects DB:  No
##
##            Notes:  My solution to the problem :)
##
##        Generator:  ModGenerator (http://punres.cactuz.nu/modgen/)
##                    on: 2004-05-18 20:46:56
##
##       DISCLAIMER:  Please note that "mods" are not officially supported by
##                    PunBB. Installation of this modification is done at your
##                    own risk. Backup your forum database and any and all
##                    applicable files before proceeding.
##
##

PunRes: http://punres.cactuz.nu/projects/desc.php?id=33

Re: Improved New Message 1.0

Hmm, you're setting one cookie for every read topic?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Improved New Message 1.0

Yeah.. It doesn't require any serialize or anything :P

Re: Improved New Message 1.0

Ouch :)

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Improved New Message 1.0

Jansson wrote:

Yeah.. It doesn't require any serialize or anything :P

I told you to not make a weird solution :P

Re: Improved New Message 1.0

Exactly why is it weird? =P

Re: Improved New Message 1.0

After reading the forums for a while, there will be quite a lot of cookie data being transferred to the webserver.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Improved New Message 1.0

Well. They are removed when the last update is updated (default 600sec). And if there is so many new topics (only stores cookie if topic contains new posts) you shouldn't be able to read so many topics in that time. And the data that will be transferred is smaller because you only have to check the latest post-cookie. And not many people have like 200 forums ;)

Re: Improved New Message 1.0

Jansson wrote:

And the data that will be transferred is smaller because you only have to check the latest post-cookie.

Not sure what you mean by that. The browser always sends every cookie that applies to the site you've visiting. What you do with it in your PHP code doesn't matter.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Improved New Message 1.0

Rickard wrote:
Jansson wrote:

And the data that will be transferred is smaller because you only have to check the latest post-cookie.

Not sure what you mean by that. The browser always sends every cookie that applies to the site you've visiting. What you do with it in your PHP code doesn't matter.

Ok. But that doesn't really matters anyway.

11

Re: Improved New Message 1.0

hi all, where can i get this mod now ?

12

Re: Improved New Message 1.0

It is good for who care about (New Message) smile
I dont care, i use my memory.

If your people come crazy, you will not need to your mind any more.

Re: Improved New Message 1.0

well, start at the top and work your way through wink

14

Re: Improved New Message 1.0

hm. so no definite answer ?

15

Re: Improved New Message 1.0

it isnt working for me sad

Re: Improved New Message 1.0

hmmm ... a thought just struck me ... IIRC I read somewhere that there was a limit on the 'cookie array' you can have. What I don't remember is if it was an IE, Apache or PHP limit tongue
OTOH it's perhaps big enough for people never experiencing it? wink

Re: Improved New Message 1.0

According to my Google search, it's 300 total or 20 per server or domain (that's supposed to be the minimum)

http://wp.netscape.com/newsref/std/cookie_spec.html

18 (edited by XuMiX 2004-11-05 20:15)

Re: Improved New Message 1.0

viewtopic.php
-----8<------
~110 line
if (!$cookie['is_guest'])
$result = $db->query('SELECT t.subject, t.closed, t.sticky, t.num_replies, t.last_post_id, t.last_post, f.id, f.forum_name, f.moderators, f.closed AS forum_closed, f.admmod_only, s.user_id AS is_subscribed FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON t.forum_id=f.id LEFT JOIN '.$db->prefix.'subscriptions AS s ON (s.topic_id=t.id AND s.user_id='.$cur_user['id'].') WHERE t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
else
$result = $db->query('SELECT t.subject, t.closed, t.sticky, t.num_replies, t.last_post_id, t.last_post, f.id, f.forum_name, f.moderators, f.closed AS forum_closed, f.admmod_only, 0 FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON t.forum_id=f.id WHERE t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());

~118 line
list($subject, $closed, $sticky, $num_replies, $last_post_id, $last_post, $forum_id, $forum_name, $moderators, $forum_closed, $admmod_only, $is_subscribed) = $db->fetch_row($result);

+++  before $footer_style =.... add
// Create/Update topic view session
if($cur_user['last_visit'] < $last_post)
setcookie('puntopic_'.$last_post_id, time(), (time()+$pun_config['o_timeout_visit']), $cookie_path, $cookie_domain, $cookie_secure);
------------->8--------

viewforum.php
~165? line
---if (!$cookie['is_guest'] && $cur_topic['last_post'] > $cur_user['last_visit'] && $cur_topic['moved_to'] == null)
+++if (!$cookie['is_guest'] && new_topic($cur_topic['last_post_id'], $cur_topic['last_post']) && $cur_topic['moved_to'] == null)

index.php
~88? line
---if (!$cookie['is_guest'] && $cur_forum['last_post'] > $cur_user['last_visit'])
+++if (!$cookie['is_guest'] && new_topic($cur_forum['last_post_id'], $cur_forum['last_post']))


include/functions.php
+++
function new_topic($id, $last_post)
{
    global $cur_user;

    if(isset($_COOKIE['puntopic_'.$id]))
    {
        if($_COOKIE['puntopic_'.$id] < $last_post)
            return true;
    }else
    {
        if($cur_user['last_visit'] < $last_post)
            return true;
    }
    return false;
}