Location: PHPKode > projects > Operational Information > opinfo-1.2/index.php
<?php

/*
SCRIPT NAME: opinfo
VERSION: 1.2
*/

// SESSION START
session_start(); 

// SETTINGS
include("settings.php");
if ($password == "")
	{$password = "lkaJHJKhKH235W4R2w2wWw";}
$aerodrome_name = strtoupper($aerodrome_name);
$aerodrome_icao_code = strtoupper($aerodrome_icao_code);
$aerodrome_position = strtoupper($aerodrome_position);
$aerodrome_email = strtoupper($aerodrome_email);
$style = " style='font-size:10pt;font-family:courier new;text-transform:uppercase' ";

// CONNECT TO SERVER
$con = mysql_connect($database_hostname, $database_username, $database_password);
$db_selected = mysql_select_db($database_name, $con);
if (!$db_selected)
	{
	if (mysql_query("CREATE DATABASE IF NOT EXIST $database_name",$con))
		{
		$db_selected = mysql_select_db($database_name, $con);
		}
	else
		{
		die("DATABASE $database_name CANNOT BE SELECTED AND CANNOT BE CREATED");
		}
	}

// LOGIN
if ($password == $_GET['password'])
	{
	$_SESSION['op_logged_in'] = 1;
	$refresh_page = "<meta http-equiv='Refresh' content='0;url=?' />";
	}
elseif ($password == $_POST['password'] || $_SESSION['op_logged_in'] == 1)
	{
	if (!$_SESSION['op_logged_in'])
		{$_SESSION['op_logged_in'] = 1;}
	$refresh_page = "<meta http-equiv='Refresh' content='300;url=?password=logg_out_due_5min_timeout' />";
	}
else
	{
	$refresh_page = "<meta http-equiv='Refresh' content='300;url=?' />";
	}

//LOG OUT
if ($_POST['log_out'] == "log_out")
	{
	unset($_SESSION['op_logged_in']);
	}
elseif ($_GET['password'] == "logg_out_due_5min_timeout")
	{
	unset($_SESSION['op_logged_in']);
	$logg_out_due_5min_timeout = "<font color='red' ><b>YOU ARE LOGGED OUT DUE TO 5 MIN INACTIVITY</b></font><br /><br />";
	$refresh_page = "<meta http-equiv='Refresh' content='300;url=?' />";
	}

// HTML
if ($_SESSION['op_logged_in'] == 1)
	{
	$table_width = " width='900' ";
	$hr_style = "";//" style='height:4px;background-color:gray' ";
	}
else
	{
	$table_width = " width='550' ";
	$hr_style = "";
	}

echo "
<html lang='en'>
<head>$refresh_page<title>$aerodrome_icao_code OP INFO</title></head>
<body $style>
<table $table_width>
";


// HEADING ///////////////////////////////////////////////////////////////////////////
// HEADING ///////////////////////////////////////////////////////////////////////////
// HEADING ///////////////////////////////////////////////////////////////////////////
// HEADING ///////////////////////////////////////////////////////////////////////////
// HEADING ///////////////////////////////////////////////////////////////////////////
echo"<tr><td $style align='center'><b>";

echo $logg_out_due_5min_timeout;


if ($aerodrome_name != "")
	{
	echo strtoupper($aerodrome_name) . "<br />";
	}
if (($aerodrome_icao_code != "") && ($aerodrome_position != ""))
	{
	echo strtoupper($aerodrome_icao_code) . " " . strtoupper($aerodrome_position);
	}
elseif ($aerodrome_icao_code != "")
	{
	echo strtoupper($aerodrome_icao_code);
	}
elseif ($aerodrome_position != "")
	{
	echo strtoupper($aerodrome_position);
	}
echo "<br />OPERATIONAL INFORMATION";

echo "</b></td></tr>";


// WEATHER ///////////////////////////////////////////////////////////////////////////
// WEATHER ///////////////////////////////////////////////////////////////////////////
// WEATHER ///////////////////////////////////////////////////////////////////////////
// WEATHER ///////////////////////////////////////////////////////////////////////////
// WEATHER ///////////////////////////////////////////////////////////////////////////

// WEATHER HEADING START
echo"<tr><td $style align='left'><hr $hr_style />";
echo "<b>WEATHER</b><br />";

// METAR MANUAL INPUT
if ($man_wx_path != "" && $_SESSION['op_logged_in'] == 1)
	{echo "METAR MANUAL WEATHER INPUT <a href='$man_wx_path?password=$man_wx_password' target='_blank'>LINK</a>=<br />";}
	
// METAR MySQL
if (strtolower($metar_mysql_on_off) == "on")
	{
	$table_name_metar = $database_table_prefix . "_wx_metar";
	$result = mysql_query("
		SELECT timestamp, icao_code, metar 
		FROM $table_name_metar 
		WHERE timestamp=(SELECT MAX(timestamp) FROM $table_name_metar)
		");
	while($row = mysql_fetch_array($result))
		{
		$timestamp = $row['timestamp'];
		$icao_code = $row['icao_code'];
		$metar = $row['metar'];
		}
	if ((time() - $timestamp) > 7200)
		{$metar = "METAR " . $icao_code . " NIL";}
	echo $metar . "=<br />";
	}
	
// METAR LINK
if ($metar_path != "")
	{echo "METAR <a href='$metar_path' target='_blank'>LINK</a>=<br />";}

// FORECAST PLACE
if ($yr_place != "")
	{echo "FORECAST <a href='forecast.php' target='_blank'>LINK</a>=<br />";}
	
// FORECAST LINK
if ($forecast_path != "")
	{echo "FORECAST <a href='$forecast_path' target='_blank'>LINK</a>=<br />";}

// WINDREP
if ($windrep_path != "")
	{echo "WINDREP <a href='$windrep_path' target='_blank'>LINK</a>=<br />";}

// WEATHER HEADING END
echo "</td></tr>";
	

// NOTAM ///////////////////////////////////////////////////////////////////////////
// NOTAM ///////////////////////////////////////////////////////////////////////////
// NOTAM ///////////////////////////////////////////////////////////////////////////
// NOTAM ///////////////////////////////////////////////////////////////////////////
// NOTAM ///////////////////////////////////////////////////////////////////////////
echo"<tr><td $style align='left'><hr $hr_style />";

// HEADING
if ($_SESSION['op_logged_in'] != 1)
	{echo "<b>NOTAM</b><br />";}

// TABLE NAME
$table_name_notam = $database_table_prefix . "_op_notam";

// CREATE TABLE IF NOT EXIST
$sql = "CREATE TABLE IF NOT EXISTS $table_name_notam (
id smallint(4) unsigned NOT NULL AUTO_INCREMENT,
icao_code varchar(4) NOT NULL,
valid_from int(10) unsigned NOT NULL,
valid_to int(10) unsigned NOT NULL,
text varchar(255) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;";
mysql_query($sql);

// IF LOGGED IN
if ($_SESSION['op_logged_in'] == 1)
	{

	// SHOW/HIDE expired notams
	if ($_POST['show_hide_expired_notam'] == "show")
		{$_SESSION['show_expired_notam'] = 1;}
	elseif ($_POST['show_hide_expired_notam'] == "hide")
		{unset($_SESSION['show_expired_notam']);}

	// HEADING (TABLE)
	echo "<table width='100%' $style><tr>";
		
	// NOTAM HEADING
	echo "<td><b>NOTAM</b></td>";
		
	// MESSAGES 
	echo "<td align='center'>";

	// CONFIRM DELETE NOTAM
	if ($_POST['notam_delete_id'] && $_POST['notam_delete_id'] != $_SESSION['notam_delete_confirm'])
		{
		$_SESSION['notam_delete_confirm'] = $_POST['notam_delete_id'];
		$notam_delete_id = $_POST['notam_delete_id'];
		$notam_delete_icao_code = $_POST['notam_delete_icao_code'];
		echo "<font color='red'>PRESS DELETE AGAIN TO CONFIRM DELETE NOTAM '$notam_delete_icao_code/$notam_delete_id'</font><br />";
		unset($_POST['notam_delete_id']);
		}
	elseif ($_SESSION['notam_delete_confirm'])
		{
		unset($_SESSION['notam_delete_confirm']);
		}
	
	// DELETE NOTAM	
	if ($_POST['notam_delete_id'])
		{
		$notam_delete_id = $_POST['notam_delete_id'];
		$notam_delete_icao_code = $_POST['notam_delete_icao_code'];
		
		// CHECK IF NOTAM ACTIVE
		$result = mysql_query("SELECT valid_from FROM $table_name_notam WHERE id=$notam_delete_id");
		$row = mysql_fetch_array($result);
		$check_valid_from = $row['valid_from'];
		if ($check_valid_from < time())
			{
			echo "<font color='red'>ERROR: NOTAM '$notam_delete_icao_code/$notam_delete_id' IS ACTIVE AND CANNOT BE DELETED</font><br />";
			}
		else
			{
			mysql_query("
				DELETE FROM $table_name_notam 
				WHERE id=$notam_delete_id
				");
			echo "<font color='green'><b>NOTAM '$notam_delete_icao_code/$notam_delete_id' DELETED</b></font><br />";
			}
		}

	// CONFIRM STOP NOTAM
	if ($_POST['notam_stop_id'] && $_POST['notam_stop_id'] != $_SESSION['notam_stop_confirm'])
		{
		$_SESSION['notam_stop_confirm'] = $_POST['notam_stop_id'];
		$notam_stop_id = $_POST['notam_stop_id'];
		$notam_stop_icao_code = $_POST['notam_stop_icao_code'];
		echo "<font color='red'>PRESS STOP AGAIN TO CONFIRM STOP NOTAM '$notam_stop_icao_code/$notam_stop_id'</font><br />";
		unset($_POST['notam_stop_id']);
		unset($_POST['notam_stop_icao_code']);
		}
	elseif ($_SESSION['notam_stop_confirm'])
		{
		unset($_SESSION['notam_stop_confirm']);
		}

	// STOP NOTAM
	if ($_POST['notam_stop_id'])
		{
		$notam_stop_id = $_POST['notam_stop_id'];
		$notam_stop_icao_code = $_POST['notam_stop_icao_code'];
		$now = time() - 1;
		mysql_query("
			UPDATE $table_name_notam 
			SET valid_to=$now
			WHERE id=$notam_stop_id
			");
		echo "<font color='green'>NOTAM '$notam_stop_icao_code/$notam_stop_id' STOPPED (FORCED EXPIRED)</font><br />";
		}
		
	// LEVEL 1 (RETRIEVE AND CHECK)
	$notam_level = $_POST['notam_level'];
	if ($notam_level == 1)
		{
		// RETRIEVE
		$notam_valid_from_Y = $_POST['notam_valid_from_Y'];
		$notam_valid_from_m = $_POST['notam_valid_from_m'];
		$notam_valid_from_d = $_POST['notam_valid_from_d'];
		$notam_valid_from_Hi = $_POST['notam_valid_from_Hi'];
		$notam_valid_from_Hi_split = str_split($notam_valid_from_Hi,2);
			$notam_valid_from_H = $notam_valid_from_Hi_split[0];
			$notam_valid_from_i = $notam_valid_from_Hi_split[1];
		$notam_valid_to_Y = $_POST['notam_valid_to_Y'];
		$notam_valid_to_m = $_POST['notam_valid_to_m'];
		$notam_valid_to_d = $_POST['notam_valid_to_d'];
		$notam_valid_to_Hi = $_POST['notam_valid_to_Hi'];
		$notam_valid_to_Hi_split = str_split($notam_valid_to_Hi,2);
			$notam_valid_to_H = $notam_valid_to_Hi_split[0];
			$notam_valid_to_i = $notam_valid_to_Hi_split[1];
		$notam_text = strtoupper($_POST['notam_text']);
		// DATE (digits)
		if (!$notam_valid_from_m || !$notam_valid_from_d || !$notam_valid_from_Y || !$notam_valid_to_m || !$notam_valid_to_d || !$notam_valid_to_Y)
			{echo "<font color='red'>ERROR: ALL DATE FIELDS MUST BE FILLED</font><br />";}
		elseif (!checkdate($notam_valid_from_m,$notam_valid_from_d,$notam_valid_from_Y) || !checkdate($notam_valid_to_m,$notam_valid_to_d,$notam_valid_to_Y)) 
			{echo "<font color='red'>ERROR: DATE NOT VALID</font><br />";}
		// TIME (digits)
		elseif (strlen($notam_valid_from_Hi) != 4 || strlen($notam_valid_to_Hi) != 4 || !is_numeric($notam_valid_from_Hi) || !is_numeric($notam_valid_to_Hi))
			{echo "<font color='red'>ERROR: TIME MUST BE 4 DIGITS (HHMM)</font><br />";}
		// TIME (values)
		elseif (($notam_valid_from_H < 0 || $notam_valid_from_H > 23 || $notam_valid_from_i < 0 || $notam_valid_from_i > 59) || ($notam_valid_to_H < 0 || $notam_valid_to_H > 23 || $notam_valid_to_i < 0 || $notam_valid_to_i > 59))
			{echo "<font color='red'>ERROR: TIME NOT A VALID (USE VALUE FROM 0000 TO 2359)</font><br />";}
		// VALID FROM
		elseif (gmmktime($notam_valid_from_H,$notam_valid_from_i,0,$notam_valid_from_m,$notam_valid_from_d,$notam_valid_from_Y,0) < time())
			{echo "<font color='red'>ERROR: 'VALID FROM' CAN NOT BE PAST TIME</font><br />";}
		// VALID TO
		elseif (gmmktime($notam_valid_to_H,$notam_valid_to_i,0,$notam_valid_to_m,$notam_valid_to_d,$notam_valid_to_Y,0) <= gmmktime($notam_valid_from_H,$notam_valid_from_i,0,$notam_valid_from_m,$notam_valid_from_d,$notam_valid_from_Y,0))
			{echo "<font color='red'>ERROR: 'VALID TO' MUST BE AFTER 'VALID FROM'</font><br />";}
		// TEXT
		elseif (strlen($notam_text) < 1)
			{echo "<font color='red'>ERROR: NOTAM TEXT MUST BE FILLED</font><br />";}
		else
			{$notam_level = 2;}
		}

	// LEVEL 2 (SAVE)
	if ($notam_level == 2)
		{
		$notam_valid_from = gmmktime($notam_valid_from_H,$notam_valid_from_i,0,$notam_valid_from_m,$notam_valid_from_d,$notam_valid_from_Y,0);
		$notam_valid_to = gmmktime($notam_valid_to_H,$notam_valid_to_i,0,$notam_valid_to_m,$notam_valid_to_d,$notam_valid_to_Y,0);
		$query = mysql_query("
			INSERT INTO $table_name_notam (icao_code, valid_from, valid_to, text) 
			VALUES ('$aerodrome_icao_code', '$notam_valid_from', '$notam_valid_to', '$notam_text')
			");		
		echo "<font color='green'><b>NOTAM SAVED</b></font><br />";
		$notam_level = 0;
		}

	// BUTTON: OLDER THAN 72 HRS BUTTON
	echo "<form name='input' action='' method='post'>";
	if ($_SESSION['show_expired_notam'] == 1)
		{
		echo "<td align='right'><input size='8' type='hidden' value='hide' name='show_hide_expired_notam' />
		<input style='font-size:8pt;font-family:courier new' type='submit' value='HIDE EXPIRED' /></td>";
		}
	else
		{
		echo "<td align='right'><input type='hidden' value='show' name='show_hide_expired_notam' />
		<input style='font-size:8pt;font-family:courier new' type='submit' value='SHOW EXPIRED' /></td>";
		}
	echo "</form>";
		
	// END OF HEADING TABLE
	echo "</td></tr></table>";		


	
	// RETRIEVE
	$now = time();
	if ($_SESSION['show_expired_notam'] == 1)
		{$where = " ";}
	else
		{$where = " WHERE valid_to > $now ";}
	$result = mysql_query("
		SELECT id, icao_code, valid_from, valid_to, text 
		FROM $table_name_notam 
		$where 
		ORDER BY valid_from DESC
		");
	
	// TABLE
	echo "<table width='100%' border='1' cellpadding='2' cellspacing='0'>";
	echo "<tr>";
		echo "<td $style width='165' align='center' ><b>VALID FROM (UTC)</b></td>";
		echo "<td $style width='165' align='center' ><b>VALID TO (UTC)</b></td>";
		echo "<td $style ><b>TEXT</b></td>";
		echo "<td $style width='70' align='center' ><b>ID</b></td>";
		echo "<td $style width='60' align='center' ><b>EDIT</b></td>";
	echo "</tr>";
	
	// NEW NOTAM FORM
	if ($notam_level != 1)
		{
		$notam_valid_from_Y = gmdate("Y");
		$notam_valid_from_m = gmdate("m");
		$notam_valid_from_d = gmdate("d");
		$notam_valid_from_Hi = "HHMM";
		$notam_valid_to_Y = gmdate("Y");
		$notam_valid_to_m = gmdate("m");
		$notam_valid_to_d = gmdate("d");
		$notam_valid_to_Hi = "HHMM";
		$notam_text = "";
		}
	echo "<form action='' method='post'>";
		echo "<tr>";
			echo "<td $style align='center' >";
			echo "<input $style type='text' size='4' maxlength='4' name='notam_valid_from_Y' value='$notam_valid_from_Y' />-";
			echo "<input $style type='text' size='2' maxlength='2' name='notam_valid_from_m' value='$notam_valid_from_m' />-";
			echo "<input $style type='text' size='2' maxlength='2' name='notam_valid_from_d' value='$notam_valid_from_d' /> ";
			echo "<input $style type='text' size='4' maxlength='4' name='notam_valid_from_Hi' value='$notam_valid_from_Hi' />";
			echo "</td>";
			echo "<td $style align='center' >";
			echo "<input $style type='text' size='4' maxlength='4' name='notam_valid_to_Y' value='$notam_valid_to_Y' />-";
			echo "<input $style type='text' size='2' maxlength='2' name='notam_valid_to_m' value='$notam_valid_to_m' />-";
			echo "<input $style type='text' size='2' maxlength='2' name='notam_valid_to_d' value='$notam_valid_to_d' /> ";
			echo "<input $style type='text' size='4' maxlength='4' name='notam_valid_to_Hi' value='$notam_valid_to_Hi' />";
			echo "</td>";
			echo "<td colspan=2 ><input $style type='text' size='57' maxlength='255' name='notam_text' value='$notam_text' /></td>";
			echo "<td $style align='center'>
					<input type='hidden' name='notam_level' value='1' />
					<input style='font-size:8pt;font-family:courier new' type='submit' name='submit' value='SAVE' alt='SAVE' />
					</td>";
		echo "</tr>";
	echo "</form>";
	
	// WHILE
	while($row = mysql_fetch_array($result))
		{
		$not_nil = 1;
		$notam_id = $row["id"];
		$notam_icao_code = $row["icao_code"];
		$notam_valid_from = $row["valid_from"];
		$notam_valid_to = $row["valid_to"];
		$notam_text = strtoupper($row["text"]);
		
		// STATUS MARKS (colors found at http://www.w3schools.com/html/html_colors.asp)
		if ($notam_valid_from > gmmktime())
			{
			$bgcolor = "bgcolor='FFCC00'"; // future - orange
			$status = "
				<form action='' method='post'>
					<td $style $bgcolor align='center'>
					<input type='hidden' value='$notam_id' name='notam_delete_id' />
					<input type='hidden' value='$notam_icao_code' name='notam_delete_icao_code' />
					<input type='image' align='top' src='delete.gif' width='15' height='15' alt='DELETE' />
					</td>
				</form>";
			}
		elseif ($notam_valid_to < gmmktime())
			{
			$bgcolor = "bgcolor='E0E0E0'"; // past - light gray
			$status = "
				<td $style align='center' $bgcolor><img src='locked.gif' width='15' height='15' alt='LOCKED'/></td>";
			}
		else
			{
			$bgcolor = "bgcolor='98FB98'";// PaleGreen (light green with minimal contrast)
			$status = "
				<form action='' method='post'>
					<td $style $bgcolor align='center'>
					<input type='hidden' value='$notam_id' name='notam_stop_id' />
					<input type='hidden' value='$notam_icao_code' name='notam_stop_icao_code' />
					<input type='image' align='top' src='stop.gif' width='15' height='15' alt='STOP' />
					</td>
				</form>";
			}
		
		// SHOW
		echo "<tr>";
			echo "<td $style align='center' $bgcolor>" . gmdate("Y-m-d H:i",$notam_valid_from) . "</td>";
			echo "<td $style align='center' $bgcolor>" . gmdate("Y-m-d H:i",$notam_valid_to) . "</td>";
			echo "<td $style $bgcolor>$notam_text</td>";
			echo "<td $style align='center' $bgcolor>$notam_icao_code/$notam_id</td>";
			echo "$status";
		echo "</tr>";

		}

	echo "</tr></table>";
	
	}

// IF NOT LOGGED IN
elseif ($_SESSION['op_logged_in'] != 1)
	{
	// RETRIEVE FROM DB
	$now = time();
	$result = mysql_query("
	SELECT id, icao_code, text
	FROM $table_name_notam 
	WHERE 
		valid_from < $now 
		AND 
		valid_to > $now 
	ORDER BY valid_from DESC");
	
	// WHILE
	while($row = mysql_fetch_array($result))
		{
		$not_nil = 1;
		$notam_id = $row["id"];
		$notam_icao_code = $row["icao_code"];
		$notam_text = strtoupper($row["text"]);
		// SHOW
		echo $notam_text . " ($notam_icao_code/$notam_id)=<br />";
		}
	
	// DISPLAY 'NIL' IF NO DATA
	if($not_nil != 1)
		{
		echo "NIL=<br />";
		}
	}
	
echo "</td></tr>";



















// PUBLICATIONS //////////////////////////////////////////////////////////////////////
// PUBLICATIONS //////////////////////////////////////////////////////////////////////
// PUBLICATIONS //////////////////////////////////////////////////////////////////////
// PUBLICATIONS //////////////////////////////////////////////////////////////////////
// PUBLICATIONS //////////////////////////////////////////////////////////////////////
echo"<tr><td $style align='left'><hr $hr_style />";	

// HEADING
if ($_SESSION['op_logged_in'] != 1)
	{echo "<b>PUBLICATION</b><br />";}

// TABLE NAME
$table_name_publication = $database_table_prefix . "_op_publication";

// CREATE TABLE IF NOT EXIST
$sql = "CREATE TABLE IF NOT EXISTS $table_name_publication (
id smallint(4) unsigned NOT NULL AUTO_INCREMENT,
created_time INT(10) unsigned NOT NULL,
published_name VARCHAR(50) NOT NULL,
name VARCHAR(50) NOT NULL,
type VARCHAR(30) NOT NULL,
size INT NOT NULL,
content MEDIUMBLOB NOT NULL COMMENT '(max 16 mb)',
deleted_time INT(10) unsigned DEFAULT '0',
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;";
mysql_query($sql);

// IF LOGGED IN
if ($_SESSION['op_logged_in'] == 1)
	{	
	// SHOW/HIDE deleted
	if ($_POST['show_hide_publication_deleted'] == "show")
		{$_SESSION['show_deleted_publication'] = 1;}
	elseif ($_POST['show_hide_publication_deleted'] == "hide")
		{unset($_SESSION['show_deleted_publication']);}

	// HEADING TABLE
	echo "<table width='100%' $style><tr>";
	
	// HEADING
	echo "<td><b>PUBLICATION</b></td>";
	
	// MESSAGES 
	echo "<td align='center'>";

	// CONFIRM DELETE PUBLICATION
	if ($_POST['publication_delete_id'] && $_POST['publication_delete_id'] != $_SESSION['publication_delete_confirm'])
		{
		$_SESSION['publication_delete_confirm'] = $_POST['publication_delete_id'];
		$publication_delete_id = $_POST['publication_delete_id'];
		$publication_name = $_POST['publication_name'];
		echo "<font color='red'>PRESS DELETE AGAIN TO CONFIRM DELETE FILE '$publication_name'</font><br />";
		unset($_POST['publication_delete_id']);
		}
	elseif ($_SESSION['publication_delete_confirm'])
		{
		unset($_SESSION['publication_delete_confirm']);
		}

	// DELETE PUBLICATION
	if ($_POST['publication_delete_id'])
		{
		$publication_delete_id = $_POST['publication_delete_id'];
		$publication_name = $_POST['publication_name'];
		$now = time();
		mysql_query("
			UPDATE $table_name_publication 
			SET deleted_time=$now
			WHERE id=$publication_delete_id
			");
		echo "<font color='green'><b>FILE '$publication_name' DELETED</b></font><br />";
		$publication_delete_id = "";
		}

	// GET/CHECK DATA
	if(isset($_POST['upload']))
		{
		$created_time = time();
		$published_name = strtoupper($_POST['published_name']);
		$rev_Y = $_POST['rev_Y'];
		$rev_m = $_POST['rev_m'];
		$rev_d = $_POST['rev_d'];
		$fileName = $_FILES['userfile']['name'];
		$tmpName  = $_FILES['userfile']['tmp_name'];
		$fileSize = $_FILES['userfile']['size'];
		$fileType = $_FILES['userfile']['type'];
		if (strlen($published_name) < 1 || $published_name == "PUBLISHED NAME")
			{echo "<font color='red'>ERROR: PUBLISHED NAME MUST BE FILLED</font><br />";}
		elseif (!is_numeric($_POST['rev_Y']) || !is_numeric($_POST['rev_m']) || !is_numeric($_POST['rev_d']))
			{echo "<font color='red'>ERROR: REVISION DATE MUST BE FILLED</font><br />";}
		elseif (!checkdate($rev_m,$rev_d,$rev_Y))
			{echo "<font color='red'>ERROR: REVISION DATE NOT A VALID DATE</font><br />";}
		elseif (!$_FILES['userfile']['size'] > 0)
			{echo "<font color='red'>ERROR: NO FILE SELECTED, FILE IS EMPTY OR FILE IS TOO LARGE</font><br />";}
		else
			{
			$published_name_to_save = $published_name . strtoupper(gmdate(" (Y-m-d)",gmmktime(0,0,0,$rev_m,$rev_d,$rev_Y,0)));
			
			// UPLOAD FILE
			$fp      = fopen($tmpName, 'r');
			$content = fread($fp, filesize($tmpName));
			$content = addslashes($content);
			fclose($fp);
			if(!get_magic_quotes_gpc())
				{
				$fileName = addslashes($fileName);
				}
			$query = "INSERT INTO $table_name_publication (created_time, published_name, name, size, type, content ) ".
			"VALUES ('$created_time', '$published_name_to_save', '$fileName', '$fileSize', '$fileType', '$content')";
			//$control = mysql_query($query);
			$control = mysql_unbuffered_query($query);
			
			if (!$control)
				{echo "ERROR: QUERY FAILED WHEN TRY TO UPLOAD FILE";}
			else
				{echo "<font color='green'><b>FILE '$fileName' SAVED</b></font><br />";}
			
			// UNSET
			unset($_POST['upload']);
			}
		}
	// MESSAGES END
	echo "</td>";
	
	// DELETED PUBLICATION BUTTON
	echo "<form name='input' action='' method='post'>";
	if ($_SESSION['show_deleted_publication'] == 1)
		{
		echo "<td align='right'><input size='8' type='hidden' value='hide' name='show_hide_publication_deleted' />
		<input style='font-size:8pt;font-family:courier new' type='submit' value='HIDE DELETED' /></td>";
		}
	else
		{
		echo "<td align='right'><input type='hidden' value='show' name='show_hide_publication_deleted' />
		<input style='font-size:8pt;font-family:courier new' type='submit' value='SHOW DELETED' /></td>";
		}
	echo "</form>";
		
	// END OF HEADING TABLE
	echo "</tr></table>";	


	// TABLE
	echo "<table width='100%' border='1' cellpadding='2' cellspacing='0'>";// 
	echo "<tr>";
		echo "<td $style width='165' align='center' ><b>CREATED (UTC)</b></td>";
		echo "<td $style width='265' align='left' ><b>PUBLISHED NAME (REV DATE)</b></td>";
		echo "<td $style align='left' ><b>FILE NAME (MAX 15MB (IF ERROR, MAX 1MB))</b></td>";
		echo "<td $style width='60' align='center' ><b>EDIT</b></td>";
	echo "</tr>";

	// NEW PUBLICATION FORM
	if (!isset($_POST['upload']))
		{
		$published_name = "PUBLISHED_NAME";
		$rev_Y = "YYYY";
		$rev_m = "MM";
		$rev_d = "DD";
		}
	$pub_style = " style='font-size:8pt;font-family:courier new;text-transform:uppercase' ";
	echo "<form action='' method='post' enctype='multipart/form-data'><tr>";
		echo "<td $style align='center' ></td>";
			echo "<td $style >";
			echo "<input $style type='text' size='15' maxlength='40' name='published_name' value='$published_name' />";
			echo "(<input $style type='text' size='4' maxlength='4' name='rev_Y' value='$rev_Y' />-";
			echo "<input $style type='text' size='2' maxlength='2' name='rev_m' value='$rev_m' />-";
			echo "<input $style type='text' size='2' maxlength='2' name='rev_d' value='$rev_d' />) ";
			echo "</td>";
		echo "<td $style align='left'>
				<input $pub_style type='hidden' name='MAX_FILE_SIZE' value='1500000' />
				<input $pub_style type='file' name='userfile' id='userfile' />
			</td>";
		echo "<td $style align='center' >		
				<input $pub_style type='submit' name='upload' value='SAVE' alt='SAVE' />
				</td>";
	echo "</tr></form>";

	// RETRIEVE 
	if ($_SESSION['show_deleted_publication'] == 1)
		{$where = " ";}
	else
		{$where = " WHERE deleted_time = 0 ";}
	$query = "
		SELECT * FROM $table_name_publication 
		$where 
		ORDER BY created_time DESC
		";
	$result = mysql_query($query) or die('Error, \'show\' query failed');
	
	// SHOW
	while($row = mysql_fetch_array($result))
		{
		$publication_id = $row['id'];
		$created_time = $row["created_time"];
		$published_name = $row["published_name"];
		$name = $row["name"];
		if ($row["size"] < 1000000)
			{$size = round(($row["size"] / 1000),0) . "KB";}
		else
			{$size = round(($row["size"] / 1000000),1) . "MB";}
		$deleted_time = $row["deleted_time"];

		if ($deleted_time != 0)
			{
			$bgcolor = ""; // dark gray
			$del_start = "<del>";	$del_end = "</del>";
			$deleted_time = " [DELETED " . gmdate("Y-m-d H:i",$deleted_time) . "]";
			$name_row_format = " colspan='3' ";
			$edit = "";
			}
		else
			{
			$bgcolor = "bgcolor='98FB98'"; // green
			$del_start = "";	$del_end = "";
			$name_row_format = "";
			$deleted_time = "";
			$edit = "
				<form action='' method='post'>
					<td $style align='center' $bgcolor>
						<input type='hidden' value='$publication_id' name='publication_delete_id' />
						<input type='hidden' value='$name' name='publication_name' />
						<input type='image' src='delete.gif' width='15' height='15' alt='DELETE' /> 
					</td>
				</form>
				";
			}
		
		echo "<tr>";
		echo "<td $style $bgcolor align='center' >$del_start" . gmdate("Y-m-d H:i",$created_time) . "$del_end</td>";
		echo "<td $style $bgcolor >$del_start$published_name$del_end</td>";
		echo "<td $style $bgcolor $name_row_format><a href='download_publication.php?download_publication_id=$publication_id'>$del_start$name ($size)$del_end</a>$deleted_time</td>";
		echo $edit;
		echo "</tr>";
		
		// CANCEL del tag
		unset($del_start); unset($del_end);
		}

	echo "</table>"; // TO INFO: END OF "// TABLE" SECTION	

	} // END OF "IF LOGGED IN"


// IF NOT LOGGED IN
if ($_SESSION['op_logged_in'] != 1)
	{
	
	// RETRIEVE 
	$query = "
		SELECT * FROM $table_name_publication 
		WHERE deleted_time = 0 
		ORDER BY created_time DESC
		";
	$result = mysql_query($query);
	if (!$result)
		{echo "Error, publication retrieve query failed";}
	elseif(mysql_num_rows($result) == 0)
		{
		echo "NIL=<br>";
		}
	else
		{
		while($row = mysql_fetch_array($result))
			{
			$publication_id = $row['id'];
			$published_name = $row["published_name"];
			echo "<a href='download_publication.php?download_publication_id=$publication_id'>$published_name</a>=<br />";
			}
		}
	}
	


















echo "</td></tr>"; // AVSLUTTER PUBLICATION

// TRAFFIC ///////////////////////////////////////////////////////////////////////////
// TRAFFIC ///////////////////////////////////////////////////////////////////////////
// TRAFFIC ///////////////////////////////////////////////////////////////////////////
// TRAFFIC ///////////////////////////////////////////////////////////////////////////
// TRAFFIC ///////////////////////////////////////////////////////////////////////////

	
// TABLE NAME
$table_name_traffic = $database_table_prefix . "_op_traffic";	

// CREATE TABLE IF NOT EXIST
$sql = "CREATE TABLE IF NOT EXISTS $table_name_traffic (
id smallint(4) unsigned NOT NULL AUTO_INCREMENT,
created_time int(10) unsigned NOT NULL,
time int(10) unsigned NOT NULL,
type enum('LANDING','TAKE OFF','OTHER') DEFAULT NULL,
registration char(6) DEFAULT NULL,
comments varchar(255) DEFAULT NULL,
deleted_time int(10) unsigned DEFAULT '0',
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;";
mysql_query($sql);

// IF LOGGED IN
if ($_SESSION['op_logged_in'] == 1)
	{
	echo"<tr><td $style align='left'><hr $hr_style />";
	
	// SHOW/HIDE older than 72 hrs
	if ($_POST['show_hide_traffic_older_than_72hrs'] == "show")
		{$_SESSION['show_traffic_older_than_72hrs'] = 1;}
	elseif ($_POST['show_hide_traffic_older_than_72hrs'] == "hide")
		{unset($_SESSION['show_traffic_older_than_72hrs']);}

	// SHOW/HIDE deleted
	if ($_POST['show_hide_traffic_deleted'] == "show")
		{$_SESSION['show_deleted_traffic'] = 1;}
	elseif ($_POST['show_hide_traffic_deleted'] == "hide")
		{unset($_SESSION['show_deleted_traffic']);}
		
	// HEADING TABLE
	echo "<table width='100%' $style><tr>";
	
	// HEADING
	echo "<td><b>TRAFFIC</b></td>";
	
	// MESSAGES 
	echo "<td align='center'>";

	// CONFIRM DELETE PUBLICATION
	if ($_POST['traffic_delete_id'] && $_POST['traffic_delete_id'] != $_SESSION['traffic_delete_confirm'])
		{
		$_SESSION['traffic_delete_confirm'] = $_POST['traffic_delete_id'];
		$traffic_delete_id = $_POST['traffic_delete_id'];
		$traffic_delete_details = $_POST['traffic_delete_details'];
		echo "<font color='red'>PRESS DELETE AGAIN TO CONFIRM DELETE TRAFFIC '$traffic_delete_details'</font><br />";
		unset($_POST['traffic_delete_id']);
		}
	elseif ($_SESSION['traffic_delete_confirm'])
		{
		unset($_SESSION['traffic_delete_confirm']);
		}

	// DELETE TRAFFIC
	if ($_POST['traffic_delete_id'])
		{
		$traffic_delete_id = $_POST['traffic_delete_id'];
		$now = time();
		mysql_query("
			UPDATE $table_name_traffic 
			SET deleted_time=$now
			WHERE id=$traffic_delete_id
			");
		echo "<font color='green'><b>TRAFFIC DELETED</b></font><br />";
		$traffic_delete_id = "";
		}
		
	// LEVEL 1 (RETRIEVE AND CHECK)
	$traffic_level = $_POST['traffic_level'];
	if ($traffic_level == 1)
		{
		// RETRIEVE
		$traffic_time_Y = $_POST['traffic_time_Y'];
		$traffic_time_m = $_POST['traffic_time_m'];
		$traffic_time_d = $_POST['traffic_time_d'];
		$traffic_time_Hi = $_POST['traffic_time_Hi'];
		$traffic_time_Hi_split = str_split($traffic_time_Hi,2);
			$traffic_time_H = $traffic_time_Hi_split[0];
			$traffic_time_i = $traffic_time_Hi_split[1];
		$traffic_type = $_POST['traffic_type'];
		$traffic_reg = strtoupper($_POST['traffic_reg']);
		$traffic_comments = strtoupper($_POST['traffic_comments']);
		
		// DATE (digits)
		if (!$traffic_time_Y || !$traffic_time_m || !$traffic_time_d)
			{echo "<font color='red'>ERROR: ALL DATE FIELDS NOT FILLED</font><br />";}
		elseif (!checkdate($traffic_time_m,$traffic_time_d,$traffic_time_Y)) 
			{echo "<font color='red'>ERROR: DATE NOT A VALID</font><br />";}
		// TIME (digits)
		elseif (strlen($traffic_time_Hi) != 4 || !is_numeric($traffic_time_Hi))
			{echo "<font color='red'>ERROR: TIME MUST BE 4 DIGITS (HHMM)</font><br />";}
		// TIME (values)
		elseif (($traffic_time_H < 0 || $traffic_time_H > 23 || $traffic_time_i < 0 || $traffic_time_i > 59))
			{echo "<font color='red'>ERROR: TIME NOT A VALID (USE VALUE FROM 0000 TO 2359)</font><br />";}
		// VALID FROM
		elseif (gmmktime($traffic_time_H,$traffic_time_i,0,$traffic_time_m,$traffic_time_d,$traffic_time_Y,0) > time())
			{echo "<font color='red'>ERROR: TIME CAN NOT BE IN THE FUTURE</font><br />";}
		// TYPE
		elseif ($traffic_type == "") 
			{echo "<font color='red'>ERROR: 'TYPE' MUST BE SELECTED</font><br />";}
		// REG
		elseif (strlen($traffic_reg) <= 4 && $traffic_reg != "?")
			{echo "<font color='red'>ERROR: 'REG' TOO SHORT (IF UNKNOWN, USE '?')</font><br />";}
		// COMMENTS
		elseif ($traffic_type == "OTHER" && strlen($traffic_comments) < 1) 
			{echo "<font color='red'>ERROR: IF 'TYPE' SET TO 'OTHER', COMMENTS MUST BE FILLED</font><br />";}
		elseif ($traffic_reg == "?" && strlen($traffic_comments) < 1) 
			{echo "<font color='red'>ERROR: IF 'REG' SET TO '?' (UNKNOWN), COMMENTS MUST BE FILLED</font><br />";}
		else
			{$traffic_level = 2;}
		}

	// LEVEL 2 (SAVE)
	if ($traffic_level == 2)
		{
		$now = time();
		$traffic_time = gmmktime($traffic_time_H,$traffic_time_i,0,$traffic_time_m,$traffic_time_d,$traffic_time_Y,0);
		// IF TOUCH AND GO ---> SPLIT IN TWO RECORDS
		if ($traffic_type == "TOUCH AND GO")
			{
			$query = mysql_query("
				INSERT INTO $table_name_traffic (created_time, time, type, registration, comments) 
				VALUES ('$now', '$traffic_time', 'LANDING', '$traffic_reg', '$traffic_comments')
				");
			$traffic_type = "TAKE OFF";
			}
		$query = mysql_query("
			INSERT INTO $table_name_traffic (created_time, time, type, registration, comments) 
			VALUES ('$now', '$traffic_time', '$traffic_type', '$traffic_reg', '$traffic_comments')
			");	
		echo "<font color='green'><b>TRAFFIC SAVED</b></font><br />";
		$traffic_level = 0;
		}
		
	// MESSAGES END
	echo "</td>";
	
	// EXPORT
	echo "<td $style width='95' align='right'><a href='download_traffic.php' target='_blank' >EXPORT DATA</a></td>";
	
	// OLDER THAN 72 HRS BUTTON
	echo "<form action='' method='post'>";
	if ($_SESSION['show_traffic_older_than_72hrs'] == 1)
		{
		echo "<td width='10' align='right'><input size='8' type='hidden' value='hide' name='show_hide_traffic_older_than_72hrs' />
		<input style='font-size:8pt;font-family:courier new' type='submit' value='HIDE OLDER THAN 72 HRS' /></td>";
		}
	else
		{
		echo "<td width='10' align='right'><input type='hidden' value='show' name='show_hide_traffic_older_than_72hrs' />
		<input style='font-size:8pt;font-family:courier new' type='submit' value='SHOW OLDER THAN 72 HRS' /></td>";
		}
	echo "</form>";
	
	// DELETED TRAFFIC
	echo "<form action='' method='post'>";
	if ($_SESSION['show_deleted_traffic'] == 1)
		{
		echo "<td width='10' align='right'><input size='8' type='hidden' value='hide' name='show_hide_traffic_deleted' />
		<input style='font-size:8pt;font-family:courier new' type='submit' value='HIDE DELETED' /></td>";
		}
	else
		{
		echo "<td width='10' align='right'><input type='hidden' value='show' name='show_hide_traffic_deleted' />
		<input style='font-size:8pt;font-family:courier new' type='submit' value='SHOW DELETED' /></td>";
		}
	echo "</form>";

	// RETRIEVE
	$traffic_ago = time() - 259200;
	if ($_SESSION['show_deleted_traffic'] == 1)
		{
		$where = " ";
		if ($_SESSION['show_traffic_older_than_72hrs'] == 1)
			{$where = " ";}
		else
			{$where = " WHERE time > $traffic_ago ";}
		}
	else
		{
		$where = " WHERE deleted_time = 0 ";
		if ($_SESSION['show_traffic_older_than_72hrs'] == 1)
			{$where = $where;}
		else
			{$where = $where . " AND time > $traffic_ago ";}
		}

	$result = mysql_query("
		SELECT id, time, type, registration, comments, deleted_time
		FROM $table_name_traffic 
		$where 
		ORDER BY time DESC");  //WHERE deleted_time = '0' 
	
	// TABLE
	echo "<table width='100%' border='1' cellpadding='2' cellspacing='0'>";
	echo "<tr>";
		echo "<td $style width='165' align='center'><b>TIME (UTC)</b></td>";
		echo "<td $style width='60' align='center'><b>TYPE</b></td>";
		echo "<td $style width='60' align='center'><b>REG</b></td>";
		echo "<td $style ><b>COMMENTS</b></td>";
		echo "<td $style width='60' align='center'><b>EDIT</b></td>";
	echo "</tr>";

	// NEW TRAFFIC FORM
	if ($traffic_level != 1)
		{
		$traffic_time_Y = gmdate("Y");
		$traffic_time_m = gmdate("m");
		$traffic_time_d = gmdate("d");
		$traffic_time_Hi = "HHMM";
		$traffic_type = "";
		$traffic_reg = "";
		$traffic_comments = "";
		}
	if ($traffic_type == "") {$traffic_type_selected_blank_selected = "selected";}
	if ($traffic_type == "LANDING") {$traffic_type_selected_landing = "selected";}
	if ($traffic_type == "TAKE OFF") {$traffic_type_selected_takeoff = "selected";}
	if ($traffic_type == "TOUCH AND GO") {$traffic_type_selected_touchandgo = "selected";}
	if ($traffic_type == "OTHER") {$traffic_type_selected_other = "selected";}
	echo "<tr>";
		echo "<form action='' method='post' >";
		echo "<td $style align='center' >";
		echo "<input $style type='text' size='4' maxlength='4' name='traffic_time_Y' value='$traffic_time_Y' />-";
		echo "<input $style type='text' size='2' maxlength='2' name='traffic_time_m' value='$traffic_time_m' />-";
		echo "<input $style type='text' size='2' maxlength='2' name='traffic_time_d' value='$traffic_time_d' /> ";
		echo "<input $style type='text' size='4' maxlength='4' name='traffic_time_Hi' value='$traffic_time_Hi' />";
		echo "</td>";
		echo "<td $style align='center' >
			<select $style name='traffic_type'>
			<option value='' $traffic_type_selected_blank></option>
			<option value='LANDING' $traffic_type_selected_landing>LANDING</option>
			<option value='TAKE OFF' $traffic_type_selected_takeoff>TAKE OFF</option>
			<option value='TOUCH AND GO' $traffic_type_selected_touchandgo>TOUCH AND GO</option>
			<option value='OTHER' $traffic_type_selected_other>OTHER</option>
			</select></center></td>";
		echo "<td $style align='center' >
			<input $style type='text' size='6' maxlength='6' name='traffic_reg' value='$traffic_reg' /></td>";
		echo "<td $style >
			<input $style type='text' size='53' maxlength='255' name='traffic_comments' value='$traffic_comments' /></td>";
		echo "<td align='center' >
				<input type='hidden' name='traffic_level' value='1' />
				<input style='font-size:8pt;font-family:courier new' type='submit' name='submit' value='SAVE' alt='SAVE' />
			</td>";
		echo "</form>";		
	echo "</tr>";

	// WHILE
	while($row = mysql_fetch_array($result))
		{
		$not_nil = 1;
		$traffic_id = $row["id"];
		$traffic_time = $row["time"];
		$traffic_time_show = gmdate("Y-m-d H:i",$traffic_time);
		$traffic_type = $row["type"];
		$traffic_reg = $row["registration"];
		$traffic_comments = $row["comments"];
		$traffic_deleted_time = $row["deleted_time"];
		
		// STATUS MARKS (colors found at http://www.w3schools.com/html/html_colors.asp)
		if ($traffic_time < $traffic_ago)
			{$traffic_bgcolor = "bgcolor='E0E0E0'";} // > 72 hrs ago - light gray
		else
			{$traffic_bgcolor = "";}
		if ($traffic_deleted_time != 0)
			{
			$comment_row_format = " colspan='2' ";
			$del_start = "<del>";	$del_end = "</del>";
			$deleted_time = " [DELETED " . gmdate("Y-m-d H:i",$traffic_deleted_time) . "]";
			$edit = "";
			}
		else
			{
			$comment_row_format = "";
			$deleted_time = "";
			$edit = "
				<form action='' method='post'>
					<td $style align='center' $traffic_bgcolor>
						<input type='hidden' value='$traffic_id' name='traffic_delete_id' />
						<input type='hidden' value='$traffic_time_show/$traffic_type/$traffic_reg' name='traffic_delete_details' />
						<input type='image' src='delete.gif' width='15' height='15' alt='DELETE' /> 
					</td>
				</form>
				";
			}
		
		// SHOW
		echo "<tr >";
		echo "<td $style $traffic_bgcolor align='center'>$del_start$traffic_time_show$del_end</td>";
		echo "<td $style $traffic_bgcolor align='center'>$del_start$traffic_type$del_end</td>";
		echo "<td $style $traffic_bgcolor align='center'>$del_start$traffic_reg$del_end</td>";
		echo "<td $style $traffic_bgcolor $comment_row_format>$del_start$traffic_comments$del_end$deleted_time</td>";
		echo $edit;
		echo "</tr>";
		
		// CANCEL del tag
		unset($del_start); unset($del_end);
		}
	echo "</table>";

	}

echo "</td></tr>";


// FOOTER ///////////////////////////////////////////////////////////////////////////
// FOOTER ///////////////////////////////////////////////////////////////////////////
// FOOTER ///////////////////////////////////////////////////////////////////////////
// FOOTER ///////////////////////////////////////////////////////////////////////////
// FOOTER ///////////////////////////////////////////////////////////////////////////
echo"<tr><td $style align='center'><hr $hr_style />";

	if ($aerodrome_phone != '')
		{
		echo "<b>" . strtoupper($aerodrome_phone) . '</b><br />';
		}
	if ($aerodrome_email != '')
		{
		echo "<b>" . strtoupper($aerodrome_email) . '</b><br />';
		}
	echo '<b>' . gmdate('Y-m-d H:i:s') . ' UTC</b><br />';
	echo '<b>END OF INFORMATION</b>';
	
echo "</td></tr>";


// BUTTONS ///////////////////////////////////////////////////////////////////////////
// BUTTONS ///////////////////////////////////////////////////////////////////////////
// BUTTONS ///////////////////////////////////////////////////////////////////////////
// BUTTONS ///////////////////////////////////////////////////////////////////////////
// BUTTONS ///////////////////////////////////////////////////////////////////////////
echo"<tr><td $style align='center'>";

	echo "<table><tr>";
	
		echo "<td>";
			//HELP
			if ($_POST['help'] == "show")
				{$_SESSION['help'] = 1;}
			elseif ($_POST['help'] == "hide")
				{unset($_SESSION['help']);}
			if ($_SESSION['help'] == 1)
				{$help_hide_show = "hide";}
			else
				{$help_hide_show = "show";}
			echo "	<form name='input' action='' method='post'>
							<input style='font-size:8pt;font-family:courier new' size='8' type='hidden' value='$help_hide_show' name='help' />
							<input type='image' valign='center' align='center' src='help.gif' width='13' height='13' alt='HELP' />
					</form>";
		echo "</td>";
		
		echo "<td>";

			// LOGIN
			if ($_SESSION['op_logged_in'] == 1)
				{
				echo "
				<form name='input' action='?' method='post'>
						<input type='hidden' value='log_out' name='log_out' />
						<input type='image' valign='center' align='center' src='login.gif' width='13' height='13' alt='LOG OUT' />
				</form>
				";
				}
			else
				{
				echo "
				<form name='input' action='?' method='post'>";
					if (!$_POST['password'] || $_POST['password'] == "")
						{echo "<input style='font-size:8pt;font-family:courier new' value='show_field_15226' type='hidden' name='password' />";}
					else
						{echo "<input style='font-size:8pt;font-family:courier new' size='4' type='password' name='password' />";}
					
					echo "<input type='image' valign='center' align='center' src='login.gif' width='13' height='13' alt='LOGIN' />
				</form>
				";
				}
		echo "</td>";
	
	echo "</tr></table>";

echo "</td></tr>";

// HELP TEXT ///////////////////////////////////////////////////////////////////////////
// HELP TEXT ///////////////////////////////////////////////////////////////////////////
// HELP TEXT ///////////////////////////////////////////////////////////////////////////
// HELP TEXT ///////////////////////////////////////////////////////////////////////////
// HELP TEXT ///////////////////////////////////////////////////////////////////////////
if ($_SESSION['help'] == 1)
	{

	echo"<tr><td $style align='left'><hr $hr_style />";
	
		echo "
			<b>HELP</b><br />
			<br />
			GENERAL: ALL DATE AND TIME IS UTC. PAGE, LINKS AND CONTENTS ARE NOT AUTHORIZED BY AUTHORITIES, NOT CONNECTED TO AFTN SYSTEM AND MAY CONTAIN ERROR.<br />
			<br />
			WEATHER GENERAL: VALUES MUST BE USED AS GUIDENS ONLY. THIS IS A NON-PROFFESIONAL SYSTEM AND MAY THEREFOR CONTAIN ERROR. '/' MEANS THAT VALUE CANNOT BE RETRIEVED.<br />
			<br />
			METAR: UPDATED AT SCHEDULED TIMES EVERY HOUR OR WHEN MANUAL OBSERVATION HAS BEEN MADE. WHEN 'AUTO' IS INDICATED, METAR IS COMPLETELY AUTOMATED AND CONTAIN DATA ABOUT WIND, TEMPERATURE, DEWPOINT AND QNH ONLY. WHEN MANUAL OBSERVATION HAS BEEN MADE (METAR WITHOUT 'AUTO' INDICATED), DATA ABOUT VISIBILITY, WEATHER AND CLOUDS HAVE PRESUMABLY BEEN ADDED TO THE METAR.<br />
			<br />
			FORECAST: 48 HRS METEOGRAM FROM HTTP://WWW.YR.NO.<br />
			<br />
			WINDREP: BASED ON 2 MINUTES WIND. UPDATED EVERY 14 SECONDS. BROWSER AUTO REFRESHING.<br />
			<br />
			NOTAM: LOCAL NOTAM FOR $aerodrome_icao_code. ALTHOUGH, IN CASE OF NO NOTAM, YOU CAN NOT BE GARANTEED THAT AERODROME IS 'OK'.<br />
			<br />
			";
		if ($_SESSION['op_logged_in'] == 1)
		{
		echo "
			PUBLICATION: PUBLICATIONS IS RECOMMENDED TO BE 'APPROACH CHART', 'AERODROME CHART' OR 'TEXTPAGE'.<br />
			<br />			
			TRAFFIC: ONE MOVEMENT IS DEFINED AS A LANDING OR A TAKE OFF. I.E. LOW APPROACH IS ZERO MOVEMENTS, TOUCH AND GO IS 2 MOVEMENTS. WHEN YOU SELECT 'TOUCH AND GO', ONE 'LANDING' AND ONE 'TAKE OFF' WILL BE RECORDED.<br />
			<br />
		";
		}
	
	echo "<hr $hr_style /></td></tr>";
	}



// END HTML ///////////////////////////////////////////////////////////////////////////
// END HTML ///////////////////////////////////////////////////////////////////////////
// END HTML ///////////////////////////////////////////////////////////////////////////
// END HTML ///////////////////////////////////////////////////////////////////////////
// END HTML ///////////////////////////////////////////////////////////////////////////
echo "</table></body></html>";
mysql_close($con);
?>
Return current item: Operational Information