\n");
$SQLNumRows = pg_numrows($SQLQueryResults);
if ( $SQLNumRows ) {
for ( $loop = 0 ; $loop != $SQLNumRows ; $loop++ ) {
$SQLQueryResultsObject = pg_fetch_object($SQLQueryResults,$loop) or
die(pg_errormessage()."
\n");
$id=stripslashes(pgdatatrim($SQLQueryResultsObject->trule_id));
$alert=pgdatatrim($SQLQueryResultsObject->trule_logalert);
$email=stripslashes(pgdatatrim($SQLQueryResultsObject->trule_email));
$expression=pgdatatrim($SQLQueryResultsObject->trule_expression);
$desc=pgdatatrim($SQLQueryResultsObject->trule_desc);
$startseverity=stripslashes(pgdatatrim($SQLQueryResultsObject->trule_startseverity));
$stopseverity=stripslashes(pgdatatrim($SQLQueryResultsObject->trule_stopseverity));
$startfacility=stripslashes(pgdatatrim($SQLQueryResultsObject->trule_startfacility));
$stopfacility=stripslashes(pgdatatrim($SQLQueryResultsObject->trule_stopfacility));
$ruleorlevel=stripslashes(pgdatatrim($SQLQueryResultsObject->trule_ruleorlevel));
$launchid=stripslashes(pgdatatrim($SQLQueryResultsObject->tlaunch_id));
$newid=getnextid ($dbsocket, "syslog_trule_trule_id_seq");
$threshold=stripslashes(pgdatatrim($SQLQueryResultsObject->trule_threshold));
$thresholdtype=stripslashes(pgdatatrim($SQLQueryResultsObject->trule_thresholdtype));
$starttime=stripslashes(pgdatatrim($SQLQueryResultsObject->trule_starttime));
$endtime=stripslashes(pgdatatrim($SQLQueryResultsObject->trule_endtime));
$timertype=stripslashes(pgdatatrim($SQLQueryResultsObject->trule_timertype));
$daysofweek=stripslashes(pgdatatrim($SQLQueryResultsObject->trule_daysofweek));
clonehostrule($dbsocket,$newid,$destination,$alert,$email,$expression,$desc,$startfacility,$stopfacility,$startseverity,$stopseverity,$ruleorlevel,$launchid,$threshold,$thresholdtype,$starttime,$endtime,$timertype,$daysofweek);
if ( numdenials($dbsocket,1,$id) ) {
clonedenials($dbsocket,$id,$newid);
}
}
pg_freeresult($SQLQueryResults) or
die(pg_errormessage() . "
\n");
}
$hostid=$destination;
$ruletype=2;
}
if ( $ruletype == 1 ) {
if ( $subaction == "save" ) {
if ( strval($id) < 1 ) {
addpremaderule($dbsocket,$code,$desc,$typeid,$startfacility,$stopfacility,$startseverity,$stopseverity,$ruleorlevel,$launchid,$threshold,$thresholdtype);
$id=stripslashes(pgdatatrim(relatedata ($dbsocket,'Syslog_TPremade','TPremade_ID',"TPremade_Desc='".$desc."'")));
} else {
updatepremaderule($dbsocket,$id,$code,$desc,$typeid,$startfacility,$stopfacility,$startseverity,$stopseverity,$ruleorlevel,$launchid,$threshold,$thresholdtype);
}
}
if ( ( $action == "Add Deny Rule" ) && ( strval($id) > 0 ) ){
addblankdenypremade($dbsocket,$id);
}
if ( $subaction == "savedeny" ) {
if ( $action == "Save" ) {
updatedenial($dbsocket,2,$denyid,$denyexp,$denystartfacility,$denystopfacility,$denystartseverity,$denystopseverity);
}
}
if ( ( $id != "" ) && ( $action != "Add" ) ) {
$SQLQuery="select * from Syslog_TPremade where TPremade_ID=$id";
$SQLQueryResults=pg_exec($dbsocket,$SQLQuery) or
die(pg_errormessage()."
\n");
if ( $SQLQueryResults ) {
$SQLQueryResultsObject = pg_fetch_object($SQLQueryResults,0) or
die(pg_errormessage()."
\n");
$code=pgdatatrim($SQLQueryResultsObject->tpremade_code);
$desc=pgdatatrim($SQLQueryResultsObject->tpremade_desc);
$typeid=stripslashes(pgdatatrim($SQLQueryResultsObject->tpremadetype_id));
$ruleorlevel=stripslashes(pgdatatrim($SQLQueryResultsObject->tpremade_premadeorlevel));
$startseverity=stripslashes(pgdatatrim($SQLQueryResultsObject->tpremade_startseverity));
$stopseverity=stripslashes(pgdatatrim($SQLQueryResultsObject->tpremade_stopseverity));
$startfacility=stripslashes(pgdatatrim($SQLQueryResultsObject->tpremade_startfacility));
$stopfacility=stripslashes(pgdatatrim($SQLQueryResultsObject->tpremade_stopfacility));
$launchid=stripslashes(pgdatatrim($SQLQueryResultsObject->tlaunch_id));
$threshold=stripslashes(pgdatatrim($SQLQueryResultsObject->tpremade_threshold));
$thresholdtype=stripslashes(pgdatatrim($SQLQueryResultsObject->tpremade_thresholdtype));
}
pg_freeresult($SQLQueryResults) or
die(pg_errormessage() . "
\n");
} else {
$id="";
$code="";
$desc="";
}
}
if ( $ruletype == 2 ) {
if ( $action == "Save New" ) {
$host = gethost($dbsocket,$hostid);
if ( $alert != 1 ) { $alert=0; }
if ( $exptype == 2 ) {
$cnt=count($premadeid);
for ( $loop = 0 ; $loop != $cnt ; $loop ++ ) {
$preid=$premadeid[($loop)];
$expression=pgdatatrim(relatedata ($dbsocket,'Syslog_TPremade','TPremade_Code',"TPremade_ID=$preid"));
$desc=stripslashes(pgdatatrim(relatedata ($dbsocket,'Syslog_TPremade','TPremade_Desc',"TPremade_ID=$preid")));
$ruleorlevel=stripslashes(pgdatatrim(relatedata ($dbsocket,'Syslog_TPremade','TPremade_premadeorlevel',"TPremade_ID=$preid")));
$startseverity=stripslashes(pgdatatrim(relatedata ($dbsocket,'Syslog_TPremade','TPremade_StartSeverity',"TPremade_ID=$preid")));
$stopseverity=stripslashes(pgdatatrim(relatedata ($dbsocket,'Syslog_TPremade','TPremade_StopSeverity',"TPremade_ID=$preid")));
$startfacility=stripslashes(pgdatatrim(relatedata ($dbsocket,'Syslog_TPremade','TPremade_StartFacility',"TPremade_ID=$preid")));
$stopfacility=stripslashes(pgdatatrim(relatedata ($dbsocket,'Syslog_TPremade','TPremade_Stopfacility',"TPremade_ID=$preid")));
$launchid=stripslashes(pgdatatrim(relatedata ($dbsocket,'Syslog_TPremade','TLaunch_ID',"TPremade_ID=$preid")));
$threshold=stripslashes(pgdatatrim(relatedata ($dbsocket,'Syslog_TPremade','TPremade_Threshold',"TPremade_ID=$preid")));
$thresholdtype=stripslashes(pgdatatrim(relatedata ($dbsocket,'Syslog_TPremade','TPremade_ThresholdType',"TPremade_ID=$preid")));
$starttime=mktime($starthour,$startminute,0,numberofmonth($startmonth),$startday,$startyear);
$endtime=mktime($stophour,$stopminute,0,numberofmonth($stopmonth),$stopday,$stopyear);
$newdaysofweek=0;
for ( $dayloop=0; $dayloop != count($daysofweek) ; $dayloop++ ) { $newdaysofweek=$newdaysofweek+$daysofweek[$dayloop]; }
$daysofweek=$newdaysofweek;
addhostrule($dbsocket,$hostid,$alert,$email,$expression,$desc,$startfacility,$stopfacility,$startseverity,$stopseverity,$ruleorlevel,$launchid,$threshold,$thresholdtype,$starttime,$endtime,$timertype,$daysofweek);
}
} else {
$starttime=mktime($starthour,$startminute,0,numberofmonth($startmonth),$startday,$startyear);
$endtime=mktime($stophour,$stopminute,0,numberofmonth($stopmonth),$stopday,$stopyear);
$newdaysofweek=0;
for ( $dayloop=0; $dayloop != count($daysofweek) ; $dayloop++ ) { $newdaysofweek=$newdaysofweek+$daysofweek[$dayloop]; }
$daysofweek=$newdaysofweek;
addhostrule($dbsocket,$hostid,$alert,$email,$expression,$desc,$startfacility,$stopfacility,$startseverity,$stopseverity,$ruleorlevel,$launchid,$threshold,$thresholdtype,$starttime,$endtime,$timertype,$daysofweek);
}
}
if ( ( $action == "Delete" ) && ( $subaction != "ruledeny" ) ) {
dropruleid($dbsocket,$ruleid);
dropdenial($dbsocket,1,$ruleid);
}
if ( ( $action == "Save" ) && ( $subaction != "ruledeny" ) ) {
if ( $alert != 1 ) { $alert=0; }
$rulestarttime=mktime($rulestarthour,$rulestartminute,0,numberofmonth($rulestartmonth),$rulestartday,$rulestartyear);
$ruleendtime=mktime($rulestophour,$rulestopminute,0,numberofmonth($rulestopmonth),$rulestopday,$rulestopyear);
$newdaysofweek=0;
for ( $dayloop=0; $dayloop != count($ruledaysofweek) ; $dayloop++ ) { $newdaysofweek=$newdaysofweek+$ruledaysofweek[$dayloop]; }
$ruledaysofweek=$newdaysofweek;
updatehostrule($dbsocket,$ruleid,$hostid,$alert,$email,$expression,$desc,$startfacility,$stopfacility,$startseverity,$stopseverity,$ruleorlevel,$launchid,$rulethreshold,$rulethresholdtype,$rulestarttime,$ruleendtime,$ruletimertype,$ruledaysofweek);
}
if ( $subaction == "ruledeny" ) {
if ( $action == "Delete" ) { dropdenial($dbsocket,1,$denyid); }
if ( $action == "Save" ) {
updatedenial($dbsocket,1,$denyid,$denyexp,$denystartfacility,$denystopfacility,$denystartseverity,$denystopseverity);
}
}
}
$PageTitle="Syslog Management Tool";
do_header($PageTitle, 'rule');
if ( $ruletype == 1 ) {
/* This section is for manipulating premade rules */
if ( ( $action == "Delete" ) && ( $subaction == "savedeny" ) ) { dropdenial($dbsocket,2,$denyid); }
if ( ( $action == "Delete" ) && ( $subaction != "savedeny" ) ) {
if ( droppremade($dbsocket,$id) ) {
dropdenial($dbsocket,2,$id);
echo "Delete Successfull
\n";
} else {
echo "Delete Failed!
\n";
}
} else {
if ( $startfacility == "" ) {
$startfacility=0;
$stopfacility=23;
$startseverity=0;
$stopseverity=7;
}
openform("rule.php","post",2,1,0);
formfield("ruletype","Hidden",3,1,0,10,10,1);
formfield("id","Hidden",3,1,0,10,10,$id);
formfield("subaction","Hidden",3,1,0,10,10,"save");
echo "Expression: ";
formfield("code","text",3,1,1,60,80,$code);
echo "Problem/Resolution Description: ";
formfield("desc","text",3,1,1,60,256,$desc);
echo "Premade Type: ";
premadetypedropdown ($dbsocket, "typeid",0,1,1,1,$typeid);
echo "Facility Range: ";
facilitydropdown("startfacility",1,0,0,1,$startfacility);
echo " to ";
facilitydropdown("stopfacility",1,1,1,1,$stopfacility);
echo "Severity Range: ";
severitydropdown("startseverity",1,0,0,1,$startseverity);
echo " to ";
severitydropdown("stopseverity",1,1,1,1,$stopseverity);
echo "Rule Type: Expression ";
echo "Facility & Severity ";
echo "Expression w/ Facility & Severity
";
echo "Launch External Program: ";
launchdropdown ($dbsocket, "launchid",0,1,1,1,$launchid);
echo "Threshold Type: None ";
echo "Supression Threshold ";
echo "Accumulating Threshold
\n";
echo "Threshold: ";
thresholddropdown('threshold', 0, 0, 1, 1,$threshold);
formsubmit("Add Deny Rule",3,1,0);
formsubmit("Save",3,1,0);
formreset("Reset",3,1,0);
closeform();
if ( numdenials($dbsocket,2,$id) ) {
$SQLQuery="select * from Syslog_TPremadeDeny where TPremade_ID=$id order by TPremadeDeny_ID";
$DenySQLQueryResults=pg_exec($dbsocket,$SQLQuery) or
die(pg_errormessage()."
\n");
$DenySQLNumRows = pg_numrows($DenySQLQueryResults);
if ( $DenySQLNumRows ) {
for ( $denyloop=0 ; $denyloop != $DenySQLNumRows ; $denyloop++ ) {
$DenySQLQueryResultsObject = pg_fetch_object($DenySQLQueryResults,$denyloop) or
die(pg_errormessage()."
\n");
$denyid=stripslashes(pgdatatrim($DenySQLQueryResultsObject->tpremadedeny_id));
$denyexp=pgdatatrim($DenySQLQueryResultsObject->tpremadedeny_expression);
$denystartfacility=stripslashes(pgdatatrim($DenySQLQueryResultsObject->tpremadedeny_startfacility));
$denystopfacility=stripslashes(pgdatatrim($DenySQLQueryResultsObject->tpremadedeny_stopfacility));
$denystartseverity=stripslashes(pgdatatrim($DenySQLQueryResultsObject->tpremadedeny_startseverity));
$denystopseverity=stripslashes(pgdatatrim($DenySQLQueryResultsObject->tpremadedeny_stopseverity));
echo "
ID: $denyid | \n"; openform("rule.php","post",2,1,0); formfield("id","Hidden",3,1,0,10,10,$id); formfield("denyid","Hidden",3,1,0,10,10,$denyid); formfield("ruletype","Hidden",3,1,0,10,10,1); formfield("subaction","Hidden",3,1,0,10,10,"savedeny"); echo " |
"; echo "Reg. Expression Code: "; formfield("denyexp","text",3,1,1,60,80,$denyexp); echo " | |
Facility Range: "; facilitydropdown("denystartfacility",1,0,0,1,$denystartfacility); echo " to "; facilitydropdown("denystopfacility",1,1,1,1,$denystopfacility); echo " | Severity Range: "; severitydropdown("denystartseverity",1,0,0,1,$denystartseverity); echo " to "; severitydropdown("denystopseverity",1,1,1,1,$denystopseverity); echo " |
"; formsubmit("Save",3,1,0); formsubmit("Delete",3,1,0); formreset("Reset",3,1,0); closeform(); echo " |
Action | Log Alert | Email Address | " . "Expression | Pre-made Rule | ||
\n | " .
" | \n\n | \n" . " | \n" . " | "; pixruledropdown ($dbsocket, "premadeid[]",2,1,0,5,"multiple"); echo " | |
Facility Range: "; facilitydropdown("startfacility",1,0,0,1,0); echo " to "; facilitydropdown("stopfacility",1,0,0,1,23); echo " | Severity Range: "; severitydropdown("startseverity",1,0,0,1,0); echo " to "; severitydropdown("stopseverity",1,0,0,1,7); echo " | |||||
"; echo "Rule Type: Expression "; echo "Facility & Severity "; echo "Expression w/ Facility & Severity | ||||||
Launch External Program: "; launchdropdown ($dbsocket, "launchid",0,0,0,1,""); echo " | ||||||
Threshold Type: None "; echo "Supression Threshold "; echo "Accumulating Threshold | "; echo " Threshold: "; thresholddropdown('threshold', 0, 0, 0, 1,$threshold); echo " | |||||
Problem/Resolution Description: "; formfield("desc","text",3,1,0,80,256,""); echo " | ||||||
Rule Timer: None "; echo "Suspend "; echo "Delete & Suspend "; echo "Specified Suspend | ||||||
Rule Start: Time: " ; hourdropdown("starthour") ; echo ":" ; minutedropdown("startminute") ; echo " \nDate: "; monthdropdown("startmonth"); echo "/"; daydropdown("startday"); echo "/"; yeardropdown("startyear"); echo " | Rule End: Time: "; hourdropdown("stophour") ; echo ":" ; minutedropdown("stopminute") ; echo " Date: "; monthdropdown("stopmonth"); echo "/"; daydropdown("stopday"); echo "/"; yeardropdown("stopyear"); echo " | |||||
"; dayofweekboxes("daysofweek",0,0,0,$daysofweek) . "\n"; closeform(); echo " |
"; echo ''; echo ''; echo ' | '; echo "ID: $id | Log Alert: "; if ( $alert ) { echo ""; } else { echo ""; } echo " | EMail: "; formfield("email","Text",3,1,1,20,80,$email); echo " | Expression: "; formfield("expression","Text",3,1,1,20,80,$expression); echo " | ||
Facility Range: "; facilitydropdown("startfacility",1,0,0,1,$startfacility); echo " to "; facilitydropdown("stopfacility",1,0,0,1,$stopfacility); echo " | Severity Range: "; severitydropdown("startseverity",1,0,0,1,$startseverity); echo " to "; severitydropdown("stopseverity",1,0,0,1,$stopseverity); echo " | |||||
"; echo "Rule Type: Expression "; echo "Facility & Severity "; echo "Expression w/ Facility & Severity | ||||||
Launch External Program: "; launchdropdown ($dbsocket, "launchid",0,0,0,1,$launchid); echo " | ||||||
Threshold Type: None "; echo "Supression Threshold "; echo "Accumulating Threshold "; echo " | Threshold: "; thresholddropdown('rulethreshold', 0, 0, 0, 1,$rulethreshold); echo " | |||||
Problem/Resolution Description: "; formfield("desc","text",3,1,0,80,256,$desc) ; echo " | ||||||
Rule Timer: None "; echo "Suspend "; echo "Delete & Suspend "; echo "Specified Suspend | ||||||
Rule Start: Time: "; hourdropdown("rulestarthour",0,0,0,1,$rulestarthour) ; echo ":" ; minutedropdown("rulestartminute",0,0,0,1,$rulestartminute) ; echo " Date: "; monthdropdown("rulestartmonth",0,0,0,1,$rulestartmonth); echo "/"; daydropdown("rulestartday",0,0,0,1,$rulestartday); echo "/"; yeardropdown("rulestartyear",0,0,0,1,$rulestartyear); echo " | Rule End: Time: "; hourdropdown("rulestophour",0,0,0,1,$rulestophour) ; echo ":" ; minutedropdown("rulestopminute",0,0,0,1,$rulestopminute) ; echo " Date: "; monthdropdown("rulestopmonth",0,0,0,1,$rulestopmonth); echo "/"; daydropdown("rulestopday",0,0,0,1,$rulestopday); echo "/"; yeardropdown("rulestopyear",0,0,0,1,$rulestopyear); echo " | |||||
"; dayofweekboxes("ruledaysofweek",0,0,0,$ruledaysofweek) . "\n"; closeform(); echo " |
DENIAL ID: $denyid | "; openform("rule.php","post",2,0,0); formsubmit("Save",3,1,0); formsubmit("Delete",3,1,0); formreset("Reset",3,1,0); echo " | \n"; formfield("denyid","Hidden",3,1,0,10,10,$denyid); formfield("hostid","Hidden",3,1,0,10,10,$hostid); formfield("ruletype","Hidden",3,1,0,10,10,2); formfield("ruleid","Hidden",3,1,0,10,10,$id); formfield("subaction","Hidden",3,1,0,10,10,"ruledeny"); echo "
"; echo "Expression: "; formfield("denyexp","text",3,1,1,60,80,$denyexp); echo " | |
Facility Range: "; facilitydropdown("denystartfacility",1,0,0,1,$denystartfacility); echo " to "; facilitydropdown("denystopfacility",1,1,1,1,$denystopfacility); echo " | Severity Range: "; severitydropdown("denystartseverity",1,0,0,1,$denystartseverity); echo " to "; severitydropdown("denystopseverity",1,1,1,1,$denystopseverity); echo " |