Andreu | 78e5bb0 | 2019-09-22 13:38:04 +0200 | [diff] [blame] | 1 | <?php |
| 2 | require './credentials.php'; |
| 3 | require './php/utils.php'; |
Andreu | 0d0f9fd | 2019-09-23 03:56:08 +0200 | [diff] [blame] | 4 | |
Andreu | 20af6c2 | 2019-09-24 18:33:50 +0200 | [diff] [blame^] | 5 | $credentials = new Credentials(); |
| 6 | $usersdb = $credentials->usersdb; |
| 7 | $mortsdb = $credentials->mortsdb; |
| 8 | |
Andreu | a0fc827 | 2019-09-23 00:35:25 +0200 | [diff] [blame] | 9 | $user = (int)$_POST['user']; |
Andreu | 0d0f9fd | 2019-09-23 03:56:08 +0200 | [diff] [blame] | 10 | $password = isset($_POST['password']) ? md5($_POST['password']) : ''; |
Andreu | 4b2fbd9 | 2019-09-22 22:30:25 +0200 | [diff] [blame] | 11 | |
Andreu | a0fc827 | 2019-09-23 00:35:25 +0200 | [diff] [blame] | 12 | // Check if password is correct |
Andreu | 20af6c2 | 2019-09-24 18:33:50 +0200 | [diff] [blame^] | 13 | $query_password = "SELECT password FROM $usersdb WHERE id=$user"; |
Andreu | a0fc827 | 2019-09-23 00:35:25 +0200 | [diff] [blame] | 14 | $real_password = query($query_password)->fetch_row()[0]; |
| 15 | if ($real_password != $password) die("<script>window.location.href = './index.php?wrongpassword=1'</script>"); |
| 16 | |
Andreu | 0d0f9fd | 2019-09-23 03:56:08 +0200 | [diff] [blame] | 17 | if (!isset($_POST['user']) or $_POST['user'] == '') { |
Andreu | 4b2fbd9 | 2019-09-22 22:30:25 +0200 | [diff] [blame] | 18 | die("<script>window.location.href = './index.php'</script>"); |
Andreu | a0fc827 | 2019-09-23 00:35:25 +0200 | [diff] [blame] | 19 | } else if (isset($_POST['password'])) { |
Andreu | 20af6c2 | 2019-09-24 18:33:50 +0200 | [diff] [blame^] | 20 | $query_password = "SELECT password FROM $usersdb WHERE id=$user"; |
Andreu | a0fc827 | 2019-09-23 00:35:25 +0200 | [diff] [blame] | 21 | if (query($query_password)->fetch_row()[0] != $password) { |
Andreu | 78e5bb0 | 2019-09-22 13:38:04 +0200 | [diff] [blame] | 22 | // Unset variables |
| 23 | setcookie('user', '', -1, "/"); |
| 24 | setcookie('password', '', -1, "/"); |
| 25 | |
Andreu | 4b2fbd9 | 2019-09-22 22:30:25 +0200 | [diff] [blame] | 26 | die("<script>window.location.href = './index.php?passwordchanged=1'</script>"); |
Andreu | 78e5bb0 | 2019-09-22 13:38:04 +0200 | [diff] [blame] | 27 | } |
Andreu | 09b8b05 | 2019-09-21 21:47:20 +0200 | [diff] [blame] | 28 | } |
| 29 | ?> |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 30 | <html> |
| 31 | <head> |
| 32 | <meta charset="UTF-8"> |
Andreu | 0d0f9fd | 2019-09-23 03:56:08 +0200 | [diff] [blame] | 33 | <title>PastanagAPP</title> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 34 | |
| 35 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
Andreu | 0d0f9fd | 2019-09-23 03:56:08 +0200 | [diff] [blame] | 36 | <link rel="manifest" href="https://api.myjson.com/bins/u6r41"> |
| 37 | |
| 38 | <!-- Apple web app --> |
| 39 | <link rel="apple-touch-icon" href="./bin/images/icons/icon-72x72.png"> |
| 40 | <meta name="apple-mobile-web-app-title" content="PastanagAPP"> |
| 41 | <meta name="apple-mobile-web-app-capable" content="yes"> |
| 42 | <meta name="apple-mobile-web-app-status-bar-style" content="green"> |
| 43 | |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 44 | |
Andreu | 4b2fbd9 | 2019-09-22 22:30:25 +0200 | [diff] [blame] | 45 | <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans" /> |
| 46 | |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 47 | <link rel="stylesheet" href="./css/basic.css" /> |
| 48 | <link rel="stylesheet" href="./css/main.css" /> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 49 | |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 50 | <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script> |
Andreu | ed8e1f9 | 2019-09-18 22:26:04 +0200 | [diff] [blame] | 51 | <script src="https://rawgit.com/notifyjs/notifyjs/master/dist/notify.js"></script> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 52 | |
Andreu | 10cb304 | 2019-09-18 19:55:36 +0200 | [diff] [blame] | 53 | <script src="./js/utils.js"></script> |
Andreu | efe66eb | 2019-09-21 18:41:49 +0200 | [diff] [blame] | 54 | <script src="./js/animations.js"></script> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 55 | |
| 56 | <?php |
Andreu | a0fc827 | 2019-09-23 00:35:25 +0200 | [diff] [blame] | 57 | $user = get_users($user); |
Andreu | 09b8b05 | 2019-09-21 21:47:20 +0200 | [diff] [blame] | 58 | $victim = get_users($user->quimata); |
Andreu | 0530b30 | 2019-09-24 04:18:20 +0200 | [diff] [blame] | 59 | if ($user->mort) die("<script>window.location.href = './dead.php'</script>"); |
Andreu | 779c3b7 | 2019-09-24 03:14:35 +0200 | [diff] [blame] | 60 | |
| 61 | $bits = dec2bits($user->bits); |
| 62 | $bit_counter = 0; |
Andreu | dca79f4 | 2019-09-18 23:53:19 +0200 | [diff] [blame] | 63 | ?> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 64 | |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 65 | <script> |
Andreu | ed49167 | 2019-09-20 13:09:18 +0200 | [diff] [blame] | 66 | let user = { |
Andreu | 9950105 | 2019-09-22 20:09:08 +0200 | [diff] [blame] | 67 | 'id': <?=(int)$user->id?>, |
| 68 | 'quimata': <?=(int)$user->quimata?>, |
| 69 | 'requested': <?=(int)$user->requested?>, |
| 70 | 'mort': <?=(int)$user->mort?>, |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 71 | |
Andreu | abbcb7e | 2019-09-21 18:22:14 +0200 | [diff] [blame] | 72 | 'nom': "<?=$user->nomcomplet?>", |
Andreu | 9950105 | 2019-09-22 20:09:08 +0200 | [diff] [blame] | 73 | 'curs': <?=(int)$user->curs?>, |
| 74 | 'grau': <?=(int)$user->grau?> |
Andreu | ed49167 | 2019-09-20 13:09:18 +0200 | [diff] [blame] | 75 | }; |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 76 | </script> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 77 | |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 78 | </head> |
| 79 | <body> |
| 80 | <div id="outter-container"> |
| 81 | <div id="inner-container"> |
Andreu | 0d0f9fd | 2019-09-23 03:56:08 +0200 | [diff] [blame] | 82 | <a href="./index.php" class="goback">Torna a la pàgina principal</a><br /> |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 83 | <h2>Hola <name id="user_name"><?=$user->nom()?></name>,</h2> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 84 | |
Andreu | 4b2fbd9 | 2019-09-22 22:30:25 +0200 | [diff] [blame] | 85 | <div class="formulari_contrasenya"> |
Andreu | a0fc827 | 2019-09-23 00:35:25 +0200 | [diff] [blame] | 86 | <p>Sembla que no tens clau d'accés, la gent podrà entrar al teu compte...</p> |
Andreu | 20cbd1d | 2019-09-22 00:00:57 +0200 | [diff] [blame] | 87 | <form action="./php/change_password.php" method="POST"> |
Andreu | a0fc827 | 2019-09-23 00:35:25 +0200 | [diff] [blame] | 88 | <input type="hidden" value="<?=(int)$_POST['user']?>" name="userid"> |
Andreu | 543e70c | 2019-09-22 14:08:49 +0200 | [diff] [blame] | 89 | <input type="password" placeholder="Nova clau d'accés..." name="password" /><br /> |
| 90 | <input type="password" placeholder="Repeteix la clau d'accés" name="confirmation"/><br /> |
Andreu | 4b2fbd9 | 2019-09-22 22:30:25 +0200 | [diff] [blame] | 91 | <input type="submit" value="Posar clau d'accés"> |
Andreu | 20cbd1d | 2019-09-22 00:00:57 +0200 | [diff] [blame] | 92 | </form> |
| 93 | </div> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 94 | |
| 95 | <p>La teva víctima és:</p> |
| 96 | |
Andreu | 04f79ef | 2019-09-22 18:52:19 +0200 | [diff] [blame] | 97 | <div class="victima"> |
| 98 | <table> |
| 99 | <tr> |
Andreu | 779c3b7 | 2019-09-24 03:14:35 +0200 | [diff] [blame] | 100 | <td class="table_img"> |
| 101 | <div id="victim_img"> |
| 102 | <table cellspacing="0" cellpadding="0"> |
| 103 | <tr> |
| 104 | <td><img src="./bin/images/imgs/<?=$victim->id?>/slice_01_01.png" width="33" class="<?=(int)$bits[$bit_counter++] ? 'black' : ''?>" /></td> |
| 105 | <td><img src="./bin/images/imgs/<?=$victim->id?>/slice_01_02.png" width="33" class="<?=(int)$bits[$bit_counter++] ? 'black' : ''?>" /></td> |
| 106 | <td><img src="./bin/images/imgs/<?=$victim->id?>/slice_01_03.png" width="33" class="<?=(int)$bits[$bit_counter++] ? 'black' : ''?>" /></td> |
| 107 | </tr> |
| 108 | <tr> |
| 109 | <td><img src="./bin/images/imgs/<?=$victim->id?>/slice_02_01.png" width="33" class="<?=(int)$bits[$bit_counter++] ? 'black' : ''?>" /></td> |
| 110 | <td><img src="./bin/images/imgs/<?=$victim->id?>/slice_02_02.png" width="33" class="<?=(int)$bits[$bit_counter++] ? 'black' : ''?>" /></td> |
| 111 | <td><img src="./bin/images/imgs/<?=$victim->id?>/slice_02_03.png" width="33" class="<?=(int)$bits[$bit_counter++] ? 'black' : ''?>" /></td> |
| 112 | </tr> |
| 113 | <tr> |
| 114 | <td><img src="./bin/images/imgs/<?=$victim->id?>/slice_03_01.png" width="33" class="<?=(int)$bits[$bit_counter++] ? 'black' : ''?>" /></td> |
| 115 | <td><img src="./bin/images/imgs/<?=$victim->id?>/slice_03_02.png" width="33" class="<?=(int)$bits[$bit_counter++] ? 'black' : ''?>" /></td> |
| 116 | <td><img src="./bin/images/imgs/<?=$victim->id?>/slice_03_03.png" width="33" class="<?=(int)$bits[$bit_counter++] ? 'black' : ''?>" /></td> |
| 117 | </tr> |
| 118 | </table> |
| 119 | </div> |
| 120 | </td> |
Andreu | 0d0f9fd | 2019-09-23 03:56:08 +0200 | [diff] [blame] | 121 | <td class="table_text"> |
Andreu | 04f79ef | 2019-09-22 18:52:19 +0200 | [diff] [blame] | 122 | <div id="victim_name"><?=$victim->nomcomplet?></div> |
| 123 | <div id="victim_curs_i_grau"> |
Andreu | 4b2fbd9 | 2019-09-22 22:30:25 +0200 | [diff] [blame] | 124 | <span id="victim_curs"><?=$victim->nomcurs()?></span> |
Andreu | 04f79ef | 2019-09-22 18:52:19 +0200 | [diff] [blame] | 125 | - |
Andreu | 4b2fbd9 | 2019-09-22 22:30:25 +0200 | [diff] [blame] | 126 | <span id="victim_grau"><?=$victim->nomgrau()?></span> |
Andreu | 04f79ef | 2019-09-22 18:52:19 +0200 | [diff] [blame] | 127 | </div> |
| 128 | <div id="butons" class="options"> |
| 129 | <button id="win" onclick="js: send_request(user, 'REQ KILL');">L'he matat</button> |
| 130 | </div> |
| 131 | </td> |
| 132 | </tr> |
| 133 | </table> |
| 134 | </div> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 135 | |
| 136 | <div style="clear: both;"></div> |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 137 | </div> |
| 138 | </div> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 139 | |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 140 | <script> |
Andreu | dca79f4 | 2019-09-18 23:53:19 +0200 | [diff] [blame] | 141 | $(document).ready(function() { |
Andreu | abbcb7e | 2019-09-21 18:22:14 +0200 | [diff] [blame] | 142 | // Set interval of checking |
Andreu | efe66eb | 2019-09-21 18:41:49 +0200 | [diff] [blame] | 143 | let checking = setInterval(function() { update_info(user); }, 1500); |
Andreu | 96f1bcd | 2019-09-22 00:33:09 +0200 | [diff] [blame] | 144 | // Set to hidden or not the password prompt |
Andreu | 543e70c | 2019-09-22 14:08:49 +0200 | [diff] [blame] | 145 | if (<?=$user->md5password=="" ? 1 : 0?>) { |
| 146 | $.notify("No tens clau d'accés", "info"); |
| 147 | $(".formulari_contrasenya").show(); |
| 148 | } |
Andreu | dca79f4 | 2019-09-18 23:53:19 +0200 | [diff] [blame] | 149 | }); |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 150 | </script> |
| 151 | </body> |
| 152 | </html> |