$error = 0; function safe(&$item) { $item = StrSafe_DB($item); } $schedule = isset($_REQUEST['schedule']) && preg_match('/^[0-9]{4}\\-[0-9]{2}\\-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/', $_REQUEST['schedule']) ? $_REQUEST['schedule'] : null; $events = isset($_REQUEST['events']) && is_array($_REQUEST['events']) ? $_REQUEST['events'] : null; $team = isset($_REQUEST['team']) ? $_REQUEST['team'] : null; $serverDate = isset($_REQUEST['serverDate']) ? $_REQUEST['serverDate'] : null; $parameters = isset($_REQUEST['parameters']) ? $_REQUEST['parameters'] : null; if (!CheckTourSession() || is_null($schedule) || is_null($events) || is_null($team) || is_null($serverDate)) { exit; } // se ho i parametri li salvo if (!is_null($parameters) && strlen($parameters) > 0) { SetParameter('SpkTimer', $parameters); } $query = "SELECT UNIX_TIMESTAMP(NOW()) AS serverDate "; $rs = safe_r_sql($query); $row = safe_fetch($rs); $xml .= '<serverDate>' . $row->serverDate . '</serverDate>' . "\n"; $reset = 0; if (count($events) > 0 && $events[0] != '') { array_walk($events, 'safe'); $otherWhere = "\r\n\t\t\tAND fs1.FSTeamEvent=" . StrSafe_DB($team) . " AND (fs1.FSEvent IN(" . implode(',', $events) . ") OR fs2.FSEvent IN(" . implode(',', $events) . ") )\r\n\t\t\tAND (CONCAT(fs1.FSScheduledDate,' ',fs1.FSScheduledTime)=" . StrSafe_DB($schedule) . " OR CONCAT(fs2.FSScheduledDate,' ',fs2.FSScheduledTime)=" . StrSafe_DB($schedule) . ")\r\n\t\t"; /* * cerco se ci sono scontri aggiornati rispetto alla serverDate passata, se sì ritorno tutto altrimenti nulla */ $otherWhere2 = ''; if ($team == 0) { $otherWhere2 = $otherWhere . "AND UNIX_TIMESTAMP(IF(f1.FinDateTime>=f2.FinDateTime,f1.FinDateTime,f2.FinDateTime))>" . StrSafe_DB($serverDate) . " ";
function db_save_version($newversion) { //Aggiorno alla versione attuale SOLO le gare che erano alla versione immediatamente precedente $oldDbVersion = GetParameter('DBUpdate'); safe_w_sql("UPDATE Tournament SET ToDbVersion='{$newversion}' WHERE ToDbVersion='{$oldDbVersion}'"); SetParameter('DBUpdate', $newversion); SetParameter('SwUpdate', ProgramVersion); }
while ($row = safe_fetch($rs)) { $q = insertIntoGridForF2F_21($row->ToId); $rs2 = safe_w_sql($q, false, array(1062)); } } db_save_version('2012-01-24 15:16:00'); } if ($version < '2012-01-26 14:48:00') { $q = "ALTER TABLE `F2FEntries` ADD `F2FRankFinal` SMALLINT( 6 ) NOT NULL DEFAULT '0' AFTER `F2FRankScore` ;"; $r = safe_w_sql($q, false, array(1060)); db_save_version('2012-01-26 14:48:00'); } if ($version < '2012-02-29 15:30:00') { $q = "ALTER TABLE `Parameters` CHANGE `ParId` `ParId` VARCHAR( 15 ) NOT NULL "; $r = safe_w_sql($q, false, array(1060)); SetParameter('OnClickMenu', ''); db_save_version('2012-02-29 15:30:00'); } if ($version < '2012-03-31 18:30:00') { $q = "ALTER TABLE `Tournament` ADD `ToOptions` text NOT NULL"; $r = safe_w_sql($q, false, array(1060)); db_save_version('2012-03-31 18:30:00'); } if ($version < '2012-04-01 11:30:02') { $q = "ALTER TABLE HhtData ADD `HdTimeStamp` DATETIME NOT NULL default '0000-00-00 00:00:00', ADD INDEX ( `HdTournament` , `HdTimeStamp` , `HdDistance` , `HdArrowStart` ) "; $r = safe_w_sql($q, false, array(1060)); db_save_version('2012-04-01 11:30:02'); } if ($version < '2012-05-07 10:15:00') { $q = "CREATE TABLE `ModulesParameters` (\n\t\t`MpModule` VARCHAR( 50 ) NOT NULL ,\n\t\t`MpParameter` VARCHAR( 20 ) NOT NULL ,\n\t\t`MpTournament` INT UNSIGNED NOT NULL ,\n\t\t`MpValue` TEXT NOT NULL ,\n\t\tPRIMARY KEY ( `MpModule` , `MpParameter` , `MpTournament` )\n\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8"; $r = safe_w_sql($q, false, array(1050));