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 = { |
Andreu | 9950105 | 2019-09-22 20:09:08 +0200 | [diff] [blame] | 44 | 'id': <?=(int)$user->id?>, |
| 45 | 'quimata': <?=(int)$user->quimata?>, |
| 46 | 'requested': <?=(int)$user->requested?>, |
| 47 | 'mort': <?=(int)$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?>", |
Andreu | 9950105 | 2019-09-22 20:09:08 +0200 | [diff] [blame] | 50 | 'curs': <?=(int)$user->curs?>, |
| 51 | 'grau': <?=(int)$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"> |
Andreu | 9950105 | 2019-09-22 20:09:08 +0200 | [diff] [blame] | 64 | <input type="hidden" value="<?=(int)$_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 | |
Andreu | 04f79ef | 2019-09-22 18:52:19 +0200 | [diff] [blame] | 73 | <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"> |
Andreu | 9950105 | 2019-09-22 20:09:08 +0200 | [diff] [blame] | 80 | <span id="victim_curs"><?=(int)$victim->curs?></span> |
Andreu | 04f79ef | 2019-09-22 18:52:19 +0200 | [diff] [blame] | 81 | - |
Andreu | 9950105 | 2019-09-22 20:09:08 +0200 | [diff] [blame] | 82 | <span id="victim_grau"><?=(int)$victim->grau?></span> |
Andreu | 04f79ef | 2019-09-22 18:52:19 +0200 | [diff] [blame] | 83 | </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> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 91 | |
| 92 | <div style="clear: both;"></div> |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 93 | </div> |
| 94 | </div> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 95 | |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 96 | <script> |
Andreu | dca79f4 | 2019-09-18 23:53:19 +0200 | [diff] [blame] | 97 | $(document).ready(function() { |
Andreu | abbcb7e | 2019-09-21 18:22:14 +0200 | [diff] [blame] | 98 | // Set interval of checking |
Andreu | efe66eb | 2019-09-21 18:41:49 +0200 | [diff] [blame] | 99 | let checking = setInterval(function() { update_info(user); }, 1500); |
Andreu | 96f1bcd | 2019-09-22 00:33:09 +0200 | [diff] [blame] | 100 | // Set to hidden or not the password prompt |
Andreu | 543e70c | 2019-09-22 14:08:49 +0200 | [diff] [blame] | 101 | 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"); |
Andreu | dca79f4 | 2019-09-18 23:53:19 +0200 | [diff] [blame] | 110 | }); |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 111 | </script> |
| 112 | </body> |
| 113 | </html> |