I am trying to parse PHPIDS's XML rule list (downloadable on their site http://phpids.org/), against the entered URL using the XML's regular expressions.
Now, i know very little about regex, and i've tried looking around and i haven't found much information on it which i've found helpful.
What i'd like to do is something like this (psuedo) if URL == regex die();
This is my latest attempt, of many:
<?php
$file="default_filter.xml";
$load = simplexml_load_file($file);
$regex = $load->filter->rule;
$url = explode(" ","http://localhost/test.php");
$url2 = "http://localhost/test.php";
if(in_array($regex,$url))
{
echo "bad url";
}
if(preg_match($regex,$url2))
{
echo "bad url";
}
//The above gives me Warning: preg_match() [function.preg-match]: Unknown modifier '|' in C:\wamp\www\test.php on line 12
//Which, already i don't understand regex so i dont know why the above is a problem...
?>
If i can get it to work, i'll loop through the rules, but for now i'm just trying 1 regex to get it working.
but i cannot figure out get the regex working.
This is the regex which is being pulled from the XML file:
<rule><![CDATA[(?:"[^"]*[^-]?>)|(?:[^\w\s]\s*\/>)|(?:>")]]></rule>
although i do not understand one bit of that...
Thanks in advance to anyone who can assit me.