Andreu | 78e5bb0 | 2019-09-22 13:38:04 +0200 | [diff] [blame] | 1 | <?php |
| 2 | require './credentials.php'; |
| 3 | require './php/utils.php'; |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 4 | require_once('./php/security.php'); |
Andreu | 20af6c2 | 2019-09-24 18:33:50 +0200 | [diff] [blame] | 5 | |
Adrià Vilanova Martínez | d3394e1 | 2022-11-19 15:45:58 +0100 | [diff] [blame] | 6 | date_default_timezone_set("Europe/Madrid"); |
Andreu | 03d030d | 2019-09-25 21:52:01 +0200 | [diff] [blame] | 7 | |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 8 | Security::checkIsSignedIn(); |
Andreu | 09b8b05 | 2019-09-21 21:47:20 +0200 | [diff] [blame] | 9 | ?> |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 10 | <html> |
| 11 | <head> |
| 12 | <meta charset="UTF-8"> |
Andreu | 0d0f9fd | 2019-09-23 03:56:08 +0200 | [diff] [blame] | 13 | <title>PastanagAPP</title> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 14 | |
| 15 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
Adrià Vilanova Martínez | 71e9f87 | 2022-11-20 01:54:50 +0100 | [diff] [blame] | 16 | <link rel="manifest" href="/bin/manifest.json"> |
Andreu | 0d0f9fd | 2019-09-23 03:56:08 +0200 | [diff] [blame] | 17 | |
| 18 | <!-- Apple web app --> |
| 19 | <link rel="apple-touch-icon" href="./bin/images/icons/icon-72x72.png"> |
| 20 | <meta name="apple-mobile-web-app-title" content="PastanagAPP"> |
| 21 | <meta name="apple-mobile-web-app-capable" content="yes"> |
| 22 | <meta name="apple-mobile-web-app-status-bar-style" content="green"> |
| 23 | |
Adrià Vilanova Martínez | dc7fbb6 | 2022-12-11 16:28:44 +0100 | [diff] [blame] | 24 | <link rel="preconnect" href="https://fonts.googleapis.com"> |
| 25 | <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> |
| 26 | <link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400;0,500;1,400;1,500" rel="stylesheet"> |
Andreu | 4b2fbd9 | 2019-09-22 22:30:25 +0200 | [diff] [blame] | 27 | |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 28 | <link rel="stylesheet" href="./css/basic.css" /> |
| 29 | <link rel="stylesheet" href="./css/main.css" /> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 30 | |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 31 | <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script> |
Andreu | ed8e1f9 | 2019-09-18 22:26:04 +0200 | [diff] [blame] | 32 | <script src="https://rawgit.com/notifyjs/notifyjs/master/dist/notify.js"></script> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 33 | |
Andreu | 10cb304 | 2019-09-18 19:55:36 +0200 | [diff] [blame] | 34 | <script src="./js/utils.js"></script> |
Andreu | efe66eb | 2019-09-21 18:41:49 +0200 | [diff] [blame] | 35 | <script src="./js/animations.js"></script> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 36 | |
| 37 | <?php |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 38 | $user = get_users($_SESSION["id"]); |
Andreu | 0530b30 | 2019-09-24 04:18:20 +0200 | [diff] [blame] | 39 | if ($user->mort) die("<script>window.location.href = './dead.php'</script>"); |
Adrià Vilanova Martínez | 7b206bb | 2022-12-10 17:29:52 +0100 | [diff] [blame] | 40 | |
| 41 | // @TODO: Reenable photos |
| 42 | /*$bits = dec2bits($user->bits); |
| 43 | $bit_counter = 0;*/ |
Andreu | dca79f4 | 2019-09-18 23:53:19 +0200 | [diff] [blame] | 44 | ?> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 45 | |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 46 | <script> |
Andreu | ed49167 | 2019-09-20 13:09:18 +0200 | [diff] [blame] | 47 | let user = { |
Andreu | 9950105 | 2019-09-22 20:09:08 +0200 | [diff] [blame] | 48 | 'id': <?=(int)$user->id?>, |
| 49 | 'quimata': <?=(int)$user->quimata?>, |
| 50 | 'requested': <?=(int)$user->requested?>, |
| 51 | 'mort': <?=(int)$user->mort?>, |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 52 | |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 53 | 'nom': "<?=Security::htmlsafe($user->nomcomplet)?>", |
Andreu | 9950105 | 2019-09-22 20:09:08 +0200 | [diff] [blame] | 54 | 'curs': <?=(int)$user->curs?>, |
| 55 | 'grau': <?=(int)$user->grau?> |
Andreu | ed49167 | 2019-09-20 13:09:18 +0200 | [diff] [blame] | 56 | }; |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 57 | </script> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 58 | |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 59 | </head> |
| 60 | <body> |
| 61 | <div id="outter-container"> |
| 62 | <div id="inner-container"> |
Adrià Vilanova Martínez | 163f5aa | 2022-11-20 01:17:20 +0100 | [diff] [blame] | 63 | <a href="/php/logout.php" class="goback">Tancar sessió</a><br /> |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 64 | <h2>Hola <name id="user_name"><?=Security::htmlsafe($user->nom())?></name>,</h2> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 65 | |
Andreu | 4b2fbd9 | 2019-09-22 22:30:25 +0200 | [diff] [blame] | 66 | <div class="formulari_contrasenya"> |
Andreu | a0fc827 | 2019-09-23 00:35:25 +0200 | [diff] [blame] | 67 | <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] | 68 | <form action="./php/change_password.php" method="POST"> |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 69 | <input type="hidden" value="<?=(int)$user->id?>" name="userid"> |
Andreu | 543e70c | 2019-09-22 14:08:49 +0200 | [diff] [blame] | 70 | <input type="password" placeholder="Nova clau d'accés..." name="password" /><br /> |
| 71 | <input type="password" placeholder="Repeteix la clau d'accés" name="confirmation"/><br /> |
Andreu | 4b2fbd9 | 2019-09-22 22:30:25 +0200 | [diff] [blame] | 72 | <input type="submit" value="Posar clau d'accés"> |
Andreu | 20cbd1d | 2019-09-22 00:00:57 +0200 | [diff] [blame] | 73 | </form> |
| 74 | </div> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 75 | |
Adrià Vilanova Martínez | c4ced6d | 2022-12-22 19:37:32 +0100 | [diff] [blame] | 76 | <?php |
| 77 | if (!Credentials::isAllVsAllModeEnabled()) { |
| 78 | $victim = get_users($user->quimata); |
| 79 | ?> |
| 80 | <p>La teva víctima és:</p> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 81 | |
Adrià Vilanova Martínez | c4ced6d | 2022-12-22 19:37:32 +0100 | [diff] [blame] | 82 | <div class="victima"> |
| 83 | <table> |
| 84 | <tr> |
| 85 | <?php |
| 86 | // @TODO: Reenable photos |
| 87 | /* |
| 88 | <td class="table_img"> |
| 89 | <div id="victim_img"> |
| 90 | <div class="grid-container"> |
| 91 | <div class="grid-item <?=(int)$bits[$bit_counter++] ? 'black' : ''?>"></div> |
| 92 | <div class="grid-item <?=(int)$bits[$bit_counter++] ? 'black' : ''?>"></div> |
| 93 | <div class="grid-item <?=(int)$bits[$bit_counter++] ? 'black' : ''?>"></div> |
| 94 | <div class="grid-item <?=(int)$bits[$bit_counter++] ? 'black' : ''?>"></div> |
| 95 | <div class="grid-item <?=(int)$bits[$bit_counter++] ? 'black' : ''?>"></div> |
| 96 | <div class="grid-item <?=(int)$bits[$bit_counter++] ? 'black' : ''?>"></div> |
| 97 | <div class="grid-item <?=(int)$bits[$bit_counter++] ? 'black' : ''?>"></div> |
| 98 | <div class="grid-item <?=(int)$bits[$bit_counter++] ? 'black' : ''?>"></div> |
| 99 | <div class="grid-item <?=(int)$bits[$bit_counter++] ? 'black' : ''?>"></div> |
| 100 | </div> |
Andreu Huguet | f133417 | 2020-09-15 17:29:22 +0200 | [diff] [blame] | 101 | </div> |
Adrià Vilanova Martínez | c4ced6d | 2022-12-22 19:37:32 +0100 | [diff] [blame] | 102 | </td> |
| 103 | */ |
| 104 | ?> |
| 105 | <td class="table_text"> |
| 106 | <div id="victim_name"><?=Security::htmlsafe($victim->nomcomplet)?></div> |
| 107 | <div id="victim_curs_i_grau"> |
| 108 | <span id="victim_curs"><?=Security::htmlsafe($victim->nomcurs())?></span> |
| 109 | - |
| 110 | <span id="victim_grau"><?=Security::htmlsafe($victim->nomgrau())?></span> |
| 111 | </div> |
| 112 | <div id="butons" class="options"> |
| 113 | <button id="win" onclick="js: send_request(user, 'REQ KILL');">L'he matat</button> |
| 114 | </div> |
| 115 | </td> |
| 116 | </tr> |
| 117 | </table> |
| 118 | </div> |
| 119 | |
| 120 | <?php |
| 121 | $query_seen_victim = "SELECT COUNT(*) FROM missatges WHERE `seen` = 0 AND (`receiver_id` = " . (int)$user->id . " AND `sender_id` = " . (int)$user->quimata . ")"; |
| 122 | $query_seen_killer = "SELECT COUNT(*) FROM missatges WHERE `seen` = 0 AND (`receiver_id` = " . (int)$user->id . " AND `sender_id` != " . (int)$user->quimata . ")"; |
| 123 | ?> |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 124 | |
Adrià Vilanova Martínez | c4ced6d | 2022-12-22 19:37:32 +0100 | [diff] [blame] | 125 | <div> |
| 126 | <p>Podeu posar aquesta pàgina com a icona apretant el botó de "Add to Home Screen" del vostre navegador.</p> |
| 127 | <a href="./ranking.php">Anar al rànquing</a><br /> |
| 128 | <a href="./victim-chat.php">Xatejar amb la teva víctima (<?= query($query_seen_victim)->fetch_row()[0] ?>)</a><br /> |
| 129 | <a href="./killer-chat.php">Xatejar amb el teu assassí (<?= query($query_seen_killer)->fetch_row()[0] ?>)</a> |
| 130 | </div> |
| 131 | <?php |
| 132 | } else { |
| 133 | ?> |
| 134 | <p>Tots contra tots! Ara pots matar a qualsevol persona que continuï viva (les de la següent llista).</p> |
| 135 | <p>Quan matis alguna persona, selecciona-la i fes clic al botó "L'he assassinat/da".</p> |
| 136 | <form action="php/request.php" method="POST" onsubmit="return confirm('Estàs segura que has assassinat aquesta persona? Per agilitzar el procediment l\'altra persona no haurà de confirmar la mort i obtindràs els punts directament.\n\nL\'ús inadecuat comportarà una penalització.');"> |
| 137 | <?php |
| 138 | $users = get_users(); |
| 139 | foreach ($users as $user) { |
| 140 | if ($user->mort) continue; |
| 141 | ?> |
| 142 | <p><input type="radio" name="mort" value="<?=(int)$user->id?>" required<?=$user->id == $_SESSION['id'] ? ' disabled' : ''?>> <?=Security::htmlsafe($user->nomcomplet)?> - <?=Security::htmlsafe($user->nomcurs())?> - <?=Security::htmlsafe($user->nomgrau())?></p> |
| 143 | <?php |
| 144 | } |
| 145 | ?> |
| 146 | <input type="hidden" name="msg" value="INSTAKILL"> |
| 147 | <button>L'he assassinat/da</button> |
| 148 | <?php |
| 149 | } |
| 150 | ?> |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 151 | </div> |
| 152 | </div> |
avm99963 | db383ed | 2019-09-22 02:14:42 +0200 | [diff] [blame] | 153 | |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 154 | <script> |
Andreu | dca79f4 | 2019-09-18 23:53:19 +0200 | [diff] [blame] | 155 | $(document).ready(function() { |
Andreu | abbcb7e | 2019-09-21 18:22:14 +0200 | [diff] [blame] | 156 | // Set interval of checking |
Adrià Vilanova Martínez | 67727cd | 2022-11-20 01:31:53 +0100 | [diff] [blame] | 157 | update_info(user); |
Adrià Vilanova Martínez | c4ced6d | 2022-12-22 19:37:32 +0100 | [diff] [blame] | 158 | |
Andreu | 96f1bcd | 2019-09-22 00:33:09 +0200 | [diff] [blame] | 159 | // Set to hidden or not the password prompt |
Andreu | 543e70c | 2019-09-22 14:08:49 +0200 | [diff] [blame] | 160 | if (<?=$user->md5password=="" ? 1 : 0?>) { |
| 161 | $.notify("No tens clau d'accés", "info"); |
| 162 | $(".formulari_contrasenya").show(); |
| 163 | } |
Andreu | 03d030d | 2019-09-25 21:52:01 +0200 | [diff] [blame] | 164 | // Notify of messages |
| 165 | if (getUrlParameter("wrongconfirmation")) read_message("Les contrasenyes no coincideixen", "error"); |
| 166 | if (getUrlParameter("errordb")) read_message("Hi ha hagut un problema a la base de dades, torna-ho a intentar", "error"); |
| 167 | if (getUrlParameter("successpassword")) read_message("La teva clau d'accés s'ha guardat", "success"); |
Adrià Vilanova Martínez | c4ced6d | 2022-12-22 19:37:32 +0100 | [diff] [blame] | 168 | if (getUrlParameter("killsuccess")) read_message("La mort s'ha guardat correctament", "success"); |
Andreu | dca79f4 | 2019-09-18 23:53:19 +0200 | [diff] [blame] | 169 | }); |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 170 | </script> |
| 171 | </body> |
| 172 | </html> |