KEY `id-tid` (`net_id`,`object_tid`),
  KEY `object_tid-attr_id` (`net_id`,`attr_id`),
  KEY `AttributeValue_IPv6-FK-map` (`object_tid`,`attr_id`),
  CONSTRAINT `AttributeValue_IPv6-FK-map` FOREIGN KEY (`object_tid`, `attr_id`) REFERENCES `AttributeMap` (`objtype_id`, `attr_id`),
  CONSTRAINT `AttributeValue_IPv6-FK-object` FOREIGN KEY (`net_id`) REFERENCES `IPv6Network` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO Dictionary (dict_key, chapter_id, dict_sticky, dict_value) VALUES
 (49000, 1, 'no', 'IPv4 network (dummy)'),
 (49001, 1, 'no', 'IPv6 network (dummy)');
*/
$page['flatip']['title'] = 'IP networks';
$page['flatip']['parent'] = 'index';
$tabhandler['flatip']['default'] = 'renderFlatIP';
registerHook('modifyEntitySummary', 'addAttributesToNetworkSummary', 'chain');
foreach (array('ipv4net', 'ipv6net') as $net_realm) {
    registerTabHandler($net_realm, 'properties', 'renderNetworkEditAttrs');
    registerOpHandler($net_realm, 'properties', 'updateAttrs', 'handleNetworkAttrsChange');
    registerOpHandler($net_realm, 'properties', 'clearSticker', 'handleNetworkStickerClear');
}
// Pseudo-object type ids.
// Network attributes are assigned to these object types.
$netobject_type_id = array('ipv4net' => 49000, 'ipv6net' => 49001);
// Special page 'flatip' handler that lists networks like the 'depot' page lists object.
// Lists both IP families on the same page.
// No network hierarchy is displayed, that's why 'flat'.
function renderFlatIP()
{
    if (isset($_REQUEST['attr_id']) && isset($_REQUEST['attr_value'])) {
        $params = array('attr_id' => $_REQUEST['attr_id'], 'attr_value' => $_REQUEST['attr_value']);
        $av = $_REQUEST['attr_value'];
        if ($av === 'NULL') {
<?php

/*
   This plug-in adds tab 'Spare search' to the IPv4 space page.
   It is used to search for a spare IP range of the given size
   in the given subset of parent networks (using tag-based filter).
*/
$tab['ipv4space']['newiprange'] = 'Spare search';
registerTabHandler('ipv4space', 'newiprange', 'renderSearchNewIP4Range');
/*
SPARE_SEARCH_PREDICATE is a predicate name describing aggregates to search in.
It is useful to define a predicate like '[RIPE allocation]' to search only there.
Define this constant in your secret.php like this:

define ('SPARE_SEARCH_PREDICATE', 'RIPE allocation');
*/
function renderSearchNewIP4Range()
{
    global $pTable;
    // prepare $cellfilter
    $cellfilter = getCellFilter();
    if ($cellfilter['is_empty'] || !isset($_REQUEST['cfp'])) {
        if (defined('SPARE_SEARCH_PREDICATE') && isset($pTable[SPARE_SEARCH_PREDICATE])) {
            $_REQUEST['cfp'] = array(SPARE_SEARCH_PREDICATE);
            $cellfilter = getCellFilter();
        }
    }
    $mask = NULL;
    if (!empty($_REQUEST['pref_len'])) {
        $mask = intval($_REQUEST['pref_len']);
    }
//
// 2012-11-16  Blazej Gomoluch:
//		* changes to work in 0.20.1 (gateways.php: added function to breedfunc array)
//		* moved to registerTabHandler()
// 2012-02-27  Blazej Gomoluch:
//		* modified function ios12ReadInterfaces to skip text from banners etc and start to parse from line with show interfaces
// 2012-02-18  Blazej Gomoluch:
//		* added description column
// 2012-12-20  Blazej Gomoluch:
//		* switched from patching CSS to addCSS()
//		* switched to queryDevice() function
//		* indentation format
//
$tab['object']['liveinterfaces'] = 'Live interfaces';
$trigger['object']['liveinterfaces'] = 'trigger_liveports';
registerTabHandler('object', 'liveinterfaces', 'renderInterfacesStats');
//after this time (in minutes) we consider that the port is not used
global $port_use_age;
$port_use_age = 151200;
// 7 weeks
function time_convert($cisco_time)
{
    $time = -1;
    if (preg_match('/^uptime is ((\\d+) years?, )?((\\d+) weeks?, )?((\\d+) days?, )?((\\d+) hours?, )?(\\d+) minutes?/', $cisco_time, $matches)) {
        //convert to minutes
        $time = $matches[2] * 525600 + $matches[4] * 10080 + $matches[6] * 1440 + $matches[8] * 60 + $matches[9];
    } elseif (preg_match('/(\\d+)w(\\d+)d/', $cisco_time, $matches)) {
        //convert to minutes
        $time = $matches[1] * 10080 + $matches[2] * 1440;
    } elseif (preg_match('/(\\d+):(\\d+):(d\\+)/', $cisco_time, $matches)) {
        //convert to minutes