PDA

View Full Version : Send User a PM on Birthday


melondog
04-01-2002, 10:00 PM
Ok, I made a little hack to send users a PM on their Birthday.

Fixed

First, make a new file, pmbday.txt, and chmod it to 777.

Next open index.php and add this code:

// send PM if Birthday
$message = "Your message here.\n";
$title = "Happy Birthday!!";
$username = $bbuserinfo['username'];

if(vbdate('m-d', time()) == substr($bbuserinfo['birthday'], 5)){
$file = file("pmbday.txt");
while(list(,$value) = each($file)){
list($user, $date) = explode("|", $value);
if($username == $user){
}else{

$touserid = $bbuserinfo['userid'];

$DB_site->query("INSERT INTO privatemessage (privatemessageid, userid,touserid, fromuserid, title, message, dateline, showsignature, iconid, messageread, folderid, receipt) VALUES (NULL,$touserid,$touserid,1,'$title','$message',".time().",0,0,0,0,0)");

if($noshutdownfunc){
$DB_site->query("UPDATE user SET pmpopup=2 WHERE userid=$touserid");
}else{
$shutdownqueries[]="UPDATE LOW_PRIORITY user SET pmpopup=2 WHERE userid=$touserid";
}

$date = date("m.d.y");
$fp = fopen("pmbday.txt", a);
fputs($fp, "$username|$date|\n");
fclose($fp);
}
}
} You can add it pretty much anywhere in index.php.

If you have questions or comments, feel free to post them.

defnot
04-02-2002, 07:42 PM
great !!! thx for this hack !!

melondog
04-02-2002, 07:47 PM
Thanks. I will be adding more hacks as I make them.

hidjra
04-02-2002, 08:59 PM
Why do i receive 17 pm's???

wooolF[RM]
04-02-2002, 09:03 PM
]LOL :D I have birthday only once a year... ;)

Freddie Bingham
04-02-2002, 09:29 PM
Hmm what happens if the user doesn't accept cookies?

Oh they get a pm for every view of index.php ;)

wooolF[RM]
04-02-2002, 09:55 PM
]good idea for spamming.... :D ;)

TWTCommish
04-02-2002, 09:55 PM
I think this hack needs a switch to specify the birthday PM as having already been sent. :)

pwr_sneak
04-03-2002, 09:11 AM
how about sending the PM when the system updates the birthday-templates once per day (first hit after midnight) ?
search for "if ($showbirthdays) {" in your index.php and for "function getbirthdays() {" in admin/functions.php
I'd change the while-loop inside getbirthdays() to send the PM or create a new function wich is called from within that loop.
Maybe You can create new templates for the message and the title and give fromuserid its own variable to let the admin decide which userid is the sender of this message.

I'd make this changes on my own, but i don't have the time and melondog needs to learn ;)

sneak

melondog
04-03-2002, 03:23 PM
Ok, I didn't realize this, it was a quick hack. I will have a fixed version for you guys soon. Thanks pwr_sneak for the tips.

melondog
04-03-2002, 08:39 PM
It's all fixed guys. I hope there arn't anymore problems with it.

pwr_sneak
04-04-2002, 05:37 PM
ok, this works now, but adds load to the server and doesn't work on forums, which use multiple boxes, but these problems are very special :)

Another problem could occur more often. Your hack won't work if a user got a pipe (|) in his username, better to use userid.

My idea was, send all PM notifications just once a day on the first page-impression after midnight.
Do do that add right after:
while ($birthday=$DB_site->fetch_array($bdays)) {


while ($birthday=$DB_site->fetch_array($bdays)) {
$message = "Your message here.\n";
$title = "Happy Birthday!!";

$DB_site->query("INSERT INTO privatemessage (privatemessageid, userid,touserid, fromuserid,
title, message, dateline, showsignature, iconid, messageread, folderid, receipt) VALUES (NULL,
$birthday[userid],$birthday[userid],1,'$title','$message',".time().",0,0,0,0,0)");