Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 1 | <?php |
| 2 | // Define MySQL login variables |
Andreu | ed8e1f9 | 2019-09-18 22:26:04 +0200 | [diff] [blame] | 3 | $servername = "localhost"; // "fdb22.awardspace.net"; |
| 4 | $username = "root"; // "3155560_users"; |
| 5 | $password = ""; // "btechnoro@fox4news.info"; |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 6 | |
| 7 | // Create connection |
Andreu | ed8e1f9 | 2019-09-18 22:26:04 +0200 | [diff] [blame] | 8 | $conn = new mysqli($servername, $username, $password, "pastanaga"); |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 9 | if ($conn->connect_error) die("Connection failed: " . $conn->connect_error); |
| 10 | $conn->set_charset("utf8"); |
| 11 | |
| 12 | // Do the query |
Andreu | efe66eb | 2019-09-21 18:41:49 +0200 | [diff] [blame^] | 13 | $queries = [""]; |
Andreu | abbcb7e | 2019-09-21 18:22:14 +0200 | [diff] [blame] | 14 | |
| 15 | $victimid = "ANY (SELECT quimata FROM users WHERE id=".(int)$_GET['user_id'].")"; |
| 16 | |
Andreu | efe66eb | 2019-09-21 18:41:49 +0200 | [diff] [blame^] | 17 | if ($_GET['msg'] == "REQ KILL") $queries = ["UPDATE users SET requested=1 WHERE id=".$victimid]; // request kill |
| 18 | if ($_GET['msg'] == "REQ DEAD") $queries = ["UPDATE users SET requested=2 WHERE quimata=".(int)$_GET['user_id']]; // request dead |
| 19 | if ($_GET['msg'] == "DENY REQ") $queries = ["UPDATE users SET requested=0 WHERE id=".(int)$_GET['user_id']]; // deny request |
Andreu | ed49167 | 2019-09-20 13:09:18 +0200 | [diff] [blame] | 20 | if ($_GET['msg'] == "CONF DEAD") { |
Andreu | efe66eb | 2019-09-21 18:41:49 +0200 | [diff] [blame^] | 21 | $queries = ["UPDATE users SET requested=0, quimata=".(int)$_GET['user_quimata']." WHERE quimata=".(int)$_GET['user_id'], // assign new victim to killer |
| 22 | "UPDATE users SET quimata=0, mort=1 WHERE id=".(int)$_GET['user_id']]; // confirm victim dead/killed |
Andreu | 885889c | 2019-09-19 00:28:20 +0200 | [diff] [blame] | 23 | } |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 24 | // Fetch the information of the user |
Andreu | efe66eb | 2019-09-21 18:41:49 +0200 | [diff] [blame^] | 25 | foreach ($queries as $query) { |
| 26 | if ($query != "" and $result = $conn->query($query)) echo $query; |
| 27 | else die("Wrong query: " . $query); |
| 28 | } |
| 29 | |
Andreu | 66ad5cf | 2019-09-18 17:15:44 +0200 | [diff] [blame] | 30 | // Close connection |
| 31 | $conn->close(); |
| 32 | ?> |