コード例 #1
0
ファイル: AddEvent.php プロジェクト: brian-nelson/ianseo
	Aggiorna il campo di Events passato in querystring.
*/
define('debug', false);
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
require_once 'Common/Fun_FormatText.inc.php';
if (!CheckTourSession() || !isset($_REQUEST['New_EvCode']) || !isset($_REQUEST['New_EvEventName']) || !isset($_REQUEST['New_EvProgr']) || !isset($_REQUEST['New_EvMatchMode']) || !isset($_REQUEST['New_EvFinalFirstPhase']) || !isset($_REQUEST['New_EvFinalTargetType']) || !isset($_REQUEST['New_EvTargetSize']) || !isset($_REQUEST['New_EvDistance'])) {
    print get_text('CrackError');
    exit;
}
$Errore = 0;
$xml = '';
if (!IsBlocked(BIT_BLOCK_TOURDATA)) {
    // Aggiungo la nuova riga
    $Insert = "INSERT INTO Events (EvCode,EvTeamEvent,EvTournament,EvEventName,EvProgr,EvShootOff,EvFinalFirstPhase,EvFinalTargetType,EvTargetSize,EvDistance,EvMatchMode) " . "VALUES(" . StrSafe_DB($_REQUEST['New_EvCode']) . "," . StrSafe_DB('1') . "," . StrSafe_DB($_SESSION['TourId']) . "," . StrSafe_DB($_REQUEST['New_EvEventName']) . "," . StrSafe_DB($_REQUEST['New_EvProgr']) . "," . StrSafe_DB('0') . "," . StrSafe_DB($_REQUEST['New_EvFinalFirstPhase']) . "," . StrSafe_DB($_REQUEST['New_EvFinalTargetType']) . ", " . StrSafe_DB($_REQUEST['New_EvTargetSize']) . ", " . StrSafe_DB($_REQUEST['New_EvDistance']) . ", " . StrSafe_DB($_REQUEST['New_EvMatchMode']) . " " . ") ";
    $RsIns = safe_w_sql($Insert);
    set_qual_session_flags();
    if (debug) {
        print $Insert . '<br>';
    }
    if (!$RsIns) {
        $Errore = 1;
    } else {
        /*
         *  imposto i parametri delle frecce.
         *  Sicuramente ho un evento team cumulativo e non mixed perchè il flag del mixed si
         *  gestisce dopo la creazione dell'evento
         */
        $MySql = "UPDATE " . "Events " . "SET " . "EvElimEnds=4,EvElimArrows=6,EvElimSO=3,EvFinEnds=4,EvFinArrows=6,EvFinSO=3 " . "WHERE " . "EvTeamEvent=1 AND EvTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND EvCode=" . StrSafe_DB($_REQUEST['New_EvCode']);
        $Rs = safe_w_sql($MySql);
        // le query che seguono mi servono per generare la tendine dinamiche
        $StartPhase = -1;
コード例 #2
0
 /**
  * Viene chiamata per azzerare gli shootoff delle qualifiche
  *
  * @param array int $ids: vettore degli id di cui bisogna azzerare lo shootoof
  * @param boolean &$error: true se il post processo genera un errore
  */
 private function resetQualsShootOff($ids, &$error)
 {
     /*
      * Se non ci sono ids buoni non ho shootoff, non ho la generazione di nulla
      * e il post-processing fallisce
      */
     if (count($ids) == 0) {
         $error = true;
         return;
     }
     // shootoff
     $query = "UPDATE Events INNER JOIN EventClass ON EvCode=EcCode AND (EvTeamEvent='0' OR EvTeamEvent='1') AND EcTournament=" . $this->getTourId() . " " . "INNER JOIN Entries ON EcDivision=EnDivision AND EcClass=EnClass  AND EnId IN(" . join(',', $ids) . ") " . "SET EvShootOff='0' " . "WHERE (EvTeamEvent='0' OR EvTeamEvent='1') AND EvTournament=" . $this->getTourId() . " ";
     $rs = safe_w_sql($query);
     set_qual_session_flags();
     if (debug) {
         print $query . '<br><br>';
     }
     // rank e squadre
     $query = "SELECT CONCAT(EnDivision,EnClass) AS MyEvent, EnCountry as MyTeam,EnDivision,EnClass " . "FROM Entries " . "WHERE EnId IN(" . join(',', $ids) . ") AND EnTournament=" . $this->getTourId() . " ";
     $rs = safe_r_sql($query);
     if (debug) {
         print $query . '<br><br>';
     }
     if (safe_num_rows($rs) > 0) {
         while ($rr = safe_fetch($rs)) {
             $Evento = $rr->MyEvent;
             $Category = $rr->MyEvent;
             $Societa = $rr->MyTeam;
             $Div = $rr->EnDivision;
             $Cl = $rr->EnClass;
             // rank distanza
             if (CalcQualRank($this->getDistance(), $Evento)) {
                 $error = true;
             } else {
                 // rank totale
                 if (CalcQualRank(0, $Evento)) {
                     $error = true;
                 } else {
                     // squadre
                     if (MakeTeams($Societa, $Category)) {
                         $error = true;
                     } else {
                         if (MakeTeamsAbs($Societa, $Div, $Cl)) {
                             $error = true;
                         }
                     }
                 }
             }
         }
     } else {
         $error = true;
     }
 }
コード例 #3
0
/**
 * ResetShootoff().
 * resetta gli shootoff di un evento e le IndRankFinal e TeamRankFinal (ora non presente)
 *
 * Una combinazione senza senso di parametri verrà ignorata
 *
 * @param string $event: evento interessato
 * @param string $team: 0 evento ind 1 evento team
 * @param int[] $type: tipo di shootoff
 * 		 0: azzera tutto
 * 		 1: azzera partendo dal II girone
 * 		 2: azzera solo le finali
 * 		 3: azzera solo le finali e ignora il reset della rankfinal dei gironi
 * @return bool: true se ok false altrimenti.
 */
function ResetShootoff($event, $team = 0, $type = 0)
{
    $ret = true;
    if ($event == '') {
        $ret = false;
    } else {
        if (!in_array($team, array(0, 1))) {
            $ret = false;
        } else {
            if (!in_array($type, array(0, 1, 2, 3))) {
                $ret = false;
            } else {
                // rimuovi le virgolette singole!!!!
                $event = preg_replace('#^\'(.*)\'$#', '$1', $event);
                $q = "\r\n\t\t\t\t\t\tUPDATE\r\n\t\t\t\t\t\t\tEvents\r\n\t\t\t\t\t\tSET\r\n\t\t\t\t\t";
                if ($type == 0) {
                    $q .= "EvShootOff='0',EvE1ShootOff='0',EvE2ShootOff='0' ";
                } elseif ($type == 1) {
                    $q .= "EvShootOff='0',EvE2ShootOff='0' ";
                } elseif ($type == 2 || $type == 3) {
                    $q .= "EvShootOff='0' ";
                }
                $q .= "\r\n\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\tEvTournament={$_SESSION['TourId']} AND EvTeamEvent={$team} AND EvCode='{$event}'\r\n\t\t\t\t\t";
                //print $q.'<br><br>';
                //					$mtime = microtime();
                //					$mtime = explode(' ', $mtime);
                //					$mtime = $mtime[1] + $mtime[0];
                //					$starttime = $mtime;
                $r = safe_w_sql($q);
                //					$mtime = microtime();
                //					$mtime = explode(" ", $mtime);
                //					$mtime = $mtime[1] + $mtime[0];
                //					$endtime = $mtime;
                //					print $event . ' ' . $team . ' Reset flag: ' .($endtime - $starttime).'<br>';
                if (!$r) {
                    $ret = false;
                } else {
                    /*
                     *  Sego le RankFinal	(e segherò le TeamRankFinal).
                     *  A seconda dei tipi richiesti dovrò azzerare certi pezzi di rank.
                     *
                     *  Se $type==0 devo distruggere tutta la rank dell'evento
                     *
                     *  Se $type==1 devo azzerare la rank partendo dal II girone elim
                     *
                     *  Se $type==2 devo azzerare solo la rank delle finali
                     */
                    $date = date('Y-m-d H:i:s');
                    $q = "";
                    if ($type == 0 || $type == 3) {
                        if ($team == 0) {
                            $q = "UPDATE Individuals " . "SET " . "IndRankFinal=0, " . "IndTimestampFinal='{$date}' " . "WHERE " . "IndTournament={$_SESSION['TourId']} AND IndEvent='{$event}' ";
                        } elseif ($team == 1) {
                            $q = "UPDATE Teams " . "SET " . "TeFinal=0, " . "TeRankFinal=0," . "TeTimeStampFinal=0 " . "WHERE " . "TeTournament={$_SESSION['TourId']} AND TeEvent='{$event}' AND TeFinEvent=1 ";
                        }
                    } elseif ($type == 1) {
                        // non ho team!
                        if ($team == 0) {
                            $q = "UPDATE Individuals INNER JOIN Eliminations ON IndTournament=ElTournament AND IndId=ElId AND IndEvent=ElEventCode AND ElElimPhase=0 " . "SET " . "IndRankFinal=0, " . "IndTimestampFinal='{$date}' " . "WHERE " . "IndTournament={$_SESSION['TourId']} AND IndEvent='{$event}' ";
                        }
                    } elseif ($type == 2) {
                        // non ho team!
                        if ($team == 0) {
                            $q = "UPDATE Individuals INNER JOIN Eliminations ON IndTournament=ElTournament AND IndId=ElId AND IndEvent=ElEventCode AND ElElimPhase=1 " . "SET " . "IndRankFinal=0, " . "IndTimestampFinal='{$date}' " . "WHERE " . "IndTournament={$_SESSION['TourId']} AND IndEvent='{$event}' ";
                        }
                    }
                    //print $q.'<br><br>';
                    $ret = safe_w_sql($q) !== false;
                    //						$mtime = microtime();
                    //						$mtime = explode(" ", $mtime);
                    //						$mtime = $mtime[1] + $mtime[0];
                    //						$endtime = $mtime;
                    //						print $event . ' ' . $team . ' Reset rank finals: ' .($endtime - $starttime).'<br>';
                    set_qual_session_flags();
                }
            }
        }
    }
    return $ret;
}
コード例 #4
0
ファイル: Globals.inc.php プロジェクト: brian-nelson/ianseo
/**
 * Crea una sessione del torneo
 * @param $TourId: id del torneo
 * @return true se ci riesce e false altrimenti
 */
function CreateTourSession($TourId)
{
    $Select = "SELECT" . " Tournament.*" . ", UNIX_TIMESTAMP(ToWhenFrom) AS ToWhenFromUTS" . ", DATE_FORMAT(ToWhenFrom,'" . get_text('DateFmtDB') . "') AS DtFrom" . ", UNIX_TIMESTAMP(ToWhenTo) AS ToWhenToUTS" . ", DATE_FORMAT(ToWhenTo,'" . get_text('DateFmtDB') . "') AS DtTo" . ", ToTypeName AS TtName" . ", ToElimination AS TtElimination " . "FROM Tournament " . "WHERE ToId=" . StrSafe_DB($TourId) . " ";
    //print $Select;
    $Rs = safe_r_sql($Select);
    if (safe_num_rows($Rs) == 1) {
        $debug = $_SESSION['debug'];
        $debmode = !empty($_SESSION['debug-mode']) ? $_SESSION['debug-mode'] : '';
        $_SESSION = array();
        $_SESSION['debug'] = $debug;
        $_SESSION['debug-mode'] = $debmode;
        $MyRow = safe_fetch($Rs);
        $_SESSION['TourId'] = $MyRow->ToId;
        $_SESSION['TourType'] = $MyRow->ToType;
        $_SESSION['TourPrintLang'] = $MyRow->ToPrintLang;
        $_SESSION['TourLocRule'] = $MyRow->ToLocRule;
        $_SESSION['TourCode'] = $MyRow->ToCode;
        $_SESSION['TourCodeSafe'] = preg_replace('/[^a-z0-9_.-]+/sim', '', $MyRow->ToCode);
        $_SESSION['TourCollation'] = $MyRow->ToCollation;
        $_SESSION['TourName'] = $MyRow->ToName;
        $_SESSION['TourWhere'] = $MyRow->ToWhere;
        $_SESSION['TourRealWhenFrom'] = $MyRow->ToWhenFrom;
        $_SESSION['TourRealWhenTo'] = $MyRow->ToWhenTo;
        $_SESSION['TourWhenFrom'] = $MyRow->DtFrom;
        $_SESSION['TourWhenTo'] = $MyRow->DtTo;
        $_SESSION['ToWhenFromUTS'] = $MyRow->ToWhenFromUTS;
        $_SESSION['ToWhenToUTS'] = $MyRow->ToWhenToUTS;
        $_SESSION['ToPaper'] = $MyRow->ToPrintPaper;
        // parametri per le credenziali di upload verso ianseo.net
        $_SESSION['OnlineId'] = 0;
        $_SESSION['OnlineEventCode'] = 0;
        $_SESSION['OnlineAuth'] = 0;
        //Parametro per il Padding dei paglioni
        $_SESSION['TargetPadding'] = 2;
        // sets the collation for the tournament
        set_collation($MyRow->ToCollation);
        // if a collation is set for a tournament, this will be the default whatever language is chosen
        $_SESSION['COLLATION-LOCK'] = $MyRow->ToCollation != '';
        // Defines if a tournament is ORIS compliant or not
        $_SESSION['ISORIS'] = $MyRow->ToIsORIS;
        $q = "\r\n\t\t\tSELECT IFNULL(MAX(SesTar4Session),0) AS max_session\r\n\t\t\tFROM\r\n\t\t\t\tSession\r\n\t\t\tWHERE\r\n\t\t\t\tSesTournament={$MyRow->ToId}\r\n\t\t";
        $t = safe_r_sql($q);
        if ($u = safe_fetch($t)) {
            if ($u->max_session >= 100) {
                $_SESSION['TargetPadding'] = 3;
            } else {
                $_SESSION['TargetPadding'] = 2;
            }
        }
        $_SESSION['ClickMenu'] = GetParameter('OnClickMenu');
        // parametri per gli spareggi... e i menu
        set_qual_session_flags();
        return $MyRow;
    }
    return false;
}
コード例 #5
0
function RecalculateShootoffAndTeams($indFEvent, $teamFEvent, $country, $div, $cl, $zero)
{
    $Errore = 0;
    if ($zero) {
        return 0;
    }
    // scopro se $div e $cl sono per gli atleti
    $q = "\n\t\tSELECT\n\t\t\t(DivAthlete AND ClAthlete) AS isAth\n\t\tFROM\n\t\t\tDivisions\n\t\t\tINNER JOIN\n\t\t\t\tClasses\n\t\t\tON DivTournament=ClTournament\n\t\tWHERE\n\t\t\tDivTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND (DivAthlete AND ClAthlete)=1\n\t\t\tAND DivId=" . StrSafe_DB($div) . " AND ClId=" . StrSafe_DB($cl) . "\n\t";
    //print $q.'<br><br>';
    $rs = safe_r_sql($q);
    if ($rs && safe_num_rows($rs) == 1) {
        $queries = array();
        $date = date('Y-m-d H:i:s');
        // shootoff degli individuali a zero (e reset della RankFinal)
        if ($indFEvent == 1) {
            $queries[] = "\n\t\t\t\tUPDATE\n\t\t\t\t\tEvents\n\t\t\t\t\tINNER JOIN\n\t\t\t\t\t\tEventClass\n\t\t\t\t\tON EvCode=EcCode AND EvTeamEvent='0' AND EvTournament=EcTournament AND EcTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND\n\t\t\t\t\tEcDivision=" . StrSafe_DB($div) . " AND EcClass=" . StrSafe_DB($cl) . "\n\t\t\t\t\tINNER JOIN\n\t\t\t\t\t\tIndividuals\n\t\t\t\t\tON EvCode=IndEvent AND EvTournament=IndTournament AND EvTeamEvent=0 AND EvTournament={$_SESSION['TourId']}\n\t\t\t\tSET\n\t\t\t\t\tEvShootOff='0',\n\t\t\t\t\tEvE1ShootOff='0',\n\t\t\t\t\tEvE2ShootOff='0',\n\t\t\t\t\tIndRankFinal=0,\n\t\t\t\t\tIndTimestampFinal='{$date}'\n\t\t\t";
        }
        // shootoff dei team a zero
        if ($teamFEvent == 1) {
            $queries[] = "\n\t\t\t\tUPDATE\n\t\t\t\t\tEvents\n\t\t\t\t\tINNER JOIN\n\t\t\t\t\t\tEventClass\n\t\t\t\t\tON EvCode=EcCode AND EvTeamEvent='1' AND EvTournament=EcTournament AND EcTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND\n\t\t\t\t\tEcDivision=" . StrSafe_DB($div) . " AND EcClass=" . StrSafe_DB($cl) . "\n\t\t\t\tSET\n\t\t\t\t\tEvShootOff='0',\n\t\t\t\t\tEvE1ShootOff='0',\n\t\t\t\t\tEvE2ShootOff='0'\n\t\t\t";
        }
        foreach ($queries as $q) {
            //print $q.'<br><br>';
            $rs = safe_w_sql($q);
        }
        set_qual_session_flags();
        // teams
        if (MakeTeams($country, $div . $cl)) {
            $Errore = 1;
            //print 'team error';
        } else {
            if (MakeTeamsAbs($country, $div, $cl)) {
                $Errore = 1;
                //print 'absteam error';
            }
        }
    }
    //exit;
    return $Errore;
}