This repository has been archived on 2026-11-17. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
serverdiscountergraphviewer/index.php
2020-09-24 18:49:36 +00:00

46 lines
No EOL
1.8 KiB
PHP

<?php
$email = "";
$password = "";
$serverID = ""; #This is not your Server ID, this ID can can be found in the URL if you click on your product
$loginPage = file_get_contents("https://ksc.serverdiscounter.com/clientarea.php");
$token = explode("\"", explode("value=\"", explode("name=\"token\"", $loginPage)[1])[1])[0];
# Our new data
$data = array(
'token' => $token,
'username' => $email,
'password' => $password
);
# Create a connection
$url = 'https://ksc.serverdiscounter.com/dologin.php';
$ch = curl_init($url);
# Form data string
$postString = http_build_query($data, '', '&');
# Setting our options
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch , CURLOPT_COOKIEJAR, 'cookies.txt');
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36');
# Get the response
$response = curl_exec($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);
$cookie = explode(";", explode("Set-Cookie: ", $header)[1])[0];
# Create a connection
$url = 'https://ksc.serverdiscounter.com/modules/servers/dedicated/request.php?id=$serverID&ajaxfetch=1&networkGraphs=1';
$ch = curl_init($url);
# Form data string
# Setting our options
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch , CURLOPT_COOKIEFILE, 'cookies.txt');
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36');
# Get the response
$response = json_decode(curl_exec($ch), true)["Graphs"];
header("Content-type: image/png");
echo base64_decode($response[$_GET["card"]][$_GET["type"]]);