SHARE
TWEET

Untitled

a guest Sep 10th, 2014 190 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /* @(#) $Id: os_lib_handle.php,v 1.9 2008/03/03 19:37:25 dcid Exp $ */
  3.  
  4. /* Copyright (C) 2006-2008 Daniel B. Cid <dcid@ossec.net>
  5.  * All rights reserved.
  6.  *
  7.  * This program is a free software; you can redistribute it
  8.  * and/or modify it under the terms of the GNU General Public
  9.  * License (version 3) as published by the FSF - Free Software
  10.  * Foundation
  11.  */
  12.  
  13. /**
  14.  * This file contains functions dealing with the retrieval of firewall alert
  15.  * related information from an OSSEC installation.
  16.  *
  17.  * @copyright Copyright (c) 2006-2008, Daniel B. Cid, All rights reserved.
  18.  * @package ossec_web_ui
  19.  * @author  Daniel B. Cid <dcid@ossec.net>
  20.  * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License
  21.  *
  22.  */
  23.  
  24. /**
  25.  * Verify that the given configuration items are set. Returns
  26.  * NULL on error.
  27.  *
  28.  * @param unknown_type $ossec_dir
  29.  * @param unknown_type $ossec_max_alerts_per_page
  30.  * @param unknown_type $ossec_search_level
  31.  * @param unknown_type $ossec_search_time
  32.  * @param unknown_type $ossec_refresh_time
  33.  * @return unknown
  34.  */
  35. function os_check_config($ossec_dir, $ossec_max_alerts_per_page,
  36.                          $ossec_search_level, $ossec_search_time,
  37.                          $ossec_refresh_time)
  38. {
  39.     $config_err = "<b class='red'>Configuration error. Missing '%s'.</b><br />";
  40.  
  41.     /* checking each config variable */
  42.     if(!isset($ossec_dir))
  43.     {
  44.         echo sprintf($config_err, '$ossec_dir');
  45.         return(0);
  46.     }
  47.     if(!isset($ossec_max_alerts_per_page))
  48.     {
  49.         echo sprintf($config_err, '$ossec_max_alerts_per_page');
  50.         return(0);
  51.     }
  52.     if(!isset($ossec_search_level))
  53.     {
  54.         echo sprintf($config_err, '$ossec_search_level');
  55.         return(0);
  56.     }
  57.     if(!isset($ossec_search_level))
  58.     {
  59.         echo sprintf($config_err, '$ossec_search_level');
  60.         return(0);
  61.     }
  62.     if(!isset($ossec_search_time))
  63.     {
  64.         echo sprintf($config_err, '$ossec_search_time');
  65.         return(0);
  66.     }
  67.     if(!isset($ossec_refresh_time))
  68.     {
  69.         echo sprintf($config_err, '$ossec_refresh_time');
  70.         return(0);
  71.     }
  72.  
  73.     return(1);
  74. }
  75.  
  76. /**
  77.  * Set the handle directory and create the ossec handler.
  78.  *
  79.  * @param unknown_type $dir
  80.  * @return unknown
  81.  */
  82. function os_handle_start($dir)
  83. {
  84.     $ossec_handle{'dir'} = NULL;
  85.     $ossec_handle{'agent_dir'} = NULL;
  86.     $ossec_handle{'name'} = NULL;
  87.     $ossec_handle{'error'} = NULL;
  88.  
  89.  
  90.     /* 20 minutes */
  91.     $ossec_handle{'notify_time'} = 1200;
  92.  
  93.     $dh = NULL;
  94.     if($dh = opendir($dir))
  95.     {
  96.         closedir($dh);
  97.         $ossec_handle{'dir'} = $dir;
  98.         $ossec_handle{'agent_dir'} = $dir."/queue/agent-info";
  99.  
  100.         return($ossec_handle);
  101.     }
  102.     return(NULL);
  103. }
  104.  
  105.  
  106. /* EOF */
  107. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top