<?

/*
FlexCMS (http://www.flexcms.com)
Flexible, Powerful, Affordable.

Contents of this file are protected by the copyright
notice found at http://www.flexcms.com/flex/pages/copyright.html,
and its usage is subject to the terms of the licensing agreement 
available at http://www.flexcms.com/flex/pages/license.html
*/



	// ========================================================================================
	// manage subscribers page
	// ========================================================================================
	
	$query = "select * from `".$Settings['DBPrefix']."nl-Settings`";
	$result = mysql_query($query) or die (mysql_error());
	while ($row = mysql_fetch_array($result)) {
		$nlSettings[$row['Name']] = $row['Value'];
	}
	
	
	$PageTitle = '<img src="'.$ImagesURL.'/admin/admincp_newsletter.gif" width="22" height="21"> '.$MsgText[5][3];
	$BrowserTitle = $MsgText[5][3];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="' . $MainURL . '/options.html">'.$MsgText[0][4].'</a> > '.$MsgText[5][3];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[502] == 'y') {
							
		
			if ($nlSettings['DoubleOptInMode'] == 'y') {
			// double opt in mode		
				
				$SubscribersFound = 'n';
			
				$PageContents .= '<br><b><a href="'.$MainURL.'/admin/newsletter_subscribers_add.html">'.$MsgText[5][32].'</a></b> | <b><a href="'.$MainURL.'/admin/newsletter_compose.html">'.$MsgText[5][2].'</a></b><br><br><br><b>'.$MsgText[5][14].':</b>';
				$PageContents .= '<table cellpadding="1" cellspacing="0" border="0"><form action="'.$MainURL.'/admin/newsletter_subscriber_delete_bulk.html" method="post">';
				
				$query = "select * from `".$Settings['DBPrefix']."nl-Addresses` where DoubleConfirmed='y' order by Email asc";
				$result = mysql_query($query) or die (mysql_error());
				while ($row = mysql_fetch_array($result)) {
					$Counter++;
					$PageContents .= '<tr><td><input type="checkbox" name="SubscriberSelected-'.$Counter.'" value="'.$row['Email'].'"></td><td><td><font face="'.$FontFace.'" size="'.$FontSize.'">'.$row['Email'].'</td><td><font face="'.$FontFace.'" size="'.$FontSize.'">&nbsp;&nbsp;&nbsp;<a href="'.$MainURL.'/admin/newsletter_subscriber_delete/'.$row['RecordNumber'].'.html">'.$MsgText[0][156].'</a></td></tr>';
					$SubscribersFound = 'y';
					$SubscribersCount++;
				}
				
				if ($SubscribersFound == 'n') {
					$PageContents .= '<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'">['.$MsgText[5][33].']</td></tr>';		
				}
								
				$PageContents .= '</table>';
				
				
				if ($SubscribersFound == 'y') {
					$PageContents .= '<br><input type="submit" value="'.$MsgText[5][77].'" style="'.$FormStyle.'"><input type="hidden" name="SubscribersCount" value="'.$Counter.'"></form><br>';
				}
				
				
				
				$SubscribersFound = 'n';
				
				$PageContents .= '<br><br><b>'.$MsgText[5][34].':</b>';
				$PageContents .= '<table cellpadding="1" cellspacing="0" border="0">';
				
				$query = "select * from `".$Settings['DBPrefix']."nl-Addresses` where DoubleConfirmed!='y' order by Email asc";
				$result = mysql_query($query) or die (mysql_error());
				while ($row = mysql_fetch_array($result)) {
					$PageContents .= '<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'">'.$row['Email'].'</td><td><font face="'.$FontFace.'" size="'.$FontSize.'">&nbsp;&nbsp;&nbsp;<a href="'.$MainURL.'/admin/newsletter_subscriber_delete/'.$row['RecordNumber'].'.html">'.$MsgText[0][156].'</a></td></tr>';
					$SubscribersFound = 'y';
				}
				
				if ($SubscribersFound == 'n') {
					$PageContents .= '<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'">['.$MsgText[5][33].']</td></tr>';
				}
				
				$PageContents .= '</table>';
				
				$PageContents .= '<br><a href="'.$MainURL.'/admin/newsletter_unconfirmed_delete.html">'.$MsgText[5][35].'</a><br><br><br>'.$MsgText[5][36].': '.$SubscribersCount;
				
			}
			else {
			// not double opt in mode
			
				$SubscribersFound = 'n';
			
				$PageContents .= '<br><b>Current Subscribers:</b>';
				$PageContents .= '<table cellpadding="1" cellspacing="0" border="0">';
			
				$query = "select * from `".$Settings['DBPrefix']."nl-Addresses` order by Email asc";
				$result = mysql_query($query) or die (mysql_error());
				while ($row = mysql_fetch_array($result)) {
					$PageContents .= '<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'">'.$row['Email'].'</td><td><font face="'.$FontFace.'" size="'.$FontSize.'">&nbsp;&nbsp;&nbsp;<a href="'.$MainURL.'/admin/newsletter_subscriber_delete/'.$row['RecordNumber'].'.html">'.$MsgText[0][156].'</a></td></tr>';
					$SubscribersFound = 'y';
					$SubscribersCount++;
				}
				
				if ($SubscribersFound == 'n') {
					$PageContents .= '<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'">['.$MsgText[5][33].']</td></tr>';		
				}
				
				$PageContents .= '</table><br>'.$MsgText[5][37].': '.$SubscribersCount;
			
			}
			
			
		}
		else {
		
			$PageContents = $MsgText[0][97];
		
		}

	}
	else {
	
		RedirectToLogin();
	
	}
		


?>
