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> |
| 12 | <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans" /> |
| 13 | <link rel="stylesheet" href="./css/basic.css" /> |
| 14 | <link rel="stylesheet" href="./css/main.css" /> |
| 15 | |
Andreu Huguet | 0d5d731 | 2020-09-15 21:12:43 +0200 | [diff] [blame] | 16 | <?php |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame^] | 17 | $user = get_users($_SESSION['id']); |
| 18 | $victim = get_users($user->quimata); |
| 19 | if ($user->mort) die("<script>window.location.href = './dead.php'</script>"); |
Andreu Huguet | 0d5d731 | 2020-09-15 21:12:43 +0200 | [diff] [blame] | 20 | ?> |
| 21 | |
| 22 | <meta charset="UTF-8"> |
| 23 | <title>PastanagAPP</title> |
| 24 | |
| 25 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 26 | <link rel="manifest" href="https://api.myjson.com/bins/u6r41"> |
| 27 | |
| 28 | <!-- Apple web app --> |
| 29 | <link rel="apple-touch-icon" href="./bin/images/icons/icon-72x72.png"> |
| 30 | <meta name="apple-mobile-web-app-title" content="PastanagAPP"> |
| 31 | <meta name="apple-mobile-web-app-capable" content="yes"> |
| 32 | <meta name="apple-mobile-web-app-status-bar-style" content="green"> |
| 33 | |
| 34 | </head> |
| 35 | <body> |
| 36 | <div id="outter-container"> |
| 37 | <div id="inner-container"> |
| 38 | <div><a href="./main.php">Tornar a la pàgina principal</a></div> |
| 39 | |
| 40 | <div id="message-board"> |
| 41 | <div id="killer-messages"> |
| 42 | <div class="messages-sent"> |
| 43 | <?php |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame^] | 44 | $query_quielmata = "SELECT id FROM pastanaga WHERE quimata = " . (int)$user->id; |
Andreu Huguet | 0d5d731 | 2020-09-15 21:12:43 +0200 | [diff] [blame] | 45 | $quielmata = $conn->query($query_quielmata)->fetch_row()[0]; |
| 46 | |
| 47 | // Execute query and save result |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame^] | 48 | $query_msgs = "SELECT * FROM `missatges` WHERE (`sender_id` = ".(int)$user->id." AND `receiver_id` = ".(int)$quielmata . |
| 49 | ") OR (`sender_id` = ".(int)$quielmata." AND `receiver_id` = ".(int)$user->id . ")"; |
Andreu Huguet | 0d5d731 | 2020-09-15 21:12:43 +0200 | [diff] [blame] | 50 | $result = $conn->query($query_msgs); |
| 51 | |
| 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'>".htmlspecialchars($res[4])."</div><div class='meta-data'><span class='timestamp'>$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 | } |
| 59 | |
| 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="Demostra que no tens por" /> |
| 67 | <input type="hidden" name="killer-id" value="<?=(int)$user->id?>"> |
| 68 | <input type="hidden" name="victim-id" value="<?=(int)$quielmata?>"> |
| 69 | <input type="hidden" name="origin" value="killer"> |
| 70 | <input type="submit" value="Respon amenaça" /> |
| 71 | </form> |
| 72 | </div> |
| 73 | </div> |
| 74 | </div> |
| 75 | </div> |
Adrià Vilanova Martínez | d3394e1 | 2022-11-19 15:45:58 +0100 | [diff] [blame] | 76 | </body> |