Need help integrating function in a form (PHP?) | Newbie | | Join Date: Jun 2008
Posts: 3
| |
Hello! I just want to start with saying that i hope i'm asking the question in the right part of the forum. Maybe it should have been in the PERL section or some other section? Feel free to move the thread if this is so.
To the Q:
I have a simple contact-form in my website that looks like this: - <FORM action=http://www.domain.com/cgi-bin/FormMail.pl method=post><INPUT type=hidden value=info@domain.com name=recipient> <INPUT type=hidden value=kontakt@domain.com name=subject> <INPUT type=hidden value=http://www.domain.com/english/thanx.html name=redirect>
-
-
Name <INPUT size=50 name=Name><BR>
-
-
<P></P>E-mail <INPUT size=30 name=email><BR> <BR>
-
-
<P>Message: <BR><TEXTAREA name=Meddelande rows=7 cols=50></TEXTAREA></P>
-
</SELECT>
-
-
<P></P>
-
-
<P><INPUT type=submit value=Send! name=skicka> <INPUT type=reset value="Clear .." name=rensa></P></FORM>
As you see, I'm using the mailscript "FormMail.pl" that is provided by my host.
I also use a mailinglist on my site. The mailinglist i use is called "Listmessenger" and works well for me. The code i use to integrate listmessenger on the webpage looks like this: -
<form action="http://www.domain.com/listmessenger/public/listmessenger.php" method="post">
-
-
<input type="text" name="email_address" value="" maxlength="128">
-
-
<select name="action">
-
<option value="subscribe">Subscribe</option>
-
<option value="unsubscribe">Unsuscribe</option>
-
-
</select>
-
<input type="hidden" name="group_ids[]" value="2" />
-
<input type="submit" value="Send" />
-
-
</form>
What i would like to do is to put a " checkbox" on the first form that if checked would also subscribe people to the mailinglist (send the "name" and "e-mail" part of the first form to "listmessenger.php" with the appropiate information that is in the second form").
Something like this maybe: -
<INPUT TYPE=CHECKBOX NAME="maillist">Yes! Put me on the list!<P>
-
I have to emphasize that i do not know alot of programing.
I know superbasic HTML/CSS and can do simple adjustments to already made PHP code, so if anybody sees a simple solution i would be really greatful.
Thanx for reading
/Daniel
|  | Moderator | | Join Date: Jun 2007 Location: York, England, with wolves.
Posts: 4,949
| | | re: Need help integrating function in a form (PHP?)
Welcome to the forum, Daniel!
First off, I'd like to mention writing html elements in UPPERCASE is no-longer acceptable! lowercase is the way we do it. :) Anotherthing, when you assign a value to an attribute, you always use quotes. name="name" value="yes".
On to the PHP:
You could simply add an IF conditional check to see if the checkbox was.. checked - alot of checks in this here sentence. Anyway, here's an example.
[php]
# add to mailinglist
if( isset ( $_POST['maillist'] ) )
{
# we'll need to do some database work here
$query = "INSERT INTO `tbl_name` ('name', 'email') VALUES ('{$_POST['escaped_name']}', '{$_POST['escaped_email']}')";
# do the actual query
$query = mysql_query($query) or die(mysql_error());
# check if query ran
if($query)
{
# email inserted
}
else
{
# wasnt inserted - problem.
}
}
[/php]
Let me know if you need some further help!
| | Newbie | | Join Date: Jun 2008
Posts: 3
| | | re: Need help integrating function in a form (PHP?)
Hello markus!
Thank you for replying to my request and sorry for not coming with feedback sooner.... You pointers are really helpfull btw....
Im sorry for beeing such a super-beginner but I really can't wrap my head around how to apply the code you suggested...and work further on it....
Are you thinking i should put the code inside of "mailinglist.php" or should i make my "contact.html" into a php and aply the checking-php-code there...?
Also the database work you are refering to..... *blushing*
As you see im really kind of lost but i do want to learn....so if you have the patience im really grateful....
The page i want to put the "checkbox" on is this one:
http://www.telluskultur.se/english/kontakt.html
Thanx
/Danielo
|  | Moderator | | Join Date: Jun 2007 Location: York, England, with wolves.
Posts: 4,949
| | | re: Need help integrating function in a form (PHP?) Quote:
Originally Posted by livingreality2012 Hello markus!
Thank you for replying to my request and sorry for not coming with feedback sooner.... You pointers are really helpfull btw....
Im sorry for beeing such a super-beginner but I really can't wrap my head around how to apply the code you suggested...and work further on it....
Are you thinking i should put the code inside of "mailinglist.php" or should i make my "contact.html" into a php and aply the checking-php-code there...?
Also the database work you are refering to..... *blushing*
As you see im really kind of lost but i do want to learn....so if you have the patience im really grateful....
The page i want to put the "checkbox" on is this one:
http://www.telluskultur.se/english/kontakt.html
Thanx
/Danielo Do not apologise! Everyone's been there.
So, listmessenger.php is the target file!
If you would like to post that file to this thread (use code tags) I will help you on inserting the code.
Kind regards.
| | Newbie | | Join Date: Jun 2008
Posts: 3
| | | re: Need help integrating function in a form (PHP?)
Hi again! Thanks for being so helpful.
Here comes the listmessenger.php code...
Quite alot of it.. - <?php
-
/*
-
ListMessenger - Professional Mailing List Management
-
Copyright © 2005 Silentweb [http://www.silentweb.ca]
-
-
Developed By: Matt Simpson <msimpson@listmessenger.com>
-
-
For the most recent version, visit the ListMessenger website:
-
[http://www.listmessenger.com]
-
-
License Information is found in docs/licence.html
-
$Id: Exp $
-
*/
-
-
// Change the $LM_PATH variable in the eu_config.inc.php file in this directory.
-
require_once("./public_config.inc.php");
-
-
if(!@file_exists($LM_PATH."includes/config.inc.php")) {
-
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n";
-
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n";
-
echo "<head>\n";
-
echo " <title>ListMessenger Path Error</title>\n";
-
echo " <style>\n";
-
echo " table.error-table {\n";
-
echo " width: 60%;\n";
-
echo " background-color: #FFD9D0;\n";
-
echo " border: 1px #CC0000 solid;\n";
-
echo " padding: 5px\n";
-
echo " }\n\n";
-
echo " td.error-text {\n";
-
echo " color: #000000;\n";
-
echo " font-family: Verdana, Arial, Helvetica, sans-serif;\n";
-
echo " font-size: 11px;\n";
-
echo " padding-right: 5px\n";
-
echo " }\n";
-
echo " </style>\n";
-
echo "</head>\n";
-
echo "<body>\n";
-
echo "<table cellspacing=\"1\" cellpadding=\"2\" border=\"0\" class=\"error-table\">\n";
-
echo "<tr>\n";
-
echo " <td class=\"error-text\">\n";
-
echo " The path to the ListMessenger directory that you've provided [<b>".$LM_PATH."</b>] appears to be invalid or PHP does not have permission to read files from this directory. Please ensure that you provide the full path from root to your ListMessenger program directory in the \$LM_PATH variable within this file [<b>".__FILE__."</b>].";
-
echo " </td>\n";
-
echo "</tr>\n";
-
echo "</table>\n";
-
echo "</body>\n";
-
echo "</html>\n";
-
exit;
-
} else {
-
@ini_set("include_path", str_replace("\\", "/", $LM_PATH."/includes"));
-
@ini_set("allow_url_fopen", 1);
-
@ini_set("error_reporting", E_ALL ^ E_NOTICE);
-
@ini_set("magic_quotes_runtime", 0);
-
-
define("TOOLS_LOADED", true);
-
require_once("eu_header.inc.php");
-
-
if(!$ERROR) {
-
// Recognized actions for this file. (subscribe || unsubscribe)
-
switch($info["action"]) {
-
// SUBSCRIBE
-
case "subscribe" :
-
// Error checking for group information.
-
if(((@is_array($info["group_ids"])) && (@count($info["group_ids"]) < 1)) || (trim($info["group_ids"]) == "") || (!str_is_int(trim($info["group_ids"])))) {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_subscribe_no_groups"];
-
} else {
-
$groups = array();
-
-
if(@is_array($info["group_ids"])) {
-
foreach($info["group_ids"] as $group_id) {
-
$query = "SELECT `group_name` FROM `".TABLES_PREFIX."groups` WHERE `groups_id`='".checkslashes($group_id)."'";
-
$result = $db->GetRow($query);
-
if($result) {
-
$query = "SELECT `users_id` FROM `".TABLES_PREFIX."users` WHERE `group_id`='".checkslashes($group_id)."' AND `email_address`='".checkslashes(trim(strtolower($info["email_address"])))."'";
-
$result = $db->GetRow($query);
-
if((!$result) && (!@in_array($group_id, $groups))) {
-
$groups[] = $group_id;
-
}
-
} else {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_subscribe_group_not_found"];
-
}
-
}
-
if((!$ERROR) && (@count($groups) < 1)) {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_subscribe_email_exists"];
-
}
-
} else {
-
if(trim($info["group_ids"]) != "") {
-
$query = "SELECT `group_name` FROM `".TABLES_PREFIX."groups` WHERE `groups_id`='".checkslashes(trim($info["group_ids"]))."'";
-
$result = $db->GetRow($query);
-
if($result) {
-
$query = "SELECT `users_id` FROM `".TABLES_PREFIX."users` WHERE `group_id`='".checkslashes(trim($info["group_ids"]))."' AND `email_address`='".checkslashes(trim(strtolower($info["email_address"])))."'";
-
$result = $db->GetRow($query);
-
if($result) {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_subscribe_email_exists"];
-
} else {
-
$groups[] = checkslashes(trim($info["group_ids"]));
-
}
-
} else {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_subscribe_group_not_found"];
-
}
-
}
-
}
-
}
-
-
// Error checking for e-mail address information.
-
if((!$info["email_address"]) || (trim($info["email_address"]) == "")) {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_subscribe_no_email"];
-
} else {
-
if(!valid_address(trim($info["email_address"]))) {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_subscribe_invalid_email"];
-
} else {
-
if(@in_array(trim(strtolower($info["email_address"])), $config[ENDUSER_BANEMAIL])) {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_subscribe_banned_email"];
-
} else {
-
$address = explode("@", trim(strtolower($info["email_address"])));
-
if(@in_array($address[1], $config[ENDUSER_BANDOMS])) {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_subscribe_banned_domain"];
-
} else {
-
if($config[ENDUSER_MXRECORD] == "yes") {
-
if((@getmxrr($address[1].".", $mxhosts) == false) && (@gethostbyname($address[1].".") == $address[1].".")) {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_subscribe_invalid_domain"];
-
}
-
}
-
}
-
}
-
}
-
}
-
-
// Error checking for custom field information.
-
$query = "SELECT `field_sname`, `field_lname`, `field_req` FROM `".TABLES_PREFIX."cfields` ORDER BY `field_order` ASC";
-
$results = $db->GetAll($query);
-
if($results) {
-
$custom_data = array();
-
foreach($results as $result) {
-
$field_completed = true;
-
-
if(isset($info[$result["field_sname"]])) {
-
if(@is_array($info[$result["field_sname"]])) {
-
if(@count($info[$result["field_sname"]]) > 0) {
-
$custom_data[$result["field_sname"]] = checkslashes(html_encode(implode(", ", $info[$result["field_sname"]])));
-
} else {
-
$field_completed = false;
-
}
-
} else {
-
if(strlen(trim($info[$result["field_sname"]])) > 0) {
-
$custom_data[$result["field_sname"]] = checkslashes(html_encode($info[$result["field_sname"]]));
-
} else {
-
$field_completed = false;
-
}
-
}
-
} else {
-
$field_completed = false;
-
}
-
-
if(($result["field_req"] == "1") && (!$field_completed)) {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = str_replace("[cfield_name]", $result["field_lname"], $language_pack["error_subscribe_required_cfield"]);
-
}
-
-
}
-
}
-
if(!$ERROR) {
-
if($config[ENDUSER_SUBCON] == "yes") {
-
$result = users_queue(trim($info["email_address"]), html_encode(trim($info["firstname"])), html_encode(trim($info["lastname"])), $groups, $custom_data, "usr-subscribe");
-
if($result) {
-
@ini_set("sendmail_from", $config[PREF_ERREMAL_ID]);
-
-
$mail = new PHPMailer();
-
$mail->PluginDir = $LM_PATH."includes/classes/phpmailer/";
-
$mail->SetLanguage("en", $LM_PATH."includes/classes/phpmailer/language/");
-
-
switch($config[PREF_MAILER_BY_ID]) {
-
case "mail" :
-
$mail->IsMail();
-
break;
-
case "smtp" :
-
$mail->IsSMTP();
-
$mail->Host = $config[PREF_MAILER_BY_VALUE];
-
$mail->SMTPAuth = $config[PREF_MAILER_AUTH_ID];
-
if($mail->SMTPAuth) {
-
$mail->Username = $config[PREF_MAILER_AUTHUSER_ID];
-
$mail->Password = $config[PREF_MAILER_AUTHPASS_ID];
-
}
-
$mail->SMTPKeepAlive = true;
-
break;
-
case "sendmail" :
-
$mail->IsSendmail();
-
$mail->Sendmail = $config[PREF_MAILER_BY_VALUE];
-
break;
-
}
-
-
$mail->Priority = 3; // Normal
-
$mail->CharSet = $config[PREF_DEFAULT_CHARSET];
-
$mail->Encoding = "8bit";
-
$mail->WordWrap = $config[PREF_WORDWRAP];
-
-
$mail->From = $config[PREF_FRMEMAL_ID];
-
$mail->FromName = $config[PREF_FRMNAME_ID];
-
-
$mail->Sender = $config[PREF_ERREMAL_ID];
-
-
$mail->AddReplyTo($config[PREF_RPYEMAL_ID], $config[PREF_FRMNAME_ID]);
-
-
$mail->AddCustomHeader("X-ListMessenger-Version: ".VERSION_TYPE." [".VERSION_INFO."]");
-
$mail->AddCustomHeader("X-ListMessenger-ID: ".urlencode($config[REG_SERIAL]));
-
$mail->AddCustomHeader("X-Originating-IP: ".$_SERVER["REMOTE_ADDR"]);
-
-
$mail->Subject = $language_pack["subscribe_confirmation_subject"];
-
$mail->Body = str_replace(array("[name]", "[url]", "[abuse_address]", "[from]"), array(checkslashes(trim($info["firstname"]), 1), ($config[PREF_PUBLIC_URL].$config[ENDUSER_CONFIRM_FILENAME]."?id=".$result["confirm_id"]."&code=".$result["hash"]), $config[PREF_ABUEMAL_ID], $config[PREF_FRMNAME_ID]), $language_pack["subscribe_confirmation_message"]);
-
-
$mail->ClearAddresses();
-
-
if(strlen(trim($info["firstname"])) > 1) {
-
$senders_name = checkslashes(trim($info["firstname"]), 1).((strlen(trim($info["lastname"])) > 1) ? " ".checkslashes(trim($info["lastname"]), 1) : "");
-
} else {
-
$senders_name = trim($info["email_address"]);
-
}
-
$mail->AddAddress(trim($info["email_address"]), $senders_name);
-
-
if(@$mail->Send()) {
-
$TITLE = $language_pack["success_subscribe_optin_title"];
-
$MESSAGE = $language_pack["success_subscribe_optin_message"];
-
} else {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_subscribe_failed_optin"];
-
-
$query = "DELETE FROM `".TABLES_PREFIX."confirmation` WHERE `confirm_id`='".$result["confirm_id"]."';";
-
if(!$db->Execute($query)) {
-
if($config[PREF_ERROR_LOGGING] == "yes") {
-
@error_log(display_date("r", time())."\t".__FILE__." [Line: ".__LINE__."]\tUnable to delete the failed confirmation queue request from the confirmation table. Database server said: ".$db->ErrorMsg()."\n", 3, $config[PREF_PRIVATE_PATH]."logs/error_log.txt");
-
}
-
}
-
if($config[PREF_ERROR_LOGGING] == "yes") {
-
@error_log(display_date("r", time())."\t".__FILE__." [Line: ".__LINE__."]\tUnable to send test message to ".$email_address.". PHPMailer said: ".$mail->ErrorInfo."\n", 3, $config[PREF_PRIVATE_PATH]."logs/error_log.txt");
-
}
-
}
-
-
if($mail->Mailer == "smtp") $mail->SmtpClose();
-
-
$mail->ClearCustomHeaders();
-
-
@ini_restore("sendmail_from");
-
} else {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_subscribe_email_exists"];
-
-
if($config[PREF_ERROR_LOGGING] == "yes") {
-
@error_log(display_date("r", time())."\t".__FILE__." [Line: ".__LINE__."]\tUnable to add a new subscriber to the confirmation queue. The subscriber is already present in all groups.\n", 3, $config[PREF_PRIVATE_PATH]."logs/error_log.txt");
-
}
-
}
-
} else {
-
$result = users_add(trim($info["email_address"]), html_encode(trim($info["firstname"])), html_encode(trim($info["lastname"])), $groups, $custom_data);
-
if($result) {
-
$query = "INSERT INTO `".TABLES_PREFIX."confirmation` VALUES ('', '".time()."', 'usr-subscribe', '".addslashes($_SERVER["REMOTE_ADDR"])."', '".addslashes($_SERVER["HTTP_REFERER"])."', '".addslashes($_SERVER["HTTP_USER_AGENT"])."', '".trim($info["email_address"])."', '".html_encode(trim($info["firstname"]))."', '".html_encode(trim($info["lastname"]))."', '".addslashes(serialize($groups))."', '".addslashes(serialize($custom_data))."', '', '0');";
-
$db->Execute($query);
-
-
if($config[ENDUSER_NEWSUBNOTICE] == "yes") {
-
if(!send_notice("subscribe", array("email_address" => trim($info["email_address"]), "groups" => $groups))) {
-
if($config[PREF_ERROR_LOGGING] == "yes") {
-
@error_log(display_date("r", time())."\t".__FILE__." [Line: ".__LINE__."]\tUnable to send new subscriber notice to administrator.\n", 3, $config[PREF_PRIVATE_PATH]."logs/error_log.txt");
-
}
-
}
-
}
-
-
if($result["failed"] > 0) {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_subscribe_failed"];
-
}
-
if($result["success"] > 0) {
-
$TITLE = $language_pack["success_subscribe_title"];
-
$MESSAGE = $language_pack["success_subscribe_message"];
-
}
-
} else {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_subscribe_email_exists"];
-
-
if($config[PREF_ERROR_LOGGING] == "yes") {
-
@error_log(display_date("r", time())."\t".__FILE__." [Line: ".__LINE__."]\tUnable to add a new subscriber to the database. The subscriber is already present in all groups.\n", 3, $config[PREF_PRIVATE_PATH]."logs/error_log.txt");
-
}
-
}
-
}
-
}
-
break;
-
-
// UNSUBSCRIBE
-
case "unsubscribe" :
-
// Error checking for group information.
-
if(((@is_array($info["group_ids"])) && (@count($info["group_ids"]) < 1)) || (trim($info["group_ids"]) == "") || (!str_is_int(trim($info["group_ids"])))) {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_unsubscribe_no_groups"];
-
} else {
-
$groups = array();
-
$subscriber_ids = array();
-
if(@is_array($info["group_ids"])) {
-
foreach($info["group_ids"] as $group_id) {
-
$query = "SELECT `group_name` FROM `".TABLES_PREFIX."groups` WHERE `groups_id`='".checkslashes(trim($group_id))."'";
-
$result = $db->GetRow($query);
-
if($result) {
-
$query = "SELECT `users_id` FROM `".TABLES_PREFIX."users` WHERE `group_id`='".checkslashes(trim($group_id))."' AND `email_address`='".checkslashes(trim(strtolower($info["email_address"])))."'";
-
$result = $db->GetRow($query);
-
if(($result) && (!@in_array($result["users_id"], $subscriber_ids))) {
-
$subscriber_ids[] = $result["users_id"];
-
$groups[] = $group_id;
-
}
-
} else {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_unsubscribe_group_not_found"];
-
}
-
}
-
if((!$ERROR) && (@count($subscriber_ids) < 1)) {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_unsubscribe_email_not_exists"];
-
}
-
} else {
-
if((trim($info["group_ids"]) != "") && (str_is_int($info["group_ids"]))) {
-
$query = "SELECT `group_name` FROM `".TABLES_PREFIX."groups` WHERE `groups_id`='".checkslashes(trim($info["group_ids"]))."'";
-
$result = $db->GetRow($query);
-
if($result) {
-
$query = "SELECT `users_id` FROM `".TABLES_PREFIX."users` WHERE `group_id`='".checkslashes(trim($info["group_ids"]))."' AND `email_address`='".checkslashes(trim(strtolower($info["email_address"])))."'";
-
$result = $db->GetRow($query);
-
if($result) {
-
$subscriber_ids[] = $result["users_id"];
-
$groups[] = checkslashes(trim($info["group_ids"]));
-
} else {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_unsubscribe_email_not_exists"];
-
}
-
} else {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_unsubscribe_group_not_found"];
-
}
-
}
-
}
-
}
-
-
// Error checking for e-mail address information.
-
if((!$info["email_address"]) || (trim($info["email_address"]) == "")) {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_unsubscribe_no_email"];
-
} else {
-
if(!valid_address(trim($info["email_address"]))) {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_unsubscribe_invalid_email"];
-
}
-
-
if(!$ERROR) {
-
if($config[ENDUSER_UNSUBCON] == "yes") {
-
$result = users_queue(trim($info["email_address"]), "", "", $groups, array(), "usr-unsubscribe");
-
if($result) {
-
@ini_set("sendmail_from", $config[PREF_ERREMAL_ID]);
-
-
$mail = new PHPMailer();
-
$mail->PluginDir = $LM_PATH."includes/classes/phpmailer/";
-
$mail->SetLanguage("en", $LM_PATH."includes/classes/phpmailer/language/");
-
-
switch($config[PREF_MAILER_BY_ID]) {
-
case "mail" :
-
$mail->IsMail();
-
break;
-
case "smtp" :
-
$mail->IsSMTP();
-
$mail->Host = $config[PREF_MAILER_BY_VALUE];
-
$mail->SMTPAuth = $config[PREF_MAILER_AUTH_ID];
-
if($mail->SMTPAuth) {
-
$mail->Username = $config[PREF_MAILER_AUTHUSER_ID];
-
$mail->Password = $config[PREF_MAILER_AUTHPASS_ID];
-
}
-
$mail->SMTPKeepAlive = true;
-
break;
-
case "sendmail" :
-
$mail->IsSendmail();
-
$mail->Sendmail = $config[PREF_MAILER_BY_VALUE];
-
break;
-
}
-
-
$mail->Priority = 3; // Normal
-
$mail->CharSet = $config[PREF_DEFAULT_CHARSET];
-
$mail->Encoding = "8bit";
-
$mail->WordWrap = $config[PREF_WORDWRAP];
-
-
$mail->From = $config[PREF_FRMEMAL_ID];
-
$mail->FromName = $config[PREF_FRMNAME_ID];
-
-
$mail->Sender = $config[PREF_ERREMAL_ID];
-
-
$mail->AddReplyTo($config[PREF_RPYEMAL_ID], $config[PREF_FRMNAME_ID]);
-
-
$mail->AddCustomHeader("X-ListMessenger-Version: ".VERSION_TYPE." [".VERSION_INFO."]");
-
$mail->AddCustomHeader("X-ListMessenger-ID: ".urlencode($config[REG_SERIAL]));
-
$mail->AddCustomHeader("X-Originating-IP: ".$_SERVER["REMOTE_ADDR"]);
-
-
$mail->Subject = $language_pack["unsubscribe_confirmation_subject"];
-
$mail->Body = str_replace(array("[url]", "[abuse_address]", "[from]"), array(($config[PREF_PUBLIC_URL].$config[ENDUSER_CONFIRM_FILENAME]."?id=".$result["confirm_id"]."&code=".$result["hash"]), $config[PREF_ABUEMAL_ID], $config[PREF_FRMNAME_ID]), $language_pack["unsubscribe_confirmation_message"]);
-
-
$mail->ClearAddresses();
-
$mail->AddAddress(trim($info["email_address"]), trim($info["email_address"]));
-
-
if(@$mail->Send()) {
-
$TITLE = $language_pack["success_unsubscribe_optout_title"];
-
$MESSAGE = $language_pack["success_unsubscribe_optout_message"];
-
} else {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_unsubscribe_failed_optout"];
-
-
$query = "DELETE FROM `".TABLES_PREFIX."confirmation` WHERE `confirm_id`='".$result["confirm_id"]."';";
-
if(!$db->Execute($query)) {
-
if($config[PREF_ERROR_LOGGING] == "yes") {
-
@error_log(display_date("r", time())."\t".__FILE__." [Line: ".__LINE__."]\tUnable to delete the failed confirmation queue request from the confirmation table. Database server said: ".$db->ErrorMsg()."\n", 3, $config[PREF_PRIVATE_PATH]."logs/error_log.txt");
-
}
-
}
-
if($config[PREF_ERROR_LOGGING] == "yes") {
-
@error_log(display_date("r", time())."\t".__FILE__." [Line: ".__LINE__."]\tUnable to send test message to ".$email_address.". PHPMailer said: ".$mail->ErrorInfo."\n", 3, $config[PREF_PRIVATE_PATH]."logs/error_log.txt");
-
}
-
}
-
-
if($mail->Mailer == "smtp") $mail->SmtpClose();
-
-
$mail->ClearCustomHeaders();
-
-
@ini_restore("sendmail_from");
-
} else {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_unsubscribe_email_not_exists"];
-
-
if($config[PREF_ERROR_LOGGING] == "yes") {
-
@error_log(display_date("r", time())."\t".__FILE__." [Line: ".__LINE__."]\tUnable to add a new subscriber to the confirmation queue. The subscriber is already present in all groups.\n", 3, $config[PREF_PRIVATE_PATH]."logs/error_log.txt");
-
}
-
}
-
} else {
-
$result = subscriber_remove($subscriber_ids);
-
if($result) {
-
$query = "INSERT INTO `".TABLES_PREFIX."confirmation` VALUES ('', '".time()."', 'usr-unsubscribe', '".addslashes($_SERVER["REMOTE_ADDR"])."', '".addslashes($_SERVER["HTTP_REFERER"])."', '".addslashes($_SERVER["HTTP_USER_AGENT"])."', '".trim($info["email_address"])."', '', '', '".addslashes(serialize($groups))."', '', '', '0');";
-
$db->Execute($query);
-
-
if($config[ENDUSER_UNSUBNOTICE] == "yes") {
-
if(!send_notice("unsubscribe", array("email_address" => trim($info["email_address"]), "groups" => $groups))) {
-
if($config[PREF_ERROR_LOGGING] == "yes") {
-
@error_log(display_date("r", time())."\t".__FILE__." [Line: ".__LINE__."]\tUnable to send unsubscribe notice to administrator.\n", 3, $config[PREF_PRIVATE_PATH]."logs/error_log.txt");
-
}
-
}
-
}
-
-
$TITLE = $language_pack["success_unsubscribe_title"];
-
$MESSAGE = $language_pack["success_unsubscribe_message"];
-
} else {
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_unsubscribe_email_not_exists"];
-
-
if($config[PREF_ERROR_LOGGING] == "yes") {
-
@error_log(display_date("r", time())."\t".__FILE__." [Line: ".__LINE__."]\tUnable to remove subscriber from the database. They do not appear to be subscribed to the system.\n", 3, $config[PREF_PRIVATE_PATH]."logs/error_log.txt");
-
}
-
}
-
}
-
}
-
}
-
break;
-
default :
-
$ERROR++;
-
$TITLE = $language_pack["error_default_title"];
-
$MESSAGE = $language_pack["error_invalid_action"];
-
break;
-
}
-
}
-
-
require_once("eu_footer.inc.php");
-
-
@ini_restore("include_path");
-
@ini_restore("allow_url_fopen");
-
@ini_restore("error_reporting");
-
@ini_restore("magic_quotes_runtime");
-
}
-
?>
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,510 network members.
|