blob: d5a2729af59f59eed4d0f3ede59017eac0b5e071 [file] [log] [blame]
Andreu78e5bb02019-09-22 13:38:04 +02001<?php
2 require './credentials.php';
3 require './php/utils.php';
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +01004 require_once('./php/security.php');
Andreu20af6c22019-09-24 18:33:50 +02005
Adrià Vilanova Martínezd3394e12022-11-19 15:45:58 +01006 date_default_timezone_set("Europe/Madrid");
Andreu03d030d2019-09-25 21:52:01 +02007
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +01008 Security::checkIsSignedIn();
Andreu09b8b052019-09-21 21:47:20 +02009?>
Andreu66ad5cf2019-09-18 17:15:44 +020010<html>
11 <head>
12 <meta charset="UTF-8">
Andreu0d0f9fd2019-09-23 03:56:08 +020013 <title>PastanagAPP</title>
avm99963db383ed2019-09-22 02:14:42 +020014
15 <meta name="viewport" content="width=device-width, initial-scale=1">
Adrià Vilanova Martínez71e9f872022-11-20 01:54:50 +010016 <link rel="manifest" href="/bin/manifest.json">
Andreu0d0f9fd2019-09-23 03:56:08 +020017
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ínezdc7fbb62022-12-11 16:28:44 +010024 <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">
Andreu4b2fbd92019-09-22 22:30:25 +020027
Andreu66ad5cf2019-09-18 17:15:44 +020028 <link rel="stylesheet" href="./css/basic.css" />
29 <link rel="stylesheet" href="./css/main.css" />
avm99963db383ed2019-09-22 02:14:42 +020030
Andreu66ad5cf2019-09-18 17:15:44 +020031 <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
Andreued8e1f92019-09-18 22:26:04 +020032 <script src="https://rawgit.com/notifyjs/notifyjs/master/dist/notify.js"></script>
avm99963db383ed2019-09-22 02:14:42 +020033
Andreu10cb3042019-09-18 19:55:36 +020034 <script src="./js/utils.js"></script>
Andreuefe66eb2019-09-21 18:41:49 +020035 <script src="./js/animations.js"></script>
avm99963db383ed2019-09-22 02:14:42 +020036
37 <?php
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010038 $user = get_users($_SESSION["id"]);
Andreu0530b302019-09-24 04:18:20 +020039 if ($user->mort) die("<script>window.location.href = './dead.php'</script>");
Adrià Vilanova Martínez7b206bb2022-12-10 17:29:52 +010040
41 // @TODO: Reenable photos
42 /*$bits = dec2bits($user->bits);
43 $bit_counter = 0;*/
Andreudca79f42019-09-18 23:53:19 +020044 ?>
avm99963db383ed2019-09-22 02:14:42 +020045
Andreu66ad5cf2019-09-18 17:15:44 +020046 <script>
Andreued491672019-09-20 13:09:18 +020047 let user = {
Andreu99501052019-09-22 20:09:08 +020048 'id': <?=(int)$user->id?>,
49 'quimata': <?=(int)$user->quimata?>,
50 'requested': <?=(int)$user->requested?>,
51 'mort': <?=(int)$user->mort?>,
avm99963db383ed2019-09-22 02:14:42 +020052
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010053 'nom': "<?=Security::htmlsafe($user->nomcomplet)?>",
Andreu99501052019-09-22 20:09:08 +020054 'curs': <?=(int)$user->curs?>,
55 'grau': <?=(int)$user->grau?>
Andreued491672019-09-20 13:09:18 +020056 };
Andreu66ad5cf2019-09-18 17:15:44 +020057 </script>
avm99963db383ed2019-09-22 02:14:42 +020058
Andreu66ad5cf2019-09-18 17:15:44 +020059 </head>
60 <body>
61 <div id="outter-container">
62 <div id="inner-container">
Adrià Vilanova Martínez163f5aa2022-11-20 01:17:20 +010063 <a href="/php/logout.php" class="goback">Tancar sessió</a><br />
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010064 <h2>Hola <name id="user_name"><?=Security::htmlsafe($user->nom())?></name>,</h2>
avm99963db383ed2019-09-22 02:14:42 +020065
Andreu4b2fbd92019-09-22 22:30:25 +020066 <div class="formulari_contrasenya">
Andreua0fc8272019-09-23 00:35:25 +020067 <p>Sembla que no tens clau d'accés, la gent podrà entrar al teu compte...</p>
Andreu20cbd1d2019-09-22 00:00:57 +020068 <form action="./php/change_password.php" method="POST">
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010069 <input type="hidden" value="<?=(int)$user->id?>" name="userid">
Andreu543e70c2019-09-22 14:08:49 +020070 <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 />
Andreu4b2fbd92019-09-22 22:30:25 +020072 <input type="submit" value="Posar clau d'accés">
Andreu20cbd1d2019-09-22 00:00:57 +020073 </form>
74 </div>
avm99963db383ed2019-09-22 02:14:42 +020075
Adrià Vilanova Martínezc4ced6d2022-12-22 19:37:32 +010076 <?php
77 if (!Credentials::isAllVsAllModeEnabled()) {
78 $victim = get_users($user->quimata);
79 ?>
80 <p>La teva víctima és:</p>
avm99963db383ed2019-09-22 02:14:42 +020081
Adrià Vilanova Martínezc4ced6d2022-12-22 19:37:32 +010082 <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 Huguetf1334172020-09-15 17:29:22 +0200101 </div>
Adrià Vilanova Martínezc4ced6d2022-12-22 19:37:32 +0100102 </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ínez13cf0cd2022-11-20 01:02:20 +0100124
Adrià Vilanova Martínezc4ced6d2022-12-22 19:37:32 +0100125 <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 ?>
Andreu66ad5cf2019-09-18 17:15:44 +0200151 </div>
152 </div>
avm99963db383ed2019-09-22 02:14:42 +0200153
Andreu66ad5cf2019-09-18 17:15:44 +0200154 <script>
Andreudca79f42019-09-18 23:53:19 +0200155 $(document).ready(function() {
Andreuabbcb7e2019-09-21 18:22:14 +0200156 // Set interval of checking
Adrià Vilanova Martínez67727cd2022-11-20 01:31:53 +0100157 update_info(user);
Adrià Vilanova Martínezc4ced6d2022-12-22 19:37:32 +0100158
Andreu96f1bcd2019-09-22 00:33:09 +0200159 // Set to hidden or not the password prompt
Andreu543e70c2019-09-22 14:08:49 +0200160 if (<?=$user->md5password=="" ? 1 : 0?>) {
161 $.notify("No tens clau d'accés", "info");
162 $(".formulari_contrasenya").show();
163 }
Andreu03d030d2019-09-25 21:52:01 +0200164 // 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ínezc4ced6d2022-12-22 19:37:32 +0100168 if (getUrlParameter("killsuccess")) read_message("La mort s'ha guardat correctament", "success");
Andreudca79f42019-09-18 23:53:19 +0200169 });
Andreu66ad5cf2019-09-18 17:15:44 +0200170 </script>
171 </body>
172</html>