Пример #1
0
        if (isset($rows)) {
            foreach ($rows as $fila) {
                ?>
                                <hr class="col-sm-12 icon-image">
                                <div id="toRepeat" name="toRepeat">
                                    <div class="col-sm-3">
                                        <div class="text-center">
                                            <img src="img/user.png" alt="usuario" class="img-circle icon-image"><br/>
                                            <?php 
                echo "<span>{$fila->nombre} <br/> {$fila->apellido}</span>";
                ?>
                                        </div>
                                    </div>
                                    <div class="col-sm-9 mensaje">
                                        <?php 
                $cbcCipher = new CbcCipher($fila->contenido);
                $contenido = $cbcCipher->decrypt();
                echo $contenido;
                ?>
                                        <br>
                                        <span class="pull-right">Publicado el <?php 
                $fecha = substr($fila->fecha_alta, 0, 10);
                $hora = substr($fila->fecha_alta, 10, 15);
                echo $fecha;
                ?>
 a las <?php 
                echo $hora;
                ?>
 </span>
                                    </div>
                                </div>
$mysession->initSession();
$content = $_POST["content"];
$toWall = $_POST["toWall"];
$patron = "/^[[:digit:]]+\$/";
if (isset($_SESSION['id']) and preg_match($patron, $_SESSION['id'])) {
    $fromUser = $_SESSION['id'];
} else {
    //El id 1 pertenece al usuario anonimo
    $fromUser = 1;
}
if (isset($_POST["toUser"]) and preg_match($patron, $_POST["toUser"])) {
    $toUser = $_POST["toUser"];
} else {
    header('location:index.php?error=4');
    exit;
}
echo "string";
$wallRepo = new WallRepositoryService();
$wallResult = $wallRepo->getWallByUserId($toUser);
if ($row = $wallResult->fetch_object()) {
    $wall = new Wall();
    $messages = $wall->getMessages($row->limite_muro, $toUser);
    if (count($messages) < $row->limite_muro) {
        $cbcCipher = new CbcCipher($content);
        $content = $cbcCipher->encrypt();
        $message = new Message($content, $toWall, $fromUser);
        header('location: ../../index.php?usuario=' . $toUser);
    } else {
        header('location: ../../index.php?usuario=' . $toUser . '&alert');
    }
}