<?php
session_start();
/*
 * Administation/formUsers.php
 * 
 * Copyright 2009, 2018 Pedro Quaresma <pedro@mat.uc.pt>
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 */

require_once("../servidor.php");

$pTipoUtilizador = $_SESSION['tipoUtilizador'];
if ($pTipoUtilizador=="anonymous" || $pTipoUtilizador=="regular") { // separa por tipo de utilizador
  require($entradaFILE.'headerUsers.php');
  require($entradaFILE.'menuAdmins.php');
  echo "<meta http-equiv='refresh' content='0; url=".$entradaURL."users.php' />";
  exit;  // os anonimos não têem acesso a esta página
}
else {
  require($entradaFILE.'headerAdmins.php');
  require($entradaFILE.'menuAdmins.php');
}

// coloca o valor para a página de ajuda apropriada
$_SESSION['helpsection']='logs';

require_once($entradaFILE.'dbLogin.php');

?>

<hr/>

<center>
<h3 class="maketitle">User Report</h3>
</center>

<hr/>

<?php
$argumento = $_GET['argumento'];

// cria uma pesquisa
$sql = "SELECT userId,name,affiliation,url,email,dateSubmission,
               username,type
          FROM users
         WHERE userId='$argumento'";

$resultado = mysqli_query($ligacao,$sql);

$ncampos =mysqli_num_fields($resultado);


$linha = mysqli_fetch_assoc($resultado);

$pUserId         = $linha['userId'];
$pName           = $linha['name'];
$pAffiliation    = $linha['affiliation'];
$pURL            = $linha['url'];
$pEmail          = $linha['email'];
$pDateSubmission = $linha['dateSubmission'];
$pUsername       = $linha['username'];
$pType           = $linha['type'];

echo "<!-- ficha -->";
echo "<table width='100%' bgcolor='white' cellpadding='4' cellspacing='4'>";
echo "<tr>";
echo "<td width='100%' colspan='8' align='center'>User Info</td>";
echo "</tr>";
echo "<tr>";
echo "<td align='left' width='25%' colspan='2'><span class='ficha'>Name</span></td>";
echo "<td width='50%' colspan='4'>$pName</td>";
echo "<td align='left' width='12.5%' colspan='1'><span class='ficha'>User's Id</span></td>";
echo "<td width='12.5%' colspan='1'>$pUserId</td>";
echo "</tr>";
echo "<tr>";
echo "<td width='25%' colspan='2'><span class='ficha'>Affiliation</span></td>";
echo "<td width='75%' colspan='6'>$pAffiliation</td>";
echo "</tr>  ";
echo "<tr>";
echo "<td width='12.5%' colspan='1'><span class='ficha'>URL</span></td>";
echo "<td width='37.5%' colspan='3'>$pURL</td>";
echo "<td width='12.5%' colspan='1'><span class='ficha'>Email</span></td>";
echo "<td width='37.5%' colspan='3'>$pEmail</td>";
echo "</tr>\n";
echo "<tr>";
echo "<td width='25%' colspan='2'><span class='ficha'>Username</span></td>";
echo "<td width='25%' colspan='2'>$pUsername</td>";
echo "<td width='25%' colspan='2'><span class='ficha'>Type</span> </td>";
echo "<td width='25%' colspan='2'>$pType</td>";
echo "</tr> \n";
echo "<tr>\n";
echo "<td width='25%' colspan='2'><span class='ficha'>Date of Submission</span></td>";
echo "<td width='75%' colspan='6' align='left'>$pDateSubmission</td>"; 
echo "</tr>";
echo "</table>";
?>

<hr/>

<?php
  require($entradaFILE.'footer.php');
?>
