Location: PHPKode > projects > eBlog > maillist.php
<?php

/**************************************************************************
 *                                                                        *
 *                                                                        *
 *         Solution: eBlog                                                *
 *          Release: 1.7                                                  *
 *             File: maillist.php                                         *
 *               By: Emuci inc.                                           *
 *          Website: http://www.emuci.com                                 *
 *        Copyright: (C) 2010 Emcui inc.                                  *
 *                                                                        *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *                                                                        *
 *   This script is NOT freeware and is subjected to Emuci terms of use   *
 *   located in the docs folder.                                          *
 *                                                                        *
 *                                                                        *
 *************************************************************************/



include_once 'includes/global.php';

$action = $_GET['action'];
$id = $_GET['id'];

if(empty($action))
$action = "main";
		
$defaultTemplate = $template;
$copyrights = "&copy; " . date("Y") . " " . $lang_admin_globalRights1;

// 1: Main View
if($action == "main"){
	
	$tree_map = $lang_blog_joinMyMainingList;	
	
	$random = rand(18989, 99999);	
		
	$static_value = array ($blog_dir, $lang_blog_form_name,$lang_blog_form_email,$lang_blog_form_cc,$random,$lang_blog_submit, $blog_windows_encoding, $lang_erorr_code149, $lang_erorr_code151, $lang_erorr_code155, $lang_erorr_code156, $lang_blog_join, $lang_blog_leave);
	$static_name = array ("{blog_dir}","{lang_blog_form_name}", "{lang_blog_form_email}", "{lang_blog_form_cc}","{random}","{lang_blog_submit}", "{blog_windows_encoding}", "{lang_erorr_code149}", "{lang_erorr_code151}", "{lang_erorr_code155}","{lang_erorr_code156}", "{lang_blog_join}", "{lang_blog_leave}");
	$file = $new_template->load_template ("templates/$defaultTemplate/maillist.html");
	$template = $new_template->replace_static($static_name, $static_value, $file);
	
	if($popup < 1){
	
		$static_value = array ($lang_blog_secionsList, $sections_list);
		$static_name = array ("{lang_blog_secionsList}","{sections_list}");
		$file = $new_template->load_template ("templates/$defaultTemplate/sideMenu.html");
		$side_menu = $new_template->replace_static($static_name, $static_value, $file);
	
		$static_value = array (
								$blog_windows_encoding, $blog_slogan, $lang_blog_search, $lang_blog_recentTopics,
							    $tree_map, $css, $side_menu,$template, $blog_dir, $blog_name,
							    $meta, $social_networks, $copyrights, $lang_blog_emailMe, $lang_blog_joinMyMainingList,
							    $lang_blog_MyFriends, $lang_blog_visitors, $visitors,$popupDefine, $blog_windows_encoding
							  );
							  
							  
		$static_name  = array (
							   "{blog_windows_encoding}", "{blog_slogan}","{lang_blog_search}", "{lang_blog_recentTopics}",
							   "{tree_map}", "{css}", "{side_menu}", "{page_content}", "{blog_dir}", "{blog_name}",
							   "{meta}", "{social_networks}", "{copyrights}", "{lang_blog_emailMe}", "{lang_blog_joinMyMainingList}",
							   "{lang_blog_MyFriends}", "{lang_blog_visitors}", "{visitors}", "{popupDefine}", "{blog_windows_encoding}"
							  );
		
		$header = $new_template->load_template ("templates/$defaultTemplate/header.html");
		$body = $new_template->load_template ("templates/$defaultTemplate/layout.html");
		$footer = $new_template->load_template ("templates/$defaultTemplate/footer.html");
		$template = $new_template->replace_static($static_name, $static_value, $header . $body	. $footer);
	}
		
	echo $template;
}


// 2: Process
else if($action == "process"){

	$conn = mysql_connect($dbhost, $dbuser, $dbpass);
	mysql_select_db($dbname);		
	
	$name = htmlspecialchars($_POST['name']);
	$code = $_POST['code'];
	$code2 = $_POST['code2'];
	$email = $_POST['email'];
	$todo = $_POST['todo'];
	
	if(empty($name)){
	$erorr++;
	}

	if(empty($email)){
	$erorr++;
	}				
	
	if($code != $code2){
	$erorr++;
	}


	if($erorr < 1)
	{

		$result = mysql_query("SELECT id FROM eblog_contacts WHERE email = '$email'");	
		$row = mysql_fetch_row($result);
		$xID = $row[0];
						
		if($todo == 1)
		{
			
			if(!empty($xID))	
			{
				$messageToShow = $lang_blog_sub4;
			}
			else
			{
				$messageToShow = $lang_blog_sub1;
				
				$newID = 0;
				$query  = "SELECT id FROM eblog_contacts ORDER BY id ASC";
				$result = mysql_query($query);
				while($row = mysql_fetch_array($result, MYSQL_ASSOC))
				{
					$newID = $row['id'];
				}
				$newID++;
				
				mysql_query("INSERT INTO eblog_contacts  VALUES ('$newID', '$name', '$email')");
				
			    $result2 = mysql_query("SELECT enable3 FROM eblog_settings WHERE id = '1'");	
				$row2 = mysql_fetch_row($result2);
				$enable3 = $row2[0];				
				
				if($enable3 == 1)
				{
				    $result2 = mysql_query("SELECT sub FROM eblog_alerts WHERE id = '1'");	
					$row2 = mysql_fetch_row($result2);
					$currentAlerts = $row2[0] + 1;	
					$sql="UPDATE eblog_alerts SET sub='$currentAlerts' WHERE id = '1'";
					$result=mysql_query($sql);	
					
					$query  = "SELECT id FROM eblog_new ORDER BY id ASC";
					$result = mysql_query($query);
					while($row = mysql_fetch_array($result, MYSQL_ASSOC))
					{
						$thisNewID = $row['id'];
					}
					$thisNewID++;
					 mysql_query("INSERT INTO eblog_new  VALUES ('$thisNewID', '$newID', '3')");									
				}				

			}		
		}
		else
		{
			
			if(empty($xID))	
			{
				$messageToShow = $lang_blog_sub3;
			}
			else
			{
				mysql_query("DELETE FROM eblog_contacts WHERE id=$xID");
				mysql_close($conn);
				$messageToShow = $lang_blog_sub2;
			}					
		}
			
		mysql_close($conn);
		
		if($popup == 3)
		{
			echo "
			<script type='text/javascript'> 
			alert('$messageToShow');
			javascript:window.close();
			</script>
			";			
		}
		else if($popup == 1)
		{
			echo "
			<script type='text/javascript'> 
			alert('$messageToShow');
			window.location='maillist.php';
			</script>
			";			
		}		
		else
		{
			echo "
			<script type='text/javascript'> 
			alert('$messageToShow');
			parent.location='index.php';
			</script>
			";	
		}
	}
				
}

// 3: Else, show error message
else
{
	echo "
	<script type='text/javascript'> 
	alert('$lang_erorr_PgaeNotFound');
	parent.location='index.php';
	</script>
	";
}


?>
Return current item: eBlog