index 090880d6a1613d6172593d79ddea1244cc8b0a08..99f170df244e134473815505e191704b24f9c672 100644 (file)
function sieve_if($elements,$object_id,$parent)
{
$this->parent = $parent;
+ $this->object_id = $object_id;
/* Possible address parts we can select */
$this->address_parts = array(
/* Match types */
$this->match_types = array(
":is" => _("is"),
+ ":regex" => _("regex"),
":contains" => _("contains"),
":matches" => _("matches"),
":count" => _("count"),
"gt" => _("greater than"),
"ne" => _("not equal"));
- $this->object_id = $object_id;
- if($elements!=NULL){
- $this->elements = $elements;
- $this->_parsed = $this->_parse($elements['ELEMENTS'],1);
+ /* Skip parsing if this element is new */
+ if($elements != NULL){
+
+ /* Remove comments from tests */
+ $tmp = array();
+ foreach($elements['ELEMENTS'] as $ele){
+ if($ele['class'] != "comment"){
+ $tmp[] = $ele;
+ }
+ }
+ $elements['ELEMENTS'] = $tmp;
+
+ if($elements!=NULL){
+ $this->elements = $elements;
+ $this->_parsed = $this->_parse($elements['ELEMENTS'],1);
+ }
}
}
default:
{
if(isset($data['LastError']) && !empty($data['LastError'])){
- print_a(array($data));
$ret[] = $data['LastError'];
}
}
}
/* Add allof/anyof tag */
- $script.= " ".$key." ( ";
+ if($Inverse){
+ $script .= "not ";
+ }
+ $script.= $key." ( ";
/* Add each test parameter */
foreach($data as $key2 => $dat){
if(!isset($match_types[$mt])){
$parsed[$key]['LastError'] = _("Invalid match type given.");
}
+ if($mt == ":regex"){
+ $this->parent->add_require("regex");
+ }
$parsed[$key]['Match_type'] = $mt;
}
$Match_types = array( ":over" => _("greater than") ,
":under" => _("lower than"));
- $Units = array( "M" => _("Megabyte") ,
- "K" => _("Kilobyte"));
+ $Units = array( "M" => _("Megabyte"),
+ "K" => _("Kilobyte"),
+ "" => _("Bytes"));
+
+ /* Toggle Inverse ? */
+ if(isset($_POST['toggle_inverse_'.$element_id])){
+ $parsed[$key]['Inverse'] = !$parsed[$key]['Inverse'];
+ }
/* Reset error */
$parsed[$key]['LastError'] ="";
}else{
$object = $smarty->fetch(get_template_path("templates/element_elsif.tpl",TRUE,dirname(__FILE__)));
}
- $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
+ $str = preg_replace("/%%OBJECT_CONTENT%%/",addcslashes($object,"\\"),$object_container);
return($str);
}
$values .= $key.", ";
}
$values = preg_replace("/,$/","",trim($values));
+
$smarty->assign("keys",$keys);
- $smarty->assign("values",$values);
+ $smarty->assign("values", $values);
$smarty->assign("ID" , $element_id);
- $ret .= $smarty->fetch(get_template_path("templates/element_address.tpl",TRUE,dirname(__FILE__)));
+ $str = $smarty->fetch(get_template_path("templates/element_address.tpl",TRUE,dirname(__FILE__)));
+ $ret .= $str;
break;
}
$Match_types = array( ":over" => _("greater than") ,
":under" => _("lower than"));
- $Units = array( "M" => _("Megabyte") ,
- "K" => _("Kilobyte"));
+ $Units = array( "M" => _("Megabyte"),
+ "K" => _("Kilobyte"),
+ "" => _("Bytes"));
$Match_type = $data['Match_type'];
$Value = preg_replace("/[^0-9]/","",$data['Value_List'][0]);
$smarty->assign("DisplayAdd",FALSE);
$smarty->assign("DisplayDel",TRUE);
$str = $smarty->fetch(get_template_path("templates/object_test_container.tpl",TRUE,dirname(__FILE__)));
- $ret = preg_replace("/%%OBJECT_CONTENT%%/",$ret,$str);
+ $ret = preg_replace("/%%OBJECT_CONTENT%%/",addcslashes($ret,"\\"),$str);
return($ret);
}
*/
function _parse($data,$id = 0)
{
- $av_methods = array("address","allof","anyof","exists","false","header","not","size","true","envelope");
- $av_match_type= array(":is",":contains",":matches",":over",":count",":value",":under");
+ $av_match_type = array();
+ foreach($this->match_types as $name => $description){
+ $av_match_type[] = $name;
+ }
+ $av_match_type[] = ":over";
+ $av_match_type[] = ":under";
+
+
+
+ $av_methods= array("address","allof","anyof","exists","false","header","not","size","true","envelope");
$type = $data[$id]['text'];
$tmp = array();
$part = "(:all|:localpart|:domain)";
- $operator = "(:contains|:is|:matches|:count|:value)";
+ $operator = "(:regex|:contains|:is|:matches|:count|:value)";
$value_op = "(lt|le|eq|ge|gt|ne)";
$Address_Part = "";