public function listar()
 {
     $dql = 'SELECT m, u.apelido FROM Models\\Mensagem m ' . 'JOIN m.usuario u ORDER BY m.dataTs DESC';
     $messages = $this->em->createQuery($dql)->setMaxResults(10)->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY);
     $s = Container::getSession();
     $k = $s->get("key");
     $iv = $s->get("iv");
     foreach ($messages as $msg) {
         $encrypted = mcrypt_encrypt(MCRYPT_3DES, safeHexToString($k), trim($msg[0]["conteudo"]), MCRYPT_MODE_CBC, safeHexToString($iv));
         $item = ["nick" => trim($msg["apelido"]), "mensagem" => stringToHex($encrypted), "hora" => $msg[0]["dataTs"]->format('d/m/y H:i:s')];
         $resp[] = $item;
     }
     echo json_encode($resp, JSON_UNESCAPED_UNICODE);
     return "";
 }
Example #2
0
 public function postLoginUser(Router $r)
 {
     $r->post('/ajax/ControleUsuario/login/*/*', function ($email, $senha) {
         $em = Container::gerEntityManager();
         $c = new ControleUsuario($em);
         $json_str = file_get_contents("/var/www/minichat3des/public/js/srp.json");
         $jsrc = json_decode($json_str, true);
         extract($jsrc);
         $login = array("email" => mcrypt_decrypt(MCRYPT_3DES, $k, hexToString($email), MCRYPT_MODE_CBC, hexToString($iv)), "senha" => $senha);
         $rsp = $c->login($login);
         if ($rsp) {
             header("/chat");
         }
     });
 }
Example #3
0
 public function postLoguot(Router $r)
 {
     $r->post("/ajax/ControleUsuario/logout", function () {
         $sessao = Container::getSession();
         $sessao->unsetKey("usuario");
         echo "Loged out";
     });
 }
Example #4
0
<?php

require 'vendor/autoload.php';
require_once __DIR__ . '/src/Library/cypher3des.php';
use Library\Container;
$jsrc = Container::getCrytoParams();
extract($jsrc);
echo safeHexToString($k);