2020-10-11 21:11:46 +03:00
< ? php
2021-06-07 23:44:16 +03:00
/*
This file is part of Novetus , but unlike the rest of the program where it is under the MIT license ,
this file is under the GPL 3.0 license .
Novetus ' s query . php is free software : you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation , either version 3 of the License , or
( at your option ) any later version .
Novetus ' s query . php is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with Novetus ' s query . php . If not , see < https :// www . gnu . org / licenses />.
*/
2020-10-11 21:11:46 +03:00
//NOVETUS MASTER SERVER QUERY CODE
2021-10-30 21:45:15 +03:00
//thanks to idkwhatnametoget for the port fix
2020-10-11 21:11:46 +03:00
2021-10-30 21:45:15 +03:00
//name
2021-03-24 23:23:23 +02:00
$name = $_GET [ " name " ];
2021-10-30 21:45:15 +03:00
//port
2021-03-24 23:23:23 +02:00
$port = $_GET [ " port " ];
2021-10-30 21:45:15 +03:00
//client
2021-03-24 23:23:23 +02:00
$client = $_GET [ " client " ];
2021-11-01 02:32:47 +02:00
//version
$version = $_GET [ " version " ];
2020-10-11 21:11:46 +03:00
2021-11-01 02:32:47 +02:00
if ( ! empty ( $port ) and $port < 65535 and is_numeric ( $port ) and ! empty ( $name ) and ! empty ( $client ) and ! empty ( $version ))
2020-10-11 21:11:46 +03:00
{
2021-10-30 21:45:15 +03:00
//server ip
$ip = $_GET [ " ip " ];
//online status
$online = $_GET [ " online " ];
//strings
$deleteentry = 1 ;
$status = " Offline " ;
2021-03-24 23:23:23 +02:00
2021-10-30 21:45:15 +03:00
$file = 'serverlist.txt' ;
//ONLY the $name and $client arguments will show up in the master server!
2021-11-01 02:32:47 +02:00
$text = base64_encode ( base64_encode ( $name ) . '|' . base64_encode ( $ip ) . '|' . base64_encode ( $port ) . '|' . base64_encode ( $client ) . '|' . base64_encode ( $version )) . " \r \n " ;
2021-10-30 21:45:15 +03:00
if ( $online == 1 )
2020-10-11 21:11:46 +03:00
{
2021-10-30 21:45:15 +03:00
$deleteentry = 0 ;
foreach ( file ( $file ) as $line )
2021-03-24 23:23:23 +02:00
{
2021-10-30 21:45:15 +03:00
if ( strpos ( $line , $text ) !== false )
{
$file_contents = file_get_contents ( $file );
$contents = str_replace ( $line , '' , $file_contents );
file_put_contents ( $file , $contents );
}
2021-03-24 23:23:23 +02:00
}
2021-10-30 21:45:15 +03:00
file_put_contents ( $file , $text , FILE_APPEND );
$status = " Online " ;
2020-10-11 21:11:46 +03:00
}
2021-10-30 21:45:15 +03:00
if ( $deleteentry == 1 )
2021-03-24 23:23:23 +02:00
{
2021-10-30 21:45:15 +03:00
foreach ( file ( $file ) as $line )
2021-03-24 23:23:23 +02:00
{
2021-10-30 21:45:15 +03:00
if ( strpos ( $line , $text ) !== false )
{
$file_contents = file_get_contents ( $file );
$contents = str_replace ( $line , '' , $file_contents );
file_put_contents ( $file , $contents );
}
2021-03-24 23:23:23 +02:00
}
}
2020-10-11 21:11:46 +03:00
2021-10-30 21:45:15 +03:00
// Display the server info to browsers.
2021-11-01 02:32:47 +02:00
echo " " . htmlspecialchars ( $name ) . " . A " . htmlspecialchars ( $client ) . " server running on " . htmlspecialchars ( $version ) . " . Server Status: " . htmlspecialchars ( $status ) . " " ;
2021-10-30 21:45:15 +03:00
}
2020-10-11 21:11:46 +03:00
?>