Novetus_src/query.php

57 lines
1.3 KiB
PHP
Raw Normal View History

2020-10-11 21:11:46 +03:00
<?php
//NOVETUS MASTER SERVER QUERY CODE
//server name
$name = $_GET["name"];
2020-10-11 21:11:46 +03:00
//server ip
$ip = $_GET["ip"];
2020-10-11 21:11:46 +03:00
//server port
$port = $_GET["port"];
2020-10-11 21:11:46 +03:00
//client name
$client = $_GET["client"];
2020-10-11 21:11:46 +03:00
//online status
$online = $_GET["online"];
2020-10-11 21:11:46 +03:00
//strings
$deleteentry = 1;
$status = "Offline";
//ONLY the $name and $client arguments will show up in the master server!
$file = 'serverlist.txt';
2021-03-25 01:26:26 +02:00
$text = base64_encode(base64_encode($name).'|'.base64_encode($ip).'|'.base64_encode($port).'|'.base64_encode($client))."\r\n";
2020-10-11 21:11:46 +03:00
if ($online == 1)
{
$deleteentry = 0;
2021-03-25 01:26:26 +02:00
foreach(file($file) as $line)
2020-10-11 21:11:46 +03:00
{
if (strpos($line, $text) !== false)
{
$file_contents = file_get_contents($file);
$contents = str_replace($line, '', $file_contents);
file_put_contents($file, $contents);
}
2020-10-11 21:11:46 +03:00
}
2021-03-25 01:26:26 +02:00
file_put_contents($file, $text, FILE_APPEND);
2020-10-11 21:11:46 +03:00
$status = "Online";
}
if ($deleteentry == 1)
{
foreach(file($file) as $line)
{
if (strpos($line, $text) !== false)
{
$file_contents = file_get_contents($file);
$contents = str_replace($line, '', $file_contents);
file_put_contents($file, $contents);
}
}
2020-10-11 21:11:46 +03:00
}
// Display the server info to browsers.
2021-05-24 22:29:16 +03:00
echo "" . htmlspecialchars($name) . ".<br>A " . htmlspecialchars($client) . " server.<br>Server Status: " . htmlspecialchars($status) . "";
2020-10-11 21:11:46 +03:00
?>