Changeset 380 for trunk


Ignore:
Timestamp:
Mar 11, 2010, 7:21:43 PM (15 years ago)
Author:
george
Message:
  • Opraveno: Správně vylomítkování podřetězce SQL dotazu při volání exportu.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/export/export.php

    r377 r380  
    2525    if($DbResult->num_rows == 0) die('Export '.$this->Id.' neexistuje');
    2626    $this->Export = $DbResult->fetch_assoc();
    27 
     27   
    2828    // Filter selected languages
    2929    $this->WhereLang = '';
    3030    $DbResult = $this->Database->query('SELECT * FROM `ExportLanguage` WHERE `Export`='.$this->Id.' ORDER BY `Sequence`');
     31    echo($this->Database->error);
    3132    while($Language = $DbResult->fetch_assoc())
    32       $this->WhereLang .= ' OR (Language = '.$Language['Language'].')';
     33      $this->WhereLang .= ' OR (`Language` = '.$Language['Language'].')';
    3334    if($this->WhereLang == '') $this->WhereLang = 1;
    3435      else $this->WhereLang = '('.substr($this->WhereLang, 4).')';
     
    5253    } else
    5354    {
    54       $this->WhereUsers = '(User IN ('.$this->SelectedUsers.'))';
    55       $this->OrderByUserList = ' ORDER BY FIELD(User, '.$this->SelectedUsers.')';
     55      $this->WhereUsers = '(`User` IN ('.$this->SelectedUsers.'))';
     56      $this->OrderByUserList = ' ORDER BY FIELD(`User`, '.$this->SelectedUsers.')';
    5657    }
    5758   
     
    221222  function ExportToDBC()
    222223  {
    223     global $TranslationTree, $LanguageList,$Config;
     224    global $TranslationTree, $LanguageList, $Config;
    224225 
    225226    $this->LoadFilters();
    226227
    227228    $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id.' AND `Group`.`DBCFileName` != ""');
    228     while($Group = $DbResult->fetch_assoc())
    229     {
    230       echo($Group['Name'].'... ');
    231         if(file_exists('../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc')) {
    232                  
    233          $i = 1;
    234          $columns = '';
    235          foreach($TranslationTree[$Group['Id']]['Items'] as $Column) {
    236            $columns .= ' `T`.`'.$Column['Column'].'` AS `Text`'.$i.',';
    237            $i = $i+1;
    238          }
    239          
    240          $querty = '"SELECT '.$columns.' `T`.`Entry` AS `Entry` FROM (SELECT * FROM '.$Group['TablePrefix'].' WHERE (`Complete` = 1) AND '.$this->WhereLang.' AND '.$this->WhereUsers.' AND (`VersionStart` <= '.$this->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$this->ClientVersion['BuildNumber'].')) AS `T` GROUP BY `T`.`Entry`"';
     229    echo('Počet generovaných skupin: '.$DbResult->num_rows.'<br/>'."\n");
     230    while($Group = $DbResult->fetch_assoc())
     231    {
     232      echo($Group['Name'].', ');
     233      if(file_exists('../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc'))
     234      {
     235        $i = 1;
     236        $columns = '';
     237        foreach($TranslationTree[$Group['Id']]['Items'] as $Column)
     238        {
     239          $columns .= ' `T`.`'.$Column['Column'].'` AS `Text'.$i.'`,';
     240          $i = $i + 1;
     241        }
     242        $Query = 'SELECT '.$columns.' `T`.`Entry` AS `Entry` FROM (SELECT * FROM `'.$Group['TablePrefix'].'` WHERE (`Complete` = 1) AND '.$this->WhereLang.' AND '.$this->WhereUsers.' AND (`VersionStart` <= '.$this->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$this->ClientVersion['BuildNumber'].')) AS `T` GROUP BY `T`.`Entry`';
     243        $Query = str_replace('`', '\`', $Query);
     244        $Query = '"'.str_replace(' ', '\ ', $Query).'"';
    241245     
    242        $params = '-u '.$Config['Database']['User'].' -p '.$Config['Database']['Password'].' -f ../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc -n '.$this->TempDir.'dbc/'.$Group['DBCFileName'].'.dbc -c '.GetDBCColumns($this->ClientVersion['Version'], $Group['DBCFileName']).' -q '.$querty;
     246        $params = '-u '.$Config['Database']['User'].' -p '.$Config['Database']['Password'].' -f ../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc -n '.$this->TempDir.'dbc/'.$Group['DBCFileName'].'.dbc -c '.GetDBCColumns($this->ClientVersion['Version'], $Group['DBCFileName']).' -q '.$Query;
    243247     
    244      //  echo('./DBCExport '.$params);
     248        //echo('./DBCExport '.$params);       
     249        exec('./DBCExport '.$params);
    245250       
    246        exec('./DBCExport '.$params);
    247        
    248       echo('Hotovo <br />
    249 ');
    250251      } else echo('Zdrojový soubor '.'../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc'.' nenalezen.'."\n");
    251252    }
     253    echo('Hotovo <br />');
    252254  }
    253255
  • trunk/includes/global_function.php

    r376 r380  
    138138  }
    139139  return(array(
    140     'SQL' => ' ORDER BY '.$_SESSION['OrderCol'].' '.$OrderDirSQL[$_SESSION['OrderDir']],
     140    'SQL' => ' ORDER BY `'.$_SESSION['OrderCol'].'` '.$OrderDirSQL[$_SESSION['OrderDir']],
    141141    'Output' => '<tr>'.$Result.'</tr>',
    142142    'Column' => $_SESSION['OrderCol'],
  • trunk/save.php

    r376 r380  
    1616  $Language = $_POST['Language'] * 1;
    1717  if(array_key_exists('End', $_POST)) $Complete = 1;
    18     else $complete = 0;
     18    else $Complete = 0;
    1919             
    2020  $DbResult = $Database->SQLCommand('SELECT * FROM `'.$Table.'` WHERE (`Language` = 0) AND (`Entry` = '.$Entry.')');
Note: See TracChangeset for help on using the changeset viewer.