blob: bfbbc1ee2f541cf7ddccc73b0105cb40666fd7c8 [file] [log] [blame]
Andreu78e5bb02019-09-22 13:38:04 +02001<?php
2 require './credentials.php';
3 require './php/utils.php';
Andreu0d0f9fd2019-09-23 03:56:08 +02004
Andreu20af6c22019-09-24 18:33:50 +02005 $credentials = new Credentials();
6 $usersdb = $credentials->usersdb;
7 $mortsdb = $credentials->mortsdb;
8
Andreu03d030d2019-09-25 21:52:01 +02009 date_default_timezone_set("Europe/Berlin");
10
11 $user = $_COOKIE['user']; // (int)$_POST['user'];
12 $password = $_COOKIE['password']; // isset($_POST['password']) ? md5($_POST['password']) : '';
Andreu4b2fbd92019-09-22 22:30:25 +020013
Andreu03d030d2019-09-25 21:52:01 +020014 if (!isset($_COOKIE['user']) or $_COOKIE['user'] == '') {
15 die("<script>window.location.href = './'</script>");
16 } else if (isset($_COOKIE['password'])) {
Andreu20af6c22019-09-24 18:33:50 +020017 $query_password = "SELECT password FROM $usersdb WHERE id=$user";
Andreua0fc8272019-09-23 00:35:25 +020018 if (query($query_password)->fetch_row()[0] != $password) {
Andreu78e5bb02019-09-22 13:38:04 +020019 // Unset variables
20 setcookie('user', '', -1, "/");
21 setcookie('password', '', -1, "/");
22
Andreu03d030d2019-09-25 21:52:01 +020023 die("<script>window.location.href = './?passwordchanged=1'</script>");
Andreu78e5bb02019-09-22 13:38:04 +020024 }
Andreu09b8b052019-09-21 21:47:20 +020025 }
26?>
Andreu66ad5cf2019-09-18 17:15:44 +020027<html>
28 <head>
29 <meta charset="UTF-8">
Andreu0d0f9fd2019-09-23 03:56:08 +020030 <title>PastanagAPP</title>
avm99963db383ed2019-09-22 02:14:42 +020031
32 <meta name="viewport" content="width=device-width, initial-scale=1">
Andreu0d0f9fd2019-09-23 03:56:08 +020033 <link rel="manifest" href="https://api.myjson.com/bins/u6r41">
34
35 <!-- Apple web app -->
36 <link rel="apple-touch-icon" href="./bin/images/icons/icon-72x72.png">
37 <meta name="apple-mobile-web-app-title" content="PastanagAPP">
38 <meta name="apple-mobile-web-app-capable" content="yes">
39 <meta name="apple-mobile-web-app-status-bar-style" content="green">
40
avm99963db383ed2019-09-22 02:14:42 +020041
Andreu4b2fbd92019-09-22 22:30:25 +020042 <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans" />
43
Andreu66ad5cf2019-09-18 17:15:44 +020044 <link rel="stylesheet" href="./css/basic.css" />
45 <link rel="stylesheet" href="./css/main.css" />
avm99963db383ed2019-09-22 02:14:42 +020046
Andreu66ad5cf2019-09-18 17:15:44 +020047 <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
Andreued8e1f92019-09-18 22:26:04 +020048 <script src="https://rawgit.com/notifyjs/notifyjs/master/dist/notify.js"></script>
avm99963db383ed2019-09-22 02:14:42 +020049
Andreu10cb3042019-09-18 19:55:36 +020050 <script src="./js/utils.js"></script>
Andreuefe66eb2019-09-21 18:41:49 +020051 <script src="./js/animations.js"></script>
avm99963db383ed2019-09-22 02:14:42 +020052
53 <?php
Andreua0fc8272019-09-23 00:35:25 +020054 $user = get_users($user);
Andreu09b8b052019-09-21 21:47:20 +020055 $victim = get_users($user->quimata);
Andreu0530b302019-09-24 04:18:20 +020056 if ($user->mort) die("<script>window.location.href = './dead.php'</script>");
Andreu779c3b72019-09-24 03:14:35 +020057
58 $bits = dec2bits($user->bits);
59 $bit_counter = 0;
Andreudca79f42019-09-18 23:53:19 +020060 ?>
avm99963db383ed2019-09-22 02:14:42 +020061
Andreu66ad5cf2019-09-18 17:15:44 +020062 <script>
Andreued491672019-09-20 13:09:18 +020063 let user = {
Andreu99501052019-09-22 20:09:08 +020064 'id': <?=(int)$user->id?>,
65 'quimata': <?=(int)$user->quimata?>,
66 'requested': <?=(int)$user->requested?>,
67 'mort': <?=(int)$user->mort?>,
avm99963db383ed2019-09-22 02:14:42 +020068
Andreuabbcb7e2019-09-21 18:22:14 +020069 'nom': "<?=$user->nomcomplet?>",
Andreu99501052019-09-22 20:09:08 +020070 'curs': <?=(int)$user->curs?>,
71 'grau': <?=(int)$user->grau?>
Andreued491672019-09-20 13:09:18 +020072 };
Andreu66ad5cf2019-09-18 17:15:44 +020073 </script>
avm99963db383ed2019-09-22 02:14:42 +020074
Andreu66ad5cf2019-09-18 17:15:44 +020075 </head>
76 <body>
77 <div id="outter-container">
78 <div id="inner-container">
Andreu03d030d2019-09-25 21:52:01 +020079 <a href="./" class="goback">Canvi d'usuari</a><br />
Andreu66ad5cf2019-09-18 17:15:44 +020080 <h2>Hola <name id="user_name"><?=$user->nom()?></name>,</h2>
avm99963db383ed2019-09-22 02:14:42 +020081
Andreu4b2fbd92019-09-22 22:30:25 +020082 <div class="formulari_contrasenya">
Andreua0fc8272019-09-23 00:35:25 +020083 <p>Sembla que no tens clau d'accés, la gent podrà entrar al teu compte...</p>
Andreu20cbd1d2019-09-22 00:00:57 +020084 <form action="./php/change_password.php" method="POST">
Andreu03d030d2019-09-25 21:52:01 +020085 <input type="hidden" value="<?=$user->id?>" name="userid">
Andreu543e70c2019-09-22 14:08:49 +020086 <input type="password" placeholder="Nova clau d'accés..." name="password" /><br />
87 <input type="password" placeholder="Repeteix la clau d'accés" name="confirmation"/><br />
Andreu4b2fbd92019-09-22 22:30:25 +020088 <input type="submit" value="Posar clau d'accés">
Andreu20cbd1d2019-09-22 00:00:57 +020089 </form>
90 </div>
avm99963db383ed2019-09-22 02:14:42 +020091
92 <p>La teva víctima és:</p>
93
Andreu04f79ef2019-09-22 18:52:19 +020094 <div class="victima">
95 <table>
96 <tr>
Andreu779c3b72019-09-24 03:14:35 +020097 <td class="table_img">
98 <div id="victim_img">
Andreu Huguetf1334172020-09-15 17:29:22 +020099 <div class="grid-container">
100 <div class="grid-item <?=(int)$bits[$bit_counter++] ? 'black' : ''?>"></div>
101 <div class="grid-item <?=(int)$bits[$bit_counter++] ? 'black' : ''?>"></div>
102 <div class="grid-item <?=(int)$bits[$bit_counter++] ? 'black' : ''?>"></div>
103 <div class="grid-item <?=(int)$bits[$bit_counter++] ? 'black' : ''?>"></div>
104 <div class="grid-item <?=(int)$bits[$bit_counter++] ? 'black' : ''?>"></div>
105 <div class="grid-item <?=(int)$bits[$bit_counter++] ? 'black' : ''?>"></div>
106 <div class="grid-item <?=(int)$bits[$bit_counter++] ? 'black' : ''?>"></div>
107 <div class="grid-item <?=(int)$bits[$bit_counter++] ? 'black' : ''?>"></div>
108 <div class="grid-item <?=(int)$bits[$bit_counter++] ? 'black' : ''?>"></div>
109 </div>
Andreu779c3b72019-09-24 03:14:35 +0200110 </div>
111 </td>
Andreu0d0f9fd2019-09-23 03:56:08 +0200112 <td class="table_text">
Andreu04f79ef2019-09-22 18:52:19 +0200113 <div id="victim_name"><?=$victim->nomcomplet?></div>
114 <div id="victim_curs_i_grau">
Andreu4b2fbd92019-09-22 22:30:25 +0200115 <span id="victim_curs"><?=$victim->nomcurs()?></span>
Andreu04f79ef2019-09-22 18:52:19 +0200116 -
Andreu4b2fbd92019-09-22 22:30:25 +0200117 <span id="victim_grau"><?=$victim->nomgrau()?></span>
Andreu04f79ef2019-09-22 18:52:19 +0200118 </div>
119 <div id="butons" class="options">
120 <button id="win" onclick="js: send_request(user, 'REQ KILL');">L'he matat</button>
121 </div>
122 </td>
123 </tr>
124 </table>
125 </div>
Andreu03d030d2019-09-25 21:52:01 +0200126
Andreu Huguet6a633f22020-09-15 18:07:15 +0200127 <div id="message-board">
Andreu Huguet73fd1bc2020-09-15 19:21:05 +0200128 <h1>L'atacat</h1>
129 <div id="messages-sent">
130 <?php
131 // Create connection
132 $credentials = new Credentials();
133 $conn = new mysqli($credentials->servername, $credentials->username, $credentials->password, $credentials->dbname);
134 if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
135 $conn->set_charset("utf8");
136
137 // Execute query and save result
138 $query_msgs = "SELECT * FROM `missatges` WHERE (`sender_id` = ".$user->id." AND `receiver_id` = ".$user->quimata .
139 ") OR (`sender_id` = ".$user->quimata." AND `receiver_id` = ".$user->id . ")";
140 $result = $conn->query($query_msgs);
141
142 while($res = $result->fetch_row()) {
143 echo $res[1] . "->" . $res[2] . " (" . $res[3] . "): " . $res[4] . "<br />";
144 }
145 ?>
146 </div>
Andreu Huguetdd3ae822020-09-15 18:27:51 +0200147 <form action="./php/send_thread.php" method="POST">
Andreu Huguet92c6e0d2020-09-15 18:15:40 +0200148 <input type="text" name="msg-content" placeholder="Que es cagui de por" />
149 <input type="hidden" name="killer-id" value="<?=(int)$user->id?>">
150 <input type="hidden" name="victim-id" value="<?=(int)$user->quimata?>">
Andreu Huguet6a633f22020-09-15 18:07:15 +0200151 <input type="submit" value="Enviar amenaça" />
152 </form>
Andreu Huguet73fd1bc2020-09-15 19:21:05 +0200153 <h1>L'atacant</h1>
154 <div id="messages-sent">
155 <?php
156 $query_quielmata = "SELECT id FROM pastanaga WHERE quimata = " . $user->id;
157 $quielmata = $conn->query($query_quielmata)->fetch_row()[0];
158
159 // Execute query and save result
160 $query_msgs = "SELECT * FROM `missatges` WHERE (`sender_id` = ".$user->id." AND `receiver_id` = ".$quielmata .
161 ") OR (`sender_id` = ".$quielmata." AND `receiver_id` = ".$user->id . ")";
162 $result = $conn->query($query_msgs);
163
164 while($res = $result->fetch_row()) {
165 echo $res[1] . "->" . $res[2] . " (" . $res[3] . "): " . $res[4] . "<br />";
166 }
167
168
169 // Close the connection
170 $conn->close();
171 ?>
172 </div>
173 <form action="./php/send_thread.php" method="POST">
174 <input type="text" name="msg-content" placeholder="Demostra que no tens por" />
175 <input type="hidden" name="killer-id" value="<?=(int)$user->id?>">
176 <input type="hidden" name="victim-id" value="<?=(int)$quielmata?>">
177 <input type="submit" value="Respon amenaça" />
178 </form>
Andreu Huguet6a633f22020-09-15 18:07:15 +0200179 </div>
180
Andreu03d030d2019-09-25 21:52:01 +0200181 <div>
182 <p>Podeu posar aquesta pàgina com a icona apretant el botó de "Add to Home Screen" del vostre navegador.</p>
183 <a href="./ranking.php">Anar al rànquing</a>
184 </div>
Andreu66ad5cf2019-09-18 17:15:44 +0200185 </div>
186 </div>
avm99963db383ed2019-09-22 02:14:42 +0200187
Andreu66ad5cf2019-09-18 17:15:44 +0200188 <script>
Andreudca79f42019-09-18 23:53:19 +0200189 $(document).ready(function() {
Andreuabbcb7e2019-09-21 18:22:14 +0200190 // Set interval of checking
Andreuefe66eb2019-09-21 18:41:49 +0200191 let checking = setInterval(function() { update_info(user); }, 1500);
Andreu96f1bcd2019-09-22 00:33:09 +0200192 // Set to hidden or not the password prompt
Andreu543e70c2019-09-22 14:08:49 +0200193 if (<?=$user->md5password=="" ? 1 : 0?>) {
194 $.notify("No tens clau d'accés", "info");
195 $(".formulari_contrasenya").show();
196 }
Andreu03d030d2019-09-25 21:52:01 +0200197 // Notify of messages
198 if (getUrlParameter("wrongconfirmation")) read_message("Les contrasenyes no coincideixen", "error");
199 if (getUrlParameter("errordb")) read_message("Hi ha hagut un problema a la base de dades, torna-ho a intentar", "error");
200 if (getUrlParameter("successpassword")) read_message("La teva clau d'accés s'ha guardat", "success");
Andreudca79f42019-09-18 23:53:19 +0200201 });
Andreu66ad5cf2019-09-18 17:15:44 +0200202 </script>
203 </body>
204</html>