ZontreckWebsite/php/Ping.php

43 lines
No EOL
715 B
PHP

<?php
if(!defined("COMMON"))
require("Common.php");
$js = getJsonizedInput();
$psk = "";
$allow=false;
$user = "";
$display_name = "";
$logged_in = false;
$totalUsers = 0;
if(!defined("CLIENTPSK")) {
$allow=true;
} else {
if($js['client'] == CLIENTPSK) {
// Authorized. Send the PSK value to the client
$allow=true;
$psk = PSK;
}else {
$allow=false;
}
$DB = get_DB();
// Query total number of users
$res = $DB->query("SELECT * FROM auth;");
$totalUsers = $res->num_rows;
$DB->close();
}
$ret = array(
"type" => "S2CPong",
"authorized" => $allow,
"psk" => $psk,
"user_count" => $totalUsers
);
die(json_encode($ret));
?>