<?php

		//////////////////////////////////////////////////////////
		//////////// Deleted members script, based on ////////////
		//////////////// the base FairyAds script ////////////////
		//////////////// Coded by Jonathan, v0.1 /////////////////
		//////////////////////////////////////////////////////////

session_start();

include "../header.php";
include "../config.php";
include "../style.php";

if( isset($_SESSION["alogin"]) ) {
    $query = "SELECT * FROM `leaves` ORDER BY `leaves`.`deleted` ASC";
	$result = mysql_query ($query)
	     or die ("Query failed");
       $num_rows = mysql_num_rows($result);
    	?><table>
      	<tr>
        <td width="15%" valign=top><br>
        <? include("adminnavigation.php"); ?>
        </td>
        <td valign="top" align="center"><br><br> <?
	echo "<font size=4 face='$fonttype' color='$fontcolour'><p><center>";
	echo "<center>Leaves Options</center>";
    echo "<font size=3 face='$fonttype' color='$fontcolour'><p><center>";
    echo "<center>";
		
		
		//Get the options of Leaves
		$options = mysql_query ("select * from leaves_options where id='1'");
        $array = mysql_fetch_array($options);
		$scriptactive = $array["leave_active"];
		$joinemail = $array["join_email"];
		$leavemail = $array["leave_email"];
		$email = $array["adminemail"];
		$logleaved = $array["log_leaved"];
		
		
		//The Script activate and deactivate button
		echo "<font size=3 face='$fonttype' color='$fontcolour'>"
		?><br><br>Activate and Deactivate the script<?
		if($scriptactive == 1)
		{
			?>
			<br><br><font size=2>The script is currently <font color=green><b>ACTIVE</b></font>.</font><br>
          	<form method="POST" action="deleteds/disen_script.php">
          	<input type="submit" value="Disable the Leaves script">
          	</form>
			<?
		}
		else
		{
			?>
			<br><br><font size=2>The script is currently <font color=red><b>INACTIVE</b></font>!</font><br>
          	<form method="POST" action="deleteds/disen_script.php">
          	<input type="submit" value="Activate the Leaves script">
          	</form>
			<br><br><font size=2><font color=red>NOTE: NONE of the below functions will work if the main script isn't active, even if the other functions report to be active!</font><br>
			<?
		}
		
		//Storing leaving members in the database, activate and deactivate button
		echo "<font size=3 face='$fonttype' color='$fontcolour'>"
		?><br><br><br><br><br>Do you want to store the leaving members into the database?<?
		if($logleaved == 1)
		{
			?>
			<br><br><font size=2>You're currently <font color=green><b>STORING</b></font> the leaving members in the database.</font><br>
          	<form method="POST" action="deleteds/disen_store.php">
          	<input type="submit" value="Stop storing leaving members in the database">
          	</form>
			<?
		}
		else
		{
			?>
			<br><br><font size=2>You are currently <font color=red><b>NOT STORING</b></font> the leaving members in the database!</font><br>
          	<form method="POST" action="deleteds/disen_store.php">
          	<input type="submit" value="Store leaving members in the database">
          	</form>
			<?
		}
		
		//Getting e-mail when someone joins, activate and deactivate button
		echo "<font size=3 face='$fonttype' color='$fontcolour'>"
		?><br><br><br><br><br>Do you want to receive e-mail when a member joins?<?
		if($joinemail == 1)
		{
			?>
			<br><br><font size=2>You're currently <font color=green><b>RECEIVING</b></font> e-mail when someone joins.</font><br>
          	<form method="POST" action="deleteds/disen_join.php">
          	<input type="submit" value="Stop getting e-mails when a member joins">
          	</form>
			<?
		}
		else
		{
			?>
			<br><br><font size=2>You are currently <font color=red><b>NOT RECEIVING</b></font> e-mail when someone joins!</font><br>
          	<form method="POST" action="deleteds/disen_join.php">
          	<input type="submit" value="Receive e-mails when a member joins">
          	</form>
			<?
		}
		
		//Getting e-mail when someone leaves, activate and deactivate button
		echo "<font size=3 face='$fonttype' color='$fontcolour'>"
		?><br><br><br><br><br>Do you want to receive e-mail when a member leaves?<?
		if($leavemail == 1)
		{
			?>
			<br><br><font size=2>You're currently <font color=green><b>RECEIVING</b></font> e-mail when someone leaves.</font><br>
          	<form method="POST" action="deleteds/disen_leave.php">
          	<input type="submit" value="Stop getting e-mails when a member leaves">
          	</form>
			<?
		}
		else
		{
			?>
			<br><br><font size=2>You are currently <font color=red><b>NOT RECEIVING</b></font> e-mail when someone leaves!</font><br>
          	<form method="POST" action="deleteds/disen_leave.php">
          	<input type="submit" value="Receive e-mails when a member leaves">
          	</form>
			<?
		}
		
		//E-mail adress to e-mail to
		echo "<font size=3 face='$fonttype' color='$fontcolour'>"
		?><br><br><br><br><br>Please enter the e-mail below that you'd like to be mailed on<?
		if(!$email)
		{
			?>
			<br><br><font size=2>You have <font color=red><b>NOT STORED</b></font> an e-mail adress yet!</font><br>
			<form method="post" action="deleteds/change_email.php"><div class="form"><div class="formlist"></div>

				  <div class="formfield">
					<table width="331" border="0" align="center" cellpadding="0" cellspacing="0">
					  <tr>
						<td width="186"><div align="center">
						  <textarea rows="4" cols="40" name="email" value=""></textarea>
						</div></td>
					  </tr>
					</table>
				  </div>

				<div class="form"><div class="formlist">
					<div align="center">
					  <input name="submit" value="Submit E-mail" type="submit">
					</div>
				</div>
			</form>
			<?
		}
		else
		{
			?>
			<br><br><font size=2>The stored e-mail is <font color=green><b><? echo($email) ?></b></font></font><br>
			<form method="post" action="deleteds/change_email.php"><div class="form"><div class="formlist"></div>

				  <div class="formfield">
					<table width="331" border="0" align="center" cellpadding="0" cellspacing="0">
					  <tr>
						<td width="186"><div align="center">
						  <textarea rows="4" cols="40" name="email" value=""></textarea>
						</div></td>
					  </tr>
					</table>
				  </div>

				<div class="form"><div class="formlist">
					<div align="center">
					  <input name="submit" value="Change E-mail" type="submit">
					</div>
				</div>
			</form>
			<br><br><br>
			<?
		}
}
else 
{
	echo "Unauthorised Access!";
}
echo "</table></td></tr></table>";

include "../footer.php";
mysql_close($dblink);
?>