Generalization of the dbname
diff --git a/php/change_password.php b/php/change_password.php
index d02f389..d8bcc19 100644
--- a/php/change_password.php
+++ b/php/change_password.php
@@ -2,12 +2,16 @@
require '../credentials.php';
require 'utils.php';
+ $credentials = new Credentials();
+ $usersdb = $credentials->usersdb;
+ $mortsdb = $credentials->mortsdb;
+
// Check if confirmation is the same
if ($_POST['password'] != $_POST['confirmation']) {
die("<script>window.location.href = '../index.php?wrongconfirmation=1'</script>");
} else {
// Execute query to change password
- $update_password = "UPDATE users SET password=\"".md5($_POST['password'])."\" WHERE id=".$_POST['userid'];
+ $update_password = "UPDATE $usersdb SET password=\"".md5($_POST['password'])."\" WHERE id=".$_POST['userid'];
if(!$result = query($update_password)) die("<script>window.location.href = '../index.php?errordb=1'</script>");
// Save 'password' to cookies
diff --git a/php/login.php b/php/login.php
index abaac74..45575e3 100644
--- a/php/login.php
+++ b/php/login.php
@@ -1,7 +1,11 @@
<?php
require '../credentials.php';
require 'utils.php';
-
+
+ $credentials = new Credentials();
+ $usersdb = $credentials->usersdb;
+ $mortsdb = $credentials->mortsdb;
+
// Set the 'user' POST and COOKIE variable
$user = '';
if (isset($_POST['user'])) $user = $_POST['user'];
@@ -11,7 +15,7 @@
}
// Check if password is correct
- $query_password = "SELECT password FROM users WHERE id=".$user;
+ $query_password = "SELECT password FROM $usersdb WHERE id=".$user;
$real_password = query($query_password)->fetch_row()[0];
// Prioritize input rather than memory
diff --git a/php/request.php b/php/request.php
index 845cdb1..ac2c8cf 100644
--- a/php/request.php
+++ b/php/request.php
@@ -2,17 +2,21 @@
require '../credentials.php';
require 'utils.php';
+ $credentials = new Credentials();
+ $usersdb = $credentials->usersdb;
+ $mortsdb = $credentials->mortsdb;
+
// Do the query
$queries = [""];
- $victimid = "ANY (SELECT quimata FROM (SELECT * FROM users) AS victims WHERE id=".(int)$_POST['user_id'].")";
+ $victimid = "ANY (SELECT quimata FROM (SELECT * FROM $usersdb) AS victims WHERE id=".(int)$_POST['user_id'].")";
- if ($_POST['msg'] == "REQ KILL") $queries = ["UPDATE users SET requested=1 WHERE id=".$victimid]; // request kill
- if ($_POST['msg'] == "REQ DEAD") $queries = ["UPDATE users SET requested=2 WHERE quimata=".(int)$_POST['user_id']]; // request dead
- if ($_POST['msg'] == "DENY REQ") $queries = ["UPDATE users SET requested=0 WHERE id=".(int)$_POST['user_id']]; // deny request
+ if ($_POST['msg'] == "REQ KILL") $queries = ["UPDATE $usersdb SET requested=1 WHERE id=".$victimid]; // request kill
+ if ($_POST['msg'] == "REQ DEAD") $queries = ["UPDATE $usersdb SET requested=2 WHERE quimata=".(int)$_POST['user_id']]; // request dead
+ if ($_POST['msg'] == "DENY REQ") $queries = ["UPDATE $usersdb SET requested=0 WHERE id=".(int)$_POST['user_id']]; // deny request
if ($_POST['msg'] == "CONF DEAD") {
- $queries = ["INSERT INTO morts (id, quimatava, assassi, curs, grau) (SELECT id, quimata, (SELECT id FROM users WHERE quimata=".(int)$_POST['user_id']."), curs, grau FROM users WHERE id=".(int)$_POST['user_id'].")", // add to 'morts'
- "UPDATE users SET requested=0, quimata=".(int)$_POST['user_quimata'].", bits=".(int)rand(1,512)." WHERE quimata=".(int)$_POST['user_id'], // assign new victim to killer
- "UPDATE users SET quimata=0, mort=1 WHERE id=".(int)$_POST['user_id']]; // confirm victim dead/killed
+ $queries = ["INSERT INTO $mortsdb (id, quimatava, assassi, curs, grau) (SELECT id, quimata, (SELECT id FROM $usersdb WHERE quimata=".(int)$_POST['user_id']."), curs, grau FROM $usersdb WHERE id=".(int)$_POST['user_id'].")", // add to 'morts'
+ "UPDATE $usersdb SET requested=0, quimata=".(int)$_POST['user_quimata'].", bits=".(int)rand(1,512)." WHERE quimata=".(int)$_POST['user_id'], // assign new victim to killer
+ "UPDATE $usersdb SET quimata=0, mort=1 WHERE id=".(int)$_POST['user_id']]; // confirm victim dead/killed
}
// Fetch the information of the user
foreach ($queries as $query) {
diff --git a/php/utils.php b/php/utils.php
index abd519e..49ccbb7 100644
--- a/php/utils.php
+++ b/php/utils.php
@@ -1,4 +1,5 @@
<?php
+
function nomcurs($curs) {
if ($curs == 1) return "1r";
if ($curs == 2) return "2n";
@@ -53,8 +54,12 @@
function get_users($id = 0, $getAsObjects = true) {
$users = [];
+ $credentials = new Credentials();
+ $usersdb = $credentials->usersdb;
+ $mortsdb = $credentials->mortsdb;
+
// Prepare the query
- $query = "SELECT * FROM users";
+ $query = "SELECT * FROM $usersdb";
if ($id > 0) $query .= " WHERE id=".$id;
// Fetch the information of the user