Andreu | 78e5bb0 | 2019-09-22 13:38:04 +0200 | [diff] [blame] | 1 | <?php |
| 2 | require './credentials.php'; |
| 3 | require './php/utils.php'; |
| 4 | |
Andreu | 09b8b05 | 2019-09-21 21:47:20 +0200 | [diff] [blame] | 5 | if (!isset($_COOKIE['user'])) { |
Andreu | 96f1bcd | 2019-09-22 00:33:09 +0200 | [diff] [blame] | 6 | header("Location: ./index.php"); |
Andreu | 09b8b05 | 2019-09-21 21:47:20 +0200 | [diff] [blame] | 7 | die(); |
Andreu | 78e5bb0 | 2019-09-22 13:38:04 +0200 | [diff] [blame] | 8 | } 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 | } |
Andreu | 09b8b05 | 2019-09-21 21:47:20 +0200 | [diff] [blame] | 18 | } |
| 19 | ?> |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 20 | <html> |
| 21 | <head> |
| 22 | <meta charset="UTF-8"> |
| 23 | <title>Pàgina de l'usuari</title> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 24 | |
| 25 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 26 | |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 27 | <link rel="stylesheet" href="./css/basic.css" /> |
| 28 | <link rel="stylesheet" href="./css/main.css" /> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 29 | |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 30 | <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script> |
Andreu | ed8e1f9 | 2019-09-18 22:26:04 +0200 | [diff] [blame] | 31 | <script src="https://rawgit.com/notifyjs/notifyjs/master/dist/notify.js"></script> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 32 | |
Andreu | 10cb304 | 2019-09-18 19:55:36 +0200 | [diff] [blame] | 33 | <script src="./js/utils.js"></script> |
Andreu | efe66eb | 2019-09-21 18:41:49 +0200 | [diff] [blame] | 34 | <script src="./js/animations.js"></script> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 35 | |
| 36 | <?php |
Andreu | 09b8b05 | 2019-09-21 21:47:20 +0200 | [diff] [blame] | 37 | $user = get_users($_COOKIE['user']); |
| 38 | $victim = get_users($user->quimata); |
Andreu | 4ed7496 | 2019-09-22 00:06:15 +0200 | [diff] [blame] | 39 | if ($user->mort) header("Location: ./dead.php"); |
Andreu | dca79f4 | 2019-09-18 23:53:19 +0200 | [diff] [blame] | 40 | ?> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 41 | |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 42 | <script> |
Andreu | ed49167 | 2019-09-20 13:09:18 +0200 | [diff] [blame] | 43 | let user = { |
| 44 | 'id': <?=$user->id?>, |
| 45 | 'quimata': <?=$user->quimata?>, |
| 46 | 'requested': <?=$user->requested?>, |
Andreu | abbcb7e | 2019-09-21 18:22:14 +0200 | [diff] [blame] | 47 | 'mort': <?=$user->mort?>, |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 48 | |
Andreu | abbcb7e | 2019-09-21 18:22:14 +0200 | [diff] [blame] | 49 | 'nom': "<?=$user->nomcomplet?>", |
| 50 | 'curs': <?=$user->curs?>, |
| 51 | 'grau': <?=$user->grau?> |
Andreu | ed49167 | 2019-09-20 13:09:18 +0200 | [diff] [blame] | 52 | }; |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 53 | </script> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 54 | |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 55 | </head> |
| 56 | <body> |
| 57 | <div id="outter-container"> |
| 58 | <div id="inner-container"> |
| 59 | <h2>Hola <name id="user_name"><?=$user->nom()?></name>,</h2> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 60 | |
Andreu | 96f1bcd | 2019-09-22 00:33:09 +0200 | [diff] [blame] | 61 | <div class="formulari_contrasenya" style="display: none;"> |
Andreu | 543e70c | 2019-09-22 14:08:49 +0200 | [diff] [blame] | 62 | <p>Sembla que no tens clau d'accés, la gent podrà entrar a la teva compta...</p> |
Andreu | 20cbd1d | 2019-09-22 00:00:57 +0200 | [diff] [blame] | 63 | <form action="./php/change_password.php" method="POST"> |
| 64 | <input type="hidden" value="<?=$_COOKIE['user']?>" name="userid"> |
Andreu | 543e70c | 2019-09-22 14:08:49 +0200 | [diff] [blame] | 65 | <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 /> |
Andreu | 20cbd1d | 2019-09-22 00:00:57 +0200 | [diff] [blame] | 67 | <input type="submit"> |
| 68 | </form> |
| 69 | </div> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 70 | |
| 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> |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 87 | </div> |
| 88 | </div> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 89 | |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 90 | <script> |
Andreu | dca79f4 | 2019-09-18 23:53:19 +0200 | [diff] [blame] | 91 | $(document).ready(function() { |
Andreu | abbcb7e | 2019-09-21 18:22:14 +0200 | [diff] [blame] | 92 | // Set interval of checking |
Andreu | efe66eb | 2019-09-21 18:41:49 +0200 | [diff] [blame] | 93 | let checking = setInterval(function() { update_info(user); }, 1500); |
Andreu | 96f1bcd | 2019-09-22 00:33:09 +0200 | [diff] [blame] | 94 | // Set to hidden or not the password prompt |
Andreu | 543e70c | 2019-09-22 14:08:49 +0200 | [diff] [blame] | 95 | if (<?=$user->md5password=="" ? 1 : 0?>) { |
| 96 | $.notify("No tens clau d'accés", "info"); |
| 97 | $(".formulari_contrasenya").show(); |
| 98 | } |
| 99 | |
| 100 | // Notify of messages |
| 101 | if (getUrlParameter("wrongconfirmation")) read_message("Les contrasenyes no coincideixen", "error"); |
| 102 | if (getUrlParameter("errordb")) read_message("Hi ha hagut un problema a la base de dades, torna-ho a intentar", "error"); |
| 103 | if (getUrlParameter("successpassword")) read_message("La teva clau d'accés s'ha guardat", "success"); |
Andreu | dca79f4 | 2019-09-18 23:53:19 +0200 | [diff] [blame] | 104 | }); |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 105 | </script> |
| 106 | </body> |
| 107 | </html> |