Location: PHPKode > projects > SnortCenter 2.x > snortcenter-release/list_template.inc.php
<?php
    /*
    ** SnortCenter Copyright (C) 2001,2002,2003 Stefan Dens
    **
    ** Author: Stefan Dens <hide@address.com>
    **
    ** This program is free software; you can redistribute it and/or modify
    ** it under the terms of the GNU General Public License as published by
    ** the Free Software Foundation; either version 2 of the License, or
    ** (at your option) any later version.
    **
    ** This program is distributed in the hope that it will be useful,
        ** but WITHOUT ANY WARRANTY; without even the implied warranty of
    ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    ** GNU General Public License for more details.
    **
    ** You should have received a copy of the GNU General Public License
    ** along with this program; if not, write to the Free Software
    ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    */
?>

<?php
    function deactivate($element, $element_type, $template_id, $db) {
      if ($element) {
	$result_id = $db->acidExecute("SELECT $element_type from rules_template where id='$template_id'");
        $myrow_id = $result_id->acidFetchRow();
        $result_id->acidFreeRows();
        $myrow_act = $myrow_id[0];
        foreach($element as $key) {
	    list($part_1, $part_2) = explode("|$key|;", $myrow_act, 2);
            $myrow_act = $part_1 . $part_2;
        }
        $result = $db->acidExecute("UPDATE rules_template SET $element_type='$myrow_act' where id = '$template_id'");
      }
    }
     
    function activate($element, $element_type, $template_id, $db) {
      if ($element) {	
	$result_id = $db->acidExecute("SELECT $element_type from rules_template where id = '$template_id'");
        $myrow_id = $result_id->acidFetchRow();
        $result_id->acidFreeRows();
        $myrow_act = $myrow_id[0];
        foreach($element as $key) {
	    if (!strstr($myrow_act, "|$key|;")) {
                $myrow_act  .= "|$key|;";
            }
        }
        $result = $db->acidExecute("UPDATE rules_template SET $element_type='$myrow_act' where id = '$template_id'");
      }
    }
     
    function get_active_template($element_type, $template_id, $db) {
        $result_id = $db->acidExecute("SELECT $element_type from rules_template where id = '$template_id'");
        $myrow_id = $result_id->acidFetchRow();
        $rule_act = explode(";", $myrow_id[0]);
        $result_id->acidFreeRows();
        return $rule_act;
    }
     
     
    function display_goto($sensor_id, $template_id) {
        global $lang;
    ?>
    <style>
    TD {
    	FONT-FAMILY: Verdana,Helvetica; FONT-SIZE: 10px
    }
    </style>
    <TABLE align=center border=0 cellspacing="0" cellpadding="0"><TR height="35">
    <td background="./images/form/left.gif" width="12">&nbsp;</td>
    <?php
        #    echo "<TD bgcolor='#3b577a'><FORM name=goto_rule method=GET><FONT color='#ffffff'><B>&nbsp;$lang[64]&nbsp;</B></FONT>";
        echo "<TD bgcolor='#3b577a'><FORM action='' name=goto_rule method=GET><FONT color='#ffffff'><B>&nbsp;$lang[64]&nbsp;</B></FONT>";
        echo "<SELECT NAME=find_what><OPTION value='sid'>sid</OPTION>";
        echo "<OPTION value='msg'>msg</OPTION></SELECT>";
         
        echo "<INPUT TYPE=HIDDEN NAME='sensor_id' VALUE='$sensor_id'>";
        echo "&nbsp;<INPUT type=text name=goto size=20>&nbsp;";
        echo "&nbsp;<INPUT type=hidden name=template_id value=\"$template_id\">&nbsp;";
        echo "</TD></FORM>";
    ?>
    <td background="./images/form/right.gif">&nbsp;</td></tr><tr>
    <td width="12" height="12"><img src="./images/form/down-left.gif" alt="" border="0"></td>
    <td background="./images/form/down.gif" align="center" height="12">&nbsp;</td>
    <td><img src="./images/form/down-right.gif" width="12" height="12" alt="" border="0"></td></tr>
    </td></tr></table><BR>
    <?php
    }
     
    function display_hide_active($template_id, $category) {
        global $lang, $hide_active, $hide_deactive, $hide_policy,$sensor_id;
         
        if ($hide_deactive == 'yes' && $hide_active == 'yes') {
            $hide_deactive = '';
            $hide_active = '';
        }
    ?>
    <style>
    TD {
    	FONT-FAMILY: Verdana,Helvetica; FONT-SIZE: 10px
    }
    </style>
    <TABLE align=center border=0 cellspacing="0" cellpadding="0"><TR height="35">
    <td background="./images/form/left.gif" width="12">&nbsp;</td>
    <?php
        echo "<FORM name=active_rule method=GET><INPUT TYPE=HIDDEN NAME='sensor_id' VALUE='$sensor_id'><INPUT TYPE=HIDDEN NAME='template_id' VALUE='$template_id'>";
        echo "<INPUT TYPE=HIDDEN NAME='category' VALUE='$category'>";
        echo "<TD bgcolor='#3b577a'><FONT color='#ffffff'><B>&nbsp;$lang[287]&nbsp;</B></FONT>";
        echo "<BR></TD>";
        echo "<TD bgcolor='#3b577a'><INPUT style=\"color: #FFFFFF; background-color: #3b577a;\" onclick='this.form.submit();' type=CHECKBOX name=hide_policy value=yes ";
        if ($hide_policy == 'yes') echo 'CHECKED ';
        echo ">&nbsp;";
        echo "<BR>";
        echo "</TD>";

        echo "<TD bgcolor='#3b577a'><FONT color='#ffffff'><B>&nbsp;$lang[241]&nbsp;</B></FONT>";
        echo "<BR><FONT color='#ffffff'><B>&nbsp;$lang[242]&nbsp;</B></FONT></TD>";
         
        echo "<TD bgcolor='#3b577a'><INPUT style=\"color: #FFFFFF; background-color: #3b577a;\" onclick='this.form.submit();' type=CHECKBOX name=hide_active value=yes ";
        if ($hide_active == 'yes') echo 'CHECKED ';
        echo ">&nbsp;";
        echo "<BR><INPUT style=\"color: #FFFFFF; background-color: #3b577a;\" onclick='this.form.submit();' type=CHECKBOX name=hide_deactive value=yes ";
        if ($hide_deactive == 'yes') echo 'CHECKED ';
        echo ">&nbsp;";
        echo "</TD></FORM>";
    ?>
    <td background="./images/form/right.gif">&nbsp;</td></tr><tr>
    <td width="12" height="12"><img src="./images/form/down-left.gif" alt="" border="0"></td>
    <td colspan=4 background="./images/form/down.gif" align="center" height="12">&nbsp;</td>
    <td><img src="./images/form/down-right.gif" width="12" height="12" alt="" border="0"></td></tr>
    </td></tr></table><BR>
    <?php
    }     
    function display_list_start($template_id) {
    global $sensor_id;
    ?>
    <style>
    TD {
    	FONT-FAMILY: Verdana,Helvetica; FONT-SIZE: 10px
    }
    </style>
    <table width=100% align="center" border="0" cellspacing="0" cellpadding="0"><tr>
    <td width="12" height="12"><img src="./images/form/up-left.gif" alt="" border="0"></td>
    <td width=100% background="./images/form/up.gif" align="center"  height="12">&nbsp;</td>
    <td><img src="./images/form/up-right.gif" width="12" height="12" alt="" border="0"></td></tr>
    <tr>
    <td background="./images/form/left.gif" width="12">&nbsp;</td>
    <td bgcolor="#3b577a"><center>
    <?php
        echo "<table align=center border=0 cellpadding=0 cellspacing=0 width=100%>";
        echo "<FORM name=ruleform method=GET><BR><INPUT TYPE=hidden name=sensor_id value='$sensor_id'><INPUT TYPE=hidden name=template_id value='$template_id'>";
         
    }
     
    function display_list_end($select) {
        global $lang, $PHP_SELF;
        if ($select == '1') {
        ?>
    <tr><td colspan=4><FONT color="#ffffff">
    <img src="./images/arrow_ltr.png" border="0" width="38" height="22" />
    (<a style="color: #FFFFFF" href="" onClick="SelectAll(); return false;"><?php echo $lang[65]; ?></a>
    -
    <a  style="color: #FFFFFF" href="" onClick="UnselectAll(); return false;"><?php echo $lang[66]; ?></a>
    -
    <a style="color: #FFFFFF" href="" onclick="Invers(); return false;"><?php echo $lang[67]; ?></a>)&nbsp;<?php echo $lang[68]; ?>
    &nbsp;&nbsp;&nbsp;
    </FONT>
    <select name="do" dir="ltr" onchange="this.form.submit();">
    <option value="" selected="selected"><?php echo $lang[69]; ?></option>
    <OPTION value=Activate><?php echo $lang[70]; ?></OPTION>
    <OPTION value=Deactivate><?php echo $lang[71]; ?></OPTION>
    <OPTION value=Deactivate_template_sid><?php echo $lang[282]; ?></OPTION>
    <OPTION value=Activate_category><?php echo $lang[283]; ?></OPTION>
    <OPTION value=Deactivate_category><?php echo $lang[284]; ?></OPTION>
    <OPTION value=Deactivate_follow_category><?php echo $lang[285]; ?></OPTION>

    </select>&nbsp;
    <script type="text/javascript" language="javascript">
    </script>
    <noscript>
    <INPUT TYPE=SUBMIT VALUE='Update'></FORM>;
    </noscript>
    </TD></TR>
<?php } 
elseif($select == '2')
{
?>
    <tr><td colspan=4><FONT color="#ffffff">
    <img src="./images/arrow_ltr.png" border="0" width="38" height="22" />
    (<a style="color: #FFFFFF" href="" onClick="SelectAll(); return false;"><?php echo $lang[65]; ?></a>
    -
    <a  style="color: #FFFFFF" href="" onClick="UnselectAll(); return false;"><?php echo $lang[66]; ?></a>
    -
    <a style="color: #FFFFFF" href="" onclick="Invers(); return false;"><?php echo $lang[67]; ?></a>)&nbsp;<?php echo $lang[68]; ?>
    &nbsp;&nbsp;&nbsp;
    </FONT>
    <select name="do" dir="ltr" onchange="this.form.submit();">
    <option value="" selected="selected"><?php echo $lang[69]; ?></option>
    <OPTION value=Delete><?php echo $lang[72]; ?></OPTION>
    </select>&nbsp;
    <script type="text/javascript" language="javascript">
    </script>
    <noscript>
    <INPUT TYPE=SUBMIT VALUE='Update'></FORM>;
    </noscript>
    </TD></TR>
<?php } ?>
</TABLE>
</center>
</td>
<td background="./images/form/right.gif">&nbsp;</td></tr><tr>
<td width="12" height="12"><img src="./images/form/down-left.gif" alt="" border="0"></td>
<td background="./images/form/down.gif" align="center" height="12">&nbsp;</td>
<td><img src="./images/form/down-right.gif" width="12" height="12" alt="" border="0"></td></tr>
</td></tr></table><BR>
        <?php
        }

function display_template_description($template_id, $sensor_id, $db) {
        global $lang, $category;
	$result_id = $db->acidExecute("SELECT template_name, template_description from rules_template where id='$template_id'");
        $myrow_id = $result_id->acidFetchRow();
    ?>
    <style>
    TD {
    	FONT-FAMILY: Verdana,Helvetica; FONT-SIZE: 10px
    }
    </style>
    <SCRIPT type="text/javascript" language="javascript">
function confirmLink(theLink, theSqlQuery)
{
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
    return true;
    }
		
    var is_confirmed = confirm(confirmMsg + ' :\n' + theSqlQuery);
    if (is_confirmed) {
    theLink.href += '&js_confirmed=1';
    theLink.elements['js_confirmed'].value = 1;
    return true;
    }
			    
    return is_confirmed;
} // end of the 'confirmLink()' function
var confirmMsg  = 'Do you really want to ';
</SCRIPT>
    <TABLE align=center border=0 cellspacing="0" cellpadding="0"><TR height="35">
    <td background="./images/form/left.gif" width="12">&nbsp;</td>
    <?php
        echo "<FORM action='edit_template.php' name='' method=GET><INPUT TYPE=HIDDEN NAME='sensor_id' VALUE='$sensor_id'><INPUT TYPE=HIDDEN NAME='template_id' VALUE='$template_id'>";
        echo "<INPUT TYPE=HIDDEN NAME='category' VALUE='$category'>";
        echo "<TD bgcolor='#3b577a'><FONT color='#ffffff'><B>&nbsp;$lang[279]: </b>&nbsp;$myrow_id[template_name]&nbsp;<BR><b>&nbsp;$lang[281]: </b>&nbsp;$myrow_id[template_description]&nbsp;</FONT></TD>";
        echo "<TD bgcolor='#3b577a'>&nbsp;<INPUT style=\"color: #FFFFFF; background-color: #3b577a;\" onclick='this.form.submit();' type=button value='Edit'>&nbsp;&nbsp;";
        echo "</TD></FORM>";
    ?>
    <td background="./images/form/right.gif">&nbsp;</td></tr><tr>
    <td width="12" height="12"><img src="./images/form/down-left.gif" alt="" border="0"></td>
    <td colspan=2 background="./images/form/down.gif" align="center" height="12">&nbsp;</td>
    <td><img src="./images/form/down-right.gif" width="12" height="12" alt="" border="0"></td></tr>
    </td></tr></table><BR>
    <?php
    }         
    ?>
Return current item: SnortCenter 2.x