blob: 54212b1bf674ab51d96b4aad910289b073712228 [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;">
Andreu20cbd1d2019-09-22 00:00:57 +020062 <p>Sembla que no tens contrasenya, la gent podrà entrar a la teva compta...</p>
63 <form action="./php/change_password.php" method="POST">
64 <input type="hidden" value="<?=$_COOKIE['user']?>" name="userid">
65 <input type="password" placeholder="Nova contrasenya..." name="password" /><br />
66 <input type="password" placeholder="Repeteix la contrasenya" name="confirmation"/><br />
67 <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>
75 <td><img id="victim_img" src="./imgs/<?=$victim->id?>.png" /></td>
76 <td>
77 <div id="victim_name"><?=$victim->nomcomplet?></div>
78 <div id="victim_curs_i_grau"><span id="victim_curs"><?=$victim->curs?></span>-<span id="victim_grau"><?=$victim->grau?></span></div>
79 <div id="butons" class="options">
80 <button id="win" onclick="js: send_request(user, 'REQ KILL');">L'he matat</button>
81 </div>
82 </td>
83 </tr>
84 </table>
85
86 <div style="clear: both;"></div>
Andreu66ad5cf2019-09-18 17:15:44 +020087 </div>
88 </div>
avm99963db383ed2019-09-22 02:14:42 +020089
Andreu66ad5cf2019-09-18 17:15:44 +020090 <script>
Andreudca79f42019-09-18 23:53:19 +020091 $(document).ready(function() {
Andreuabbcb7e2019-09-21 18:22:14 +020092 // Set interval of checking
Andreuefe66eb2019-09-21 18:41:49 +020093 let checking = setInterval(function() { update_info(user); }, 1500);
Andreu96f1bcd2019-09-22 00:33:09 +020094 // Set to hidden or not the password prompt
95 if (<?=$user->md5password=="" ? 1 : 0?>) $(".formulari_contrasenya").show();
Andreudca79f42019-09-18 23:53:19 +020096 });
Andreu66ad5cf2019-09-18 17:15:44 +020097 </script>
98 </body>
99</html>