Private Message Notification on First Page Charles Capps 01 04 07 19 34 This UBB modification is in BETA STAGES. It is NOT meant to be used in production environments, etc, etc, yadda yadda yadda. This hack is meant for 6.03, but should work with minimal (if any) changes in previous versions. This is a very "quick and dirty" hack. It does what it needs to without any fluff. It might not work as most user expect it to, however. Instead of going through the overhead of loading up the user's entire PM inbox, it only checks the indexed times of the PMs. If there are new PMs since the last time the user logged in to the board, even if the user has read the PMs, it will count them as new. This is probably the best way to do it. This is not a difficult hack to add to your board. If you encounter errors installing this hack, you seriously need to reconsider what you're doing. The instructions are very straightforward. If you have problems understanding the simple fact that line numbers may vary, I suggest you move on. This hack does not CURRENTLY take advantage of wordlets. It will in the future, as soon as I can figure out how to parse a wordlet for a number. I can and will not help you install this hack. Do not post asking me to help. I will not. I simply lack the time. :( Don't try and install a variation of this hack for ANY OTHER PAGES, it WILL NOT work due to the funky way that the cache is built there. You have been warned. You are expressly prohibited from redistributing this hack, or a modification based on this hack, or any part contained within it, without my expressly written consent. If you lack an understanding of any of the words in the preceding sentence, stop reading this hack now and go play with your tinker toys. Files required: /cgi-bin/ubb_lib.cgi /cgi-bin/ubb_forum_summary.cgi /noncgi/Templates/public_forum_summary.pl 1) Open ubb_lib.cgi. Scroll to the bottom. Between the last } and the #do not remove line, insert the following code: --------------------BEGIN sub ParseThisHTML { my($searchstring,$replacestring) = @_; quotemeta($searchstring); $ThisHTML =~ s/$searchstring/$replacestring/gim; } sub CheckPMs { #we know this is being called only if the user cookie is set my $counter; my $usernumber = $ubber[4]; if(-e "$vars_config{MembersPath}/pm_users/$usernumber.cgi") { require "$vars_config{MembersPath}/pm_users/$usernumber.cgi"; } else { return ""; } if($last_login_j) { foreach(keys(%pm_user_index)) { $counter++ if($pm_user_index{$_} >= $last_login_j); } #endforeach } #endif #use Data::Dumper; #my $dumped = Dumper(\%pm_user_index); if($counter) { return "
You have $counter new PMs since your last visit.";# (
\n$dumped\n\n$last_login_j\n
)."; } else { return "
You have no new PMs since your last visit."; # (
\n$dumped\n\n$last_login_j\n
)."; } } --------------------END 2) Save and close ubb_lib.cgi 3) Open ubb_forum_summary.cgi. There are TWO instances of code similar to this: $ThisHTML = &OpenFileAsVar("$vars_config{NonCGIPath}/cache-$cache_cookie near the very top of the file, within the first 35 lines. Directly below the $ThisHTML assignment will be another two lines: print "$ThisHTML"; exit; BETWEEN the first line and the second two, insert the following code: --------------------BEGIN my $pmWording = &CheckPMs if $ubber[4] =~ /^\d{8}$/; &ParseThisHTML("", $pmWording); --------------------END You will need to do this for BOTH INSTANCES. 4) Scroll down to around line 105. There will be the following two lines: #display onscreen print "$ThisHTML"; exit; ABOVE those two lines, place the code mentioned above. 5) Save and close ubb_forum_summary.cgi 6) Open public_forum_summary.pl Choose a place to insert the PM notification. I recommend placing it IMMEDIATELY after $show_logout. Normally, $show_logout is printed on line 30, but this may vary. The PM notification text is: Thus, the modified HTML should look like: » $show_logout 7) Save and close public_forum_summary.pl 8) Upload the three changed files in ASCII and set permissions as required. 9) Clear the forum summary page cache in your UBB control panel. 10) Visit your board - you will now note the PM notification text. That's it. If your board throws errors, go back to unhacked files and start over again.