<?php
///////////////////////////////////////////////////////////////////////////////
//                                                                           //
//   Program Name         : ProPhotoHost                                     //
//   Release Version      : 1.0                                              //
//   Home Page            : http://www.prophotohost.com                      //
//   Program Author       : Jake P                                           //
//   Supplied by          : drew010                                          //
//   Nullified by         : CyKuH [WTN]                                      //
//   Distribution         : via WebForum, ForumRU and associated file dumps  //
//                                                                           //
///////////////////////////////////////////////////////////////////////////////
session_start();
if($session_admin != true) {
	header("location: ./error.php?error=session");
}

include('i.setup.php');
include('i.connection.php');
include('i.function.php');

if($mode == "activate") {
	$date = now();
	
	$sql = "UPDATE member SET member_status='A', updated_on='$date' WHERE member_id = '$member_id'";
	$result = mysql_query($sql);
	
	$result = mysql_query("SELECT member_name, member_email FROM member WHERE member_id = '$member_id'", $db);
	$data = mysql_fetch_object($result);
	
	$message .= "Member activation\n\n";
	$message .= "Name: " . $data->member_name . "\n";
	$message .= "E-mail: " . $data->member_email . "\n\n";
	$message .= "Welcome to " . $page_name . "! Your account has been activated successfully at your request.\n";
	$message .= "Please visit " . $page_url . " to login.\n";
	
	mail($data->member_email, $page_name . " activation notice", $message, "From: " . $page_signup_email);
	
	header("location: admin.member.php");
}
if($mode == "delete") {
	$date = now();
	
	$sql = "UPDATE member SET member_status='D', updated_on='$date' WHERE member_id = '$member_id'";
	$result = mysql_query($sql);
	
	$result = mysql_query("SELECT member_name, member_email FROM member WHERE member_id = '$member_id'", $db);
	$data = mysql_fetch_object($result);
	
	$message .= "Member removal process\n\n";
	$message .= "Name: " . $data->member_name . "\n";
	$message .= "E-mail: " . $data->member_email . "\n\n";
	$message .= "Your account has been removed successfully at your request.\n";
	$message .= "Please visit https://www.paypal.com/cgi-bin/webscr?cmd=_subscr-find&alias=" . $data->member_email . " to cancel your subscription to " . $page_name . "\n";
	
	mail($data->member_email, $page_name . " removal notice", $message, "From: " . $page_support_email);
	
	header("location: admin.member.php");
}
?>

<html>

<head>
<title><?php print($page_title); ?></title>

<?php include('i.style.php'); ?>

<script language="javascript">
	
	function jp_activate(name, member_id) {
		var agree = confirm("Are you sure you want to activate " + name + "?");
		
		if(agree) {
			document.member.action = "<? echo $PHP_SELF; ?>?mode=activate&member_id=" + member_id;
			document.member.submit();		
		}
	}
	
	function jp_delete(name, member_id) {
		var agree = confirm("Are you sure you want to delete " + name + "?");
		
		if(agree) {
			document.member.action = "<? echo $PHP_SELF; ?>?mode=delete&member_id=" + member_id;
			document.member.submit();		
		}
	}
	
</script>

</head>

<body marginwidth="0" marginheight="0" leftmargin="0" topmargin="0" rightmargin="0">
	
	<table width="100%" cellpadding="0" cellspacing="0">
		
		<?php include('i.header.php'); ?>
		
		<tr>
			
			<td valign="top">
				
				<table cellpadding="0" cellspacing="0">
					
					<tr>
						
						<td><font face="verdana" size="1">&nbsp;&nbsp;&nbsp;</font></td>
						
					</tr>
					
				<tr>
					
					<td><font face="verdana" size="1">&nbsp;&nbsp;&nbsp;</font></td>
					
					<td valign="top">
						
						<table cellpadding="0" cellspacing="0">
							
							<?php include('i.tab.php'); ?>
							
						</table>
						
					</td>
					
					<td><font face="verdana" size="1">&nbsp;&nbsp;</font></td>
					
					<td valign="top" width="100%" height="100%">
						
						<table width="100%" height="100%" cellpadding="0" cellspacing="0">
							
							<tr>
								
								<td><font face="verdana" size="1">&nbsp;</font></td>
								
								<td width="100%" height="100%">
									
									<table width="100%" height="100%" cellpadding="0" cellspacing="0">
										
										<tr>
											
											<td><img src="./images/heading.control.gif"></td>
											
										</tr>
										
										<tr>
											
											<td height="8" background="images/hr.gif"></td>
											
										</tr>
										
										<tr>
											
											<td><font face="verdana" size="1">&nbsp;</font></td>
											
										</tr>
										
										<form name="member" method="post">
										
										<tr>
											
											<td>
												
												<table width="100%" cellpadding="4" cellspacing="0">
													
													<tr>
														
														<td align="center"><font face="verdana" size="1"><b></b></font></td>
														
														<td align="center"><font face="verdana" size="1"><b>Edit</b></font></td>
														
														<td><font face="verdana" size="1"><b>Name</b></font></td>
														
														<td><font face="verdana" size="1"><b>E-mail</b></font></td>
														
														<td align="center"><font face="verdana" size="1"><b>Status</b></font></td>
														
														<td align="center"><font face="verdana" size="1"><b>Created</b></font></td>
														
													</tr>
													
													<?php
													$count = 0;
													$query = mysql_query("SELECT * FROM member");
													while($data = mysql_fetch_object($query, $db)) {
														$count++;
														if(($thisrow%2) == 0) {
															$color = "#EEEEEE";
															$thisrow++;
														}
														else {
															$color = "#FFFFFF";
															$thisrow++;
														}
														
														$temp = split("/", $data->created_on);
														$date = $temp[1] . "/" . $temp[2] . "/" . $temp[0];
													?>
														
														<tr bgcolor="<?php print($color); ?>">
															
															<td align="center"><font face="verdana" size="1"><?php print($count); ?></font></td>
															
															<?php if($data->member_status == "D") { ?>
																
																<td align="center"><font face="verdana" size="1"><a href="javascript:jp_activate('<?php print($data->member_name); ?>','<?php print($data->member_id); ?>');">activate</a></font></td>
																
															<?php } ?>
															
															<?php if($data->member_status == "A") { ?>
																
																<td align="center"><font face="verdana" size="1"><a href="javascript:jp_delete('<?php print($data->member_name); ?>','<?php print($data->member_id); ?>');">delete</a></font></td>
																
															<?php } ?>
															
															<?php if($data->member_status == "I") { ?>
																
																<td align="center"><font face="verdana" size="1"><a href="javascript:jp_activate('<?php print($data->member_name); ?>','<?php print($data->member_id); ?>');">activate</a>&nbsp;<a href="javascript:jp_delete('<?php print($data->member_name); ?>','<?php print($data->member_id); ?>');">delete</a></font></td>
																
															<?php } ?>
															
															<td><font face="verdana" size="1"><?php print($data->member_name); ?></font></td>
															
															<td><font face="verdana" size="1"><?php print($data->member_email); ?></font></td>
															
															<td align="center"><font face="verdana" size="1"><?php print($data->member_status); ?></font></td>
															
															<td align="center"><font face="verdana" size="1"><?php print($date); ?></font></td>
															
														</tr>
														
													<?php } ?>
													
												</table>
												
											</td>
											
										</tr>
										
										<tr>
											
											<td height="100%"><font face="verdana" size="1">&nbsp;</font></td>
											
										</tr>
										
										<tr>
											
											<td height="8" background="images/hr.gif"></td>
											
										</tr>
										
									</table>
									
								</td>
								
								<td><font face="verdana" size="1">&nbsp;</font></td>
								
							</tr>
							
						</table>
						
					</td>
					
				</tr>
				
			</table>
			
		</td>
		
	</tr>
	
	<?php include('i.footer.php'); ?>
	
	</table>
	
</body>

</html>