Location: PHPKode > scripts > PHP Newsletter > admin/del_all_emails.php
<?php

////////////////////////////////////
// PHP Newsletter v3.6.0            
// (C) 2006-2013 Alexander Yanitsky 
// Website: http://janicky.com      
// E-mail: hide@address.com         
// Skype: janickiy                  
///////////////////////////////////

Error_Reporting(E_ALL & ~E_NOTICE);

define("DEBUG", 0);

ob_start();

require "class/class.exception_mysql.php";
require "class/class.exception_object.php";
require "class/class.exception_member.php";

try
{
	require_once "lib/functions.inc";
	require_once "lib/connect.inc";
	require_once "lib/set.inc";
	require_once "templates/language/".$settings['language']."/language.inc";	
	require_once "templates/language/".$settings['language']."/del_all_emails.inc";	
	require_once "lib/authenticate.inc";
	require_once "lib/delete.inc";
	
	
	$query = "SELECT id_user FROM ".DB_USERS."";
	$result = $dbh->query($query);

	if(!$result)
	{
		throw new ExceptionMySQL($dbh->error,$query,"Error executing SQL query!");
	}
	
	while($row = $result->fetch_array())
	{
		$delete = "DELETE FROM ".DB_SUB." WHERE id_user=".$row['id_user'];
		$dbh->query($delete);
	}
	
	$result->close();

	$delete = "DELETE FROM ".DB_USERS."";

	if($dbh->query($delete))
	{
		redirect(MSG_REMOVE_EMAILS,$_SERVER["HTTP_REFERER"],2);
	}
	else
	{
		throw new ExceptionMySQL($dbh->error,$delete,"Error executing SQL query!");
	}

	$dbh->close();
}
catch(ExceptionObject $exc)
{
	require_once("lib/exception_object_debug.inc");
}
catch(ExceptionMySQL $exc)
{
	require_once("lib/exception_mysql_debug.inc");
}
catch(ExceptionMember $exc)
{
	require_once("lib/exception_member_debug.inc");
}

?>
Return current item: PHP Newsletter