Pagina 1 van 1

Cron Birthday MOD

Geplaatst: 26 jan 2005, 13:38
door Hacktor
Dit is een MOD om Birthday automatisch een bericht te laten verzenden. Echter werkt deze MOD alleen met UBB.Threads 6.4.
Is er ook één die werkt voor PHPBB??? :?:

Code: Selecteer alles

<?
// Birthday Mod Auto PM 2.1
// by Joshua Pettit 
// http://www.joshuapettit.com
//
// This software may be used and modified freely providing this
// copyright notice remains intact at the head of all files and
// displayed at the bottom of all pages generated by the software.
//
// This software may NOT be distributed without expressed written
// consent from the author. 
//
// The author accepts no liability for any loss or damages whatsoever 
// incurred directly or indirectly from the use of this software. 
// The author of this software makes no claims as to its fitness for 
// any purpose whatsoever. If you wish to use this software you 
// should first satisfy yourself that it meets your requirements.
//
// Version 2.0 updates for UBB.Threads 6.4
// Version 2.1 fixed a bug related to the user option to show their birthday publically

$whatistoday = date("F jS",time());


// ------------VARIABLES SECTION ------------------

// Do you want PM's, a Post to the Board, or Both?
// 1=PM Only, 2=Post Only, 3=Both
	$hownotify = 3;
	
// If sending a PM, what user number is the PM from
	$pmfrom = 117;	

// If sending a PM, what do you want the Subject to be?
	$pmsubject = "Happy Birthday to You!";
	
// If sending a PM, what do you want the PM body to be?
// use <br /> for a line break
	$pmbody = "Hey, <br />I wanted to wish you a [b]Happy Birthday![/b] <br /><br /> Hope you have a Great Day! :D ";

// If making a Post what forum do you want to post in?
	$boardkeyword = "events";

// If making a post, what user number do you want to be the poster?
	$postfrom = 117;	
// If making a post, What do you want the subject of the post to be?	
	$postsubject = "Today's Birthdays! ($whatistoday)";
	
// If making a post, what do you want the post body to be?
// $postbody1 appears before the list of birthday names and 
// $postbody2 appears after the list of birthday names
// use <br /> for a line break
	$postbody1 = "[b]Today's Birthdays:[/b] "; //The list of usernames would be inserted here
	$postbody2 = ".<br /><br />  Hope you have a [b]great[/b] day! :) ";

// What Post Icon do you want the post to have... 
// should be in the format 'book.gif' from your /images/icon directory
	$posticon = "exclamation.gif";

// --------------END OF VARIABLES -----------------

// Require the threadss library
   require ("main.inc.php");
   $html = new html;

// Do the markup on your post and PM text
      $postbody1 = $html -> do_markup($postbody1);
      $postbody2 = $html -> do_markup($postbody2);
      $pmbody = $html -> do_markup($pmbody);

// Setup stuff for Database Queries
	$pmfrom_q = addslashes($pmfrom);
	$pmsubject_q = addslashes($pmsubject);
	$pmbody_q = addslashes($pmbody);
	$boardkeyword_q = addslashes($boardkeyword);
	$postfrom_q = addslashes($postfrom);
	$postsubject_q = addslashes($postsubject);	
	$posticon_q = addslashes($posticon);
	
// Lets figure out when today is
	$date = $html -> get_date();
      $temp = getdate();
      $month = $temp["mon"];
      $day   = $temp["mday"];

// Do the markup on your post and PM text
      $postbody1 = $html -> do_markup($postbody1);
      $postbody2 = $html -> do_markup($postbody2);
      $pmbody = $html -> do_markup($pmbody);


//--------------------------------------------------
// If we are sending Private Messages we do it here
if (($hownotify == 1) || ($hownotify == 3)) {

	$bdaynumber = "";
	// Lets get the Users who are celebrating a birthday today
		$query = "
			SELECT U_Username,U_Number
			FROM   {$config['tbprefix']}Users
         WHERE  U_Birthday LIKE '$month/$day/%'
         AND U_ShowBday = 1
	      ORDER BY U_Username	       	
		";
    	$sth = $dbh -> do_query($query);
		$comma = 0;
		$output = "Birthday Private Messages Sent to ";

		while (list($bdayname,$bdaynumber) = $dbh -> fetch_array($sth) ) {
			$bdaynumber_q = addslashes($bdaynumber);
			
			// Put the message into the Messages table
			$query = " 
    			INSERT INTO {$config['tbprefix']}Messages (M_Uid,M_Status,M_Subject,M_Sender,M_Message,M_Sent)
    			VALUES ('$bdaynumber_q','N','$pmsubject_q','$pmfrom_q','$pmbody_q','$date')
			"; 
			$dbh -> do_query($query);

			// Up Their Private Message Count by 1
			$query = " 
    			UPDATE {$config['tbprefix']}Users
    			SET U_Privates = U_Privates+1
				WHERE U_Number = '$bdaynumber_q'
			"; 
			$dbh -> do_query($query);

			if ($comma) {
				$output .= ", ";
			}

			$comma++;
			$output .= "$bdayname";					
	
		} //end of loop
	   
		$dbh -> finish_sth($sth);
		$output .= ".  ";
} // end of PM operation


//--------------------------------------------------
// If we are makeing a post we do it here
if (($hownotify == 2) || ($hownotify == 3)) {
	
	$bdayname = "";
	$bdaynumber = "";

	// Lets get the Users who are celebrating a birthday today
		$query = "
			SELECT U_Username, U_Number
	      FROM   {$config['tbprefix']}Users
         WHERE  U_Birthday LIKE '$month/$day/%'
         AND U_ShowBday = 1
	      ORDER BY U_Username	       	
		";
    	$sth = $dbh -> do_query($query);
		$comma = 0;

		while (list($bdayname,$bdaynumber) = $dbh -> fetch_array($sth) ) {
		// Lets list the names linking to profiles and put commas between them
			if ($comma) {
				$todaysbdays .= ", ";
			}
	
			$comma++;
			$todaysbdays .= "<a href=\"{$config['phpurl']}/showprofile.php?User=$bdaynumber\" target=\"_blank\">$bdayname</a>";					
		}
	   
		$dbh -> finish_sth($sth);

		if ($comma) {
		// Cheesy reuse of $comma to indicate that there are rows to process
		// Let's build the body of the Post
			$postbody = $postbody1;
			$postbody .= $todaysbdays;
			$postbody .= $postbody2;
			$postbody_q = addslashes($postbody);
	
		// Lets put the post into the database
			$query = "
				INSERT INTO {$config['tbprefix']}Posts (B_Board,B_Parent,B_Posted,B_Last_Post,B_Subject,B_Body,B_Kept,B_Status,B_Approved,B_Icon,B_Reged,B_Replies,B_Topic,B_Convert,B_PosterId,B_Sticky)
				VALUES ('$boardkeyword_q','0','$date','$date','$postsubject_q','$postbody_q','','O','yes','$posticon_q','y','0','1','both','$postfrom_q','0')
	   	";
	   	$dbh -> do_query($query);

		// Now we need to find out what the last post number was
			$query = "
	   		SELECT last_insert_id()
	   	";
	   	
			$sth = $dbh -> do_query($query);
	   	
			list ($PostNumber) = $dbh -> fetch_array($sth);
		
		// Now we need to update the Main number
			$query = "
       		UPDATE {$config['tbprefix']}Posts 
				SET    B_Main   = '$PostNumber'
        		WHERE  B_Number = '$PostNumber'
      	";

			$dbh -> do_query($query);

		// Now we need to update the last post and board info
			$query = "
        		UPDATE {$config['tbprefix']}Boards 
	        	SET		Bo_Total   = Bo_Total + 1,
		     				Bo_Last    = $date,
							Bo_Posterid = '$postfrom_q',
	    		   		Bo_LastNumber = '$PostNumber',
	    					Bo_LastMain   = '$PostNumber',
       					Bo_Threads = Bo_Threads + 1
	        	WHERE		Bo_Keyword = '$boardkeyword_q'
      ";

      $dbh -> do_query($query);
	
		$output .= "A post has also been made to the board: $boardkeyword.";
	} // end if($comma)
} // end of Post operation

echo $output;
?>

Geplaatst: 26 jan 2005, 14:19
door XP-Rene
Kijk hier eens, er staan er 3 onder elkaar, kies maar uit zou ik zeggen:
http://www.phpbbhacks.com/searchresults ... rch_type=1

Geplaatst: 26 jan 2005, 14:50
door Hacktor
Had ik al gekeken maar een CRON functie voor PHPBB staat er niet bij....

Geplaatst: 26 jan 2005, 15:52
door Bee
Wat ik opmaak uit je OP, wil je een mailtje versturen naar iemand als hij jarig is. Het is overbodig om daarvoor een Cron actie te starten, een uitbreiding voor de mod, zoals XP-rene heeft gegeven is dan voldoende :roll: