PDA

View Full Version : Instant Messing Hack


08-03-2000, 04:30 PM
This may be impossible to do, but it has been requested by my girls on the UBB (which hopefully will be on Vb when I get my new server which is why I'm posting this here).

They want to be able to see someone "online" and be able to send them an instant message. Example, I see Martin on the "currently online" section on the front page. I click on his profile, and there is a link that says "send him an instant message" where I can fill out a form and it sends it to him. Martin instantly gets some type of notification, maybe a popup, or some noticable way that appears on any page he is on. He clicks on it, and then he can send an instant message back to me.

08-03-2000, 05:18 PM
would be nice, but wouldn't the PM hack be better for this ? i mean i hate to have say 100 online members instant message me at the same time :eek:

08-03-2000, 05:50 PM
You'd think, but my visitors want instant messaging so they can chat when they are both online. You don't know you have a PM unless you go to the front page or check your email for a confirmation.

Unless you can get PM notification on all pages....
Ed???

[Edited by Me2Be on 08-03-2000 at 02:50 PM]

08-03-2000, 05:56 PM
Originally posted by Me2Be
Unless you can get PM notification on all pages....

Humm this would be nice... and I don't think too difficult either.

-Chris

08-03-2000, 06:01 PM
actually i have seen the PM hack done that way shown on showthreads template bit over at fanforum.com - one big vbulletin there too :) check out the FAQ forum if you can find it on the frontpage.... the top of each thread has the PM notification

08-03-2000, 06:15 PM
Thanks Eva - just checked it out and I like the way that is done. Their Vb is quite slow, must be all the visitors on there (150)!

08-03-2000, 06:40 PM
yeah i know fanforum is slow and a bit buggy, i think it could be their customisation... cause i registered fine, but my sister was caught in a loop on sign up there... she kept pressing agree and kept getting redirected to the initial sign up page :eek:

150 online users is alot, i wonder how long it took them to do the customisation... so many templates :rolleyes:

08-03-2000, 06:42 PM
i am thinking of doing the PM hack that way too, so how would one do that ? maybe justifies a new thread :)

08-03-2000, 07:10 PM
Putting the PM indicator on every page would be easy but time consuming. Just think of all the templates you would have to edit, UGGGHHHH!

Putting something in fivelinks would be the way to do it I think. The little light indicator and then a link to private.php

08-03-2000, 07:14 PM
It's very easy.

Turn on PHP in your Header and paste all the index.php code in there.

Should work great.

Well, actually - that would bring up the PM code, but you might want to edit the templates so it's a full table, and then remove the $pminfo link from forumhome.

08-03-2000, 07:18 PM
Actually, I would only add it to the major templates like show/newthread, show/newreply, forumdisplay, memberlist etc.

After the time I spent on my test board creating my templates, what's a few more minutes! LOL

What would I put in the template - $pminfo or something else?

[Edited by Me2Be on 08-03-2000 at 04:19 PM]

08-03-2000, 08:39 PM
yeah - or you could just add below all the code I told you to paste in the header, this:

$header = $pminfo;

08-04-2000, 02:55 PM
I thought I saw a hack like this for the UBB. Here's how it was basically done:
It was very similar to a PM, except it checked for an instant message every time a user loaded a page. If there was a new IM, it used javascript to pop open a new window with the message in it.
Not exactly instant - you have to reload or change pages to get it - but pretty close.
I'd love to see someone try to implement this in a graceful manner. It has potential to be great, but could also be very ugly if not done well.

08-04-2000, 03:57 PM
I love the pop-up idea - that would be excellent!

08-04-2000, 09:26 PM
Yeah, this was something that I suggested awhile back where when someone has a new message and they get on the forum it gives you a pop up that tells you you have a new message and gives you the ability to either read it there or go to the private message page.

Parker

08-05-2000, 02:03 AM
That would be great. I am sure you can do it Ed. ;)

08-07-2000, 06:35 PM
I tried coping all the info you mentioned above into my header, but I'm getting parsing errors.

Is there another, simpler way to have the PM notification appear on the forumdisplay and showthreads page?

08-08-2000, 03:36 PM
I'd think that the only way to have truly "instant" messages is to run a Java applet in the pages which keeps querying the DB on a regular basis looking for new IMs -- and if you get one it can pop a window saying "Here is your new message: blah blah blah". I’ve worked with Java before and it wouldn't be too hard to do if you have Java on your server -- however it would cause a huge server load if you had a lot of people online continually pegging the DB for their entire session.

08-09-2000, 03:32 AM
This will provide a pop up when you have a new private message. You need to have the Private Messages Hack by Ed Sullivan installed for it to work.

In index.php look for in the private messages hack:


if ($newpmcount == 0) {
$lightbulb = 'images/off.gif';
} else {
$lightbulb = 'images/on.gif';
}


and replace this with:


if ($newpmcount == 0) {
$lightbulb = 'images/off.gif';
} else {
$lightbulb = 'images/on.gif';
eval("\$popupinfo .=\"".gettemplate("popupscript")."\";");
}



Then in your forumhome template look for:


{htmldoctype}
<HTML>
<HEAD><TITLE>$bbtitle - powered by vBulletin</title>
$cssinclude
</head>


and replace this with:


{htmldoctype}
<HTML>
<HEAD><TITLE>$bbtitle - powered by vBulletin</title>
$cssinclude
$popupinfo
</head>


then create a new template called:

popupscript

and put in:


<SCRIPT LANGUAGE="JavaScript">

<!--
browser = (((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 2 )) || ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 2 )));
browser4 = (((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4 )) || ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 )));
if (browser4) {
if (!self.url) {
self.url = '';
}
if (parent.name != 'test') {
test = window.open("http://www.yoururl.com/forum/instantprivate.html", "test", "resizable=yes,width=320,height=80");
}
} else if (browser) {
if (!self.url) {
self.url = '';
}
if (parent.name != 'test') {
test = window.open("http://www.yoururl.com/forum/instantprivate.html", "test", "resizable=yes,width=328,height=100");
}
}

//-->

</SCRIPT>


if you want it to work you read a post:

open showthread.php and look for:


if ($userinfo[receivepm]=="1") {
$pmlink = "<a href=\"private.php?action=newmessage&toid=$userinfo[userid]\"><img src=\"images/pm.gif\" border=0></a>&nbsp;";
} else {
$pmlink = "";
}
//END PM Hack


and replace this with:


if ($userinfo[receivepm]=="1") {
$pmlink = "<a href=\"private.php?action=newmessage&toid=$userinfo[userid]\"><img src=\"images/pm.gif\" border=0 alt=\"Send $userinfo[username] a Private Message\"></a>&nbsp;";
} else {
$pmlink = "";
}
$pmcounta = $DB_site->query_first("SELECT COUNT(msgid) AS msgid FROM privatercvd WHERE toid=$userid");
$pmcount = $pmcounta[msgid];
$newpmcounta = $DB_site->query_first("SELECT COUNT(msgid) AS msgid FROM privatercvd WHERE toid=$userid AND UNIX_TIMESTAMP(datetime)>$bblastvisit");
$newpmcount = $newpmcounta[msgid];
if ($newpmcount == 0) {
$lightbulb = "";
} else {
$lightbulb = "<a href=\"private.php\"><img src=\"images/pmon.gif\" border=0 alt=\"You have a private message. Click here to read it.\"></a>";
eval("\$popupinfo .=\"".gettemplate("popupscript")."\";");
}
//END PM Hack


then open your showthread template and look for:


{htmldoctype}
<HTML>
<HEAD><TITLE>$bbtitle - $threadtitle</title>
$cssinclude
<script language="javascript">
<!--
function aimwindow(aimid) {
window.open("member.php?action=aimmessage&aim="+aimid,"_blank","toolbar=no,location=no,menubar=no,scrollbars=no,wi dth=175,height=275,resizeable=yes,status=no")
// -->
}
</script>
</head>


and replace this with:


{htmldoctype}
<HTML>
<HEAD><TITLE>$bbtitle - $threadtitle</title>
$cssinclude
$popupinfo
<script language="javascript">
<!--
function aimwindow(aimid) {
window.open("member.php?action=aimmessage&aim="+aimid,"_blank","toolbar=no,location=no,menubar=no,scrollbars=no,wi dth=175,height=275,resizeable=yes,status=no")
// -->
}
</script>
</head>


and in the postbit template look for:

&nbsp;&nbsp;$pmlink

and add after $pmlink:

&nbsp;$lightbulb


Then after all of that create an .html file called
instantprivate.html

and put in:


<html>
<head>
<title>Private Message Popup</title>
</head>

<body>
<table>
<tr bgcolor="yellow">
<td align="center">
You have new private message(s).<P>
[ <a href="private.php" target="_new">Read them!</a> ]</td>
</tr>
</table>

</body>
</html>


and upload this to your forum directory. In the popupscript template that you created you will need to change the path to point to the location of this html file.

Change the .html to read or give you the layout that you want.

This will give you a pop up window, with the private message hack installed, that will tell your members when they have a new message when they first get on the board and if they read a post and they have a new message. They can then go to the private message from the pop up or they will be given a new message icon in their posts. You will need to upload an image file for whatever you have the $lightbulb in the showthread.php file pointing to.

You will also need to go into your admin options area and change the default time for the cookietimeout section. It is set to 14,400 and you may want to reduce this time so that your members won't be getting a pop up window each time they go to the forum.

Give this a shot and let me know how it works.

Parker

08-09-2000, 06:45 PM
Nice work Parker. Do you have this installed anywhere for us to check out?

That sounds like its getting close to what we are looking for.

One way I can think of to improve it would be to put the contents of the private message in the window itself. Also, include a reply button so a user can send an reply without having to stop what they are doing on the board. After they respond, the window can automatically close. That way, its almost just like an instant message.

Of course, at this point, its probably best to make it a seperate hack (instant message as opposed to private message). Give it its own set of templates with minimal interface.

With these small changes it sounds like we've almost got a decent IM tool!

08-09-2000, 06:59 PM
I'd like to see this up somewhere to. Great job!

08-09-2000, 07:00 PM
nice... just a quetion regarding these instant message and pm hacks... if used excessively would they use up alot of bandwidth ?

08-09-2000, 07:24 PM
Johnny:

I have no clue how to put the content of the message or put a reply button in the pop up window. This was just a way to let people know that they have a private message waiting with a pop up. So if someone where to have a private message sent to them while they are on the board it would give them a pop up.

Huss:

I only have this on a test board right now. And this board is changing all the time to get it ready to have my forum as it is switched over.

eva2000:

I am not sure of the amount of bandwidth they would use. I would imagine it would be pretty minimal with what I have as it is just a pop up message.

Parker

08-10-2000, 12:22 PM
You can see this in action at:

http://www.hometheaterforum.com/htforum/index.php

The forum has messages imported with usernames to test with.
It also loads slowly as it hasn't been set up with PHP and mySQL for optimization yet. You can click on the private messages link at the bottom on the first page or post a message, send a private message and see how it looks on the forumdisplay page too.

Parker



[Edited by Parker Clack on 08-10-2000 at 09:23 AM]