Location: PHPKode > projects > ADbNewsSender > ADbNewsSender_2.0.4/protected/maintenance/modules/ml_pl.php.inc
<?php
//Copyright (c) Florian Grannemann
//Last change in version: 2.0 Beta 2
/*
    ******************************************************************************
    ADbNewsSender 2

    Copyright (C) 2009 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/	
    ******************************************************************************
*/

//This maintenance modul deletes expired maillinglist and pendinglist entries
//function:
function ml_pl($MyCFGro,$MyDB,$path_to_protected_folder)
{
	$newsletters=array();
	$newsletters=$MyCFGro->get_all_newsletters();
	$today=time();
	$XMailer="ADbNewsSender ".$MyCFGro->get_config_value("Version");
	if(count($newsletters >0))
	{
	   
	    $i=0;
	    $WebsiteURL=$MyCFGro->get_config_value("URL");
	    $SubscribeURL=$MyCFGro->get_config_value("SubscribeURL");
	    while($i < count($newsletters))
	    {
		if(!@$MyDB->is_connected)
		{
		    if(!@$MyDB->connect())
		    {
			return;
		    }
		}
		//deleting expired PL entrys:
		@$MyDB->query("DELETE from ADBNS2_Pendinglist_".$newsletters[$i]." WHERE timestamp_expires <= $today;");
		 
		//select expiring ML entrys:
		$result=$MyDB->query("SELECT email from ADBNS2_Maillinglist_".$newsletters[$i]." WHERE timestamp_expires <= $today;");
		
		$tmpNL= new pub_Newsletter($newsletters[$i],&$MyDB);
		
		if(!@(include "$path_to_protected_folder/localisation/lang/".$tmpNL->get_NLconfig_setting("Language")."/localsettings.php.inc"))
		{
			return;
		}
		$DateToday=date($dateformat,$today);
		$NewsletterName=html_entity_decode($tmpNL->get_NLconfig_setting("NL_name"));
		$expires_after=$tmpNL->get_NLconfig_setting("Time_on_ML");
		$NewsletterEmail=$tmpNL->get_NLconfig_setting("Email");
		
		if(!@(include "$path_to_protected_folder/localisation/lang/".$tmpNL->get_NLconfig_setting("Language")."/maintenance_expiration_info_mail.php.inc"))
		{
			return;
		}
		   $header="From:".mb_encode_mimeheader($NewsletterName,strtolower($charset_email))." <$NewsletterEmail> \n";
		   $header .="X-Mailer: $XMailer \n";
		   $header .="Content-Type: text/plain; charset=\"$charset_email\"\n";
		
		while($row=@$MyDB->fetch_row($result))
		{
		
		    mail(stripslashes($row[0]), mb_encode_mimeheader(stripslashes($subject),strtolower($charset_email)), stripslashes($mailtext),$header);

		}
		@$MyDB->query("DELETE from ADBNS2_Maillinglist_".$newsletters[$i]." WHERE timestamp_expires <= $today;");

		$i++;
	    }

	}
}

//function call:
ml_pl($MyCFGro,$MyDB,$path_to_protected_folder);






?>   
Return current item: ADbNewsSender