blob: 6197cae0bff50c26fc7a3efe4950c3de17512386 [file] [log] [blame]
Andreu78e5bb02019-09-22 13:38:04 +02001<?php
2 require './credentials.php';
3 require './php/utils.php';
Andreu0d0f9fd2019-09-23 03:56:08 +02004
Andreua0fc8272019-09-23 00:35:25 +02005 $user = (int)$_POST['user'];
Andreu0d0f9fd2019-09-23 03:56:08 +02006 $password = isset($_POST['password']) ? md5($_POST['password']) : '';
Andreu4b2fbd92019-09-22 22:30:25 +02007
Andreua0fc8272019-09-23 00:35:25 +02008 // Check if password is correct
9 $query_password = "SELECT password FROM users WHERE id=".$user;
10 $real_password = query($query_password)->fetch_row()[0];
11 if ($real_password != $password) die("<script>window.location.href = './index.php?wrongpassword=1'</script>");
12
Andreu0d0f9fd2019-09-23 03:56:08 +020013 if (!isset($_POST['user']) or $_POST['user'] == '') {
Andreu4b2fbd92019-09-22 22:30:25 +020014 die("<script>window.location.href = './index.php'</script>");
Andreua0fc8272019-09-23 00:35:25 +020015 } else if (isset($_POST['password'])) {
16 $query_password = "SELECT password FROM users WHERE id=$user";
17 if (query($query_password)->fetch_row()[0] != $password) {
Andreu78e5bb02019-09-22 13:38:04 +020018 // Unset variables
19 setcookie('user', '', -1, "/");
20 setcookie('password', '', -1, "/");
21
Andreu4b2fbd92019-09-22 22:30:25 +020022 die("<script>window.location.href = './index.php?passwordchanged=1'</script>");
Andreu78e5bb02019-09-22 13:38:04 +020023 }
Andreu09b8b052019-09-21 21:47:20 +020024 }
25?>
Andreu66ad5cf2019-09-18 17:15:44 +020026<html>
27 <head>
28 <meta charset="UTF-8">
Andreu0d0f9fd2019-09-23 03:56:08 +020029 <title>PastanagAPP</title>
avm99963db383ed2019-09-22 02:14:42 +020030
31 <meta name="viewport" content="width=device-width, initial-scale=1">
Andreu0d0f9fd2019-09-23 03:56:08 +020032 <link rel="manifest" href="https://api.myjson.com/bins/u6r41">
33
34 <!-- Apple web app -->
35 <link rel="apple-touch-icon" href="./bin/images/icons/icon-72x72.png">
36 <meta name="apple-mobile-web-app-title" content="PastanagAPP">
37 <meta name="apple-mobile-web-app-capable" content="yes">
38 <meta name="apple-mobile-web-app-status-bar-style" content="green">
39
avm99963db383ed2019-09-22 02:14:42 +020040
Andreu4b2fbd92019-09-22 22:30:25 +020041 <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans" />
42
Andreu66ad5cf2019-09-18 17:15:44 +020043 <link rel="stylesheet" href="./css/basic.css" />
44 <link rel="stylesheet" href="./css/main.css" />
avm99963db383ed2019-09-22 02:14:42 +020045
Andreu66ad5cf2019-09-18 17:15:44 +020046 <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
Andreued8e1f92019-09-18 22:26:04 +020047 <script src="https://rawgit.com/notifyjs/notifyjs/master/dist/notify.js"></script>
avm99963db383ed2019-09-22 02:14:42 +020048
Andreu10cb3042019-09-18 19:55:36 +020049 <script src="./js/utils.js"></script>
Andreuefe66eb2019-09-21 18:41:49 +020050 <script src="./js/animations.js"></script>
avm99963db383ed2019-09-22 02:14:42 +020051
52 <?php
Andreua0fc8272019-09-23 00:35:25 +020053 $user = get_users($user);
Andreu09b8b052019-09-21 21:47:20 +020054 $victim = get_users($user->quimata);
Andreu0530b302019-09-24 04:18:20 +020055 if ($user->mort) die("<script>window.location.href = './dead.php'</script>");
Andreu779c3b72019-09-24 03:14:35 +020056
57 $bits = dec2bits($user->bits);
58 $bit_counter = 0;
Andreudca79f42019-09-18 23:53:19 +020059 ?>
avm99963db383ed2019-09-22 02:14:42 +020060
Andreu66ad5cf2019-09-18 17:15:44 +020061 <script>
Andreued491672019-09-20 13:09:18 +020062 let user = {
Andreu99501052019-09-22 20:09:08 +020063 'id': <?=(int)$user->id?>,
64 'quimata': <?=(int)$user->quimata?>,
65 'requested': <?=(int)$user->requested?>,
66 'mort': <?=(int)$user->mort?>,
avm99963db383ed2019-09-22 02:14:42 +020067
Andreuabbcb7e2019-09-21 18:22:14 +020068 'nom': "<?=$user->nomcomplet?>",
Andreu99501052019-09-22 20:09:08 +020069 'curs': <?=(int)$user->curs?>,
70 'grau': <?=(int)$user->grau?>
Andreued491672019-09-20 13:09:18 +020071 };
Andreu66ad5cf2019-09-18 17:15:44 +020072 </script>
avm99963db383ed2019-09-22 02:14:42 +020073
Andreu66ad5cf2019-09-18 17:15:44 +020074 </head>
75 <body>
76 <div id="outter-container">
77 <div id="inner-container">
Andreu0d0f9fd2019-09-23 03:56:08 +020078 <a href="./index.php" class="goback">Torna a la pàgina principal</a><br />
Andreu66ad5cf2019-09-18 17:15:44 +020079 <h2>Hola <name id="user_name"><?=$user->nom()?></name>,</h2>
avm99963db383ed2019-09-22 02:14:42 +020080
Andreu4b2fbd92019-09-22 22:30:25 +020081 <div class="formulari_contrasenya">
Andreua0fc8272019-09-23 00:35:25 +020082 <p>Sembla que no tens clau d'accés, la gent podrà entrar al teu compte...</p>
Andreu20cbd1d2019-09-22 00:00:57 +020083 <form action="./php/change_password.php" method="POST">
Andreua0fc8272019-09-23 00:35:25 +020084 <input type="hidden" value="<?=(int)$_POST['user']?>" name="userid">
Andreu543e70c2019-09-22 14:08:49 +020085 <input type="password" placeholder="Nova clau d'accés..." name="password" /><br />
86 <input type="password" placeholder="Repeteix la clau d'accés" name="confirmation"/><br />
Andreu4b2fbd92019-09-22 22:30:25 +020087 <input type="submit" value="Posar clau d'accés">
Andreu20cbd1d2019-09-22 00:00:57 +020088 </form>
89 </div>
avm99963db383ed2019-09-22 02:14:42 +020090
91 <p>La teva víctima és:</p>
92
Andreu04f79ef2019-09-22 18:52:19 +020093 <div class="victima">
94 <table>
95 <tr>
Andreu779c3b72019-09-24 03:14:35 +020096 <td class="table_img">
97 <div id="victim_img">
98 <table cellspacing="0" cellpadding="0">
99 <tr>
100 <td><img src="./bin/images/imgs/<?=$victim->id?>/slice_01_01.png" width="33" class="<?=(int)$bits[$bit_counter++] ? 'black' : ''?>" /></td>
101 <td><img src="./bin/images/imgs/<?=$victim->id?>/slice_01_02.png" width="33" class="<?=(int)$bits[$bit_counter++] ? 'black' : ''?>" /></td>
102 <td><img src="./bin/images/imgs/<?=$victim->id?>/slice_01_03.png" width="33" class="<?=(int)$bits[$bit_counter++] ? 'black' : ''?>" /></td>
103 </tr>
104 <tr>
105 <td><img src="./bin/images/imgs/<?=$victim->id?>/slice_02_01.png" width="33" class="<?=(int)$bits[$bit_counter++] ? 'black' : ''?>" /></td>
106 <td><img src="./bin/images/imgs/<?=$victim->id?>/slice_02_02.png" width="33" class="<?=(int)$bits[$bit_counter++] ? 'black' : ''?>" /></td>
107 <td><img src="./bin/images/imgs/<?=$victim->id?>/slice_02_03.png" width="33" class="<?=(int)$bits[$bit_counter++] ? 'black' : ''?>" /></td>
108 </tr>
109 <tr>
110 <td><img src="./bin/images/imgs/<?=$victim->id?>/slice_03_01.png" width="33" class="<?=(int)$bits[$bit_counter++] ? 'black' : ''?>" /></td>
111 <td><img src="./bin/images/imgs/<?=$victim->id?>/slice_03_02.png" width="33" class="<?=(int)$bits[$bit_counter++] ? 'black' : ''?>" /></td>
112 <td><img src="./bin/images/imgs/<?=$victim->id?>/slice_03_03.png" width="33" class="<?=(int)$bits[$bit_counter++] ? 'black' : ''?>" /></td>
113 </tr>
114 </table>
115 </div>
116 </td>
Andreu0d0f9fd2019-09-23 03:56:08 +0200117 <td class="table_text">
Andreu04f79ef2019-09-22 18:52:19 +0200118 <div id="victim_name"><?=$victim->nomcomplet?></div>
119 <div id="victim_curs_i_grau">
Andreu4b2fbd92019-09-22 22:30:25 +0200120 <span id="victim_curs"><?=$victim->nomcurs()?></span>
Andreu04f79ef2019-09-22 18:52:19 +0200121 -
Andreu4b2fbd92019-09-22 22:30:25 +0200122 <span id="victim_grau"><?=$victim->nomgrau()?></span>
Andreu04f79ef2019-09-22 18:52:19 +0200123 </div>
124 <div id="butons" class="options">
125 <button id="win" onclick="js: send_request(user, 'REQ KILL');">L'he matat</button>
126 </div>
127 </td>
128 </tr>
129 </table>
130 </div>
avm99963db383ed2019-09-22 02:14:42 +0200131
132 <div style="clear: both;"></div>
Andreu66ad5cf2019-09-18 17:15:44 +0200133 </div>
134 </div>
avm99963db383ed2019-09-22 02:14:42 +0200135
Andreu66ad5cf2019-09-18 17:15:44 +0200136 <script>
Andreudca79f42019-09-18 23:53:19 +0200137 $(document).ready(function() {
Andreuabbcb7e2019-09-21 18:22:14 +0200138 // Set interval of checking
Andreuefe66eb2019-09-21 18:41:49 +0200139 let checking = setInterval(function() { update_info(user); }, 1500);
Andreu96f1bcd2019-09-22 00:33:09 +0200140 // Set to hidden or not the password prompt
Andreu543e70c2019-09-22 14:08:49 +0200141 if (<?=$user->md5password=="" ? 1 : 0?>) {
142 $.notify("No tens clau d'accés", "info");
143 $(".formulari_contrasenya").show();
144 }
Andreudca79f42019-09-18 23:53:19 +0200145 });
Andreu66ad5cf2019-09-18 17:15:44 +0200146 </script>
147 </body>
148</html>