<?php 
include_once 'CheckLogOut.php';
require_once 'Connection.php';
require_once 'Contact.php';
// para atualizar a lista
require_once 'User.php';
require_once 'CacheArquivo.php';
////////////////////////////
require_once 'Log.php';
$con = new Connection();
$c = new Contact();
$c->ContactId($_GET['contactId']);
$c->DeleteContact();
// para atualizar a lista
$u = new User();
$cacheArquivo = new CacheArquivo();
$cacheArquivo->set_valor($UsId);
$Contacts = $u->GetAllContacts($USERID);
$valor = json_encode($Contacts);
$cacheArquivo->set_valor($USERID, $valor);
////////////////////////////
$Log = new Log(3);
// log de deleção, conforme a tabela Actions
$Log->UserId($USERID);
//
$Log->InsertLog();
echo '<html>';
echo '<script language="JavaScript">';
echo 'window.location="Main.php"';
echo '</script>';
echo '</html>';
<?php

//include_once 'cache.arquivo.php';
require_once 'CacheArquivo.php';
require_once 'CacheSessao.php';
require_once 'Connection.php';
require_once 'User.php';
$c = new Connection();
$u = new User();
$cacheArquivo = new CacheArquivo();
$cacheSessao = new CacheSessao();
$UsId = $u->GetUserIdByUserName($_REQUEST['userName']);
$u->UserId($UsId);
$Contacts = $u->GetAllContacts($UsId);
$valor = json_encode($Contacts);
$cacheArquivo->set_valor($UsId, $valor);
if ($UsId > 0) {
    $cacheSessao->set_valor('USERID', $UsId);
    $cacheSessao->set_valor('USERNAME', $_REQUEST['userName']);
} else {
    $cacheSessao->set_valor('USERID');
    $cacheSessao->set_valor('USERNAME');
}
$u->UserName($_REQUEST['userName']);
$u->Password($_REQUEST['password']);
$res = $u->VerifyLogin();
if ($res) {
    echo '<html>';
    echo '<script language="JavaScript">';
    echo 'window.location="Main.php"';
    echo '</script>';
<?php 
include_once 'CheckLogOut.php';
require_once 'CacheSessao.php';
require_once 'CacheArquivo.php';
$cacheArquivo = new CacheArquivo();
$cacheArquivo->set_valor($USERID);
$cacheSessao = new CacheSessao();
$USERID = $cacheSessao->set_valor('USERID');
$USERNAME = $cacheSessao->set_valor('USERNAME');
echo '<html>';
echo '<script>';
echo 'alert("Deslogado!");';
echo 'window.location="Index.php"';
echo '</script>';
echo '</html>';
 public function printContacts($userId, $orderBy, $orderType)
 {
     $cacheArquivo = new CacheArquivo();
     $existe = $cacheArquivo->em_cache($userId);
     if ($existe) {
         $result = json_decode($cacheArquivo->get_valor($userId), true);
     } else {
         $result = $this->GetAllContacts($userId, $orderBy, $orderType);
     }
     $num_results = count($result["contacts"]["contactId"]);
     echo '<html>';
     echo '<style>                                     ';
     echo 'table, td, th {                             ';
     echo '    border: 1px solid green;          ;';
     echo '    width: ' . $max * 18.0 . 'px;';
     echo '}                                               ';
     echo 'tr:first-child {                                           ';
     echo '    background-color: #046380;        ';
     echo '    color: #EFECCA;                           ;';
     echo '}                                               ';
     echo '</style>                                    ';
     echo '<body>';
     echo '<div id="BODY"> ';
     echo '<form>';
     echo '<table border = 1 align="left" style="width:100%;">';
     // tabela Contacts
     echo '<tr>';
     echo '<th>  <img src="Images/editContactInfo.png" height="32" width="32"> </th>';
     if (isset($_GET['orderId']) && $_GET['orderId'] == 'desc') {
         echo '<th> <a href="Main.php?orderId=asc">ID </a> </th>';
     } else {
         echo '<th> <a href="Main.php?orderId=desc">ID </a> </th>';
     }
     if (isset($_GET['orderNome']) && $_GET['orderNome'] == 'desc') {
         echo '<th> <a href="Main.php?orderNome=asc">Nome </a> </th>';
     } else {
         echo '<th> <a href="Main.php?orderNome=desc">Nome </a> </th>';
     }
     if (isset($_GET['orderEmail']) && $_GET['orderEmail'] == 'desc') {
         echo '<th> <a href="Main.php?orderEmail=asc">Email </a> </th>';
     } else {
         echo '<th> <a href="Main.php?orderEmail=desc">Email </a> </th>';
     }
     echo '<th> Rua </th>';
     echo '<th> Número </th>';
     echo '<th> Complemento </th>';
     echo '<th> Ponto de referência </th>';
     echo '<th> Tipo de telefone </th>';
     echo '<th> Código de País </th>';
     echo '<th> DDD </th>';
     echo '<th> Número de telefone </th>';
     echo '<th colspan="2">  <img src="Images/phone.png" height="32" width="32"> </th>';
     echo '<th colspan="2">  <img src="Images/adress.png" height="32" width="32"> </th>';
     echo '<th >  <img src="Images/contact.png" height="32" width="32"> </th>';
     echo '</tr>';
     for ($i = 0; $i < $num_results; $i++) {
         echo '<tr>';
         echo '<td align=center> <a href="EditContact.php?contactId=' . $result["contacts"]["contactId"][$i] . '&fullName=' . $result["contacts"]["fullName"][$i] . '&email=' . $result["contacts"]["email"][$i] . '&streetName=' . $result["contacts"]["streetName"][$i] . '&number=' . $result["contacts"]["number"][$i] . '&complement=' . $result["contacts"]["complement"][$i] . '&checkPoint=' . $result["contacts"]["checkPoint"][$i] . '&phoneType=' . $result["contacts"]["phoneType"][$i] . '&countryId=' . $result["contacts"]["countryId"][$i] . '&ddd=' . $result["contacts"]["ddd"][$i] . '&phoneNumber=' . $result["contacts"]["phoneNumber"][$i] . '&caSeq=' . $result["contacts"]["caSeq"][$i] . '&cpSeq=' . $result["contacts"]["cpSeq"][$i] . '" title="Editar Linha"> <img src="Images/right.png"></a> </td>';
         echo '<td align="center"> <FONT COLOR="black" > <strong> ' . $result["contacts"]["contactId"][$i] . ' </strong> </td>';
         echo '<td align=center> ' . $result["contacts"]["fullName"][$i] . ' </td>';
         echo '<td align=center> ' . $result["contacts"]["email"][$i] . ' </td>';
         echo '<td align=center> ' . $result["contacts"]["streetName"][$i] . ' </td>';
         echo '<td align=center> ' . $result["contacts"]["number"][$i] . ' </td>';
         echo '<td align=center> ' . $result["contacts"]["complement"][$i] . ' </td>';
         echo '<td align=center> ' . $result["contacts"]["checkPoint"][$i] . ' </td>';
         echo '<td align=center> ' . $result["contacts"]["phoneType"][$i] . ' </td>';
         echo '<td align=center> ' . $result["contacts"]["countryId"][$i] . ' </td>';
         echo '<td align=center> ' . $result["contacts"]["ddd"][$i] . ' </td>';
         echo '<td align=center> ' . $result["contacts"]["phoneNumber"][$i] . ' </td>';
         echo '<td align=center> <a href="NewContactPhone.php?contactId=' . $result["contacts"]["contactId"][$i] . '" title="Inserir telefone"> <img src="Images/add.png"> </img> </a> </td>';
         echo '<td align=center> <a href="ContactPhone_del.php?contactId=' . $result["contacts"]["contactId"][$i] . '&sequential=' . $result["contacts"]["cpSeq"][$i] . '" title="Deletar telefone"> <img src="Images/del.png"> </img></a> </td>';
         echo '<td align=center> <a href="NewContactAdress.php?contactId=' . $result["contacts"]["contactId"][$i] . '" title="Inserir endereço"> <img src="Images/add.png"> </img> </a> </td>';
         echo '<td align=center> <a href="ContactAdress_del.php?contactId=' . $result["contacts"]["contactId"][$i] . '&sequential=' . $result["contacts"]["caSeq"][$i] . '" title="Deletar endereço"> <img src="Images/del.png"> </img> </a> </td>';
         echo '<td align=center> <a href="Contact_del.php?contactId=' . $result["contacts"]["contactId"][$i] . '" title="Deletar contato"> <FONT COLOR="white"> <strong> <img src="Images/del.png"> </img></strong> </a> </td>';
         echo '</tr>';
     }
     echo '</table>';
     echo '</form>';
     echo '</div>';
     echo '</body>';
     echo '</html>';
     $cacheSessao = new CacheSessao();
     $USERID = $cacheSessao->get_valor('USERID');
     $Log = new Log(4);
     // log de listagem, conforme a tabela Actions
     $Log->UserId($USERID);
     //
     $Log->InsertLog();
 }