######################################################## ## ## Hack Title: E-Mail Notification on new PM ## Hack Version: 1.0.1 ## Author: Christoph "Toxic" Hellings (toxic@freenet.de) ## Date Created: 09-02-02 ## Date Updated: 09-02-02 ## Thread Location: ## Working Example: ## Description: If a user sets the option to yes in his profile he will ## receive an e-mail notification whenever he gets a PM. ## ## ## Installation Level: Intermediate ## Installation Time: 10 Minutes ## Files To Edit: 5 ## Edit Database: yes ## Included Files: none ## ######################################################## ## ## Installation/Author Notes: ## ## I think it works but no warranty... ## UPGRADING INSTRUCTIONS 1.0.0 -> 1.0.1: ## just add an semicolon at the end of this line: ## if ($row = mysql_fetch_array($result)) MailPMNotice($tou,$row[0]); ## END OF UPGRADING INSTRUCTIONS ## ######################################################## # #-----[ ACTION: BACKUP ]------------------------------------------ # Every time you edit your files, you should always back them up first. Although all of these hacks have been tested on various systems, they may not work with your configuration or you may not like what it does. Backing up protects yourself and your users from downtime. # #-----[ ACTION: EDIT DATABASE ]---------------------------------- # ALTER TABLE t_users ADD PMnotify TINYTEXT NOT NULL; # #-----[ ACTION: OPEN ]------------------------------------------- # forum_template.php # #-----[ ACTION: LOCATE ]----------------------------------------- # function PrintRegForm() # #-----[ ACTION: FIND ]------------------------------------------- # "> "> Yes No # #-----[ ACTION: ADD AFTER ]-------------------------------------- # "> "> Yes No # #-----[ ACTION: LOCATE ]----------------------------------------- # function PrintEditProfile() # #-----[ ACTION: FIND ]------------------------------------------- # "> "> Yes No # #-----[ ACTION: ADD AFTER ]-------------------------------------- # "> "> > Yes > No # #-----[ ACTION: OPEN ]------------------------------------------- # functions.php # #-----[ ACTION: FIND ]------------------------------------------- # $UserInfo["UserName"] = $row["UserName"]; # #-----[ ACTION: ADD AFTER ]-------------------------------------- # if ($row["PMnotify"] == "yes") $UserInfo["PMnotify"] = "yes"; else $UserInfo["PMnotify"] = "no"; # #-----[ ACTION: OPEN ]------------------------------------------- # member.php # #-----[ ACTION: LOCATE ]----------------------------------------- # function AddMember() # #-----[ ACTION: FIND ]------------------------------------------- # { global $username,$password,$email,$homepage,$country,$icqnumber,$aolhandle,$msnhandle,$yahoohandle,$signature,$savepass,$timezone,$avatar; # #-----[ ACTION: REPLACE ]----------------------------------------- # { global $username,$password,$email,$homepage,$country,$icqnumber,$aolhandle,$msnhandle,$yahoohandle,$signature,$savepass,$timezone,$avatar,$PMnotify; # #-----[ ACTION: FIND ]------------------------------------------- # $query = "INSERT INTO t_users (UserName,Password,Email,Homepage,Country,ICQNumber,YahooHandle,MSNHandle,AOLHandle,Signature,NumPost,RegDate,SavePass,timezone,Avatar) "; $query .= "VALUES('".AddSlash($username)."','$password','$email','$homepage','$country','$icqnumber','$yahoohandle','$msnhandle','$aolhandle','$signature',0,UNIX_TIMESTAMP(),'$savepass','$timezone','$avatar')"; # #-----[ ACTION: REPLACE ]----------------------------------------- # $query = "INSERT INTO t_users (UserName,Password,Email,Homepage,Country,ICQNumber,YahooHandle,MSNHandle,AOLHandle,Signature,NumPost,RegDate,SavePass,timezone,Avatar,PMnotify) "; $query .= "VALUES('".AddSlash($username)."','$password','$email','$homepage','$country','$icqnumber','$yahoohandle','$msnhandle','$aolhandle','$signature',0,UNIX_TIMESTAMP(),'$savepass','$timezone','$avatar','$PMnotify')"; # #-----[ ACTION: LOCATE ]----------------------------------------- # function EditProfile() # #-----[ ACTION: FIND ]------------------------------------------- # { global $username,$password,$newpassword,$email,$homepage,$icqnumber,$aolhandle,$yahoohandle,$signature,$savepass,$txt,$timezone,$country,$msnhandle,$avatar; # #-----[ ACTION: REPLACE ]----------------------------------------- # { global $username,$password,$newpassword,$email,$homepage,$icqnumber,$aolhandle,$yahoohandle,$signature,$savepass,$txt,$timezone,$country,$msnhandle,$avatar,$PMnotify; # #-----[ ACTION: FIND ]------------------------------------------- # if ($newpassword) $query = "UPDATE t_users SET Password='$newpassword',Email='$email',Homepage='$homepage',Country='$country',ICQNumber='$icqnumber',YahooHandle='$yahoohandle',MSNHandle='$msnhandle',AOLHandle='$aolhandle',Signature='$signature',SavePass='$savepass',timezone='$timezone',Avatar='$avatar' WHERE ID = '$ID'"; else $query = "UPDATE t_users SET Email='$email',Homepage='$homepage',Country='$country',ICQNumber='$icqnumber',YahooHandle='$yahoohandle',MSNHandle='$msnhandle',AOLHandle='$aolhandle',Signature='$signature',SavePass='$savepass',timezone='$timezone',Avatar='$avatar' WHERE ID = '$ID'"; # #-----[ ACTION: REPLACE ]----------------------------------------- # if ($newpassword) $query = "UPDATE t_users SET Password='$newpassword',Email='$email',Homepage='$homepage',Country='$country',ICQNumber='$icqnumber',YahooHandle='$yahoohandle',MSNHandle='$msnhandle',AOLHandle='$aolhandle',Signature='$signature',SavePass='$savepass',timezone='$timezone',Avatar='$avatar',PMnotify='$PMnotify' WHERE ID = '$ID'"; else $query = "UPDATE t_users SET Email='$email',Homepage='$homepage',Country='$country',ICQNumber='$icqnumber',YahooHandle='$yahoohandle',MSNHandle='$msnhandle',AOLHandle='$aolhandle',Signature='$signature',SavePass='$savepass',timezone='$timezone',Avatar='$avatar',PMnotify='$PMnotify' WHERE ID = '$ID'"; # #-----[ ACTION: OPEN ]------------------------------------------- # pm.php # #-----[ ACTION: FIND ]------------------------------------------- # $fSettings = GetSettings(); # #-----[ ACTION: ADD AFTER ]-------------------------------------- # function MailPMNotice($touser,$PMID) { global $fSettings; $ToUser = GrabUserInfo($touser); if ($ToUser["LevelID"] != 99) { $subject = "tForum Reply Notice"; $message = "Someone has send you a PM on tForum.\n\nPlease use this link to read the PM: ".$fSettings["ScriptURL"]."/pm.php?Action=read&username=".$ToUser["UserName"]."&MID=".$PMID; mail($ToUser["UserName"]." <".$ToUser["Email"].">", $subject, $message, "From: tForum <".$fSettings["Email"].">"); } } # #-----[ ACTION: LOCATE ]----------------------------------------- # function sendPM() # #-----[ ACTION: FIND ]------------------------------------------- # if ($result) {?> # #-----[ ACTION: REPLACE ]----------------------------------------- # if ($result) { $query = "SELECT PMnotify FROM t_users WHERE UserName = '".AddSlash($tou)."'"; $result = mysql_query($query); $row = mysql_fetch_array($result); if ($row[0] == "yes") { $query = "SELECT ID FROM t_pm WHERE ToUser = '".AddSlash($tou)."' ORDER BY DATE DESC LIMIT 1"; $result = mysql_query($query); if ($row = mysql_fetch_array($result)) MailPMNotice($tou,$row[0]); } ?> # #-----[ ACTION: OPEN ]------------------------------------------- # english_lg.php # #-----[ ACTION: ADD ]-------------------------------------------- # $txt['PMnotify'] = "E-mail notification when receiving a PM?"; # #-----[ ACTION: SAVE & UPLOAD ]----------------------------------- # forum_template.php functions.php member.php pm.php english_lg.php # #----------------------------------------------------------------- # EOF