Exemplo n.º 1
0
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database, false);
$Sections = new Sections($Database);
$Subnets = new Subnets($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# create csrf token
$csrf = $User->csrf_cookie("create", "linkedsubnet");
# ID must be numeric
if (!is_numeric($_POST['subnetId'])) {
    $Result->show("danger", _("Invalid ID"), true, true);
}
# get all IPv6 subnets
$ipv6_subnets = $Subnets->fetch_all_subnets_search("IPv6");
# get subnet details
$subnet = $Subnets->fetch_subnet(null, $_POST['subnetId']);
?>



<!-- header -->
<div class="pHeader"><?php 
print _('Link IPv4 subnet to IPv6 subnet');
?>
</div>

<!-- content -->
<div class="pContent">
	<span class='muted'><?php 
Exemplo n.º 2
0
 /**
  * Search inside subnets if host address is provided! ipv6
  *
  * @access private
  * @param mixed $search_term
  * @param number $high
  * @param number $low
  * @return array
  */
 private function search_subnets_inside_v6($high, $low, $search_req)
 {
     // same
     if ($low == $high) {
         # Initialize PEAR NET object
         $this->initialize_pear_net_IPv6();
         // validate
         if ($this->Net_IPv6->checkIPv6($search_req)) {
             # ifmask remove it
             if (strpos($search_req, "/") > 0) {
                 $search_req = $this->Net_IPv6->removeNetmaskSpec($search_req);
             }
             # subnets class
             $Subnets = new Subnets($this->Database);
             # fetch all subnets
             $subnets = $Subnets->fetch_all_subnets_search("IPv6");
             # loop and search
             foreach ($subnets as $s) {
                 # cast
                 $s = (array) $s;
                 # parse address
                 $net = $this->Net_IPv6->parseAddress($this->transform_address($s['subnet'], "dotted") . '/' . $s['mask']);
                 if (gmp_cmp($low, $this->transform_address(@$net['start'], "decimal")) == 1 && gmp_cmp($low, $this->transform_address($net['end'], "decimal")) == -1) {
                     $ids[] = $s['id'];
                 }
             }
             # filter
             $ids = sizeof(@$ids) > 0 ? array_filter($ids) : array();
             # search
             if (sizeof($ids) > 0) {
                 foreach ($ids as $id) {
                     $result[] = $Subnets->fetch_subnet(null, $id);
                 }
             }
             # return
             return sizeof(@$result) > 0 ? array_filter($result) : array();
         } else {
             return array();
         }
     } else {
         return array();
     }
 }
Exemplo n.º 3
0
 /**
  * Search inside subnets if host address is provided!
  *
  * @access private
  * @param mixed $search_term
  * @param number $high
  * @param number $low
  * @return array
  */
 private function search_subnets_inside($high, $low)
 {
     if ($low == $high) {
         # subnets class
         $Subnets = new Subnets($this->Database);
         # fetch all subnets
         $subnets = $Subnets->fetch_all_subnets_search();
         # loop and search
         foreach ($subnets as $s) {
             # cast
             $s = (array) $s;
             //first verify address type
             $type = $Subnets->identify_address($s['subnet']);
             if ($type == "IPv4") {
                 # Initialize PEAR NET object
                 $this->initialize_pear_net_IPv4();
                 # parse address
                 $net = $this->Net_IPv4->parseAddress($Subnets->transform_to_decimal($s['subnet']) . '/' . $s['mask']);
                 if ($low > $Subnets->transform_to_decimal(@$net->network) && $low < $Subnets->transform_to_decimal($net->broadcast)) {
                     $ids[] = $s['id'];
                 }
             }
         }
         # filter
         $ids = sizeof(@$ids) > 0 ? array_filter($ids) : array();
         # search
         if (sizeof($ids) > 0) {
             foreach ($ids as $id) {
                 $result[] = $Subnets->fetch_subnet(null, $id);
             }
         }
         # return
         return sizeof(@$result) > 0 ? array_filter($result) : array();
     } else {
         return array();
     }
 }