Location: PHPKode > projects > ADbNewsSender > ADbNewsSender 2.1.0/protected/renewal.php.inc
<?php
/* File: renewal.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"];
$SubscriptionKey=intval($_REQUEST["SubscriptionKey"]);
$NLID=intval($_REQUEST["NewsletterID"]);

if(!isset($NLID))
{
    include_once "$path_to_protected_folder/localization/lang/".$MyCFG->get_config_value("Language")."/lang-renewal.php.inc";
    print $MSG_unknown_Newsletter;
}
else
{
	if($MyCFG->NL_exists($NLID))
	{
		$MyNL=new pub_Newsletter($NLID, $MyDB);

		$path_to_language_folder="$path_to_protected_folder/localization/lang/".$MyNL->get_NLconfig_setting("Language");
		if(!is_dir($path_to_language_folder))
		{
		    //if the nl specific language pack does not exist:
		    $path_to_language_folder="$path_to_protected_folder/localization/lang/".$MyCFG->get_config_value("Language");
		
		}
		include_once $path_to_language_folder."/lang-renewal.php.inc";
		$entryID=$MyNL->get_ML_entry_id($email);
		if($entryID <1)
		{
		  //entry does not exist or the connection to db has failed
		  
		    if($entryID==0)
		    {
			print $MSG_DB_connection_failed;
		    }
		    else
		    {
			 print $MSG_renewal_failed2;
		    }
		}
		else
		{  
		    include_once $path_to_language_folder."/localsettings.php.inc";
		    //if e-mail address is on maillinglist, $entryID contains the entry id.
		   //Now let's try to renew the entry:
		    $result=$MyNL->renew_entry($entryID,$SubscriptionKey, $_SERVER['REMOTE_ADDR']);
		    if($result <1)
		    {
			//failed:
			if($result <-1)
			{
			    //combination of ID and SubscriptionKey is invalid or incorrect
			    print $MSG_renewal_failed2;
			}
			if($result==-1)
			{
			    //the entry is not in renewal period
			    print preg_replace("/<-ExpirationDate->/",date($dateformat,$MyNL->get_ML_entry_expiration_TS($entryID)),$MSG_renewal_failed1);
			}
			if($result==0)
			{
			    //DB connection has failed
			    print $MSG_DB_connection_failed;
			}
		    }
		    else
		    {
			//success, $result contains the timestamp of the new date of expiration
			 print preg_replace("/<-ExpirationDate->/",date($dateformat,$result),$MSG_renewal_Succes);
		    }

		}
	}
	else
	{	//selected NL does not exist:
		include_once "$path_to_protected_folder/localization/lang/".$MyCFG->get_config_value("Language")."/lang-renewal.php.inc";
		print $MSG_unknown_Newsletter;
	}
}
?> 
Return current item: ADbNewsSender