diff --git a/admin/cheat.php b/admin/cheat.php
index 5bc8277..e37d934 100644
--- a/admin/cheat.php
+++ b/admin/cheat.php
@@ -6,9 +6,9 @@
include '../includes/db.php';
-$user = new UserController;
-$cheat = new CheatController;
-$admin = new AdminController;
+$user = new UserController();
+$cheat = new CheatController();
+$admin = new AdminController();
Session::init();
@@ -18,124 +18,121 @@
Util::head('Admin Panel');
Util::navbar();
-// if post request
+// if post request
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
-
-
- if (isset($_POST["cheatStatus"])) {
- $admin->setCheatStatus();
- $sql = "INSERT INTO `logs` (`log_user`, `log_action`, `log_time`) VALUES ('$username', 'Set cheat status to " . $_POST['cheatStatus'] . "', NOW())";
-
- $webhook = ADMIN_WEBHOOK;
- $embed = array(
- "title" => "Cheat Status",
- "description" => "$username has set the cheat status to " . $_POST['cheatStatus'],
- "color" => 0x00ff00
- );
- $data = array(
- "embeds" => array($embed)
- );
- $options = array(
- 'http' => array(
- 'header' => "Content-type: application/json\r\n",
- 'method' => 'POST',
- 'content' => json_encode($data)
- )
- );
- // send webhook
- $context = stream_context_create($options);
- $result = file_get_contents($webhook, false, $context);
-
- $result = $mysqli->query($sql);
- }
-
- if (isset($_POST["cheatMaint"])) {
- $admin->setCheatMaint();
- $sql = "INSERT INTO `logs` (`log_user`, `log_action`, `log_time`) VALUES ('$username', 'Set cheat maintenance to " . $_POST['cheatMaint'] . "', NOW())";
-
- $webhook = ADMIN_WEBHOOK;
- $embed = array(
- "title" => "Cheat Maintenance",
- "description" => "$username has set the cheat maintenance to " . $_POST['cheatMaint'],
- "color" => 0x00ff00
- );
- $data = array(
- "embeds" => array($embed)
- );
- $options = array(
- 'http' => array(
- 'header' => "Content-type: application/json\r\n",
- 'method' => 'POST',
- 'content' => json_encode($data)
- )
- );
- // send webhook
- $context = stream_context_create($options);
- $result = file_get_contents($webhook, false, $context);
- $result = $mysqli->query($sql);
- }
-
- if (isset($_POST["cheatVersion"])) {
- $ver = floatval($_POST['version']);
- $admin->setCheatVersion($ver);
- $sql = "INSERT INTO `logs` (`log_user`, `log_action`, `log_time`) VALUES ('$username', 'Set cheat version to " . $_POST['version'] . "', NOW())";
-
- $webhook = ADMIN_WEBHOOK;
- $embed = array(
- "title" => "Cheat Version",
- "description" => "$username has set the cheat version to " . $_POST['version'],
- "color" => 0x00ff00
- );
- $data = array(
- "embeds" => array($embed)
- );
- $options = array(
- 'http' => array(
- 'header' => "Content-type: application/json\r\n",
- 'method' => 'POST',
- 'content' => json_encode($data)
- )
- );
- // send webhook
- $context = stream_context_create($options);
- $result = file_get_contents($webhook, false, $context);
-
- $result = $mysqli->query($sql);
- }
-
- header("location: cheat");
-
+ if (isset($_POST["cheatStatus"])) {
+ $admin->setCheatStatus();
+ $sql = "INSERT INTO `logs` (`log_user`, `log_action`, `log_time`) VALUES ('$username', 'Set cheat status to " . $_POST['cheatStatus'] . "', NOW())";
+
+ $webhook = ADMIN_WEBHOOK;
+ $embed = array(
+ "title" => "Cheat Status",
+ "description" => "$username has set the cheat status to " . $_POST['cheatStatus'],
+ "color" => 0x00ff00
+ );
+ $data = array(
+ "embeds" => array($embed)
+ );
+ $options = array(
+ 'http' => array(
+ 'header' => "Content-type: application/json\r\n",
+ 'method' => 'POST',
+ 'content' => json_encode($data)
+ )
+ );
+ // send webhook
+ $context = stream_context_create($options);
+ $result = file_get_contents($webhook, false, $context);
+
+ $result = $mysqli->query($sql);
+ }
+
+ if (isset($_POST["cheatMaint"])) {
+ $admin->setCheatMaint();
+ $sql = "INSERT INTO `logs` (`log_user`, `log_action`, `log_time`) VALUES ('$username', 'Set cheat maintenance to " . $_POST['cheatMaint'] . "', NOW())";
+
+ $webhook = ADMIN_WEBHOOK;
+ $embed = array(
+ "title" => "Cheat Maintenance",
+ "description" => "$username has set the cheat maintenance to " . $_POST['cheatMaint'],
+ "color" => 0x00ff00
+ );
+ $data = array(
+ "embeds" => array($embed)
+ );
+ $options = array(
+ 'http' => array(
+ 'header' => "Content-type: application/json\r\n",
+ 'method' => 'POST',
+ 'content' => json_encode($data)
+ )
+ );
+ // send webhook
+ $context = stream_context_create($options);
+ $result = file_get_contents($webhook, false, $context);
+ $result = $mysqli->query($sql);
+ }
+
+ if (isset($_POST["cheatVersion"])) {
+ $ver = floatval($_POST['version']);
+ $admin->setCheatVersion($ver);
+ $sql = "INSERT INTO `logs` (`log_user`, `log_action`, `log_time`) VALUES ('$username', 'Set cheat version to " . $_POST['version'] . "', NOW())";
+
+ $webhook = ADMIN_WEBHOOK;
+ $embed = array(
+ "title" => "Cheat Version",
+ "description" => "$username has set the cheat version to " . $_POST['version'],
+ "color" => 0x00ff00
+ );
+ $data = array(
+ "embeds" => array($embed)
+ );
+ $options = array(
+ 'http' => array(
+ 'header' => "Content-type: application/json\r\n",
+ 'method' => 'POST',
+ 'content' => json_encode($data)
+ )
+ );
+ // send webhook
+ $context = stream_context_create($options);
+ $result = file_get_contents($webhook, false, $context);
+
+ $result = $mysqli->query($sql);
+ }
+
+ header("location: cheat");
}
-if(isset($_POST['set_motd'])) {
- // update motd in cheat table
- $motd = $_POST['motd'];
- $sql = "UPDATE cheat SET motd = '$motd'";
- $result = mysqli_query($mysqli, $sql);
- $sql = "INSERT INTO `logs` (`log_user`, `log_action`, `log_time`) VALUES ('$username', 'Set MOTD to " . $_POST['motd'] . "', NOW())";
-
- $webhook = ADMIN_WEBHOOK;
- $embed = array(
- "title" => "MOTD",
- "description" => "$username has set the MOTD to " . $_POST['motd'],
- "color" => 0x00ff00
- );
- $data = array(
- "embeds" => array($embed)
- );
- $options = array(
- 'http' => array(
- 'header' => "Content-type: application/json\r\n",
- 'method' => 'POST',
- 'content' => json_encode($data)
- )
- );
- // send webhook
- $context = stream_context_create($options);
- $result = file_get_contents($webhook, false, $context);
-
- $result = $mysqli->query($sql);
- Util::redirect('/admin/cheat');
+if (isset($_POST['set_motd'])) {
+ // update motd in cheat table
+ $motd = $_POST['motd'];
+ $sql = "UPDATE cheat SET motd = '$motd'";
+ $result = mysqli_query($mysqli, $sql);
+ $sql = "INSERT INTO `logs` (`log_user`, `log_action`, `log_time`) VALUES ('$username', 'Set MOTD to " . $_POST['motd'] . "', NOW())";
+
+ $webhook = ADMIN_WEBHOOK;
+ $embed = array(
+ "title" => "MOTD",
+ "description" => "$username has set the MOTD to " . $_POST['motd'],
+ "color" => 0x00ff00
+ );
+ $data = array(
+ "embeds" => array($embed)
+ );
+ $options = array(
+ 'http' => array(
+ 'header' => "Content-type: application/json\r\n",
+ 'method' => 'POST',
+ 'content' => json_encode($data)
+ )
+ );
+ // send webhook
+ $context = stream_context_create($options);
+ $result = file_get_contents($webhook, false, $context);
+
+ $result = $mysqli->query($sql);
+ Util::redirect('/admin/cheat');
}
?>
diff --git a/admin/index.php b/admin/index.php
index 7496742..b782dd1 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -5,8 +5,8 @@
include '../includes/db.php';
-$user = new UserController;
-$admin = new AdminController;
+$user = new UserController();
+$admin = new AdminController();
Session::init();
diff --git a/admin/invites.php b/admin/invites.php
index be04794..c036510 100644
--- a/admin/invites.php
+++ b/admin/invites.php
@@ -3,8 +3,8 @@
require_once '../app/require.php';
require_once '../app/controllers/AdminController.php';
-$user = new UserController;
-$admin = new AdminController;
+$user = new UserController();
+$admin = new AdminController();
Session::init();
@@ -18,41 +18,36 @@
Util::head('Admin Panel');
Util::navbar();
-// if post request
+// if post request
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
-
-
- if (isset($_POST["genInv"])) {
- $admin->getInvCodeGen($username);
- $sql = "INSERT INTO `logs` (`log_user`, `log_action`, `log_time`) VALUES ('$username', 'Generated Invite Code', NOW())";
- $result = $mysqli->query($sql);
-
- //
- $webhook = INVITE_WEBHOOK;
- $embed = array(
- "title" => "New Invite Code",
- "description" => "A new invite code has been generated by $username",
- "color" => 0x00ff00
- );
- $data = array(
- "embeds" => array($embed)
- );
- $options = array(
- 'http' => array(
- 'header' => "Content-type: application/json\r\n",
- 'method' => 'POST',
- 'content' => json_encode($data)
- )
- );
- // send webhook
- $context = stream_context_create($options);
- $result = file_get_contents($webhook, false, $context);
-
- }
-
- header("location: invites");
-
-
+ if (isset($_POST["genInv"])) {
+ $admin->getInvCodeGen($username);
+ $sql = "INSERT INTO `logs` (`log_user`, `log_action`, `log_time`) VALUES ('$username', 'Generated Invite Code', NOW())";
+ $result = $mysqli->query($sql);
+
+ //
+ $webhook = INVITE_WEBHOOK;
+ $embed = array(
+ "title" => "New Invite Code",
+ "description" => "A new invite code has been generated by $username",
+ "color" => 0x00ff00
+ );
+ $data = array(
+ "embeds" => array($embed)
+ );
+ $options = array(
+ 'http' => array(
+ 'header' => "Content-type: application/json\r\n",
+ 'method' => 'POST',
+ 'content' => json_encode($data)
+ )
+ );
+ // send webhook
+ $context = stream_context_create($options);
+ $result = file_get_contents($webhook, false, $context);
+ }
+
+ header("location: invites");
}
?>
diff --git a/admin/logs.php b/admin/logs.php
index a6afb49..0d2f6c2 100644
--- a/admin/logs.php
+++ b/admin/logs.php
@@ -3,8 +3,8 @@
require_once '../app/require.php';
require_once '../app/controllers/AdminController.php';
-$user = new UserController;
-$admin = new AdminController;
+$user = new UserController();
+$admin = new AdminController();
Session::init();
@@ -24,25 +24,25 @@
if ($result) {
$sql = "INSERT INTO `logs` (`log_user`, `log_action`, `log_time`) VALUES ('$username', 'Deleted all logs', NOW())";
- $webhook = ADMIN_WEBHOOK;
- $embed = array(
- "title" => "Logs Deleted",
- "description" => "$username has deleted all logs",
- "color" => 0x00ff00
- );
- $data = array(
- "embeds" => array($embed)
- );
- $options = array(
- 'http' => array(
- 'header' => "Content-type: application/json\r\n",
- 'method' => 'POST',
- 'content' => json_encode($data)
- )
- );
- // send webhook
- $context = stream_context_create($options);
- $result = file_get_contents($webhook, false, $context);
+ $webhook = ADMIN_WEBHOOK;
+ $embed = array(
+ "title" => "Logs Deleted",
+ "description" => "$username has deleted all logs",
+ "color" => 0x00ff00
+ );
+ $data = array(
+ "embeds" => array($embed)
+ );
+ $options = array(
+ 'http' => array(
+ 'header' => "Content-type: application/json\r\n",
+ 'method' => 'POST',
+ 'content' => json_encode($data)
+ )
+ );
+ // send webhook
+ $context = stream_context_create($options);
+ $result = file_get_contents($webhook, false, $context);
$result = $mysqli->query($sql);
Util::redirect('/admin/logs');
diff --git a/admin/sub.php b/admin/sub.php
index 4273a5a..4b7e0ff 100644
--- a/admin/sub.php
+++ b/admin/sub.php
@@ -3,8 +3,8 @@
require_once '../app/require.php';
require_once '../app/controllers/AdminController.php';
-$user = new UserController;
-$admin = new AdminController;
+$user = new UserController();
+$admin = new AdminController();
include '../includes/db.php';
@@ -18,39 +18,36 @@
Util::head('Admin Panel');
Util::navbar();
-// if post request
+// if post request
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
-
-
- if (isset($_POST["genSub"])) {
- $admin->getSubCodeGen($username);
- $sql = "INSERT INTO `logs` (`log_user`, `log_action`, `log_time`) VALUES ('$username', 'Generated new sub code', NOW())";
-
- $webhook = ADMIN_WEBHOOK;
- $embed = array(
- "title" => "New Sub Code",
- "description" => "A new sub code has been generated by $username",
- "color" => 0x00ff00
- );
- $data = array(
- "embeds" => array($embed)
- );
- $options = array(
- 'http' => array(
- 'header' => "Content-type: application/json\r\n",
- 'method' => 'POST',
- 'content' => json_encode($data)
- )
- );
- // send webhook
- $context = stream_context_create($options);
- $result = file_get_contents($webhook, false, $context);
-
- $result = $mysqli->query($sql);
- }
-
- header("location: sub");
-
+ if (isset($_POST["genSub"])) {
+ $admin->getSubCodeGen($username);
+ $sql = "INSERT INTO `logs` (`log_user`, `log_action`, `log_time`) VALUES ('$username', 'Generated new sub code', NOW())";
+
+ $webhook = ADMIN_WEBHOOK;
+ $embed = array(
+ "title" => "New Sub Code",
+ "description" => "A new sub code has been generated by $username",
+ "color" => 0x00ff00
+ );
+ $data = array(
+ "embeds" => array($embed)
+ );
+ $options = array(
+ 'http' => array(
+ 'header' => "Content-type: application/json\r\n",
+ 'method' => 'POST',
+ 'content' => json_encode($data)
+ )
+ );
+ // send webhook
+ $context = stream_context_create($options);
+ $result = file_get_contents($webhook, false, $context);
+
+ $result = $mysqli->query($sql);
+ }
+
+ header("location: sub");
}
?>
diff --git a/admin/users.php b/admin/users.php
index 24cf2ac..30e36aa 100644
--- a/admin/users.php
+++ b/admin/users.php
@@ -3,8 +3,8 @@
require_once '../app/require.php';
require_once '../app/controllers/AdminController.php';
-$user = new UserController;
-$admin = new AdminController;
+$user = new UserController();
+$admin = new AdminController();
include '../includes/db.php';
@@ -18,95 +18,93 @@
Util::head('Admin Panel');
Util::navbar();
-// if post request
+// if post request
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
-
- if (isset($_POST["resetHWID"])) {
- $rowUID = $_POST['resetHWID'];
- $admin->resetHWID($rowUID);
- $sql = "INSERT INTO `logs` (`log_user`, `log_action`, `log_time`) VALUES ('$username', 'Reset HWID from user with id $rowUID', NOW())";
-
- $webhook = ADMIN_WEBHOOK;
- $embed = array(
- "title" => "HWID Reset",
- "description" => "$username has reset the HWID for user with id $rowUID",
- "color" => 0x00ff00
- );
- $data = array(
- "embeds" => array($embed)
- );
- $options = array(
- 'http' => array(
- 'header' => "Content-type: application/json\r\n",
- 'method' => 'POST',
- 'content' => json_encode($data)
- )
- );
- // send webhook
- $context = stream_context_create($options);
- $result = file_get_contents($webhook, false, $context);
-
- $result = $mysqli->query($sql);
- }
-
- if (isset($_POST["setBanned"])) {
- $rowUID = $_POST['setBanned'];
- $admin->setBanned($rowUID);
- $sql = "INSERT INTO `logs` (`log_user`, `log_action`, `log_time`) VALUES ('$username', 'Ban/unban user with id $rowUID', NOW())";
-
- $webhook = ADMIN_WEBHOOK;
- $embed = array(
- "title" => "Ban/Unban",
- "description" => "$username has banned/unbanned user with id $rowUID",
- "color" => 0x00ff00
- );
- $data = array(
- "embeds" => array($embed)
- );
- $options = array(
- 'http' => array(
- 'header' => "Content-type: application/json\r\n",
- 'method' => 'POST',
- 'content' => json_encode($data)
- )
- );
- // send webhook
- $context = stream_context_create($options);
- $result = file_get_contents($webhook, false, $context);
-
- $result = $mysqli->query($sql);
- }
-
- if (isset($_POST["setAdmin"])) {
- $rowUID = $_POST['setAdmin'];
- $admin->setAdmin($rowUID);
- $sql = "INSERT INTO `logs` (`log_user`, `log_action`, `log_time`) VALUES ('$username', 'Set admin / nonadmin user with id $rowUID', NOW())";
-
- $webhook = ADMIN_WEBHOOK;
- $embed = array(
- "title" => "Admin/Non-Admin",
- "description" => "$username has set user with id $rowUID as admin",
- "color" => 0x00ff00
- );
- $data = array(
- "embeds" => array($embed)
- );
- $options = array(
- 'http' => array(
- 'header' => "Content-type: application/json\r\n",
- 'method' => 'POST',
- 'content' => json_encode($data)
- )
- );
- // send webhook
- $context = stream_context_create($options);
- $result = file_get_contents($webhook, false, $context);
-
- $result = $mysqli->query($sql);
- }
-
- header("location: users");
-
+ if (isset($_POST["resetHWID"])) {
+ $rowUID = $_POST['resetHWID'];
+ $admin->resetHWID($rowUID);
+ $sql = "INSERT INTO `logs` (`log_user`, `log_action`, `log_time`) VALUES ('$username', 'Reset HWID from user with id $rowUID', NOW())";
+
+ $webhook = ADMIN_WEBHOOK;
+ $embed = array(
+ "title" => "HWID Reset",
+ "description" => "$username has reset the HWID for user with id $rowUID",
+ "color" => 0x00ff00
+ );
+ $data = array(
+ "embeds" => array($embed)
+ );
+ $options = array(
+ 'http' => array(
+ 'header' => "Content-type: application/json\r\n",
+ 'method' => 'POST',
+ 'content' => json_encode($data)
+ )
+ );
+ // send webhook
+ $context = stream_context_create($options);
+ $result = file_get_contents($webhook, false, $context);
+
+ $result = $mysqli->query($sql);
+ }
+
+ if (isset($_POST["setBanned"])) {
+ $rowUID = $_POST['setBanned'];
+ $admin->setBanned($rowUID);
+ $sql = "INSERT INTO `logs` (`log_user`, `log_action`, `log_time`) VALUES ('$username', 'Ban/unban user with id $rowUID', NOW())";
+
+ $webhook = ADMIN_WEBHOOK;
+ $embed = array(
+ "title" => "Ban/Unban",
+ "description" => "$username has banned/unbanned user with id $rowUID",
+ "color" => 0x00ff00
+ );
+ $data = array(
+ "embeds" => array($embed)
+ );
+ $options = array(
+ 'http' => array(
+ 'header' => "Content-type: application/json\r\n",
+ 'method' => 'POST',
+ 'content' => json_encode($data)
+ )
+ );
+ // send webhook
+ $context = stream_context_create($options);
+ $result = file_get_contents($webhook, false, $context);
+
+ $result = $mysqli->query($sql);
+ }
+
+ if (isset($_POST["setAdmin"])) {
+ $rowUID = $_POST['setAdmin'];
+ $admin->setAdmin($rowUID);
+ $sql = "INSERT INTO `logs` (`log_user`, `log_action`, `log_time`) VALUES ('$username', 'Set admin / nonadmin user with id $rowUID', NOW())";
+
+ $webhook = ADMIN_WEBHOOK;
+ $embed = array(
+ "title" => "Admin/Non-Admin",
+ "description" => "$username has set user with id $rowUID as admin",
+ "color" => 0x00ff00
+ );
+ $data = array(
+ "embeds" => array($embed)
+ );
+ $options = array(
+ 'http' => array(
+ 'header' => "Content-type: application/json\r\n",
+ 'method' => 'POST',
+ 'content' => json_encode($data)
+ )
+ );
+ // send webhook
+ $context = stream_context_create($options);
+ $result = file_get_contents($webhook, false, $context);
+
+ $result = $mysqli->query($sql);
+ }
+
+ header("location: users");
}
?>
diff --git a/admin/vSocket/app.php b/admin/vSocket/app.php
index 5e8b90a..be024a1 100644
--- a/admin/vSocket/app.php
+++ b/admin/vSocket/app.php
@@ -5,7 +5,7 @@
use Ratchet\WebSocket\WsServer;
use vSocket\Socket;
-require dirname( __FILE__ ) . '/vendor/autoload.php';
+require dirname(__FILE__) . '/vendor/autoload.php';
$server = IoServer::factory(
new HttpServer(
diff --git a/admin/vSocket/app/socket.php b/admin/vSocket/app/socket.php
index 035ffed..085e686 100644
--- a/admin/vSocket/app/socket.php
+++ b/admin/vSocket/app/socket.php
@@ -5,14 +5,15 @@
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
-class Socket implements MessageComponentInterface {
-
+class Socket implements MessageComponentInterface
+{
public function __construct()
{
- $this->clients = new \SplObjectStorage;
+ $this->clients = new \SplObjectStorage();
}
- public function onOpen(ConnectionInterface $conn) {
+ public function onOpen(ConnectionInterface $conn)
+ {
// Store the new connection in $this->clients
$this->clients->attach($conn);
@@ -20,21 +21,22 @@ public function onOpen(ConnectionInterface $conn) {
echo "New connection! ({$conn->resourceId})\n";
}
- public function onMessage(ConnectionInterface $from, $msg) {
-
- foreach ( $this->clients as $client ) {
-
- if ( $from->resourceId == $client->resourceId ) {
+ public function onMessage(ConnectionInterface $from, $msg)
+ {
+ foreach ($this->clients as $client) {
+ if ($from->resourceId == $client->resourceId) {
continue;
}
- $client->send( "Client $from->resourceId said $msg" );
+ $client->send("Client $from->resourceId said $msg");
}
}
- public function onClose(ConnectionInterface $conn) {
+ public function onClose(ConnectionInterface $conn)
+ {
}
- public function onError(ConnectionInterface $conn, \Exception $e) {
+ public function onError(ConnectionInterface $conn, \Exception $e)
+ {
}
}
diff --git a/api/auth.php b/api/auth.php
index ef16011..690f969 100644
--- a/api/auth.php
+++ b/api/auth.php
@@ -1,37 +1,31 @@
'failed', 'error' => 'Missing arguments');
-
+ $response = array('status' => 'failed', 'error' => 'Missing arguments');
} else {
+ $username = $_GET['user'];
+ $passwordHash = $_GET['pass'];
+ $hwidHash = $_GET['hwid'];
+ $key = $_GET['key'];
- $username = $_GET['user'];
- $passwordHash = $_GET['pass'];
- $hwidHash = $_GET['hwid'];
- $key = $_GET['key'];
-
- if (API_KEY === $key) {
-
- // decode
- $password = base64_decode($passwordHash);
- $hwid = base64_decode($hwidHash);
-
- $response = $API->getUserAPI($username, $password, $hwid);
-
- } else {
+ if (API_KEY === $key) {
- $response = array('status' => 'failed', 'error' => 'Invalid API key');
-
- }
+ // decode
+ $password = base64_decode($passwordHash);
+ $hwid = base64_decode($hwidHash);
+ $response = $API->getUserAPI($username, $password, $hwid);
+ } else {
+ $response = array('status' => 'failed', 'error' => 'Invalid API key');
+ }
}
-echo (json_encode($response));
+echo(json_encode($response));
diff --git a/api/discord.php b/api/discord.php
index 1afce4b..97aea9e 100644
--- a/api/discord.php
+++ b/api/discord.php
@@ -18,7 +18,7 @@
$tokenURL = 'https://discord.com/api/oauth2/token';
$apiURLBase = 'https://discord.com/api/users/@me';
-$user = new UserController;
+$user = new UserController();
Session::init();
@@ -30,80 +30,76 @@
die("You are not logged in. Please login.");
}
-if(get('code')) {
-
- $token = apiRequest($tokenURL, array(
+if (get('code')) {
+ $token = apiRequest($tokenURL, array(
"grant_type" => "authorization_code",
'client_id' => OAUTH2_CLIENT_ID,
'client_secret' => OAUTH2_CLIENT_SECRET,
'redirect_uri' => 'https://domain/panel/api/discord.php',
'code' => get('code')
));
- $logout_token = $token->access_token;
- $_SESSION['access_token'] = $token->access_token;
+ $logout_token = $token->access_token;
+ $_SESSION['access_token'] = $token->access_token;
- header('Location: ' . $_SERVER['PHP_SELF']);
+ header('Location: ' . $_SERVER['PHP_SELF']);
}
-if(session('access_token')) {
- $user = apiRequest($apiURLBase);
-
- $headers = array(
+if (session('access_token')) {
+ $user = apiRequest($apiURLBase);
+
+ $headers = array(
'Content-Type: application/json',
'Authorization: Bot OTMxNTU1MDU0MzkyMDc4MzU3.YeGIQA.rh6DpWF9hladlFpccrl59Zj-N4E' // add your bot token here
);
- $data = array("access_token" => session('access_token'));
+ $data = array("access_token" => session('access_token'));
$data_string = json_encode($data);
-
- $url = "https://discord.com/api/guilds/919531932054872065/members/". $user->id; // replace 919531932054872065 with your guild id
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
- curl_exec($ch);
- curl_close($ch);
-
- if ($_SESSION["login"]) {
- $stmt = $mysqli->prepare("UPDATE users SET dcid = ? WHERE username = ?");
- $stmt->bind_param("is", $user->id, $username);
- $stmt->execute();
- $stmt->close();
-
- $role = "919533220641513483";
- }
- else if ($_SESSION["admin"]) {
- $stmt = $mysqli->prepare("UPDATE users SET dcid = ? WHERE username = ?");
- $stmt->bind_param("is", $user->id, $username);
- $stmt->execute();
- $stmt->close();
-
- $role = "919533212030623774";
- }
- // else if ($_SESSION["reseller"]) {
- // $stmt = $mysqli->prepare("UPDATE users SET dcid = ? WHERE username = ?");
- // $stmt->bind_param("is", $user->id, $username);
- // $stmt->execute();
- // $stmt->close();
-
- // $role = "919533220570210354";
- // }
+
+ $url = "https://discord.com/api/guilds/919531932054872065/members/". $user->id; // replace 919531932054872065 with your guild id
+ $ch = curl_init($url);
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
+ curl_exec($ch);
+ curl_close($ch);
+
+ if ($_SESSION["login"]) {
+ $stmt = $mysqli->prepare("UPDATE users SET dcid = ? WHERE username = ?");
+ $stmt->bind_param("is", $user->id, $username);
+ $stmt->execute();
+ $stmt->close();
+
+ $role = "919533220641513483";
+ } elseif ($_SESSION["admin"]) {
+ $stmt = $mysqli->prepare("UPDATE users SET dcid = ? WHERE username = ?");
+ $stmt->bind_param("is", $user->id, $username);
+ $stmt->execute();
+ $stmt->close();
+
+ $role = "919533212030623774";
+ }
+ // else if ($_SESSION["reseller"]) {
+ // $stmt = $mysqli->prepare("UPDATE users SET dcid = ? WHERE username = ?");
+ // $stmt->bind_param("is", $user->id, $username);
+ // $stmt->execute();
+ // $stmt->close();
+
+ // $role = "919533220570210354";
+ // }
$url = "https://discord.com/api/guilds/919531932054872065/members/". $user->id. "/roles/{$role}"; // replace 919531932054872065 with your guild id
$ch = curl_init($url);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
- curl_exec($ch);
+ curl_exec($ch);
curl_close($ch);
-
-
} else {
- die("Not logged into Discord!");
+ die("Not logged into Discord!");
}
@@ -122,63 +118,69 @@
// die();
// }
-if(get('action') == 'logout') {
- $url = "https://discord.com/api/guilds/919531932054872065/members/". $user->id;
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
+if (get('action') == 'logout') {
+ $url = "https://discord.com/api/guilds/919531932054872065/members/". $user->id;
+ $ch = curl_init($url);
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Authorization: Bot OTMxNTU1MDU0MzkyMDc4MzU3.YeGIQA.rh6DpWF9hladlFpccrl59Zj-N4E' // add your bot token here
));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
- curl_exec($ch);
- curl_close($ch);
- unset($_SESSION['access_token']);
- header('Location: ' . $_SERVER['PHP_SELF']);
- die();
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
+ curl_exec($ch);
+ curl_close($ch);
+ unset($_SESSION['access_token']);
+ header('Location: ' . $_SERVER['PHP_SELF']);
+ die();
}
-function apiRequest($url, $post=FALSE, $headers=array()) {
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+function apiRequest($url, $post=false, $headers=array())
+{
+ $ch = curl_init($url);
+ curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $response = curl_exec($ch);
+ $response = curl_exec($ch);
- if($post)
- curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
+ if ($post) {
+ curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
+ }
- $headers[] = 'Accept: application/json';
+ $headers[] = 'Accept: application/json';
- if(session('access_token'))
- $headers[] = 'Authorization: Bearer ' . session('access_token');
+ if (session('access_token')) {
+ $headers[] = 'Authorization: Bearer ' . session('access_token');
+ }
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- $response = curl_exec($ch);
- return json_decode($response);
+ $response = curl_exec($ch);
+ return json_decode($response);
}
-function logout($url, $data=array()) {
- $ch = curl_init($url);
- curl_setopt_array($ch, array(
- CURLOPT_POST => TRUE,
- CURLOPT_RETURNTRANSFER => TRUE,
+function logout($url, $data=array())
+{
+ $ch = curl_init($url);
+ curl_setopt_array($ch, array(
+ CURLOPT_POST => true,
+ CURLOPT_RETURNTRANSFER => true,
CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
CURLOPT_HTTPHEADER => array('Content-Type: application/x-www-form-urlencoded'),
CURLOPT_POSTFIELDS => http_build_query($data),
));
- $response = curl_exec($ch);
- return json_decode($response);
+ $response = curl_exec($ch);
+ return json_decode($response);
}
-function get($key, $default=NULL) {
- return array_key_exists($key, $_GET) ? $_GET[$key] : $default;
+function get($key, $default=null)
+{
+ return array_key_exists($key, $_GET) ? $_GET[$key] : $default;
}
-function session($key, $default=NULL) {
- return array_key_exists($key, $_SESSION) ? $_SESSION[$key] : $default;
+function session($key, $default=null)
+{
+ return array_key_exists($key, $_SESSION) ? $_SESSION[$key] : $default;
}
@@ -247,4 +249,4 @@ function session($key, $default=NULL) {