blob: f010b36eb08e4712cd6f105689b9005b1d48be52 [file] [log] [blame]
Andreu66ad5cf2019-09-18 17:15:44 +02001<?php
2 // Define MySQL login variables
Andreu09b8b052019-09-21 21:47:20 +02003 $servername = "localhost"; // "andreuhuguet78654.ipagemysql.com";
4 $username = "root"; // "andreu";
5 $password = ""; // "1234";
6 $dbname = "pastanaga"; // "fme_2019";
Andreu66ad5cf2019-09-18 17:15:44 +02007
8 // Create connection
Andreu09b8b052019-09-21 21:47:20 +02009 $conn = new mysqli($servername, $username, $password, $dbname);
Andreu66ad5cf2019-09-18 17:15:44 +020010 if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
11 $conn->set_charset("utf8");
12
13 // Do the query
Andreuefe66eb2019-09-21 18:41:49 +020014 $queries = [""];
Andreuabbcb7e2019-09-21 18:22:14 +020015
Andreu09b8b052019-09-21 21:47:20 +020016 $victimid = "ANY (SELECT quimata FROM users WHERE id=".(int)$_POST['user_id'].")";
Andreuabbcb7e2019-09-21 18:22:14 +020017
Andreu09b8b052019-09-21 21:47:20 +020018 if ($_POST['msg'] == "REQ KILL") $queries = ["UPDATE users SET requested=1 WHERE id=".$victimid]; // request kill
19 if ($_POST['msg'] == "REQ DEAD") $queries = ["UPDATE users SET requested=2 WHERE quimata=".(int)$_POST['user_id']]; // request dead
20 if ($_POST['msg'] == "DENY REQ") $queries = ["UPDATE users SET requested=0 WHERE id=".(int)$_POST['user_id']]; // deny request
21 if ($_POST['msg'] == "CONF DEAD") {
22 $queries = ["UPDATE users SET requested=0, quimata=".(int)$_POST['user_quimata']." WHERE quimata=".(int)$_POST['user_id'], // assign new victim to killer
23 "UPDATE users SET quimata=0, mort=1 WHERE id=".(int)$_POST['user_id']]; // confirm victim dead/killed
Andreu885889c2019-09-19 00:28:20 +020024 }
Andreu66ad5cf2019-09-18 17:15:44 +020025 // Fetch the information of the user
Andreuefe66eb2019-09-21 18:41:49 +020026 foreach ($queries as $query) {
27 if ($query != "" and $result = $conn->query($query)) echo $query;
28 else die("Wrong query: " . $query);
29 }
30
Andreu66ad5cf2019-09-18 17:15:44 +020031 // Close connection
32 $conn->close();
33?>