blob: 7e0231be2227db399285ba6922d120625fbb9ec6 [file] [log] [blame]
Andreu78e5bb02019-09-22 13:38:04 +02001<?php
2 require './credentials.php';
3 require './php/utils.php';
4
Andreu09b8b052019-09-21 21:47:20 +02005 if (!isset($_COOKIE['user'])) {
Andreu96f1bcd2019-09-22 00:33:09 +02006 header("Location: ./index.php");
Andreu09b8b052019-09-21 21:47:20 +02007 die();
Andreu78e5bb02019-09-22 13:38:04 +02008 } else if (isset($_COOKIE['password'])) {
9 $query_password = "SELECT password FROM users WHERE id=" . (int)$_COOKIE['user'];
10 if (query($query_password)->fetch_row()[0] != $_COOKIE['password']) {
11 // Unset variables
12 setcookie('user', '', -1, "/");
13 setcookie('password', '', -1, "/");
14
15 header("Location: ./index.php?passwordchanged=1");
16 die();
17 }
Andreu09b8b052019-09-21 21:47:20 +020018 }
19?>
Andreu66ad5cf2019-09-18 17:15:44 +020020<html>
21 <head>
22 <meta charset="UTF-8">
23 <title>Pàgina de l'usuari</title>
avm99963db383ed2019-09-22 02:14:42 +020024
25 <meta name="viewport" content="width=device-width, initial-scale=1">
26
Andreu66ad5cf2019-09-18 17:15:44 +020027 <link rel="stylesheet" href="./css/basic.css" />
28 <link rel="stylesheet" href="./css/main.css" />
avm99963db383ed2019-09-22 02:14:42 +020029
Andreu66ad5cf2019-09-18 17:15:44 +020030 <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
Andreued8e1f92019-09-18 22:26:04 +020031 <script src="https://rawgit.com/notifyjs/notifyjs/master/dist/notify.js"></script>
avm99963db383ed2019-09-22 02:14:42 +020032
Andreu10cb3042019-09-18 19:55:36 +020033 <script src="./js/utils.js"></script>
Andreuefe66eb2019-09-21 18:41:49 +020034 <script src="./js/animations.js"></script>
avm99963db383ed2019-09-22 02:14:42 +020035
36 <?php
Andreu09b8b052019-09-21 21:47:20 +020037 $user = get_users($_COOKIE['user']);
38 $victim = get_users($user->quimata);
Andreu4ed74962019-09-22 00:06:15 +020039 if ($user->mort) header("Location: ./dead.php");
Andreudca79f42019-09-18 23:53:19 +020040 ?>
avm99963db383ed2019-09-22 02:14:42 +020041
Andreu66ad5cf2019-09-18 17:15:44 +020042 <script>
Andreued491672019-09-20 13:09:18 +020043 let user = {
Andreu99501052019-09-22 20:09:08 +020044 'id': <?=(int)$user->id?>,
45 'quimata': <?=(int)$user->quimata?>,
46 'requested': <?=(int)$user->requested?>,
47 'mort': <?=(int)$user->mort?>,
avm99963db383ed2019-09-22 02:14:42 +020048
Andreuabbcb7e2019-09-21 18:22:14 +020049 'nom': "<?=$user->nomcomplet?>",
Andreu99501052019-09-22 20:09:08 +020050 'curs': <?=(int)$user->curs?>,
51 'grau': <?=(int)$user->grau?>
Andreued491672019-09-20 13:09:18 +020052 };
Andreu66ad5cf2019-09-18 17:15:44 +020053 </script>
avm99963db383ed2019-09-22 02:14:42 +020054
Andreu66ad5cf2019-09-18 17:15:44 +020055 </head>
56 <body>
57 <div id="outter-container">
58 <div id="inner-container">
59 <h2>Hola <name id="user_name"><?=$user->nom()?></name>,</h2>
avm99963db383ed2019-09-22 02:14:42 +020060
Andreu96f1bcd2019-09-22 00:33:09 +020061 <div class="formulari_contrasenya" style="display: none;">
Andreu543e70c2019-09-22 14:08:49 +020062 <p>Sembla que no tens clau d'accés, la gent podrà entrar a la teva compta...</p>
Andreu20cbd1d2019-09-22 00:00:57 +020063 <form action="./php/change_password.php" method="POST">
Andreu99501052019-09-22 20:09:08 +020064 <input type="hidden" value="<?=(int)$_COOKIE['user']?>" name="userid">
Andreu543e70c2019-09-22 14:08:49 +020065 <input type="password" placeholder="Nova clau d'accés..." name="password" /><br />
66 <input type="password" placeholder="Repeteix la clau d'accés" name="confirmation"/><br />
Andreu20cbd1d2019-09-22 00:00:57 +020067 <input type="submit">
68 </form>
69 </div>
avm99963db383ed2019-09-22 02:14:42 +020070
71 <p>La teva víctima és:</p>
72
Andreu04f79ef2019-09-22 18:52:19 +020073 <div class="victima">
74 <table>
75 <tr>
76 <td><img id="victim_img" src="https://picsum.photos/id/<?=$victim->id?>/200/200" /></td>
77 <td>
78 <div id="victim_name"><?=$victim->nomcomplet?></div>
79 <div id="victim_curs_i_grau">
Andreu99501052019-09-22 20:09:08 +020080 <span id="victim_curs"><?=(int)$victim->curs?></span>
Andreu04f79ef2019-09-22 18:52:19 +020081 -
Andreu99501052019-09-22 20:09:08 +020082 <span id="victim_grau"><?=(int)$victim->grau?></span>
Andreu04f79ef2019-09-22 18:52:19 +020083 </div>
84 <div id="butons" class="options">
85 <button id="win" onclick="js: send_request(user, 'REQ KILL');">L'he matat</button>
86 </div>
87 </td>
88 </tr>
89 </table>
90 </div>
avm99963db383ed2019-09-22 02:14:42 +020091
92 <div style="clear: both;"></div>
Andreu66ad5cf2019-09-18 17:15:44 +020093 </div>
94 </div>
avm99963db383ed2019-09-22 02:14:42 +020095
Andreu66ad5cf2019-09-18 17:15:44 +020096 <script>
Andreudca79f42019-09-18 23:53:19 +020097 $(document).ready(function() {
Andreuabbcb7e2019-09-21 18:22:14 +020098 // Set interval of checking
Andreuefe66eb2019-09-21 18:41:49 +020099 let checking = setInterval(function() { update_info(user); }, 1500);
Andreu96f1bcd2019-09-22 00:33:09 +0200100 // Set to hidden or not the password prompt
Andreu543e70c2019-09-22 14:08:49 +0200101 if (<?=$user->md5password=="" ? 1 : 0?>) {
102 $.notify("No tens clau d'accés", "info");
103 $(".formulari_contrasenya").show();
104 }
105
106 // Notify of messages
107 if (getUrlParameter("wrongconfirmation")) read_message("Les contrasenyes no coincideixen", "error");
108 if (getUrlParameter("errordb")) read_message("Hi ha hagut un problema a la base de dades, torna-ho a intentar", "error");
109 if (getUrlParameter("successpassword")) read_message("La teva clau d'accés s'ha guardat", "success");
Andreudca79f42019-09-18 23:53:19 +0200110 });
Andreu66ad5cf2019-09-18 17:15:44 +0200111 </script>
112 </body>
113</html>