Factory.php 2.5 KB

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