exists() !== true || Login::auth($username, $password) !== Login::LOGIN_OK) { header("HTTP/1.1 403 Unauthorized"); die("\"403 Unauthorized\""); } // query max results $max = 20; if (preg_match("/^[0-9]+$/", $VARS['max']) === 1 && $VARS['max'] <= 1000) { $max = (int) $VARS['max']; } switch ($VARS['action']) { case "ping": $out = ["status" => "OK", "maxresults" => $max, "pong" => true]; exit(json_encode($out)); default: header("HTTP/1.1 400 Bad Request"); die("\"400 Bad Request\""); }