blob: eeda409d45106e6cf286f8613270f29f220e0515 [file] [log] [blame]
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +01001<?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 Huguet0d5d7312020-09-15 21:12:43 +020011<head>
Adrià Vilanova Martínezdc7fbb62022-12-11 16:28:44 +010012<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 Huguet0d5d7312020-09-15 21:12:43 +020015<link rel="stylesheet" href="./css/basic.css" />
16<link rel="stylesheet" href="./css/main.css" />
17
Andreu Huguet0d5d7312020-09-15 21:12:43 +020018<?php
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010019 $user = get_users($_SESSION['id']);
20 $victim = get_users($user->quimata);
21 if ($user->mort) die("<script>window.location.href = './dead.php'</script>");
Andreu Huguet0d5d7312020-09-15 21:12:43 +020022?>
23
24 <meta charset="UTF-8">
25 <title>PastanagAPP</title>
26
27 <meta name="viewport" content="width=device-width, initial-scale=1">
Adrià Vilanova Martínez71e9f872022-11-20 01:54:50 +010028 <link rel="manifest" href="/bin/manifest.json">
Andreu Huguet0d5d7312020-09-15 21:12:43 +020029
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
36</head>
37<body>
38 <div id="outter-container">
39 <div id="inner-container">
40 <div><a href="./main.php">Tornar a la pàgina principal</a></div>
41
42 <div id="message-board">
43 <div id="killer-messages">
44 <div class="messages-sent">
45 <?php
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010046 $query_quielmata = "SELECT id FROM pastanaga WHERE quimata = " . (int)$user->id;
Andreu Huguet0d5d7312020-09-15 21:12:43 +020047 $quielmata = $conn->query($query_quielmata)->fetch_row()[0];
48
49 // Execute query and save result
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010050 $query_msgs = "SELECT * FROM `missatges` WHERE (`sender_id` = ".(int)$user->id." AND `receiver_id` = ".(int)$quielmata .
51 ") OR (`sender_id` = ".(int)$quielmata." AND `receiver_id` = ".(int)$user->id . ")";
Andreu Huguet0d5d7312020-09-15 21:12:43 +020052 $result = $conn->query($query_msgs);
53
54 while($res = $result->fetch_row()) {
55 if ($res[1] == $user->id) {
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010056 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 Huguet0d5d7312020-09-15 21:12:43 +020057 } else {
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010058 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 Huguet0d5d7312020-09-15 21:12:43 +020059 }
60 }
61
62 // Update 'seen' messages
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010063 $query_seen = "UPDATE missatges SET `seen` = 1 WHERE `receiver_id` = " . (int)$user->id . " AND `sender_id` != " . (int)$user->quimata . " AND `seen` <> 1";
Andreu Huguet0d5d7312020-09-15 21:12:43 +020064 $conn->query($query_seen);
Andreu Huguet0d5d7312020-09-15 21:12:43 +020065 ?>
66 </div>
67 <form action="./php/send_thread.php" method="POST">
68 <input type="text" name="msg-content" placeholder="Demostra que no tens por" />
69 <input type="hidden" name="killer-id" value="<?=(int)$user->id?>">
70 <input type="hidden" name="victim-id" value="<?=(int)$quielmata?>">
71 <input type="hidden" name="origin" value="killer">
72 <input type="submit" value="Respon amenaça" />
73 </form>
74 </div>
75 </div>
76 </div>
77 </div>
Adrià Vilanova Martínezd3394e12022-11-19 15:45:58 +010078</body>