| <?php |
| require './credentials.php'; |
| require './php/utils.php'; |
| require_once('./php/security.php'); |
| |
| date_default_timezone_set("Europe/Madrid"); |
| |
| Security::checkIsSignedIn(); |
| ?> |
| |
| <head> |
| <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans" /> |
| <link rel="stylesheet" href="./css/basic.css" /> |
| <link rel="stylesheet" href="./css/main.css" /> |
| |
| <?php |
| $user = get_users($_SESSION["id"]); |
| $victim = get_users($user->quimata); |
| if ($user->mort) die("<script>window.location.href = './dead.php'</script>"); |
| ?> |
| |
| <meta charset="UTF-8"> |
| <title>PastanagAPP</title> |
| |
| <meta name="viewport" content="width=device-width, initial-scale=1"> |
| <link rel="manifest" href="/bin/manifest.json"> |
| |
| <!-- Apple web app --> |
| <link rel="apple-touch-icon" href="./bin/images/icons/icon-72x72.png"> |
| <meta name="apple-mobile-web-app-title" content="PastanagAPP"> |
| <meta name="apple-mobile-web-app-capable" content="yes"> |
| <meta name="apple-mobile-web-app-status-bar-style" content="green"> |
| </head> |
| <body> |
| <div id="outter-container"> |
| <div id="inner-container"> |
| <div><a href="./main.php">Tornar a la pàgina principal</a></div> |
| |
| <div id="message-board"> |
| <div id="victim-messages"> |
| <div class="messages-sent"> |
| <?php |
| // Execute query and save result |
| $statement = $conn->prepare("SELECT * FROM `missatges` WHERE (`sender_id` = ? AND `receiver_id` = ?) OR (`sender_id` = ? AND `receiver_id` = ?)"); |
| $statement->bind_param("iiii", $user->id, $user->quimata, $user->quimata, $user->id); |
| $statement->execute(); |
| |
| $result = $statement->get_result(); |
| |
| while($res = $result->fetch_row()) { |
| if ($res[1] == $user->id) { |
| echo "<div class='from-me'><div class='msg-content'>".htmlspecialchars($res[4])."</div><div class='meta-data'><span class='timestamp'>$res[3]</span><span class='seen'>".($res[5] == 0 ? 'Enviat' : 'Vist')."</span></div></div>"; |
| } else { |
| echo "<div class='to-me'><div class='msg-content'>$res[4]</div><div class='meta-data'><span class='timestamp'>".htmlspecialchars($res[3])."</span><span class='seen'>".($res[5] == 0 ? 'Nou!' : '')."</span></div></div>"; |
| } |
| } |
| |
| // Update 'seen' messages |
| $query_seen = "UPDATE missatges SET `seen` = 1 WHERE `receiver_id` = " . (int)$user->id . " AND `sender_id` = " . (int)$user->quimata . " AND `seen` <> 1"; |
| $conn->query($query_seen); |
| ?> |
| </div> |
| <form action="./php/send_thread.php" method="POST"> |
| <input type="text" name="msg-content" placeholder="Que es cagui de por" /> |
| <input type="hidden" name="killer-id" value="<?=(int)$user->id?>"> |
| <input type="hidden" name="victim-id" value="<?=(int)$user->quimata?>"> |
| <input type="hidden" name="origin" value="victim"> |
| <input type="submit" value="Enviar amenaça" /> |
| </form> |
| </div> |
| |
| </div> |
| |
| </div> |
| </div> |
| </body> |