Ignore:
Timestamp:
Mar 11, 2010, 8:40:32 AM (15 years ago)
Author:
george
Message:
  • Upraveno: Informace o přihlášeném uživateli nově pročištěny a sjednoceny do třídy User. SQL pro kontrolu a generovány hesel dostupné přímo přes metodu CryptPasswordSQL. Přístup k Id přihlášeného uživatele přes globální proměnnou $User a vlastnost Id ($User->Id). Podobně přístup k dalším vlastnostem uživatele.
  • Opraveno: Některé chyby z předchozích předělávek.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/export/export.php

    r375 r376  
    1111  var $SelectedUsers;
    1212  var $UserNames;
    13   var $User;
    1413  var $ClientVersion;
    1514  var $OrderByUserList;
     
    3837    $this->UserNames = '';
    3938    $DbResult = $this->Database->query('SELECT `ExportUser`.*, `User`.`Name`, `User`.`ID` FROM `ExportUser` LEFT JOIN `User` ON `User`.`ID`=`ExportUser`.`User` WHERE `ExportUser`.`Export`='.$this->Id.' ORDER BY `ExportUser`.`Sequence`');
    40     while($User = $DbResult->fetch_assoc())
    41     {
    42       $this->SelectedUsers .= ','.$User['ID'];
    43       $this->UserNames .= ','.$User['Name'];
     39    while($UserLine = $DbResult->fetch_assoc())
     40    {
     41      $this->SelectedUsers .= ','.$UserLine['ID'];
     42      $this->UserNames .= ','.$UserLine['Name'];
    4443    }
    4544    $this->SelectedUsers = substr($this->SelectedUsers, 1);
     
    5655    }
    5756   
    58     // Load logged user
    59     if(isset($_SESSION) and ($_SESSION['UserID'] != ''))
    60     {
    61       $DbResult = $this->Database->query('SELECT `Name` FROM `User` WHERE `ID`='.$_SESSION['UserID']);
    62       $this->User = $DbResult->fetch_assoc();
    63     } else $this->User = array('User' => 'Neznámý');
    64 
    65 
    6657    $DbResult = $this->Database->query('SELECT * FROM `ClientVersion` WHERE `Id`='.$this->Export['ClientVersion']);
    6758    $this->ClientVersion = $DbResult->fetch_assoc();   
     
    7061  function ExportToMangosSQL()
    7162  {
    72     global $TranslationTree, $LanguageList;
     63    global $TranslationTree, $LanguageList, $User, $Config;
    7364 
    7465    $this->LoadFilters();
     
    8273      "-- Znaková sada: ".$this->Config['Database']['Charset']." / ".$this->Config['Web']['Charset']."\n".
    8374      "-- Diakritika: ".$this->AnoNe[$this->Export['WithDiacritic']]."\n".
    84       "-- Vygeneroval uživatel: ".$this->User['Name']."\n".
     75      "-- Vygeneroval uživatel: ".$User->Name."\n".
    8576      "-- Vzato od uživatelů: ".$this->UserNames."\n".
    8677      "-- Generované tabulky: ";
     
    8980    while($Group = $DbResult->fetch_assoc())
    9081    {
    91        $Buffer .= $Group['MangosTable'].', ';
     82      $Buffer .= $Group['TablePrefix'].', ';
    9283    }
    9384    $Buffer .= "\n\n"; 
     
    146137      {
    147138        $Ori_text = $Line['name'];
    148         $DbResult2 = $Database2->query('SELECT `text` AS en,
    149         (SELECT `text` FROM `'.$Config['Database']['Database'].'`.`global_strings` AS `tabletran`
    150          WHERE `tableen`.`entry` = `tabletran`.`entry` AND (`Complete` = 1) AND '.$this->WhereLang.' AND '.$this->WhereUsers.$this->OrderByUserList.' LIMIT 1) AS `tran`
    151          FROM `'.$Config['Database']['Database'].'`.`global_strings` AS `tableen` WHERE
    152           `text` = "'.addslashes($Ori_text).'" LIMIT 1');
     139        $DbResult2 = $Database2->query('SELECT `Text` AS `En`,
     140        (SELECT `Text` FROM `'.$Config['Database']['Database'].'`.`TextGlobalString` AS `TableTran`
     141         WHERE `TableEn`.`Entry` = `TableTran`.`Entry` AND (`Complete` = 1) AND '.$this->WhereLang.' AND '.$this->WhereUsers.$this->OrderByUserList.' LIMIT 1) AS `Tran`
     142         FROM `'.$Config['Database']['Database'].'`.`TextGlobalString` AS `TableEn` WHERE
     143          `Text` = "'.addslashes($Ori_text).'" LIMIT 1');
    153144        $Tran = $DbResult2->fetch_assoc();
    154145        //echo ($Line['name'].'='.$Tran['tran']);
    155         if($Tran['tran'] == '')
     146        if($Tran['Tran'] == '')
    156147        {
    157           $DbResult2 = $Database2->query('SELECT `OptionText` AS `en`,
    158           (SELECT `OptionText` FROM `'.$this->Config['Database']['Database'].'`.`npc_option` AS `tabletran`
    159            WHERE `tableen`.`entry` = `tabletran`.`entry` AND (`Complete` = 1) AND '.$this->WhereLang.'
    160             AND '.$this->WhereUsers.$this->OrderByUserList.' LIMIT 1) AS `tran`
    161           FROM `'.$this->Config['Database']['Database'].'`.`npc_option` AS `tableen` WHERE
     148          $DbResult2 = $Database2->query('SELECT `OptionText` AS `En`,
     149          (SELECT `OptionText` FROM `'.$this->Config['Database']['Database'].'`.`TextNPCOption` AS `TableTran`
     150           WHERE `TableEn`.`Entry` = `TableTran`.`Entry` AND (`Complete` = 1) AND '.$this->WhereLang.'
     151            AND '.$this->WhereUsers.$this->OrderByUserList.' LIMIT 1) AS `Tran`
     152          FROM `'.$this->Config['Database']['Database'].'`.`TextNPCOption` AS `TableEn` WHERE
    162153            `OptionText` = "'.addslashes($Ori_text).'" LIMIT 1');
    163154          $Tran = $DbResult2->fetch_assoc();
    164155        }
    165156       
    166         if($Tran['tran'] <> '')
    167           $Buffer .= 'UPDATE `'.$AoWoWTable.'` SET `name` = "'.addslashes($Tran['tran']).'" WHERE '.$IndexColum.' = '.$Line[$IndexColum].' ;'."\n";
     157        if($Tran['Tran'] <> '')
     158          $Buffer .= 'UPDATE `'.$AoWoWTable.'` SET `name` = "'.addslashes($Tran['Tran']).'" WHERE '.$IndexColum.' = '.$Line[$IndexColum].' ;'."\n";
    168159      }
    169160      $Buffer .= "\n\n"; 
     
    176167  function ExportToXML()
    177168  {
    178     global $TranslationTree, $LanguageList;
     169    global $TranslationTree, $LanguageList, $User;
    179170 
    180171    $this->LoadFilters($this->Id);
     
    186177    "    <time>".date('r')."</time>\n".
    187178    "    <diacritics mode=".'"'.$this->Export['WithDiacritic'].'"'." />\n".
    188     "    <author>".$this->User['Name']."</author>\n".
     179    "    <author>".$User->Name."</author>\n".
    189180    "    <contributors>\n";
    190181    foreach(explode(',', $this->UserNames) as $UserName)
     
    209200      while($Line = $DbResult2->fetch_assoc())
    210201      {
    211         $Buffer .= '      <item id="'.$Line['entry'].'" user="'.$Line['UserName'].'">'."\n";
     202        $Buffer .= '      <item id="'.$Line['Entry'].'" user="'.$Line['UserName'].'">'."\n";
    212203        $Values = '';
    213204        foreach($TranslationTree[$Group['Id']]['Items'] as $GroupItem)
     
    242233         $columns = '';
    243234         foreach($TranslationTree[$Group['Id']]['Items'] as $Column) {
    244            $columns .= ' T.'.$Column['Column'].' as text'.$i.',';
     235           $columns .= ' `T`.`'.$Column['Column'].'` AS `Text`'.$i.',';
    245236           $i = $i+1;
    246237         }
    247238         
    248          $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"';
     239         $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`"';
    249240     
    250241       $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;
Note: See TracChangeset for help on using the changeset viewer.