예제 #1
0
$SelArcher = '';
if (!is_null($Command)) {
    if ($Command == 'OK') {
        /*
         * Cerco l'id del tizio.
         */
        $Filter = '';
        // se c'è il codice faccio la query su quello altrimenti sul cognome e nome
        if ($Code != '') {
            $Filter = "AND EnCode=" . StrSafe_DB($Code) . " ";
        } else {
            if ($FirstName != '') {
                $Filter .= "AND EnFirstName LIKE " . Strsafe_DB("%" . $FirstName . "%") . " ";
            }
            if ($Name != '') {
                $Filter .= "AND EnName LIKE " . Strsafe_DB("%" . $Name . "%") . " ";
            }
        }
        if ($Filter != '') {
            $Query = "SELECT " . "EnId,EnCode,EnFirstName,EnName," . "EnDivision,EnClass," . "CoCode,CoName " . "FROM " . "Entries " . "INNER JOIN " . "Countries " . "ON EnCountry=CoId AND EnTournament=CoTournament " . "WHERE " . "EnTournament=" . StrSafe_DB($_SESSION['TourId']) . " " . $Filter . " " . "ORDER BY " . "EnFirstName,EnName ";
            //print $Query;exit;
            $Rs = safe_r_sql($Query);
            /*
             * Se c'è una riga sola tiro fuori l'id e ridireziono subito verso l'altra pagina
             * altrimenti creo l'output per selezionare la persona giusta
             */
            $x = safe_num_rows($Rs);
            if ($x == 1) {
                $MyRow = safe_fetch($Rs);
                header('Location: RankPersonal2.php?Id=' . $MyRow->EnId);
                exit;
예제 #2
0
 /**
  * Importa le sezioni <entry> verificando che siano nella forma giusta
  *
  */
 public function import()
 {
     // il vettore contiene gli indici dei nodi entry non importati
     $badEntries = array();
     // contatore dei nodi importati
     $importedEntries = 0;
     $G = $this->G;
     $X = $this->X;
     if (debug) {
         print 'Phase: ' . $this->getPhase() . '<br>';
         print 'Session: ' . $this->getSession() . '<br>';
         print 'Distance: ' . $this->getDistance() . '<br>';
         print 'End: ' . $this->getEnd() . '<br>';
         print 'Arrows: ' . $this->getArrows() . '<br>';
         print 'MaxArrows: ' . $this->getMaxArrows() . '<br>';
     }
     // Metodo da chimare dopo tutti gli import (in base alla fase importata)
     $postImportMethod = '';
     // parametro per il metodo $postImportMethod
     $postParam = null;
     switch ($this->getPhase()) {
         case ARF::QUALIFICATION:
             $postImportMethod = 'resetQualsShootOff';
             break;
         case ARF::ELIMINATION:
             $postImportMethod = 'resetElimShootOff';
             break;
         case ARF::INDIVIDUAL_FINAL:
         case ARF::TEAM_FINAL:
             $postImportMethod = 'nextPhase';
             break;
     }
     // collezione di entry
     $entries = $this->xmlDoc->getElementsByTagName('entry');
     $c = $entries->length;
     if ($c == 0) {
         $this->setError(1);
         return false;
     }
     // il vettore contiene gli id delle persone a cui occorre azzerrare lo shootoff (QUALIFICATION e ELIMINATION)
     $shootOffIds = array();
     // Vettore delle chiavi per il passaggio di fase (INDIVIDULAL_FINAL TEAM_FINAL)
     $keysNextPhase = array();
     for ($i = 0; $i < $c; ++$i) {
         $arrowString = '##@@##';
         $e = $entries->item($i);
         // verifico la forma del nodo
         if (!$this->verifyEntry($e)) {
             $badEntries[] = $i;
             continue;
         }
         $targetNo = null;
         $position = null;
         $matchNo = null;
         $curPhase = null;
         if ($this->getSession() != 'MATCH') {
             $targetNo = str_pad($e->getElementsByTagName('target')->item(0)->textContent, TargetNoPadding + 1, '0', STR_PAD_LEFT);
         } else {
             $position = $e->getElementsByTagName('position')->item(0)->textContent;
             $event = $e->getElementsByTagName('event')->item(0)->textContent;
             $curPhase = $e->getElementsByTagName('cur_phase')->item(0)->textContent;
         }
         $valid = $e->getElementsByTagName('valid')->item(0)->textContent;
         $endScore = $e->getElementsByTagName('end_total')->item(0)->textContent;
         $points = array();
         $arrows = $e->getElementsByTagName('arrow');
         foreach ($arrows as $a) {
             /*
              * Per ora se non c'è l'attributo num, la freccia viene ignorata
              */
             /*$index=$a->getAttribute('num');
             		if (is_numeric($index))
             			$points[$index]=$a->textContent;*/
             /*
              * Edit del precedente commento:
              * per ora anche se non c'è l'attributo num la freccia viene importata
              */
             $points[] = $a->textContent;
         }
         /*
          * Sicuramente ho il numero corretto di frecce (lo ha verificato $this->verifyNode)
          * quindi posso procedere
          */
         // Cerco la riga nella tabella appropriata
         $query = "";
         switch ($this->getPhase()) {
             case ARF::QUALIFICATION:
                 $query = "SELECT " . "QuId AS AthId,EnStatus AS AthStatus,QuD" . $this->getDistance() . "ArrowString AS ArrowString " . "FROM " . "Qualifications INNER JOIN Entries ON QuId=EnId AND EnTournament=" . $this->getTourId() . " " . "WHERE " . "QuSession=" . StrSafe_DB($this->getSession()) . " AND QuTargetNo=" . StrSafe_DB($this->getSession() . $targetNo) . " ";
                 break;
             case ARF::ELIMINATION:
                 $query = "SELECT " . "ElId AS AthId,EnStatus AS AthStatus,ElArrowString AS ArrowString " . "FROM " . "Eliminations INNER JOIN Entries ON ElId=EnId AND EnTournament=" . $this->getTourId() . " " . "WHERE " . "ElElimPhase=" . StrSafe_DB($this->getSession() - 1) . " AND ElTargetNo=" . StrSafe_DB($targetNo) . " ";
                 break;
             case ARF::INDIVIDUAL_FINAL:
                 if ($this->getSession() != 'MATCH') {
                     $query = "SELECT " . "FinAthlete AS AthId,IF(FinAthlete!=0,0,9) AS AthStatus,FinMatchNo AS MatchNo,GrPhase,FinEvent AS Event,FSTarget,FinArrowString AS ArrowString, CONCAT(FSScheduledDate,' ',FSScheduledTime) AS Scheduled " . "FROM " . "Finals INNER JOIN FinSchedule ON FinMatchNo=FSMatchNo AND FinTournament=FSTournament " . "AND FinEvent=FSEvent AND FSTeamEvent=0 " . "INNER JOIN Grids ON FinMatchNo=GrMatchNo " . "WHERE " . "FinTournament=" . $this->getTourId() . " AND " . "FSTarget='" . substr($targetNo, 0, -1) . "' AND " . "CONCAT(FSScheduledDate,' ',FSScheduledTime)=" . StrSafe_DB($this->getSession()) . " " . "ORDER BY " . "FinEvent,FinMatchNo ASC " . "LIMIT " . (substr($targetNo, -1) == 'A' ? 0 : 1) . ",1 ";
                     //print $query;exit;
                 } else {
                     $query = "SELECT " . "FinAthlete AS AthId,IF(FinAthlete!=0,0,9) AS AthStatus,FinMatchNo AS MatchNo,GrPhase,FinEvent AS Event,FSTarget,FinArrowString AS ArrowString " . "FROM " . "Finals INNER JOIN FinSchedule ON FinMatchNo=FSMatchNo AND FinTournament=FSTournament " . "AND FinEvent=FSEvent AND FSTeamEvent=0 " . "INNER JOIN Grids ON FinMatchNo=GrMatchNo " . "WHERE " . "FinTournament=" . $this->getTourId() . " AND " . "GrPosition=" . StrSafe_DB($position) . " AND " . "GrPhase=" . StrSafe_DB($curPhase) . " AND " . "FinEvent=" . StrSafe_DB($event) . " " . "ORDER BY " . "FinEvent,FinMatchNo ASC ";
                 }
                 break;
             case ARF::TEAM_FINAL:
                 if ($this->getSession() != 'MATCH') {
                     $query = "SELECT TfTeam AS AthId,IF(TfTeam!=0,0,9) AS AthStatus,TfMatchNo AS MatchNo,GrPhase,TfEvent AS Event,FSTarget,TfArrowString AS ArrowString " . "FROM TeamFinals INNER JOIN FinSchedule ON TfMatchNo=FSMatchNo AND TfTournament=FSTournament " . "AND TfEvent=FSEvent AND FSTeamEvent=1 " . "INNER JOIN Grids ON TfMatchNo=GrMatchNo " . "WHERE TfTournament=" . $this->getTourId() . " AND " . "FSTarget='" . substr($targetNo, 0, -1) . "' AND " . "CONCAT(FSScheduledDate,' ',FSScheduledTime)=" . StrSafe_DB($this->getSession()) . " " . "ORDER BY TfEvent,TfMatchNo ASC " . "LIMIT " . (substr($targetNo, -1) == 'A' ? 0 : 1) . ",1";
                 } else {
                     $query = "SELECT TfTeam AS AthId,IF(TfTeam!=0,0,9) AS AthStatus,TfMatchNo AS MatchNo,GrPhase,TfEvent AS Event,FSTarget,TfArrowString AS ArrowString " . "FROM TeamFinals INNER JOIN FinSchedule ON TfMatchNo=FSMatchNo AND TfTournament=FSTournament " . "AND TfEvent=FSEvent AND FSTeamEvent=1 " . "INNER JOIN Grids ON TfMatchNo=GrMatchNo " . "WHERE TfTournament=" . $this->getTourId() . " AND " . "GrPosition=" . StrSafe_DB($position) . " AND " . "GrPhase=" . StrSafe_DB($curPhase) . " AND " . "TfEvent=" . StrSafe_DB($event) . " " . "ORDER BY TfEvent,TfMatchNo ASC ";
                 }
                 break;
         }
         if (debug) {
             print $query . '<br><br>';
         }
         $rs = safe_r_sql($query);
         $myRow = null;
         $good = false;
         // true se il nodo è ok
         if ($rs) {
             // non trovo il bersaglio in db
             if (safe_num_rows($rs) == 0) {
                 if ($valid == 1) {
                     $badEntries[] = $i;
                     continue;
                 } else {
                     continue;
                 }
             } elseif (safe_num_rows($rs) == 1) {
                 $myRow = safe_fetch($rs);
                 // la tabella dice che tira
                 if ($myRow->AthStatus <= 1) {
                     // ma il file dice no
                     if ($valid == 0) {
                         $badEntries[] = $i;
                         continue;
                     } elseif ($valid == 1) {
                         $arrowString = str_pad($myRow->ArrowString, $this->getMaxArrows(), ' ', STR_PAD_RIGHT);
                     }
                 } else {
                     // il file è d'accordo
                     if ($valid == 0) {
                         continue;
                     } else {
                         $badEntries[] = $i;
                         continue;
                     }
                 }
             }
         } else {
             $badEntries[] = $i;
             continue;
         }
         // Creo la nuova arrowstring e verifico il totale della volee
         $subArrowString = '';
         $totEnd = 0;
         foreach ($points as $value) {
             $value2write = ' ';
             // inizializzato a blank
             if ($value != '#') {
                 $totEnd += $value != 'M' && $value != 'm' ? $value : 0;
                 $value2write = GetLetterFromPrint($value);
             }
             // Questa condizione in realtà sarebbe un errore
             if ($value2write == '') {
                 $value2write = ' ';
             }
             $subArrowString .= $value2write;
         }
         // se il totale dichiarato in end_total non è coerente con i punti passati, il nodo non viene importato
         if ($endScore != $totEnd) {
             $badEntries[] = $i;
             continue;
         }
         if (debug) {
             print '..' . $subArrowString . '..(' . strlen($subArrowString) . ')<br>';
         }
         $Ip = $this->getArrows() * ($this->getEnd() - 1);
         $Fp = $Ip + ($this->getArrows() - 1);
         $arrowString = substr_replace($arrowString, $subArrowString, $Ip, strlen($subArrowString));
         //print $arrowString . '<br><br>';
         if (debug) {
             print '..' . $arrowString . '..<br><br>';
         }
         // Posso calcolare i punti
         $score = 0;
         $gold = 0;
         $xnine = 0;
         if ($this->getPhase() == ARF::QUALIFICATION || $this->getPhase() == ARF::ELIMINATION) {
             list($score, $gold, $xnine) = ValutaArrowStringGX($arrowString, $G, $X);
         } else {
             $score = ValutaArrowString($arrowString);
         }
         if (debug) {
             print 'Score: ' . $score . '<br>';
             print 'Gold: ' . $gold . '<br>';
             print 'Xnine: ' . $xnine . '<br><br>';
         }
         // posso fare l'update
         $query = "";
         switch ($this->getPhase()) {
             case ARF::QUALIFICATION:
                 $query = "UPDATE " . "Qualifications " . "SET " . "QuD" . $this->getDistance() . "Score=" . StrSafe_DB($score) . "," . "QuD" . $this->getDistance() . "Gold=" . StrSafe_DB($gold) . "," . "QuD" . $this->getDistance() . "Xnine=" . StrSafe_DB($xnine) . ", " . "QuD" . $this->getDistance() . "ArrowString=" . StrSafe_DB($arrowString) . ", " . "QuScore=QuD1Score+QuD2Score+QuD3Score+QuD4Score+QuD5Score+QuD6Score+QuD7Score+QuD8Score," . "QuGold=QuD1Gold+QuD2Gold+QuD3Gold+QuD4Gold+QuD5Gold+QuD6Gold+QuD7Gold+QuD8Gold," . "QuXnine=QuD1Xnine+QuD2Xnine+QuD3Xnine+QuD4Xnine+QuD5Xnine+QuD6Xnine+QuD7Xnine+QuD8Xnine, " . "QuTimestamp=" . StrSafe_DB(date('Y-m-d H:i:s')) . " " . "WHERE " . "QuId=" . StrSafe_DB($myRow->AthId) . " ";
                 if (debug) {
                     print $query . '<br><br>';
                 }
                 $rs = safe_w_sql($query);
                 if ($rs) {
                     ++$importedEntries;
                     $shootOffIds[] = StrSafe_DB($myRow->AthId);
                 } else {
                     $badEntries[] = $i;
                     continue;
                 }
                 break;
             case ARF::ELIMINATION:
                 $query = "UPDATE " . "Eliminations " . "SET " . "ElScore=" . Strsafe_DB($score) . "," . "ElGold=" . Strsafe_DB($gold) . "," . "ElXnine=" . Strsafe_DB($xnine) . ", " . "ElArrowString=" . StrSafe_DB($arrowString) . " " . "WHERE " . "ElId=" . StrSafe_DB($myRow->AthId) . " AND ElElimPhase=" . StrSafe_DB($this->getSession() - 1) . " ";
                 //print $query . '<br><br>';
                 $rs = safe_w_sql($query);
                 if ($rs) {
                     ++$importedEntries;
                     $shootOffIds[] = StrSafe_DB($myRow->AthId);
                 } else {
                     $badEntries[] = $i;
                     continue;
                 }
                 break;
             case ARF::INDIVIDUAL_FINAL:
                 $query = "UPDATE Finals SET " . "FinScore=" . StrSafe_DB($score) . "," . "FinArrowString=" . StrSafe_DB($arrowString) . "," . "FinTie=0," . "FinTiebreak=NULL," . "FinTiePosition=NULL " . "WHERE FinMatchNo=" . StrSafe_DB($myRow->MatchNo) . " AND " . "FinEvent=" . StrSafe_DB($myRow->Event) . " AND FinTournament=" . $this->getTourId() . " ";
                 $rs = safe_w_sql($query);
                 //print $query . '<br><br>';
                 if ($rs) {
                     ++$importedEntries;
                     $keysNextPhase[$myRow->GrPhase]["'" . $myRow->Event . "'"] = 1;
                 } else {
                     $badEntries[] = $i;
                     continue;
                 }
                 break;
             case ARF::TEAM_FINAL:
                 $query = "UPDATE TeamFinals SET " . "TfScore=" . StrSafe_DB($score) . "," . "TfArrowString=" . StrSafe_DB($arrowString) . "," . "TfTie=0," . "TfTiebreak=NULL," . "TfTiePosition=NULL " . "WHERE TfMatchNo=" . StrSafe_DB($myRow->MatchNo) . " AND " . "TfEvent=" . StrSafe_DB($myRow->Event) . " AND TfTournament=" . $this->getTourId() . " ";
                 $rs = safe_w_sql($query);
                 //print $query . '<br><br>';
                 if ($rs) {
                     ++$importedEntries;
                     $keysNextPhase[$myRow->GrPhase]["'" . $myRow->Event . "'"] = 1;
                 } else {
                     $badEntries[] = $i;
                     continue;
                 }
                 break;
         }
     }
     //exit;
     // Provo a post-processare i dati importati
     switch ($this->getPhase()) {
         case ARF::QUALIFICATION:
         case ARF::ELIMINATION:
             $postParam = $shootOffIds;
             break;
         case ARF::INDIVIDUAL_FINAL:
         case ARF::TEAM_FINAL:
             $postParam = $keysNextPhase;
             break;
     }
     $postError = false;
     // true se la prossima chiamata ritorna un errore
     if ($this->getPhase() == ARF::QUALIFICATION || $this->getPhase() == ARF::ELIMINATION) {
         call_user_func(array($this, $postImportMethod), $postParam, &$postError);
     } elseif ($this->getPhase() == ARF::INDIVIDUAL_FINAL || $this->getPhase() == ARF::TEAM_FINAL) {
         $team = $this->getPhase() == ARF::INDIVIDUAL_FINAL ? 0 : 1;
         call_user_func(array($this, $postImportMethod), $postParam, $team, &$postError);
     }
     return array($this->getTourCode(), $importedEntries, $badEntries, $postError);
 }
예제 #3
0
     $y = imagesy($im) - $h - 2;
 }
 $lineColor = imagecolorallocate($im, 255, 255, 0);
 imagesetthickness($im, 3);
 if (!empty($_REQUEST['get']) && $_REQUEST['get'] == 1 && !IsBlocked(BIT_BLOCK_ACCREDITATION)) {
     setcookie("getPhotoX", $x, time() + 24 * 60);
     setcookie("getPhotoY", $y, time() + 24 * 60);
     setcookie("getPhotoW", $w, time() + 24 * 60);
     $dest = imagecreatetruecolor(MAX_WIDTH, MAX_HEIGHT);
     if (!imagecopyresampled($dest, $im, 0, 0, $x, $y, MAX_WIDTH, MAX_HEIGHT, $w, $h)) {
         $errMsg = get_text('PhotoDimError', 'Tournament', array(MAX_WIDTH, MAX_HEIGHT));
     } else {
         if (!empty($athId)) {
             imagejpeg($dest, '/tmp/salvala', 90);
             $image = addslashes(base64_encode(file_get_contents('/tmp/salvala')));
             $query = "INSERT INTO Photos (PhEnId,PhPhoto,PhPhotoEntered) " . "VALUES(" . Strsafe_DB($athId) . ", " . "'" . $image . "', " . "NOW()" . ") " . "ON DUPLICATE KEY UPDATE " . "PhPhoto='" . $image . "', PhPhotoEntered=NOW() ";
             //print $query . '<br>';
             $rs = safe_w_sql($query);
             $lineColor = imagecolorallocate($im, 0, 0, 255);
             imagesetthickness($im, 10);
             if ($tmp = @imagecreatefromstring(base64_decode($image))) {
                 Imagejpeg($tmp, $CFG->DOCUMENT_PATH . 'TV/Photos/' . $_SESSION['TourCodeSafe'] . '-En-' . $athId . '.jpg', 95);
             }
         }
     }
 }
 imagerectangle($im, $x, $y, $x + $w, $y + $h, $lineColor);
 header("Content-type: image/png");
 imagepng($im);
 imagedestroy($im);
 fclose($f);