<?php
//prevents caching
header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: post-check=0, pre-check=0",false);
session_cache_limiter();
session_start();

require('../config.php');
require('../functions.php');

//check for administrative rights
if (allow_access(Administrators) != "yes")
{
	include ('../check_login.php');
	exit;
}

//make connection to dbase
$connection = @mysql_connect($server, $dbusername, $dbpassword)
			or die(mysql_error());
			
$db = @mysql_select_db($db_name,$connection)
			or die(mysql_error());

//build and issue the query
$sql ="SELECT * FROM $table_name";
$result = @mysql_query($sql,$connection) or die(mysql_error());

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Language" content="es-ES" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Información de usuario - La Factoría Verde</title>
    <link rel="stylesheet" type="text/css" href="estilos.css">
</head>

<body>
<div id="layout">
  <div id="header"> <img src="../img/lafactoriaverde.gif" alt="La Factoría Verde" />
    <div style="float: right;">Sesión iniciada como <?php echo $_SESSION[user_name]; ?></div>
    <?php include('_menu.php'); ?>
  </div>
  <div id="content">


<?php
	if (isset($_GET['user_det'])) {
		$s_string = $_GET['user_det'];
		$explodeit = explode(" ", "$s_string");
		$c = count($explodeit);
		if ($c > 1) {
			for ($i = 0; $i < $c; $i++) {
				$user_det = $explodeit[$i] . "+";
			}
		}
		else {
			$user_det = $s_string;
		}
	}

	if ($user_det != "") {
		echo "<h2>Detalles del usuario '".$user_det."'</h2>";
		$dsql = "SELECT * FROM $table_name WHERE username = '$user_det'";
		$dresults = @mysql_query($dsql, $connection) or die(mysql_error());
		while ($dsql = mysql_fetch_object($dresults)) {
			$fname = $dsql->firstname;
			$lname = $dsql->lastname;
			$uname = $dsql->username;
			$p_change = $dsql->pchange;
			$verif_d = $dsql->verified;
			$last = $dsql->last_login;
			$re_direct = $dsql->redirect;
			$groupA = $dsql->group1;
			$groupB = $dsql->group2;
			$groupC = $dsql->group3;
			$e_mail = $dsql->email;
			if ($p_change == "0") {
				$p_change = "No";
			}
			else {
				$p_change = "Yes";
			}

			if ($verif_d == "0") {
				$verif_d = "No";
			}
			else {
				$verif_d = "Yes";
			}
			?>  
	<br/>

    <table width="100%" id="table1">
      <tr>
        <td width="100" rowspan="10" valign="top"><?php echo $uname; ?></td>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td width="177">E-Mail:</td>
        <td><a href="<?php echo $e_mail; ?>"><?php echo $e_mail; ?></a></td>
      </tr>
      <tr>
        <td width="177">Nombre completo:</td>
        <td><?php echo "$fname $lname &nbsp;"; ?></td>
      </tr>
      <tr>
        <td width="177">Última sesión:</td>
        <td><?php echo $last; ?>&nbsp;</td>
      </tr>
      <tr>
        <td width="177">Solicitud de cambio de contraseña:</td>
        <td><?php echo $p_change; ?>&nbsp;</td>
      </tr>
      <tr>
        <td width="177">Verificar e-mail:</td>
        <td><?php echo $verif_d; ?>&nbsp;</td>
      </tr>
      <tr>
        <td width="177">Miembro del grupo:</td>
        <td><?php echo $groupA; ?>&nbsp;</td>
      </tr>
      <tr>
        <td width="177">&nbsp;</td>
        <td><?php echo $groupB; ?>&nbsp;</td>
      </tr>
      <tr>
        <td width="177">&nbsp;</td>
        <td><?php echo $groupC; ?>&nbsp;</td>
      </tr>
      <tr>
        <td width="177">Redirigir a:</td>
        <td><?php echo $re_direct; ?></td>
      </tr>
    </table>
	<br/>
    <center>
      <a href="<?php echo "adminpage.php"; ?>">Volver a la lista</a>
    </center>
    <?php }
}?>
	</div>
  <div id="footer"> </div>
</div>
</body>
</html>