Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 1 | <?php |
| 2 | require './credentials.php'; |
| 3 | require './php/utils.php'; |
| 4 | require_once('./php/security.php'); |
| 5 | |
| 6 | date_default_timezone_set("Europe/Madrid"); |
| 7 | |
| 8 | Security::checkIsSignedIn(); |
| 9 | ?> |
| 10 | |
Andreu Huguet | 0d5d731 | 2020-09-15 21:12:43 +0200 | [diff] [blame] | 11 | <head> |
Adrià Vilanova Martínez | dc7fbb6 | 2022-12-11 16:28:44 +0100 | [diff] [blame] | 12 | <link rel="preconnect" href="https://fonts.googleapis.com"> |
| 13 | <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> |
| 14 | <link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400;0,500;1,400;1,500" rel="stylesheet"> |
Andreu Huguet | 0d5d731 | 2020-09-15 21:12:43 +0200 | [diff] [blame] | 15 | <link rel="stylesheet" href="./css/basic.css" /> |
| 16 | <link rel="stylesheet" href="./css/main.css" /> |
Andreu Huguet | 0d5d731 | 2020-09-15 21:12:43 +0200 | [diff] [blame] | 17 | |
| 18 | <?php |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 19 | $user = get_users($_SESSION["id"]); |
| 20 | $victim = get_users($user->quimata); |
| 21 | if ($user->mort) die("<script>window.location.href = './dead.php'</script>"); |
Andreu Huguet | 0d5d731 | 2020-09-15 21:12:43 +0200 | [diff] [blame] | 22 | ?> |
| 23 | |
Andreu Huguet | 0d5d731 | 2020-09-15 21:12:43 +0200 | [diff] [blame] | 24 | <meta charset="UTF-8"> |
| 25 | <title>PastanagAPP</title> |
| 26 | |
| 27 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
Adrià Vilanova Martínez | 71e9f87 | 2022-11-20 01:54:50 +0100 | [diff] [blame] | 28 | <link rel="manifest" href="/bin/manifest.json"> |
Andreu Huguet | 0d5d731 | 2020-09-15 21:12:43 +0200 | [diff] [blame] | 29 | |
| 30 | <!-- Apple web app --> |
| 31 | <link rel="apple-touch-icon" href="./bin/images/icons/icon-72x72.png"> |
| 32 | <meta name="apple-mobile-web-app-title" content="PastanagAPP"> |
| 33 | <meta name="apple-mobile-web-app-capable" content="yes"> |
| 34 | <meta name="apple-mobile-web-app-status-bar-style" content="green"> |
| 35 | </head> |
| 36 | <body> |
| 37 | <div id="outter-container"> |
| 38 | <div id="inner-container"> |
| 39 | <div><a href="./main.php">Tornar a la pàgina principal</a></div> |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 40 | |
Andreu Huguet | 0d5d731 | 2020-09-15 21:12:43 +0200 | [diff] [blame] | 41 | <div id="message-board"> |
| 42 | <div id="victim-messages"> |
| 43 | <div class="messages-sent"> |
| 44 | <?php |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 45 | // Execute query and save result |
| 46 | $statement = $conn->prepare("SELECT * FROM `missatges` WHERE (`sender_id` = ? AND `receiver_id` = ?) OR (`sender_id` = ? AND `receiver_id` = ?)"); |
| 47 | $statement->bind_param("iiii", $user->id, $user->quimata, $user->quimata, $user->id); |
| 48 | $statement->execute(); |
| 49 | |
| 50 | $result = $statement->get_result(); |
| 51 | |
Andreu Huguet | 0d5d731 | 2020-09-15 21:12:43 +0200 | [diff] [blame] | 52 | while($res = $result->fetch_row()) { |
| 53 | if ($res[1] == $user->id) { |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 54 | 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>"; |
Andreu Huguet | 0d5d731 | 2020-09-15 21:12:43 +0200 | [diff] [blame] | 55 | } else { |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 56 | 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>"; |
Andreu Huguet | 0d5d731 | 2020-09-15 21:12:43 +0200 | [diff] [blame] | 57 | } |
| 58 | } |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 59 | |
Andreu Huguet | 0d5d731 | 2020-09-15 21:12:43 +0200 | [diff] [blame] | 60 | // Update 'seen' messages |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 61 | $query_seen = "UPDATE missatges SET `seen` = 1 WHERE `receiver_id` = " . (int)$user->id . " AND `sender_id` = " . (int)$user->quimata . " AND `seen` <> 1"; |
Andreu Huguet | 0d5d731 | 2020-09-15 21:12:43 +0200 | [diff] [blame] | 62 | $conn->query($query_seen); |
Andreu Huguet | 0d5d731 | 2020-09-15 21:12:43 +0200 | [diff] [blame] | 63 | ?> |
| 64 | </div> |
| 65 | <form action="./php/send_thread.php" method="POST"> |
| 66 | <input type="text" name="msg-content" placeholder="Que es cagui de por" /> |
| 67 | <input type="hidden" name="killer-id" value="<?=(int)$user->id?>"> |
| 68 | <input type="hidden" name="victim-id" value="<?=(int)$user->quimata?>"> |
| 69 | <input type="hidden" name="origin" value="victim"> |
| 70 | <input type="submit" value="Enviar amenaça" /> |
| 71 | </form> |
| 72 | </div> |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 73 | |
Andreu Huguet | 0d5d731 | 2020-09-15 21:12:43 +0200 | [diff] [blame] | 74 | </div> |
| 75 | |
| 76 | </div> |
| 77 | </div> |
Adrià Vilanova Martínez | d3394e1 | 2022-11-19 15:45:58 +0100 | [diff] [blame] | 78 | </body> |