Esempio n. 1
0
<body>

<?php 
if (POST('insert') && empty($data['data']['id'])) {
    if ($data['status'] == 'error') {
        $txt_error = "<div>" . _("The following errors occurred") . ":</div>\n\t\t\t\t\t  <div style='padding: 2px 10px 5px 10px;'>" . implode("<br/>", $validation_errors) . "</div>";
        $config_nt = array('content' => $txt_error, 'options' => array('type' => 'nf_error', 'cancel_button' => false), 'style' => 'width: 80%; margin: 20px auto; text-align: left;');
        $nt = new Notification('nt_1', $config_nt);
        $nt->show();
        Util::make_form("POST", "newportgroupform.php?id={$id}");
        die;
    }
    $db = new ossim_db();
    $conn = $db->connect();
    $actives_ports = Port_group::expand_ports($actives_ports);
    Port_group::update($conn, $id, $pgname, $actives_ports, $descr, $ctx);
    Util::memcacheFlush();
    $db->close();
    ?>
	<script type='text/javascript'>
        if (!parent.is_lightbox_loaded(window.name))
        {
            document.location.href="portgroup.php?msg=updated";
        }
        else
        {
            document.location.href="newportgroupform.php?id=<?php 
    echo $id;
    ?>
&update=1";
        }      
Esempio n. 2
0
require_once 'classes/Net.inc';
$net_list = Net::get_list($conn);
$nets[] = array("value" => ANY, "name" => "ANY");
foreach ($net_list as $n) {
    $nets[] = array("value" => $n->get_name(), "name" => $n->get_name());
}
/* sensors */
require_once 'classes/Sensor.inc';
$sensor_list = Sensor::get_list($conn);
$sensors[] = array("value" => ANY, "name" => "ANY");
foreach ($sensor_list as $s) {
    $sensors[] = array("value" => $s->get_ip(), "name" => $s->get_name() . " (" . $s->get_ip() . ")");
}
/* ports */
require_once 'classes/Port_group.inc';
$port_list = Port_group::get_list($conn);
$ports[] = array("value" => ANY, "name" => "ANY");
foreach ($port_list as $p) {
    $ports[] = array("value" => $p->get_name(), "name" => $p->get_name() . " (" . $p->get_descr() . ")");
}
/* plugins */
require_once 'classes/Plugin.inc';
$plugin_list = Plugin::get_list($conn);
$plugins[] = array("value" => ANY, "name" => "ANY");
foreach ($plugin_list as $p) {
    $plugins[] = array("value" => $p->get_id(), "name" => $p->get_name() . " (" . $p->get_id() . ")");
}
/* actions */
require_once 'classes/Action.inc';
$action_list = Action::get_list($conn);
if (is_array($action_list)) {
		<?php 
    echo gettext("Yes");
    ?>
 </a>&nbsp;&nbsp;&nbsp;<a href="port.php">
		<?php 
    echo gettext("No");
    ?>
 </a>
    </p>
<?php 
    exit;
}
$db = new ossim_db();
$conn = $db->connect();
if (Port_group::can_delete($conn, $id)) {
    Port_group::delete($conn, $id);
} else {
    echo "ERROR_CANNOT";
}
$db->close();
?>

    <p> <?php 
echo gettext("Port group deleted");
?>
 </p>
    <p><a href="portgroup.php"><?php 
echo gettext("Back");
?>
 </a></p>
    <?php 
Esempio n. 4
0
         foreach ($port_list as $port_group) {
             if (!check_any($port_group->get_port_id())) {
                 $ports .= ($ports == "" ? "" : "<br/>") . Port_group::get_name_by_id($conn, $port_group->get_port_id());
             }
         }
     }
     if (empty($ports)) {
         $ports = "<font color='#AAAAAA'><b>" . _('ANY') . "</b></font>";
     }
     $xml .= "<cell><![CDATA[" . $ports . "]]></cell>";
     //Ports destiny
     $ports = "";
     if ($port_list = $policy->get_ports($conn, 'dest')) {
         foreach ($port_list as $port_group) {
             if (!check_any($port_group->get_port_id())) {
                 $ports .= ($ports == "" ? "" : "<br/>") . Port_group::get_name_by_id($conn, $port_group->get_port_id());
             }
         }
     }
     if (empty($ports)) {
         $ports = "<font color='#AAAAAA'><b>" . _('ANY') . "</b></font>";
     }
     $xml .= "<cell><![CDATA[" . $ports . "]]></cell>";
 }
 //Event Types
 $event_types = '';
 $flag_events = true;
 //DS Groups
 $plugingroups = "";
 foreach ($policy->get_plugingroups($conn, $policy->get_id()) as $group) {
     $plugingroups .= ($plugingroups == "" ? "" : "<br/>") . "<a href='javascript:;' onclick='GB_show(\"" . _("Plugin groups") . "\",\"plugingroups.php?id=" . $group['id'] . "&collection=1#" . $group['id'] . "\",500,\"90%\");return false;'>" . $group['name'] . "</a>";
Esempio n. 5
0
 if ($dest_net_list = $policy->get_net_groups($conn, 'dest')) {
     foreach ($dest_net_list as $dest_net_group) {
         $dests['netgroup_' . $dest_net_group->get_net_group_id()] = check_any($dest_net_group->get_net_group_id()) ? _("ANY") : _("NETWORK_GROUP") . ": " . Net_group::get_name_by_id($conn, $dest_net_group->get_net_group_id());
     }
 }
 //PORTS
 //source
 if ($port_list = $policy->get_ports($conn, 'source')) {
     foreach ($port_list as $port_group) {
         $ports_source[$port_group->get_port_id()] = check_any($port_group->get_port_id()) ? _("ANY") : Port_group::get_name_by_id($conn, $port_group->get_port_id());
     }
 }
 //destiny
 if ($port_list = $policy->get_ports($conn, 'dest')) {
     foreach ($port_list as $port_group) {
         $ports_destiny[$port_group->get_port_id()] = check_any($port_group->get_port_id()) ? _("ANY") : Port_group::get_name_by_id($conn, $port_group->get_port_id());
     }
 }
 $flag_events = true;
 //PLUGIN GROUPS
 foreach ($policy->get_plugingroups($conn, $policy->get_id()) as $pgroup) {
     $plugingroups[] = $pgroup['id'];
 }
 if (!$is_engine) {
     //TAXONOMY
     if ($taxonomy_list = $policy->get_taxonomy_conditions($conn)) {
         foreach ($taxonomy_list as $tax) {
             $tax_id = $tax->get_product_type_id() . "@" . $tax->get_category_id() . "@" . $tax->get_subcategory_id();
             $tax_val = $filter['ptype'][$tax->get_product_type_id()] . " | " . $filter['cat'][$tax->get_category_id()] . " | " . $filter['subcat'][$tax->get_subcategory_id()];
             $tax_filters[$tax_id] = $tax_val;
             $flag_events = false;
Esempio n. 6
0
}
ossim_valid($order, OSS_ALPHA, OSS_SPACE, OSS_SCORE, OSS_NULLABLE, 'illegal:' . _("order"));
ossim_valid($page, OSS_DIGIT, OSS_NULLABLE, 'illegal:' . _("page"));
ossim_valid($rp, OSS_DIGIT, OSS_NULLABLE, 'illegal:' . _("rp"));
if (ossim_error()) {
    die(ossim_error());
}
if (empty($order)) {
    $order = "name";
}
$start = ($page - 1) * $rp;
$limit = "LIMIT {$start}, {$rp}";
$db = new ossim_db();
$conn = $db->connect();
$xml = "";
$port_list = Port_group::get_list($conn, "ORDER BY {$order} {$limit}");
if ($port_list[0]) {
    $total = $port_list[0]->get_foundrows();
    if ($total == 0) {
        $total = count($port_list);
    }
} else {
    $total = 0;
}
$xml .= "<rows>\n";
$xml .= "<page>{$page}</page>\n";
$xml .= "<total>{$total}</total>\n";
foreach ($port_list as $port_group) {
    $name = $port_group->get_name();
    $xml .= "<row id='" . htmlspecialchars(utf8_encode($name)) . "'>";
    $link_modify = "<a style='font-weight:bold;' href=\"./newportform.php?portname=" . urlencode($name) . "\">" . Util::htmlentities($name) . "</a>";
Esempio n. 7
0
<body>

<?php 
if ($data['status'] == 'error') {
    $txt_error = "<div>" . _("The following errors occurred") . ":</div>\n\t\t\t\t\t  <div style='padding: 2px 10px 5px 10px;'>" . implode("<br/>", $validation_errors) . "</div>";
    $config_nt = array('content' => $txt_error, 'options' => array('type' => 'nf_error', 'cancel_button' => false), 'style' => 'width: 80%; margin: 20px auto; text-align: left;');
    $nt = new Notification('nt_1', $config_nt);
    $nt->show();
    Util::make_form("POST", "newportgroupform.php");
    exit;
}
$db = new ossim_db();
$conn = $db->connect();
if (POST('insert')) {
    $actives_ports = Port_group::expand_ports($actives_ports);
    $new_id = Port_group::insert($conn, $pgname, $actives_ports, $descr, $ctx);
    Util::memcacheFlush();
}
$db->close();
?>
    <script type='text/javascript'>
        if (!parent.is_lightbox_loaded(window.name))
        {
            document.location.href="portgroup.php?msg=updated";
        }
        else
        {
            document.location.href="newportgroupform.php?id=<?php 
echo $new_id;
?>
&update=1";
Esempio n. 8
0
$ports_input = implode(",", $arr_ports_input);
if (isset($_SESSION['_portgroup'])) {
    $pgname = $_SESSION['_portgroup']['pgname'];
    $actives_ports = $_SESSION['_portgroup']['actives_ports'];
    $descr = $_SESSION['_portgroup']['descr'];
    unset($_SESSION['_portgroup']);
} else {
    $pgname = GET('portname');
    $descr = "";
    $actives_ports = array();
    if ($pgname != '') {
        ossim_valid($pgname, OSS_ALPHA, OSS_SCORE, OSS_SPACE, OSS_PUNC, 'illegal:' . _("Port Group Name"));
        if (ossim_error()) {
            die(ossim_error());
        }
        if ($port_group_list = Port_group::get_list($conn, "WHERE name = '{$pgname}'")) {
            $port_group = $port_group_list[0];
        }
        //if ($port_list = Port::get_list($conn))
        if ($port_list) {
            $actives_ports = Port_group_reference::in_port_group_reference_for_name($conn, $port_group->get_name());
            /*
            foreach($port_list as $port)
            {
            	//$is_active = Port_group_reference::in_port_group_reference($conn, $port_group->get_name() , $port->get_port_number() , $port->get_protocol_name());
            	 
            	if ( $is_active ) 
            		$actives_ports[] = $port->get_port_number()." - ". $port->get_protocol_name();
            }
            */
        }
Esempio n. 9
0
ossim_valid($key, OSS_NULLABLE, OSS_TEXT, OSS_PUNC, 'illegal:' . _("Key"));
if (ossim_error()) {
    die(_("Invalid Parameter key"));
}
$cachefile = "/var/ossim/sessions/" . $_SESSION["_user"] . "_ports_" . base64_encode($key) . ".json";
if (file_exists($cachefile)) {
    readfile($cachefile);
    exit;
}
require_once 'classes/Port_group.inc';
require_once 'ossim_db.inc';
$db = new ossim_db();
$conn = $db->connect();
$port_groups = array();
$buffer = "";
if ($port_group_list = Port_group::get_list($conn, "ORDER BY name")) {
    foreach ($port_group_list as $port_group) {
        $pg_name = $port_group->get_name();
        $pg_ports = $port_group->get_reference_ports($conn, $pg_name);
        $pg_descr = $port_group->get_descr();
        if (!preg_match("/ANY/i", $pg_name)) {
            $port_groups[] = array($pg_name, $pg_ports, $pg_descr);
        } else {
            $port_groups[] = array($pg_name, array(), "");
        }
    }
}
if ($key == "") {
    $buffer .= "[ {title: '" . _("Port Groups") . "', key:'key1', isFolder:true, icon:'../../pixmaps/theme/ports.png', expand:true\n";
    if (count($port_groups) > 0) {
        $j = 1;
Esempio n. 10
0
if (POST('withoutmenu') != "1") {
    include "../hmenu.php";
    $get_param = "portname={$pgname}";
} else {
    $get_param = "portname={$pgname}&withoutmenu=1";
}
if (POST('insert') && !empty($pgname)) {
    if ($error == true) {
        $txt_error = "<div>" . _("We Found the following errors") . ":</div><div style='padding:10px;'>" . implode("<br/>", $message_error) . "</div>";
        Util::print_error($txt_error);
        Util::make_form("POST", "newportform.php?" . $get_param);
        die;
    }
    $db = new ossim_db();
    $conn = $db->connect();
    Port_group::update($conn, $pgname, $actives_ports, $descr);
    Util::clean_json_cache_files("ports");
    $db->close($conn);
}
if (isset($_SESSION['_portgroup'])) {
    unset($_SESSION['_portgroup']);
}
if ($_SESSION["menu_sopc"] == "Ports" && POST('withoutmenu') != "1") {
    ?>
        <p> <?php 
    echo gettext("Port group succesfully updated");
    ?>
 </p>
        <script type='text/javascript'>document.location.href="port.php"</script>
	<?php 
} else {
                        
                        <tr>
                            <td class="noborder" style="padding-top:10px">
                            <?php 
echo _("Selected ports for the group");
?>
:
                            </td>
                        </tr>
                        
                        <tr>
                        	<td class="noborder">
                        		<select id="selected_ports" name="act_ports[]" class='vfield' multiple="multiple">
                        		<?php 
if (is_array($actives_ports)) {
    $actives_ports = Port_group::group_ports($actives_ports);
    foreach ($actives_ports as $v) {
        echo "<option value='{$v}' selected='selected'>{$v}</option>";
    }
}
?>
                        		</select>
                        	</td>
                        </tr>
                        <tr>
                        	<td class="noborder">
                        		<div id='c_action_ports'>
                        			<input type="button" value=" [X] " onclick="deletefrom('selected_ports');" class="small av_b_secondary"/> 
                        			<input type="button" value="<?php 
echo _('Delete all');
?>
Esempio n. 12
0
} else {
    $total = 0;
}
$xml .= "<rows>\n";
$xml .= "<page>{$page}</page>\n";
$xml .= "<total>{$total}</total>\n";
foreach ($port_list as $port_group) {
    $name = $port_group->get_name();
    $id = $port_group->get_id();
    $xml .= "<row id='" . $id . "'>";
    $link_modify = "<a style='font-weight:bold;' href=\"./newportgroupform.php?id=" . $id . "\">" . Util::htmlentities($name) . "</a>";
    $xml .= "<cell><![CDATA[" . $link_modify . "]]></cell>";
    $ports = array();
    foreach ($port_group->get_reference_ports($conn, $id) as $port) {
        $ports[] = $port->get_port_number() . "-" . $port->get_protocol_name();
    }
    $ports = Port_group::group_ports($ports);
    $xml .= "<cell><![CDATA[" . implode(', ', $ports) . "]]></cell>";
    if (Session::show_entities()) {
        $xml .= "<cell><![CDATA[" . Session::get_entity_name($conn, $port_group->get_ctx()) . "]]></cell>";
    }
    $desc = $port_group->get_descr();
    if ($desc == "") {
        $desc = "&nbsp;";
    }
    $xml .= "<cell><![CDATA[" . utf8_encode($desc) . "]]></cell>";
    $xml .= "</row>\n";
}
$xml .= "</rows>\n";
echo $xml;
$db->close();
Esempio n. 13
0
<?php 
if (POST('withoutmenu') != "1") {
    include "../hmenu.php";
    $get_param = "withoutmenu=0";
} else {
    $get_param = "portname={$pgname}&withoutmenu=1";
}
if ($error == true) {
    $txt_error = "<div>" . _("We Found the following errors") . ":</div><div style='padding:10px;'>" . implode("<br/>", $message_error) . "</div>";
    Util::print_error($txt_error);
    Util::make_form("POST", "newportform.php?" . $get_param);
    die;
}
if (POST('insert')) {
    Port_group::insert($conn, $pgname, $actives_ports, $descr);
    Util::clean_json_cache_files("ports");
}
if (isset($_SESSION['_portgroup'])) {
    unset($_SESSION['_portgroup']);
}
$db->close($conn);
if ($_SESSION["menu_sopc"] == "Ports" && POST('withoutmenu') != "1") {
    ?>
	<p> <?php 
    echo gettext("Port Group succesfully inserted");
    ?>
 </p>
	<script type='text/javascript'>document.location.href="port.php"</script>
	<?php 
} else {