Ignore:
Timestamp:
Apr 7, 2020, 10:15:48 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Improved code formatting.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Log/Log.php

    r861 r880  
    3333  function WriteLog($Text, $Type)
    3434  {
    35     if(isset($this->System->User) and !is_null($this->System->User->Id))
     35    if (isset($this->System->User) and !is_null($this->System->User->Id))
    3636      $UserId = $this->System->User->Id;
    3737      else $UserId = 'NULL';
     
    6060  global $System, $User;
    6161
    62   if(isset($User) and !is_null($User->Id)) $UserId = $User->Id;
     62  if (isset($User) and !is_null($User->Id)) $UserId = $User->Id;
    6363    else $UserId = 'NULL';
    6464  $Query = 'INSERT INTO `Log` ( `User` , `Type` , `Text` , `Date` , `IP`, `URL` ) '.
     
    7575    $Output = '';
    7676    $Items = array();
    77     if(array_key_exists('type', $_GET)) $Where = ' WHERE `Type` = "'.($_GET['type'] * 1).'"';
     77    if (array_key_exists('type', $_GET)) $Where = ' WHERE `Type` = "'.($_GET['type'] * 1).'"';
    7878      else $Where = '';
    7979    $sql = 'SELECT *, UNIX_TIMESTAMP(`Date`) AS `TimeCreate`, (SELECT `User`.`Name` FROM `User` WHERE `User`.`ID` = `Log`.`User`) AS `UserName`, `Date` FROM `Log`'.
    8080      $Where.' ORDER BY `Date` DESC LIMIT 100';
    8181    $DbResult = $this->System->Database->query($sql);
    82     while($Line = $DbResult->fetch_assoc())
     82    while ($Line = $DbResult->fetch_assoc())
    8383    {
    8484      $DbResult2 = $this->System->Database->query('SELECT * FROM `LogType` WHERE `Id`='.$Line['Type']);
    8585      $LogType = $DbResult2->fetch_assoc();
    8686
    87       if($Line['Type'] == LOG_TYPE_ERROR) $Line['Text'] = htmlspecialchars($Line['Text']);
     87      if ($Line['Type'] == LOG_TYPE_ERROR) $Line['Text'] = htmlspecialchars($Line['Text']);
    8888      $Line['Text'] = str_replace("\n", '<br>', $Line['Text']);
    8989
     
    106106      'Items' => $Items,
    107107    ));
    108     return($Output);
     108    return $Output;
    109109  }
    110110
    111111  function Show()
    112112  {
    113     if(array_key_exists('a', $_POST)) $Action = $_POST['a'];
    114       else if(array_key_exists('a', $_GET)) $Action = $_GET['a'];
     113    if (array_key_exists('a', $_POST)) $Action = $_POST['a'];
     114      else if (array_key_exists('a', $_GET)) $Action = $_GET['a'];
    115115      else $Action = '';
    116     if($Action == 'delerrlog') $Output = $this->DeleteErrorLog();
     116    if ($Action == 'delerrlog') $Output = $this->DeleteErrorLog();
    117117    else $Output = $this->ShowList();
    118     return($Output);
     118    return $Output;
    119119  }
    120120
     
    125125    $this->Title = T('System log');
    126126    $Output = '';
    127     if(array_key_exists('type', $_GET)) $_SESSION['type'] = $_GET['type'] * 1;
    128     else if(!array_key_exists('type', $_SESSION)) $_SESSION['type'] = '';
    129 
    130     if(array_key_exists('group', $_GET)) $_SESSION['group'] = $_GET['group'];
    131 
    132     if($_SESSION['type'] != '') $WhereType = ' (`Type`='.$_SESSION['type'].')';
     127    if (array_key_exists('type', $_GET)) $_SESSION['type'] = $_GET['type'] * 1;
     128    else if (!array_key_exists('type', $_SESSION)) $_SESSION['type'] = '';
     129
     130    if (array_key_exists('group', $_GET)) $_SESSION['group'] = $_GET['group'];
     131
     132    if ($_SESSION['type'] != '') $WhereType = ' (`Type`='.$_SESSION['type'].')';
    133133      else $WhereType = '1=1';
    134134
     
    138138
    139139    // Show category filter
    140     if($this->System->User->Licence(LICENCE_MODERATOR))
     140    if ($this->System->User->Licence(LICENCE_MODERATOR))
    141141    {
    142142      $Output = '<strong>'.T('Filter').':</strong>';
    143143        $Item = '<a href="'.$this->System->Link('/log/?type=').'" title="Bez filtrování">'.T('All').'</a>';
    144       if($_SESSION['type'] == '') $Item = '<strong>'.$Item.'</strong>';
     144      if ($_SESSION['type'] == '') $Item = '<strong>'.$Item.'</strong>';
    145145      $Output .= ' '.$Item;
    146146      $DbResult = $this->System->Database->query('SELECT * FROM `LogType`');
    147       while($LogType = $DbResult->fetch_assoc())
     147      while ($LogType = $DbResult->fetch_assoc())
    148148      {
    149149        $Item = '<a href="'.$this->System->Link('/log/?type='.$LogType['Id']).'" style="color:'.
    150150          $LogType['Color'].'" title="'.$LogType['Name'].'">'.T($LogType['Name']).'</a>';
    151         if($_SESSION['type'] == $LogType['Id']) $Item = '<strong>'.$Item.'</strong>';
     151        if ($_SESSION['type'] == $LogType['Id']) $Item = '<strong>'.$Item.'</strong>';
    152152        $Output .= ' '.$Item;
    153153      }
     
    155155     $Output .= '<br /><br />';
    156156
    157     if(array_key_exists('type', $_SESSION)) $Where = ' WHERE '.$WhereType;
     157    if (array_key_exists('type', $_SESSION)) $Where = ' WHERE '.$WhereType;
    158158    else
    159159    {
    160       if(array_key_exists('group', $_SESSION)) $Where = ' WHERE `Text` LIKE "%'.$TranslationTree[$_SESSION['group']]['Name'].'%"';
     160      if (array_key_exists('group', $_SESSION)) $Where = ' WHERE `Text` LIKE "%'.$TranslationTree[$_SESSION['group']]['Name'].'%"';
    161161        else $Where = '';
    162162    }
    163     //if(($Where != '') and (array_key_exists('group', $_SESSION))) $Where .= ' AND text LIKE "%'.$TranslationTree[$_SESSION['group']]['Name'].'%"';
     163    //if (($Where != '') and (array_key_exists('group', $_SESSION))) $Where .= ' AND text LIKE "%'.$TranslationTree[$_SESSION['group']]['Name'].'%"';
    164164
    165165    $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Log` '.$Where);
     
    172172      array('Name' => 'Date', 'Title' => T('Time')),
    173173    );
    174     if($_SESSION['type'] == '') $TableColumns[] =
     174    if ($_SESSION['type'] == '') $TableColumns[] =
    175175      array('Name' => 'LogName', 'Title' => T('Type'));
    176176    $TableColumns = array_merge($TableColumns, array(
     
    187187      '(SELECT `User`.`Name` FROM `User` WHERE `User`.`ID` = `Log`.`User`) AS `UserName` FROM `Log` LEFT JOIN `LogType` ON `LogType`.`Id`=`Log`.`Type` '.$Where.$Order['SQL'].$PageList['SQLLimit'];
    188188    $DbResult = $this->System->Database->query($sql);
    189     while($Line = $DbResult->fetch_assoc())
    190     {
    191       if($Line['Type'] == LOG_TYPE_ERROR) $Line['Text'] = htmlspecialchars($Line['Text']);
     189    while ($Line = $DbResult->fetch_assoc())
     190    {
     191      if ($Line['Type'] == LOG_TYPE_ERROR) $Line['Text'] = htmlspecialchars($Line['Text']);
    192192      $Line['Text'] = str_replace("\n", '<br/>', $Line['Text']);
    193193      $Output .= '<tr><td>'.$Line['Date'].'</td>';
    194       if($_SESSION['type'] == '') $Output .= '<td>'.T($Line['LogName']).'</td>';
     194      if ($_SESSION['type'] == '') $Output .= '<td>'.T($Line['LogName']).'</td>';
    195195      $Output .= '<td><span style="color: '.$Line['LogColor'].'">'.$Line['Text'].'</span></td>'.
    196196      '<td><a href="'.$this->System->Link('/user/?user='.$Line['User']).'">'.$Line['UserName'].'</a></td>'.
     
    200200    $Output .= '</table>'.
    201201      $PageList['Output'];
    202       if($this->System->User->Licence(LICENCE_ADMIN))
     202      if ($this->System->User->Licence(LICENCE_ADMIN))
    203203      {
    204204        $Output .= '<div>'.T('Remove').': <a href="'.$this->System->Link('/log/?a=delerrlog&amp;type='.LOG_TYPE_ERROR).'">'.T('Error logs').'</a> '.
     
    207207    } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    208208
    209     return($Output);
     209    return $Output;
    210210  }
    211211
    212212  function DeleteErrorLog()
    213213  {
    214     if($this->System->User->Licence(LICENCE_ADMIN) and
     214    if ($this->System->User->Licence(LICENCE_ADMIN) and
    215215    (($_GET['type'] == LOG_TYPE_ERROR) or ($_GET['type'] == LOG_TYPE_PAGE_NOT_FOUND)))
    216216    {
     
    223223      $Output = ShowMessage('Smazáno všech '.$DbRow[0].' záznamů z '.$LogType['Description'].'.');
    224224      $Output .= $this->ShowList();
    225       return($Output);
     225      return $Output;
    226226    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    227227  }
Note: See TracChangeset for help on using the changeset viewer.