function ip_in_network6($ip, $net_addr, $net_mask = false) { if (!$net_mask && strpos($net_addr, "/") !== false) { $cidr_arr = explode("/", $net_addr); $net_addr = $cidr_arr[0]; $net_mask = $cidr_arr[1]; } $ip = inet6_expand($ip); $net_addr = inet6_expand($net_addr); $net_mask_hex = inet6_expand(inet6_prefix_to_mask($net_mask)); $ip_dec_arr = inet6_to_int64($ip); $net_dec_arr = inet6_to_int64($net_addr); $mask_dec_arr = inet6_to_int64($net_mask_hex); // Need to handle >64 bit net masks if ($net_mask > 64) { $net_mask_64_arr[0] = 64; $net_mask_64_arr[1] = 64 - (128 - $net_mask); } else { $net_mask_64_arr[0] = $net_mask; $net_mask_64_arr[1] = false; } if ((substr(gmp_convert($ip_dec_arr[0], 10, 2), 0, $net_mask_64_arr[0]) & substr(gmp_convert($mask_dec_arr[0], 10, 2), 0, $net_mask_64_arr[0])) == substr(gmp_convert($net_dec_arr[0], 10, 2), 0, $net_mask_64_arr[0])) { if ($net_mask_64_arr[1]) { if ((substr(gmp_convert($ip_dec_arr[1], 10, 2), 0, $net_mask_64_arr[1]) & substr(gmp_convert($mask_dec_arr[1], 10, 2), 0, $net_mask_64_arr[1])) != substr(gmp_convert($net_dec_arr[1], 10, 2), 0, $net_mask_64_arr[1])) { return false; } } return true; } }
?> <table class="table table-striped table-condensed"> <thead> <tr><th>Network</th><th>rDNS Records</th></tr> </thead> <tbody> <?php foreach ($addresses6 as $address) { echo '<tr><td>' . int64_to_inet6(array($address->ip_address, 0)) . '/64 <br /><a data-toggle="modal" data-target="#v6-add-' . $address->ip_address . '" class="btn btn-primary btn-xs" href="/ip/rdns6/' . $address->ip_address . '"><i class="fa fa-plus"></i> Add Record</a><div id="v6-add-' . $address->ip_address . '" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>'; if ($this->ion_auth->is_admin()) { echo ' <a data-toggle="modal" data-target="#v6-rm-block-' . $address->ip_address . '" class="btn btn-danger btn-xs" href="/server/remove_ip6/' . $server_id . '/' . $address->ip_address . '"><i class="fa fa-trash-o"></i> Remove Block</a><div id="v6-rm-block-' . $address->ip_address . '" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>'; } echo '</td><td><table class="table table-bordered table-striped table-condensed">'; foreach ($address->rdns as $address6) { $a_int = inet6_to_int64(ptr_to_inet6($address6->name)); echo '<tr><td style="padding-left: 0px">' . ptr_to_inet6($address6->name) . '</td><td>' . $address6->content . '</td><td><a data-toggle="modal" data-target="#v6-edit-' . $a_int[0] . '-' . $a_int[1] . '" class="btn btn-primary btn-xs" href="/ip/rdns6/' . $a_int[0] . '/' . $a_int[1] . '"><i class="fa fa-check"></i> Edit rDNS</a><div id="v6-edit-' . $a_int[0] . '-' . $a_int[1] . '" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div> <a data-toggle="modal" data-target="#v6-rm-rdns-' . $a_int[0] . '-' . $a_int[1] . '" class="btn btn-danger btn-xs" href="/ip/rdns6delete/' . $a_int[0] . '/' . $a_int[1] . '"><i class="fa fa-trash-o"></i> Delete</a><div id="v6-rm-rdns-' . $a_int[0] . '-' . $a_int[1] . '" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div></td></tr>'; } echo '</table></td></tr>'; } ?> </tbody> </table> </div> <?php if ($this->ion_auth->is_admin()) { ?> <div class="panel panel-default"> <div class="panel-heading">Add IPv6 Block</div>
if ($this->input->is_ajax_request()) { ?> <?php $this->output->set_output(''); ?> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">Delete rDNS Record</h4> </div> <?php $a_int = inet6_to_int64($address); ?> <?php echo form_open('ip/rdns6delete/' . $a_int[0] . '/' . $a_int[1], array('class' => 'form-horizontal')); ?> <div class="modal-body"> <p>Are you sure you want to delete the rDNS entry for IPv6 address <?php echo $address; ?> ?</p> </div> <div class="modal-footer"> <?php