Beispiel #1
0
/* If no errors are present execute request */
if (sizeof(@$errors) > 0) {
    print '<div class="alert alert-danger"><strong>' . _('Please fix following problems') . '</strong>:';
    foreach ($errors as $error) {
        print "<br>" . $error;
    }
    print '</div>';
    die;
} elseif ($_POST['action'] == "delete" && !isset($_POST['deleteconfirm'])) {
    # for ajax to prevent reload
    print "<div style='display:none'>alert alert-danger</div>";
    # result
    print "<div class='alert alert-warning'>";
    # print what will be deleted
    //fetch all slave subnets
    $Subnets->fetch_subnet_slaves_recursive($_POST['subnetId']);
    $subcnt = sizeof($Subnets->slaves);
    foreach ($Subnets->slaves as $s) {
        $slave_array[$s] = $s;
    }
    $ipcnt = $Addresses->count_addresses_in_multiple_subnets($slave_array);
    print "<strong>" . _("Warning") . "</strong>: " . _("I will delete") . ":<ul>";
    print "\t<li>{$subcnt} " . _("subnets") . "</li>";
    if ($ipcnt > 0) {
        print "\t<li>{$ipcnt} " . _("IP addresses") . "</li>";
    }
    print "</ul>";
    print "<hr><div style='text-align:right'>";
    print _("Are you sure you want to delete above items?") . " ";
    print "<div class='btn-group'>";
    print "\t<a class='btn btn-sm btn-danger editSubnetSubmitDelete' id='editSubnetSubmitDelete'>" . _("Confirm") . "</a>";
Beispiel #2
0
 /**
  * Fetches changelog entries for all slave subnets recursive
  *
  * @access public
  * @param mixed $subnetId
  * @param int $limit (default: 50)
  * @return void
  */
 public function fetch_subnet_slaves_changlog_entries_recursive($subnetId, $limit = 50)
 {
     # limit check
     if (!is_numeric($limit)) {
         $this->Result->show("danger", "Invalid limit", true);
         return false;
     }
     # $subnetId check
     if (!is_numeric($subnetId)) {
         $this->Result->show("danger", "Invalid subnet Id", true);
         return false;
     }
     # fetch all slave subnet ids
     $Subnets = new Subnets($this->Database);
     $Subnets->reset_subnet_slaves_recursive();
     $Subnets->fetch_subnet_slaves_recursive($subnetId);
     # remove master subnet ID
     $key = array_search($subnetId, $Subnets->slaves);
     unset($Subnets->slaves[$key]);
     $Subnets->slaves = array_unique($Subnets->slaves);
     # if some slaves are present get changelog
     if (sizeof($Subnets->slaves) > 0) {
         # set query
         $query = "select\n\t\t\t\t\t\t`u`.`real_name`,`o`.`sectionId`,`o`.`subnet`,`o`.`mask`,`o`.`isFolder`,`o`.`description`,`o`.`id`,`c`.`caction`,`c`.`cresult`,`c`.`cdate`,`c`.`cdiff`  from `changelog` as `c`, `users` as `u`, `subnets` as `o`\n\t\t\t\t\t\twhere `c`.`cuser` = `u`.`id` and `c`.`coid`=`o`.`id`\n\t\t\t\t\t\tand (";
         foreach ($Subnets->slaves as $slaveId) {
             if (!isset($args)) {
                 $args = array();
             }
             $query .= "`c`.`coid` = ? or ";
             $args[] = $slaveId;
             //set keys
         }
         $query = substr($query, 0, -3);
         $query .= ") and `c`.`ctype` = 'subnet' order by `c`.`cid` desc limit {$limit};";
         # fetch
         try {
             $logs = $this->Database->getObjectsQuery($query, $args);
         } catch (Exception $e) {
             $this->Result->show("danger", $e->getMessage(), false);
             return false;
         }
         # return result
         return $logs;
     } else {
         return false;
     }
 }
Beispiel #3
0
$Tools = new Tools($Database);
$Addresses = new Addresses($Database);
# verify that user is logged in
$User->check_user_session();
# create csrf token
$csrf = $User->csrf_cookie("create", "address");
# validate action
$Tools->validate_action($_POST['action']);
# validate post
is_numeric($_POST['subnetId']) ?: $Result->show("danger", _("Invalid ID"), true);
is_numeric($_POST['id']) || strlen($_POST['id']) == 0 ?: $Result->show("danger", _("Invalid ID"), true);
# fetch address and subnet
$address = (array) $Addresses->fetch_address(null, $_POST['id']);
$subnet = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']);
# fetch all slave subnets
$Subnets->fetch_subnet_slaves_recursive($subnet['id']);
?>

<!-- header -->
<div class="pHeader"><?php 
print _('Move IP address to different subnet');
?>
</div>

<!-- content -->
<div class="pContent editIPAddress">

	<!-- IP address modify form -->
	<form class="editipaddress" name="editipaddress">
	<!-- edit IP address table -->
	<table id="editipaddress" class="table table-noborder table-condensed">