Changeset 287


Ignore:
Timestamp:
Dec 22, 2009, 10:40:43 AM (15 years ago)
Author:
george
Message:
  • Opraveno: Kontrola zaslání položek formuláře při zadávání slov ve slovníku.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/TranslationList.php

    r286 r287  
    205205 
    206206  $WhereUsers = '';   
    207   for($i = 0; $i < Count($users); $i++)
    208   {
    209     if($WhereUsers <> '') $WhereUsers .= ' OR `User` = '.$users[$i];
    210       else $WhereUsers .= ' `User` = '.$users[$i];
    211   }
    212   if($WhereUsers == '') $WhereUsers = '0';
    213  
     207  foreach($users as $Index => $User)
     208  {
     209    if($WhereUsers <> '') $WhereUsers .= ' OR `User` = '.$User;
     210      else $WhereUsers .= ' `User` = '.$User;
     211  }
     212  if($WhereUsers == '') $WhereUsers = '0'; 
    214213 
    215214  WriteQuests('SELECT *, (SELECT `user`.`user` FROM `user` WHERE `user`.`id` = `'.$Table.'`.`user`) AS `User` FROM `'.$Table.'` WHERE '.$WhereUsers, '', 'users');
     
    317316{
    318317  if(array_key_exists('ID', $_GET)) $Search = $_GET['ID'];
    319   else $Search = $_POST['ID'];
     318  else if(array_key_exists('ID', $_POST)) $Search = $_POST['ID'];
     319  else $Search = '';
    320320 
    321321  $sql = 'SELECT *, (SELECT `user`.`user` FROM `user` WHERE `user`.`id` = `'.$Table.'`.`user`) AS `User` FROM `'.$Table.'` WHERE `entry` LIKE "'.$Search.'"';
  • trunk/dictionary.php

    r286 r287  
    142142    if(($_GET['action'] == 'save') and Licence(LICENCE_USER))
    143143    {
    144       $DbResult = $Database->SQLCommand('SELECT * FROM `dictionary` WHERE `Text` = "'.$_POST['Original'].'" AND Language=0');
    145       if(mysql_num_rows($DbResult) > 0)
    146       {
    147         $DbRow = mysql_fetch_assoc($DbResult);
    148         $Entry = $DbRow['Entry'];
    149       } else
    150       {
    151         $DbResult = $Database->SQLCommand('SELECT MAX(Entry) FROM dictionary');
    152         $DbRow = mysql_fetch_row($DbResult);
    153         $Entry = $DbRow[0] + 1;
    154         $Database->SQLCommand('INSERT INTO `dictionary` ( `Text` , `Entry` , `Description` , `User`, `Language` ) VALUES ("'.$_POST['Original'].'", "'.$Entry.'", "", 0, 0);');
    155       }
     144      if(array_key_exists('Original', $_POST) and array_key_exists('Translated', $_POST) and array_key_exists('Description', $_POST))
     145      {       
     146        $DbResult = $Database->SQLCommand('SELECT * FROM `dictionary` WHERE `Text` = "'.$_POST['Original'].'" AND Language=0');
     147        if(mysql_num_rows($DbResult) > 0)
     148        {
     149          $DbRow = mysql_fetch_assoc($DbResult);
     150          $Entry = $DbRow['Entry'];
     151        } else
     152        {
     153          $DbResult = $Database->SQLCommand('SELECT MAX(Entry) FROM dictionary');
     154          $DbRow = mysql_fetch_row($DbResult);
     155          $Entry = $DbRow[0] + 1;
     156          $Database->SQLCommand('INSERT INTO `dictionary` ( `Text` , `Entry` , `Description` , `User`, `Language` ) VALUES ("'.$_POST['Original'].'", "'.$Entry.'", "", 0, 0);');
     157        }
    156158     
    157       $DbResult = $Database->SQLCommand('SELECT Id FROM `dictionary` WHERE `Entry` = '.$Entry.' AND Language='.$_SESSION['language'].' AND User='.$_SESSION['UserID']);
    158       if(mysql_num_rows($DbResult) > 0)
    159       {
    160         $DbRow = mysql_fetch_assoc($DbResult);
    161         $Database->SQLCommand('UPDATE `dictionary` SET `Text`="'.$_POST['Translated'].'", `Description` = "'.$_POST['Description'].'" WHERE Id='.$DbRow['Id']);
    162       } else     
    163         $Database->SQLCommand('INSERT INTO `dictionary` ( `Text` , `Entry` , `Description` , `User`, `Language` ) VALUES ("'.$_POST['Translated'].'", "'.$Entry.'", "'.$_POST['Description'].'", '.$_SESSION['UserID'].', '.$_SESSION['language'].')');
    164       echo('Záznam byl uložen!');
     159        $DbResult = $Database->SQLCommand('SELECT Id FROM `dictionary` WHERE `Entry` = '.$Entry.' AND Language='.$_SESSION['language'].' AND User='.$_SESSION['UserID']);
     160        if(mysql_num_rows($DbResult) > 0)
     161        {
     162          $DbRow = mysql_fetch_assoc($DbResult);
     163          $Database->SQLCommand('UPDATE `dictionary` SET `Text`="'.$_POST['Translated'].'", `Description` = "'.$_POST['Description'].'" WHERE Id='.$DbRow['Id']);
     164        } else     
     165          $Database->SQLCommand('INSERT INTO `dictionary` ( `Text` , `Entry` , `Description` , `User`, `Language` ) VALUES ("'.$_POST['Translated'].'", "'.$Entry.'", "'.$_POST['Description'].'", '.$_SESSION['UserID'].', '.$_SESSION['language'].')');
     166        echo('Záznam byl uložen!');
     167      } else echo('Nebyly zaslány všechny položky formuláře.');
    165168    } else
    166169    if(($_GET['action'] == 'remove') and Licence(LICENCE_USER))
Note: See TracChangeset for help on using the changeset viewer.