mRule=$rule; $this->mTags=$tags; $this->mImpact=$impact; $this->mDescription=$description; } /** * Abstract match method * * The concrete match process which returns a boolean to inform * about a match * * @abstract * @access public * @return bool */ function Match($string) { error("This method needs to be overridden in subclasses"); } /** * Get filter description * * @access public * @return string Filter description */ function Description() { return $this->mDescription; } /** * Return list of tags * * @access public * @return array List of tags */ function Tags() { return $this->mTags; } /** * Return filter rule * * @access public * @return mixed Filter rule */ function Rule() { return $this->mRule; } /** * Get filter impact level * * @access public * @return integer Impact level */ function Impact() { return $this->mImpact; } } /** * Regex filter class * * The filter class based on regular expression matching is the default * filter class used in PHP4IDS. * * @author Stefan Gehrig (gehrig@ishd.de) * @package PHP4IDS * @subpackage Filter * @version 0.2 */ class IDSRegexpFilter extends IDSFilter { /** * Returns PCRE flags (default 'ims') * * @access public * @return string */ function Flags() { $static_name="_STATIC_" . strtoupper(__CLASS__); if (!isset($GLOBALS[$static_name])) $GLOBALS[$static_name]='ims'; return $GLOBALS[$static_name]; } /** * Set PCRE flags * * @access public * @param string $flags Regular expression modifier flags * @return void */ function SetFlags($flags) { $static_name="_STATIC_" . strtoupper(__CLASS__); $GLOBALS[$static_name]=$flags; } /** * Match method * * IDSRegexpFilter->match() used preg_match() to match the rule against * the given string. * * @access public * @return bool Filter matched? */ function Match($string) { if (!is_string($string)) error('Invalid argument. Exptected a string, got ' . gettype($string)); return (bool) preg_match('/' . $this->Rule() . '/' . IDSRegexpFilter::Flags(), $string); } } ?>