示例#1
0
文件: Monitor.php 项目: steph/PHPIDS
 /**
  * Constructor
  *
  * @throws \InvalidArgumentException When PHP version is less than what the library supports
  * @throws \Exception
  * @param  Init       $init instance of IDS_Init
  * @param  array|null $tags list of tags to which filters should be applied
  * @return Monitor
  */
 public function __construct(Init $init, array $tags = null)
 {
     $this->storage = new Storage($init);
     $this->tags = $tags;
     $this->scanKeys = $init->config['General']['scan_keys'];
     $this->exceptions = isset($init->config['General']['exceptions']) ? $init->config['General']['exceptions'] : array();
     $this->html = isset($init->config['General']['html']) ? $init->config['General']['html'] : array();
     $this->json = isset($init->config['General']['json']) ? $init->config['General']['json'] : array();
     if (isset($init->config['General']['HTML_Purifier_Cache'])) {
         $this->HTMLPurifierCache = $init->getBasePath() . $init->config['General']['HTML_Purifier_Cache'];
     }
     $tmpPath = $init->getBasePath() . $init->config['General']['tmp_path'];
     if (!is_writeable($tmpPath)) {
         throw new \InvalidArgumentException("Please make sure the folder '{$tmpPath}' is writable");
     }
 }
示例#2
0
文件: Storage.php 项目: steph/PHPIDS
 /**
  * Constructor
  *
  * Loads filters based on provided IDS_Init settings.
  *
  * @param object $init IDS_Init instance
  *
  * @throws \InvalidArgumentException if unsupported filter type is given
  * @return void
  */
 public final function __construct(Init $init)
 {
     if ($init->config) {
         $caching = isset($init->config['Caching']['caching']) ? $init->config['Caching']['caching'] : 'none';
         $type = $init->config['General']['filter_type'];
         $this->source = $init->getBasePath() . $init->config['General']['filter_path'];
         if ($caching && $caching !== 'none') {
             $this->cacheSettings = $init->config['Caching'];
             $this->cache = CacheFactory::factory($init, 'storage');
         }
         switch ($type) {
             case 'xml':
                 return $this->getFilterFromXML();
             case 'json':
                 return $this->getFilterFromJson();
             default:
                 throw new \InvalidArgumentException('Unsupported filter type.');
         }
     }
 }
示例#3
0
 /**
  * Constructor
  *
  * @param string $type caching type
  * @param object $init the IDS_Init object
  * @throws \Exception
  *
  * @return void
  */
 public function __construct($type, Init $init)
 {
     $this->type = $type;
     $this->config = $init->config['Caching'];
     $this->path = $init->getBasePath() . $this->config['path'];
     if (file_exists($this->path) && !is_writable($this->path)) {
         throw new \Exception('Make sure all files in ' . htmlspecialchars($this->path, ENT_QUOTES, 'UTF-8') . 'are writeable!');
     }
 }