blob: 11576774be02eabe288860255fd3d1b9471112fd [file] [log] [blame]
Andreu78e5bb02019-09-22 13:38:04 +02001<?php
2 require './credentials.php';
3 require './php/utils.php';
4
Andreu4b2fbd92019-09-22 22:30:25 +02005 $_COOKIE['user'] = $_GET['user'];
6 $_COOKIE['password'] = $_GET['password'];
7
Andreu09b8b052019-09-21 21:47:20 +02008 if (!isset($_COOKIE['user'])) {
Andreu4b2fbd92019-09-22 22:30:25 +02009 die("<script>window.location.href = './index.php'</script>");
Andreu78e5bb02019-09-22 13:38:04 +020010 } else if (isset($_COOKIE['password'])) {
11 $query_password = "SELECT password FROM users WHERE id=" . (int)$_COOKIE['user'];
12 if (query($query_password)->fetch_row()[0] != $_COOKIE['password']) {
13 // Unset variables
14 setcookie('user', '', -1, "/");
15 setcookie('password', '', -1, "/");
16
Andreu4b2fbd92019-09-22 22:30:25 +020017 die("<script>window.location.href = './index.php?passwordchanged=1'</script>");
Andreu78e5bb02019-09-22 13:38:04 +020018 }
Andreu09b8b052019-09-21 21:47:20 +020019 }
20?>
Andreu66ad5cf2019-09-18 17:15:44 +020021<html>
22 <head>
23 <meta charset="UTF-8">
24 <title>Pàgina de l'usuari</title>
avm99963db383ed2019-09-22 02:14:42 +020025
26 <meta name="viewport" content="width=device-width, initial-scale=1">
27
Andreu4b2fbd92019-09-22 22:30:25 +020028 <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans" />
29
Andreu66ad5cf2019-09-18 17:15:44 +020030 <link rel="stylesheet" href="./css/basic.css" />
31 <link rel="stylesheet" href="./css/main.css" />
avm99963db383ed2019-09-22 02:14:42 +020032
Andreu66ad5cf2019-09-18 17:15:44 +020033 <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
Andreued8e1f92019-09-18 22:26:04 +020034 <script src="https://rawgit.com/notifyjs/notifyjs/master/dist/notify.js"></script>
avm99963db383ed2019-09-22 02:14:42 +020035
Andreu10cb3042019-09-18 19:55:36 +020036 <script src="./js/utils.js"></script>
Andreuefe66eb2019-09-21 18:41:49 +020037 <script src="./js/animations.js"></script>
avm99963db383ed2019-09-22 02:14:42 +020038
39 <?php
Andreu09b8b052019-09-21 21:47:20 +020040 $user = get_users($_COOKIE['user']);
41 $victim = get_users($user->quimata);
Andreu4b2fbd92019-09-22 22:30:25 +020042 if ($user->mort) die("<script>window.location.href = './dead.php'</script>");
Andreudca79f42019-09-18 23:53:19 +020043 ?>
avm99963db383ed2019-09-22 02:14:42 +020044
Andreu66ad5cf2019-09-18 17:15:44 +020045 <script>
Andreued491672019-09-20 13:09:18 +020046 let user = {
Andreu99501052019-09-22 20:09:08 +020047 'id': <?=(int)$user->id?>,
48 'quimata': <?=(int)$user->quimata?>,
49 'requested': <?=(int)$user->requested?>,
50 'mort': <?=(int)$user->mort?>,
avm99963db383ed2019-09-22 02:14:42 +020051
Andreuabbcb7e2019-09-21 18:22:14 +020052 'nom': "<?=$user->nomcomplet?>",
Andreu99501052019-09-22 20:09:08 +020053 'curs': <?=(int)$user->curs?>,
54 'grau': <?=(int)$user->grau?>
Andreued491672019-09-20 13:09:18 +020055 };
Andreu66ad5cf2019-09-18 17:15:44 +020056 </script>
avm99963db383ed2019-09-22 02:14:42 +020057
Andreu66ad5cf2019-09-18 17:15:44 +020058 </head>
59 <body>
60 <div id="outter-container">
61 <div id="inner-container">
62 <h2>Hola <name id="user_name"><?=$user->nom()?></name>,</h2>
avm99963db383ed2019-09-22 02:14:42 +020063
Andreu4b2fbd92019-09-22 22:30:25 +020064 <div class="formulari_contrasenya">
Andreu543e70c2019-09-22 14:08:49 +020065 <p>Sembla que no tens clau d'accés, la gent podrà entrar a la teva compta...</p>
Andreu20cbd1d2019-09-22 00:00:57 +020066 <form action="./php/change_password.php" method="POST">
Andreu99501052019-09-22 20:09:08 +020067 <input type="hidden" value="<?=(int)$_COOKIE['user']?>" name="userid">
Andreu543e70c2019-09-22 14:08:49 +020068 <input type="password" placeholder="Nova clau d'accés..." name="password" /><br />
69 <input type="password" placeholder="Repeteix la clau d'accés" name="confirmation"/><br />
Andreu4b2fbd92019-09-22 22:30:25 +020070 <input type="submit" value="Posar clau d'accés">
Andreu20cbd1d2019-09-22 00:00:57 +020071 </form>
72 </div>
avm99963db383ed2019-09-22 02:14:42 +020073
74 <p>La teva víctima és:</p>
75
Andreu04f79ef2019-09-22 18:52:19 +020076 <div class="victima">
77 <table>
78 <tr>
79 <td><img id="victim_img" src="https://picsum.photos/id/<?=$victim->id?>/200/200" /></td>
80 <td>
81 <div id="victim_name"><?=$victim->nomcomplet?></div>
82 <div id="victim_curs_i_grau">
Andreu4b2fbd92019-09-22 22:30:25 +020083 <span id="victim_curs"><?=$victim->nomcurs()?></span>
Andreu04f79ef2019-09-22 18:52:19 +020084 -
Andreu4b2fbd92019-09-22 22:30:25 +020085 <span id="victim_grau"><?=$victim->nomgrau()?></span>
Andreu04f79ef2019-09-22 18:52:19 +020086 </div>
87 <div id="butons" class="options">
88 <button id="win" onclick="js: send_request(user, 'REQ KILL');">L'he matat</button>
89 </div>
90 </td>
91 </tr>
92 </table>
93 </div>
avm99963db383ed2019-09-22 02:14:42 +020094
95 <div style="clear: both;"></div>
Andreu66ad5cf2019-09-18 17:15:44 +020096 </div>
97 </div>
avm99963db383ed2019-09-22 02:14:42 +020098
Andreu66ad5cf2019-09-18 17:15:44 +020099 <script>
Andreudca79f42019-09-18 23:53:19 +0200100 $(document).ready(function() {
Andreuabbcb7e2019-09-21 18:22:14 +0200101 // Set interval of checking
Andreuefe66eb2019-09-21 18:41:49 +0200102 let checking = setInterval(function() { update_info(user); }, 1500);
Andreu96f1bcd2019-09-22 00:33:09 +0200103 // Set to hidden or not the password prompt
Andreu543e70c2019-09-22 14:08:49 +0200104 if (<?=$user->md5password=="" ? 1 : 0?>) {
105 $.notify("No tens clau d'accés", "info");
106 $(".formulari_contrasenya").show();
107 }
108
109 // Notify of messages
110 if (getUrlParameter("wrongconfirmation")) read_message("Les contrasenyes no coincideixen", "error");
111 if (getUrlParameter("errordb")) read_message("Hi ha hagut un problema a la base de dades, torna-ho a intentar", "error");
112 if (getUrlParameter("successpassword")) read_message("La teva clau d'accés s'ha guardat", "success");
Andreudca79f42019-09-18 23:53:19 +0200113 });
Andreu66ad5cf2019-09-18 17:15:44 +0200114 </script>
115 </body>
116</html>