var $rules;
/** user id */
var $uid;
+ /** tmp.bd or not */
+ var $bd;
function Filter($_uid) {
+ global $philter;
$this->uid = $_uid;
$this->rules = array();
- $sql = mysql_query("SELECT rank,rid,flags,name FROM rules WHERE uid='$_uid' ORDER BY rank");
+ $sql = mysql_query("SELECT rank,rid,flags,name FROM ".bd()."rules WHERE uid='$_uid' ORDER BY rank");
while(list($_rank,$_rid,$_flags,$_name) = mysql_fetch_row($sql)) {
- $this->rules[$_rid] = new Rule($_rank,$_flags,$_name,true);
+ $this->rules[$_rid] = new Rule($_rank,$_flags,$_name);
$this->rules[$_rid]->sql_get_matches($_uid,$_rid);
$this->rules[$_rid]->sql_get_actions($_uid,$_rid);
}
}
+
+ function get_global_data($_plug_id) {
+ if(isset($this->rules[0]))
+ foreach($this->rules[0]->matches as $match)
+ if($match[0] == $_plug_id)
+ return $match;
+ return(Array($_plug_id,0));
+ }
+
+ function set_global_data($_plug_id, $data) {
+ if(!isset($this->rules[0]))
+ $this->rules[0] = new Rule(0,'','GLOBAL');
+ foreach($this->rules[0]->matches as $id=>$match)
+ if($match[0] == $_plug_id) {
+ $this->rules[0]->matches[$id] = $data;
+ return;
+ }
+ $this->rules[0]->matches[] = $data;
+ }
function to_string() {
return "";
$this->rules[$_rid]->sql_clean($this->uid, $_rid);
unset($this->rules[$_rid]);
- mysql_query("UPDATE rules SET rank=rank-1 WHERE uid='{$this->uid}' and rank>$rk");
+ mysql_query("UPDATE ".bd()."rules SET rank=rank-1 WHERE uid='{$this->uid}' and rank>$rk");
}
function new_rule_id() {
$my_rule->actions[] = $data;
if(!count($my_rule->actions) && !count($my_rule->matches)) {
- $philter->set_error("You cannot add an empty rule");
+ $philter->set_error(_i18n('filter_err_empty'));
return false;
}
}
function to_js() {
- $res = "filter[0] = { all: 1, block:1, name:'[ new rule ]', matches: [], actions: [] };\n";
+ $res = "filter[0] = { all: 1, block:1, name:'"._i18n('new_rule')."', matches: [], actions: [] };\n";
foreach($this->rules as $id=>$rule)
- $res .= "filter[$id] = ".$rule->to_js().";\n";
+ if($id)
+ $res .= "filter[$id] = ".$rule->to_js().";\n";
return $res;
}