UBB.Dev
Mod Name / Version - Private Message Pop Up Notification 2.2
Version 2.2 fixes an issue with the popup script not displaying on some servers.

Description - This pops up a little window when there are new Private Messages Waiting. The window tells how many messages, and gives a link to check them. The window will refresh periodically and update the total number of messages, and close when there are no more new messages to read. There is also an option to have an audio alert (with or without the popup window) when you have new private messages. Users can specify which option, or none or both in their profiles.

Pre-requisites - none

Author - JoshPet

Credits - Definately couldn't have done this without help from JustDave and Gardener - Thanks Guys! Thanks to Chaos for helping to track down bugs and errors in my instructions for 6.2. <img src="/threads/php/images/graemlins/smile.gif" alt="" />

Files Altered - ubbt.inc.php, editbasic.php, changebasic.php,
/templates/default/editbasic.tmpl, /templates/default/ubbt_registerednav.tmpl,
/languages/english/online.php, /languages/english/generic.php,
/languages/english/editbasic.php

Database Altered - Yes - 2 fields (U_PrivatePopup & U_PrivateAlert) are added to allow users the option to choose or disable either option

New Files - messagepopup.php

Any other info - I was pretty proud of myself for pulling this one off. <img src="/threads/php/images/graemlins/wink.gif" alt="" /> LOL

Screenshot - Here is what the popup window looks like. I made it bright yellow, with red text (not stylesheet dependent) so that it will stand out. It inserts the name of the site (from config file), user's name, number of messages and link back to check private messages. Clicking the link or the flashing envelope icon will open the list of received messages back in the original threads window. 
[]https://www.ubbdev.com/threads/php/uploads/59752-popupwindow.gif[/]

I also have included this sound file in the zip, but you can substitute any .wav file. I found a great source for "you have mail" type sound files at http://newmail.monsterserve.com

NOTE: Audio alert may not work in all browsers. <img src="/threads/php/images/graemlins/wink.gif" alt="" />


Attached File
Josh after installing this (I checked it twice so I think I have done it correctly) I get this

Parse error: parse error, unexpected T_ELSE in c:\wwwroot\ubbthreads\ubbt.inc.php on line 1759

Fatal error: Call to undefined function: getmicrotime() in C:\wwwroot\ubbthreads\main.inc.php on line 16
OK - think I got a little happy with Cut and Paste.

Look for the line in ubbt.inc.php that starts like this:

    if ($Query) { $Query .=","; }
    $Query .= "U_Username,U_Password,U_SessionId, .....


Below it, add:

    }

That should fix it.

I'll update my instructions and zip. Thanks.
nope still getting the same error

per your suggestion
// -----------------------------------------------------------------
// We are automatically adding StyleSheet, Status, Privates and
// FrontPage and Number to each SQL call because this information is needed by
// every script that makes a call to authenticate
else {
if ($Query) { $Query .=","; }
$Query .= "U_Username,U_Password,U_SessionId, U_StyleSheet, U_Status, U_Privates, U_FrontPage, U_Number, U_PrivatePopup, U_PrivateAlert";
}
What's around your line 1759 where it seems to be having trouble?
lines 1755-1790
// -----------------------------------------------------------------
// We are automatically adding StyleSheet, Status, Privates and
// FrontPage and Number to each SQL call because this information is needed by
// every script that makes a call to authenticate
else {
if ($Query) { $Query .=","; }
$Query .= "U_Username,U_Password,U_SessionId, U_StyleSheet, U_Status, U_Privates, U_FrontPage, U_Number, U_PrivatePopup, U_PrivateAlert";
}

$Uid = addslashes(${$config['cookieprefix']."w3t_myid"});

$query = "SELECT $Query FROM {$config['tbprefix']}Users WHERE U_Number = '$Uid'";
$sth = $dbh -> do_query($query);
$thisuser = $dbh -> fetch_array($sth);
$dbh -> finish_sth($query);
if ( ($thisuser['U_SessionId']) && ($thisuser['U_SessionId'] == ${$config['cookieprefix']."w3t_mysess"}) ) {
return $thisuser;
} elseif (${$config['cookieprefix']."w3t_key"} == md5("{$thisuser['U_Number']}{$thisuser['U_Password']}")) {
srand((double)microtime()*1000000);
$newsessionid = md5(rand(0,32767));
$newsessionid_q = addslashes($newsessionid);
$query = "
UPDATE {$config['tbprefix']}Users
SET U_SessionId = '$newsessionid_q'
WHERE U_Number = $Uid
";
$dbh -> do_query($query);
if ($config['tracking'] == "sessions") {
session_register("{$config['cookieprefix']}w3t_mysess");
${$config['cookieprefix']."w3t_mysess"} = $newsessionid;
}
else {
setcookie("{$config['cookieprefix']}w3t_mysess","$newsessionid","0","{$config['cookiepath']}");
}
return $thisuser;
}

Thanks Josh-
Doah... I don't know what happened to my copy paste at that part of the instructions.... must have hit or pasted the wrong thing.

At the very top....

where it says "else {"
That line should be unchanged from the original... we are only changing the query line.

So change the else { line to this:

if ($Query != "*") {


Sorry for the trouble. I am fixing my zip.
That solve the first problem now I am getting this


Parse error: parse error, unexpected T_STRING, expecting ',' or ')' in c:\wwwroot\ubbthreads\editbasic.php on line 74

Lines 61-80
// ----------------------------------------
// Get the current profile for this username
$Username_q = addslashes($Username);
$query = "
SELECT U_LoginName,U_Password,U_Email,U_Fakeemail,U_Name,U_Signature,
U_Homepage,U_Occupation,U_Hobbies,U_Location,U_Bio,U_TextCols,
U_TextRows,U_Extra1,U_Extra2,U_Extra3,U_Extra4,U_Extra5,U_Picture,
U_Visible,U_AcceptPriv,U_OnlineFormat,U_PrivatePopup,U_PrivateAlert
FROM {$config['tbprefix']}Users
WHERE U_Username = '$Username_q'
";
$sth = $dbh -> do_query($query);


// --------------------------------
// Make sure we found this Username
list($LoginName,$ChosenPassword,$Email,$Fakeemail,$Name,$Signature,
$Homepage,$Occupation,$Hobbies,$Location,$Bio,$TextCols,
$TextRows,$ICQ,$Extra2,$Extra3,$Extra4,$Extra5,$Picture,
$Visible,$AcceptPriv, $OnlineFormat,t,$PrivatePopup, $PrivateAlert) =
$dbh -> fetch_array($sth);
$dbh -> finish_sth($sth);


if (!$ChosenPassword){
$html -> not_right("{$ubbt_lang['NO_PROF']} '$Username'",$Cat);
}
OK I see the problem

Find this:

$OnlineFormat,t,$PrivatePopup,$PrivateAlert)

Remove that stray "t" like this:

$OnlineFormat,$PrivatePopup,$PrivateAlert)

Sorry you've had so much trouble. Guess it was too late when I pulled together my instructions. Or they were messed up from before. I had posted this under 6.1 but just got around to updating it (at my user's request) last night.
This might be a good basis to use as a start onto an instant message hack where this window would pop up with the message you send them from a list of choosable users online at that moment.

Ok we are one step closer to the promised land.
The pop up window now comes up but I am getting a server 500 error within it
And I was up pretty late too as you can see by my 4:50 am post and my uhh..other posts on the forum

*edit-my badd...the privatemessage.php and the sound file got extracted with its dir folder instead of directly to my UBBThreads directory.-told ya I was up late *

Thanks Josh
I'm not sure about a server 500 error.
Anyone know what kind of error that is?
^see above edit^
Cool!
Josh does this function check for Private Message automatically or does it rely on me refreshing the page I am viewing? I dont seem to be getting notification until I refresh and it sees the flashing envelope icon

Also when hovering above the flashing envelope in the pop up box the numerical value is missing for amount of posts
"You have _ new message(s)
Yeah, it works the same as the flashing envelope icon... threads doesn't check for new PMs until you refresh the page.

The popup will keep refreshing and close itself when there are no PMs left.
Doah... this one was just all dusty.

In the messagepopup.php file.....

Look for this:

alt="{$ubbt_lang['WEL_PRIV2']} $Privates {$ubbt_lang['WEL_PRIV3']}"


Change $Privates to $Messages



I'll update the zip.
Updated the zip with what *should* be the last of the tweaks and fixes.

Added Chaos to the Credits list for tracking down all the bugs and errors in the directions. Hadn't fooled with this mod since 6.1 so I guess it was dusty.

Thanks Chaos.
LOL great work..I hope ya dont mind me keeping ya jumping this afternoon
and believe me if there is a bug I am usually apt to find it lol
No better to track it down early.... blaze the trail. Now everyone else can try, now that you've found all the bugs.

It's safe now. LOL
Works like a charm now. and congrats on your 2500th post Josh

What kind of load does it put on the server if I use a different .wav file? Any suggestions on the length?
Each time it plays... it's basically bandwidth used. So smaller is better if bandwidth is a concern for you... or if you have lots of members on dialup.
Josh I get a blank popup box and no sound hearing
Hmmmm... does it work if you open the popup in the broser directly?
Also a blank page
Do you have a URL so I can look?
must have been fixed
[]Hmmmm... does it work if you open the popup in the broser directly? [/]

Hi Josh,

same problem here (Link removed - was for testing purposes only).

Installation was done exactly how you described it
Hmmm...

I'm not 100% sure why it doesn't work for you. I see it's working, but he popup won't generate.

Might be HTML fussiness.

I've learned a bit more since I originally wrote that.

Try this.... download the messagepopup.txt file that I attached to THIS post. Rename it to .php. See if that one works for you.

If anybody else want to glance at it (attached to this post) and see if they see any issues with how I've done this, please do.

If this one works for you, please let me know, and I'll put this version into the distribution.

<fingers crossed>

Attached File
68950-messagepopup.txt  (231 downloads)
Hi Josh,

this one works - thanks
I've updated the main post in this thread to version 2.2.

This fixes an issue with the popup not appearing on some servers. Thanks Stefan for your help in testing this.

Kudos goes to JustDave (although he doesn't know it) because looking at his popup graemlin panel gave me clues as to how to fix this.

Plagiarism is the biggest form of flattery.
This is one of my FAVORITES!

Thanks for the help, Josh!
##########################################
# Find this:
#

// -----------------------------------------------------------------
// We are automatically adding StyleSheet, Status, Privates and
// FrontPage and Number to each SQL call because this information is needed by
// every script that makes a call to authenticate
if ($Query != "*") {
if ($Query) { $Query .=","; }
$Query .= "U_Username,U_Password,U_SessionId, U_StyleSheet, U_Status, U_Privates, U_FrontPage, U_Number, U_PrivatePopup, U_PrivateAlert";
}

#
# Change to this:
#

// -----------------------------------------------------------------
// We are automatically adding StyleSheet, Status, Privates and
// FrontPage and Number to each SQL call because this information is needed by
// every script that makes a call to authenticate
if ($Query != "*") {
if ($Query) { $Query .=","; }
$Query .= "U_Username,U_Password,U_SessionId, U_StyleSheet, U_Status, U_Privates, U_FrontPage, U_Number, U_PrivatePopup, U_PrivateAlert";
}


###################################################

is exactly the same *gg a bug?

greetings from oversea
Ah probably an error in my instructions.

The part you are finding wouldn't have the U_PrivatePopup, U_PrivateAlert being queried. It would end with U_Number.

hier is the right one:
##########################################
# Find this:
#

// -----------------------------------------------------------------
// We are automatically adding StyleSheet, Status, Privates and
// FrontPage and Number to each SQL call because this information is needed by
// every script that makes a call to authenticate
if ($Query != "*") {
if ($Query) { $Query .=","; }
$Query .= "U_Username,U_Password,U_SessionId, U_StyleSheet, U_Status, U_Privates, U_FrontPage, U_Number";
}

#
# Change to this:
#

// -----------------------------------------------------------------
// We are automatically adding StyleSheet, Status, Privates and
// FrontPage and Number to each SQL call because this information is needed by
// every script that makes a call to authenticate
if ($Query != "*") {
if ($Query) { $Query .=","; }
$Query .= "U_Username,U_Password,U_SessionId, U_StyleSheet, U_Status, U_Privates, U_FrontPage, U_Number, U_PrivatePopup, U_PrivateAlert";
}


###################################################
Thanks.
Posted By: patt Set the default - 03/23/2003 8:40 PM
bugs?
1. Set the default for Private Message Popup & Private Message Alert Sound

they are allways on NO
if i change them to YES it's ok
if i open the "Personal information" again they go automatic on NO

2. Set the Private Message Alert Sound

if the Private Message Popup is on YES allways the sound,
YES/NO in the Private Message Alert Sound without function

3. below the footer its showing a Query:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Query: UPDATE w3t_Users SET U_Rating = '40' , U_Rates = '8' , U_RealRating = '5' WHERE U_Number = '2'
Query took a total of 0.001 seconds.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
a bug? ore possible don't show that?
Posted By: JoshPet Re: Set the default - 03/23/2003 11:06 PM
I don't understand what you are asking.

That query has to do with user ratings.
Posted By: patt Re: Set the default - 03/24/2003 1:11 AM
ok...one's more

1. when i open "Main Configuration" >> "Personal information, email, password, etc." >> "Do you want a Notification box for Private Messages?"
the default setting is on "NO"
if i open "Main Configuration" >> "Personal information, email, password, etc." >> "Do you want an Audio Alert for Private Messages?"
the default setting is on "NO"
if i change both with a click on "YES" the popub works.

when i go again into the "Main Configuration" >> "Personal information, email, password, etc."
both settings show me again "NO"
why they changed automatic?

2. if "Do you want a Notification box for Private Messages?" is on "YES" i always hear a sound, the
"Do you want an Audio Alert for Private Messages?" didn't work....YES ore NO....always the sound!

3.after a new config from "Personal information, email, password, etc." it shows me a Query

Attached picture 74047-query.jpg
Posted By: JoshPet Re: Set the default - 03/24/2003 1:34 AM
It sounds like you've got a problem in editbasic.php or changebasic.php Double check those intructions. Make sure you've modified the query to grab the current settings of on or off. My guess is that the fields or variables haven't been added, and without a value, its going back to the default.

Then the sound always playing and the query on the bottom of the page, I'm not sure. That query has nothing to do with this.... that's a query to update someone's user Rating. So that makes me think you are missing a } somewhere in ubbt.inc.php. Double check those files as well.
Posted By: patt Re: Set the default - 03/25/2003 5:17 AM
the query is only when i install 67476-ProfileStatusBar1.1 in changebasic.php.....this i find out already.
+++++++++++++++++++++++++++++++++++++++++++++++
just find out...some copie was not ok...now it works :-)
After moving the forum to another webspace this hack is not working anymore. A window is popping up but its empty. Can someone please help me get this working again?
Might be the register globals on/off issue between servers. I think the fix is in this thread - but make sure the popup has the needed get_input functions in if register globals is setup differently.
Register globals are ON on the new server. I cannot check how this was on the old one cause this was only a virtual machine and I have no access to php.ini to check this.

Post deleted by p74vic
ok.. disregard last post (i deleted it), fixed the parse error... now I have a question..

I logged in and had TWO pm's waiting, everytime I went to a new page, the PM page, the reply page, the pm page again, and the replay page again to reply to my pm's, it popped up telling me I had a message... is there a way to make it so it only pops up like once per hour or per session?

Jason
Like the standard "flasher" for PMs, it checks for it every page load. It's tied to that same "mechinasm".

But it forces people to read their PMs right away... which is what I wanted.
Hey Josh, Is this version good for 6.3 also?

Haven't had a need to use it under 6.3. Should be, but I'm not sure. Untested.
I just installed the 2.2 version. I am using UBB threads 6.3.1

I am getting this error in the popup window:

Parse error: parse error, unexpected $ in /home/tampains/public_html/ubbthreads/messagepopup.php on line 60


I looked at line 60 and it is just this:

<title>Private Message Popup</title>

I went and moved that down a line to see if the error followed it and the error did come back showing to be on line 61.

Why would that line be causing the parse error? Also I heard no sound effect either. I am using IE 6.

-Buddy
Actually, line 60 in the stock code is:

Code
UBBTPRINT;


...according to BeyondCompare.
[]DLWebmaestro said:
Actually, line 60 in the stock code is:

Code
UBBTPRINT;


...according to BeyondCompare. [/]


I double checked again. Reverified I copied and pasted via the instructions correctly. The line with UBBTPRINT; is actually line 68. That's straight out of the zip file.

The line the error says is the problem is line 60 which says:
<title>Private Message Popup</title>

... any other ideas?


also, the messagepopup.php file does say it's only 1.0 modified last November. Is that right? Is there a newer version of this file out there to fit the .threads 6.3?

-update-
I played with the coding a bit. Still getting that parse error but I did find that it's all in the UBBTPRINT function.

If I remove this all together... :

Code
 echo <<<UBBTPRINT <br /><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br /><html> <br /><head> <br /><title>Private Message Popup</title> <br /><meta http-equiv="Refresh" content="$refreshtime;url={$config['phpurl']}/messagepopup.php?Cat=$Cat" /> <br /></head> <br /><body> <br /><body bgcolor="#ffff33"> <br />$output <br /></body> <br /></html> <br />UBBTPRINT; 


...I will just get an empty pop up window with no error message. So does that mean this is incompatible code for 6.3?

I have attached the messagepopup.php file I have.

Thanks again.

Attached File
91770-messagepopup.txt  (165 downloads)
I thought there was a more updated one in this thread... but must not have made the zip.

Download the attached file.... change the .txt to .php and try that. If it works let me know and I'll add it into the zip.... but I think this one is more current.

Attached File
91821-messagepopup.txt  (161 downloads)
Hey...now that worked like a beaut! I really appreciate it. Now I just need a sub-forums hack and i'll be good to go. I won't hold my breath on that though.

Thanks Josh.
Don't know how the old one got in the ZIP. But I updated the main post in the thread.....
Thanks for testing it out.
Mmmmm, anyone test this out on v6.4 yet?
Also a 6.4 user, and wouldn't mind seeing this...anyone else?
I have it on 6.4 It's been awhile but if I remember correctly it went on no problems.
Anyone else tried this on 6.4??
Is everyone trying this on UBBThreads 6.5 or. 6.5.1?
Yes... lets bring this back for 6.5.1!!!!!!
Yes PLEASE
© UBB.Developers