#!/usr/bin/perl # this script runs through the various bible verses daily # (incrementing number.txt) and mails em out. require '/usr/home/fso/libs/fso-g-lib.pl'; require '/usr/home/em/libs/em-defs.pl'; require '/usr/home/em/libs/em-g-lib.pl'; use Date::Manip; use File::Copy; ### AS use rlib '../../../mod-lib'; use rlib '../../../../dntk/mod-lib'; use di; use dntk; my $dntk = new dntk; use Text::Wrap qw($columns wrap); $columns = 55; # TOP_DIR hack $TOP_DIR = "${TOP_DIR}/voa"; $lyris::config_filename = "/opt/lyris/cgi/lyris.plc"; my $rc = &lyris::init; $| = 1; $DEBUG = 1; $N_DATE = &UnixDate('today', '%m-%d-%Y'); #$N_DATE = "04-11-02"; #$AD_DATE = "2002-04-11"; $BIBLE_TYPE{ASV} = "American Standard Version"; $BIBLE_TYPE{KJV} = "King James Version"; $BIBLE_TYPE{NAS} = "New American Standard"; $BIBLE_TYPE{NIV} = "New International Version"; $BIBLE_TYPE{NKJ} = "New King James Version"; $LIST = "bibleverses"; $CONTENT = "$TOP_DIR/$LIST/verses/combined"; $REPLYTO = "bv-text-reply\@DailyInbox.com"; $OURMAIL = "bv-text\@DailyInbox.com"; $BASE = "$SYSURL/daily"; $LAST_MAILED_CONTENT = "last.mailed.bv.txt"; # name of file where last send is kept $CHECK_FOR_DUPS = 1; # set it to prevent a dup submission from going through $SUBJECT = "DailyInbox.com - Bible Verses - $N_DATE"; $NUMBER_FILE = "$TOP_DIR/$LIST/verses/kjv/number.txt"; open(LOG, ">>/opt/bv_send.log"); $date = `/usr/bin/date`; chomp($date); print LOG "\n-----------------------------\nStarting [bv_text.pl] $LIST send run - $date\n"; if ( ! -f $NUMBER_FILE ) { print LOG "Creating number.txt file for the first time.\n"; open(OUT, ">$NUMBER_FILE") or failure("EM - $LIST - couldn't open outfile number.txt"); print OUT "1\n"; close(OUT); } open(IN, "<$NUMBER_FILE") or failure("EM - $LIST - couldn't open infile number.txt"); $CURRENT = ; chomp($CURRENT); if ( $CURRENT !~ /\d+/ ) { # chk to make sure we got a digit or a few failure("EM - $LIST - didn't get a valid number from number.txt"); } close(IN); #print "-> NF: $NUMBER_FILE\n"; #exit; print LOG "-> NF: $NUMBER_FILE\n"; print LOG "-> ID: $CURRENT\n"; $NEW = $CURRENT; open(IN, "<$CONTENT/$NEW") or failure("EM - $LIST - couldn't open content file [$CONTENT/$NEW]"); $LINE1 = ; @LINES = ; print LOG "Successfully retrieved content for send.\n"; $SUBJECT = "DailyInBox.com - Bible Verses - $LINE1 - $N_DATE"; open (DAILY, "> $TOP_DIR/daily.txt"); print DAILY "$page \n"; close DAILY; $page .= "______________________________________________________ \n\n"; $page .= "BIBLE VERSES is a free e-mail service from \n"; $page .= "DailyInbox.com and Volunteers of America \n"; $page .= "(http://www.voa.org), a national, nonprofit, \n"; $page .= "spiritually based organization providing local \n"; $page .= "human service programs and the opportunity for \n"; $page .= "individual and community involvement. \n"; $page .= "http://Your.DailyInbox.Com/voa/ \n"; $page .= "______________________________________________________ \n\n"; $page .= "DIB Presents...(http://www.dailyinbox.com/dibpresents.html)\n"; $page .= "puts you within one \"click\" of the best daily inspirational\n"; $page .= "and educational content the Net has to offer.\n"; $page .= "______________________________________________________ \n"; $page .= ""; $page .= "###TARGET_2###\n"; $page .= " ______________________________________________________ \n\n"; $page .= " Today's selection is $LINE1\n"; foreach (@LINES) { if ( /FRONTLET.(.*)/ ) { $first_part = $BIBLE_TYPE{$1}; } else { $bla = wrap('', ' ', $_); $page .= " * $first_part\n $bla\n"; } } $page .= "______________________________________________________ \n\n"; $page .= "As you read today's BIBLE VERSE, consider sending this inspirational \n"; $page .= "service to a friend or family member. Enlighten their day by giving \n"; $page .= "them a FREE subscription at: \n"; $page .= "http://Mailroom.DailyInbox.Com/voa/addFriend.iphtml\n"; $page .= "______________________________________________________ \n\n"; $page .= " Subscribe a Friend: http://MailRoom.DailyInBox.com/voa/f.iphtml \n"; $page .= " You may unsubscribe here: http://DailyInBox.com/voa/unsubscribe.shtml\n"; $page .= " Visit our website: http://DailyInBox.com\n"; $page .= " You are subscribed with: \$subst('Recip.EmailAddr')\n"; $page .= " Mail your unsubscribe request to: \n"; $page .= " DailyInbox\n"; $page .= " P.O. Box 913\n"; $page .= " Wimberley, TX 78676\n"; $page .= "______________________________________________________ \n\n"; ##print $page; ##exit; ### AS my $ad_body = &insert_ads($page, $dntk, $AD_DATE, "bv-text"); $page = $ad_body; #open(OUT, ">$LAST_MAILED_CONTENT"); #print OUT "$page"; #close(OUT); # now submit to lyris $mid = &sendLyrisMail("bv-text", "$SUBJECT", "$REPLYTO", "$OURMAIL", "$page", "txt", "$LIST.html"); #$mid = &sendLyrisMail("bv-text-test", "TEST - $SUBJECT", "$REPLYTO", "$OURMAIL", "$page", "txt", "$LIST.html"); print LOG "Message id: [$mid]\n"; if ( ! $mid ) { print LOG "ERROR: Message inject into lyris for $LIST has failed! [$mid]\n"; `/usr/local/bin/critsit "HTML $LIST [$mid] message into Lyris failed!"`; exit; } print LOG "Not incrementing number [$CURRENT]\n"; print LOG "Done.\n\n"; exit;