当前位置: 首页>>代码示例>>PHP>>正文


PHP safe_r_sql函数代码示例

本文整理汇总了PHP中safe_r_sql函数的典型用法代码示例。如果您正苦于以下问题:PHP safe_r_sql函数的具体用法?PHP safe_r_sql怎么用?PHP safe_r_sql使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了safe_r_sql函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: read

 /**
  * read()
  *
  * @Override
  *
  * (non-PHPdoc)
  * @see ianseo/Common/Rank/Obj_Rank#calculate()
  */
 public function read()
 {
     $f = $this->safeFilter();
     $filter = $f !== false ? $f : "";
     if (array_key_exists('cutRank', $this->opts) && is_numeric($this->opts['cutRank']) && $this->opts['cutRank'] > 0) {
         $filter .= "AND Teams.teRank<={$this->opts['cutRank']} ";
     }
     $q = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tTeTournament,CoId,TeSubTeam,CoCode,CoName, TeEvent,EvEventName,ToNumEnds,ToNumDist,ToMaxDistScore,FlContAssoc,\r\n\t\t\t\t\tEvMaxTeamPerson, EvProgr, EvFinalFirstPhase,\r\n\t\t\t\t\tClDescription, DivDescription,\r\n\t\t\t\t\tEnId,EnCode,EnFirstName,upper(EnFirstName) EnFirstNameUpper,EnName,EnClass,EnDivision,EnAgeClass,EnSubClass,\r\n\t\t\t\t\tIF(EvFinalFirstPhase=48, 104, IF(EvFinalFirstPhase=24, 56, (EvFinalFirstPhase*2))) AS QualifiedNo,\tEvQualPrintHead,\r\n\t\t\t\t\tSUBSTRING(QuTargetNo,1,1) AS Session, SUBSTRING(QuTargetNo,2) AS TargetNo,\r\n\t\t\t\t\tQuHits*EvMaxTeamPerson AS Arrows_Shot, QuScore, TeScore,TeRank, TeGold, TeXnine, ToGolds, ToXNine,TeHits,\r\n\t\t\t\t\tTeRank, EvRunning, IF(EvRunning=1,IFNULL(ROUND(TeScore/TeHits,3),0),0) as RunningScore,\r\n\t\t\t\t\tABS(TeSO) AS RankBeforeSO,\r\n\t\t\t\t\ttie.Quanti,\r\n\t\t\t\t\tTeTieBreak,(TeSO>0) AS isSO,IFNULL(sqY.Quanti,1) AS `NumCT`,\r\n\t\t\t\t\tIFNULL(Td1,'.1.') as Td1, IFNULL(Td2,'.2.') as Td2, IFNULL(Td3,'.3.') as Td3, IFNULL(Td4,'.4.') as Td4, IFNULL(Td5,'.5.') as Td5, IFNULL(Td6,'.6.') as Td6, IFNULL(Td7,'.7.') as Td7, IFNULL(Td8,'.8.') as Td8,\r\n\t\t\t\t\tTeTimeStamp, DiEnds, DiArrows\r\n\t\t\t\tFROM\r\n\t\t\t\t\tTournament\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tTeams\r\n\t\t\t\t\tON ToId=TeTournament AND TeFinEvent=1\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tCountries\r\n\t\t\t\t\tON TeCoId=CoId AND TeTournament=CoTournament\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tEvents\r\n\t\t\t\t\tON TeEvent=EvCode AND ToId=EvTournament AND EvTeamEvent=1\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\tSELECT\r\n\t\t\t\t\t\t\t\tTeEvent as tieEvent, TeFinEvent as tieFinEvent, TeTournament as tieTournament, TeScore as tieScore, Count(*) as Quanti\r\n\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\tTeams\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tTeTournament = {$this->tournament}  {$filter}\r\n\t\t\t\t\t\t\tGROUP BY\r\n\t\t\t\t\t\t\t\tTeEvent, TeFinEvent, TeTournament, TeScore\r\n\t\t\t\t\t\t) AS tie\r\n\t\t\t\t\tON Teams.TeEvent=tie.tieEvent AND Teams.TeTournament=tie.tieTournament AND Teams.TeFinEvent=tie.tieFinEvent AND Teams.TeScore=tie.tieScore\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tTeamComponent AS tc\r\n\t\t\t\t\tON Teams.TeCoId=tc.TcCoId AND Teams.TeSubTeam=tc.TcSubTeam AND  Teams.TeEvent=tc.TcEvent AND Teams.TeTournament=tc.TcTournament AND Teams.TeFinEvent=tc.TcFinEvent\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tEntries\r\n\t\t\t\t\tON TcId=EnId\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tQualifications\r\n\t\t\t\t\tON EnId=QuId\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tDivisions\r\n\t\t\t\t\tON EnDivision=DivId AND EnTournament=DivTournament\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tClasses\r\n\t\t\t\t\tON EnClass=ClId AND EnTournament=ClTournament\r\n\t\t\t\t/* Contatori per CT (gialli)*/\r\n\t\t\t\t\tLEFT JOIN\r\n\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\tSELECT\r\n\t\t\t\t\t\t\t\tTeEvent as sqyEvent,Count(*) as Quanti, TeSO as sqyRank, TeTournament as sqyTournament\r\n\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\tTeams\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tTeTournament = {$this->tournament} AND TeFinEvent=1 AND TeSO!=0 {$filter}\r\n\t\t\t\t\t\t\tGROUP BY\r\n\t\t\t\t\t\t\t\tTeSO, TeEvent, TeTournament\r\n\t\t\t\t\t\t) AS sqY\r\n\t\t\t\t\tON sqY.sqyRank=TeSO AND sqY.sqyEvent=Teams.TeEvent AND Teams.TeFinEvent=1 AND sqY.sqyTournament=Teams.TeTournament\r\n\t\t\t\t\tLEFT JOIN\r\n\t\t\t\t\t\tTournamentDistances\r\n\t\t\t\t\tON ToType=TdType AND TdTournament=ToId AND TeEvent like TdClasses\r\n\t\t\t\t\tLEFT JOIN\r\n\t\t\t\t\t\tFlags\r\n\t\t\t\t\t\tON FlIocCode='FITA' and FlCode=CoCode and FlTournament=-1\r\n\t\t\t\t\tleft join DistanceInformation on EnTournament=DiTournament and DiSession=1 and DiDistance=1 and DiType='Q'\r\n\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\tTeams.TeTournament={$this->tournament}\r\n\t\t\t\t\t{$filter}\r\n\t\t\t\tORDER BY\r\n\t\t\t\t\tEvProgr,TeEvent, RunningScore DESC, TeRank ASC, TeGold DESC, TeXnine DESC, CoCode, TeSubTeam ,tc.TcOrder\r\n\t\t\t";
     $r = safe_r_sql($q);
     $this->data['meta']['title'] = get_text('ResultSqAbs', 'Tournament');
     $this->data['meta']['lastUpdate'] = '0000-00-00 00:00:00';
     $this->data['sections'] = array();
     $myEv = '';
     $myTeam = '';
     if (safe_num_rows($r) > 0) {
         $section = null;
         while ($row = safe_fetch($r)) {
             if ($myEv != $row->TeEvent) {
                 if ($myEv != '') {
                     foreach ($section["meta"]["arrowsShot"] as $k => $v) {
                         if ($v) {
                             $section["meta"]["sesArrows"][$k] = get_text('AfterXArrows', 'Common', $v);
                         }
                     }
                     $this->data['sections'][$myEv] = $section;
                     $section = null;
                 }
                 $myEv = $row->TeEvent;
                 $fields = array('id' => 'Id', 'countryCode' => get_text('CountryCode'), 'countryName' => get_text('Country'), 'subteam' => get_text('PartialTeam'), 'athletes' => array('name' => get_text('Athletes'), 'fields' => array('id' => 'Id', 'bib' => get_text('Code', 'Tournament'), 'session' => get_text('Session'), 'target' => get_text('Target'), 'athlete' => get_text('Athlete'), 'familyname' => get_text('FamilyName', 'Tournament'), 'givenname' => get_text('Name', 'Tournament'), 'div' => get_text('Division'), 'class' => get_text('Cl'), 'ageclass' => get_text('AgeCl'), 'subclass' => get_text('SubCl', 'Tournament'), 'quscore' => get_text('TotaleScore'))), 'rank' => get_text('PositionShort'), 'rankBeforeSO' => '', 'score' => $row->EvRunning == 1 ? get_text('ArrowAverage') : get_text('TotaleScore'), 'gold' => $row->ToGolds, 'xnine' => $row->ToXNine, 'hits' => get_text('Arrows', 'Tournament'), 'tiebreak' => get_text('TieArrows'), 'tie' => get_text('Tie'), 'ct' => get_text('CoinTossShort', 'Tournament'), 'so' => get_text('ShotOffShort', 'Tournament'));
                 $distFields = array();
                 $distValid = $row->ToNumDist;
                 foreach (range(1, 8) as $n) {
                     $distFields['dist_' . $n] = $row->{'Td' . $n};
                     if ($distFields['dist_' . $n] == '-') {
                         $distValid--;
                     }
                 }
                 $section = array('meta' => array('event' => $myEv, 'firstPhase' => $row->EvFinalFirstPhase, 'descr' => get_text($row->EvEventName, '', '', true), 'qualifiedNo' => $row->QualifiedNo, 'printHeader' => $row->EvQualPrintHead, 'order' => $row->EvProgr, 'numDist' => $distValid, 'maxScore' => $row->ToMaxDistScore * $row->EvMaxTeamPerson, 'maxArrows' => ($row->DiEnds ? $row->DiEnds * $row->DiArrows : $row->ToNumEnds * 3) * $row->EvMaxTeamPerson, 'arrowsShot' => array(), 'sesArrows' => array(), 'running' => $row->EvRunning == 1 ? 1 : 0, 'fields' => $fields), 'items' => array());
             }
             if ($myTeam != $row->CoId . $row->TeSubTeam . $row->TeEvent) {
                 $tmpArr = array();
                 for ($countArr = 0; $countArr < strlen(trim($row->TeTieBreak)); $countArr = $countArr + $row->EvMaxTeamPerson) {
                     $tmpArr[] = ValutaArrowString(substr(trim($row->TeTieBreak), $countArr, $row->EvMaxTeamPerson)) . ",";
                 }
                 $item = array('id' => $row->CoId, 'countryCode' => $row->CoCode, 'contAssoc' => $row->FlContAssoc, 'countryName' => $row->CoName, 'subteam' => $row->TeSubTeam, 'athletes' => array(), 'rank' => $row->TeRank, 'rankBeforeSO' => $row->RankBeforeSO, 'score' => $row->EvRunning == 1 ? $row->RunningScore : $row->TeScore, 'gold' => $row->TeGold, 'xnine' => $row->TeXnine, 'hits' => $row->TeHits, 'recordGap' => $row->Arrows_Shot * 10 - $row->TeScore, 'tiebreak' => $row->TeTieBreak, 'tiebreakDecoded' => $row->TeTieBreak ? 'T.' . implode(',', $tmpArr) : '', 'ct' => $row->NumCT, 'tie' => $row->Quanti > 1, 'so' => $row->isSO);
                 //Gestisco il numero di frecce tirate per sessione
                 if (empty($section["meta"]["arrowsShot"][$row->Session]) || $section["meta"]["arrowsShot"][$row->Session] <= $row->Arrows_Shot) {
                     $section["meta"]["arrowsShot"][$row->Session] = $row->Arrows_Shot;
                 }
                 $section['items'][] = $item;
                 if ($row->TeTimeStamp > $this->data['meta']['lastUpdate']) {
                     $this->data['meta']['lastUpdate'] = $row->TeTimeStamp;
                 }
                 $myTeam = $row->CoId . $row->TeSubTeam . $row->TeEvent;
             }
             if (!array_key_exists('components', $this->opts) || $this->opts['components']) {
                 $athlete = array('id' => $row->EnId, 'bib' => $row->EnCode, 'session' => $row->Session, 'target' => $row->TargetNo, 'athlete' => $row->EnFirstNameUpper . ' ' . $row->EnName, 'familyname' => $row->EnFirstName, 'familynameUpper' => $row->EnFirstNameUpper, 'givenname' => $row->EnName, 'div' => $row->EnDivision, 'class' => $row->EnClass, 'ageclass' => $row->EnAgeClass, 'subclass' => $row->EnSubClass, 'quscore' => $row->QuScore);
                 $section['items'][count($section['items']) - 1]['athletes'][] = $athlete;
             }
         }
         foreach ($section["meta"]["arrowsShot"] as $k => $v) {
             if ($v) {
                 $section["meta"]["sesArrows"][$k] = str_replace("<br/>", " ", get_text('AfterXArrows', 'Common', $v));
             }
         }
         // ultimo giro
         $this->data['sections'][$myEv] = $section;
     }
 }
开发者ID:brian-nelson,项目名称:ianseo,代码行数:77,代码来源:Obj_Rank_AbsTeam.php

示例2: findOutOfRange

function findOutOfRange()
{
    global $flags;
    /*
     * Per ogni sessione eliminatoria con i parametri settati calcolo il range corretto dei suoi bersagli.
     * Poi tra le righe che agganciano una sessione controllo la bontà del target impostato
     */
    $sessions = GetSessions('E');
    $ranges = array();
    foreach ($sessions as $s) {
        // se ogni parametro è >0
        if ($s->SesTar4Session * $s->SesAth4Target * $s->SesFirstTarget > 0) {
            $range = array();
            for ($tt = $s->SesFirstTarget; $tt < $s->SesTar4Session + $s->SesFirstTarget; ++$tt) {
                for ($aa = 1; $aa <= $s->SesAth4Target; ++$aa) {
                    $range[] = str_pad($tt, TargetNoPadding, '0', STR_PAD_LEFT) . chr($aa + 64);
                }
            }
            $ranges[$s->SesOrder] = $range;
        }
    }
    // adesso controllo i bersagli
    $q = "\r\n\t\t\tSELECT CONCAT(ElElimPhase,'_',ElEventCode,'_',ElQualRank,'_',ElTournament) AS `Id`,ElSession,ElTargetNo\r\n\t\t\tFROM\r\n\t\t\t\tEliminations\r\n\t\t\tWHERE\r\n\t\t\t\tElTournament={$_SESSION['TourId']}\r\n\t\t";
    $r = safe_r_sql($q);
    while ($MyRow = safe_fetch($r)) {
        if ($MyRow->ElSession != 0 && trim($MyRow->ElTargetNo) != '') {
            $flags[$MyRow->Id]['out'] = !in_array($MyRow->ElTargetNo, $ranges[$MyRow->ElSession]) ? 0 : 1;
        }
    }
}
开发者ID:brian-nelson,项目名称:ianseo,代码行数:30,代码来源:FindRedTarget.php

示例3: getStatEntriesByCountriesQuery

function getStatEntriesByCountriesQuery($ORIS = false, $Athletes = false)
{
    $Sql = "";
    if ($ORIS) {
        $Sql = "SELECT SUM(IF((DivAthlete AND ClAthlete AND EnSex=0), 1,0)) as M, SUM(IF((DivAthlete AND ClAthlete AND EnSex=1), 1,0)) as W, SUM(IF((DivAthlete AND ClAthlete), 0,1)) as Of, ";
        $Sql .= "CoCode as NationCode, CoName as NationName ";
        $Sql .= "FROM Entries ";
        $Sql .= "INNER JOIN Countries ON EnCountry = CoId ";
        $Sql .= "LEFT JOIN Divisions ON EnDivision=DivId AND DivTournament=" . StrSafe_DB($_SESSION['TourId']) . " ";
        $Sql .= "LEFT JOIN Classes ON EnClass=ClId AND ClTournament=" . StrSafe_DB($_SESSION['TourId']) . " ";
        $Sql .= "WHERE EnTournament = " . StrSafe_DB($_SESSION['TourId']) . " ";
        $Sql .= "GROUP BY CoCode ";
        $Sql .= "ORDER BY CoCode ";
    } else {
        $Sql = "SELECT DISTINCT CONCAT(TRIM(EnDivision),'|',TRIM(EnClass)) as Id, (DivAthlete AND ClAthlete) as isAthlete " . "FROM Entries " . "LEFT JOIN Divisions ON EnDivision=DivId AND DivTournament=" . StrSafe_DB($_SESSION['TourId']) . " " . "LEFT JOIN Classes ON EnClass=ClId AND ClTournament=" . StrSafe_DB($_SESSION['TourId']) . " " . "WHERE EnTournament = " . StrSafe_DB($_SESSION['TourId']) . " " . ($Athletes ? 'AND DivAthlete=1 AND ClAthlete=1 ' : '') . "ORDER BY LENGTH(EnDivision) DESC, DivViewOrder, EnDivision, LENGTH(EnClass) DESC, ClViewOrder, EnClass";
        $Rs = safe_r_sql($Sql);
        $Sql = "SELECT ";
        if (safe_num_rows($Rs) > 0) {
            while ($MyRow = safe_fetch($Rs)) {
                $Sql .= "SUM(IF(CONCAT(TRIM(EnDivision),'|',TRIM(EnClass))='" . $MyRow->Id . "',1,0)) as `" . $MyRow->Id . "`, ";
            }
            safe_free_result($Rs);
        }
        $Sql .= "CoCode as NationCode, CoName as NationName ";
        $Sql .= "FROM Entries ";
        $Sql .= "INNER JOIN Countries ON EnCountry = CoId ";
        $Sql .= "WHERE EnTournament = " . StrSafe_DB($_SESSION['TourId']) . " ";
        $Sql .= "GROUP BY CoCode ";
        $Sql .= "ORDER BY CoCode ";
    }
    return $Sql;
}
开发者ID:brian-nelson,项目名称:ianseo,代码行数:32,代码来源:StartListQueries.php

示例4: GetParameter

function GetParameter($ParameterName)
{
    $TmpSql = "SELECT ParValue FROM Parameters WHERE ParId=" . StrSafe_DB($ParameterName);
    $Rs = safe_r_sql($TmpSql, false, true);
    if ($Rs and $TmpRow = safe_fetch($Rs)) {
        return $TmpRow->ParValue;
    }
    return '';
}
开发者ID:brian-nelson,项目名称:ianseo,代码行数:9,代码来源:Fun_DB.inc.php

示例5: __construct

 function __construct($TemplateID = 0)
 {
     parent::__construct('BackNumber');
     $Select = "SELECT BackNumber.*, LENGTH(BnBackground) as ImgSize  " . "FROM BackNumber  " . "WHERE BnTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND BnFinal in (0," . $TemplateID . ") order by BnFinal desc limit 1";
     //print $Select;exit;
     $Rs = safe_r_sql($Select);
     if (safe_num_rows($Rs) == 1) {
         $this->RowBn = safe_fetch($Rs);
     } else {
         // fall back if no Backnumber creates from template!
         include_once 'Tournament/BackNumberEmpty.php';
         $this->RowBn = emptyBackNumber();
     }
     $this->Rotation = $this->RowBn->BnOffsetX != 0 || $this->RowBn->BnOffsetY != 0;
     $this->RotX = $this->RowBn->BnWidth / 2;
     $this->RotY = $this->RowBn->BnOffsetY / 2;
     // TargetNo Specs
     $this->TargetNoFont = ($this->RowBn->BnTargetNo & 4) == 4 ? $this->FontFix : (($this->RowBn->BnTargetNo & 2) == 2 ? 'dejavuserif' : $this->FontStd);
     $this->TargetNoStyle = ($this->RowBn->BnTargetNo & 8 ? 'B' : '') . ($this->RowBn->BnTargetNo & 16 ? 'I' : '');
     $this->TargetNoColor = array(base_convert(substr($this->RowBn->BnTnoColor, 0, 2), 16, 10), base_convert(substr($this->RowBn->BnTnoColor, 2, 2), 16, 10), base_convert(substr($this->RowBn->BnTnoColor, 4, 2), 16, 10));
     $this->TargetNoAlign = ($this->RowBn->BnTargetNo & 96) == 64 ? 'L' : (($this->RowBn->BnTargetNo & 96) == 32 ? 'R' : 'C');
     // Athlete Specs
     $this->AthleteFont = ($this->RowBn->BnAthlete & 4) == 4 ? $this->FontFix : (($this->RowBn->BnAthlete & 2) == 2 ? 'dejavuserif' : $this->FontStd);
     $this->AthleteStyle = ($this->RowBn->BnAthlete & 8 ? 'B' : '') . ($this->RowBn->BnAthlete & 16 ? 'I' : '');
     $this->AthleteColor = array(base_convert(substr($this->RowBn->BnAthColor, 0, 2), 16, 10), base_convert(substr($this->RowBn->BnAthColor, 2, 2), 16, 10), base_convert(substr($this->RowBn->BnAthColor, 4, 2), 16, 10));
     $this->AthleteAlign = ($this->RowBn->BnAthlete & 96) == 64 ? 'L' : (($this->RowBn->BnAthlete & 96) == 32 ? 'R' : 'C');
     if ($this->RowBn->BnCapitalFirstName) {
         $this->FirstNameAllCaps = true;
     }
     // Country Specs
     $this->CountryFont = ($this->RowBn->BnCountry & 4) == 4 ? $this->FontFix : (($this->RowBn->BnCountry & 2) == 2 ? 'dejavuserif' : $this->FontStd);
     $this->CountryStyle = ($this->RowBn->BnCountry & 8 ? 'B' : '') . ($this->RowBn->BnCountry & 16 ? 'I' : '');
     $this->CountryColor = array(base_convert(substr($this->RowBn->BnCoColor, 0, 2), 16, 10), base_convert(substr($this->RowBn->BnCoColor, 2, 2), 16, 10), base_convert(substr($this->RowBn->BnCoColor, 4, 2), 16, 10));
     $this->CountryAlign = ($this->RowBn->BnCountry & 96) == 64 ? 'L' : (($this->RowBn->BnCountry & 96) == 32 ? 'R' : 'C');
     // background temp creation
     if ($this->RowBn->ImgSize) {
         $this->BackGroundFile = tempnam('/tmp', 'bgf');
         $img = imagecreatefromstring($this->RowBn->BnBackground);
         if (!imagepng($img, $this->BackGroundFile)) {
             die('could not create image');
         }
     }
     $Orientation = $this->RowBn->BnWidth > $this->RowBn->BnHeight ? 'L' : 'P';
     $this->setPageOrientation($Orientation);
     $this->setPageFormat(array($this->RowBn->BnWidth, $this->RowBn->BnHeight), $Orientation);
     $this->SetFont($this->FontStd, '', 10);
     $this->AliasNbPages();
     $this->setPrintHeader(false);
     $this->setPrintFooter(false);
     $this->SetMargins(10, 10, 10);
     $this->SetAutoPageBreak(false, 10);
     $this->SetAuthor('http://www.ianseo.net');
     $this->SetCreator('Software Design by Ianseo');
     $this->SetTitle('IANSEO - Integrated Result System (release ' . ProgramVersion . ')');
     $this->SetSubject('BackNo');
 }
开发者ID:brian-nelson,项目名称:ianseo,代码行数:56,代码来源:BackNoPDF.php

示例6: calculateAgeClass

function calculateAgeClass($dateOfBirth, $gender, $division = '')
{
    $allowedClass = array();
    $age = intval(substr($_SESSION['TourRealWhenTo'], 0, 4) - substr($dateOfBirth, 0, 4));
    // get the classes based on the division selected
    $Select = "SELECT DISTINCT ClId " . "FROM Classes " . "INNER JOIN Divisions on DivTournament=ClTournament and DivAthlete=ClAthlete " . ($division ? "AND DivId='{$division}' " : '') . "WHERE ClTournament={$_SESSION['TourId']} " . "AND (ClDivisionsAllowed='' or find_in_set(DivId, ClDivisionsAllowed)) " . "AND ClSex in (-1, {$gender}) " . ($age ? "AND (ClAthlete!='1' or (ClAgeFrom<={$age} and ClAgeTo>={$age})) " : '') . "ORDER BY ClViewOrder, DivViewOrder ";
    $RsCl = safe_r_sql($Select);
    while ($MyRow = safe_fetch($RsCl)) {
        $allowedClass[] = $MyRow->ClId;
    }
    return $allowedClass;
}
开发者ID:brian-nelson,项目名称:ianseo,代码行数:12,代码来源:Fun_Entries.inc.php

示例7: create

 /**
  * create().
  * Metodo statico per istanziare la classe corretta.
  * La classe corretta viene scelta in base al parametro $family e deve trovarsi
  * nella directory /Common/Rank.
  *
  * Il nome del file e il nome della classe stessa deve essere nella seguente forma:
  * Obj_Rank_<family>_<type>_<lang>
  * con <family> la famiglia, <type> il tipo gara e <lang> la regola localizzata con <type> e <lang>
  * opzionali.
  *
  * Il metodo cerca nella directory se esiste prima di tutto il file corretto nella sequenza:
  * 1) Obj_Rank_<family>_<type>_<lang>
  * 2) Obj_Rank_<family>_<lang>
  * 3) Obj_Rank_<family>_<type>
  * 4) Obj_Rank_<family>
  *
  * @static
  *
  * @param string $family: famiglia
  * 		Attualmente per convenzione abbiamo:
  * 			DivClass 		=> classifica di Divisione/Classe individuale
  * 			SubClass 		=> classifica di Categoria/Classe di merito individuale
  * 			Snapshot 		=> classifica di Categoria/Classe o di Qualificazione basata sul metodo dell "Snapshot"
  * 			Abs 			=> classifica di qualificazione assoluta
  * 			AbsTeam 		=> classifica di qualificazione assoluta a squadre
  * 			ElimInd 		=> classifica fase eliminatoria individuale
  * 			FinalInd 		=> classifica finale individuale
  * 			DivClassTeam	=> classifica di Divisione/Classe s squadre
  * 			AbsTeam			=> classifica di qualificazione a squadre
  * 			FinalTeam 		=> classifica finale a squadre
  *
  * @param mixed[] $opts: opzioni usate dai vari metodi write() e read() dalle classi.
  * 		A seconda della classe sarà inizializzato in un qualche modo.
  * 		Ogni classe commenta la forma di $opts
  *
  * @see Obj_Rank_*
  *
  * @return mixed: istanza della classe corretta per gestire la rank
  *
  */
 public static function create($family, $opts = null)
 {
     /*
      * In base a $family, al tipo di torneo e alla localizzazione della regola
      * con cui il torneo è stato creato istanzio la classe giusta includendo quello che serve
      */
     global $CFG;
     // torneo passato
     $tournament = array_key_exists('tournament', $opts) ? $opts['tournament'] : $_SESSION['TourId'];
     // tipo e localizzazione
     $q = safe_r_sql("select ToType, ToLocRule from Tournament where ToId={$tournament}");
     $r = safe_fetch($q);
     $ToType = $r->ToType;
     $ToLocRule = $r->ToLocRule;
     // sicuramente includo la classe base
     if (!file_exists($CFG->DOCUMENT_PATH . 'Common/Rank/Obj_Rank.php')) {
         return null;
     }
     require_once 'Common/Rank/Obj_Rank.php';
     /*
      * Adesso in base alla famiglia, al tipo e alla localizzazione
      * cerco il file in questa sequenza:
      * 1) Obj_Rank_<family>_<type>_<lang>
      * 2) Obj_Rank_<family>_<lang>
      * 3) Obj_Rank_<family>_<type>
      * 4) Obj_Rank_<family>
      * Se neppure (4) esiste termino con errore (null) perchè il default è la base della famiglia
      * e voglio che esista!
      */
     //print $family.'<br/>';
     $name = 'Obj_Rank_' . $family;
     $rootLoc = $CFG->DOCUMENT_PATH . "Modules/Sets/{$ToLocRule}/Rank/" . $name . "%s.php";
     $rootGlobal = $CFG->DOCUMENT_PATH . "Common/Rank/" . $name . "%s.php";
     if (file_exists($file = sprintf($rootLoc, "_{$ToType}")) or file_exists($file = sprintf($rootLoc, "")) or file_exists($file = sprintf($rootGlobal, "_{$ToType}")) or file_exists($file = sprintf($rootGlobal, ""))) {
         // first step is to include base class!!!
         require_once $file;
         $name = basename($file, ".php");
         // check if the "calc" class exists
         if (file_exists($file = sprintf($rootLoc, "_{$ToType}_calc")) or file_exists($file = sprintf($rootLoc, "_calc")) or file_exists($file = sprintf($rootGlobal, "_{$ToType}_calc")) or file_exists($file = sprintf($rootGlobal, "_calc"))) {
             require_once $file;
             $name = basename($file, ".php");
         }
         // returns the found class
         return new $name($opts);
     } else {
         // no class found!
         return null;
     }
 }
开发者ID:brian-nelson,项目名称:ianseo,代码行数:90,代码来源:Obj_RankFactory.php

示例8: getModuleParameter

function getModuleParameter($module, $param, $defaultValue = '')
{
    static $Parameters = array();
    if (empty($Parameters[$module])) {
        $TmpSql = "SELECT MpValue, MpParameter\n\t\t\tFROM ModulesParameters\n\t\t\tWHERE MpModule=" . StrSafe_DB($module) . "\n\t\t\tAND MpTournament=" . StrSafe_DB($_SESSION['TourId']);
        $Rs = safe_r_sql($TmpSql);
        while ($r = safe_fetch($Rs)) {
            $Parameters[$module][$r->MpParameter] = $r->MpValue;
        }
    }
    if (isset($Parameters[$module][$param])) {
        return $Parameters[$module][$param];
    } else {
        return $defaultValue;
    }
}
开发者ID:brian-nelson,项目名称:ianseo,代码行数:16,代码来源:Fun_Modules.php

示例9: getGroupedTargets

function getGroupedTargets($TargetNo, $Session = 0, $SesType = 'Q', $SesPhase = '')
{
    global $CompId;
    // get all targets associated/grouped together with the target requested
    $SubSelect = "select TgGroup, TgSession, TgSesType\n\t\tfrom TargetGroups\n\t\twhere TgTournament={$CompId}\n\t\tand TgTargetNo='{$TargetNo}'";
    if ($SesType != 'Q') {
        $SubSelect .= " and TgSesType='{$SesType}{$SesPhase}'";
    }
    $Tmp = array();
    $q = safe_r_sql("Select TgTargetNo\n\t\tfrom TargetGroups\n\t\twhere TgTournament={$CompId}\n\t\tand (TgGroup, TgSession, TgSesType)=({$SubSelect}) order by TgTargetNo");
    while ($r = safe_fetch($q)) {
        $Tmp[] = $r->TgTargetNo;
    }
    if ($Tmp) {
        $TargetNo = implode("','", $Tmp);
    }
    return $TargetNo;
}
开发者ID:brian-nelson,项目名称:ianseo,代码行数:18,代码来源:config.php

示例10: SetElimArrowValue

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;
}
开发者ID:brian-nelson,项目名称:ianseo,代码行数:43,代码来源:Fun_Eliminations.local.inc.php

示例11: Get_Image

function Get_Image($IocCode = null, $Section = null, $Reference = null, $Type = null, $Tourid = 0)
{
    if (empty($Tourid)) {
        $Tourid = $_SESSION['TourId'];
    }
    $SQL = "select * from Images where ImTournament={$Tourid}";
    if (!isnull($IocCode)) {
        $SQL .= " and ImIocCode='{$IocCode}'";
    }
    if (!isnull($Section)) {
        $SQL .= " and ImSection='{$Section}'";
    }
    if (!isnull($Reference)) {
        $SQL .= " and ImReference='{$Reference}'";
    }
    if (!isnull($Type)) {
        $SQL .= " and ImType='{$Type}'";
    }
    $q = safe_r_sql($SQL);
}
开发者ID:brian-nelson,项目名称:ianseo,代码行数:20,代码来源:CommonLib.php

示例12: getTargets

function getTargets($ByDiv = true)
{
    $ar = array();
    $MySql = "select" . " DivId" . ", ClId" . ", TfId " . ", TfName " . ", TfDefault " . "from" . " Divisions" . " inner join Classes on DivTournament=ClTournament and DivAthlete=ClAthlete" . " inner join TargetFaces Tf on DivTournament=TfTournament and if(TfRegExp>'', concat(trim(DivId),trim(ClId)) REGEXP TfRegExp, concat(trim(DivId),trim(ClId)) like TfClasses) " . "WHERE" . " DivTournament={$_SESSION['TourId']} " . " AND DivAthlete='1' " . " AND (ClDivisionsAllowed='' or find_in_set(DivId, ClDivisionsAllowed))" . "order by" . " DivViewOrder" . ", ClViewOrder" . ", TfDefault desc" . ", TfRegExp>'' desc" . ", concat(trim(DivId),trim(ClId)) = TfClasses desc" . ", left(TfClasses,1)!='_' and left(TfClasses,1)!='%' desc" . ", left(TfClasses,1)='_' desc" . ", TfClasses desc" . ", TfClasses='%' ";
    $q = safe_r_sql($MySql);
    if ($ByDiv) {
        while ($r = safe_fetch($q)) {
            if (!$r->TfDefault or empty($ar[$r->DivId][$r->ClId])) {
                $ar[$r->DivId][$r->ClId][$r->TfId] = get_text($r->TfName, 'Tournament', '', true);
            }
        }
    } else {
        $divs = array();
        while ($r = safe_fetch($q)) {
            if (!$r->TfDefault or empty($divs[$r->DivId][$r->ClId])) {
                $ar[$r->TfId][$r->DivId][$r->ClId] = $r->TfDefault;
                $divs[$r->DivId][$r->ClId] = 'done';
            }
        }
    }
    return $ar;
}
开发者ID:brian-nelson,项目名称:ianseo,代码行数:22,代码来源:Fun_Targets.php

示例13: __construct

 public function __construct($tourId, $phase)
 {
     $this->setTourId($tourId);
     $this->setPhase($phase);
     // Estraggo le info del torneo
     /*$query
     		= "SELECT "
     			. "ToCode,ToName,IF(TtElabTeam=1 || TtElabTeam=2,'1',IF(INSTR(TtName,'Indoor')=0,'0','2' )) AS MyType "
     		. "FROM "
     			. "Tournament INNER JOIN Tournament*Type ON ToType=TtId "
     		. "WHERE "
     			. "ToId=" . $this->getTourId() . " ";*/
     $query = "SELECT " . "ToCode,ToName,IF(ToElabTeam=1 || ToElabTeam=2,'1',IF(INSTR(ToTypeName,'Indoor')=0,'0','2' )) AS MyType " . "FROM " . "Tournament " . "WHERE " . "ToId=" . $this->getTourId() . " ";
     $rs = safe_r_sql($query);
     if (safe_num_rows($rs) == 1) {
         $myRow = safe_fetch($rs);
         $this->setTourCode($myRow->ToCode);
         $this->setTourName($myRow->ToName);
         $this->setType($myRow->MyType);
     } else {
         $this->setError(1);
     }
 }
开发者ID:brian-nelson,项目名称:ianseo,代码行数:23,代码来源:ARF.class.php

示例14: FindLive

/**
 * Cerca quale evento è live in questo momento
 * Se trova più eventi contemporanei ritorna i dati di quello con modifiche più recenti.
 *
 * @param Int $Team: vale 0 se l'evento è individuale e 1 se è a squadre.
 *
 * @return Array: Un vettore formato dall'Evento e dal MatchNo oppure false in caso di errore.
 * 					Se non ci sono eventi live viene ritornato array(NULL,NULL)
 */
function FindLive($Team = -1)
{
    if ($Team == 0) {
        $Select = "SELECT" . "  '0' Team" . " , FinDateTime DateTime" . " , FinEvent AS Event" . " , FinMatchNo AS MatchNo" . " FROM" . "  Finals " . " WHERE" . "  FinTournament=" . StrSafe_DB($_SESSION['TourId']) . "  AND FinLive='1' " . "ORDER BY" . " Team," . " DateTime DESC," . " Event ASC," . " MatchNo ASC ";
    } elseif ($Team == 1) {
        $Select = "SELECT" . "  '1' Team " . " , TfDateTime DateTime" . " , TfEvent AS Event " . " , TfMatchNo AS MatchNo " . " FROM" . "  TeamFinals " . " WHERE" . "  TfTournament=" . StrSafe_DB($_SESSION['TourId']) . "  AND TfLive='1' " . "ORDER BY" . " Team," . " DateTime DESC," . " Event ASC," . " MatchNo ASC";
    } elseif ($Team == -1) {
        $Select = "(SELECT" . "  '0' Team" . " , FinDateTime DateTime" . " , FinEvent AS Event" . " , FinMatchNo AS MatchNo" . " FROM" . "  Finals " . " WHERE" . "  FinTournament=" . StrSafe_DB($_SESSION['TourId']) . "  AND FinLive='1') " . "UNION " . "(SELECT" . "  '1' Team " . " , TfDateTime DateTime " . " , TfEvent AS Event " . " , TfMatchNo AS MatchNo " . " FROM" . "  TeamFinals " . " WHERE" . "  TfTournament=" . StrSafe_DB($_SESSION['TourId']) . "  AND TfLive='1') " . "ORDER BY" . " Team," . " DateTime DESC," . " Event ASC," . " MatchNo ASC ";
    } else {
        return '';
    }
    $Rs = safe_r_sql($Select);
    // at least 2 rows because "live" is set on both opponents!
    if (safe_num_rows($Rs) < 2) {
        return '';
    }
    $MyRow1 = safe_fetch($Rs);
    $MyRow2 = safe_fetch($Rs);
    // check if these are really 2 opponents in the same match!!
    if ($MyRow1->Event == $MyRow2->Event and $MyRow1->Team == $MyRow2->Team and ($MyRow1->MatchNo == $MyRow2->MatchNo - 1 or $MyRow1->MatchNo == $MyRow2->MatchNo + 1)) {
        return array($MyRow1->Event, min($MyRow1->MatchNo, $MyRow2->MatchNo), $MyRow1->Team);
    }
    return '';
}
开发者ID:brian-nelson,项目名称:ianseo,代码行数:33,代码来源:Config.inc.php

示例15: SetAccreditation

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;
}
开发者ID:brian-nelson,项目名称:ianseo,代码行数:24,代码来源:Lib.php


注:本文中的safe_r_sql函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。