Location: PHPKode > projects > NmnNewsletter > NmnNewsletter1.0.8/importUsers.php
<?php
/*
    NmnNewsletter is a library that provides newsletter service 
	management for websites running php and mysql.
    Copyright (C) 2006  Ivan Preziosi from netmeans.net - Rome.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library 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
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

    For more informations or to join the development of the library contact
    the author at: hide@address.com
    */
	session_start();
	require_once("includes/config.php");
	sessCtrl();

	$usersList = '';
	$separator = ";";
	$usersInserted = 0;
	$usersExistent = 0;
	$usersError = 0;
	$usersToImport = 0;
	$msg = '';
	
	
	if (isset($_REQUEST["usersList"]) && $_REQUEST["usersList"] != ''){
		$usersList = $_REQUEST["usersList"];
	}

	if (isset($_REQUEST["separator"]) && $_REQUEST["separator"] != ''){
		$separator = $_REQUEST["separator"];
	}

	
	if ($usersList != ''){

		$usersArray = explode($separator,$usersList);
		$usersToImport = count($usersArray);

		foreach ($usersArray as $newMail){
			if (!NewsletterUsers::isEmailExistent($newMail)){
				if (NewsletterUsers::subscribeUser($newMail, true)){
					$usersInserted = $usersInserted +1;
				}else{
					$usersError = $usersError +1;
				}
			}else{
				$usersExistent = $usersExistent +1;
			}
		}
		$msg = "<div class=message>".IMPORT_USERS_PRE_TOT." ".$usersInserted." ".IMPORT_USERS_MID_TOT." ".$usersToImport."<br />".$usersExistent." ".IMPORT_USERS_EXISTENT."<br />".$usersError." ".IMPORT_USERS_ERROR."</div><br />";

	}

		$main .= "
			<div class=page_heading>".IMPORT_USERS_TITLE."</div>
			$msg
			<table width=95%>
			<tr>
			<td align=right>
			<span ><a href=\"subscribers.php\">".IMPORT_USERS_SUBSCRIBERS_LINK."</a></span>
				</td>

			 </tr>
			<tr>
			<form name='import' action='importUsers.php' method='post'>
			<td align='center' class='message'>
			
			".IMPORT_USERS_TEXT."<br />
			<textarea  name=\"usersList\" rows=\"5\" cols=\"90\"></textarea><br />
			<br />
			".IMPORT_USERS_SEPARATOR." <br /><input type=\"text\" name=\"separator\"  size=\"2\" /><br /><br />
			<input class=button type=submit value='".IMPORT_USERS_BUTTON."'>
			
			
			</td>
</form>
			
			 </tr>

			
			 
			
			 
			 </table>";
	
	$page = "subscribers";
	require_once("includes/template.php");

?>
Return current item: NmnNewsletter