<?php
/* File: confirmation.php.inc
//Last change in version: 2.1 Alpha 1
******************************************************************************
ADbNewsSender 2
Copyright (C) 2010 Florian Grannemann (hide@address.com)
Website: http://adbnewssender.sf.net
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************
*/
include "$path_to_protected_folder/skeleton/public_apis.class.php.inc";
$path_to_DB_defs="$path_to_protected_folder/skeleton/includes/db_defs/";
$path_to_DB_conf="$path_to_protected_folder/database/DBconf.php.inc";
$MyDB = new ADBNS_DB($path_to_DB_defs,$path_to_DB_conf);
$MyCFG=new global_config_ro($MyDB);
//trying to override the time zone:
$MyCFG->setTimeZone();
$email=$_REQUEST["email"];
$random=$_REQUEST["random"];
$NLID=intval($_REQUEST["NewsletterID"]);
if(!isset($NLID))
{
include_once "$path_to_protected_folder/localization/lang/".$MyCFG->get_config_value("Language")."/lang-confirmation.php.inc";
print $MSG_unknown_Newsletter;
}
else
{
if($MyCFG->NL_exists($NLID))
{
$MyNL=new pub_Newsletter($NLID, $MyDB);
$path_to_language_dir="$path_to_protected_folder/localization/lang/".$MyNL->get_NLconfig_setting("Language");
if(!is_dir($path_to_language_dir))
{
$path_to_language_dir="$path_to_protected_folder/localization/lang/".$MyCFG->get_config_value("Language");
}
include_once $path_to_language_dir."/lang-confirmation.php.inc";
$email=preg_replace("/ /","",$email);
$email=preg_replace("/\n/","",$email);
if($MyNL->on_PL($email))
{
$random=preg_replace("/ /","",$random);
$random=preg_replace("/\n/","",$random);
//try to add the e-mail address to ML:
$result=$MyNL->add_to_ML($email,$random,$_SERVER['REMOTE_ADDR']);
if($result <1)
{
//failed:
if($result < 0)
{
//email address or random code are invalid or the combination of both is incorrect
print $MSG_INCORRECT_ConfirmationLink;
}
else
{
//connection to database has failed :-(
print $MSG_DB_connection_failed;
}
}
else
{
//success, $result contains now the ID number of the new entry
//retrieving timestamp of the expiration date
$expires_TS=$MyNL->get_ML_entry_expiration_TS($result);
include_once $path_to_language_dir."/localsettings.php.inc";
$expiration_date=date($dateformat,$expires_TS);
$expiration_time=date($timeformat,$expires_TS);
$message=preg_replace("/<-DateExpires->/",$expiration_date,$MSG_CORRECT_ConfirmationLink);
$message=preg_replace("/<-TimeExpires->/",$expiration_time,$message);
$message=preg_replace("/<-TimeZone->/",$MyCFG->get_timezone(),$message);
print $message;
}
}
else
{ //if e-mail address is not on pendinglist
print $MSG_INCORRECT_ConfirmationLink;
}
}
else
{ //selected NL does not exist:
include_once "$path_to_protected_folder/localization/lang/".$MyCFG->get_config_value("Language")."/lang-confirmation.php.inc";
print $MSG_unknown_Newsletter;
}
}
?>