1 : <?php
2 :
3 : /**
4 : * PHPIDS
5 : *
6 : * Requirements: PHP5, SimpleXML
7 : *
8 : * Copyright (c) 2007 PHPIDS group (http://php-ids.org)
9 : *
10 : * This program is free software; you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License as published by
12 : * the Free Software Foundation; version 2 of the license.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * PHP version 5.1.6+
20 : *
21 : * @category Security
22 : * @package PHPIDS
23 : * @author Mario Heiderich <mario.heiderich@gmail.com>
24 : * @author Christian Matthies <ch0012@gmail.com>
25 : * @author Lars Strojny <lars@strojny.net>
26 : * @license http://www.gnu.org/licenses/lgpl.html LGPL
27 : * @link http://php-ids.org/
28 : */
29 :
30 : /**
31 : * Caching factory
32 : *
33 : * This class is used as a factory to load the correct concrete caching
34 : * implementation.
35 : *
36 : * @category Security
37 : * @package PHPIDS
38 : * @author Christian Matthies <ch0012@gmail.com>
39 : * @author Mario Heiderich <mario.heiderich@gmail.com>
40 : * @author Lars Strojny <lars@strojny.net>
41 : * @copyright 2007 The PHPIDS Group
42 : * @license http://www.gnu.org/licenses/lgpl.html LGPL
43 : * @version Release: $Id:Factory.php 517 2007-09-15 15:04:13Z mario $
44 : * @link http://php-ids.org/
45 : * @since Version 0.4
46 : */
47 : class IDS_Caching
48 : {
49 :
50 : /**
51 : * Factory method
52 : *
53 : * @param array $init the IDS_Init object
54 : * @param string $type the caching type
55 : *
56 : * @return object the caching facility
57 : */
58 : public static function factory($init, $type)
59 : {
60 :
61 48 : $object = false;
62 48 : $wrapper = preg_replace(
63 48 : '/\W+/m',
64 48 : null,
65 48 : ucfirst($init->config['Caching']['caching'])
66 48 : );
67 48 : $class = 'IDS_Caching_' . $wrapper;
68 48 : $path = dirname(__FILE__) . DIRECTORY_SEPARATOR .
69 48 : $wrapper . '.php';
70 :
71 48 : if (file_exists($path)) {
72 47 : include_once $path;
73 :
74 47 : if (class_exists($class)) {
75 47 : $object = call_user_func(array($class, 'getInstance'),
76 47 : $type, $init);
77 47 : }
78 47 : }
79 :
80 48 : return $object;
81 : }
82 : }
83 :
84 : /*
85 : * Local variables:
86 : * tab-width: 4
87 : * c-basic-offset: 4
88 : * End:
|