Deny requests
diff --git a/js/utils.js b/js/utils.js
index 8c436fd..5886883 100644
--- a/js/utils.js
+++ b/js/utils.js
@@ -11,9 +11,7 @@
'type': 'GET',
'dataType': 'json',
'data': { 'id': id, 'msg': msg },
- 'success': function(data) { alert("S'ha avisat a l'altre jugador"); },
- 'error': function(xhr, status, error) {
- alert(xhr.responseText);
- }
+ 'success': function(data) { console.log('Success'); },
+ 'error': function(xhr, status, error) {}
});
}
diff --git a/main.php b/main.php
index 4dd8d4a..bd0cedb 100644
--- a/main.php
+++ b/main.php
@@ -10,14 +10,16 @@
<?php require 'login.php'; ?>
<script>
- if (<?=$user->mort?>) alert("Venga niño, pitjor que el Condom, MORT.");
+ if (<?=$user->mort?>) document.write("Venga niño, pitjor que el Condom, MORT.");
else {
let dead = false
let killed = false
if(<?=$user->requested?> == 1) dead = confirm("El teu assassí ha dit que t'ha matat, és veritat?");
if(<?=$user->requested?> == 2) killed = confirm("En/na <?=$victim->nom()?> ha dit que l'has matat, és veritat?");
- if (dead) send_request(<?=$user->id?>, 3);
- if (killed) send_request(<?=$victim->id?>, 4);
+ if (dead) send_request(<?=$user->id?>, 3); // confirm death
+ else send_request(<?=$user->id?>, 5); // deny death
+ if (killed) send_request(<?=$victim->id?>, 4); // confirm kill
+ else send_request(<?=$user->id?>, 5); // deny kill
}
</script>
</head>
diff --git a/request.php b/request.php
index 39fa91c..a26e445 100644
--- a/request.php
+++ b/request.php
@@ -15,14 +15,11 @@
if ($_GET['msg'] == 2) $query = "UPDATE users SET requested=".$_GET['msg']." WHERE quimata=".$_GET['id']; // request dead
if ($_GET['msg'] == 3) $query = "UPDATE users SET mort=1 WHERE id=".$_GET['id']; // confirm dead
if ($_GET['msg'] == 4) $query = "UPDATE users SET mort=1 WHERE quimata=".$_GET['id']; // confirm killed
+ if ($_GET['msg'] == 5) $query = "UPDATE users SET requested=0 WHERE id=".$_GET['id']; // deny request
// Fetch the information of the user
- if ($result = $conn->query($query)) {
- echo 'Success!';
- // $result->close();
- } else {
- die("Wrong query: " . $query);
- }
+ if ($result = $conn->query($query)) echo 'Success!';
+ else die("Wrong query: " . $query);
// Close connection
$conn->close();