= 4.2.3 # 2) You must have a mail server running on the machine this script # is installed on. # #INSTALLATION: # 1) Set the path to the "require" statement belowif you do not keep all your files # in the same directory. # 2) Set the values located in the "MailListConfigs_basic.php" # file. ALL VALUES SHOULD BE ENCLOSED IN QUOTES. # 3) Complete the "installation" section of the file "MailListAdmin_basic.php". # #RUNNING: # 1) The link to print the "Subscribe" form to your users is: # http://www.yourdomain.com/scripts/MailList_basic.php # #ADDITIONAL FEATURES AVAILABLE IN THE ADVANCED VERSION # 1) Providing the Unsubscribe form to allow users to automatically unsubscribe # from the list. # 2) Mail confirmation unsubscribe email to the user requesting to be removed. # 3) Unsubscribing the user from the list if they click on the link within their confirmation email. # 4) Support for multiple lists # #More details can be found at http://www.davelozinski.com/scripts/ # #WHERE/HOW TO PURCHASE THE ADVANCED VERSION # http://www.davelozinski.com/scripts # #LICENSE: # You are free to further develop/modify the source code to fit your #needs, but you MAY NOT resell and/or redistribute the source code in any #way, manner, fashion, or form without my hand-written consent! # # This license grants the purchaser of this archive the permission to #have an unlimited number of users use this script at any time. #Likewise, the purchaser may have any number of copies of this script as long #as the media that this program resides on or run from is owned by the purchaser. #If not, more licenses MUST be purchased. # #Examples: # 1) If you have your own webserver hosting your various customers, you only need once license #to run the code on your webserver to provide the email functionality to your clients hosted on your server. # 2) If you are designing websites for 3 individual clients, each of which wants the email functionality, #and each of which will be hosting their websites and emailer on their own server, #then you need to purchase 3 licenses. # #If you modify the source code in anyway for your own purposes, the #original header-comments must remain intact. # #REVISION HISTORY: # 3.00 07/31/04 Updated with advanced script. # 2.10 07/04/04 Updated with advanced script. # 2.00 04/12/03 Functionality improved. # 1.01 06/18/02 Corrected a Mail formatting issue # 1.00 03/01/02 Original Version # #CONTACT INFORMATION: # http://www.davelozinski.com/cgi-bin/email_lozinski.pl # require(preg_replace("/\w+\.php$/","",preg_replace("/" . preg_quote("\\\\") . "/","/",$_SERVER["PATH_TRANSLATED"])) . "MailListConfigs_basic.php"); ################################ #NOTHING BELOW THIS LINE SHOULD NEED TO BE CONFIGURED ################################ #Done to distinguish between a Windows OS and other OS. Windows requires #a \r\n for mail and to write to files. Other OS's only require the \n. if (preg_match("/^WIN/i",PHP_OS)) { define ("NEWLINE", "\r\n"); } else { define ("NEWLINE", "\n"); } if (array_key_exists ("a", $_REQUEST)) { $a = $_REQUEST["a"]; } else { $a = 9; } if (array_key_exists ("e", $_REQUEST)) { $e = $_REQUEST["e"]; } else { $e = ""; } $AnError = 0; $ErrorMessage = ""; $Title = ""; $Admin_Email = ""; $Email_Admin_With_List_Update = 0; $Mail_Subscribe_Thank_You_Letter = 0; $Send_HTML_Format = 0; $Mail_List_Data_File = ""; $msg_body = ""; $subject = ""; $datestring = ""; $mailheaders = ""; $localtime = array(); $localtime = localtime(time(),1); $found = 0; $output = ""; $fp = ""; $Title_String = "Mailing List "; if (is_numeric($a)) { $a = (int) $a; #0 - Print subscribe form if ($a>2 || $a<0) { #1 - Mail confirmation subscribe email $a = 0; #2 - Subscribe to list } } else { $a = 0; } if (($a==1 || $a==2) && (strcmp($e,"") == 0)) { $AnError = 1; $ErrorMessage = "

You need to provide your email address.

\n"; } elseif (($a==1) && ! IsValidEmailAddress($e)) { $AnError = 1; $ErrorMessage = "

You need to provide a valid email address.

\n"; } elseif (($a==2) && ! IsValidEmailAddress(base64_decode($e))) { $AnError = 1; $ErrorMessage = "

You need to provide a valid email address.

\n"; } if (!$AnError) { $Title = $C_TITLE; $Admin_Email = $C_ADMIN_EMAIL; $Email_Admin_With_List_Update = $C_EMAIL_ADMIN_WITH_LIST_UPDATE; $Mail_Subscribe_Thank_You_Letter = $C_MAIL_SUBSCRIBE_THANK_YOU_LETTER; $Send_HTML_Format = $C_SEND_HTML_FORMAT; $Mail_List_Data_File = $C_MAIL_LIST_DATA_FILE; $Title_String .= "for: \"" . $Title . "\"\n"; } ?> <?=$Title_String?> " . $subject . "
" . NEWLINE; $msg_body .= "You are receiving this email because your email address was submitted to "; $msg_body .= "subscribe to: "; $msg_body .= NEWLINE . "\"" . $Title . "\"." . NEWLINE . "

To confirm, click on the link below. "; $msg_body .= "if you cannot, copy and paste the URL into your browser. Thank you!

" . NEWLINE . NEWLINE; $msg_body .= "" . $SCRIPT_URL . "?a=2&e=" . urlencode(base64_encode($e)); $msg_body .= "

" . NEWLINE . "" . NEWLINE . NEWLINE; if (mail(stripslashes($e), $subject, $msg_body, $mailheaders)) { echo ("

Thank you! A confirmation email has been sent to \"" . $e . "\".

\n"); echo ("You need to click on the URL (or copy and paste it into your browser) to confirm your selection.

\n"); } else { echo ("

An error occurred and a confirmation email could not be sent to \"" . $e . "\".

\n"); echo ("If the problem persists, please contact " . $Admin_Email . ". Thank you!

\n"); } } elseif ($a == 2) { # Subscribe to the list $error = 0; if (file_exists($Mail_List_Data_File) && !(filesize($Mail_List_Data_File) == 0)) { if ( $fp = file ($Mail_List_Data_File, "r") ) { while (!$found && list ($num,$line) = each ($fp)) { list ($email,$date) = preg_split("/\|/", $line); if (strcmp($email,base64_decode($e)) == 0) { $found = 1; } } } else { echo ("

An error occurred. The user data file could not be opened for reading. \n"); echo ("If you continue to experience problems, please email " . $Admin_Email . ". Thank you!

\n"); $error = 1; ###So we don't go into the appending section } } else { $found = 0; } if (!$error) { if ( !$found ) { if ($fp = fopen ($Mail_List_Data_File, "a") ) { flock ($fp,LOCK_EX); fwrite($fp,base64_decode($e) . "|"); $datestring = sprintf("%04d",$localtime["tm_year"] +1900) . "-"; $datestring .= sprintf("%02d",$localtime["tm_mon"] + 1) . "-"; $datestring .= sprintf("%02d",$localtime["tm_mday"]); fwrite($fp, $datestring . NEWLINE); flock ($fp,LOCK_UN); fclose ($fp); if ($Email_Admin_With_List_Update) { EmailAdmin($datestring); } echo ("

Thank you! You are now subscribed to: " . $Title . "

\n"); if ($Mail_Subscribe_Thank_You_Letter) { $mailheaders = "From: " . $Admin_Email . NEWLINE . "Reply-to: " . $Admin_Email . NEWLINE; $subject = "Thank you for subscribing to: " . $Title; $msg_body = "Thank you for subscribing to " . $Title . "!" . NEWLINE. NEWLINE; if (!mail(stripslashes(base64_decode($e)), stripslashes($subject), $msg_body, $mailheaders)) { echo ("

An error occurred and a confirmation email could not be sent to \"" . base64_decode($e) . "\".

\n"); echo ("If the problem persists, please contact " . $Admin_Email . ". Thank you!

\n"); } } } else { echo ("

An error occurred, and your confirmation could not be saved. Please try again. \n"); echo ("If you continue to experience problems, please email " . $Admin_Email . ". Thank you!

\n"); } } else { #already in the list echo("

You have already subscribed to \"" . $Title . "\".

\n"); } } } else { #Print the subscribe form by default ?>

: Subscribe

Enter your email address below. A confirmation email will be sent to your email address.




An error occurred. Please notify " . $Admin_Email . ". Thank you!\n"); } } ################################ ?>