Location: PHPKode > projects > IPTables log analyzer > iptablelog/admin/modules/zCustomize.php
<? #require_once("$file_base/utils/Db.php"); ?>
<center>
<table cellspacing="1" cellpadding="2" width="500" bgcolor="#FFFFFF">
<tr>
<td rowspan=5 bgcolor="#DDDDDD" width=200>
<center><b>Customize Protocols</b><br>
<div class="DatabaseStats">
<?
if (isset($_REQUEST["cust_proto"])) {
        $query = "SELECT num, name, description FROM protos WHERE num =" . $_REQUEST['proto_num'];
        $result = db_query ($query) or db_handleError("Unable to query log table");
        if($line = db_nextobject($result)) {
                if ($line->custom == 'Y') {
                        echo $line->num . ": changing custom entry from<br>" . $line->name . " to " . $_REQUEST['proto_name'] . ".";
                } else {
                        echo $line->num . ": changing entry from<br>" . $line->name . " to " . $_REQUEST['proto_name'] . ".";
                }
                $query = "UPDATE protos SET name = '" . $_REQUEST['proto_name'] . "', description = '" . 
			$_REQUEST['proto_desc'] . "' WHERE ip=" . $line->ip;
        } else {
                $query = "INSERT INTO protos (num,name,description,custom) VALUES (" . $_REQUEST['proto_num'] . ",'" .  
			$_REQUEST['proto_name'] . "','" .  $_REQUEST['proto_desc'] . "','Y')";
                echo $_REQUEST['proto_num'] . ": adding entry for<br>" . $_REQUEST['proto_name'] . ".";
        }
        #echo "<br>" . $query;
        $result = db_query ($query) or db_handleError("Unable to query log table");
}
?>
</div>
</center></td>
<form action="index.php" method="post">
<input type="hidden" name="cust_proto" value="1">
<td align=right>Protocol Number: </td>
<td> <input type="text" size=5 name="proto_num"> </td>
</tr>
<tr><td align=right>Protocol Name: </td>
<td> <input type="text" size=15 name="proto_name"> </td>
<tr>
<td align=right>Description: </td><td>&nbsp;</td></tr>
<tr><td colspan=2 align=center><textarea name="proto_desc" rows=4 cols=30></textarea></td></tr>
<tr><td colspan=2 align=center><input type="submit" value="Add/Change Protocol"> &nbsp; 
<input type="button" onClick="window.open('show_protos.php','admin_show','status=0,toolbar=0,menubar=0,width=700,height=500,scrollbars=1');" value="Show Protocols"></td></tr>
 </form>
<tr>
<td rowspan=5 bgcolor="#DDDDDD" width=200>
<center><b>Customize Ports</b><br>
<div class="DatabaseStats">
<?
if (isset($_REQUEST["cust_port"])) {
        $query = "SELECT port, name, proto, description FROM ports WHERE port =" . $_REQUEST['port_num'] . 
			" AND name='" . $_REQUEST['port_name'] . "' AND proto='" . $_REQUEST['port_proto'] . "'";
        $result = db_query ($query) or db_handleError("Unable to query log table");
        if($line = db_nextobject($result)) {
                if ($line->custom == 'Y') {
                        echo $line->port . ": changing custom entry from<br>" . $line->name . " to " . $_REQUEST['port_name'] . ".";
                } else {
                        echo $line->port . ": changing entry from<br>" . $line->name . " to " . $_REQUEST['port_name'] . ".";
                }
                $query = "UPDATE ports SET name = '" . $_REQUEST['port_name'] . "', description = '" . 
                        $_REQUEST['port_desc'] . "', proto='" . $_REQUEST['port_proto'] . "' WHERE port=" . $line->port .
			" AND name='" . $line->name . "'";
        } else {
                $query = "INSERT INTO ports (port,proto,name,description,custom) VALUES (" . $_REQUEST['port_num'] . ",'" .
			$_REQUEST['port_proto'] ."','" . $_REQUEST['port_name'] . "','" .
                        $_REQUEST['port_desc'] . "','Y')";
                echo $_REQUEST['port_num'] . ": adding entry for<br>" . $_REQUEST['port_name'] . ".";
        }
        #echo "<br>" . $query;
        $result = db_query ($query) or db_handleError("Unable to query log table");
}
?>
</div>
</center></td>
<form action="index.php" method="post">
<input type="hidden" name="cust_port" value="1">
<td align=right>Port Number: </td>
<td> <input type="text" size=5 name="port_num">  &nbsp; 
<select name="port_proto">
<option>tcp</option>
<option>udp</option>
</select>
</td>
</tr>
<tr><td align=right>Port Name: </td>
<td> <input type="text" size=15 name="port_name"> </td>
<tr>
<td align=right>Description: </td><td>&nbsp;</td></tr>
<tr><td colspan=2 align=center><textarea name="port_desc" rows=4 cols=30></textarea></td></tr>
<tr><td colspan=2 align=center><input type="submit" value="Add/Change Port"> &nbsp; 
<input type="button" onClick="window.open('show_ports.php','admin_show','status=0,toolbar=0,menubar=0,width=700,height=500,scrollbars=1');" value="Show Ports"></td></tr>
 </form>
<tr>

</table>
</center>
Return current item: IPTables log analyzer