| <?php |
| require './credentials.php'; |
| require './php/utils.php'; |
| require_once('./php/security.php'); |
| |
| date_default_timezone_set("Europe/Madrid"); |
| |
| Security::checkIsSignedIn(); |
| ?> |
| |
| <head> |
| <link rel="preconnect" href="https://fonts.googleapis.com"> |
| <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> |
| <link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400;0,500;1,400;1,500" rel="stylesheet"> |
| <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="killer-messages"> |
| <div class="messages-sent"> |
| <?php |
| $query_quielmata = "SELECT id FROM pastanaga WHERE quimata = " . (int)$user->id; |
| $quielmata = $conn->query($query_quielmata)->fetch_row()[0]; |
| |
| // Execute query and save result |
| $query_msgs = "SELECT * FROM `missatges` WHERE (`sender_id` = ".(int)$user->id." AND `receiver_id` = ".(int)$quielmata . |
| ") OR (`sender_id` = ".(int)$quielmata." AND `receiver_id` = ".(int)$user->id . ")"; |
| $result = $conn->query($query_msgs); |
| |
| 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'>".htmlspecialchars($res[4])."</div><div class='meta-data'><span class='timestamp'>$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="Demostra que no tens por" /> |
| <input type="hidden" name="killer-id" value="<?=(int)$user->id?>"> |
| <input type="hidden" name="victim-id" value="<?=(int)$quielmata?>"> |
| <input type="hidden" name="origin" value="killer"> |
| <input type="submit" value="Respon amenaça" /> |
| </form> |
| </div> |
| </div> |
| </div> |
| </div> |
| </body> |