Location: PHPKode > projects > TS2WebAdmin > ts2webadmin/app/mod_globallog.php
<?php

/**
 * TS2WebAdmin - Lightweight TeamSpeak 2 Control Panel
 *
 * $Id: mod_globallog.php 2009-09-03 20:23:12 sven $
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * @package   TS2WebAdmin
 * @version   2.0.0-alpha2
 * @author    Sven 'ScP' Paulsen
 * @copyright Copyright (c) 2009 by Planet TeamSpeak. All rights reserved.    
 */

/* check if file is included correctly */
defined('TS2WA_VALID') || die('Access denied...');

/**
 * @package  TS2WebAdmin_Module_Globallog
 * @category TS2WebAdmin_Module
 */
class TS2WebAdmin_Module_Globallog extends TS2WebAdmin_Module
{
  /**
   * Module requires SSA permissions.
   * 
   * @return void
   */
  function checkLogin()
  {
    $this->isAuthorized(TS2WA_LOGIN_SUPERADMIN);
  }

  /**
   * Displays a list of entries from the server log.
   * 
   * @return void
   */
  function indexAction()
  {
    $this->setSubMenu('global');

    $logs = $this->_ts2->sadmin_logRead(3000);
    
    if(!is_array($logs))
    {
      $this->_app->raiseError('Error loading server log', 500, $this->_ts2->debug_lastreply());
    }
        
    $patterns = array(
      'web : superserveradmin connected',
      'tcpquery : superserveradmin connected',
      '*remark by ' . $this->_app->getConfigParam('server_username', '') . '* TS2WebAdmin client connected',
    );
    
    foreach($logs as $key => $val)
    {
      foreach($patterns as $pattern) if(strstr($val['event'], $pattern) !== FALSE) unset($logs[$key]);
    }
    
    $this->assign('logs', array_reverse($logs));
  }
  
  /**
   * Displays a list of entries from the server log matching a searched string.
   * 
   * @return void
   */
  function searchAction()
  {
    $this->setSubMenu('global');
    $this->setTplFile('globallog');

    $search_pattern = $this->_app->getParam('pattern', FALSE);
    
    if($search_pattern === FALSE || $search_pattern == 'search...')
    {
      $this->redirect('globallog');
    }
    
    $logs = $this->_ts2->sadmin_logFind($search_pattern);
    
    if(!is_array($logs))
    {
      $this->_app->raiseError('Error loading server log', 500, $this->_ts2->debug_lastreply());
    }
    
    $patterns = array(
      'web : superserveradmin connected',
      'tcpquery : superserveradmin connected',
      '*remark by ' . $this->_app->getConfigParam('server_username', '') . '* TS2WebAdmin client connected',
    );
    
    foreach($logs as $key => $val)
    {
      foreach($patterns as $pattern) if(strstr($val['event'], $pattern) !== FALSE) unset($logs[$key]);
    }

    $this->assign('pattern', $search_pattern);
    $this->assign('logs', array_reverse($logs));
  }
}
Return current item: TS2WebAdmin