Changeset 357 for trunk/log.php


Ignore:
Timestamp:
Mar 5, 2010, 7:42:00 AM (15 years ago)
Author:
george
Message:
  • Upraveno: Definice typů logovacích záznamů přesunuta do databáze do tabulky LogType. Doplněny konstanty začínající LOG_TYPE_ pro přehlednější používaní v kódu.
  • Přidáno: Odkaz a stránka zobrazení všech aktualit.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/log.php

    r298 r357  
    66{
    77  $Items = array();
    8   if(array_key_exists('type', $_GET)) $Where = ' WHERE type = "'.($_GET['type'] * 1).'"';
     8  if(array_key_exists('type', $_GET)) $Where = ' WHERE `type` = "'.($_GET['type'] * 1).'"';
    99    else $Where = '';
    10   $sql = 'SELECT *,UNIX_TIMESTAMP(date), (SELECT user.user FROM user WHERE user.id = log.user) as user FROM log'.$Where.' ORDER BY date DESC LIMIT 100';
     10  $sql = 'SELECT *,UNIX_TIMESTAMP(`date`), (SELECT `user`.`user` FROM `user` WHERE `user`.`id` = `log`.`user`) AS `user` FROM `log`'.$Where.' ORDER BY `date` DESC LIMIT 100';
    1111  $ID = $Database->SQLCommand($sql);
    1212  while($Line = mysql_fetch_assoc($ID))
    1313  {
    14     if(array_key_exists($Line['type'], $LogTypes)) $TypeName = $LogTypes[$Line['type']]['Name'];
    15       else $TypeName = '';
     14    $DbResult = $Database->SQLCommand('SELECT * FROM `LogType` WHERE `Id`='.$Line['type']);
     15    $LogType = mysql_fetch_assoc($DbResult);
     16   
    1617    $Items[] = array
    1718    (
    18       'Title' => strip_tags($TypeName.': '.$Line['text'].' ('.$Line['user'].', '.$Line['IP'].')'),
     19      'Title' => strip_tags($LogType['Name'].': '.$Line['text'].' ('.$Line['user'].', '.$Line['IP'].')'),
    1920      'Link' =>  $Config['Web']['BaseURL'].'log.php',
    20       'Description' => $TypeName.': '.$Line['text'].' ('.$Line['user'].', '.$Line['IP'].')',
     21      'Description' => $LogType['Name'].': '.$Line['text'].' ('.$Line['user'].', '.$Line['IP'].')',
    2122      'Time' => $Line['UNIX_TIMESTAMP(date)'],
    2223    );
     
    4849    echo('<strong>Filtr: </strong>');
    4950    echo('<span style="color:black"><a href="log.php?type=" title="Bez filtrování">Všechny</a></span> ');
    50     foreach($LogTypes as $Index => $LogItem)
     51    $DbResult = $Database->SQLCommand('SELECT * FROM `LogType`');
     52    while($LogType = mysql_fetch_assoc($DbResult))
    5153    {
    52       echo('<a href="log.php?type='.$Index.'" style="color:'.$LogItem['Color'].'" title="'.$LogItem['Name'].'">'.$LogItem['Name'].'</a> ');
     54      echo('<a href="log.php?type='.$LogType['Id'].'" style="color:'.$LogType['Color'].'" title="'.$LogType['Name'].'">'.$LogType['Name'].'</a> ');
    5355    }
    5456  }
     
    5961  else
    6062  {
    61     if(array_key_exists('group', $_SESSION)) $Where = ' WHERE text LIKE "%'.$TranslationTree[$_SESSION['group']]['Name'].'%"';
     63    if(array_key_exists('group', $_SESSION)) $Where = ' WHERE `text` LIKE "%'.$TranslationTree[$_SESSION['group']]['Name'].'%"';
    6264      else $Where = '';
    6365  }
     
    8082  echo($Order['Output']);
    8183 
    82   $sql = 'SELECT *,(SELECT `user`.`user` FROM `user` WHERE `user`.`id` = `log`.`user`) AS `user` FROM `log` '.$Where.$Order['SQL'].$PageList['SQLLimit'];
     84  $sql = 'SELECT *, `LogType`.`Color` AS `LogColor`, (SELECT `user`.`user` FROM `user` WHERE `user`.`id` = `log`.`user`) AS `user` FROM `log` LEFT JOIN `LogType` ON `LogType`.`Id`=`log`.`type` '.$Where.$Order['SQL'].$PageList['SQLLimit'];
    8385  //echo($sql);
    8486  $ID = $Database->SQLCommand($sql);
    8587  while($Line = mysql_fetch_assoc($ID))
    8688  {
    87     echo('<tr><td>'.$Line['date'].'</td><td><span style="color:'.$LogTypes[$Line['type']]['Color'].'">'.$Line['text'].'</span></td><td>'.$Line['user'].'</td><td>'.$Line['IP'].'</td></tr>');
     89    echo('<tr><td>'.$Line['date'].'</td><td><span style="color: '.$Line['LogColor'].'">'.$Line['text'].'</span></td><td>'.$Line['user'].'</td><td>'.$Line['IP'].'</td></tr>');
    8890  }
    8991  echo('</table>');
Note: See TracChangeset for help on using the changeset viewer.