Changeset 376 for trunk/dictionary.php


Ignore:
Timestamp:
Mar 11, 2010, 8:40:32 AM (14 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/dictionary.php

    r366 r376  
    9191if(!isset($_SESSION['language']))
    9292{
    93   if(Licence(LICENCE_USER))
    94   {
    95     $DbResult = $Database->SQLCommand('SELECT `Language` FROM `User` WHERE `ID`='.$_SESSION['UserID']);
    96     $User = mysql_fetch_assoc($DbResult);
    97     $_SESSION['language'] = $User['Language'];
     93  if($User->Licence(LICENCE_USER))
     94  {
     95    $_SESSION['language'] = $User->Language;
    9896  } else $_SESSION['language'] = 1;
    9997}
     
    127125  if(array_key_exists('action', $_GET))
    128126  {
    129     if(($_GET['action'] == 'insert')  and Licence(LICENCE_USER))
     127    if(($_GET['action'] == 'insert')  and $User->Licence(LICENCE_USER))
    130128    {
    131129      echo('<form action="dictionary.php?action=save" method="post">'.
     
    140138      '</form>');   
    141139    } else
    142     if(($_GET['action'] == 'save') and Licence(LICENCE_USER))
     140    if(($_GET['action'] == 'save') and $User->Licence(LICENCE_USER))
    143141    {
    144142      if(array_key_exists('Original', $_POST) and array_key_exists('Translated', $_POST) and array_key_exists('Description', $_POST))
     
    157155        }
    158156     
    159         $DbResult = $Database->SQLCommand('SELECT `Id` FROM `Dictionary` WHERE `Entry` = '.$Entry.' AND `Language`='.$_SESSION['language'].' AND `User`='.$_SESSION['UserID']);
     157        $DbResult = $Database->SQLCommand('SELECT `Id` FROM `Dictionary` WHERE `Entry` = '.$Entry.' AND `Language`='.$_SESSION['language'].' AND `User`='.$User->Id);
    160158        if(mysql_num_rows($DbResult) > 0)
    161159        {
     
    163161          $Database->SQLCommand('UPDATE `Dictionary` SET `Text`="'.$_POST['Translated'].'", `Description` = "'.$_POST['Description'].'" WHERE Id='.$DbRow['Id']);
    164162        } else     
    165           $Database->SQLCommand('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , `User`, `Language` ) VALUES ("'.$_POST['Translated'].'", "'.$Entry.'", "'.$_POST['Description'].'", '.$_SESSION['UserID'].', '.$_SESSION['language'].')');
     163          $Database->SQLCommand('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , `User`, `Language` ) VALUES ("'.$_POST['Translated'].'", "'.$Entry.'", "'.$_POST['Description'].'", '.$User->Id.', '.$_SESSION['language'].')');
    166164        echo('Záznam byl uložen!');
    167165      } else echo('Nebyly zaslány všechny položky formuláře.');
    168166    } else
    169     if(($_GET['action'] == 'remove') and Licence(LICENCE_USER))
    170     {
    171       $Database->SQLCommand('DELETE FROM `Dictionary` WHERE `User`='.$_SESSION['UserID'].' AND `Language`='.$_SESSION['language'].' AND `Entry`='.$_GET['entry']);
     167    if(($_GET['action'] == 'remove') and $User->Licence(LICENCE_USER))
     168    {
     169      $Database->SQLCommand('DELETE FROM `Dictionary` WHERE `User`='.$User->Id.' AND `Language`='.$_SESSION['language'].' AND `Entry`='.$_GET['entry']);
    172170    } else
    173     if(($_GET['action'] == 'modify')  and Licence(LICENCE_USER))
    174     {
    175       $DbResult = $Database->SQLCommand('SELECT * FROM `Dictionary` WHERE `User`='.$_SESSION['UserID'].' AND `Entry`='.$_GET['entry'].' AND `Language`='.$_SESSION['language']);
     171    if(($_GET['action'] == 'modify')  and $User->Licence(LICENCE_USER))
     172    {
     173      $DbResult = $Database->SQLCommand('SELECT * FROM `Dictionary` WHERE `User`='.$User->Id.' AND `Entry`='.$_GET['entry'].' AND `Language`='.$_SESSION['language']);
    176174      $DbRow = mysql_fetch_assoc($DbResult);
    177175      $DbResult = $Database->SQLCommand('SELECT * FROM `Dictionary` WHERE `User`=0 AND `Entry`='.$_GET['entry'].' AND `Language`=0');
     
    199197    <input type="text" value="'.$Search.'" name="search" size="30" />
    200198    <input type="submit" value="Vyhledat" />');
    201   if(Licence(LICENCE_USER)) echo(' <a href="dictionary.php?action=insert">Vložit slovo</a>');
     199  if($User->Licence(LICENCE_USER)) echo(' <a href="dictionary.php?action=insert">Vložit slovo</a>');
    202200           
    203201  echo('</td></tr>');
     
    231229    array('Name' => 'UserName', 'Title' => 'Překladatel'),
    232230  );
    233   if(Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => 'Akce');
     231  if($User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => 'Akce');
    234232  $Order = GetOrderTableHeader($TableColumns, 'Original');
    235233  echo('<table width="98%" class="BaseTable">');
     
    245243    <td>'.$Line['Description'].'</td>
    246244    <td>'.$Line['UserName'].'</td>');
    247     if(Licence(LICENCE_USER))
    248     {
    249       if($Line['UserID'] == $_SESSION['UserID'])
     245    if($User->Licence(LICENCE_USER))
     246    {
     247      if($Line['UserID'] == $User->Id)
    250248        echo('<td><a href="?action=remove&amp;entry='.$Line['Entry'].'">Smazat</a> <a href="?action=modify&amp;entry='.$Line['Entry'].'">Upravit</a></td>');
    251249        else echo('<td></td>');
Note: See TracChangeset for help on using the changeset viewer.