require_once 'Tournament/Fun_Tournament.local.inc.php'; if (!CheckTourSession() || !isset($_REQUEST['New_ClId']) || !isset($_REQUEST['New_ClSex']) || !isset($_REQUEST['New_ClDescription']) || !isset($_REQUEST['New_ClAthlete']) || !isset($_REQUEST['New_ClViewOrder']) || !isset($_REQUEST['New_ClAgeFrom']) || !isset($_REQUEST['New_ClAgeTo']) || !isset($_REQUEST['New_ClValidClass']) || !isset($_REQUEST['New_ClValidDivision'])) { print get_text('CrackError'); exit; } $Errore = intval(IsBlocked(BIT_BLOCK_TOURDATA) && !defined('dontEditClassDiv')); $MsgErrore = ''; if (!$Errore) { if (!is_numeric($_REQUEST['New_ClAgeFrom']) || !is_numeric($_REQUEST['New_ClAgeTo']) || $_REQUEST['New_ClAgeFrom'] <= 0 || $_REQUEST['New_ClAgeTo'] <= 0 || $_REQUEST['New_ClAgeFrom'] > $_REQUEST['New_ClAgeTo']) { $Errore = 1; } } if (!$Errore) { // Aggiungo la nuova riga $Insert = "INSERT IGNORE INTO Classes (ClId,ClTournament,ClDescription,ClAthlete,ClViewOrder,ClAgeFrom,ClAgeTo,ClValidClass,ClDivisionsAllowed,ClSex) " . "VALUES(" . StrSafe_DB($_REQUEST['New_ClId']) . "," . StrSafe_DB($_SESSION['TourId']) . "," . StrSafe_DB($_REQUEST['New_ClDescription']) . "," . StrSafe_DB(intval($_REQUEST['New_ClAthlete'])) . "," . StrSafe_DB($_REQUEST['New_ClViewOrder']) . ", " . StrSafe_DB($_REQUEST['New_ClAgeFrom']) . ", " . StrSafe_DB($_REQUEST['New_ClAgeTo']) . ", " . StrSafe_DB(CreateValidClass($_REQUEST['New_ClId'], $_REQUEST['New_ClValidClass'])) . ", " . StrSafe_DB($_REQUEST['New_ClValidDivision']) . ", " . StrSafe_DB($_REQUEST['New_ClSex']) . " " . ") "; $RsIns = safe_w_sql($Insert); //duplicate entries is OK if (!safe_w_affected_rows()) { $Errore = 2; $MsgErrore = get_text('DuplicateEntry', 'Tournament'); } } header('Content-Type: text/xml'); print '<response>' . "\n"; print '<error>' . $Errore . '</error>' . "\n"; print '<errormsg><![CDATA[' . $MsgErrore . ']]></errormsg>' . "\n"; print '<new_clid><![CDATA[' . $_REQUEST['New_ClId'] . ']]></new_clid>' . "\n"; print '<new_cldescr><![CDATA[' . ManageHTML($_REQUEST['New_ClDescription']) . ']]></new_cldescr>' . "\n"; print '<new_clathleteyes><![CDATA[' . ManageHTML(get_text('Yes')) . ']]></new_clathleteyes>' . "\n"; print '<new_clathleteno><![CDATA[' . ManageHTML(get_text('No')) . ']]></new_clathleteno>' . "\n"; print '<new_clathlete><![CDATA[' . $_REQUEST['New_ClAthlete'] . ']]></new_clathlete>' . "\n";
/** * Serve per intefacciarsi a ProcessSetupFile(...) * * @param Int $Id: id del torneo * * @return void * */ function GetSetupFile($TourId, $ToType = 0, $Lang = '', $SubRule = '1', $useOldRules = false) { static $ciclo = 0; global $CFG; if (!$ciclo) { // reset data if any $ToDelete = array('Divisions' => 'Div', 'Classes' => 'Cl', 'SubClass' => 'Sc', 'TournamentDistances' => 'Td', 'DistanceInformation' => 'Di', 'Eliminations' => 'El', 'Events' => 'Ev', 'EventClass' => 'Ec', 'Finals' => 'Fin', 'TeamFinals' => 'Tf', 'TargetFaces' => 'Tf'); foreach ($ToDelete as $table => $pre) { safe_w_sql("delete from {$table} where {$pre}Tournament = {$TourId}"); } /** search for $ToType file, and for localisation $Lang **/ // cerco il file per il tipo localizzato per $Lang if (file_exists($file = $CFG->DOCUMENT_PATH . 'Modules/Sets/' . $Lang . '/Setup_' . $ToType . '_' . $Lang . '.php') or file_exists($file = $CFG->DOCUMENT_PATH . 'Modules/Sets/FITA/Setup_' . $ToType . '.php')) { if (empty($SubRule)) { $SubRule = 1; } require_once $file; } else { die('No Setup File!'); } // reset entries fields if any safe_w_sql("update Entries set EnDivision='' where EnTournament={$TourId} and EnDivision not in (select DivId from Divisions where DivTournament={$TourId})"); safe_w_sql("update Entries set EnClass='' where EnTournament={$TourId} and EnClass not in (select ClId from Classes where ClTournament={$TourId})"); safe_w_sql("update Entries set EnAgeClass='' where EnTournament={$TourId} and EnAgeClass not in (select ClId from Classes where ClTournament={$TourId})"); safe_w_sql("update Entries set EnSubClass='' where EnTournament={$TourId} and EnSubClass not in (select ScId from SubClass where ScTournament={$TourId})"); safe_w_sql("update Entries set EnTargetFace='' where EnTournament={$TourId} and EnTargetFace not in (select TfId from TargetFaces where TfTournament={$TourId})"); } $ciclo++; }
function SetElimArrowValue($Phase, $Event, $Target, $ArIndex, $ArSymbol, $Output = 'XML', $CompId = '') { require_once 'Common/Lib/Obj_RankFactory.php'; $JsonResult = array(); $JsonResult['error'] = 1; $JsonResult['qutarget'] = $_REQUEST['qutarget']; $JsonResult['distnum'] = $_REQUEST['distnum']; $JsonResult['arrowindex'] = $_REQUEST['arrowindex']; $JsonResult['arrowsymbol'] = ''; $JsonResult['curscore'] = ''; $JsonResult['curgold'] = ''; $JsonResult['curxnine'] = ''; $JsonResult['score'] = ''; $JsonResult['gold'] = ''; $JsonResult['xnine'] = ''; if (empty($CompId)) { $CompId = $_SESSION['TourId']; } $q = safe_r_sql("select * from Eliminations\r\n\t\twhere ElElimPhase=" . ($Phase[1] - 1) . "\r\n\t\tand ElEventCode='{$Event}'\r\n\t\tand ElTargetNo='{$Target}'\r\n\t\tand ElTournament={$CompId}\r\n\t\t"); if ($r = safe_fetch($q)) { $Arrowstring = str_pad($r->ElArrowString, $ArIndex + 1, ' ', STR_PAD_RIGHT); $xx = GetLetterFromPrint($ArSymbol); $Arrowstring[$ArIndex] = str_pad($xx, 1, ' ', STR_PAD_RIGHT); list($CurScore, $CurGold, $CurXNine) = ValutaArrowStringGX($Arrowstring); safe_w_sql("update Eliminations\r\n\t\t\tset ElArrowString='{$Arrowstring}',\r\n\t\t\tElScore={$CurScore},\r\n\t\t\tElGold={$CurGold},\r\n\t\t\tElXnine={$CurXNine}\r\n\t\t\twhere ElElimPhase=" . ($Phase[1] - 1) . "\r\n\t\t\tand ElEventCode='{$Event}'\r\n\t\t\tand ElTargetNo='{$Target}'\r\n\t\t\tand ElTournament={$CompId}"); if (safe_w_affected_rows()) { if ($Phase[1] == 1) { require_once 'Common/Fun_Sessions.inc.php'; ResetElimRows($Event, 2); } Obj_RankFactory::create('ElimInd', array('tournament' => $CompId, 'eventsC' => array($Event . '@' . $Phase[1])))->calculate(); } $JsonResult['error'] = 0; $JsonResult['arrowsymbol'] = $xx ? strtoupper($ArSymbol) : ''; $JsonResult['curscore'] = $CurScore; $JsonResult['curgold'] = $CurGold; $JsonResult['curxnine'] = $CurXNine; $JsonResult['score'] = $CurScore; $JsonResult['gold'] = $CurGold; $JsonResult['xnine'] = $CurXNine; } return $JsonResult; }
function SetAccreditation($Id, $SetRap = 0, $return = 'RicaricaOpener', $TourId = 0, $AccOp = 0) { $RicaricaOpener = false; if (!$TourId) { $TourId = $_SESSION['TourId']; } if (!$AccOp) { $AccOp = $_SESSION['AccOp']; } /* * Devo prevenire l'insert se l'id è in stato 7. * Per farlo cerco lo stato del tizio. * Se è 7 vuol dire che uno ha cliccato sul bottone dopo aver aperto il popup e io non scrivo in db */ $Select = "SELECT EnId FROM Entries\n\t\tWHERE EnId=" . StrSafe_DB($Id) . " AND EnTournament={$TourId} AND EnStatus='7' "; $Rs = safe_r_sql($Select); //TODO Patchare la query per supportare bene IpV6 if (safe_num_rows($Rs) == 0) { $Insert = "INSERT INTO AccEntries\n\t\t\t(AEId,AEOperation,AETournament,AEWhen,AEFromIp,AERapp)\n\t\t\tVALUES(\n\t\t\t\t{$Id}," . StrSafe_DB($AccOp) . "," . StrSafe_DB($TourId) . "," . StrSafe_DB(date('Y-m-d H:i')) . "," . "INET_ATON('" . ($_SERVER['REMOTE_ADDR'] != '::1' ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1') . "'), " . StrSafe_DB($SetRap) . "" . ") ON DUPLICATE KEY UPDATE " . "AEWhen=" . StrSafe_DB(date('Y-m-d H:i')) . "," . "AEFromIp=INET_ATON('" . ($_SERVER['REMOTE_ADDR'] != '::1' ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1') . "') "; $RsIns = safe_w_sql($Insert); $RicaricaOpener = $return == 'RicaricaOpener' ? true : (safe_w_affected_rows() ? 'AccreditationOK' : 'AccreditationTwice'); } return $RicaricaOpener; }
/** * calcMaxTeamPerson() * Calcola ed eventualmente scrive il numero massimo di persone in una squadra * * @param mixed $e: eventi di cui fare il calcolo. Se stringa verrà considerato l'evento; * se array verranno considerati gli eventi nel vettore * se array vuoto verranno considerati tutti gli eventi team del torneo * @param bool $write: true per scrivere il valore nella tabella; false altrimenti * @param int $t: torneo, se null prende quello aperto * @return mixed: false se ci sono stati errori; un array key=>value con key l'evento e value il numero */ function calcMaxTeamPerson($e = array(), $write = true, $t = null) { $tournament = $t === null ? $_SESSION['TourId'] : $t; $events = array(); if (!is_array($e)) { $events[] = StrSafe_DB($e); } elseif (count($e) > 0) { foreach ($e as $ee) { $events[] = StrSafe_DB($ee); } } $eventsFilter = ""; if (count($events) > 0) { $eventsFilter = " AND EcCode IN(" . implode(',', $events) . ") "; } $q = "\n\t\t\tSELECT\n\t\t\t\tSUM(sqEcNumber) AS q,sqEcCode\n\t\t\tFROM\n\t\t\t\t(\n\t\t\t\t\tSELECT DISTINCT\n\t\t\t\t\t\tEcCode AS sqEcCode,EcTeamEvent AS sqEcTeamEvent,EcTournament AS sqEcTournament,EcNumber AS sqEcNumber\n\t\t\t\t\tFROM\n\t\t\t\t\t\tEventClass\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tEcTournament={$tournament} AND EcTeamEvent<>0 {$eventsFilter}\n\t\t\t\t) AS sq\n\t\t\tGROUP BY sqEcCode\n\t\t"; //print $q.'<br><br>'; $r = safe_r_sql($q); $ret = false; if (safe_num_rows($r) > 0) { $ret = array(); while ($row = safe_fetch($r)) { $ret[] = array('event' => $row->sqEcCode, 'num' => $row->q); if ($write) { $q = "\n\t\t\t\t\t\tUPDATE\n\t\t\t\t\t\t\tEvents\n\t\t\t\t\t\tSET\n\t\t\t\t\t\t\tEvMaxTeamPerson={$row->q}\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tEvTournament={$tournament} AND EvTeamEvent=1 AND EvCode='{$row->sqEcCode}'\n\t\t\t\t\t"; //print $q.'<br><br>'; $rr = safe_w_sql($q); } } } return $ret; }
function UpdateTourDetails($TourId, $Field, $Value = '') { if (!is_array($Field)) { $Field = array($Field => $Value); } $q = array(); foreach ($Field as $k => $v) { $q[] = $k . '=' . StrSafe_DB($v); } safe_w_sql("update Tournament set " . implode(',', $q) . " where ToId={$TourId}"); }
require_once dirname(dirname(__FILE__)) . '/config.php'; require_once 'Common/Lib/Fun_DateTime.inc.php'; require_once 'Common/Fun_FormatText.inc.php'; require_once 'Tournament/Fun_Tournament.local.inc.php'; if (!CheckTourSession()) { print get_text('CrackError'); exit; } if (isset($_REQUEST['Command'])) { if ($_REQUEST['Command'] == 'ADD') { $Insert = "INSERT INTO TournamentInvolved (TiTournament,TiType,TiCode,TiName) " . "VALUES(" . StrSafe_DB($_SESSION['TourId']) . "," . StrSafe_DB($_REQUEST['new_Type']) . "," . StrSafe_DB($_REQUEST['new_Matr']) . "," . StrSafe_DB($_REQUEST['new_Name']) . " " . ") "; $RsIns = safe_w_sql($Insert); } elseif ($_REQUEST['Command'] == 'DELETE') { if (isset($_REQUEST['IdDel'])) { $Delete = "DELETE FROM TournamentInvolved WHERE TiId=" . StrSafe_DB($_REQUEST['IdDel']) . " "; $RsDel = safe_w_sql($Delete); header('Location: ' . $_SERVER['PHP_SELF']); exit; } } } $TypeOptions = array(0 => '------'); $Sel = "\r\n\t\tSELECT\r\n\t\t\t*\r\n\t\tFROM\r\n\t\t\tInvolvedType\r\n\t\tORDER BY\r\n\t\t\tIF(ItJudge!=0,1,IF(ItDoS!=0,2,IF(ItJury!=0,3,4))) ASC, IF(ItJudge!=0,ItJudge,IF(ItDoS!=0,ItDoS,IF(ItJury!=0,ItJury,ItOC))) ASC\r\n\t"; //print $Sel;exit; $RsSel = safe_r_sql($Sel); if (safe_num_rows($RsSel) > 0) { while ($RowSel = safe_fetch($RsSel)) { //$Attr = ($RowSel->ItJudge==1 ? 'J' : '') . ($RowSel->ItDoS==1 ? 'D' : ''); $TypeOptions[$RowSel->ItId] = get_text($RowSel->ItDescription, 'Tournament'); // . (strlen($Attr)>0 ? ' [' . $Attr . ']' : ''); }
if (safe_num_rows($Rs) == 0 || $RowBn->Customized == 0) { safe_w_sql("INSERT INTO BackNumber (BnTournament, BnFinal) VALUES (" . StrSafe_DB($_SESSION['TourId']) . "," . StrSafe_DB($BackNoFinal) . ")"); } safe_w_sql("UPDATE BackNumber SET " . substr($TmpUpdate, 0, -2) . " WHERE BnTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND BnFinal=" . StrSafe_DB($BackNoFinal)); if (isset($_FILES['UploadedBgImage']) && $_FILES['UploadedBgImage']['error'] == UPLOAD_ERR_OK && $_FILES['UploadedBgImage']['size'] > 0 && $_FILES['UploadedBgImage']['size'] <= 1048576) { $TmpData = addslashes($ImgString = fread(fopen($_FILES['UploadedBgImage']['tmp_name'], "r"), filesize($_FILES['UploadedBgImage']['tmp_name']))); $Rs = safe_w_sql("UPDATE BackNumber SET BnBackground='" . $TmpData . "' WHERE BnTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND BnFinal=" . StrSafe_DB($BackNoFinal)); unlink($_FILES['UploadedBgImage']['tmp_name']); if ($im = @imagecreatefromstring($ImgString)) { imagejpeg($im, $CFG->DOCUMENT_PATH . 'TV/Photos/' . $_SESSION['TourCodeSafe'] . '-BackNo-' . $BackNoFinal . '.jpg', 90); } } elseif (isset($_REQUEST["DeleteBgImage"]) && $_REQUEST["DeleteBgImage"] == 1) { $Rs = safe_w_sql("UPDATE BackNumber SET BnBackground='' WHERE BnTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND BnFinal=" . StrSafe_DB($BackNoFinal)); @unlink($CFG->DOCUMENT_PATH . 'TV/Photos/' . $_SESSION['TourCodeSafe'] . '-BackNo-' . $BackNoFinal . '.jpg'); } elseif ($RowBn->Customized == 0 && $RowBn->ImgSize > 0) { safe_w_sql("UPDATE BackNumber SET BnBackground=" . StrSafe_DB($RowBn->BnBackground) . " WHERE BnTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND BnFinal=" . StrSafe_DB($BackNoFinal)); } $Rs = safe_r_sql($Select); $RowBn = safe_fetch($Rs); } $JS_SCRIPT = array('<script type="text/javascript" src="' . $CFG->ROOT_DIR . 'Common/Fun_JS.inc.js"></script>', '<script type="text/javascript" src="' . $CFG->ROOT_DIR . 'Qualification/Fun_AJAX_index.js.php"></script>', '<script type="text/javascript" src="' . $CFG->ROOT_DIR . 'Common/ColorPicker/302pop.js"></script>'); $PAGE_TITLE = get_text('BackNumbers', 'BackNumbers'); include 'Common/Templates/head.php'; echo '<form id="PrnParameters" method="post" action="" enctype="multipart/form-data"><input type="hidden" name="BackNo" value="' . $BackNoFinal . '">'; echo '<table class="Tabella">'; echo '<tr><th class="Title" colspan="3">' . get_text('BackNumbers', 'BackNumbers') . ' - '; switch ($BackNoFinal) { case 0: echo get_text('QualRound'); break; case 1:
$Last = $ee . '_' . $mm; } if ($_REQUEST['T_' . $First] == 2 && $_REQUEST['T_' . $Last] == 2) { $TieOk = false; } else { $TieOk = true; } } if ($TieOk) { $Update .= ",FinTie=" . StrSafe_DB($t) . " "; } else { $Tie_Error[$ee . '_' . $mm] = true; } } $Update .= ",FinDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " " . "WHERE FinEvent='" . $ee . "' AND FinMatchNo='" . $mm . "' AND FinTournament=" . StrSafe_DB($_SESSION['TourId']) . " "; $RsUp = safe_w_sql($Update); if (debug) { print $Update . '<br><br>'; } } } } // Faccio i passaggi di fase foreach ($AllowedEvents as $event => $phase) { move2NextPhase($phase, $event); } } $PAGE_TITLE = get_text('MenuLM_Data insert (Table view)'); $JS_SCRIPT = array('<script type="text/javascript" src="' . $CFG->ROOT_DIR . 'Final/Individual/Fun_JS.js"></script>'); include 'Common/Templates/head.php'; ?>
$Rev2 = isset($_REQUEST['Review2']) ? $_REQUEST['Review2'] : null; if ($match % 2 != 0) { $match--; } $Errore = 0; $msg = ''; $isBlocked = $TeamEvent == 0 ? IsBlocked(BIT_BLOCK_IND) : IsBlocked(BIT_BLOCK_TEAM); if (is_null($event) || is_null($TeamEvent) || is_null($match) || $isBlocked) { $Errore = 1; } else { if (strlen($Rev1) == 0 && strlen($Rev2) == 0) { $sql = "DELETE FROM Reviews " . "WHERE RevEvent=" . StrSafe_DB($event) . " AND " . "RevMatchNo =" . $match . " AND " . "RevTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND " . "RevTeamEvent=" . StrSafe_DB($TeamEvent); $Rs = safe_w_sql($sql); } else { $sql = "INSERT INTO Reviews (RevEvent, RevMatchNo, RevTournament, RevTeamEvent, RevLanguage1, RevLanguage2, RevDateTime) " . "VALUES(" . StrSafe_DB($event) . ", " . StrSafe_DB($match) . ", " . StrSafe_DB($_SESSION['TourId']) . ", " . StrSafe_DB($TeamEvent) . ", " . StrSafe_DB(urldecode($Rev1)) . ", " . StrSafe_DB(urldecode($Rev2)) . ", " . StrSafe_DB(date('Y-m-d H:i:s')) . ") " . "ON DUPLICATE KEY UPDATE RevLanguage1=" . StrSafe_DB(urldecode($Rev1)) . ", RevLanguage2=" . StrSafe_DB(urldecode($Rev2)) . ", RevDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')); $Rs = safe_w_sql($sql); if (!safe_w_affected_rows()) { $Errore = 1; } } } if ($Errore == 0) { $msg = get_text('CmdOk'); } else { $msg = get_text('Error'); } header('Content-Type: text/xml'); print '<response>' . "\n"; print '<error>' . $Errore . '</error>' . "\n"; print '<msg>' . $msg . '</msg>' . "\n"; print '</response>' . "\n";
/** * setRow(). * Imposta le IndRank degli elementi passati. * * Questo è il metodo da chiamare quando si risolvono gli spareggi perchè chi non passa ha la rank a posto * grazie a calculate() e gli altri (sia quelli a cavallo che i buoni di sicuro) vanno impostati a mano. * * * @param mixed $items: array degli elementi da scrivere. * La struttra è la seguente: * array( * array( * ath => <id> (chiave) * event => <ev> (chiave) * dist => <dist> (chiave) * rank => <rank> * tiebreak => <arrowstring> * so => <so> * ) * ) * con <id> l'id della persona <ev> l'evento, <arrowstring> l'arrowstring delle frecce di tie (opzionale), <dist> la distanza (0 vuol dire IndRank), * <rank> la rank da impostare (opzionale), e e <so> prima degli spareggi vale come la rank se non ci sono spareggi; 0 per chi non passa e negativo come la rank in caso di gialli (opzionale). * L'arrowstring, e l'so comunque sono considerati solo se <dist>==0 * * Deve essere presente almeno un campo opzionale se no il metodo ritorna errore. * * * @return mixed: ritorna le affected_rows oppure false se c'è qualche errore * (non salva gli eventuali elementi successivi a quello che ha generato l'errore) */ public function setRow($items = array()) { // campi mandatory per $item $params = array('ath', 'event', 'dist'); $affected = 0; foreach ($items as $item) { /*print '<pre>'; print_r($item); print '</pre>';*/ $paramsOk = true; $canUp = false; /* * controllo che ci siano i campi mandatory */ foreach ($params as $p) { if (!array_key_exists($p, $item)) { $paramsOk = false; $ret = false; break; } } if (!$paramsOk) { continue; } $dd = $item['dist'] ? 'D' . $item['dist'] : ''; $date = date('Y-m-d H:i:s'); $q = "UPDATE " . "Individuals " . "SET " . "IndTimestamp='{$date}' "; /* campi opzionali e basta */ if (array_key_exists('rank', $item)) { $canUp = true; $q .= ",Ind{$dd}Rank={$item['rank']}"; } /* * campi opzionali (se dist==0). * In ogni caso i valori vengono scritti se e solo se la rank nuova è diversa dalla vecchia! */ if ($item['dist'] == 0) { if (array_key_exists('tiebreak', $item)) { $canUp = true; $q .= ",IndTiebreak='{$item['tiebreak']}'"; } if (array_key_exists('so', $item)) { $canUp = true; $q .= ",IndSO={$item['so']}"; } } $q .= " WHERE " . "IndId=" . $item['ath'] . " AND IndEvent='" . $item['event'] . "' AND IndTournament=" . $this->tournament . " "; //print $q.'<br><br>'; if (!$canUp) { return false; } $r = safe_w_sql($q); if (!$r) { $affected = false; } else { $affected += safe_w_affected_rows(); } if (empty($item['fist']) && array_key_exists('rank', $item) && array_key_exists('hits', $item) && $item['hits'] % 3 == 0) { $q = "INSERT INTO IndOldPositions (IopId, IopEvent, IopTournament, IopHits, IopRank) " . "VALUES(" . $item['ath'] . ",'" . $item['event'] . "'," . $this->tournament . "," . $item['hits'] . "," . $item['rank'] . ") " . "ON DUPLICATE KEY UPDATE IopRank=" . $item['rank']; safe_w_sql($q); } } return $affected; }
} else { $MyUpQuery .= "FinTiePosition='" . implode('|', ArrowPositionSx) . "',"; } $MyUpQuery .= "FinDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " "; $MyUpQuery .= "WHERE FinMatchNo=" . $MyRow->MatchNo . " AND FinEvent=" . StrSafe_DB($_REQUEST['Event']) . " AND FinTournament=" . StrSafe_DB($_SESSION['TourId']); $RsUpdate = safe_w_sql($MyUpQuery); //Aggiorno posizione frecce DX $MyUpQuery = "UPDATE Finals SET "; if ($_REQUEST["Volee"] != 'T') { $MyUpQuery .= "FinArrowPosition='" . implode('|', $ArrowPositionDx) . "',"; } else { $MyUpQuery .= "FinTiePosition='" . implode('|', ArrowPositionDx) . "',"; } $MyUpQuery .= "FinDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " "; $MyUpQuery .= "WHERE FinMatchNo=" . $MyRow->OppMatchNo . " AND FinEvent=" . StrSafe_DB($_REQUEST['Event']) . " AND FinTournament=" . StrSafe_DB($_SESSION['TourId']); $RsUpdate = safe_w_sql($MyUpQuery); } } /********************* Dati dello Scontro **********************/ $Select = "SELECT " . "e.EnId AS Athlete, e.EnCode as Code, e.EnName AS Name, upper(e.EnFirstName) AS FirstName, c.CoCode AS NationCode, c.CoName AS Nation, " . "f.FinMatchNo AS MatchNo, IF(EvMatchMode=0,f.FinScore,f.FinSetScore) AS FinalScore, f.FinScore AS Score, f.FinSetScore as SetScore, f.FinSetPoints as SetPoints, f.FinTie as Tie, f.FinArrowString AS ArrowString, f.FinArrowPosition AS ArrPos, f.FinTieBreak AS TieBreak, f.FinTiePosition AS TiePos, " . "e2.EnId AS OppAthlete, e.EnCode as OppCode, e2.EnName AS OppName, upper(e2.EnFirstName) AS OppFirstName, c2.CoCode AS OppNationCode, c2.CoName AS OppNation, " . "f2.FinMatchNo AS OppMatchNo, IF(EvMatchMode=0,f2.FinScore,f2.FinSetScore) AS OppFinalScore, f2.FinScore AS OppScore, f2.FinSetScore as OppSetScore, f2.FinSetPoints as OppSetPoints, f2.FinTie as OppTie, f2.FinArrowString AS OppArrowString, f2.FinArrowPosition AS OppArrPos, f2.FinTieBreak AS OppTieBreak, f2.FinTiePosition AS OppTiePos, " . "EvCode AS Event, EvEventName AS EventName, GrPhase as Phase, EvMatchMode as MatchMode, EvMatchArrowsNo " . "FROM Events " . "INNER JOIN Finals AS f ON EvTournament=f.FinTournament AND EvCode=f.FinEvent AND EvTeamEvent='0' " . "LEFT JOIN Entries AS e ON f.FinAthlete=e.EnId AND f.FinTournament=e.EnTournament " . "LEFT JOIN Countries AS c ON e.EnCountry=c.CoId AND e.EnTournament=c.CoTournament " . "INNER JOIN Finals AS f2 ON f.FinEvent=f2.FinEvent AND f.FinMatchNo=IF((f.FinMatchNo % 2)=0,f2.FinMatchNo-1,f2.FinMatchNo+1) AND f.FinTournament=f2.FinTournament " . "LEFT JOIN Entries AS e2 ON f2.FinAthlete=e2.EnId AND f2.FinTournament=e2.EnTournament " . "LEFT JOIN Countries AS c2 ON e2.EnCountry=c2.CoId AND e2.EnTournament=c2.CoTournament " . "INNER JOIN Grids ON f.FinMatchNo=GrMatchNo " . "WHERE EvCode=" . StrSafe_DB($Event) . " AND EvTournament=" . StrSafe_DB($_SESSION['TourId']) . " " . "AND f.FinMatchNo =" . StrSafe_DB($MatchNo % 2 == 0 ? $MatchNo : $MatchNo - 1) . " "; //print $Select . '<br>'; if (debug) { print $Select . '<br>'; } $JS_SCRIPT = array('<script type="text/javascript" src="' . $CFG->ROOT_DIR . 'Final/Individual/Fun_JS.js"></script>'); $PAGE_TITLE = get_text('IndFinal'); include 'Common/Templates/head.php'; ?> <form name="FrmVolee" method="post" action="<?php
/** * calcFromPhase() * Calcola la FinalRank per un evento in una certa fase * @param string $event: evento * @param int $phase: fase * @return boolean: true ok false altrimenti. In un ciclo il primo errore fa terminare il metodo con false! */ protected function calcFromPhase($event, $phase) { // trasformo la fase $phase = valueFirstPhase($phase); $date = date('Y-m-d H:i:s'); // reset delle RankFinal della fase x le persone di quell'evento e quella fase $q = "\r\n\t\t\t\tUPDATE\r\n\t\t\t\t\tIndividuals\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tFinals\r\n\t\t\t\t\tON IndId=FinAthlete AND IndTournament=FinTournament AND IndEvent=FinEvent\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tGrids\r\n\t\t\t\t\tON FinMatchNo=GrMatchNo AND GrPhase={$phase}\r\n\t\t\t\tSET\r\n\t\t\t\t\tIndRankFinal=0,\r\n\t\t\t\t\tIndTimestampFinal='{$date}'\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tGrPhase={$phase} AND IndTournament={$this->tournament} AND IndEvent='{$event}'\r\n\t\t\t"; //print $q.'<br><br>'; $r = safe_w_sql($q); if (!$r) { return false; } /* * Tiro fuori gli scontri con i perdenti nei non Opp */ $q = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tf.FinAthlete AS AthId,\r\n\t\t\t\t\tf2.FinAthlete AS OppAthId,\r\n\t\t\t\t\tIF(EvMatchMode=0,f.FinScore,f.FinSetScore) AS Score, f.FinScore AS CumScore,f.FinTie AS Tie,\r\n\t\t\t\t\tIF(EvMatchMode=0,f2.FinScore,f2.FinSetScore) as OppScore, f2.FinScore AS OppCumScore,f2.FinTie as OppTie\r\n\t\t\t\tFROM\r\n\t\t\t\t\tFinals AS f\r\n\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tFinals AS f2\r\n\t\t\t\t\tON f.FinEvent=f2.FinEvent AND f.FinMatchNo=IF((f.FinMatchNo % 2)=0,f2.FinMatchNo-1,f2.FinMatchNo+1) AND f.FinTournament=f2.FinTournament\r\n\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tGrids\r\n\t\t\t\t\tON f.FinMatchNo=GrMatchNo\r\n\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tEvents\r\n\t\t\t\t\tON f.FinEvent=EvCode AND f.FinTournament=EvTournament AND EvTeamEvent=0\r\n\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tf.FinTournament={$this->tournament} AND f.FinEvent='{$event}' AND GrPhase={$phase}\r\n\t\t\t\t\tAND (IF(EvMatchMode=0,f.FinScore,f.FinSetScore) < IF(EvMatchMode=0,f2.FinScore,f2.FinSetScore) OR (IF(EvMatchMode=0,f.FinScore,f.FinSetScore)=IF(EvMatchMode=0,f2.FinScore,f2.FinSetScore) AND f.FinTie < f2.FinTie))\r\n\t\t\t\tORDER BY\r\n\t\t\t\t\tIF(EvMatchMode=0,f.FinScore,f.FinSetScore) DESC,f.FinScore DESC\r\n\t\t\t"; //print $q.'<br><br>'; $rs = safe_r_sql($q); if ($rs) { if (safe_num_rows($rs) > 0) { /* * Se fase 0 (oro) il perdente ha la rank=2 e il vincente piglia 1, * se fase 1 (bronzo) il perdente ha la rank=4 e il vincete piglia 3 * e in entrambi i casi avrò sempre e solo una riga. * * Se fase 2 (semi) non succede nulla. * * Per le altre fasi si cicla nel recordset che ha il numero di righe >=0 */ if ($phase == 0 || $phase == 1) { $myRow = safe_fetch($rs); $toWrite = array(); if ($phase == 0) { // vincente $toWrite[] = array('event' => $event, 'id' => $myRow->OppAthId, 'rank' => 1); // perdente $toWrite[] = array('event' => $event, 'id' => $myRow->AthId, 'rank' => 2); } elseif ($phase == 1) { // vincente $toWrite[] = array('event' => $event, 'id' => $myRow->OppAthId, 'rank' => 3); // perdente $toWrite[] = array('event' => $event, 'id' => $myRow->AthId, 'rank' => 4); } foreach ($toWrite as $values) { $x = $this->writeRow($values['id'], $values['event'], $values['rank']); if ($x === false) { return false; } } } elseif ($phase == 2) { // non faccio nulla! } else { // qui posso avere tante righe $pos = 0; /* * Le posizioni partono dal numero della fase perchè poi l'incremento avverrà sempre. * (@see Obj_Rank_FinalInd_calc base) * I 1/48 quindi andranno inizializzati a 56 perchè la prima rank buona è 57. * Con tutte le fase avverrno gli incrementi */ switch ($phase) { case 4: $pos = 4; // si parte da 5 quindi qui metto 4 dato che la fase è 4 (vedi commento qui sopra) break; case 8: $pos = 8; break; case 16: $pos = 16; break; case 32: // (e 24) $pos = 32; break; case 48: $pos = 56; break; case 64: $pos = 64; break; default: return false; } $rank = $pos + 1; $scoreOld = 0; $cumOld = 0; while ($myRow = safe_fetch($rs)) { ++$pos; //print $pos . ' - '; if (!($myRow->Score == $scoreOld && $myRow->CumScore == $cumOld)) { $rank = $pos; } //print $rank.'<br>'; $scoreOld = $myRow->Score; $cumOld = $myRow->CumScore; // devo scrivere solo il perdente $x = $this->writeRow($myRow->AthId, $event, $rank); if ($x === false) { return false; } } } } } else { return false; } return true; }
function correctQualTargetsForSession($SesTournament, $SesOrder, $oldSesTar4Session, $oldSesAth4Target) { // info attuali della sessione $SesTar4Session = 0; $SesAth4Target = 0; $x = getQualTargetsInfoForSession($SesTournament, $SesOrder); if ($x !== false) { list($SesTar4Session, $SesAth4Target) = $x; /* * Il problema si presenta se $oldSesTar4Session>$SesTar4Session oppure $oldSesAth4Target>$SesAth4Target. * Se i numeri aumentano non ci sono problemi perchè la "vecchia" sessione è contenuta nella "nuova". * * Se il numero di persone si riduce occorre sganciare tutti quelli che sono nelle lettere superiori * all'ultima buona dopo l'update. * * Se il numero di paglioni si riduce occorre sganciare tutti i bersagli dalle persone nelle piazzole * dopo l'ultima buona dopo l'update. */ // si riducono le persone if ($SesAth4Target < $oldSesAth4Target) { /* * in base al numero di persone posso ricavare l'ultima lettera buona * chr(64) = '@' * chr(65) = 'A' */ $lastLetter = chr($SesAth4Target + 64); /* * Quindi tutte le lettere oltre $lastLetter vanno resettate. * In pratica si annullano le righe di Qualifications che hanno * QuSession=$SesOrder e QuTargetNo<>'' e l'ultima lettera di QuTargetNo>$lastLetter */ $q = "UPDATE " . "Qualifications INNER JOIN Entries ON QuId=EnId " . "SET " . "QuSession=0,QuTargetNo='',QuBacknoPrinted=0 " . "WHERE " . "EnTournament=" . StrSafe_DB($SesTournament) . " AND " . "QuSession=" . StrSafe_DB($SesOrder) . " AND " . "QuTargetNo<>'' AND " . "SUBSTRING(QuTargetNo,-1)>'" . $lastLetter . "' "; $r = safe_w_sql($q); } // si riducono i bersagli if ($SesTar4Session < $oldSesTar4Session) { /* * L'ultimo target è dato dal numero di bersagli */ $lastTarget = $SesTar4Session; /* * Ora tutte le persone della sessione in bersagli più alti di $lastTarget * vengono sganciate */ $q = "UPDATE " . "Qualifications INNER JOIN Entries ON QuId=EnId " . "SET " . "QuSession=0,QuTargetNo='',QuBacknoPrinted=0 " . "WHERE " . "EnTournament=" . StrSafe_DB($SesTournament) . " AND " . "QuSession=" . StrSafe_DB($SesOrder) . " AND " . "CAST(SUBSTRING(QuTargetNo,2, " . TargetNoPadding . ") AS UNSIGNED)>" . $lastTarget . " "; $r = safe_w_sql($q); } } else { return false; } }
case 'image/gif': $img = imagecreatefromgif($_FILES['JPG']['tmp_name'][$edit]); if ($img) { imagejpeg($img, $imgJPG, 95); } break; case 'image/jpg': case 'image/jpeg': $imgJPG = $_FILES['JPG']['tmp_name'][$edit]; break; default: debug_svela($_FILES['JPG']); cd_redirect('Countries.php#' . $edit); } $Image = addslashes(base64_encode(file_get_contents($imgJPG))); safe_w_sql("insert into Flags set FlCode='{$edit}', FlJPG='{$Image}', FlTournament={$_SESSION['TourId']} " . " on duplicate key update FlJPG='{$Image}'"); unlink($imgJPG); } cd_redirect('Countries.php#' . $edit); } require_once 'Common/CheckPictures.php'; CheckPictures(); $PAGE_TITLE = get_text('TourCountries', 'Tournament'); include 'Common/Templates/head.php'; echo '<form method="POST" ENCTYPE="multipart/form-data">'; echo '<table class="Tabella">'; echo '<tr>'; echo '<td colspan="4">'; echo '<a href="../Final/Team/PrnName.php?TeamLabel=1" target="_blank">' . get_text('TeamPlace', 'Tournament') . '</a>'; echo ' <a href="../Final/Team/PrnName.php?TeamLabel=1&local=1" target="_blank">' . get_text('TeamPlaceLocal', 'Tournament') . '</a>'; echo '</td>';
// Preparo le query di update if (debug) { print 'ArrSx --> ' . $ArrSx . '<br>'; print 'TieSx --> ' . $TieSx . '<br>'; print 'TotSx --> ' . $TotSx . '<br>'; print 'PosArrSx --> ' . $PosArrSx . '<br>'; } $MyUpQuerySx = "UPDATE TeamFinals SET " . "TfArrowString='" . $ArrSx . "'," . "TfTieBreak=" . StrSafe_DB($TieSx) . "," . "TfScore=" . StrSafe_DB($TotSx) . "," . "TfArrowPosition='" . implode('|', $PosArrSx) . "'," . "TfTiePosition='" . implode('|', $PosTieSx) . "'," . "TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " " . "WHERE TfMatchNo=" . StrSafe_DB($MatchSx) . " AND TfEvent=" . StrSafe_DB($_REQUEST['Event']) . " " . "AND TfTournament=" . StrSafe_DB($_SESSION['TourId']) . " "; $MyUpQueryDx = "UPDATE TeamFinals SET " . "TfArrowString=" . StrSafe_DB($ArrDx) . "," . "TfTieBreak=" . StrSafe_DB($TieDx) . "," . "TfScore=" . StrSafe_DB($TotDx) . "," . "TfArrowPosition='" . implode('|', $PosArrDx) . "'," . "TfTiePosition=" . StrSafe_DB(implode('|', $PosTieDx)) . "," . "TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " " . "WHERE TfMatchNo=" . StrSafe_DB($MatchDx) . " AND TfEvent=" . StrSafe_DB($_REQUEST['Event']) . " " . "AND TfTournament=" . StrSafe_DB($_SESSION['TourId']) . " "; if (debug) { print $MyUpQuerySx . '<br>'; print $MyUpQueryDx . '<br>'; exit; } $RsSx = safe_w_sql($MyUpQuerySx); $RsDx = safe_w_sql($MyUpQueryDx); } } // Contatori per la distribuzione di freccie $CountersSx = array_fill(1, 10, 0); $CountersSx["X"] = 0; $CountersSx["M"] = 0; //foreach ($Counters1 as $key => $value) print $key . ' --> ' . $value . "<br>"; $CountersDx = array_fill(1, 10, 0); $CountersDx["X"] = 0; $CountersDx["M"] = 0; // dati dello scontro $Select = "SELECT TfMatchNo AS MatchNo,TfEvent AS Event,TfTeam AS Athlete, " . "TfScore AS Score,TfArrowString AS ArrowString,TfArrowPosition AS ArrPos," . "TfTieBreak AS TieBreak,TfTiePosition AS TiePos, " . "TfWinLose AS WinLose, " . "CoCode AS NationCode,CoName AS Nation " . "FROM TeamFinals INNER JOIN Countries ON TfTeam=CoId " . "WHERE TfMatchNo IN(" . StrSafe_DB($MatchSx) . "," . StrSafe_DB($MatchDx) . ") " . "AND TfEvent=" . StrSafe_DB($_REQUEST['Event']) . " AND TfTournament=" . StrSafe_DB($_SESSION['TourId']) . " " . "ORDER BY TfMatchNo ASC "; //print $Select . '<br>';exit; if (debug) { print $Select . '<br>';
function UpdateTournament($Gara) { if ($Gara['Tournament']['ToDbVersion'] < '2010-04-13 14:00:00') { // rimedia all'errore introdotto in Arizona e spota il flag da DoubleSpace a WChair foreach ($Gara['Entries'] as $ID => $Entry) { if (!empty($Entry['EnDoubleSpace'])) { $Gara['Entries'][$ID]['EnWChair'] = '1'; $Gara['Entries'][$ID]['EnDoubleSpace'] = '0'; } } } if ($Gara['Tournament']['ToDbVersion'] < '2010-04-17 15:34:01') { if (empty($Gara['TournamentDistances'])) { // recupera le differenti classi delle entries e le mette in una tabella temporanea safe_w_sql("create temporary table TempClasses (TcClass varchar(5) not null, primary key (TcClass) )"); foreach ($Gara['Entries'] as $E) { safe_w_sql("insert ignore into TempClasses set TcClass='" . $E['EnDivision'] . $E['EnClass'] . "'"); } // riempie la tabella con le occorrenze $Gara['TournamentDistances'] = array(); $t = safe_r_sql("SELECT distinct td.* FROM TournamentDistances td inner join TempClasses e on TcClass LIKE TdClasses where TdType='{$Gara['Tournament']['ToType']}' and TdTournament=0"); while ($u = safe_fetch($t)) { $u->TdTournament = $Gara['Tournament']['ToId']; $qubits = array(); foreach ($u as $key => $val) { $qubits[$key] = $val; } $Gara['TournamentDistances'][] = $qubits; } } } if ($Gara['Tournament']['ToDbVersion'] < '2010-04-25 11:34:00') { // procedura di aggiornamento della gara alla versione attuale del database foreach ($Gara['Entries'] as $ID => $data) { if (array_key_exists('EnPhoto', $Gara['Entries'][$ID])) { $Gara['Entries'][$ID]['EnBadgePrinted'] = $Gara['Entries'][$ID]['EnPhoto']; unset($Gara['Entries'][$ID]['EnPhoto']); } } } if ($Gara['Tournament']['ToDbVersion'] < '2010-09-01 10:15:00') { //print $Gara['Tournament']['ToType'];exit; // aggiungo le colonne nuove alla Tournament $Gara['Tournament']['ToLocRule'] = ''; $Gara['Tournament']['ToUpNamesUrl'] = ''; $Gara['Tournament']['ToUpPhotosUrl'] = ''; $Gara['Tournament']['ToUpFlagsUrl'] = ''; // $Gara['Tournament']['ToTypeName']=''; // $Gara['Tournament']['ToNumDist']='0'; // $Gara['Tournament']['ToNumEnds']='0'; // $Gara['Tournament']['ToMaxDistScore']='0'; // $Gara['Tournament']['ToMaxFinIndScore']='0'; // $Gara['Tournament']['ToMaxFinTeamScore']='0'; // $Gara['Tournament']['ToCategory']='0'; // $Gara['Tournament']['ToElabTeam']='0'; // $Gara['Tournament']['ToElimination']='0'; // $Gara['Tournament']['ToGolds']=''; // $Gara['Tournament']['ToXNine']=''; // $Gara['Tournament']['ToDouble']='0'; // ora dai tipi di torneo prendo i valori di default e li metto nel vettore $TourTypes = array('ToTypeName' => 'Type_FITA', 'ToNumDist' => '4', 'ToNumEnds' => '12', 'ToMaxDistScore' => '360', 'ToMaxFinIndScore' => '120', 'ToMaxFinTeamScore' => '240', 'ToCategory' => '1', 'ToElabTeam' => '0', 'ToElimination' => '0', 'ToGolds' => '10', 'ToXNine' => 'X', 'ToGoldsChars' => 'L', 'ToXNineChars' => 'K', 'ToDouble' => '0'); switch ($Gara['Tournament']['ToType']) { case '2': $TourTypes['ToTypeName'] = 'Type_2xFITA'; $TourTypes['ToNumDist'] = '8'; $TourTypes['ToDouble'] = '1'; break; case '3': $TourTypes['ToTypeName'] = 'Type_70m Round'; $TourTypes['ToNumDist'] = '2'; break; case '4': $TourTypes['ToTypeName'] = 'Type_FITA 72'; $TourTypes['ToNumEnds'] = '6'; $TourTypes['ToMaxDistScore'] = '180'; break; case '5': $TourTypes['ToTypeName'] = 'Type_900 Round'; $TourTypes['ToNumDist'] = '3'; $TourTypes['ToNumEnds'] = '10'; $TourTypes['ToMaxDistScore'] = '300'; $TourTypes['ToMaxFinIndScore'] = '0'; $TourTypes['ToMaxFinTeamScore'] = '0'; break; case '6': $TourTypes['ToTypeName'] = 'Type_Indoor 18'; $TourTypes['ToNumDist'] = '2'; $TourTypes['ToNumEnds'] = '10'; $TourTypes['ToMaxDistScore'] = '300'; $TourTypes['ToCategory'] = '2'; $TourTypes['ToXNine'] = '9'; $TourTypes['ToXNineChars'] = 'J'; break; case '7': $TourTypes['ToTypeName'] = 'Type_Indoor 25'; $TourTypes['ToNumDist'] = '2'; $TourTypes['ToNumEnds'] = '10'; $TourTypes['ToMaxDistScore'] = '300'; $TourTypes['ToCategory'] = '2'; $TourTypes['ToXNine'] = '9'; $TourTypes['ToXNineChars'] = 'J'; break; case '8': $TourTypes['ToTypeName'] = 'Type_Indoor 25+18'; $TourTypes['ToNumEnds'] = '10'; $TourTypes['ToMaxDistScore'] = '300'; $TourTypes['ToCategory'] = '2'; $TourTypes['ToXNine'] = '9'; $TourTypes['ToXNineChars'] = 'J'; $TourTypes['ToDouble'] = '1'; break; case '9': case '10': case '12': $TourTypes['ToTypeName'] = $Gara['Tournament']['ToType'] == '10' ? 'Type_HF 24+24' : 'Type_HF 12+12'; $TourTypes['ToNumDist'] = $Gara['Tournament']['ToType'] == '9' ? '1' : '2'; $TourTypes['ToNumEnds'] = $Gara['Tournament']['ToType'] == '12' ? '12' : '24'; $TourTypes['ToMaxDistScore'] = $Gara['Tournament']['ToType'] == '12' ? '216' : '432'; $TourTypes['ToMaxFinIndScore'] = '72'; $TourTypes['ToMaxFinTeamScore'] = '144'; $TourTypes['ToCategory'] = '4'; $TourTypes['ToElabTeam'] = '1'; $TourTypes['ToElimination'] = '1'; $TourTypes['ToGolds'] = '6+5'; $TourTypes['ToXNine'] = '6'; $TourTypes['ToGoldsChars'] = 'FG'; $TourTypes['ToXNineChars'] = 'G'; break; case '11': case '13': $TourTypes['ToTypeName'] = '3D'; $TourTypes['ToNumDist'] = $Gara['Tournament']['ToType'] == '11' ? '1' : '2'; $TourTypes['ToNumEnds'] = '20'; $TourTypes['ToMaxDistScore'] = '220'; $TourTypes['ToMaxFinIndScore'] = '44'; $TourTypes['ToMaxFinTeamScore'] = '132'; $TourTypes['ToCategory'] = '8'; $TourTypes['ToElabTeam'] = '2'; $TourTypes['ToElimination'] = '1'; $TourTypes['ToGolds'] = '11'; $TourTypes['ToXNine'] = '10'; $TourTypes['ToGoldsChars'] = 'M'; $TourTypes['ToXNineChars'] = 'L'; break; case '14': $TourTypes['ToTypeName'] = 'Type_Las Vegas'; $TourTypes['ToNumDist'] = '4'; $TourTypes['ToNumEnds'] = '10'; $TourTypes['ToMaxDistScore'] = '300'; $TourTypes['ToMaxFinIndScore'] = '0'; $TourTypes['ToMaxFinTeamScore'] = '0'; break; case '15': $TourTypes['ToTypeName'] = 'Type_GiochiGioventu'; $TourTypes['ToNumDist'] = '2'; $TourTypes['ToNumEnds'] = '8'; $TourTypes['ToMaxDistScore'] = '240'; $TourTypes['ToMaxFinIndScore'] = '0'; $TourTypes['ToMaxFinTeamScore'] = '0'; break; case '16': $TourTypes['ToTypeName'] = 'Type_GiochiGioventuW'; $TourTypes['ToNumDist'] = '2'; $TourTypes['ToNumEnds'] = '8'; $TourTypes['ToMaxDistScore'] = '240'; $TourTypes['ToMaxFinIndScore'] = '0'; $TourTypes['ToMaxFinTeamScore'] = '0'; $TourTypes['ToCategory'] = '2'; $TourTypes['ToXNine'] = '9'; $TourTypes['ToXNineChars'] = 'J'; break; } $Gara['Tournament'] = array_merge($Gara['Tournament'], $TourTypes); } if ($Gara['Tournament']['ToDbVersion'] < '2010-09-03 17:45:00') { // per prima cosa tiro fuori gli eventi delle finali e delle eliminatorie con i bersagli (id) $events = array(); foreach ($Gara['Events'] as $g) { $events[$g['EvCode']] = $g['EvFinalTargetType']; } /*print '<pre>'; print_r($events);*/ /* * Regole di trasformazione. * la chiave è il tipo di target e ogni array contiene la serie di regole per * le sostituzioni. * Il giochino funziona così: * nelle tabelle interessate c'è la colonna dell'evento. * Da questo posso risalire, usando il vettore $events creato prima, al bersaglio di quell'evento. * Quindi ciclando dentro al vettore dei records di Finals, TeamFinals, Eliminations posso prendere la regola * giusta nel vettore qui sotto ed eseguire la serie di sostituzioni sui campi che a seconda saranno FinArrowstring, * TfArrostring etc... in base alla tabella che sto ciclando. */ $rules = array(1 => array(), 2 => array(), 3 => array(), 4 => array(), 5 => array(), 6 => array(), 7 => array(), 8 => array(), 10 => array()); // TrgIndComplete $rules[1] = array(array('from' => 'K', 'to' => 'L'), array('from' => 'k', 'to' => 'l')); // TrgIndSmall $rules[2] = array(array('from' => 'B', 'to' => 'A'), array('from' => 'C', 'to' => 'A'), array('from' => 'D', 'to' => 'A'), array('from' => 'E', 'to' => 'A'), array('from' => 'F', 'to' => 'A'), array('from' => 'K', 'to' => 'L'), array('from' => 'b', 'to' => 'a'), array('from' => 'c', 'to' => 'a'), array('from' => 'd', 'to' => 'a'), array('from' => 'e', 'to' => 'a'), array('from' => 'f', 'to' => 'a'), array('from' => 'k', 'to' => 'l')); // TrgCOIndComplete $rules[3] = array(array('from' => 'B', 'to' => 'A'), array('from' => 'C', 'to' => 'A'), array('from' => 'D', 'to' => 'A'), array('from' => 'E', 'to' => 'A'), array('from' => 'F', 'to' => 'A'), array('from' => 'L', 'to' => 'J'), array('from' => 'K', 'to' => 'L'), array('from' => 'b', 'to' => 'a'), array('from' => 'c', 'to' => 'a'), array('from' => 'd', 'to' => 'a'), array('from' => 'e', 'to' => 'a'), array('from' => 'f', 'to' => 'a'), array('from' => 'l', 'to' => 'j'), array('from' => 'k', 'to' => 'l')); // TrgCOIndSmall $rules[4] = array(array('from' => 'B', 'to' => 'A'), array('from' => 'C', 'to' => 'A'), array('from' => 'D', 'to' => 'A'), array('from' => 'E', 'to' => 'A'), array('from' => 'F', 'to' => 'A'), array('from' => 'L', 'to' => 'J'), array('from' => 'K', 'to' => 'L'), array('from' => 'b', 'to' => 'a'), array('from' => 'c', 'to' => 'a'), array('from' => 'd', 'to' => 'a'), array('from' => 'e', 'to' => 'a'), array('from' => 'f', 'to' => 'a'), array('from' => 'l', 'to' => 'j'), array('from' => 'k', 'to' => 'l')); // TrgOutdoor (questo non va toccato!!!) $rules[5] = array(); // TrgField $rules[6] = array(array('from' => 'B', 'to' => 'A'), array('from' => 'C', 'to' => 'A'), array('from' => 'D', 'to' => 'A'), array('from' => 'E', 'to' => 'A'), array('from' => 'F', 'to' => 'B'), array('from' => 'G', 'to' => 'C'), array('from' => 'H', 'to' => 'D'), array('from' => 'I', 'to' => 'E'), array('from' => 'J', 'to' => 'F'), array('from' => 'K', 'to' => 'G'), array('from' => 'L', 'to' => 'G'), array('from' => 'b', 'to' => 'a'), array('from' => 'c', 'to' => 'a'), array('from' => 'd', 'to' => 'a'), array('from' => 'e', 'to' => 'a'), array('from' => 'f', 'to' => 'b'), array('from' => 'g', 'to' => 'c'), array('from' => 'h', 'to' => 'd'), array('from' => 'i', 'to' => 'e'), array('from' => 'j', 'to' => 'f'), array('from' => 'k', 'to' => 'g'), array('from' => 'l', 'to' => 'g')); // TrgHMOutComplete $rules[7] = array(array('from' => 'B', 'to' => 'A'), array('from' => 'C', 'to' => 'A'), array('from' => 'D', 'to' => 'A'), array('from' => 'E', 'to' => 'A'), array('from' => 'F', 'to' => 'A'), array('from' => 'G', 'to' => 'A'), array('from' => 'H', 'to' => 'A'), array('from' => 'I', 'to' => 'A'), array('from' => 'J', 'to' => 'B'), array('from' => 'K', 'to' => 'B'), array('from' => 'L', 'to' => 'B'), array('from' => 'b', 'to' => 'a'), array('from' => 'c', 'to' => 'a'), array('from' => 'd', 'to' => 'a'), array('from' => 'e', 'to' => 'a'), array('from' => 'f', 'to' => 'a'), array('from' => 'g', 'to' => 'a'), array('from' => 'h', 'to' => 'a'), array('from' => 'i', 'to' => 'a'), array('from' => 'j', 'to' => 'b'), array('from' => 'k', 'to' => 'b'), array('from' => 'l', 'to' => 'b')); // Trg3DComplete $rules[8] = array(array('from' => 'B', 'to' => 'A'), array('from' => 'C', 'to' => 'A'), array('from' => 'D', 'to' => 'A'), array('from' => 'E', 'to' => 'A'), array('from' => 'G', 'to' => 'A'), array('from' => 'H', 'to' => 'A'), array('from' => 'J', 'to' => 'A'), array('from' => 'K', 'to' => 'M'), array('from' => 'b', 'to' => 'a'), array('from' => 'c', 'to' => 'a'), array('from' => 'd', 'to' => 'a'), array('from' => 'e', 'to' => 'a'), array('from' => 'f', 'to' => 'a'), array('from' => 'h', 'to' => 'a'), array('from' => 'j', 'to' => 'a'), array('from' => 'k', 'to' => 'm')); // nel db abbiamo due target Trg3DComplete $rules[10] = $rules[8]; /* * Adesso definisco le tabelle su cui ciclare e i campi da considerare. * In chiave ho la tabella e ogni elemento ha la seguente struttura: * array(eventField,fields) * con eventField il campo da usare per scoprire l'evento per risalire al bersaglio * fields un array con i campi della tabella a cui verranno applicate le regole */ $tables = array('Finals' => array('eventField' => 'FinEvent', 'fields' => array('FinArrowstring', 'FinTiebreak')), 'TeamFinals' => array('eventField' => 'TfEvent', 'fields' => array('TfArrowstring', 'TfTiebreak')), 'Eliminations' => array('eventField' => 'ElEventCode', 'fields' => array('ElArrowString'))); // per ogni tabella definita qui sopra... foreach ($tables as $table => $infos) { // fondamentale la '&' prima di $row perchè nel ciclo più interno la variabile viene riassegnata!!!! foreach ($Gara[$table] as &$row) { /* * per risalire al bersaglio della riga devo cercare in $events * la chiave con l'evento corretto che si trova nella colonna $infos['eventField'] * della riga attuale ($row). */ $target = $events[$row[$infos['eventField']]]; /*print $target.'<br>'; print_r($rules[$target]);*/ /*print '<pre>'; print_r($row); print '</pre>';*/ /* * adesso ad ogni campo definito in $infos['fields'] applico le regole */ //print 'target: ' . $target . '<br>'; foreach ($infos['fields'] as $field) { //print 'prima: <b>' . $field . '</b> ' . $row[$field] . '<br>'; foreach ($rules[$target] as $rule) { $row[$field] = str_replace($rule['from'], $rule['to'], $row[$field]); } //print 'dopo: <b>' . $field . '</b> ' . $row[$field] . '<br>'; } } } } if ($Gara['Tournament']['ToDbVersion'] < '2010-09-15 09:35:00') { /*print 'prima<br>'; print '<pre>'; print_r($Gara['Events']); print '</pre>';*/ /* * Tabella dei valori. * La chiave indica la terna Ind_Mode_Mixed * con Ind 0 o 1 se individuale o team; Mode 0 o 1 se cumulativo o set; Mixed 0 o 1 se team normale o mixed */ $rules = array('0_0_0' => array('EvElimEnds' => 2, 'EvElimArrows' => 6, 'EvElimSO' => 3, 'EvFinEnds' => 4, 'EvFinArrows' => 3, 'EvFinSO' => 3), '0_1_0' => array('EvElimEnds' => 3, 'EvElimArrows' => 6, 'EvElimSO' => 1, 'EvFinEnds' => 5, 'EvFinArrows' => 3, 'EvFinSO' => 1), '1_0_0' => array('EvElimEnds' => 4, 'EvElimArrows' => 6, 'EvElimSO' => 9, 'EvFinEnds' => 4, 'EvFinArrows' => 6, 'EvFinSO' => 9), '1_0_1' => array('EvElimEnds' => 4, 'EvElimArrows' => 4, 'EvElimSO' => 6, 'EvFinEnds' => 4, 'EvFinArrows' => 4, 'EvFinSO' => 6)); if (in_array($Gara['Tournament']['ToType'], array(9, 10, 12))) { // HF, one of 3 types $rules = array('0_0_0' => array('EvElimEnds' => 12, 'EvElimArrows' => 3, 'EvElimSO' => 3, 'EvFinEnds' => 4, 'EvFinArrows' => 3, 'EvFinSO' => 3), '1_0_0' => array('EvElimEnds' => 8, 'EvElimArrows' => 3, 'EvElimSO' => 3, 'EvFinEnds' => 4, 'EvFinArrows' => 3, 'EvFinSO' => 3)); } if (in_array($Gara['Tournament']['ToType'], array(11, 13))) { // 3D, one of 2 types $rules = array('0_0_0' => array('EvElimEnds' => 12, 'EvElimArrows' => 1, 'EvElimSO' => 1, 'EvFinEnds' => 4, 'EvFinArrows' => 1, 'EvFinSO' => 1), '1_0_0' => array('EvElimEnds' => 8, 'EvElimArrows' => 3, 'EvElimSO' => 3, 'EvFinEnds' => 4, 'EvFinArrows' => 3, 'EvFinSO' => 3)); } foreach ($Gara['Events'] as $k => &$v) { $r = $v['EvTeamEvent'] . '_' . $v['EvMatchMode'] . '_' . $v['EvMixedTeam']; foreach ($rules[$r] as $field => $param) { $v[$field] = $param; } } /*print 'dopo<br>'; print '<pre>'; print_r($Gara['Events']); print '</pre>'; exit;*/ } if ($Gara['Tournament']['ToDbVersion'] < '2010-09-24 15:00:00') { // Aggiorna la FinSchedule inserendo la posizione a bersaglio $Events = array(); foreach ($Gara['FinSchedule'] as $k => &$v) { if ($v['FSTarget']) { $v['FSLetter'] = $v['FSTarget'] . 'A'; if ($v['FSMatchNo'] % 2 == 0) { $tmp = $v; $tmp['FSMatchNo'] = $v['FSMatchNo'] + 1; $Events[] = $tmp; } } } foreach ($Gara['FinSchedule'] as $k => &$v) { if ($v['FSTarget'] and in_array($v, $Events)) { $v['FSLetter'] = $v['FSTarget'] . 'B'; } } } if ($Gara['Tournament']['ToDbVersion'] < '2010-10-12 15:44:00') { // aggiungo la tabella Session $Gara['Session'] = array(); // ora la popolo pigliando i dati dalle colonne di Tournament $ToNumSession = $Gara['Tournament']['ToNumSession']; for ($i = 1; $i <= $ToNumSession; ++$i) { $Gara['Session'][] = array('SesTournament' => $Gara['Tournament']['ToId'], 'SesOrder' => $i, 'SesType' => 'Q', 'SesName' => '', 'SesTar4Session' => $Gara['Tournament']['ToTar4Session' . $i], 'SesAth4Target' => $Gara['Tournament']['ToAth4Target' . $i], 'SesFirstTarget' => 1, 'SesFollow' => 0); } /*print '<pre>'; print_r($Gara['Session']); print '</pre>';exit;*/ /* * ATTENZIONE!!! * Qui andrebbe la cancellazione dei vecchi campi * * ToTar4Session1,ToTar4Session2,ToTar4Session3,ToTar4Session4,ToTar4Session5,ToTar4Session6,ToTar4Session7,ToTar4Session8,ToTar4Session9,ToAth4Target1,ToAth4Target2,ToAth4Target3,ToAth4Target4,ToAth4Target5,ToAth4Target6, ToAth4Target7,ToAth4Target8,ToAth4Target9 * * da Tournament */ } if ($Gara['Tournament']['ToDbVersion'] < '2010-10-18 15:32:00') { // Aggiorna i targetFaces $Gara['TargetFaces'] = array(); $tmp = array('TfTournament' => $Gara['Tournament']['ToId'], 'TfId' => '0', 'TfName' => '~Default', 'TfClasses' => '%', 'TfDefault' => '1', 'TfT1' => '0', 'TfW1' => '0', 'TfT2' => '0', 'TfW2' => '0', 'TfT3' => '0', 'TfW3' => '0', 'TfT4' => '0', 'TfW4' => '0', 'TfT5' => '0', 'TfW5' => '0', 'TfT6' => '0', 'TfW6' => '0', 'TfT7' => '0', 'TfW7' => '0', 'TfT8' => '0', 'TfW8' => '0'); switch ($Gara['Tournament']['ToType']) { case 2: // Type_2xFITA $Straight1 = $Gara['Tournament']['Td1'] >= $Gara['Tournament']['Td2']; // FITA 90-70-50-30 or 4*70m $Straight2 = $Gara['Tournament']['Td5'] >= $Gara['Tournament']['Td6']; // FITA 90-70-50-30 or 4*70m $tmp['TfId'] = 1; $tmp['TfT1'] = '5'; $tmp['TfW1'] = $Straight1 ? 122 : 80; $tmp['TfT2'] = '5'; $tmp['TfW2'] = $Straight1 ? 122 : 80; $tmp['TfT3'] = '5'; $tmp['TfW3'] = $Straight1 ? 80 : 122; $tmp['TfT4'] = '5'; $tmp['TfW4'] = $Straight1 ? 80 : 122; $tmp['TfT5'] = '5'; $tmp['TfW5'] = $Straight2 ? 122 : 80; $tmp['TfT6'] = '5'; $tmp['TfW6'] = $Straight2 ? 122 : 80; $tmp['TfT7'] = '5'; $tmp['TfW7'] = $Straight2 ? 80 : 122; $tmp['TfT8'] = '5'; $tmp['TfW8'] = $Straight2 ? 80 : 122; $Gara['TargetFaces'][] = $tmp; // Catch All $tmp['TfName'] = '~DefaultVI'; $tmp['TfClasses'] = 'VI%'; $tmp['TfId'] = 2; $tmp['TfW1'] = $Straight1 ? 60 : 122; $tmp['TfW2'] = 80; $tmp['TfW3'] = 80; $tmp['TfW4'] = $Straight1 ? 122 : 60; $tmp['TfW5'] = $Straight2 ? 60 : 122; $tmp['TfW6'] = 80; $tmp['TfW7'] = 80; $tmp['TfW8'] = $Straight2 ? 122 : 60; $Gara['TargetFaces'][] = $tmp; // VI UpdateDivsClass($Gara, '2', array('VI')); // update VI break; case 1: // Type_FITA // Type_FITA case 4: // Type_FITA 72 $Straight = $Gara['Tournament']['Td1'] >= $Gara['Tournament']['Td2']; // FITA 90-70-50-30 or 4*70m $tmp['TfId'] = 1; $tmp['TfT1'] = '5'; $tmp['TfW1'] = $Straight ? 122 : 80; $tmp['TfT2'] = '5'; $tmp['TfW2'] = $Straight ? 122 : 80; $tmp['TfT3'] = '5'; $tmp['TfW3'] = $Straight ? 80 : 122; $tmp['TfT4'] = '5'; $tmp['TfW4'] = $Straight ? 80 : 122; $Gara['TargetFaces'][] = $tmp; // Catch All $tmp['TfName'] = '~DefaultVI'; $tmp['TfClasses'] = 'VI%'; $tmp['TfId'] = 2; $tmp['TfW1'] = $Straight ? 60 : 122; $tmp['TfW2'] = 80; $tmp['TfW3'] = 80; $tmp['TfW4'] = $Straight ? 122 : 60; $Gara['TargetFaces'][] = $tmp; // VI UpdateDivsClass($Gara, '2', array('VI')); // update VI break; case 5: // Type_900 Round $tmp['TfId'] = 1; $tmp['TfT1'] = '5'; $tmp['TfW1'] = 122; $tmp['TfT2'] = '5'; $tmp['TfW2'] = 122; $tmp['TfT3'] = '5'; $tmp['TfW3'] = 122; $Gara['TargetFaces'][] = $tmp; // Catch All break; case 3: // Type_70m Round $tmp['TfId'] = 1; $tmp['TfT1'] = '5'; $tmp['TfW1'] = 122; $tmp['TfT2'] = '5'; $tmp['TfW2'] = 122; $Gara['TargetFaces'][] = $tmp; // Catch All $tmp['TfName'] = '~DefaultVI'; $tmp['TfClasses'] = 'VI%'; $tmp['TfId'] = 2; $tmp['TfW1'] = 80; $tmp['TfW2'] = 80; $Gara['TargetFaces'][] = $tmp; // VI UpdateDivsClass($Gara, '2', array('VI')); // update VI break; case 8: // Type_Indoor 25+18 $tmp['TfId'] = 1; $tmp['TfT1'] = 1; $tmp['TfW1'] = 60; $tmp['TfT2'] = 1; $tmp['TfW2'] = 60; $tmp['TfT3'] = 1; $tmp['TfW3'] = 40; $tmp['TfT4'] = 1; $tmp['TfW4'] = 40; $Gara['TargetFaces'][] = $tmp; // Catch All $tmp['TfName'] = 'Default COG'; $tmp['TfClasses'] = 'COG_'; $tmp['TfId'] = 4; $tmp['TfT1'] = 4; $tmp['TfW1'] = 80; $tmp['TfT2'] = 4; $tmp['TfW2'] = 80; $tmp['TfT3'] = 4; $tmp['TfW3'] = 60; $tmp['TfT4'] = 4; $tmp['TfW4'] = 60; $Gara['TargetFaces'][] = $tmp; // CoGio UpdateDivsClass($Gara, '4', array('C', 'CO', 'C1'), array('GM', 'GF')); // update GioCO $tmp['TfName'] = 'Default G'; $tmp['TfClasses'] = '__G_'; $tmp['TfId'] = 3; $tmp['TfT1'] = 1; $tmp['TfW1'] = 80; $tmp['TfT2'] = 1; $tmp['TfW2'] = 80; $tmp['TfT3'] = 1; $tmp['TfW3'] = 60; $tmp['TfT4'] = 1; $tmp['TfW4'] = 60; $Gara['TargetFaces'][] = $tmp; // Giovanissimi UpdateDivsClass($Gara, '3', array(), array('GM', 'GF')); // update other Gio $tmp['TfName'] = '~DefaultVI'; $tmp['TfClasses'] = 'VI%'; $tmp['TfId'] = 5; $Gara['TargetFaces'][] = $tmp; // VI UpdateDivsClass($Gara, '5', array('VI')); // update VI $tmp['TfName'] = '~DefaultCO'; $tmp['TfClasses'] = 'C%'; $tmp['TfId'] = 2; $tmp['TfT1'] = 4; $tmp['TfW1'] = 60; $tmp['TfT2'] = 4; $tmp['TfW2'] = 60; $tmp['TfT3'] = 4; $tmp['TfW3'] = 40; $tmp['TfT4'] = 4; $tmp['TfW4'] = 40; $Gara['TargetFaces'][] = $tmp; // Compounds UpdateDivsClass($Gara, '2', array('C', 'CO', 'C1')); // update Compounds break; case 7: // Type_Indoor 25 $tmp['TfId'] = 1; $tmp['TfT1'] = 1; $tmp['TfW1'] = 60; $tmp['TfT2'] = 1; $tmp['TfW2'] = 60; $Gara['TargetFaces'][] = $tmp; // Catch All $tmp['TfName'] = 'Default COG'; $tmp['TfClasses'] = 'COG_'; $tmp['TfId'] = 4; $tmp['TfT1'] = 4; $tmp['TfW1'] = 80; $tmp['TfT2'] = 4; $tmp['TfW2'] = 80; $Gara['TargetFaces'][] = $tmp; // CoGio UpdateDivsClass($Gara, '4', array('C', 'CO', 'C1'), array('GM', 'GF')); // update GioCO $tmp['TfName'] = 'Default G'; $tmp['TfClasses'] = '__G_'; $tmp['TfId'] = 3; $tmp['TfT1'] = 1; $tmp['TfW1'] = 80; $tmp['TfT2'] = 1; $tmp['TfW2'] = 80; $Gara['TargetFaces'][] = $tmp; // Giovanissimi UpdateDivsClass($Gara, '3', array(), array('GM', 'GF')); // update other Gio $tmp['TfName'] = '~DefaultVI'; $tmp['TfClasses'] = 'VI%'; $tmp['TfId'] = 5; $Gara['TargetFaces'][] = $tmp; // VI UpdateDivsClass($Gara, '5', array('VI')); // update VI $tmp['TfName'] = '~DefaultCO'; $tmp['TfClasses'] = 'C%'; $tmp['TfId'] = 2; $tmp['TfT1'] = 4; $tmp['TfW1'] = 60; $tmp['TfT2'] = 4; $tmp['TfW2'] = 60; $Gara['TargetFaces'][] = $tmp; // Compounds UpdateDivsClass($Gara, '2', array('C', 'CO', 'C1')); // update Compounds break; case 6: // Type_Indoor 18 $tmp['TfId'] = 1; $tmp['TfT1'] = 1; $tmp['TfW1'] = 40; $tmp['TfT2'] = 1; $tmp['TfW2'] = 40; $Gara['TargetFaces'][] = $tmp; // Catch All $tmp['TfName'] = 'Default COG'; $tmp['TfClasses'] = 'COG_'; $tmp['TfId'] = 4; $tmp['TfT1'] = 4; $tmp['TfW1'] = 60; $tmp['TfT2'] = 4; $tmp['TfW2'] = 60; $Gara['TargetFaces'][] = $tmp; // CoGio UpdateDivsClass($Gara, '4', array('C', 'CO', 'C1'), array('GM', 'GF')); // update GioCO $tmp['TfName'] = 'Default G'; $tmp['TfClasses'] = '__G_'; $tmp['TfId'] = 3; $tmp['TfT1'] = 1; $tmp['TfW1'] = 60; $tmp['TfT2'] = 1; $tmp['TfW2'] = 60; $Gara['TargetFaces'][] = $tmp; // Giovanissimi UpdateDivsClass($Gara, '3', array(), array('GM', 'GF')); // update other Gio $tmp['TfName'] = '~DefaultVI'; $tmp['TfClasses'] = 'VI%'; $tmp['TfId'] = 5; $Gara['TargetFaces'][] = $tmp; // VI UpdateDivsClass($Gara, '5', array('VI')); // update VI $tmp['TfName'] = '~DefaultCO'; $tmp['TfClasses'] = 'C%'; $tmp['TfId'] = 2; $tmp['TfT1'] = 4; $tmp['TfW1'] = 40; $tmp['TfT2'] = 4; $tmp['TfW2'] = 40; $Gara['TargetFaces'][] = $tmp; // Compounds UpdateDivsClass($Gara, '2', array('C', 'CO', 'C1')); // update Compounds break; case 10: // Type_HF 24+24 // Type_HF 24+24 case 12: // Type_HF 12+12 $tmp['TfId'] = 1; $tmp['TfT1'] = 6; $tmp['TfT2'] = 6; $Gara['TargetFaces'][] = $tmp; // Catch All break; case 9: // Type_HF 12+12 $tmp['TfId'] = 1; $tmp['TfT1'] = 6; $Gara['TargetFaces'][] = $tmp; // Catch All break; case 13: // 3D $tmp['TfId'] = 1; $tmp['TfT1'] = 8; $tmp['TfT2'] = 8; $Gara['TargetFaces'][] = $tmp; // Catch All break; case 11: // 3D $tmp['TfId'] = 1; $tmp['TfT1'] = 8; $Gara['TargetFaces'][] = $tmp; // Catch All break; case 14: // Type_Las Vegas: EVERYBODY shoots on large 10 ring, CO shoot on small target $tmp['TfId'] = 1; $tmp['TfT1'] = 1; $tmp['TfT2'] = 1; $tmp['TfT3'] = 1; $tmp['TfT4'] = 1; $tmp['TfW1'] = 40; $tmp['TfW2'] = 40; $tmp['TfW3'] = 40; $tmp['TfW4'] = 40; $Gara['TargetFaces'][] = $tmp; // Catch All $tmp['TfName'] = '~DefaultCO'; $tmp['TfClasses'] = 'C%'; $tmp['TfId'] = 2; $tmp['TfT1'] = 2; $tmp['TfT2'] = 2; $tmp['TfT3'] = 2; $tmp['TfT4'] = 2; $Gara['TargetFaces'][] = $tmp; // Compound UpdateDivsClass($Gara, '2', array('C', 'CO')); // update Compounds break; case 15: // Type_GiochiGioventu // Type_GiochiGioventu case 16: // Type_GiochiGioventuWinter $tmp['TfId'] = 1; $tmp['TfT1'] = 5; $tmp['TfT2'] = 5; $tmp['TfW1'] = 80; $tmp['TfW2'] = 80; $Gara['TargetFaces'][] = $tmp; // Catch All break; } UpdateDivsClass($Gara); // catchall } if ($Gara['Tournament']['ToDbVersion'] < '2010-10-26 11:30:00') { // tolgo i campi ToAth4Target[i] e ToTar4Session[i] 1<=i<=9 for ($i = 1; $i <= 9; ++$i) { unset($Gara['Tournament']['ToTar4Session' . $i]); unset($Gara['Tournament']['ToAth4Target' . $i]); } } if ($Gara['Tournament']['ToDbVersion'] < '2010-11-08 11:48:00') { /* * Devo aggiornare la gestione delle eliminatorie. * * Prima tiro fuori l'elenco degli eventi con le eliminatorie (in teoria tutti ma non si sa mai!) */ $events = array(); foreach ($Gara['Events'] as $e) { if ($e['EvElim2'] != 0) { $events[$e['EvCode']] = $e; } } // tiro fuori per ogni Qualifications l'id e la rank $qualifications = array(); foreach ($Gara['Qualifications'] as $q) { $qualifications[$q['QuId']] = $q['QuRank']; } /* * per ogni Eliminations di fase 0 tiro fuori id_fase e ElRank */ $eliminations = array(); foreach ($Gara['Eliminations'] as $g) { if ($g['ElElimPhase'] == 0) { $eliminations[$g['ElId'] . '_' . $g['ElElimPhase']] = $g['ElRank']; } } // Aggiungo il riferimento al torneo alle righe di Eliminations foreach ($Gara['Eliminations'] as &$g) { if (array_key_exists($g['ElEventCode'], $events)) { $g['ElTournament'] = $Gara['Tournament']['ToId']; } } /*print '<pre>'; print_r($events); print_r($qualifications); print_r($eliminations); print_r($Gara['Eliminations']); print '</pre>'; exit;*/ /* * Adesso metto a posto la rank. * Prima le righe di Eliminations con l'evento che ha EvElim1=0 */ foreach ($Gara['Eliminations'] as &$g) { if ($events[$g['ElEventCode']]['EvElim1'] == 0) { $g['ElQualRank'] = $qualifications[$g['ElId']]; } } /* * Adesso le righe con EvElim!=0 */ foreach ($Gara['Eliminations'] as &$g) { // due fasi if ($events[$g['ElEventCode']]['EvElim1'] != 0) { // qui piglio da $qualifications perchè sto mettendo a posto la prima fase if ($g['ElElimPhase'] == 0) { $g['ElQualRank'] = $qualifications[$g['ElId']]; } else { $g['ElQualRank'] = $eliminations[$g['ElId'] . '_0']; } } } } if ($Gara['Tournament']['ToDbVersion'] < '2010-12-03 17:40:00') { //Creo il vettore di lookup della definizione eventi $lookupEvents = array(); foreach ($Gara['EventClass'] as $ecKey => $ecValue) { if ($ecValue['EcTeamEvent'] == 0) { if (array_key_exists($ecValue['EcClass'] . $ecValue['EcDivision'], $lookupEvents)) { $lookupEvents[$ecValue['EcClass'] . $ecValue['EcDivision']][] = $ecValue['EcCode']; } else { $lookupEvents[$ecValue['EcClass'] . $ecValue['EcDivision']] = array($ecValue['EcCode']); } } } foreach ($Gara['Qualifications'] as $qKey => $qValue) { if ($Gara['Entries'][$qValue['QuId']]['EnAthlete'] == 1) { if (array_key_exists($Gara['Entries'][$qValue['QuId']]['EnClass'] . $Gara['Entries'][$qValue['QuId']]['EnDivision'], $lookupEvents)) { for ($i = 0; $i < count($lookupEvents[$Gara['Entries'][$qValue['QuId']]['EnClass'] . $Gara['Entries'][$qValue['QuId']]['EnDivision']]); $i++) { if (!array_key_exists('Individuals', $Gara)) { $Gara['Individuals'] = array(); } $Gara['Individuals'][] = array('IndId' => $qValue['QuId'], 'IndEvent' => $lookupEvents[$Gara['Entries'][$qValue['QuId']]['EnClass'] . $Gara['Entries'][$qValue['QuId']]['EnDivision']][$i], 'IndTournament' => $Gara['Tournament']['ToId'], 'IndRank' => $qValue['QuRank'], 'IndTieBreak' => $qValue['QuTieBreak']); } } } } } if ($Gara['Tournament']['ToDbVersion'] < '2011-01-17 00:32:00') { // removes the 3 fields... unset($Gara['Tournament']['ToUpNamesUrl']); unset($Gara['Tournament']['ToUpPhotosUrl']); unset($Gara['Tournament']['ToUpFlagsUrl']); // updates the IocCode of the tournament if ($Gara['Tournament']['ToLocRule'] == 'IT') { $Gara['Tournament']['ToIocCode'] = 'ITA'; foreach ($Gara['Entries'] as $key => $val) { $Gara['Entries'][$key]['EnIocCode'] = 'ITA'; } } } if ($Gara['Tournament']['ToDbVersion'] < '2011-01-30 12:56:00') { // Aggiorna le bandiere!!! if (!empty($Gara['Flags'])) { foreach ($Gara['Flags'] as $key => $Flag) { if (!empty($Flag['FlPNG'])) { $tmpnam = tempnam('/tmp', 'img'); $img = imagecreatefromstring(base64_decode($Flag['FlPNG'])); imagejpeg($img, $tmpnam, 95); $Gara['Flags'][$key]['FlJPG'] = base64_encode(file_get_contents($tmpnam)); unset($Gara['Flags'][$key]['FlPNG']); } } } } if ($Gara['Tournament']['ToDbVersion'] < '2011-02-09 21:02:00') { foreach ($Gara['Qualifications'] as $key => $val) { $t = substr($val['QuTargetNo'], 0, 1) . str_pad(substr($val['QuTargetNo'], 1, -1), 3, '0', STR_PAD_LEFT) . substr($val['QuTargetNo'], -1); $Gara['Qualifications'][$key]['QuTargetNo'] = $t; } foreach ($Gara['AvailableTarget'] as $key => $val) { $t = substr($val['AtTargetNo'], 0, 1) . str_pad(substr($val['AtTargetNo'], 1, -1), 3, '0', STR_PAD_LEFT) . substr($val['AtTargetNo'], -1); $Gara['AvailableTarget'][$key]['AtTargetNo'] = $t; } } if ($Gara['Tournament']['ToDbVersion'] < '2011-02-10 11:07:00') { foreach ($Gara['Teams'] as $key => $val) { unset($Gara['Teams'][$key]["TeFinalRank"]); } } if ($Gara['Tournament']['ToDbVersion'] < '2011-04-25 09:00:00') { if (array_key_exists('BroadCast', $Gara)) { unset($Gara['BroadCast']); } } if ($Gara['Tournament']['ToDbVersion'] < '2011-08-17 18:13:00') { require_once 'Common/Fun_FormatText.inc.php'; // updates Countries foreach ($Gara['Countries'] as $key => &$val) { $val['CoCode'] = mb_convert_case($val['CoCode'], MB_CASE_UPPER, "UTF-8"); $val['CoName'] = AdjustCaseTitle($val['CoName']); $val['CoNameComplete'] = AdjustCaseTitle($val['CoNameComplete']); } // updates Entries foreach ($Gara['Entries'] as $key => &$val) { $val['EnName'] = AdjustCaseTitle($val['EnName']); $val['EnFirstName'] = AdjustCaseTitle($val['EnFirstName']); } } if ($Gara['Tournament']['ToDbVersion'] < '2012-01-15 16:00:00') { foreach ($Gara['TVParams'] as $key => &$val) { $val['TVPColumns'] = 'ALL'; } } if ($Gara['Tournament']['ToDbVersion'] < '2012-01-18 12:00:02') { if ($Gara['Tournament']['ToBlock'] == 63) { $Gara['Tournament']['ToBlock'] = 65535; } } if ($Gara['Tournament']['ToDbVersion'] < '2014-01-31 11:35:00') { foreach ($Gara['Qualifications'] as $key => $val) { unset($Gara['Qualifications'][$key]["QuRank"]); } } if ($Gara['Tournament']['ToDbVersion'] < '2014-02-04 17:00:00') { foreach ($Gara['Qualifications'] as $key => $val) { unset($Gara['Qualifications'][$key]["QuClRankOld"]); unset($Gara['Qualifications'][$key]["QuSubClassRankOld"]); unset($Gara['Qualifications'][$key]["QuHitsCalcOld"]); unset($Gara['Qualifications'][$key]["QuHitsSubClassCalcOld"]); } foreach ($Gara['Individuals'] as $key => $val) { unset($Gara['Individuals'][$key]["IndRankOld"]); unset($Gara['Individuals'][$key]["IndRankCalcOld"]); } foreach ($Gara['Teams'] as $key => $val) { unset($Gara['Teams'][$key]["TeRankOld"]); unset($Gara['Teams'][$key]["TeRankCalcOld"]); } } if ($Gara['Tournament']['ToDbVersion'] < '2014-03-07 11:50:00') { if (!empty($Gara['DistanceInformation'])) { foreach ($Gara['DistanceInformation'] as $key => $row) { if (isset($row['DiStart'])) { $Gara['DistanceInformation'][$key]['DiStartDay'] = substr($row['DiStart'], 0, 10); $Gara['DistanceInformation'][$key]['DiStartTime'] = substr($row['DiStart'], -8); $Gara['DistanceInformation'][$key]['DiEndDay'] = substr($row['DiEnd'], 0, 10); $Gara['DistanceInformation'][$key]['DiEndTime'] = substr($row['DiEnd'], -8); $Gara['DistanceInformation'][$key]['DiWarmDay'] = substr($row['DiWarmup'], 0, 10); $Gara['DistanceInformation'][$key]['DiWarmTime'] = substr($row['DiWarmup'], -8); unset($Gara['DistanceInformation'][$key]['DiStart']); unset($Gara['DistanceInformation'][$key]['DiEnd']); unset($Gara['DistanceInformation'][$key]['DiWarmup']); } } } } if ($Gara['Tournament']['ToDbVersion'] < '2014-05-18 19:00:01') { if (!empty($Gara['DistanceInformation'])) { foreach ($Gara['DistanceInformation'] as $key => $row) { $Gara['DistanceInformation'][$key]['DiDay'] = $row['DiStartDay']; $Gara['DistanceInformation'][$key]['DiWarmStart'] = $row['DiWarmTime']; $Gara['DistanceInformation'][$key]['DiStart'] = $row['DiStartTime']; $tmp = explode(':', $row['DiStartTime']); $timeStart = $tmp[0] * 60 + $tmp[1]; $tmp = explode(':', $row['DiWarmTime']); $timeWarm = $tmp[0] * 60 + $tmp[1]; $tmp = explode(':', $row['DiEndTime']); $timeEnd = $tmp[0] * 60 + $tmp[1]; $Gara['DistanceInformation'][$key]['DiWarmDuration'] = $timeStart - $timeWarm; $Gara['DistanceInformation'][$key]['DiDuration'] = $timeEnd - $timeStart; unset($Gara['DistanceInformation'][$key]['DiStartDay']); unset($Gara['DistanceInformation'][$key]['DiStartTime']); unset($Gara['DistanceInformation'][$key]['DiEndDay']); unset($Gara['DistanceInformation'][$key]['DiEndTime']); unset($Gara['DistanceInformation'][$key]['DiWarmDay']); unset($Gara['DistanceInformation'][$key]['DiWarmTime']); } } } /* if($Gara['Tournament']['ToDbVersion']<'YYYY-MM-DD HH:MM:SS') { // procedura di aggiornamento della gara alla versione attuale del database } */ return $Gara; }
$id = safe_w_last_id(); } if (safe_w_affected_rows()) { safe_w_sql("update Entries set EnBadgePrinted=0 where EnId={$id}"); } //print $Insert.'<br><br/>'; if ($Op == 'Ins') { // aggiungo la riga in Qualifications $Insert = "INSERT INTO Qualifications (QuId,QuSession) " . "VALUES(" . StrSafe_DB($id) . "," . "0" . ") "; $Rs = safe_w_sql($Insert); //print $Insert.'<br><br>'; } $Update = "UPDATE Qualifications SET " . "QuSession=" . StrSafe_DB($_REQUEST['d_q_QuSession_']) . ", " . "QuTargetNo=" . StrSafe_DB(($_REQUEST['d_q_QuSession_'] != 0 ? $_REQUEST['d_q_QuSession_'] : '') . $_REQUEST['d_q_QuTargetNo_']) . " " . "WHERE QuId=" . StrSafe_DB($id) . " "; $Rs = safe_w_sql($Update); if (safe_w_affected_rows()) { safe_w_sql("update Qualifications SET QuBacknoPrinted=0 where QuId={$id}"); } //print $Update;exit; if ($recalc) { $x = Params4Recalc($id); if ($x !== false) { list($indFEvent, $teamFEvent, $country, $div, $cl, $zero) = $x; } // ricalcolo il vecchio e il nuovo if (!is_null($indFEvent)) { RecalculateShootoffAndTeams($indFEventOld, $teamFEventOld, $countryOld, $divOld, $clOld, $zeroOld); } RecalculateShootoffAndTeams($indFEvent, $teamFEvent, $country, $div, $cl, $zero); // rank di classe x tutte le distanze $q = "SELECT ToNumDist FROM Tournament WHERE ToId={$_SESSION['TourId']}"; $r = safe_r_sql($q);
/** * setRow(). * Imposta le IndRank degli elementi passati. * * Questo è il metodo da chiamare quando si risolvono gli spareggi perchè chi non passa ha la rank a posto * grazie a calculate() e gli altri (sia quelli a cavallo che i buoni di sicuro) vanno impostati a mano. * * * @param mixed $items: array degli elementi da scrivere. * La struttra è la seguente: * array( * array( * team => <id> (chiave) * subteam => <subteam> (chiave) * event => <ev> (chiave) * rank => <rank> * tiebreak => <arrowstring> * so => <so> * ) * ) * con <id> l'id della squadra,<subteam> il subteam, <ev> l'evento, <arrowstring> l'arrowstring delle frecce di tie (opzionale), * <rank> la rank da impostare (opzionale), e <so> prima degli spareggi vale come la rank se non ci sono spareggi; 0 per chi non passa e negativo come la rank in caso di gialli (opzionale). * L'arrowstring, e l'so comunque sono considerati solo se <dist>==0 * * Deve essere presente almeno un campo opzionale se no il metodo ritorna errore. * * * @return mixed: ritorna le affected_rows oppure false se c'è qualche errore * (non salva gli eventuali elementi successivi a quello che ha generato l'errore) */ public function setRow($items = array()) { // campi mandatory per $item $params = array('team', 'subteam', 'event'); $affected = 0; foreach ($items as $item) { /*print '<pre>'; print_r($item); print '</pre>';*/ $paramsOk = true; $canUp = false; /* * controllo che ci siano i campi mandatory */ foreach ($params as $p) { if (!array_key_exists($p, $item)) { $paramsOk = false; $ret = false; break; } } if (!$paramsOk) { continue; } $date = date('Y-m-d H:i:s'); $q = "UPDATE " . "Teams " . "SET " . "TeTimeStamp='{$date}' "; /* campi opzionali e basta */ if (array_key_exists('rank', $item)) { $canUp = true; $q .= ",TeRank={$item['rank']}"; } if (array_key_exists('tiebreak', $item)) { $canUp = true; $q .= ",TeTiebreak='{$item['tiebreak']}'"; } if (array_key_exists('so', $item)) { $canUp = true; $q .= ",TeSO={$item['so']}"; } $q .= " WHERE " . "TeCoId=" . $item['team'] . " AND TeSubTeam=" . $item['subteam'] . " AND TeFinEvent=1 AND TeEvent='" . $item['event'] . "' AND TeTournament=" . $this->tournament . " "; //print $q.'<br><br>'; if (!$canUp) { return false; } $r = safe_w_sql($q); if (!$r) { $affected = false; } else { $affected += safe_w_affected_rows(); } if (!$canUp) { return false; } $r = safe_w_sql($q); if (!$r) { $affected = false; } else { $affected += safe_w_affected_rows(); } } return $affected; }
$target = $session . $targetNo; // verifico che il bersaglio esista $query = "SELECT " . "AtTargetNo " . "FROM " . "AvailableTarget " . "WHERE " . "AtTournament=" . StrSafe_DB($tourId) . " AND AtTargetNo=" . StrSafe_DB($target) . " "; //print $query;exit; $rs = safe_r_sql($query); if (safe_num_rows($rs)) { // verifico se è già in uso (e se si salvo ma segno l'errore) $query = "SELECT " . "QuId " . "FROM " . "Qualifications " . "INNER JOIN " . "Entries " . "ON QuId=EnId AND EnTournament=" . StrSafe_DB($tourId) . " " . "WHERE " . "QuTargetNo=" . StrSafe_DB($target) . " "; $rs = safe_r_sql($query); if (safe_num_rows($rs) > 0) { $error = 1; } $query = "UPDATE " . "Qualifications " . "SET " . "QuTargetNo=" . StrSafe_DB($target) . " " . "WHERE " . "QuId=" . StrSafe_DB($id) . " "; $rs = safe_w_sql($query); if (safe_w_affected_rows()) { safe_w_sql("UPDATE Qualifications SET QuBacknoPrinted=0 WHERE QuId='{$id}'"); } if (!$rs) { $error = 1; } // verifico se è già in uso // $query // = "SELECT " // . "QuId " // . "FROM " // . "Qualifications " // . "INNER JOIN " // . "Entries " // . "ON QuId=EnId AND EnTournament=" . StrSafe_DB($tourId) . " " // . "WHERE " // . "QuTargetNo=" . StrSafe_DB($target) . " ";
} // cancella la regola e le sue associazioni if (!empty($_GET['delete'])) { $IDrule = intval($_GET['delete']); // controlla che non sia una regola predefinita (IDtour = -1) $q = safe_r_sql("SELECT * FROM TVRules WHERE TVRId={$IDrule} AND TVRTournament={$TourId}"); if (!($r = safe_fetch($q))) { cd_redirect(); } // non esiste la regola o $q = safe_r_sql("SELECT * FROM TVSequence WHERE TVSTable='DB' AND TVSRule={$IDrule} AND TVSTournament={$TourId}"); while ($r = safe_fetch($q)) { safe_w_sql("DELETE FROM TVParams WHERE TVPId={$r->TVSContent} AND TVPTournament={$TourId}"); } safe_w_sql("DELETE FROM TVRules WHERE TVRId={$IDrule} AND TVRTournament={$TourId}"); safe_w_sql("DELETE FROM TVSequence WHERE TVSRule={$IDrule} AND TVSTournament={$TourId}"); cd_redirect(); } if (!empty($_GET['edit'])) { $IDrule = intval($_GET['edit']); // controlla che non sia una regola predefinita (IDtour = -1) $q = safe_r_sql("SELECT * FROM TVRules WHERE TVRId={$IDrule} AND TVRTournament={$TourId}"); if (!($RULE = safe_fetch($q))) { cd_redirect(); } // non esiste la regola define('IN_PHP', true); include 'EditRule.php'; exit; } }
foreach ($v['events'] as $ph => $ev) { $val[] = $ph . ' (' . implode('+', $ev) . ')'; } // $ComboSes.='<option value="'.$k.'"'.$v['selected'].'>'.$v['date'] . ' '. implode('; ',$val).'</option>'; echo '<tr id="row_' . $k . '">'; echo '<td class="Center">'; if ($k && array_key_exists($k, $EventArray) && $EventArray[$k] != $_REQUEST['Id']) { echo " "; } else { echo '<input type="checkbox" name="eventList" value="' . $k . '" id="chk_' . $k . '" ' . (array_key_exists($k, $EventArray) ? 'checked' : '') . ' onClick="saveHhtEvent(\'' . $k . '\')">'; } echo '</td>'; echo '<td colspan="2">' . $v['date'] . ' ' . implode('; ', $val) . '</td>'; echo '</tr>' . "\n"; } } sort($listCodes); $delete = "DELETE FROM HhtEvents " . "WHERE HeEventCode NOT IN (" . implode(',', $listCodes) . ") AND HeTournament=" . StrSafe_DB($_SESSION['TourId']) . " "; $rs = safe_w_sql($delete); ?> </table> </form> <br> <a class="Link" href="Configuration.php"><?php echo get_text('Back'); ?> </a> </div> </div> <?php include 'Common/Templates/tail.php';
/** * Viene chiamata per fare i passaggi di fase delle finali * * @param array int $keys: vettore delle chiavi per il passaggio di fase * @param array int $team: 0 individuali 1 squadre * @param boolean &$error: true se il post processo genera un errore */ private function nextPhase($keys, $team, &$error) { /* * Se non ci sono $keys buone non ho passaggi di fase e il post-processing fallisce */ if (count($keys) == 0) { $error = true; return; } foreach ($keys as $key => $value) { $events = implode(',', array_keys($value)); $query = ""; if ($team == 0) { $query = "SELECT GrPhase AS Phase,GrPosition AS Position,\t/* Grids*/ " . "FinMatchNo AS MatchNo,FinEvent AS Event, FinAthlete AS Id, FinScore AS Score,FinTie AS Tie, " . "IF(GrPhase>2, FLOOR(FinMatchNo/2),FLOOR(FinMatchNo/2)-2) AS NextMatchNo " . "FROM Finals INNER JOIN Grids ON FinMatchNo=GrMatchNo AND GrPhase=" . StrSafe_DB($key) . " " . "LEFT JOIN Entries ON FinAthlete=EnId AND FinEvent IN(" . $events . ') ' . "WHERE FinTournament=" . $this->getTourId() . " " . "ORDER BY FinEvent, NextMatchNo ASC, FinScore DESC, FinTie DESC "; } else { $query = "SELECT GrPhase AS Phase,GrPosition AS Position,\t/* Grids*/ " . "TfTeam AS Id,TfMatchNo AS MatchNo,TfEvent AS Event, TfScore AS Score,TfTie AS Tie, " . "IF(GrPhase>2, FLOOR(TfMatchNo/2),FLOOR(TfMatchNo/2)-2) AS NextMatchNo " . "FROM TeamFinals INNER JOIN Grids ON TfMatchNo=GrMatchNo AND GrPhase=" . StrSafe_DB($key) . " " . "WHERE TfTournament=" . $this->getTourId() . " AND TfEvent IN (" . $events . ") " . "ORDER BY TfEvent, NextMatchNo ASC, TfScore DESC, TfTie DESC "; } //print $query . '<br>';exit; $rs = safe_r_SQL($query); $myNextMatchNo = 'xx'; $row = array(); if (safe_num_rows($rs) > 0) { while ($row0 = safe_fetch($rs)) { $row1 = safe_fetch($rs); $athProp = 0; $myUpQuery = ""; if ($row0->Phase >= 2) { if (($row0->Score > 0 || $row0->Tie > 0) && ($row0->Score != $row1->Score || $row0->Tie != $row1->Tie)) { if ($team == 0) { $myUpQuery = "UPDATE Finals SET "; $myUpQuery .= "FinAthlete =" . StrSafe_DB($row0->Id) . ", "; $myUpQuery .= "FinDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " "; $myUpQuery .= "WHERE FinEvent=" . StrSafe_DB($row0->Event) . " AND FinMatchNo=" . StrSafe_DB($row0->NextMatchNo) . " AND FinTournament=" . $this->getTourId() . " "; } else { $myUpQuery = "UPDATE TeamFinals SET "; $myUpQuery .= "TfTeam =" . StrSafe_DB($row0->Id) . ", "; $myUpQuery .= "TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " "; $myUpQuery .= "WHERE TfEvent=" . StrSafe_DB($row0->Event) . " AND TfMatchNo=" . StrSafe_DB($row0->NextMatchNo) . " AND TfTournament=" . $this->getTourId() . " "; } //print $myUpQuery . '<br><br>'; $rsUp = safe_w_sql($myUpQuery); $athProp = $row0->Id; } else { if ($team == 0) { $myUpQuery = "UPDATE Finals SET "; $myUpQuery .= "FinAthlete ='0', "; $myUpQuery .= "FinDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " "; $myUpQuery .= "WHERE FinEvent=" . StrSafe_DB($row0->Event) . " AND FinMatchNo=" . StrSafe_DB($row0->NextMatchNo) . " AND FinTournament=" . $this->getTourId() . " "; } else { $myUpQuery = "UPDATE TeamFinals SET "; $myUpQuery .= "TfTeam ='0', "; $myUpQuery .= "TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " "; $myUpQuery .= "WHERE TfEvent=" . StrSafe_DB($row0->Event) . " AND TfMatchNo=" . StrSafe_DB($row0->NextMatchNo) . " AND TfTournament=" . $this->getTourId() . " "; } $rsUp = safe_w_sql($myUpQuery); } } if ($row1->Phase == 2) { if (($row1->Score > 0 || $row1->Tie > 0) && ($row0->Score != $row1->Score || $row0->Tie != $row1->Tie)) { if ($team == 0) { $myUpQuery = "UPDATE Finals SET "; $myUpQuery .= "FinAthlete =" . StrSafe_DB($row1->Id) . ", "; $myUpQuery .= "FinDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " "; $myUpQuery .= "WHERE FinEvent=" . StrSafe_DB($row1->Event) . " AND FinMatchNo=" . StrSafe_DB($row1->NextMatchNo + 2) . " AND FinTournament=" . $this->getTourId() . " "; } else { $myUpQuery = "UPDATE TeamFinals SET "; $myUpQuery .= "TfTeam =" . StrSafe_DB($row1->Id) . ", "; $myUpQuery .= "TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " "; $myUpQuery .= "WHERE TfEvent=" . StrSafe_DB($row1->Event) . " AND TfMatchNo=" . StrSafe_DB($row1->NextMatchNo + 2) . " AND TfTournament=" . $this->getTourId() . " "; } $rsUp = safe_w_sql($myUpQuery); $athProp = $Row1->FinAthlete; } else { if ($team == 0) { $myUpQuery = "UPDATE Finals SET "; $myUpQuery .= "FinAthlete =" . StrSafe_DB($row1->Id) . ", "; // 0 $myUpQuery .= "FinDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " "; $myUpQuery .= "WHERE FinEvent=" . StrSafe_DB($row1->Event) . " AND FinMatchNo=" . StrSafe_DB($row1->NextMatchNo + 2) . " AND FinTournament=" . $this->getTourId() . " "; } else { $myUpQuery = "UPDATE TeamFinals SET "; $myUpQuery .= "TfTeam =" . StrSafe_DB($row1->Id) . ", "; // 0 $myUpQuery .= "TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " "; $myUpQuery .= "WHERE TfEvent=" . StrSafe_DB($row1->Event) . " AND TfMatchNo=" . StrSafe_DB($row1->NextMatchNo + 2) . " AND TfTournament=" . $this->getTourId() . " "; } $rsUp = safe_w_sql($myUpQuery); } // Devo fare la propagazione del nome se il matchno>7 (fase>2) $oldId = $athProp != 0 ? StrSafe_DB($row1->Id) : StrSafe_DB($row0->Id) . ',' . StrSafe_DB($row1->Id); $update = ""; if ($team == 0) { $update = "UPDATE Finals SET " . "FinAthlete=" . StrSafe_DB($athProp) . " " . "WHERE FinAthlete IN (" . $oldId . ") AND FinTournament=" . $this->getTourId() . " AND FinEvent=" . StrSafe_DB($row0->Event) . " AND FinMatchNo<" . StrSafe_DB($row0->NextMatchNo) . " AND (FinScore<>0 OR FinTie<>0) "; } else { $update = "UPDATE TeamFinals SET " . "TfTeam=" . StrSafe_DB($athProp) . " " . "WHERE TfTeam IN (" . $oldId . ") AND TfTournament=" . $this->getTourId() . " AND TfEvent=" . StrSafe_DB($row0->Event) . " AND TfMatchNo<" . StrSafe_DB($row0->NextMatchNo) . " AND (TfScore<>0 OR TfTie<>0) "; } //print $update . '<br><br>'; $rsProp = safe_w_sql($update); if (safe_w_affected_rows() > 0) { $error = false; } } } } } }
list($EcClass, $EcDivision) = explode('~', $_REQUEST['DelRow']); //print $EcClass . ' - ' . $EcDivision . '<br>';exit; $Delete = "DELETE FROM EventClass " . "WHERE EcCode=" . StrSafe_DB($_REQUEST['EvCode']) . " AND EcClass=" . StrSafe_DB($EcClass) . " AND EcDivision=" . StrSafe_DB($EcDivision) . " " . "AND EcTeamEvent!='0' AND EcTournament=" . StrSafe_DB($_SESSION['TourId']) . " "; //print $Delete;exit; $Rs = safe_w_sql($Delete); // calcolo il numero massimo di persone nel team calcMaxTeamPerson(array($_REQUEST['EvCode'])); // cancello le righe di Team per l'evento passato $queries[] = "DELETE FROM Teams WHERE TeTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND TeFinEvent=1 AND TeEvent=" . StrSafe_DB($_REQUEST['EvCode']) . " "; // cancello i nomi $queries[] = "DELETE FROM TeamComponent WHERE TcTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND TcFinEvent=1 AND TcEvent=" . StrSafe_DB($_REQUEST['EvCode']) . " "; // cancello i nomi fin $queries[] = "DELETE FROM TeamFinComponent WHERE TfcTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND TfcEvent=" . StrSafe_DB($_REQUEST['EvCode']) . " "; // elimino le griglie $queries[] = "DELETE FROM TeamFinals " . "WHERE TfEvent=" . StrSafe_DB($_REQUEST['EvCode']) . " AND TfTournament=" . StrSafe_DB($_SESSION['TourId']) . " "; $Rs = safe_w_sql($Delete); // reset shootoff ResetShootoff($_REQUEST['EvCode'], 1, 0); // teamabs MakeTeamsAbs(null, null, null); header('Location: SetEventRules.php?EvCode=' . $_REQUEST['EvCode']); exit; } $JS_SCRIPT = array('<script type="text/javascript" src="' . $CFG->ROOT_DIR . 'Common/ajax/ObjXMLHttpRequest.js"></script>', '<script type="text/javascript" src="' . $CFG->ROOT_DIR . 'Final/Team/Fun_AJAX_SetEventRules.js"></script>', '<script type="text/javascript" src="' . $CFG->ROOT_DIR . 'Common/Fun_JS.inc.js"></script>', '<script type="text/javascript" src="' . $CFG->ROOT_DIR . 'Final/Team/Fun_JS.js"></script>'); $PAGE_TITLE = get_text('TeamDefinition'); include 'Common/Templates/head.php'; ?> <div align="center"> <div class="medium"> <table class="Tabella" id="MyTable"> <tbody id="tbody">
} if ($version < '2013-05-02 12:11:00') { $r = safe_w_sql("ALTER TABLE CasGrid ENGINE = MYISAM ", false, array(1060)); $r = safe_w_sql("ALTER TABLE CasScore ENGINE = MYISAM ", false, array(1060)); $r = safe_w_sql("ALTER TABLE CasTeam ENGINE = MYISAM ", false, array(1060)); $r = safe_w_sql("ALTER TABLE CasTeamFinal ENGINE = MYISAM ", false, array(1060)); $r = safe_w_sql("ALTER TABLE CasTeamTarget ENGINE = MYISAM ", false, array(1060)); db_save_version('2013-05-02 12:11:00'); } if ($version < '2013-06-13 11:00:00') { $q = "update `Flags`\nset FlSVG=0x7d90cb6e83400c45f7fd0acbdd82c7f30ad32a93acc2aebbf6035020804420821154fdfa0eb4ddf4b5b174afceb125ef8fafd70ee66a9cdaa1f7288911aafe3c946d5f7b7c79ce5387c7c3dd7e9a6b88643f796c42b83d0ab12c0b2d9a86b1168a9945241096b60c4d5c130b84a66aeb2678b431c41563750e7069bbcee3bdd20f27b3fb8717df840df895d699fd419f3266a9ff10a4fa106e4568be843ccf114a8f4fd6185289624baeb08674b20e6090090327ce9129768a6cb28ead96c0e95a5f53a9c9c1aa77ce904c55463ab50a324976de90ee33bd6de7d7871dde01\n, FlJPG=0x2f396a2f34414151536b5a4a5267414241514541534142494141442f32774244414149424151454241514942415145434167494341675144416749434167554542414d4542675547426759464267594742776b494267634a427759474341734943516f4b43676f4b4267674c4441734b44416b4b4367722f327742444151494341674943416755444177554b4277594843676f4b43676f4b43676f4b43676f4b43676f4b43676f4b43676f4b43676f4b43676f4b43676f4b43676f4b43676f4b43676f4b43676f4b43676f4b43676f4b4367722f774141524341426b414d67444152454141684542417845422f385141484141424141494441414d414141414141414141414141414141674a4267634b41514d462f3851414d784141415149454177634441775143417741414141414141414d4541514947427755496c52455847565a583074514a456a45544956454b46434a4346544e426359482f7841415a4151454141774542414141414141414141414141414141414267634a42416a2f7841416e45514541414149474377414141414141414141414141414141674d42424264546b74494642676356466c4a566b5a5452302f2f61414177444151414345514d5241443841673255573349414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414145427438643365716c536134343779356431364d75494d4d50706a686166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a7a664864337170556d754f4f386272305a6351595966526166744c3633572f4a6e5a324f4865677741414141414141414141414d3679375a5a4d775762613562577a32576d7a2b505672557275574d3665465941776d586e6b546847454a6c564a6f6678525368474d50636f70475753586244624741457237736670322f5558734e5479474b58796357686f7a456e53454657744e565a65366e384f664c512f4576376831496a4e48623976737073322f38414945506273576175665932715a714d757452727242332f302f716f53726532644a306c474d5951575157546a4d6d34536a4745595156546d6d6b6d3252325452417867414141414141414141414141414141414141414141414141396a4e6d367842326b77597470316c31314a5530555570597a54547a7a5232516c6843487a474d59374e674852586d2b716d6e763074336f36305a59374c566865484e387846353452537143746c477961713662704a43525445486b735a6f5267704931693453624e6b342f776c697442574d4a7076715155446e6d72717661347568562b4958427556574f4b56426a324c4f5a6e474b597a6a5439523036647254664b6969716b597a547a522f4d59786942382b624563516d772b58435a6e793057736930565a473056592f546c556a4345497a776c2b49545268434549782b59776844384157325a377630752b6266476271322b727230364c5352716568376e5554682b4d4f3236324d746d71644b34684d31516d6449724b4f564a4966516e6d5569716a37647332794d36634a592f536847634b30733175585a396c5076766a325872484c6b303156574d5575342f5a592f6946494f6c5847486f503566397a564e5a524e4f4b30794d32314b65614576732b704a5043574d3073734a35673130414141414141414141414141414141414141414141426b46703677613238756e544e66766d55584b474231417978425a7443454e7173694b38696b5a50762b5953375038413043397a3961546237453772326e7934357a72634f7638414d55497133784c4434347330327a49537878424a6f385971776a442b717953433859522b332b715838675542675331394d483157492b6d76574d745377795557647564746451572f7956613031395447576678396d6237624e2b316a39766e36552f3841304230355a7766575139504f78464555665a764e706d4c6657777832394e746f3467795777464e793564553833654e6f53534f4a6e445a47655a745043645365434b3079634a597a7435356f776c684a45446b677a61324a595a634c2f77425132717747376c4f312f677a4e354658414b33705846456e624c4732436e386b585573366338304a4a357059374645706f2b394a5357644f6237795241317541414141414141414141414141414141414141414141417462394b2f31364c4630316c4366656c5436754e724d51722b7875494d34737343782f4430347234685479455a2f664968504a37705a314555564e69694b715530466d385a595379537153776b6c544455575a4c30792f537652654f62685a512f57377473366f39654d56326d45584770584847324d736b6f2f65435579624e67724f356e68442b30454564736636512b514958585a702b30464b347a44414c543344784772556b49782f64592b3477574f484e6c70766a3274305a3535315a6b2f7474677172394b61623362496f796533624d486d2b64397270356b626b764c73336b7178786a4f4e76554737655a797648374a4e32364d694464424f58346b545453546b546c6c68385379772b59375967596941414141414141414141414141414141414141414141414141414141414141414141414141414141466976434c7933633756787154507843433854312f6c683755356e6e693172574f366c59592f6f6349764c647a745847704d2f4548453966355965314f597461316a75705747503648434c79336337567871545078427850582b574874546d4c577459377156686a2b6877693874334f3163616b7a38516354312f6c68375535693172574f366c59592f6f6349764c647a745847704d2f4548453966355965314f597461316a75705747503648434c79336337567871545078427850582b574874546d4c577459377156686a2b6877693874334f3163616b7a38516354312f6c68375535693172574f366c59592f6f6349764c647a745847704d2f4548453966355965314f597461316a75705747503648434c79336337567871545078427850582b574874546d4c577459377156686a2b6877693874334f3163616b7a38516354312f6c68375535693172574f366c59592f6f6349764c647a745847704d2f4548453966355965314f597461316a75705747503648434c79336337567871545078427850582b574874546d4c577459377156686a2b6877693874334f3163616b7a38516354312f6c68375535693172574f366c59592f6f6349764c647a745847704d2f4548453966355965314f597461316a75705747503648434c79336337567871545078427850582b574874546d4c577459377156686a2b6877693874334f3163616b7a38516354312f6c68375535693172574f366c59592f6f6349764c647a745847704d2f4548453966355965314f597461316a75705747503648434c79336337567871545078427850582b574874546d4c577459377156686a2b6877693874334f3163616b7a38516354312f6c68375535693172574f366c59592f6f6349764c647a745847704d2f4548453966355965314f597461316a75705747503648434c79336337567871545078427850582b574874546d4c577459377156686a2b6877693874334f3163616b7a38516354312f6c68375535693172574f366c59592f6f6349764c647a745847704d2f4548453966355965314f597461316a75705747503648434c79336337567871545078427850582b574874546d4c577459377156686a2b6877693874334f3163616b7a38516354312f6c68375535693172574f366c59592f6f6c4f5231567741414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141412f2f5a\n, FlEntered='2013-06-13 08:17:14'\nwhere FlTournament=-1\nand FlCode='LBA'"; $r = safe_w_sql($q, false, array(1060)); db_save_version('2013-06-13 11:00:00'); } if ($version < '2013-07-08 15:00:00') { $q = "insert into Flags (select FlTournament, FlIocCode, 'TTO', FlSVG, FlJPG, FlEntered, FlChecked, FlContAssoc from Flags where FlIocCode='FITA' and FlCode='TRI')"; $r = safe_w_sql($q, false, array(1060)); db_save_version('2013-07-08 15:00:00'); } if ($version < '2013-07-21 18:05:00') { $q = "REPLACE INTO `LookUpPaths` (`LupIocCode`, `LupFors`, `LupPath`, `LupPhotoPath`, `LupFlagsPath`, `LupLastUpdate`) VALUES\n\t\t('NOR', '', 'http://nor.service.ianseo.net/IanseoData.php', '', '', ''),\n\t\t('NOR_s', '', 'http://nor.service.ianseo.net/IanseoData.php?ScoreClass=1', '', '', '')"; $r = safe_w_sql($q, false, array()); db_save_version('2013-07-21 18:05:00'); } if ($version < '2013-12-19 12:30:00') { $q = "drop table if exists `DistanceInformation`"; $r = safe_w_sql($q, false, array(1060)); $q = "CREATE TABLE if not exists `DistanceInformation` (\n\t\t\t`DiTournament` int(10) NOT NULL,\n\t\t\t`DiSession` tinyint(3) NOT NULL,\n\t\t\t`DiDistance` tinyint(3) NOT NULL,\n\t\t\t`DiEnds` tinyint(3) NOT NULL,\n\t\t\t`DiArrows` tinyint(3) NOT NULL,\n\t\t\t`DiMaxpoints` int(11) NOT NULL,\n\t\t\t`DiStart` datetime NOT NULL,\n\t\t\t`DiEnd` datetime NOT NULL,\n\t\t\t`DiWarmup` datetime NOT NULL,\n\t\t\t`DiOptions` text NOT NULL,\n\t\t\tPRIMARY KEY (`DiTournament`,`DiSession`,`DiDistance`)\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8"; $r = safe_w_sql($q, false, array(1060)); db_save_version('2013-12-19 12:30:00'); }
if ($ev != '') { if ($Fase == 0) { ResetElimRows($ev, 2); } Obj_RankFactory::create('ElimInd', array('eventsC' => array($ev . '@' . ($Fase + 1))))->calculate(); } // azzero gli shootoff /*$Update = "UPDATE Events INNER JOIN EventClass ON EvCode=EcCode AND EvTeamEvent='0' AND EcTournament=" . StrSafe_DB($_SESSION['TourId']) . " " . "INNER JOIN Entries ON EcDivision=EnDivision AND EcClass=EnClass AND EnId=" . StrSafe_DB($Atleta) . " " . "SET EvShootOff='0' " . ($Fase==0 ? ", EvE2ShootOff='0' " : "") . "WHERE EvTeamEvent='0' AND EvTournament=" . StrSafe_DB($_SESSION['TourId']) . " "; $Rs=safe_w_sql($Update); set_qual_session_flags();*/ $q = "\r\n\t\t\t\t\t\tSELECT EvCode\r\n\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\tEvents\r\n\t\t\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t\t\tEventClass\r\n\t\t\t\t\t\t\tON EvCode=EcCode AND EvTeamEvent='0' AND EcTournament={$_SESSION['TourId']}\r\n\t\t\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t\t\tEntries\r\n\t\t\t\t\t\t\tON EcDivision=EnDivision AND EcClass=EnClass AND EnId={$Atleta}\r\n\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t EvTeamEvent='0' AND EvTournament={$_SESSION['TourId']}\r\n\t\t\t\t\t"; $Rs = safe_w_sql($q); if ($Rs && safe_num_rows($Rs) > 0) { while ($row = safe_fetch($Rs)) { //print $Fase.'<br>'; ResetShootoff($row->EvCode, 0, $Fase == 0 ? 1 : 2); } } if (debug) { print $Update . '<br>'; } } // estraggo i totali $Select = "SELECT ElId, ElElimPhase, " . $Cosa . " " . "FROM Eliminations WHERE ElId=" . StrSafe_DB($Atleta) . " AND ElElimPhase=" . StrSafe_DB($Fase); $Rs = safe_r_sql($Select); //print $Select; $Errore = 0;
<?php require_once dirname(dirname(dirname(__FILE__))) . '/config.php'; CheckTourSession(true); require_once 'Common/Fun_FormatText.inc.php'; if (!empty($_FILES) and !empty($_FILES['ImportBackNumbers']['tmp_name'])) { $Bns = unserialize(gzuncompress(implode('', file($_FILES['ImportBackNumbers']['tmp_name'])))); foreach ($Bns as $Bn) { unset($Bn->BnTournament); unset($Bn->BnFinal); $sql = "replace into BackNumber set BnTournament={$_SESSION['TourId']}"; foreach ($Bn as $field => $value) { $sql .= ", {$field}=" . StrSafe_DB($value); } $sql .= ", BnFinal=1"; safe_w_sql($sql); } cd_redirect(basename(__FILE__)); } $JS_SCRIPT = array('<script type="text/javascript" src="../../Common/Fun_JS.inc.js"></script>', '<script type="text/javascript">', 'function DisableChkOther(NoDist, NumDist)', '{', ' if(NoDist)', ' {', ' if(document.getElementById(\'ChkDist0\').checked)', ' {', ' for(i=1; i<=NumDist; i++)', ' document.getElementById(\'ChkDist\'+i).checked=false;', ' }', ' }', ' else', ' {', ' for(i=1; i<=NumDist; i++)', ' {', ' if(document.getElementById(\'ChkDist\'+i).checked)', ' document.getElementById(\'ChkDist0\').checked=false;', ' }', ' }', '', '}', '</script>'); include 'Common/Templates/head.php'; echo '<table class="Tabella">'; echo '<tr><th class="Title" colspan="2">' . get_text('PrintBackNo', 'BackNumbers') . '</th></tr>'; //Parametri echo '<tr>'; //Pettorali Personali echo '<td class="Center" width="60%"><br><a href="PDFBackNumber.php" class="Link" target="PrintOut">'; echo '<img src="../../Common/Images/pdf.gif" alt="' . get_text('IndFinal') . '" border="0"><br>'; echo get_text('IndFinal'); echo '</a></td>'; echo '<td class="Center" width="40%" rowspan="2">';
} $Errore = 0; if (!IsBlocked(BIT_BLOCK_TOURDATA) && !defined('dontEditClassDiv')) { $Age = $_REQUEST['Age']; $ClId = $_REQUEST['ClId']; if (!is_numeric($Age)) { $Errore = 1; } else { $ClDivAllowed = empty($_REQUEST['AlDivs']) ? '' : $_REQUEST['AlDivs']; if (!CheckClassAge($ClId, $Age, $_REQUEST['FromTo'], $ClDivAllowed)) { $Errore = 1; } } if (!$Errore) { $Update = "UPDATE Classes SET " . "ClAge" . $_REQUEST['FromTo'] . "=" . StrSafe_DB($Age) . " " . ", ClDivisionsAllowed=" . StrSafe_DB($ClDivAllowed) . " " . "WHERE ClId=" . StrSafe_DB($ClId) . " AND ClTournament=" . StrSafe_DB($_SESSION['TourId']) . ""; $Rs = safe_w_sql($Update); $err = safe_w_error(); if ($err->errno != 0) { $Errore = 1; } } } else { $Errore = 1; } if (!debug) { header('Content-Type: text/xml'); } print '<response>' . "\n"; print '<error>' . $Errore . '</error>' . "\n"; print '<clid>' . $_REQUEST['ClId'] . '</clid>' . "\n"; print '<fromto>' . $_REQUEST['FromTo'] . '</fromto>' . "\n";
$recalc = false; $indFEvent = $teamFEvent = $country = $div = $cl = $zero = null; // se cambio status ricalcolo gli spareggi $query = "SELECT EnClass FROM Entries WHERE EnId=" . StrSafe_DB($id) . " AND EnStatus<>" . StrSafe_DB($status) . " "; //print $query;exit; $rs = safe_r_sql($query); if ($rs && safe_num_rows($rs) == 1) { $recalc = true; $x = Params4Recalc($id); if ($x !== false) { list($indFEvent, $teamFEvent, $country, $div, $cl, $zero) = $x; } } //Adesso aggiorno lo status $query = "UPDATE " . "Entries " . "SET " . "EnStatus=" . StrSafe_DB($status) . " " . "WHERE " . "EnId=" . StrSafe_DB($id) . " "; $rs = safe_w_sql($query); if (!$rs) { $error = 1; } if ($recalc) { // ricalcolo il vecchio e il nuovo if (!is_null($indFEvent)) { RecalculateShootoffAndTeams($indFEvent, $teamFEvent, $country, $div, $cl, $zero); } // rank di classe x tutte le distanze $q = "SELECT ToNumDist FROM Tournament WHERE ToId={$_SESSION['TourId']}"; $r = safe_r_sql($q); $tmpRow = safe_fetch($r); for ($i = 0; $i < $tmpRow->ToNumDist; ++$i) { if (!is_null($indFEvent)) { CalcQualRank($i, $div . $cl);
// recreates the tabl foreach ($_REQUEST['Records'] as $Val) { $Flags = array(); if (!empty($_REQUEST['RecBar'][$Val])) { $Flags[] = 'bar'; } if (!empty($_REQUEST['RecGap'][$Val])) { $Flags[] = 'gap'; } safe_w_sql("insert into TourRecords\r\n\t\t\t\t\t\tselect distinct '{$_SESSION['TourId']}'\r\n\t\t\t\t\t\t\t, ReType\r\n\t\t\t\t\t\t\t, ReCode\r\n\t\t\t\t\t\t\t, ReTeam\r\n\t\t\t\t\t\t\t, RePara\r\n\t\t\t\t\t\t\t, '" . substr($_REQUEST['RecColor'][$Val], 1) . "'\r\n\t\t\t\t\t\t\t, '" . implode(',', $Flags) . "'\r\n\t\t\t\t\t\tfrom Records where ReType='{$Val}' and RePara=" . ($_SESSION['TourLocRule'] == 'PAR' ? '1' : '0')); } } // removes the records on the tour that are non to follow anymore safe_w_sql("delete from RecTournament where RtTournament={$_SESSION['TourId']} and RtRecType not in (select TrRecType from TourRecords where TrTournament={$_SESSION['TourId']})"); // inserts/updates into the RecTournament the situation of records updated BEFORE the Tour Ends safe_w_sql("insert into RecTournament (\r\n\t\t\t\t\tselect '{$_SESSION['TourId']}',\r\n\t\t\t\t\t\tReType,\r\n\t\t\t\t\t\tReCode,\r\n\t\t\t\t\t\tReTeam,\r\n\t\t\t\t\t\tRePara,\r\n\t\t\t\t\t\tReCategory,\r\n\t\t\t\t\t\tReDistance,\r\n\t\t\t\t\t\tReTotal,\r\n\t\t\t\t\t\tReXNine,\r\n\t\t\t\t\t\tReDate,\r\n\t\t\t\t\t\tReExtra,\r\n\t\t\t\t\t\tReLastUpdated\r\n\t\t\t\t\tfrom Records where ReDate<='{$_SESSION['TourRealWhenFrom']}'\r\n\t\t\t\t\t\tand ReTourType='{$_SESSION['TourType']}'\r\n\t\t\t\t\t\tand RePara=" . ($_SESSION['TourLocRule'] == 'PAR' ? '1' : '0') . "\r\n\t\t\t\t\t\tand ReType in (select TrRecType from TourRecords where TrTournament={$_SESSION['TourId']}) )\r\n\t\t\t\ton duplicate key update\r\n\t\t\t\t\tRtRecTotal = ReTotal,\r\n\t\t\t\t\tRtRecXNine = ReXNine,\r\n\t\t\t\t\tRtRecDate = ReDate ,\r\n\t\t\t\t\tRtRecExtra = ReExtra,\r\n\t\t\t\t\tRtRecLastUpdated=ReLastUpdated\r\n\t\t\t\t"); } } $q = "\r\n\t\tSELECT\r\n\t\t\tToTypeName,\r\n\t\t\tToNumDist,\r\n\t\t\tToNumEnds,\r\n\t\t\tToMaxDistScore,\r\n\t\t\tToMaxFinIndScore,\r\n\t\t\tToMaxFinTeamScore,\r\n\t\t\tToCategory,\r\n\t\t\tToElabTeam,\r\n\t\t\tToElimination,\r\n\t\t\tToGolds,\r\n\t\t\tToXNine,\r\n\t\t\tToGoldsChars,\r\n\t\t\tToXNineChars,\r\n\t\t\tToDouble\r\n\t\tFROM\r\n\t\t\tTournament\r\n\t\tWHERE\r\n\t\t\tToId={$_SESSION['TourId']}\r\n\t"; $r = safe_r_sql($q); $tour = null; if (safe_num_rows($r) == 1) { $tour = safe_fetch($r); } if ($tour === null) { exit; } $goldsChars = array(); for ($i = 0; $i < strlen($tour->ToGoldsChars); ++$i) { $goldsChars[] = DecodeFromLetter($tour->ToGoldsChars[$i]); }