6 * Requirements: PHP5, SimpleXML
8 * Copyright (c) 2008 PHPIDS group (https://phpids.org)
10 * PHPIDS is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation, version 3 of the License, or
13 * (at your option) any later version.
15 * PHPIDS is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with PHPIDS. If not, see <http://www.gnu.org/licenses/>.
27 * @author Mario Heiderich <mario.heiderich@gmail.com>
28 * @author Christian Matthies <ch0012@gmail.com>
29 * @author Lars Strojny <lars@strojny.net>
30 * @license http://www.gnu.org/licenses/lgpl.html LGPL
31 * @link http://php-ids.org/
34 require_once 'IDS/Log/Interface.php';
39 * This class implements the composite pattern to allow to work with multiple
40 * logging wrappers at once.
44 * @author Christian Matthies <ch0012@gmail.com>
45 * @author Mario Heiderich <mario.heiderich@gmail.com>
46 * @author Lars Strojny <lars@strojny.net>
47 * @copyright 2007-2009 The PHPIDS Group
48 * @license http://www.gnu.org/licenses/lgpl.html LGPL
49 * @version Release: $Id:Composite.php 517 2007-09-15 15:04:13Z mario $
50 * @link http://php-ids.org/
52 class IDS_Log_Composite
56 * Holds registered logging wrapper
60 public $loggers = array();
63 * Iterates through registered loggers and executes them
65 * @param object $data IDS_Report object
69 public function execute(IDS_Report
$data)
71 // make sure request uri is set right on IIS
72 if (!isset($_SERVER['REQUEST_URI'])) {
73 $_SERVER['REQUEST_URI'] = substr($_SERVER['PHP_SELF'], 1);
74 if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING']) {
75 $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
79 // make sure server address is set right on IIS
80 if (isset($_SERVER['LOCAL_ADDR'])) {
81 $_SERVER['SERVER_ADDR'] = $_SERVER['LOCAL_ADDR'];
84 foreach ($this->loggers
as $logger) {
85 $logger->execute($data);
90 * Registers a new logging wrapper
92 * Only valid IDS_Log_Interface instances passed to this function will be
97 public function addLogger()
100 $args = func_get_args();
102 foreach ($args as $class) {
103 if (!in_array($class, $this->loggers
) &&
104 ($class instanceof IDS_Log_Interface
)) {
105 $this->loggers
[] = $class;
113 * @param object $logger IDS_Log_Interface object
117 public function removeLogger(IDS_Log_Interface
$logger)
119 $key = array_search($logger, $this->loggers
);
121 if (isset($this->loggers
[$key])) {
122 unset($this->loggers
[$key]);
135 * vim600: sw=4 ts=4 expandtab