Ignore:
Timestamp:
Jul 15, 2014, 9:48:54 PM (10 years ago)
Author:
chronos
Message:
  • Přidáno: Přístup k RSS kanálům přes přístupový token.
File:
1 edited

Legend:

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

    r661 r668  
    1111    $this->License = 'GNU/GPLv3';
    1212    $this->Description = 'Logging user actions';
    13     $this->Dependencies = array('User');
     13    $this->Dependencies = array('User', 'RSS');
    1414  }
    1515
     
    3838      ),
    3939    ));
    40 
     40    $this->System->ModuleManager->Modules['RSS']->RegisterRSS(array('Title' => 'Logs',
     41      'Channel' => 'log', 'Callback' => array('ModuleLog', 'ShowRSS'),
     42      'Permission' => array('Module' => 'Log', 'Operation' => 'RSS')));
    4143  }
    4244
     
    5759      'Operation' => $Operation, 'Value' => $Value, 'IPAddress' => $IPAddress));
    5860  }
     61
     62  function ShowRSS()
     63  {
     64    $this->ClearPage = true;
     65    $this->FormatHTML = false;
     66    Header('Content-Type: text/xml');
     67    $Count = 20;
     68
     69    $Output = '';
     70    $Items = array();
     71    if(array_key_exists('type', $_GET)) $Where = ' WHERE `Type` = "'.($_GET['type'] * 1).'"';
     72      else $Where = '';
     73    $sql = 'SELECT *, UNIX_TIMESTAMP(`Time`) AS `TimeCreate`, (SELECT `User`.`Name` FROM `User` WHERE `User`.`Id` = `Log`.`User`) AS `UserName`, `Time` FROM `Log`'.
     74      $Where.' ORDER BY `Time` DESC LIMIT '.$Count;
     75    $DbResult = $this->System->Database->query($sql);
     76    while($Line = $DbResult->fetch_assoc())
     77    {
     78      $Line['Value'] = htmlspecialchars($Line['Value']);
     79      $Line['Value'] = str_replace("\n", '<br>', $Line['Value']);
     80
     81      $Items[] = array
     82      (
     83        'Title' => $Line['Module'].' '.$Line['Operation'].' ('.$Line['UserName'].', '.$Line['IPAddress'].')',
     84        'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/log.php'),
     85        'Description' => $Line['Module'].' '.$Line['Operation'].': '.$Line['Value'].' ('.$Line['UserName'].
     86          ', '.$Line['IPAddress'].', '.HumanDate($Line['Time']).')',
     87        'Time' => $Line['TimeCreate'],
     88      );
     89    }
     90
     91    $RSS = new RSS();
     92    $RSS->Title = $this->System->Config['Web']['Title'].' - Záznamy';
     93    $RSS->Link = 'http://'.$this->System->Config['Web']['Host'].'/';
     94    $RSS->Description = 'Aktuality '.$this->System->Config['Web']['Description'];
     95    $RSS->WebmasterEmail = $this->System->Config['Web']['AdminEmail'];
     96    $RSS->Items = $Items;
     97    return($RSS->Generate());
     98  }
    5999}
Note: See TracChangeset for help on using the changeset viewer.