Update: Configuration fetch

This commit is contained in:
Akkariin Meiko 2020-01-21 12:08:36 +08:00 committed by GitHub
parent dc1abdb66d
commit 7170f89920
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,14 +31,14 @@ $nm = new NodeManager();
if((isset($_GET['apitoken']) && $_GET['apitoken'] == API_TOKEN) || (isset($_GET['action']) && $_GET['action'] == "getconf")) { if((isset($_GET['apitoken']) && $_GET['apitoken'] == API_TOKEN) || (isset($_GET['action']) && $_GET['action'] == "getconf")) {
switch($_GET['action']) { switch($_GET['action']) {
case "getconf": case "getconf":
if(isset($_GET['user'], $_GET['token'], $_GET['node'])) { // 精简了一下,用户名可以不用了
if(Regex::isUserName($_GET['user']) && Regex::isLetter($_GET['token']) && Regex::isNumber($_GET['node'])) { if(isset($_GET['token'], $_GET['node'])) {
if(Regex::isLetter($_GET['token']) && Regex::isNumber($_GET['node'])) {
$rs = Database::querySingleLine("tokens", [ $rs = Database::querySingleLine("tokens", [
"username" => $_GET['user'], "token" => $_GET['token']
"token" => $_GET['token']
]); ]);
if($rs && $nm->isNodeExist($_GET['node'])) { if($rs && $nm->isNodeExist($_GET['node'])) {
$rs = $pm->getUserProxiesConfig($_GET['user'], $_GET['node']); $rs = $pm->getUserProxiesConfig($rs['username'], $_GET['node']);
if(is_string($rs)) { if(is_string($rs)) {
Header("Content-Type: text/plain"); Header("Content-Type: text/plain");
exit($rs); exit($rs);
@ -49,7 +49,7 @@ if((isset($_GET['apitoken']) && $_GET['apitoken'] == API_TOKEN) || (isset($_GET[
Utils::sendServerNotFound("User or node not found"); Utils::sendServerNotFound("User or node not found");
} }
} else { } else {
Utils::sendServerNotFound("Invalid username or token"); Utils::sendServerNotFound("Invalid token");
} }
} else { } else {
Utils::sendServerNotFound("Invalid request"); Utils::sendServerNotFound("Invalid request");