blob: 193b7381c5bd14425f47a7c8b04c432e7852e38a [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>
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" />
Andreu Huguet0d5d7312020-09-15 21:12:43 +020015
16<?php
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010017 $user = get_users($_SESSION["id"]);
18 $victim = get_users($user->quimata);
19 if ($user->mort) die("<script>window.location.href = './dead.php'</script>");
Andreu Huguet0d5d7312020-09-15 21:12:43 +020020?>
21
Andreu Huguet0d5d7312020-09-15 21:12:43 +020022 <meta charset="UTF-8">
23 <title>PastanagAPP</title>
24
25 <meta name="viewport" content="width=device-width, initial-scale=1">
Adrià Vilanova Martínez71e9f872022-11-20 01:54:50 +010026 <link rel="manifest" href="/bin/manifest.json">
Andreu Huguet0d5d7312020-09-15 21:12:43 +020027
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</head>
34<body>
35 <div id="outter-container">
36 <div id="inner-container">
37 <div><a href="./main.php">Tornar a la pàgina principal</a></div>
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010038
Andreu Huguet0d5d7312020-09-15 21:12:43 +020039 <div id="message-board">
40 <div id="victim-messages">
41 <div class="messages-sent">
42 <?php
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010043 // Execute query and save result
44 $statement = $conn->prepare("SELECT * FROM `missatges` WHERE (`sender_id` = ? AND `receiver_id` = ?) OR (`sender_id` = ? AND `receiver_id` = ?)");
45 $statement->bind_param("iiii", $user->id, $user->quimata, $user->quimata, $user->id);
46 $statement->execute();
47
48 $result = $statement->get_result();
49
Andreu Huguet0d5d7312020-09-15 21:12:43 +020050 while($res = $result->fetch_row()) {
51 if ($res[1] == $user->id) {
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010052 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 +020053 } else {
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010054 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 Huguet0d5d7312020-09-15 21:12:43 +020055 }
56 }
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010057
Andreu Huguet0d5d7312020-09-15 21:12:43 +020058 // Update 'seen' messages
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010059 $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 +020060 $conn->query($query_seen);
Andreu Huguet0d5d7312020-09-15 21:12:43 +020061 ?>
62 </div>
63 <form action="./php/send_thread.php" method="POST">
64 <input type="text" name="msg-content" placeholder="Que es cagui de por" />
65 <input type="hidden" name="killer-id" value="<?=(int)$user->id?>">
66 <input type="hidden" name="victim-id" value="<?=(int)$user->quimata?>">
67 <input type="hidden" name="origin" value="victim">
68 <input type="submit" value="Enviar amenaça" />
69 </form>
70 </div>
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010071
Andreu Huguet0d5d7312020-09-15 21:12:43 +020072 </div>
73
74 </div>
75 </div>
Adrià Vilanova Martínezd3394e12022-11-19 15:45:58 +010076</body>