blob: 6a775991f54dd9ce9498740220fadc9dce33a9d6 [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 = {
44 'id': <?=$user->id?>,
45 'quimata': <?=$user->quimata?>,
46 'requested': <?=$user->requested?>,
Andreuabbcb7e2019-09-21 18:22:14 +020047 'mort': <?=$user->mort?>,
avm99963db383ed2019-09-22 02:14:42 +020048
Andreuabbcb7e2019-09-21 18:22:14 +020049 'nom': "<?=$user->nomcomplet?>",
50 'curs': <?=$user->curs?>,
51 'grau': <?=$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">
64 <input type="hidden" value="<?=$_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
73 <table class="victima">
74 <tr>
Andreu3b84a3b2019-09-22 14:56:29 +020075 <td><img id="victim_img" src="https://picsum.photos/id/<?=$victim->id?>/200/200" /></td>
avm99963db383ed2019-09-22 02:14:42 +020076 <td>
77 <div id="victim_name"><?=$victim->nomcomplet?></div>
Andreu3b84a3b2019-09-22 14:56:29 +020078 <div id="victim_curs_i_grau">
79 <span id="victim_curs"><?=$victim->curs?></span>
80 -
81 <span id="victim_grau"><?=$victim->grau?></span>
82 </div>
avm99963db383ed2019-09-22 02:14:42 +020083 <div id="butons" class="options">
84 <button id="win" onclick="js: send_request(user, 'REQ KILL');">L'he matat</button>
85 </div>
86 </td>
87 </tr>
88 </table>
89
90 <div style="clear: both;"></div>
Andreu66ad5cf2019-09-18 17:15:44 +020091 </div>
92 </div>
avm99963db383ed2019-09-22 02:14:42 +020093
Andreu66ad5cf2019-09-18 17:15:44 +020094 <script>
Andreudca79f42019-09-18 23:53:19 +020095 $(document).ready(function() {
Andreuabbcb7e2019-09-21 18:22:14 +020096 // Set interval of checking
Andreuefe66eb2019-09-21 18:41:49 +020097 let checking = setInterval(function() { update_info(user); }, 1500);
Andreu96f1bcd2019-09-22 00:33:09 +020098 // Set to hidden or not the password prompt
Andreu543e70c2019-09-22 14:08:49 +020099 if (<?=$user->md5password=="" ? 1 : 0?>) {
100 $.notify("No tens clau d'accés", "info");
101 $(".formulari_contrasenya").show();
102 }
103
104 // Notify of messages
105 if (getUrlParameter("wrongconfirmation")) read_message("Les contrasenyes no coincideixen", "error");
106 if (getUrlParameter("errordb")) read_message("Hi ha hagut un problema a la base de dades, torna-ho a intentar", "error");
107 if (getUrlParameter("successpassword")) read_message("La teva clau d'accés s'ha guardat", "success");
Andreudca79f42019-09-18 23:53:19 +0200108 });
Andreu66ad5cf2019-09-18 17:15:44 +0200109 </script>
110 </body>
111</html>