<?php
if (isset($_GET["q"]) && !empty($_GET["q"]))
{
if (file_exists("functions/site_functions.php"))
	{
	include_once("functions/site_functions.php");
	}
else
	{
include_once("../../functions/site_functions.php");
	}
	$q = $_GET["q"];
	if (preg_match("/[^0-9\' ']/", $q))
		{
		echo"Invalid data";
		}
	else
		{
	db_open();
	$sql="SELECT * FROM users WHERE user_id='$q'";
	@ $result=mysql_query($sql);
	$row=mysql_fetch_array($result);
	$device_id= $row['device_id'];
	$email= $row['email'];
	$userlevel=$row['userlevel'];
	$last_entry = $row['last_login'];
	$total_visits = $row['visits'];
	$messages=$row['messages'];
	$user_id=$row['user_id'];
	if ($userlevel==0)
		{
		$delete= '';
		$change='';
		$change1='';
		}
	else
		{
		$delete= '<a class="delete" title="delete device" onclick="delete_user('.$user_id.');" ><span>Delete</span></a>';
		$change='title="click to change email" onclick="change_email(1);"';
		$change1='hoverrrrr';
		}

		//funciton to get database requests
		
echo<<<a
<table id="p_i" class="user_display">
<tr>
<td class="td_title_users_display" >Device_id</td>
<td id="d" class="td_data_users_display">$device_id</td>
</tr>
a;
$sqlq="SELECT * FROM devices WHERE device_id='$device_id'";
$rowe=mysql_fetch_array(mysql_query($sqlq));
echo '<tr><td class="td_title_users_display">Device Password</td><td class="td_data_users_display">'.$rowe['password'].'</td><tr>';
echo<<<a
<tr>
<td class="td_title_users_display">Email</td>
<td  id="email" class="td_data_users_display"><a class="$change1" $change>$email</a></td>
</tr>
<tr>
<td class="td_title_users_display">Last Entry</td>
<td class="td_data_users_display">$last_entry</td>
</tr>
<tr>
<td class="td_title_users_display">Total Visits</td>
<td class="td_data_users_display">$total_visits</td>
</tr>
<tr>
<td class="td_title_users_display">Userlevel</td>
<td class="td_data_users_display">$userlevel</td>
</tr>
<tr>
<td class="td_title_users_display">Messages</td>
<td class="td_data_users_display"><a class="mess" onclick="messages(2,$user_id);">$messages</a></td>
</tr>
<tr>
<td class="td_title_users_display">Action</td>
<td id="e" class="td_data_users_display">$delete</td>
</tr>
</table>
a;
		
		db_close();	}
}
?>