예제 #1
0
 public static function getRule($ruleID)
 {
     if ($ruleID) {
         $rule = DB::execute("SELECT entryID, ruleName, userID FROM rules WHERE ruleID='" . ms($ruleID) . "'");
         if (count($rule) > 0) {
             $ruleObj = new Rule($rule["userID"]);
             $ruleObj->setRuleID($ruleID);
             $ruleObj->setEntryID($rule["entryID"]);
             $ruleObj->setRuleName($rule["ruleName"]);
             $keywords = DB::fetchAll("SELECT keyword FROM rules AS r, keyword_entries AS k WHERE ruleID='" . ms($ruleID) . "' AND r.entryID=k.entryID");
             $replies = DB::fetchAll("SELECT messageID FROM reply_msg WHERE ruleID='" . ms($ruleID) . "'");
             $ruleObj->initKeywords($keywords);
             $ruleObj->initReplies($replies);
             return $ruleObj;
         } else {
             if (DEBUG_MODE) {
                 echo "[RuleFactory | getRule] Cannot find rule from DB where ruleID = " . $this->ruleID;
             }
         }
     }
     exit;
 }
예제 #2
0
파일: rules.php 프로젝트: AviMoto/webekci
function rule_insert($post, $db)
{
    $new_rule = new Rule();
    $new_rule->setRuleID($post['rule_id']);
    $new_rule->setRuleParrentRuleID($post['rule_pid']);
    $new_rule->setRuleFileID($post['rf_filter']);
    $new_rule->setRuleInformation($post['rule_msg']);
    $new_rule->setRule($post['rule']);
    $new_rule->setRuleFileActive($post['validity']);
    $new_rule->setFilled(true);
    $db->addRule($new_rule);
}
예제 #3
0
 public function getAllRules($where = '', $wlimit = '')
 {
     $count_str = "SELECT R.RecordID,R.RuleID,R.ParrentRuleID,R.Information,\n                  R.Rule,R.DefaultValue,R.Deleted,\n                  RF.RuleFileName,RDF.DataFileName,R.RuleFileID from rules R\n                  LEFT JOIN rule_files RF ON (RF.RuleFileID=R.RuleFileID)\n                  LEFT JOIN rule_data_files RDF ON (RDF.DataFileID=RF.RuleFileID)\n                  WHERE 1 {$where} ORDER BY R.RecordID DESC {$wlimit}";
     $result = $this->dbh->query($count_str);
     if (PEAR::isError($result)) {
         echo $result->getMessage() . ' - ' . $result->getUserinfo();
         exit;
     }
     $array = $result->fetchAll();
     $result->free();
     $rules_a = array();
     foreach ($array as $r) {
         $rule = new Rule();
         $rule->setRuleRecordID($r[0]);
         $rule->setRuleID($r[1]);
         $rule->setRuleParrentRuleID($r[2]);
         $rule->setRuleInformation($r[3]);
         $rule->setRule($r[4]);
         $rule->setRuleShort(substr($r[4], 0, 55));
         $rule->setRuleDefaultValue($r[5]);
         $rule->setRuleFileName($r[7]);
         $rule->setRuleFileID($r[9]);
         $rule->setDataFileName($r[8]);
         $rule->setRuleActive($r[6]);
         $rules_a[] = $rule;
     }
     return $rules_a;
 }