<?php require_once dirname(__DIR__) . "/services/InboxRepositoryService.php"; require_once dirname(__DIR__) . "/security/CaesarCipher.php"; require_once dirname(__DIR__) . "/domain/Session.php"; $patron = "/^[[:digit:]]+\$/"; $mysession = new Session(); $mysession->initSession(); $inboxRepo = new InboxRepositoryService(); if (isset($_SESSION['id']) and preg_match($patron, $_SESSION['id']) and isset($_GET['usuarioRemitent']) and preg_match($patron, $_GET['usuarioRemitent'])) { $userRemitentIdFirst = $_SESSION['id']; $userRemitentIdSecond = $_GET['usuarioRemitent']; $inboxIdFirst = $inboxRepo->getInboxIdByUserId($userRemitentIdFirst); $inboxIdSecond = $inboxRepo->getInboxIdByUserId($userRemitentIdSecond); $messages = $inboxRepo->getMessagesOfChat($userRemitentIdFirst, $inboxIdFirst, $userRemitentIdSecond, $inboxIdSecond); } if ($messages != null) { $i = 1; while ($message = $messages->fetch_object()) { if ($message->id_usuario == $userRemitentIdFirst) { $caesarCihper = new CaesarCipher($message->contenido); echo "<li class='list-group-item text-right'>\n <div class='message-area-user'>\n <p>" . $message->nombre . " " . $message->apellido . "</p>\n </div>\n <div class='message-area-content'>\n <p>" . $caesarCihper->decryptMessage() . "</p>\n </div>\n </li>"; } else { echo "<li class='list-group-item'>\n <div class='message-area-user'>\n <p>" . $message->nombre . " " . $message->apellido . "</p>\n </div>\n <div class='message-area-content'>\n <p>" . $message->contenido . "</p>\n </div>\n </li>"; } $i++; } } else { echo "ERROR: No se pudo obtener informacion de la Base de Datos"; } echo "<input type='hidden' id='inpTotalPrivateMsg' name='inpTotalPrivateMsg' value=" . $i . ">";
<?php require_once dirname(__DIR__) . "/services/InboxRepositoryService.php"; require_once dirname(__DIR__) . "/domain/Session.php"; require_once dirname(__DIR__) . "/security/CaesarCipher.php"; $mysession = new Session(); $mysession->initSession(); $patron = "/^[[:digit:]]+\$/"; $inboxRepo = new InboxRepositoryService(); if (isset($_SESSION['id']) and preg_match($patron, $_SESSION['id'])) { $userId = $_SESSION['id']; $inboxIdUser = $inboxRepo->getInboxIdByUserId($userId); $conversations = $inboxRepo->getConversationsByUserId($userId, $inboxIdUser); $cont = 0; while ($conversation = $conversations->fetch_object()) { $cont++; if ($conversation->id_usuario == $userId) { $caesarCipher = new CaesarCipher($conversation->contenido); echo "<li class='list-group-item conversation-item'>\n <input type='hidden' class='propIdBandeja' value='" . $conversation->prop_id_bandeja . "'/>\n <input type='hidden' class='propNombreBandeja' value='" . $conversation->prop_nombre_bandeja . "'/>\n <input type='hidden' class='propApellidoBandeja' value='" . $conversation->prop_apellido_bandeja . "'/>\n <div class='conversation-item'>\n <div class='avatar'>\n <img class='img-circle' src='http://lorempixel.com/200/200/people/" . $cont . "' alt=''/>\n </div>\n <div class='userName'>\n <p>" . $conversation->prop_nombre_bandeja . " " . $conversation->prop_apellido_bandeja . "</p>\n </div>\n <div class='message-review'>\n <p><span><i class='glyphicon glyphicon-triangle-left'></i></span>" . $caesarCipher->decryptMessage() . "</p>\n </div>\n <div class='message-date'>\n <p>" . $conversation->fecha_alta . "</p>\n </div>\n </div>\n </li>"; } else { $conversationId = $conversation->id_conversacion; $conversationsToUser = $inboxRepo->getConversationToUser($userId, $conversationId); $conversationToUser = $conversationsToUser->fetch_object(); echo "<li class='list-group-item conversation-item'>\n <input type='hidden' class='propIdBandeja' value='" . $conversationToUser->prop_id_bandeja . "'/>\n <input type='hidden' class='propNombreBandeja' value='" . $conversationToUser->prop_nombre_bandeja . "'/>\n <input type='hidden' class='propApellidoBandeja' value='" . $conversationToUser->prop_apellido_bandeja . "'/>\n <div class='conversation-item'>\n <div class='avatar'>\n <img class='img-circle' src='http://lorempixel.com/200/200/people' alt=''/>\n </div>\n <div class='userName'>\n <p>" . $conversationToUser->prop_nombre_bandeja . " " . $conversationToUser->prop_apellido_bandeja . "</p>\n </div>\n <div class='message-review'>\n <p>" . $caesarCihper->decryptMessage() . "</p>\n </div>\n <div class='message-date'>\n <p>" . $conversationToUser->fecha_alta . "</p>\n </div>\n </div>\n </li>"; } } } else { echo "ERROR: No se puede cargar las conversaciones"; }