<?php
if (isset($_GET["a"]) && !empty($_GET["a"]) && $_GET["a"]<=5 && $_GET["a"]>=0)
{
if (file_exists("functions/site_functions.php"))
	{
	include_once("functions/site_functions.php");
	}
else
	{
include_once("../../functions/site_functions.php");
	}
	db_open();
	$a= strip_tags(htmlspecialchars(mysql_real_escape_string(trim($_GET['a']))));
	if ($a==1)
	{
	$sql="SELECT * FROM users WHERE userlevel='1'";
	@ $result=mysql_query($sql);
	if (mysql_numrows($result)!=0)
		{
		echo '<select id="2" onchange="troubleshoots(2,this.value,1);"><option value="">Select user</option>';
		while($row=mysql_fetch_array($result))
			{
			echo '<option value="'.$row['user_id'].'">'.$row['user_id'].'</option>';
			}
		echo "</select>";	
		}	
	}
	else if ($a==2)
	{
	echo '<select id="3" onchange="troubleshoots(3,this.value,1);"><option value="">Select Year/Month</option>';
	for ($i=1;$i<=12;$i++)
		{
		if($i<=9)
			{
			$i='0'.$i;
			}
		echo'<option value="'.date("Y").$i.'">'.date("Y").'-'.$i.'</option>';
		}
	echo "</select>";	
	}
	else if ($a==3)
		{
		echo '<select id="4" onchange="troubleshoots(4,this.value,1);"><option value="">Select problem</option>';
		echo '<option value="1">sensor not working</option><option value="2">sensor data problem</option>';
		echo '<option value="3">connection problem</option><option value="4">mail problem</option>';
		echo "</select>";
		}
	else if ($a==4)
		{
		$sql="SELECT * FROM users WHERE userlevel='1'";
		@ $result=mysql_query($sql);
		if (mysql_numrows($result)!=0)
			{
			echo '<select id="2" onchange="messages(2,this.value,1);"><option value="">Select user</option>';
			while($row=mysql_fetch_array($result))
				{
				echo '<option value="'.$row['user_id'].'">'.$row['user_id'].'</option>';
				}
			echo "</select>";	
			}
		}
	else if ($a==5)
		{
		echo '<select id="3" onchange="messages(3,this.value,1);"><option value="">Select Year/Month</option>';
		for ($i=1;$i<=12;$i++)
			{
			if($i<=9)
				{
				$i='0'.$i;
				}
			echo'<option value="'.date("Y").$i.'">'.date("Y").'-'.$i.'</option>';
			}
		echo "</select>";
		}
	else	
		{
		die();
		}
db_close();	
}
?>