Changeset 349


Ignore:
Timestamp:
Mar 3, 2010, 10:37:40 AM (15 years ago)
Author:
george
Message:
  • Opraveno: Neprovádět prázdné SQL řádky při vykonávání exportu pro AoWoW.
  • Opraveno: Chyba použití globální proměné při generování obrázků XP překladatelů při zobzarení týmu. Nestandardně zde byl vkládán skript přes include uvnitř funkce, což zapříčinilo změnu globálních proměnných na lokální.
  • Upraveno: Doplněny SQL uvozovky v některých dotazech.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin.php

    r295 r349  
    22
    33include('includes/global.php');
     4include_once('img_level.php');
    45
    56ShowPage();
    67
    7 echo('<h3>Volby pro správu</h3>');
    8 if(Licence(LICENCE_ADMIN))
     8function ShowMenu()
    99{
     10  global $Config;
     11 
     12  echo('<h3>Volby pro správu</h3>');
    1013  echo('<a href="https://wowpreklad.zdechov.net/mysql/">Správa databáze</a><br/>'.
    1114  '<small>Rozhraní phpMyAdmin pro přímou správu databáze</small><br/><br/>');
     
    1619  echo('<a href="'.$Config['Web']['BaseURL'].'log.php">Záznamy událostí</a><br/>'.
    1720  '<small>Procházení všech systémových záznamů akcí a událostí</small><br/><br/>');
    18   echo('<a href="'.$Config['Web']['BaseURL'].'img_level.php?nothide">Generování obrázků úrovní překladatelů</a><br/>'.
    19   '<small>Ihned provede přegenerování všech obrázků úrovní překladatelů</small><br/><br/>');
    20  
    21  
     21  echo('<a href="'.$Config['Web']['BaseURL'].'admin.php?action=img_level">Generování obrázků úrovní překladatelů</a><br/>'.
     22  '<small>Ihned provede přegenerování všech obrázků úrovní překladatelů</small><br/><br/>');   
     23}
     24
     25if(Licence(LICENCE_ADMIN))
     26{
     27  if(array_key_exists('action', $_GET))
     28  {
     29    if($_GET['action'] == 'img_level')
     30    {
     31      ImgLevelShow();
     32    } else ShowMenu();
     33  } else ShowMenu(); 
    2234} else echo('Nemáte oprávnění');
    2335     
  • trunk/export/export.php

    r300 r349  
    2323  function LoadFilters()
    2424  { 
    25     $DbResult = $this->Database->query('SELECT * FROM `Export` WHERE Id='.$this->Id);
     25    $DbResult = $this->Database->query('SELECT * FROM `Export` WHERE `Id`='.$this->Id);
    2626    $this->Export = $DbResult->fetch_assoc();
    2727
    2828    // Filter selected languages
    2929    $this->WhereLang = '';
    30     $DbResult = $this->Database->query('SELECT * FROM `ExportLanguage` WHERE Export='.$this->Id.' ORDER BY Sequence');
     30    $DbResult = $this->Database->query('SELECT * FROM `ExportLanguage` WHERE `Export`='.$this->Id.' ORDER BY `Sequence`');
    3131    while($Language = $DbResult->fetch_assoc())
    32       $this->WhereLang .= ' OR (Language = '.$Language['Language'].')';
     32      $this->WhereLang .= ' OR (`Language` = '.$Language['Language'].')';
    3333    if($this->WhereLang == '') $this->WhereLang = 1;
    3434      else $this->WhereLang = '('.substr($this->WhereLang, 4).')';
     
    3737    $this->SelectedUsers = ''; 
    3838    $this->UserNames = '';
    39     $DbResult = $this->Database->query('SELECT ExportUser.*, user.user FROM `ExportUser` LEFT JOIN user ON user.ID=ExportUser.User WHERE ExportUser.Export='.$this->Id.' ORDER BY ExportUser.Sequence');
     39    $DbResult = $this->Database->query('SELECT `ExportUser`.*, `user`.`user` FROM `ExportUser` LEFT JOIN `user` ON `user`.`ID`=`ExportUser`.`User` WHERE `ExportUser`.`Export`='.$this->Id.' ORDER BY `ExportUser`.`Sequence`');
    4040    while($User = $DbResult->fetch_assoc())
    4141    {
     
    5252    } else
    5353    {
    54       $this->WhereUsers = '(User IN ('.$this->SelectedUsers.'))';
    55       $this->OrderByUserList = ' ORDER BY FIELD(User, '.$this->SelectedUsers.')';
     54      $this->WhereUsers = '(`User` IN ('.$this->SelectedUsers.'))';
     55      $this->OrderByUserList = ' ORDER BY FIELD(`User`, '.$this->SelectedUsers.')';
    5656    }
    5757   
     
    5959    if(isset($_SESSION) and ($_SESSION['UserID'] != ''))
    6060    {
    61       $DbResult = $this->Database->query('SELECT user FROM `user` WHERE ID='.$_SESSION['UserID']);
     61      $DbResult = $this->Database->query('SELECT `user` FROM `user` WHERE `ID`='.$_SESSION['UserID']);
    6262      $this->User = $DbResult->fetch_assoc();
    6363    } else $this->User = array('user' => 'Neznámý');
     
    141141      $Buffer .= '--'.$AoWoWTable.', ';
    142142      $Buffer .= "\n\n"; 
    143       $Query = 'SELECT name,'.$IndexColum.' FROM '.$AoWoWTable;
     143      $Query = 'SELECT `name`,`'.$IndexColum.'` FROM `'.$AoWoWTable.'`';
    144144      $DbResult = $Database2->query($Query);
    145145      while($Line = $DbResult->fetch_assoc())
     
    147147        $Ori_text = $Line['name'];
    148148        $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.'
    151           AND '.$this->WhereUsers.$this->OrderByUserList.' LIMIT 1) as tran
    152          FROM '.$Config['Database']['Database'].'.global_strings as tableen WHERE
    153           text = "'.addslashes($Ori_text).'" LIMIT 1');
     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');
    154153        $Tran = $DbResult2->fetch_assoc();
    155154        //echo ($Line['name'].'='.$Tran['tran']);
    156155        if($Tran['tran'] == '')
    157156        {
    158           $DbResult2 = $Database2->query('SELECT OptionText as en,
    159           (SELECT OptionText FROM '.$this->Config['Database']['Database'].'.npc_option as tabletran
    160            WHERE tableen.entry = tabletran.entry AND (Complete = 1) AND '.$this->WhereLang.'
    161             AND '.$this->WhereUsers.$this->OrderByUserList.' LIMIT 1) as tran
    162           FROM '.$this->Config['Database']['Database'].'.npc_option as tableen WHERE
    163             OptionText = "'.addslashes($Ori_text).'" LIMIT 1');
     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
     162            `OptionText` = "'.addslashes($Ori_text).'" LIMIT 1');
    164163          $Tran = $DbResult2->fetch_assoc();
    165164        }
    166165       
    167166        if($Tran['tran'] <> '')
    168           $Buffer .= 'UPDATE `'.$AoWoWTable.'` SET name = "'.addslashes($Tran['tran']).'" WHERE '.$IndexColum.' = '.$Line[$IndexColum].' ;'."\n";
     167          $Buffer .= 'UPDATE `'.$AoWoWTable.'` SET `name` = "'.addslashes($Tran['tran']).'" WHERE '.$IndexColum.' = '.$Line[$IndexColum].' ;'."\n";
    169168      }
    170169      $Buffer .= "\n\n"; 
     
    204203        $Group['MangosTableIndex'] = 'entry';
    205204      }
    206       $Query = 'SELECT *,(SELECT user FROM user WHERE user.ID=T.User) as UserName FROM (SELECT * 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 T GROUP BY T.entry';
     205      $Query = 'SELECT *,(SELECT `user` FROM `user` WHERE `user`.`ID`=`T`.`User`) AS `UserName` FROM (SELECT * 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 `T` GROUP BY `T`.`entry`';
    207206      //echo($Query);
    208207      $Buffer .= '    <group id="'.$Group['Id'].'" name="'.$Group['TablePrefix'].'">'."\n";
  • trunk/export/process_aowow_export.php

    r319 r349  
    4646{
    4747  //echo($Line."\n");
    48   $Database2->query($Line);
     48  if(trim($Line) != '') $Database2->query($Line);
    4949}
    5050
  • trunk/img_level.php

    r302 r349  
    22
    33require_once('includes/global.php');
    4 
    5 if (array_key_exists('nothide', $_GET)) $nothide = true;
    6   else $nothide = false;
    7 if($nothide) ShowPage();
    8 
    9 $FontFile = 'images/FRIZQT__.ttf';
    104
    115// Nastavení
     
    137$index_level = 100;
    148$from_diakrit = 3; //zvýšené xp za slovo s diakritikou
     9$FontFile = 'images/FRIZQT__.ttf';
    1510
    1611function CheckDiakrit($word)
     
    2621    }
    2722  }
    28   return $result;
     23  return($result);
    2924}
    3025
    3126function CreateImg($prefix, $user, $xp)
    3227{
    33   global $index_level, $FontFile;
    34    
     28  global $index_level, $FontFile;   
     29 
    3530  if($xp > 0)
    3631  {
    37     $level = sqrt ($xp / $index_level);
     32    $level = sqrt($xp / $index_level);
    3833    $level = substr($level, 0, strpos($level, '.'));
    3934  } else $level = 0;
     
    106101}
    107102
    108 // Hlavní kod pro uživatele
    109 if($nothide) $ID = $Database->SQLCommand('SELECT ID,user FROM user');
    110   else $ID = $Database->SQLCommand('SELECT ID,user FROM user WHERE NeedUpdate = 1');
    111 while($LineUser = mysql_fetch_array($ID))
    112 {
    113   $xp = GetXPFromTranslation($LineUser['ID']); // Načítání XP
    114   $Database->SQLCommand('UPDATE user SET XP = '.$xp.' WHERE ID = '.$LineUser['ID']);  // Ukládání XP pro řazení
    115   CreateImg('user', $LineUser['user'], $xp);  // Vytváření obrázku
    116   if($nothide) echo('<img src="tmp/user/'.$LineUser['user'].'/level.png" /><br />');
     103function ImgLevelUpdate()
     104{
     105  global $Database;
     106
     107  // Hlavní kod pro uživatele
     108  $ID = $Database->SQLCommand('SELECT ID,user FROM user WHERE NeedUpdate = 1');
     109  while($LineUser = mysql_fetch_array($ID))
     110  {
     111    $xp = GetXPFromTranslation($LineUser['ID']); // Načítání XP
     112    $Database->SQLCommand('UPDATE user SET XP = '.$xp.' WHERE ID = '.$LineUser['ID']);  // Ukládání XP pro řazení
     113    CreateImg('user', $LineUser['user'], $xp);  // Vytváření obrázku
     114  }
     115
     116  // Hlavní kod pro překladatelské týmy
     117  $ID = $Database->SQLCommand('SELECT ID,name,(SELECT avg(XP) FROM user WHERE team = Team.Id) as average FROM Team WHERE ID IN (SELECT Team FROM user WHERE NeedUpdate = 1)');
     118  while($LineTeam = mysql_fetch_array($ID))
     119  {
     120    CreateImg('team', $LineTeam['name'], substr($LineTeam['average'], 0, strpos($LineTeam['average'],'.')));  //vytváření obrázku
     121  }
     122  $Database->SQLCommand('UPDATE user SET NeedUpdate = 0');
    117123}
    118124
    119 // Hlavní kod pro překladatelské týmy
    120 if($nothide) $ID = $Database->SQLCommand('SELECT ID,name,(SELECT avg(XP) FROM user WHERE team = Team.Id) as average FROM Team');
    121   else $ID = $Database->SQLCommand('SELECT ID,name,(SELECT avg(XP) FROM user WHERE team = Team.Id) as average FROM Team WHERE ID IN (SELECT Team FROM user WHERE NeedUpdate = 1)');
    122 while($LineTeam = mysql_fetch_array($ID))
     125function ImgLevelShow()
    123126{
    124   CreateImg('team', $LineTeam['name'], substr($LineTeam['average'], 0, strpos($LineTeam['average'],'.')));  //vytváření obrázku
    125   if($nothide) echo('<img src="tmp/team/'.$LineTeam['name'].'/level.png" /><br />');
     127  global $Database;
     128 
     129  // Hlavní kod pro uživatele
     130  $ID = $Database->SQLCommand('SELECT ID,user FROM user');
     131  while($LineUser = mysql_fetch_array($ID))
     132  {
     133    $xp = GetXPFromTranslation($LineUser['ID']); // Načítání XP
     134    $Database->SQLCommand('UPDATE user SET XP = '.$xp.' WHERE ID = '.$LineUser['ID']);  // Ukládání XP pro řazení
     135    CreateImg('user', $LineUser['user'], $xp);  // Vytváření obrázku
     136    echo('<img src="tmp/user/'.$LineUser['user'].'/level.png" /><br />');
     137  }
     138
     139  // Hlavní kod pro překladatelské týmy
     140  $ID = $Database->SQLCommand('SELECT ID,name,(SELECT avg(XP) FROM user WHERE team = Team.Id) as average FROM Team');
     141  while($LineTeam = mysql_fetch_array($ID))
     142  {
     143    CreateImg('team', $LineTeam['name'], substr($LineTeam['average'], 0, strpos($LineTeam['average'],'.')));  // Vytváření obrázku
     144    echo('<img src="tmp/team/'.$LineTeam['name'].'/level.png" /><br />');
     145  }
     146  $Database->SQLCommand('UPDATE user SET NeedUpdate = 0');
    126147}
    127 $Database->SQLCommand('UPDATE user SET NeedUpdate = 0');
    128 
    129 if($nothide) ShowFooter();     
    130148
    131149?>
  • trunk/img_statistic.php

    r328 r349  
    1515if(array_key_exists('language', $_GET))
    1616{
    17   $language = ' AND `Language` = '.$_GET['language'].'';
     17  $language = ' AND (`Language` = '.$_GET['language'].')';
    1818} else $language = '';
    1919
    2020
    21 $ID = mysql_fetch_row($Database->SQLCommand('SELECT MAX(`VersionEnd`) FROM '.$Group['TablePrefix']));
     21$DbResult = $Database->SQLCommand('SELECT MAX(`VersionEnd`) FROM '.$Group['TablePrefix']);
     22$ID = mysql_fetch_row($DbResult);
    2223$BuildNumber_max = $ID[0];
    2324
    2425$where = 'VersionEnd = '.$BuildNumber_max.' AND (`Language` <> 0) AND (`Complete` = 1) '.$team.$language;
    25 $ID = mysql_fetch_row($Database->SQLCommand('SELECT count(distinct(`entry`)) FROM '.$Group['TablePrefix'].' WHERE '.$where));
     26$ID = mysql_fetch_row($Database->SQLCommand('SELECT count(distinct(`entry`)) FROM `'.$Group['TablePrefix'].'` WHERE '.$where));
    2627$NumberTranslate = $ID[0];
    2728 
    28 $ID = mysql_fetch_row($Database->SQLCommand('SELECT count(distinct(`entry`)) FROM '.$Group['TablePrefix'].' WHERE `VersionEnd` = '.$BuildNumber_max.' AND (`Language` = 0)'));
     29$ID = mysql_fetch_row($Database->SQLCommand('SELECT count(distinct(`entry`)) FROM `'.$Group['TablePrefix'].'` WHERE `VersionEnd` = '.$BuildNumber_max.' AND (`Language` = 0)'));
    2930$NumberAJ = $ID[0];
    3031
    31 $ID = mysql_fetch_row($Database->SQLCommand('SELECT count(*) FROM `log` WHERE `Type` = 1 AND `date` >= CURRENT_DATE - INTERVAL '.$Days.' DAY
    32  AND `text` LIKE "%'.$Group['Name'].'%"'));
     32$DbResult = $Database->SQLCommand('SELECT count(*) FROM `log` WHERE (`Type` = 1) AND (`date` >= CURRENT_DATE - INTERVAL '.$Days.' DAY) AND (`text` LIKE "%'.$Group['Name'].'%")');
     33$ID = mysql_fetch_row($DbResult);
    3334$NumberPerDay = $ID[0]; //date ("Y-m-d H:i:s")
    3435
  • trunk/save.php

    r321 r349  
    1919    else $complete = 0;
    2020             
    21   $DbResult = $Database->SQLCommand('SELECT * FROM '.$Table.' WHERE Language = 0 AND entry = '.$entry);
     21  $DbResult = $Database->SQLCommand('SELECT * FROM `'.$Table.'` WHERE (`Language` = 0) AND (`entry` = '.$entry.')');
    2222  if(mysql_num_rows($DbResult) == 0) ErrorMessage('Neznámé Id položky');
    2323  $LineAJ = mysql_fetch_array($DbResult);
    24   $LineTake = mysql_fetch_array($Database->SQLCommand('SELECT VersionEnd,VersionStart FROM '.$Table.' WHERE ID = '.$TextID));
     24  $LineTake = mysql_fetch_array($Database->SQLCommand('SELECT `VersionEnd`, `VersionStart` FROM `'.$Table.'` WHERE `ID` = '.$TextID));
    2525  if(mysql_num_rows($DbResult) == 0) ErrorMessage('Neznámé Id položky');
    26   $DbResult = $Database->SQLCommand('SELECT * FROM '.$Table.' WHERE user='.$UserID.' AND entry = '.$entry.' AND VersionStart = '.$LineTake['VersionStart'].' AND VersionEnd = '.$LineTake['VersionEnd']);
     26  $DbResult = $Database->SQLCommand('SELECT * FROM `'.$Table.'` WHERE (`user`='.$UserID.') AND (`entry` = '.$entry.') AND (`VersionStart` = '.$LineTake['VersionStart'].') AND (`VersionEnd` = '.$LineTake['VersionEnd'].')');
    2727  $Line = mysql_fetch_array($DbResult);
    2828  if(!$Line)
     
    6969    while($SameTranLine = mysql_fetch_assoc($SameTranID))
    7070    {
    71       $Line = mysql_fetch_array($Database->SQLCommand('SELECT * FROM '.$Table.' WHERE user='.$UserID.' AND entry = '.$SameTranLine['entry'].' AND VersionStart = '.$LineTake['VersionStart'].' AND VersionEnd = '.$LineTake['VersionEnd']));
     71      $Line = mysql_fetch_array($Database->SQLCommand('SELECT * FROM `'.$Table.'` WHERE (`user`='.$UserID.') AND (`entry` = '.$SameTranLine['entry'].') AND (`VersionStart` = '.$LineTake['VersionStart'].') AND (`VersionEnd` = '.$LineTake['VersionEnd'].')'));
    7272      if(!$Line)
    7373      {
     
    9393 
    9494    // Konec kontrolování stejných textů   
    95    
     95       
    9696    echo('Překlad <a href="form.php?group='.$GroupId.'&amp;ID='.$TextID.'">'.$TextID.'</a> ('.$entry.') uložen!<br />');
    9797    foreach($LastIDs as $LastID)
    9898    {
    9999      if(count($LastIDs) > 1) echo('Nalezen stejný překlad, systémově přeložen: <a href="form.php?group='.$GroupId.'&amp;ID='.$LastID.'">'.$LastID.'</a> Převzat z: <a href="form.php?group='.$GroupId.'&amp;ID='.$TextID.'">'.$TextID.'</a><br />');
    100       WriteLog('Text <a href="form.php?group='.$GroupId.'&amp;ID='.$LastID.'">'.$LastID.'</a> ze skupiny <a href="?group='.$GroupId.'&amp;action=filter">'.$TranslationTree[$GroupId]['Name'].'</a> uložen! Převzat z <a href="form.php?group='.$GroupId.'&amp;ID='.$TextID.'">'.$TextID.'</a>.', 1);
     100      WriteLog('Text <a href="form.php?group='.$GroupId.'&amp;ID='.$LastID.'">'.$LastID.'</a> ze skupiny <a href="TranslationList.php?group='.$GroupId.'&amp;action=filter">'.$TranslationTree[$GroupId]['Name'].'</a> uložen! Převzat z <a href="form.php?group='.$GroupId.'&amp;ID='.$TextID.'">'.$TextID.'</a>.', 1);
    101101    }
    102102  } else
     
    106106    if(array_key_exists($GroupItem['Column'], $_POST))
    107107      $sql .= ', `'.$GroupItem['Column'].'`="'.$_POST[$GroupItem['Column']].'"';
    108     $sql .= ', `Language` = '.$Language.' WHERE `ID` = '.$TextID.' AND `Language`  <> 0';
     108    $sql .= ', `Language` = '.$Language.' WHERE `ID` = '.$TextID.' AND `Language` <> 0';
    109109  //echo($sql);
    110110    $Database->SQLCommand($sql);
     
    116116  echo('<br />Překládat: <a href="TranslationList.php?group='.$GroupId.'&amp;action=notran">Nepřeložené</a> ');
    117117
    118   $prev = FollowingTran($TextID,$Table,$GroupId, True);
    119   $next = FollowingTran($TextID,$Table,$GroupId);
     118  $prev = FollowingTran($TextID, $Table, $GroupId, True);
     119  $next = FollowingTran($TextID, $Table, $GroupId);
    120120  echo('<br /><br />');
    121121  $redirecting = mysql_fetch_assoc($Database->SQLCommand('SELECT `redirecting` FROM `user` WHERE `ID`='.$UserID));
  • trunk/team.php

    r316 r349  
    22
    33include('includes/global.php');
     4include_once('img_level.php');
    45
    56ShowPage();
     
    192193  if(array_key_exists('id', $_GET))
    193194  {
    194     include('img_level.php');
     195    ImgLevelUpdate();
    195196    $Columns = '';
    196197    $Joins = '';
  • trunk/userlist.php

    r292 r349  
    22
    33include('includes/global.php');
     4include_once('img_level.php');
    45
    56ShowPage();
    6 
    7 include('img_level.php');
     7ImgLevelUpdate();
    88
    99echo('<h3>Seznam uživatelů</h3>');
Note: See TracChangeset for help on using the changeset viewer.