diff --git a/api.php b/api.php index 376756f..fa87a4c 100644 --- a/api.php +++ b/api.php @@ -39,6 +39,21 @@ if(!array_key_exists("action", $query)||gettype($query["action"])!="string") { $action=$query["action"]; $action=explode(",", $action); + +//check if requested to show the help info before parsing game param + +if($action[0]=="help") { + echo "notice: use comma(',') to split args\n"; + echo "all available commands:\n"; + echo " user-panel: display a interactive content for user\n"; + echo " team-info: show your team info as json\n"; + echo " challenge-list: list all challenges as json which are defined internally\n"; + echo " attachment-dl : download attachment for challenge , or interact with it\n"; + echo " external-flag : used for dispatching flags for external containers that cannot be changed easily\n"; + exit; +} + + if(!array_key_exists("game", $query)||gettype($query["game"])!="string"||strlen($query["game"])<=0) { gen_error_400("key \"game\" not found or is empty, or has an invalid type."); exit; @@ -106,20 +121,6 @@ if($action[0]=="attachment-dl") { } -//show the help info if no action matches - -if($action[0]=="help") { - echo "notice: use comma(',') to split args\n"; - echo "all available commands:\n"; - echo " user-panel: display a interactive content for user\n"; - echo " team-info: show your team info as json\n"; - echo " challenge-list: list all challenges as json which are defined internally\n"; - echo " attachment-dl : download attachment for challenge , or interact with it\n"; - echo " external-flag : used for dispatching flags for external containers that cannot be changed easily\n"; - exit; -} - - gen_error_400("unknown action '".$action[0]."'. use 'help' to view help"); exit;