示例#1
0
         $tmp = array('id' => $r->TarId, 'name' => get_text($r->TarDescr));
         if (!in_array($tmp, $json_array['targettypes'])) {
             $json_array['targettypes'][] = $tmp;
         }
         $tmp = array('num' => 1, 'desc' => '1', 'arrows' => (int) $r->EvElimArrows, 'ends' => (int) $r->EvElimEnds);
         if (!in_array($tmp, $json_array['distances'])) {
             $json_array['distances'][] = $tmp;
         }
     }
 } else {
     // THIS IS THE QUALIFICATION PART
     // Retrieve the parameters sent in the call
     $Session = empty($_GET['session']) ? '' : $_GET['session'];
     $Target = sprintf("%03s", $_GET['sesstarget']);
     // Add leading zeroes because the app doesn't send them
     $TargetNo = getGroupedTargets($Session . $Target, $Session);
     // get the targettypes
     $sql = array();
     for ($n = 1; $n <= 8; $n++) {
         $sql[] = "select TarId, TarDescr from Targets\n\t\t\t\t\tinner join TargetFaces on TfT{$n}=TarId and TfTournament={$CompId}\n\t\t\t\t\tinner join Entries on EnTournament={$CompId} and EnTargetFace=TfId\n\t\t\t\t\tinner join Qualifications on EnId=QuId and left(QuTargetNo,4) in ('" . $TargetNo . "') AND EnStatus <= 1 AND EnAthlete=1";
     }
     $SQL = "(" . implode(') UNION (', $sql) . ")";
     $q = safe_r_sql($SQL);
     while ($r = safe_fetch($q)) {
         $tmp = array('id' => $r->TarId, 'name' => get_text($r->TarDescr));
         if (!in_array($tmp, $json_array['targettypes'])) {
             $json_array['targettypes'][] = $tmp;
         }
     }
     // get the distances
     $sql = array();
示例#2
0
<?php

require_once dirname(__FILE__) . '/config.php';
if (empty($_GET['distnum']) and empty($_GET['sesstarget']) and empty($_GET['endnum'])) {
    die;
}
require_once 'Common/Lib/ArrTargets.inc.php';
$TargetNo = getGroupedTargets($_GET['sesstarget']);
$Distance = intval($_GET['distnum']);
$End = intval($_GET['endnum']);
$json_array = array();
$tmp = explode('|', $TargetNo);
if (count($tmp) == 3) {
    // ELIMINATION
    $SQL = "select\n\t\t\tElScore DistScore,\n\t\t\tElGold DistGold,\n\t\t\tElXnine DistXnine,\n\t\t\tsubstr(ElArrowstring, 1+(EvElimArrows*({$End}-1)), EvElimArrows) Arrowstring,\n\t\t\tElScore QuScore, ElGold QuGold, ElXnine QuXnine, concat('{$tmp['0']}|{$tmp['1']}|', ElTargetNo) as QuTargetNo,\n\t\t\tToGoldsChars, ToXNineChars\n\t\t from Eliminations\n\t\t inner join Events on ElEventCode=EvCode and ElTournament=EvTournament and EvTeamEvent=0\n\t\t inner join Tournament on ElTournament=ToId\n\t\t where\n\t\t \tleft(ElTargetNo, 3) in ('{$tmp[2]}')\n\t\t \tand ElEventCode='{$tmp[1]}'\n\t\t \tAND ElElimPhase=" . ($tmp[0][1] - 1) . "\n\t\t \tand ElTournament={$CompId}\n\t\t order by ElTargetNo\n\t\t";
    // 	debug_svela($SQL);
} else {
    // QUALIFICATION
    $SQL = "select\n\t\t\tQuD{$Distance}Score DistScore,\n\t\t\tQuD{$Distance}Gold DistGold,\n\t\t\tQuD{$Distance}Xnine DistXnine,\n\t\t\tsubstr(QuD{$Distance}Arrowstring, 1+(DiArrows*({$End}-1)), DiArrows) Arrowstring,\n\t\t\tQuScore, QuGold, QuXnine, QuTargetNo,\n\t\t\tToGoldsChars, ToXNineChars\n\t\t from Qualifications\n\t\t inner join Entries on EnId=QuId and EnTournament={$CompId}\n\t\t inner join DistanceInformation on DiTournament={$CompId} and DiSession=QuSession and DiDistance={$Distance} and DiType='Q'\n\t\t inner join Tournament on ToId={$CompId}\n\t\t where left(QuTargetNo, 4) in ('{$TargetNo}')\n\t\t order by QuTargetNo\n\t\t";
}
$q = safe_r_sql($SQL);
while ($r = safe_fetch($q)) {
    list($Score, $Golds, $Xnine) = ValutaArrowStringGX($r->Arrowstring, $r->ToGoldsChars, $r->ToXNineChars);
    $json_array[] = array('qutarget' => $r->QuTargetNo, 'endscore' => $Score, 'endgolds' => $Golds, 'endxnine' => $Xnine, 'curscore' => $r->DistScore, 'curgolds' => $r->DistGold, 'curxnine' => $r->DistXnine, 'score' => $r->QuScore, 'golds' => $r->QuGold, 'xnine' => $r->QuXnine);
}
// Return the json structure with the callback function that is needed by the app
SendResult($json_array);