Exemple #1
0
 /**
  * Constructor
  *
  * @param array  $request array to scan
  * @param object $init    instance of IDS_Init
  * @param array  $tags    list of tags to which filters should be applied
  *
  * @return void
  */
 public function __construct(array $request, IDS_Init $init, array $tags = null)
 {
     $version = isset($init->config['General']['min_php_version']) ? $init->config['General']['min_php_version'] : '5.1.6';
     if (version_compare(PHP_VERSION, $version, '<')) {
         throw new Exception('PHP version has to be equal or higher than ' . $version . ' or
             PHP version couldn\'t be determined');
     }
     if (!empty($request)) {
         $this->storage = new IDS_Filter_Storage($init);
         $this->request = $request;
         $this->tags = $tags;
         $this->scanKeys = $init->config['General']['scan_keys'];
         $this->exceptions = isset($init->config['General']['exceptions']) ? $init->config['General']['exceptions'] : false;
         $this->html = isset($init->config['General']['html']) ? $init->config['General']['html'] : false;
         $this->json = isset($init->config['General']['json']) ? $init->config['General']['json'] : false;
         if (isset($init->config['General']['HTML_Purifier_Path']) && isset($init->config['General']['HTML_Purifier_Cache'])) {
             $this->pathToHTMLPurifier = $init->config['General']['HTML_Purifier_Path'];
             $this->HTMLPurifierCache = $init->getBasePath() . $init->config['General']['HTML_Purifier_Cache'];
         }
     }
     if (!is_writeable($init->getBasePath() . $init->config['General']['tmp_path'])) {
         throw new Exception('Please make sure the ' . htmlspecialchars($init->getBasePath() . $init->config['General']['tmp_path'], ENT_QUOTES, 'UTF-8') . ' folder is writable');
     }
     include_once 'IDS/Report.php';
     $this->report = new IDS_Report();
 }
Exemple #2
0
 /**
  * Constructor
  *
  * Loads filters based on provided IDS_Init settings.
  *
  * @param object $init IDS_Init instance
  * 
  * @throws Exception if unsupported filter type is given
  * @return void
  */
 public final function __construct(IDS_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'];
             include_once 'IDS/Caching/Factory.php';
             $this->cache = IDS_Caching::factory($init, 'storage');
         }
         switch ($type) {
             case 'xml':
                 $this->getFilterFromXML();
                 break;
             case 'json':
                 $this->getFilterFromJson();
                 break;
             default:
                 throw new Exception('Unsupported filter type.');
         }
     }
 }