[Phpslash-commit] CVS: phpslash-ft/contrib cronmail.php3,1.1,1.2
Brought to you by:
joestewart,
nhruby
From: Joe S. <joe...@us...> - 2002-03-12 12:21:03
|
Update of /cvsroot/phpslash/phpslash-ft/contrib In directory usw-pr-cvs1:/tmp/cvs-serv16635/phpslash-ft/contrib Modified Files: cronmail.php3 Log Message: [ 528861 ] cronmail.php3 that works with 0.65-pre1 Index: cronmail.php3 =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/contrib/cronmail.php3,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** cronmail.php3 23 Nov 2001 18:59:24 -0000 1.1 --- cronmail.php3 12 Mar 2002 12:20:59 -0000 1.2 *************** *** 1,11 **** <?php ! // $Id: ! // TODO: Uses old style semantics. Does not use templates ! // WARNING: DO NOT PUT IN DOC ROOT!! CALL FROM CRON - // Be sure to change this - require("./config.php3"); /////////////////// send_mailing_list.php3 ///////////////////////// function format_mail($str, $char_len, $scrub) { if ($scrub) --- 1,69 ---- + #!/usr/bin/php <?php ! /* ! * $Id$ ! * Last modified: 2002-Mar-12 ! * Luis Mondesi < le...@ho... > ! * ! * NOTE: originally created by ... modified for ! * phpslash 0.65-pre1 by Luis Mondesi ! * ! * USAGE: Run this from a cron job (CGI version of php), ! * even though it should ! * run just fine from your current site root. For as long ! * as you keep in mind that anybody might be able to run this... ! * unless of course, page_open(PERMISSIONS) and page_close() ! * are used to protect the code using PHPLIB's session management ! * routines. ! * This script requires a directory called 'text' parallel to it. ! * This directory should be writable by which ever user runs this ! * cron script, or by whichever user runs your server (if apache's ! * mod_php is used). ! * To run as a cron... ! */ ! // example for cron: ! // 00 */24 * * * php /path/to/cronmail.php3 2>&1 > /dev/null ! /* Basically, send this headlines every 24 hours and don't show ! * any errors please... ! * Another even better option would be to put this file ! * in /etc/cron.daily and make sure you have: ! * #!/path/to/php ! * at the beginning of this script ! * ! * that's all... ! * ! * ! * There is no need to touch anything in this script. All your ! * customizations should be done in your current config.php3 ! * You should put a .htaccess file in the directory from which ! * this is going to run containing the following customization ! * options (for PHP 4.x and up): ! * ! * php_flag magic_quotes_gpc Off ! * php_value include_path ".:/path/to/phplib:/path/to/phpslash" ! * #optional: ! * #php_value disable_functions phpinfo,readfile,system ! * #optional: do not report errors : ~E_ALL ! * #php_value error_reporting E_ALL ! * ! * Do they look familiar? basically it's the same set of ! * options that you might be using for phpslash... ! * ! * TODO: template this baby! :-) ! */ ! ! require_once("prepend.php3"); ! require_once("config.php3"); ! ! // variable initialization (do not modify) ! $str_out = ""; ! $freqoverride = 0; ! $errors = array(); ! $row = array(); ! $sql = ""; /////////////////// send_mailing_list.php3 ///////////////////////// + if (!function_exists('format_mail')) { function format_mail($str, $char_len, $scrub) { if ($scrub) *************** *** 35,41 **** return $str_out; } ! function build_body($offset) { ! $slash_q = new slashDB; --- 93,99 ---- return $str_out; } ! }//end if not function_exists function build_body($offset) { ! global $_PSL; $slash_q = new slashDB; *************** *** 49,63 **** $enddate = date("Y-m-d H:i:s", mktime(0,0,0,$emonth,$eday + 1,$eyear)); ! $sql="SELECT sid, title, dept, aid, time, introtext FROM stories ! WHERE time >= '$begdate' AND time <= '$enddate' ORDER BY time desc"; $slash_q->query($sql); ! $site = "yourdamnsite.com"; while($slash_q->next_record()) { $headline = $slash_q->Record["title"] . "\n"; $headline .= " From the: \"" . $slash_q->Record["dept"] . "\" dept.\n"; ! $headline .= " Posted by: \"" . $slash_q->Record["aid"] . "\" on: " . $slash_q->Record["time"] . "\n"; ! $headline .= " Story: " . format_mail($slash_q->Record["introtext"],76,True) . "\n"; ! $headline .= " $site" . "article.php3?sid=" . $slash_q->Record["sid"] . "\n"; $headline .= "---------------------------------------------------------------------------------------------\n\n"; $headline = stripslashes($headline); --- 107,124 ---- $enddate = date("Y-m-d H:i:s", mktime(0,0,0,$emonth,$eday + 1,$eyear)); ! $sql="SELECT story_id, title, dept, user_id, time, ". ! " intro_text, author_name, author_id FROM psl_story, psl_author ". ! " WHERE psl_story.time >= '$begdate' AND psl_story.time <= '$enddate' ". ! " AND psl_story.user_id = psl_author.author_id ". ! " ORDER BY time desc"; $slash_q->query($sql); ! $site = $_PSL["rooturl"]; while($slash_q->next_record()) { $headline = $slash_q->Record["title"] . "\n"; $headline .= " From the: \"" . $slash_q->Record["dept"] . "\" dept.\n"; ! $headline .= " Posted by: \"" . $slash_q->Record["author_name"] . "\" on: " . $slash_q->Record["time"] . "\n"; ! $headline .= " Story: " . format_mail($slash_q->Record["intro_text"],76,True) . "\n"; ! $headline .= " $site" . "/article.php3?story_id=" . $slash_q->Record["story_id"] . "\n"; $headline .= "---------------------------------------------------------------------------------------------\n\n"; $headline = stripslashes($headline); *************** *** 102,109 **** else { $sql .= "SELECT email, name, dayback, frequency "; ! $sql .= "FROM mailing_list, mailing_frequency "; ! $sql .= "WHERE mailing_list.id = mailing_frequency.id "; ! $sql .= "AND (mailing_frequency.frequency='" . date("l") . "' "; ! $sql .= "OR mailing_frequency.frequency = 'DAY' "; if (date("d") == 1) $sql .= "OR mailing_frequency.frequency = 'MONTH' "; $sql .= ") ORDER BY dayback, mailing_frequency.frequency"; --- 163,170 ---- else { $sql .= "SELECT email, name, dayback, frequency "; ! $sql .= "FROM psl_mailinglist, psl_mailinglist_frequency "; ! $sql .= "WHERE psl_mailinglist.id = psl_mailinglist_frequency.id "; ! $sql .= "AND (psl_mailinglist_frequency.frequency='" . date("l") . "' "; ! $sql .= "OR psl_mailinglist_frequency.frequency = 'DAY' "; if (date("d") == 1) $sql .= "OR mailing_frequency.frequency = 'MONTH' "; $sql .= ") ORDER BY dayback, mailing_frequency.frequency"; *************** *** 111,121 **** // $db_results = mysql_query($sql, $slash_q) or die(mysql_error()); ! $link = mysql_connect("location","Dbname","password"); ! $db_results = mysql("databse","SELECT email, name, dayback, frequency ! FROM mailing_list, mailing_frequency ! WHERE mailing_list.id = mailing_frequency.id ! AND (mailing_frequency.frequency = 'DAY' ! OR mailing_frequency.frequency = 'DAY') ! ORDER BY dayback, mailing_frequency.frequency;",$link); ignore_user_abort(); --- 172,182 ---- // $db_results = mysql_query($sql, $slash_q) or die(mysql_error()); ! $link = mysql_pconnect($_PSL['DB_Host'],$_PSL['DB_User'],$_PSL['DB_Password']); ! $db_results = mysql_db_query($_PSL['DB_Database'],"SELECT email, name, dayback, frequency ! FROM psl_mailinglist, psl_mailinglist_frequency ! WHERE psl_mailinglist.id = psl_mailinglist_frequency.id ! AND (psl_mailinglist_frequency.frequency = 'DAY' ! OR psl_mailinglist_frequency.frequency = 'DAY') ! ORDER BY dayback, psl_mailinglist_frequency.frequency",$link); ignore_user_abort(); *************** *** 123,127 **** $tmpDay = ''; ! $sender = "who...@yo..."; while($row = mysql_fetch_row($db_results)) { set_time_limit(SLEEP + 30); --- 184,188 ---- $tmpDay = ''; ! $sender = preg_replace("/(.*)\@.*/i","noreply",$_PSL['site_owner']); while($row = mysql_fetch_row($db_results)) { set_time_limit(SLEEP + 30); *************** *** 148,152 **** //echo "\nTO: $row[0] Name: $row[1] DayBack: $row[2] Freq: $row[3]"; } ! $subject="Headlines For You"; if(mail($row[0], $subject, "Dear " . $row[1] . ",\n\n" . $header . "\n\n" . $body . "\n\n" . $footer, "From: " . $sender)) echo "\n" . $row[0] . "... sent"; --- 209,213 ---- //echo "\nTO: $row[0] Name: $row[1] DayBack: $row[2] Freq: $row[3]"; } ! $subject=$_PSL['mailinglist_subject']; if(mail($row[0], $subject, "Dear " . $row[1] . ",\n\n" . $header . "\n\n" . $body . "\n\n" . $footer, "From: " . $sender)) echo "\n" . $row[0] . "... sent"; |