Changeset 376 for trunk/export


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.
Location:
trunk/export
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/export/create_addon.php

    r366 r376  
    174174    $Group = $TranslationTree[14]; // client table
    175175    $Column['Column'] = 'Text';
    176     $Query = 'SELECT T2.'.$Column['Column'].' AS Translation, T3.'.$Column['Column'].' as Original, T3.ShortCut FROM (SELECT T1.entry, T1.'.$Column['Column'].' FROM (SELECT entry,'.$Column['Column'].' FROM '.$Group['TablePrefix'].' WHERE (Complete = 1) AND VersionStart <= '.$this->ClientVersion['BuildNumber'].' AND VersionEnd >= '.$this->ClientVersion['BuildNumber'].' AND '.$this->WhereLang.' AND '.$this->WhereUsers.$this->OrderByUserList.') AS T1 GROUP BY T1.entry) as T2 JOIN '.$Group['TablePrefix'].' AS T3 ON (T2.entry = T3.entry) AND (T3.Language = 0)';
     176    $Query = 'SELECT `T2`.`'.$Column['Column'].'` AS `Translation`, `T3`.`'.$Column['Column'].'` AS `Original`, `T3`.`ShortCut` FROM (SELECT `T1`.`Entry`, `T1`.`'.$Column['Column'].'` FROM (SELECT `Entry`,`'.$Column['Column'].'` FROM '.$Group['TablePrefix'].' WHERE (`Complete` = 1) AND (`VersionStart` <= '.$this->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$this->ClientVersion['BuildNumber'].') AND '.$this->WhereLang.' AND '.$this->WhereUsers.$this->OrderByUserList.') AS `T1` GROUP BY `T1`.`Entry`) AS `T2` JOIN `'.$Group['TablePrefix'].'` AS `T3` ON (`T2`.`Entry` = `T3`.`Entry`) AND (`T3`.`Language` = 0)';
    177177    $DbResult = $this->Database->query($Query);
    178178    while($Line = $DbResult->fetch_array())
  • 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;
  • trunk/export/index.php

    r366 r376  
    66function ExportList()
    77{
    8   global $Database;
     8  global $Database, $User;
    99 
    1010  echo('<a href="?Action=ViewList">Všechny</a>');
    11   if(Licence(LICENCE_USER))
     11  if($User->Licence(LICENCE_USER))
    1212  {
    1313    echo(' <a href="?Action=ViewList&amp;Filter=Others">Ostatních</a>');
     
    1818  if(array_key_exists('Filter', $_GET))
    1919  {
    20     if($_GET['Filter'] == 'My') $Filter = ' WHERE `Export`.`User` = '.$_SESSION['UserID'];
    21     if($_GET['Filter'] == 'Others') $Filter = ' WHERE `Export`.`User` != '.$_SESSION['UserID'];
     20    if($_GET['Filter'] == 'My') $Filter = ' WHERE `Export`.`User` = '.$User->Id;
     21    if($_GET['Filter'] == 'Others') $Filter = ' WHERE `Export`.`User` != '.$User->Id;
    2222  }
    2323 
     
    4646  {
    4747    $Action = '<a href="?Action=View&amp;ExportId='.$Export['Id'].'">Zobrazit</a> <a href="?Action=View&amp;ExportId='.$Export['Id'].'&amp;Tab=6">Exportovat</a>';
    48     if($Export['User'] == $_SESSION['UserID']) $Action .= ' <a href="?Action=Delete&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\'Opravdu smazat položku?\');">Smazat</a>';
     48    if($Export['User'] == $User->Id) $Action .= ' <a href="?Action=Delete&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\'Opravdu smazat položku?\');">Smazat</a>';
    4949    echo('<tr><td>'.HumanDate($Export['TimeCreate']).'</td><td>'.$Export['UserName'].'</td><td>'.$Export['Title'].'</td><td>'.$Export['UsedCount'].'</td><td>'.$Export['UserCount'].'</td><td>'.$Export['GroupCount'].'</td><td>'.$Action.'</td></tr>');
    5050  }
     
    5252  echo($PageList['Output']);
    5353   
    54   if(Licence(LICENCE_USER)) echo('<br/><div style="text-align: center;"><a href="?Action=Create">Vytvořit nový export</a></div>');
     54  if($User->Licence(LICENCE_USER)) echo('<br/><div style="text-align: center;"><a href="?Action=Create">Vytvořit nový export</a></div>');
    5555}
    5656
    5757function ExportCreate()
    5858{
    59   global $Database, $Config;
    60  
    61   if(Licence(LICENCE_USER))
     59  global $Database, $Config, $User;
     60 
     61  if($User->Licence(LICENCE_USER))
    6262  {   
    63     $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM Export WHERE User='.$_SESSION['UserID']);
     63    $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `Export` WHERE `User`='.$User->Id);
    6464    $DbRow = mysql_fetch_row($DbResult);
    6565    if($DbRow[0] < $Config['MaxExportPerUser'])
     
    7777function ExportCreateFinish()
    7878{
    79   global $Database, $Config;
    80  
    81   if(Licence(LICENCE_USER))
     79  global $Database, $Config, $User;
     80 
     81  if($User->Licence(LICENCE_USER))
    8282  {   
    8383    if(array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST))
    8484    {
    85       $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `Export` WHERE `User`='.$_SESSION['UserID']);
     85      $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `Export` WHERE `User`='.$User->Id);
    8686      $DbRow = mysql_fetch_row($DbResult);
    8787      if($DbRow[0] < $Config['MaxExportPerUser'])
    8888      {
    89         $Database->SQLCommand('INSERT INTO `Export` (`Title`, `User`, `TimeCreate`, `WithDiacritic`, `Description`) VALUES ("'.$_POST['Title'].'", '.$_SESSION['UserID'].', NOW(), 1, "'.$_POST['Description'].'")');
     89        $Database->SQLCommand('INSERT INTO `Export` (`Title`, `User`, `TimeCreate`, `WithDiacritic`, `Description`) VALUES ("'.$_POST['Title'].'", '.$User->Id.', NOW(), 1, "'.$_POST['Description'].'")');
    9090        $ExportId = mysql_insert_id();
    9191        echo('Nový export vytvořen.<br/>Přímý odkaz na tento export: <a href="?Action=View&amp;ExportId='.$ExportId.'">zde</a><br/><br/>');
     
    100100function ExportDelete()
    101101{
    102   global $Database;
    103  
    104   if(Licence(LICENCE_USER))
     102  global $Database, $User;
     103 
     104  if($User->Licence(LICENCE_USER))
    105105  {   
    106106    if(array_key_exists('ExportId', $_GET))
    107107    {
    108       $DbResult = $Database->SQLCommand('SELECT * FROM Export WHERE Id='.$_GET['ExportId'].' AND User='.$_SESSION['UserID']);
     108      $DbResult = $Database->SQLCommand('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId'].' AND `User`='.$User->Id);
    109109      if(mysql_num_rows($DbResult) > 0)
    110110      {
    111         $Database->SQLCommand('DELETE FROM Export WHERE Id='.$_GET['ExportId']);
     111        $Database->SQLCommand('DELETE FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    112112        DeleteDirectory('../tmp/Export/'.$_GET['ExportId'].'/');
    113113        echo('Export smazán.<br/><br/>');
     
    122122function ExportViewTranslators()
    123123{
    124   global $Database, $TranslationTree, $Config;
     124  global $Database, $TranslationTree, $Config, $User;
    125125
    126126  $DisabledInput = array(false => ' disabled="disabled"', true => '');
     
    131131    {   
    132132      $Export = mysql_fetch_assoc($DbRows);
    133       if(Licence(LICENCE_USER) and ($_SESSION['UserID'] == $Export['User'])) $Editable = true;
     133      if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    134134        else $Editable = false;
    135135       
     
    204204  $Database->SQLCommand('SET @I = 0');
    205205  $DbResult = $Database->SQLCommand($Query);
    206   while($User = mysql_fetch_assoc($DbResult))
    207   {
    208     $Checked = $User['Sequence'] != '';
    209     $Selection = CheckBox('sel'.$User['ID'], $Checked, '', 'CheckBox', !$Editable);
    210     $Sequence = '<input type="text" name="seq'.$User['ID'].'" style="text-align: center; width: 40px;" value="'.$User['Sequence2'].'"'.$DisabledInput[$Editable].'/>';
     206  while($UserLine = mysql_fetch_assoc($DbResult))
     207  {
     208    $Checked = $UserLine['Sequence'] != '';
     209    $Selection = CheckBox('sel'.$UserLine['ID'], $Checked, '', 'CheckBox', !$Editable);
     210    $Sequence = '<input type="text" name="seq'.$UserLine['ID'].'" style="text-align: center; width: 40px;" value="'.$UserLine['Sequence2'].'"'.$DisabledInput[$Editable].'/>';
    211211    echo('<tr>
    212     <td><a href="'.$Config['Web']['BaseURL'].'/TranslationList.php?user='.$User['ID'].'&amp;action=userall" title="Zobrazit všechny jeho přeložené texty">'.$User['Name'].'</a></td>
    213     <td>'.$User['TranslatedCount'].'</td>
    214       <td><img src="'.$Config['Web']['TempFolder'].'/user/'.$User['Name'].'/level.png" alt="Úroveň uživatele" /></td>
     212    <td><a href="'.$Config['Web']['BaseURL'].'/TranslationList.php?user='.$UserLine['ID'].'&amp;action=userall" title="Zobrazit všechny jeho přeložené texty">'.$UserLine['Name'].'</a></td>
     213    <td>'.$UserLine['TranslatedCount'].'</td>
     214      <td><img src="'.$Config['Web']['TempFolder'].'/user/'.$UserLine['Name'].'/level.png" alt="Úroveň uživatele" /></td>
    215215    <td>'.$Selection.'</td><td>'.$Sequence.'</td></tr>');
    216216  }
     
    224224function ExportViewGeneral()
    225225{
    226   global $Database;
     226  global $Database, $User;
    227227 
    228228  $DisabledInput = array(false => ' disabled="disabled"', true => '');
     
    235235    {   
    236236      $Export = mysql_fetch_assoc($DbRows);
    237       if(Licence(LICENCE_USER) and ($_SESSION['UserID'] == $Export['User'])) $Editable = true;
     237      if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    238238        else $Editable = false;
    239239      if($Editable and array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST))
     
    264264function ExportViewLanguages()
    265265{
    266   global $Database, $TranslationTree, $Config;
     266  global $Database, $TranslationTree, $Config, $User;
    267267
    268268  $DisabledInput = array(false => ' disabled="disabled"', true => '');
     
    273273    {   
    274274      $Export = mysql_fetch_assoc($DbRows);
    275       if(Licence(LICENCE_USER) and ($_SESSION['UserID'] == $Export['User'])) $Editable = true;
     275      if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    276276        else $Editable = false;
    277277       
     
    357357function ExportViewGroups()
    358358{
    359   global $Database, $TranslationTree, $Config;
     359  global $Database, $TranslationTree, $Config, $User;
    360360
    361361  $DisabledInput = array(false => ' disabled="disabled"', true => '');
     
    366366    {   
    367367      $Export = mysql_fetch_assoc($DbRows);
    368       if(Licence(LICENCE_USER) and ($_SESSION['UserID'] == $Export['User'])) $Editable = true;
     368      if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    369369        else $Editable = false;
    370370       
     
    446446function ExportViewOutputFormat()
    447447{
    448   global $Database;
     448  global $Database, $User;
    449449 
    450450  $DisabledInput = array(false => ' disabled="disabled"', true => '');
     
    455455    {   
    456456      $Export = mysql_fetch_assoc($DbRows);
    457       if(Licence(LICENCE_USER) and ($_SESSION['UserID'] == $Export['User'])) $Editable = true;
     457      if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    458458        else $Editable = false;
    459459 
     
    485485function ExportViewVersion()
    486486{
    487   global $Database, $Config;
     487  global $Database, $Config, $User;
    488488
    489489  $DisabledInput = array(false => ' disabled="disabled"', true => '');
     
    494494    {   
    495495      $Export = mysql_fetch_assoc($DbRows);
    496       if(Licence(LICENCE_USER) and ($_SESSION['UserID'] == $Export['User'])) $Editable = true;
     496      if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    497497        else $Editable = false;
    498498       
     
    572572  $Export = mysql_fetch_assoc($DbResult);
    573573  $DbResult = $Database->SQLCommand('SELECT * FROM `User` WHERE `ID`='.$Export['User']);
    574   $User = mysql_fetch_assoc($DbResult);
    575   echo('Export <strong><a href="?Action=View&amp;Tab=6&amp;ExportId='.$Export['Id'].'">'.$_GET['ExportId'].'</a></strong> překladatele <strong>'.$User['Name'].'</strong> s označením <strong>'.$Export['Title'].'</strong>');
     574  $UserLine = mysql_fetch_assoc($DbResult);
     575  echo('Export <strong><a href="?Action=View&amp;Tab=6&amp;ExportId='.$Export['Id'].'">'.$_GET['ExportId'].'</a></strong> překladatele <strong>'.$UserLine['Name'].'</strong> s označením <strong>'.$Export['Title'].'</strong>');
    576576  ShowTabs(array('Obecné', 'Překladatelé', 'Překlady', 'Jazyky', 'Formát', 'Verze', 'Výstup'));
    577577  echo('<div id="content">');
Note: See TracChangeset for help on using the changeset viewer.