85 lines
2.0 KiB
PHP
85 lines
2.0 KiB
PHP
<?php
|
|
|
|
if(count($action)<2) {
|
|
gen_error_400("missing argument action[1]");
|
|
exit;
|
|
}
|
|
|
|
//change $action[1](cid) based on $alias2cid_l
|
|
|
|
if(count($action)>1&&strlen($action[1])>0) {
|
|
require(__DIR__."/phplib/libvar_alias2cid.php");
|
|
$alias2cid=[];
|
|
if(array_key_exists($game, $alias2cid_l)) {
|
|
$alias2cid=$alias2cid_l[$game];
|
|
}
|
|
unset($alias2cid_l);
|
|
if(array_key_exists($action[1], $alias2cid)) {
|
|
$action[1]=$alias2cid[$action[1]];
|
|
}
|
|
unset($alias2cid);
|
|
}
|
|
|
|
$cid=$action[1];
|
|
|
|
require(__DIR__."/phplib/libvar_cid2tid.php");
|
|
|
|
if(!array_key_exists($game, $cid2tid_l)) {
|
|
gen_error_404("the game ".$game." does not exist");
|
|
exit;
|
|
}
|
|
$gtid_l=$cid2tid_l[$game];
|
|
unset($cid2tid_l);
|
|
|
|
if(!array_key_exists($cid, $gtid_l)) {
|
|
gen_error_404("the cid ".$cid." in game ".$game." does not exist");
|
|
exit;
|
|
}
|
|
|
|
$tid=$gtid_l[$cid];
|
|
|
|
require(__DIR__."/phplib/libvar_tid2proj.php");
|
|
|
|
if(!array_key_exists($tid, $tid2proj_l)) {
|
|
gen_error_500("the tid ".$tid." does not exist");
|
|
exit;
|
|
}
|
|
|
|
$proj=$tid2proj_l[$tid];
|
|
|
|
require(__DIR__."/phplib/libvar_gsec.php");
|
|
|
|
if(!array_key_exists($game, $gsecret_l)) {
|
|
gen_error_400("game '".$game."' is not found in config file.");
|
|
exit;
|
|
}
|
|
|
|
$ginfo=$gsecret_l[$game];
|
|
unset($gsecret_l);
|
|
|
|
/*
|
|
$GLOBALS["game"]=$game;
|
|
$GLOBALS["action"]=$action;
|
|
$GLOBALS["cid"]=$cid;
|
|
$GLOBALS["tid"]=$tid;
|
|
$GLOBALS["proj"]=$proj;
|
|
$GLOBALS["ginfo"]=$ginfo;
|
|
*/
|
|
|
|
$pf=realpath(__DIR__."/".$proj["path"]."/handle_external_flag.php");
|
|
|
|
if(!is_readable($pf)) {
|
|
$pf1=realpath(__DIR__."/".$proj["path"]."/automake_attachment.php");
|
|
if(is_readable($pf1)) {
|
|
gen_error_404("challange ".$proj["name"]." has been found, but the entry handle_external_flag.php does not exist. However, the entry automake_attachment.php was found. ARE YOU SURE this challenge is EXTERNAL?");
|
|
exit;
|
|
}
|
|
gen_error_500("challange ".$proj["name"]." has been found, but the entry handle_external_flag.php does not exist.");
|
|
exit;
|
|
}
|
|
|
|
//the included script should handle the rest of the request
|
|
require($pf);
|
|
|
|
exit;
|