<?php
/*
This is the default page for administrator to update the page. This page can be accessed only when 
user is logged in his/her administrative Privilege. 
*/
include("../includes/mysql_login.php");
session_start();
if(!isset($_SESSION['autheticate']))
{
	header("Location: ../index.php");
	exit;
}
if($_SESSION['admin'] == 0)
{
	header("location: ../index.php");
	exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>IEEE Student Chater | University of Alaska Acnhorage</title>
<link rel="stylesheet" href="../includes/style.css" type="text/css" /></head>
<body> </body></html>
<div align="center">
  <table width="940" height="650" border="0" cellpadding="1" cellspacing="5">
    <tr>
      <th width="834" height="566" scope="row">      <p>You are on the admin page. Please do not abuse this page. If you have question contact webmaster</p>
	  <b>Navigate >> </b><a href="members.php"> || Members || </a><a href="printmembers.php" target="_blank">|| Print List ||</a><a href="editOfficers.php">|| Edit Officers||</a>
		<a href="../index.php">Home</a>
        <table width="834" height="384" border="0" cellpadding="1" cellspacing="5">
        <tr>
          <th width="389" height="374" scope="row">
		  <!-- Form 1 for officers information -->
		  <?php
		  echo "<form action=\"$PHP_SELF\" enctype=\"multipart/form-data\" method=\"post\">";
		  ?> 
            <p>Officers Info</p>
            <p align="left">First Name:&nbsp;&nbsp;&nbsp; 
              <input type="text" name="officers_f_name">
  </p>
            <p align="left">Last Name: &nbsp;&nbsp;
              <input type="text" name="officers_l_name">
  </p>
            <p align="left">Position:&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
              <input type="text" name="officers_position">
  </p>
            <p align="left">E-mail:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
              <input type="text" name="officers_email">
  </p>
            <p align="left">Submitted by: 
              <input type="text" name="officers_initials">
  </p>
  			<p align="left">Picture: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<input name="uploadedfile" type="file" /></p>
            <p>
              <input type="submit" name="ofsubmit" value="Submit">
            </p>
          </form></th>
          <td width="426">
		  <!--
		  	Form 2 for event details. 
		  -->
		   <?php
		  echo "<form action=\"$PHP_SELF\" method=\"post\">";
		  ?> 
            <p align="center">Event Info</p>
            <p align="left">Date: &nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type="text" name="event_date"> 
              (Format: July 04, 2007)</p>
            <p align="left">Time: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type="text" name="event_time"> 
              (Format: 11.30 am) </p>
            <p align="left">Location:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type="text" name="event_location"> 
              (Format: SSB 118)
  </p>
            <p align="left">Submitted by: 
              <input type="text" name="event_initial">
  </p>
            <p align="left">Event Detail: (Maximum charecters: 225) </p>
            <p>
              <textarea name="event_detail" cols="45" rows="3"></textarea>
  </p>
            <p>
              <input type="submit" name="evsubmit" value="Submit">
            </p>
          </form></td>
        </tr>
      </table>
      </th>
            <td width="87"><p>&nbsp;</p>
            <p>&nbsp; </p></td>
    </tr>
          <tr>
            <th height="21" scope="row">
			<!-- This is for uploading file 
			-->
			<?php
		  		echo "<form action=\"$PHP_SELF\" enctype=\"multipart/form-data\" method=\"post\">";
		  	?> 
              <p>Submit text file for "introdcution" or "About Us" Page <br>
					(Attention! it should be text file with .txt extension and of resonable length) </p>
              <p>Choose text file to upload:
                  <input name="uploadedfile" type="file" />
                            </p>
              <p>
                <input type="submit" name="attsubmit" value="Submit">
              </p>
            </form></th>
            <td>&nbsp;</td>
          </tr>
  </table>      
      <p>&nbsp;</p></th>
    </tr>
  </table>
</div>
<?php
/* 
Process Officers Info here
*/
if(isset($_POST['ofsubmit']))
{
	//echo "On this officers submit section";
	require_once('../includes/mysql_login.php');
	include("../includes/fileupload.php");
	$filename = $filename;
	$first_name = stripslashes($_POST['officers_f_name']);
	$last_name = stripslashes($_POST['officers_l_name']);
	$position = stripslashes($_POST['officers_position']);
	$email = stripslashes($_POST['officers_email']);
	$submitted_by = stripslashes($_POST['officers_initials']);
	$date_submitted = date('l dS \of F Y h:i:s A');
	echo "Following informatin has been successfully submitted<br>";
	echo "Name: " .$first_name. " " . $last_name . " <br> Position: " . $position . "<br> E-mail: ". $email . "<br> Submitted by: " .$submitted_by ; 
	function table_officers()
	{
			$officers_query = '
			CREATE TABLE `officers`(`officersid` int(20) NOT NULL auto_increment, `first_name` varchar(100) NOT NULL, `last_name` varchar(100) NOT NULL,
											`position` varchar(100) NOT NULL, `email` varchar(100), `attachment` varchar(100), `initials` varchar(100), `date_submitted` varchar(50), 
											PRIMARY KEY (`officersid`)
			)
			';
		$officers_query_result = mysql_query($officers_query);
		if(!$officers_query_result)
		{
			echo "<br>Error on creating table" .mysql_error();	
		}
	}
	//table_officers();
	$officers_insert = "INSERT INTO `officers` VALUES('$officersid', '$first_name', '$last_name', '$position', 
														'$email', '$filename', '$submitted_by', '$date_submitted')";
	$officers_insert_result = mysql_query($officers_insert);
	if(!$officers_insert_result)
		{
			echo "<br> Error on inserting values in the table <br> " . mysql_error();
		}
}
?>
<?php
/* 
Process Upcoming event
*/
if(isset($_POST['evsubmit']))
{
	//echo "<br> I am in event submit section <br>";
	$date = stripslashes($_POST['event_date']);
	$time = stripslashes($_POST['event_time']);
	$location = stripslashes($_POST['event_location']);
	$initials = stripslashes($_POST['event_initials']);
	$detail = mysql_real_escape_string($detail);
	$detail = stripslashes($_POST['event_detail']);
	$date_submitted = date('l dS \of F Y h:i:s A');
	echo "Following information has been submitted <br>"; 
	echo " Event Date: " .$date. "<br> Event Time: ". $time . "<br> Location ". $location . "<br> Submitted by " . $initials . "<br>Event Details: " . $detail; 
	echo "<br> Date Submitted: " .$date_submitted;
	// This functioin can be called only once
		function table_event()
		{
			$event_query = '
				CREATE TABLE `event`(`eventid` int(20) NOT NULL auto_increment, `date` varchar(15) NOT NULL, `time` varchar(10) NOT NULL,
											`location` varchar(10) NOT NULL, `details` longtext NOT NULL, `initials` varchar(20), `date_submitted` varchar(45), 
											PRIMARY KEY (`eventid`)
				)
				';
			$event_query_result = mysql_query($event_query);
			if(!$event_query_result)
			{
				echo "<br>Error on creating table" .mysql_error();	
			}
		}
		table_event();
		$event_insert = "INSERT INTO `event` VALUES('$eventid', '$date', '$time', '$location', 
														'$detail', '$initials', '$date_submitted')";
		$event_insert_result = mysql_query($event_insert);
		if(!$event_insert_result)
		{
			echo "<br> Error on inserting values in the table <br> " . mysql_error();
		} 
}
 else
{
}
?>
<?php
/*
This will upload a file that will be used to for UAA IEEE introduction
*/
if(isset($_POST['attsubmit']))
{
		//echo " <br> This is attachment section <br>";
		$target_path = "../file_upload/"; // Directory to upload file
		$target_path = $target_path."about_uaaieee.txt"; // file name after file upload
		// Variable $parget_path will be passed to the file ../includes/fileupload.php
		include("../includes/fileupload.php");
}
?>