<!-- content --> <div class="pContent"> <?php # remove item from nat $s = json_decode($nat->src, true); $d = json_decode($nat->dst, true); if (is_array($s[$_POST['type']])) { $s[$_POST['type']] = array_diff($s[$_POST['type']], array($_POST['item_id'])); } if (is_array($d[$_POST['type']])) { $d[$_POST['type']] = array_diff($d[$_POST['type']], array($_POST['item_id'])); } # save back and update $src_new = json_encode(array_filter($s)); $dst_new = json_encode(array_filter($d)); if ($Admin->object_modify("nat", "edit", "id", array("id" => $_POST['id'], "src" => $src_new, "dst" => $dst_new)) !== false) { $Result->show("success", "Object removed", false); } ?> </div> <!-- footer --> <div class="pFooter"> <div class="btn-group"> <button class="btn btn-sm btn-default hidePopup2"><?php print _('Close'); ?> </button> </div> </div>
if (!$Subnets->modify_subnet($_POST['action'], $values)) { $Result->show("danger", _('Error editing subnet'), true); } else { # if add save id ! if ($_POST['action'] == "add") { $new_subnet_id = $Subnets->lastInsertId; } # update also all slave subnets if section changes! if (isset($values['sectionId']) && $_POST['action'] == "edit" || $_POST['action'] == "delete") { $Subnets->reset_subnet_slaves_recursive(); $Subnets->fetch_subnet_slaves_recursive($_POST['subnetId']); $Subnets->remove_subnet_slaves_master($_POST['subnetId']); if (sizeof($Subnets->slaves) > 0) { foreach ($Subnets->slaves as $slaveId) { if ($_POST['action'] == "edit") { $Admin->object_modify("subnets", "edit", "id", array("id" => $slaveId, "sectionId" => $_POST['sectionIdNew'])); } else { $Admin->object_modify("subnets", "delete", "id", array("id" => $slaveId)); } } } } # edit success if ($_POST['action'] == "delete") { $Result->show("success", _('Subnet, IP addresses and all belonging subnets deleted successfully') . '!', false); } elseif ($_POST['action'] == "add") { $Result->show("success", _("Subnet {$_POST['action']} successfull") . '!<div class="hidden subnet_id_new">' . $new_subnet_id . '</div><div class="hidden section_id_new">' . $values['sectionId'] . '</div>', false); } else { $Result->show("success", _("Subnet {$_POST['action']} successfull") . '!', false); } }
$Result->show("danger", _("Invalid ID"), true); } // Hostname must be present if (@$_POST['name'] == "") { $Result->show("danger", _('Name is mandatory') . '!', true); } // set sections if (@$_POST['id'] != 1) { foreach ($_POST as $key => $line) { if (strlen(strstr($key, "section-")) > 0) { $key2 = str_replace("section-", "", $key); $temp[] = $key2; unset($_POST[$key]); } } # glue sections together $_POST['permissions'] = sizeof($temp) > 0 ? implode(";", $temp) : null; } else { $_POST['permissions'] = ""; } # set update values $values = array("id" => @$_POST['id'], "name" => @$_POST['name'], "description" => @$_POST['description'], "permissions" => @$_POST['permissions']); # update domain if (!$Admin->object_modify("vlanDomains", $_POST['action'], "id", $values)) { } else { $Result->show("success", _("Domain {$_POST['action']} successfull") . '!', false); } # if delete move all vlans to default domain! if ($_POST['action'] == "delete") { $Admin->update_object_references("vlans", "domainId", $_POST['id'], 1); }
/** * This function splits subnet into smaller subnets * * @access private * @param mixed $subnet_old * @param mixed $number * @param mixed $prefix * @param string $group (default: "yes") * @param string $strict (default: "yes") * @return void */ public function subnet_split($subnet_old, $number, $prefix, $group = "yes", $strict = "yes") { # we first need to check if it is ok to split subnet and get parameters $check = $this->verify_subnet_split($subnet_old, $number, $group, $strict); # ok, extract parameters from result array - 0 is $newsubnets and 1 is $addresses $newsubnets = $check[0]; $addresses = $check[1]; # admin object $Admin = new Admin($this->Database, false); # create new subnets and change subnetId for recalculated hosts $m = 0; foreach ($newsubnets as $subnet) { //set new subnet insert values $values = array("description" => strlen($prefix) > 0 ? $prefix . ($m + 1) : "split_subnet_" . ($m + 1), "subnet" => $subnet['subnet'], "mask" => $subnet['mask'], "sectionId" => $subnet['sectionId'], "masterSubnetId" => $subnet['masterSubnetId'], "vlanId" => @$subnet['vlanId'], "vrfId" => @$subnet['vrfId'], "allowRequests" => @$subnet['allowRequests'], "showName" => @$subnet['showName'], "permissions" => $subnet['permissions']); //create new subnets $this->modify_subnet("add", $values); //get all address ids unset($ids); foreach ($addresses as $ip) { if ($ip->subnetId == $m) { $ids[] = $ip->id; } } //replace all subnetIds in IP addresses to new subnet if (isset($ids)) { if (!$Admin->object_modify("ipaddresses", "edit-multiple", $ids, array("subnetId" => $this->lastInsertId))) { $Result->show("danger", _("Failed to move IP address"), true); } } # next $m++; } # do we need to remove old subnet? if ($group != "yes") { if (!$Admin->object_modify("subnets", "delete", "id", array("id" => $subnet_old->id))) { $Result->show("danger", _("Failed to remove old subnet"), true); } } # result return true; }
$Subnets = new Subnets($Database); $DNS = new DNS($Database); $Result = new Result(); # insert to database $discovered = 0; //for mailing foreach ($scan_subnets as $s) { if (sizeof(@$s->discovered) > 0) { foreach ($s->discovered as $ip) { // try to resolve hostname $tmp = new stdClass(); $tmp->ip_addr = $ip; $hostname = $DNS->resolve_address($tmp, true); //set update query $values = array("subnetId" => $s->id, "ip_addr" => $Subnets->transform_address($ip, "decimal"), "dns_name" => $hostname['name'], "description" => "-- autodiscovered --", "note" => "This host was autodiscovered on " . date("Y-m-d H:i:s"), "lastSeen" => date("Y-m-d H:i:s")); $Admin->object_modify("ipaddresses", "add", "id", $values); //set discovered $discovered++; } } } # send mail if ($discovered > 0 && $send_mail) { # check for recipients foreach ($Admin->fetch_multiple_objects("users", "role", "Administrator") as $admin) { if ($admin->mailNotify == "Yes") { $recepients[] = array("name" => $admin->real_name, "email" => $admin->email); } } # none? if (!isset($recepients)) {
$query[] = 'order by `ip_addr` ASC;'; //join $query = implode("\n", $query); } # fetch records $ipaddresses = $Database->getObjectsQuery($query); # try to update dns records foreach ($ipaddresses as $ip) { # fetch subnet $subnet = $Subnets->fetch_subnet("id", $ip->subnetId); $nsid = $subnet === false ? false : $subnet->nameserverId; # try to resolve $hostname = $DNS->resolve_address($ip->ip_addr, null, true, $nsid); # update if change if ($hostname['name'] != $Subnets->transform_to_dotted($ip->ip_addr)) { # values $values = array("dns_name" => $hostname['name'], "id" => $ip->id); # execute if (!$Admin->object_modify("ipaddresses", "edit", "id", $values)) { $Result->show_cli("Failed to update address " . $Subnets->transform_to_dotted($ip->ip_addr)); } # set text $res[] = 'updated ip address ' . $Subnets->transform_to_dotted($ip->ip_addr) . ' with hostname ' . $hostname['name']; } } # if verbose print result so it can be emailed via cron! if ($resolve_config['verbose'] == 1) { foreach ($res as $line) { print $line . "\n"; } }
/* functions */ require dirname(__FILE__) . '/../../../functions/functions.php'; # initialize user object $Database = new Database_PDO(); $User = new User($Database); $Admin = new Admin($Database); $Result = new Result(); # verify that user is logged in $User->check_user_session(); # ID must be numeric */ if ($_POST['action'] != "add") { if (!is_numeric($_POST['wid'])) { $Result->show("danger", _("Invalid ID"), true); } } # Title and path must be present! if ($_POST['action'] != "delete") { if (strlen($_POST['wtitle']) == 0 || strlen($_POST['wfile']) == 0) { $Result->show("danger", _("Filename and title are mandatory") . "!", true); } } # Remove .php form wfile if it is present $_POST['wfile'] = str_replace(".php", "", trim(@$_POST['wfile'])); # set update values $values = array("wid" => @$_POST['wid'], "wtitle" => $_POST['wtitle'], "wdescription" => @$_POST['wdescription'], "wfile" => $_POST['wfile'], "wadminonly" => $_POST['wadminonly'], "wactive" => $_POST['wactive'], "whref" => $_POST['whref'], "wsize" => $_POST['wsize']); # update if (!$Admin->object_modify("widgets", $_POST['action'], "wid", $values)) { $Result->show("danger", _("Widget {$_POST['action']} error") . "!", true); } else { $Result->show("success", _("Widget {$_POST['action']} success") . "!", true); }
} # fetch custom fields $custom = $Tools->fetch_custom_fields('locations'); if (sizeof($custom) > 0) { foreach ($custom as $myField) { //booleans can be only 0 and 1! if ($myField['type'] == "tinyint(1)") { if ($_POST[$myField['name']] > 1) { $_POST[$myField['name']] = 0; } } //not null! if ($myField['Null'] == "NO" && strlen($_POST[$myField['name']]) == 0) { $Result->show("danger", $myField['name'] . '" can not be empty!', true); } # save to update array $update[$myField['name']] = $_POST[$myField['name']]; } } // set values $values = array("id" => @$_POST['id'], "name" => $_POST['name'], "address" => $_POST['address'], "lat" => $_POST['lat'], "long" => $_POST['long'], "description" => $_POST['description']); # custom fields if (isset($update)) { $values = array_merge($values, $update); } # execute update if (!$Admin->object_modify("locations", $_POST['action'], "id", $values)) { $Result->show("danger", _("Location {$_POST['action']} failed"), false); } else { $Result->show("success", _("Location {$_POST['action']} successful"), false); }
//booleans can be only 0 and 1! if ($myField['type'] == "tinyint(1)") { if ($_POST[$myField['name']] > 1) { $_POST[$myField['name']] = 0; } } //not null! if ($myField['Null'] == "NO" && strlen($_POST[$myField['name']]) == 0) { $Result->show("danger", $myField['name'] . '" can not be empty!', true); } # save to update array $values[$myField['name']] = $_POST[$myField['name']]; } } # execute if (!$Admin->object_modify("subnets", $_POST['action'], "id", $values)) { $Result->show("danger", _('Error editing subnet'), true); } else { # update also all slave subnets! if (isset($values['sectionId']) && $_POST['action'] != "add") { $Subnets->reset_subnet_slaves_recursive(); $Subnets->fetch_subnet_slaves_recursive($_POST['subnetId']); $Subnets->remove_subnet_slaves_master($_POST['subnetId']); if (sizeof($Subnets->slaves) > 0) { foreach ($Subnets->slaves as $slaveId) { $Admin->object_modify("subnets", "edit", "id", array("id" => $slaveId, "sectionId" => $_POST['sectionIdNew'])); } } } # edit success if ($_POST['action'] == "delete") {
/* functions */ require dirname(__FILE__) . '/../../functions/functions.php'; /* @mail functions ------------------- */ require dirname(__FILE__) . '/../../functions/classes/class.Mail.php'; # initialize user object $Database = new Database_PDO(); $Subnets = new Subnets($Database); $Tools = new Tools($Database); $Admin = new Admin($Database, false); $Result = new Result(); # fetch settings, user is not authenticated ! $settings = $Tools->fetch_settings(); # requests must be enabled! if ($settings['enableIPrequests'] == 1) { # verify email if (!$Result->validate_email($_POST['requester'])) { $Result->show("danger", _('Please provide valid email address') . '! (' . _('requester') . ': ' . $_POST['requester'] . ')', true); } # formulate insert values $values = array("subnetId" => $_POST['subnetId'], "ip_addr" => @$_POST['ip_addr'], "description" => @$_POST['description'], "dns_name" => @$_POST['dns_name'], "owner" => $_POST['owner'], "requester" => $_POST['requester'], "comment" => @$_POST['comment'], "processed" => 0); if (!$Admin->object_modify("requests", "add", "id", $values)) { $Result->show("danger", _('Error submitting new IP address request'), true); } else { $Result->show("success", _('Request submitted successfully')); # send mail //if(!sendIPReqEmail($_POST)) { $Result->show("danger", _('Sending mail for new IP request failed'), true); } //else { $Result->show("success", _('Sending mail for IP request succeeded'), true); } } } else { $Result->show("danger", _('IP requests disabled'), true); }
<?php /** * Script to display language edit *************************************/ /* functions */ require dirname(__FILE__) . '/../../../functions/functions.php'; # initialize user object $Database = new Database_PDO(); $User = new User($Database); $Admin = new Admin($Database); $Result = new Result(); # verify that user is logged in $User->check_user_session(); # verify that description is present if action != delete if ($_POST['action'] != "delete" && strlen($_POST['l_code']) < 2) { $Result->show("danger", _('Code must be at least 2 characters long'), true); } if ($_POST['action'] != "delete" && strlen($_POST['l_name']) < 2) { $Result->show("danger", _('Name must be at least 2 characters long'), true); } # create update array $values = array("l_id" => @$_POST['l_id'], "l_code" => $_POST['l_code'], "l_name" => $_POST['l_name']); # update if (!$Admin->object_modify("lang", $_POST['action'], "l_id", $values)) { $Result->show("danger", _("Language {$_POST['action']} error"), true); } else { $Result->show("success", _("Language {$_POST['action']} success"), true); }
// save $password = array_pop(readline_list_history()); } } // validate password if (strlen($password) < 8) { $Result->show_cli("Password must be at least 8 characters long", true); } // hash passowrd $password_crypted = $User->crypt_user_pass($password); // save type $crypt_type = $User->return_crypt_type(); // set update array $values = array("id" => 1, "password" => $password_crypted); // update password if (!$Admin->object_modify("users", "edit", "id", $values)) { $Result->show_cli("Failed to update Admin password", false); } else { $Result->show_cli("Admin password updated", false); } // debug ? if ($debugging || $fail) { $Result->show_cli("---------"); $Result->show_cli("Crypt type: " . $crypt_type); $Result->show_cli("Password: "******"---------"); } // fail if ($fail) { die; }
$_POST['csrf_cookie'] == $_SESSION['csrf_cookie'] ?: $Result->show("danger", _("Invalid CSRF cookie"), true); # get action $action = $_POST['action']; //for adding remove id if ($action == "add") { unset($_POST['id']); } else { //check id if (!is_numeric($_POST['id'])) { $Result->show("danger", _("Invalid ID"), true); } } # set update query $values = array("id" => @$_POST['id'], "type" => $_POST['type'], "description" => @$_POST['description']); # add params unset($_POST['id'], $_POST['type'], $_POST['description'], $_POST['action']); $values["params"] = json_encode($_POST); # add - set protected if ($action == "add") { $values['protected'] = "No"; } # update if (!$Admin->object_modify("usersAuthMethod", $action, "id", $values)) { $Result->show("danger", _("Failed to edit authentication method"), false); } else { $Result->show("success", _("Authentication method updated"), false); } # if delete also reset all users that have thos auth method if ($action == "delete") { $Database->runQuery("update `users` set `authMethod`=1 where `authMethod`= ?;", array($values['id'])); }
if (strpos($key, $f['name']) !== false) { $res[substr($key, strlen($f['name']))][$f['name']] = $line; } } } } # insert entries if (sizeof($res) > 0) { $errors = 0; foreach ($res as $r) { # set insert values $values = array("rd" => $r['rd'], "name" => $r['name'], "description" => $r['description']); # custom fields if (isset($required_fields)) { foreach ($required_fields as $k => $f) { $values[$f['name']] = $r[$f['name']]; } } # insert vrfs if (!$Admin->object_modify("vrf", "add", "vrfId", $values)) { $Result->show("danger", _("Failed to import entry") . " " . $r['number'] . " " . $r['name'], false); $errors++; } } # success if no errors if ($errors == 0) { $Result->show("success", _("Scan results added to database") . "!", true); } } else { $Result->show("danger", _("No entries available"), true); }
<?php $msg = ""; $rows = ""; # Update Subnet master foreach ($rlist as $sect_id => $sect_check) { # Skip empty sections if (!$edata[$sect_id]) { continue; } # Grab a subnet and find its closest master foreach ($edata[$sect_id] as &$c_subnet) { if ($c_subnet['action'] == "edit") { # We only need id and new master $values = array("id" => $c_subnet['id'], "masterSubnetId" => $c_subnet['new_masterSubnetId']); # update $c_subnet['result'] = $Admin->object_modify("subnets", $c_subnet['action'], "id", $values); if ($c_subnet['result']) { $trc = $colors[$c_subnet['action']]; $msg = "Master " . $c_subnet['action'] . " successful."; } else { $trc = "danger"; $msg = "Master " . $c_subnet['action'] . " failed."; } $rows .= "<tr class='" . $trc . "'><td><i class='fa " . $icons[$c_subnet['action']] . "' rel='tooltip' data-placement='bottom' title='" . _($msg) . "'></i></td>"; $rows .= "<td>" . $sect_names[$sect_id] . "</td><td>" . $c_subnet['ip'] . "/" . $c_subnet['mask'] . "</td>"; $rows .= "<td>" . $c_subnet['description'] . "</td><td>" . $vrf_name[$c_subnet['vrfId']] . "</td><td>"; $rows .= $c_subnet['new_master'] . "</td><td>" . _($msg) . "</td></tr>\n"; } } } print "<table class='table table-condensed table-hover' id='resultstable'><tbody>";
$Result->show("danger", _("Name is mandatory"), true); } if ($_POST['namesrv1'] == "") { $Result->show("danger", _("Primary nameserver is mandatory"), true); } // set sections if (@$_POST['nameserverId'] != 1) { foreach ($_POST as $key => $line) { if (strlen(strstr($key, "section-")) > 0) { $key2 = str_replace("section-", "", $key); $temp[] = $key2; unset($_POST[$key]); } } # glue sections together $_POST['permissions'] = sizeof($temp) > 0 ? implode(";", $temp) : null; } else { $_POST['permissions'] = ""; } # set update array $values = array("id" => @$_POST['nameserverId'], "name" => $_POST['name'], "namesrv1" => $_POST['namesrv1'], "namesrv2" => $_POST['namesrv2'], "namesrv3" => $_POST['namesrv3'], "description" => $_POST['description'], "permissions" => $_POST['permissions']); # update if (!$Admin->object_modify("nameservers", $_POST['action'], "nameserverid", $values)) { $Result->show("danger", _("Failed to {$_POST['action']} nameserver set") . '!', true); } else { $Result->show("success", _("Nameserver set {$_POST['action']} successfull") . '!', false); } # remove all references if delete if ($_POST['action'] == "delete") { $Admin->remove_object_references("nameservers", "id", $_POST['nameserverId']); }
//not null! if ($myField['Null'] == "NO" && strlen($_POST[$myField['name']]) == 0) { $Result->show("danger", $myField['name'] . '" can not be empty!', true); } # save to update array $values[$myField['name']] = $_POST[$myField['name']]; } } # execute if (!$Subnets->modify_subnet($_POST['action'], $values)) { $Result->show("danger", _('Error editing folder'), true); } else { # update also all slave subnets! if (isset($values['sectionId']) && $_POST['action'] != "add") { $Subnets->reset_subnet_slaves_recursive(); $Subnets->fetch_subnet_slaves_recursive($_POST['subnetId']); $Subnets->remove_subnet_slaves_master($_POST['subnetId']); if (sizeof($Subnets->slaves) > 0) { foreach ($Subnets->slaves as $slaveId) { $Admin->object_modify("subnets", "edit", "id", array("id" => $slaveId, "sectionId" => $_POST['sectionIdNew'])); } } } # edit success if ($_POST['action'] == "delete") { $Result->show("success", _('Folder, IP addresses and all belonging subnets deleted successfully') . '!', false); } else { $Result->show("success", _("Folder {$_POST['action']} successfull") . '!', true); } } }
} } if (strlen($_POST['name']) == 0) { $Result->show("danger", _('Name is required') . '!', true); } # formulate update query $values = array("vlanId" => @$_POST['vlanId'], "number" => $_POST['number'], "name" => $_POST['name'], "description" => @$_POST['description'], "domainId" => $_POST['domainId']); # append custom if (sizeof($custom) > 0) { foreach ($custom as $myField) { # replace possible ___ back to spaces! $myField['nameTest'] = str_replace(" ", "___", $myField['name']); if (isset($_POST[$myField['nameTest']])) { $values[$myField['name']] = @$_POST[$myField['nameTest']]; } } } # update if (!$Admin->object_modify("vlans", $_POST['action'], "vlanId", $values)) { $Result->show("danger", _("Failed to {$_POST['action']} VLAN") . '!', true); } else { $Result->show("success", _("VLAN {$_POST['action']} successfull") . '!', false); } # remove all references if delete if ($_POST['action'] == "delete") { $Admin->remove_object_references("subnets", "vlanId", $_POST['vlanId']); } # print value for on the fly if ($_POST['action'] == "add") { print '<p id="vlanidforonthefly" style="display:none">' . $Admin->lastId . '</p>'; }
if (strpos($_POST['siteURL'], 'http://') !== false || strpos($_POST['siteURL'], 'https://') !== false) { } else { $_POST['siteURL'] = "http://" . $_POST['siteURL']; } //verify ping status fields $_POST['pingStatus'] = str_replace(" ", "", $_POST['pingStatus']); //remove possible spaces $_POST['pingStatus'] = str_replace(",", ";", $_POST['pingStatus']); //change possible , for ; $statuses = explode(";", $_POST['pingStatus']); if (sizeof($statuses) != 2) { $Result->show("danger", _("Invalid ping status intervals"), true); } if (!is_numeric($statuses[0]) || !is_numeric($statuses[1])) { $Result->show("danger", _("Invalid ping status intervals"), true); } //verify email if (filter_var($_POST['siteAdminMail'], FILTER_VALIDATE_EMAIL) === false) { $Result->show("danger", _("Invalid email"), true); } //verify numbers if (!is_numeric($_POST['vlanMax'])) { $Result->show("danger", _("Invalid value for Max VLAN number"), true); } # set update values $values = array("id" => 1, "siteTitle" => @$_POST['siteTitle'], "siteDomain" => @$_POST['siteDomain'], "siteURL" => @$_POST['siteURL'], "siteLoginText" => @$_POST['siteLoginText'], "prettyLinks" => @$_POST['prettyLinks'], "defaultLang" => @$_POST['defaultLang'], "inactivityTimeout" => @$_POST['inactivityTimeout'], "siteAdminName" => @$_POST['siteAdminName'], "siteAdminMail" => @$_POST['siteAdminMail'], "api" => $Admin->verify_checkbox(@$_POST['api']), "enableIPrequests" => $Admin->verify_checkbox(@$_POST['enableIPrequests']), "enableVRF" => $Admin->verify_checkbox(@$_POST['enableVRF']), "enableDNSresolving" => $Admin->verify_checkbox(@$_POST['enableDNSresolving']), "vlanDuplicate" => $Admin->verify_checkbox(@$_POST['vlanDuplicate']), "vlanMax" => @$_POST['vlanMax'], "enableChangelog" => $Admin->verify_checkbox(@$_POST['enableChangelog']), "tempShare" => $Admin->verify_checkbox(@$_POST['tempShare']), "enablePowerDNS" => $Admin->verify_checkbox(@$_POST['enablePowerDNS']), "enableFirewallZones" => $Admin->verify_checkbox(@$_POST['enableFirewallZones']), "log" => @$_POST['log'], "donate" => $Admin->verify_checkbox(@$_POST['donate']), "visualLimit" => @$_POST['visualLimit'], "subnetOrdering" => @$_POST['subnetOrdering'], "subnetView" => @$_POST['subnetView'], "scanPingType" => @$_POST['scanPingType'], "pingStatus" => @$_POST['pingStatus'], "scanPingPath" => @$_POST['scanPingPath'], "scanFPingPath" => @$_POST['scanFPingPath'], "scanMaxThreads" => @$_POST['scanMaxThreads']); if (!$Admin->object_modify("settings", "edit", "id", $values)) { $Result->show("danger", _("Cannot update settings"), true); } else { $Result->show("success", _("Settings updated successfully"), true); }
$old_access = json_decode($User->settings->tempAccess, true); if (!is_array($old_access)) { $old_access = array(); } else { //remove all expired foreach ($old_access as $k => $a) { if (time() > $a['validity']) { unset($old_access[$k]); } } //reset array is_array($old_access) ?: ($old_access = array()); } $new_access = json_encode(array_merge($old_access, array_filter($new_access))); # execute if (!$Admin->object_modify("settings", "edit", "id", array("id" => 1, "tempAccess" => $new_access))) { $Result->show("danger", _("Temporary share create error"), true); } else { $Result->show("success", _("Temporary share created"), false); } # send mail if (strlen($_POST['email']) > 0) { # fetch mailer settings $mail_settings = $Admin->fetch_object("settingsMail", "id", 1); # initialize mailer $phpipam_mail = new phpipam_mail($User->settings, $mail_settings); $phpipam_mail->initialize_mailer(); // generate url $url = $Result->createURL() . create_link("temp_share", $_POST['code']); // set subject $subject = "New ipam share created";
} # name must be more than 2 and alphanumberic if (strlen($_POST['name']) == 0) { $error[] = "Invalid agent name"; } } # die if errors if (sizeof($error) > 0) { $Result->show("danger", $error, true); } else { # create array of values for modification $values = array("id" => @$_POST['id'], "name" => $_POST['name'], "description" => @$_POST['description'], "code" => @$_POST['code'], "type" => @$_POST['type']); # null $values = $Admin->remove_empty_array_fields($values); # execute if (!$Admin->object_modify("scanAgents", $_POST['action'], "id", $values)) { $Result->show("danger", _("Agent {$_POST['action']} error"), true); } else { $Result->show("success", _("Agent {$_POST['action']} success"), false); } # delete - unset scanning in all subnets if ($_POST['action'] == "delete") { $query = "update `subnets` set `scanAgent`=0, `pingSubnet`=0, `discoverSubnet`=0 where `scanAgent` = ?;"; try { $Database->runQuery($query, array($_POST['id'])); } catch (Exception $e) { $this->Result->show("danger", _("Error: ") . $e->getMessage()); return false; } // references removed $this->Result->show("info", _("Scan agent references removed"));
$Subnets = new Subnets($Database); $Result = new Result(); # verify that user is logged in $User->check_user_session(); # get posted permissions foreach ($_POST as $key => $val) { if (substr($key, 0, 5) == "group") { if ($val != 0) { $perm[substr($key, 5)] = $val; } } } # set values and update $permissions = isset($perm) ? array("permissions" => json_encode($perm)) : array("permissions" => ""); # propagate ? if (@$_POST['set_inheritance'] == "Yes") { # fetch all possible slaves + master $Subnets->fetch_subnet_slaves_recursive($_POST['subnetId']); # update if (!$Admin->object_modify("subnets", "edit-multiple", $Subnets->slaves, $permissions)) { $Result->show("danger", _("Failed to set subnet permissons") . "!", true); } else { $Result->show("success", _("Subnet permissions set") . "!", true); } } else { if (!$Admin->object_modify("subnets", "edit", "id", array_merge(array("id" => $_POST['subnetId']), $permissions))) { $Result->show("danger", _("Failed to set subnet permissons") . "!", true); } else { $Result->show("success", _("Subnet permissions set") . "!", true); } }
$item = $Tools->fetch_object($obj_type, "id", $obj_id); if ($item !== false) { // update if ($nat_type == "src") { $nat_array = json_decode($nat->src, true); } else { $nat_array = json_decode($nat->dst, true); } if (is_array($nat_array[$obj_type])) { $nat_array[$obj_type] = array_merge($nat_array[$obj_type], array($obj_id)); } else { $nat_array[$obj_type] = array($obj_id); } // to json if ($nat_type == "src") { $nat->src = json_encode($nat_array); } else { $nat->dst = json_encode($nat_array); } // update if ($Admin->object_modify("nat", "edit", "id", array("id" => $nat_id, "src" => $nat->src, "dst" => $nat->dst))) { $Result->show("success", "Object added", false); } else { $Result->show("danger", "Failed to add object", false); } } else { $Result->show("danger", _("Invalid object identifier"), true); } } else { $Result->show("danger", _("Missing object type or id"), true); }
$User->csrf_cookie("validate", "rack_devices", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : ""; # ID must be numeric if (!is_numeric($_POST['rackid'])) { $Result->show("danger", _("Invalid ID"), true); } if (!is_numeric($_POST['deviceid'])) { $Result->show("danger", _("Invalid ID"), true); } if (!is_numeric($_POST['rack_start'])) { $Result->show("danger", _("Invalid start value"), true); } if (!is_numeric($_POST['rack_size'])) { $Result->show("danger", _("Invalid size value"), true); } # validate rack $rack = $Admin->fetch_object("racks", "id", $_POST['rackid']); if ($rack === false) { $Result->show("danger", _("Invalid ID"), true); } # check size if ($_POST['rack_start'] + ($_POST['rack_size'] - 1) > $rack->size) { $Result->show("danger", _("Invalid rack position (overflow)"), true); } # set update values $values = array("id" => @$_POST['deviceid'], "rack" => @$_POST['rackid'], "rack_start" => @$_POST['rack_start'], "rack_size" => @$_POST['rack_size']); # update rack if (!$Admin->object_modify("devices", "edit", "id", $values)) { $Result->show("success", _("Failed to add device to rack") . '!', false); } else { $Result->show("success", _("Device added to rack") . '!', false); }
$Result->show("danger", _("Invalid ID"), true); } // verify that new exists $vlan_domain = $Admin->fetch_object("vlanDomains", "id", $_POST['newDomainId']); if ($vlan_domain === false) { $Result->show("danger", _("Invalid ID"), true); } //fetch vlan $vlan = $Admin->fetch_object("vlans", "vlanId", $_POST['vlanId']); if ($vlan === false) { $Result->show("danger", _("Invalid ID"), true); } // check that it is not already set ! if ($User->settings->vlanDuplicate == 0) { $check_vlan = $Admin->fetch_multiple_objects("vlans", "domainId", $vlan_domain->id, "vlanId"); if ($check_vlan !== false) { foreach ($check_vlan as $v) { if ($v->number == $vlan->number) { $Result->show("danger", _("VLAN already exists"), true); } } } } # formulate update query $values = array("vlanId" => @$_POST['vlanId'], "domainId" => $vlan_domain->id); # update if (!$Admin->object_modify("vlans", "edit", "vlanId", $values)) { $Result->show("danger", _("Failed to move VLAN to new domain") . '!', true); } else { $Result->show("success", _("VLAN moved to new domain successfully") . '!', false); }
<?php /** * Script to display usermod result *************************************/ /* functions */ require dirname(__FILE__) . '/../../../functions/functions.php'; # initialize user object $Database = new Database_PDO(); $User = new User($Database); $Admin = new Admin($Database); $Result = new Result(); # verify that user is logged in $User->check_user_session(); # remove users from this group if delete and remove group from sections if ($_POST['action'] == "delete") { $Admin->remove_group_from_users($_POST['g_id']); $Admin->remove_group_from_sections($_POST['g_id']); } else { if (strlen($_POST['g_name']) < 2) { $Result->show("danger", _('Name must be at least 2 characters long') . "!", true); } } # create array of values for modification $values = array("g_id" => @$_POST['g_id'], "g_name" => $_POST['g_name'], "g_desc" => @$_POST['g_desc']); /* try to execute */ if (!$Admin->object_modify("userGroups", $_POST['action'], "g_id", $values)) { $Result->show("danger", _("Group {$_POST['action']} error") . "!", true); } else { $Result->show("success", _("Group {$_POST['action']} success") . "!", true); }
$Result->show("danger", _('Hostname is mandatory') . '!', true); } # fetch custom fields $custom = $Tools->fetch_custom_fields('devices'); if (sizeof($custom) > 0) { foreach ($custom as $myField) { //booleans can be only 0 and 1! if ($myField['type'] == "tinyint(1)") { if ($device[$myField['name']] > 1) { $device[$myField['name']] = 0; } } //not null! if ($myField['Null'] == "NO" && strlen($device[$myField['name']]) == 0) { $Result->show("danger", $myField['name'] . '" can not be empty!', true); } } # save to update array $update[$myField['name']] = $device[$myField['name']]; } # set update values $values = array("id" => @$device['switchId'], "hostname" => @$device['hostname'], "ip_addr" => @$device['ip_addr'], "type" => @$device['type'], "vendor" => @$device['vendor'], "model" => @$device['model'], "description" => @$device['description'], "sections" => @$device['sections']); # custom fields if (isset($update)) { $values = array_merge($values, $update); } # update device if (!$Admin->object_modify("devices", $_POST['action'], "id", $values)) { } else { $Result->show("success", _("Device {$device['action']} successfull") . '!', true); }
# fetch custom fields $custom = $Tools->fetch_custom_fields('ipaddresses'); if (sizeof($custom) > 0) { foreach ($custom as $myField) { if (isset($_POST[$myField['name']])) { $_POST[$myField['name']] = $_POST[$myField['name']]; } } } # fetch subnet $subnet = (array) $Admin->fetch_object("subnets", "id", $_POST['subnetId']); /* if action is reject set processed and accepted to 1 and 0 */ if ($_POST['action'] == "reject") { //set reject values $values = array("id" => $_POST['requestId'], "processed" => 1, "accepted" => 0, "adminComment" => @$_POST['adminComment']); if (!$Admin->object_modify("requests", "edit", "id", $values)) { $Result->show("danger", _("Failed to reject IP request"), true); } else { $Result->show("success", _("Request has beed rejected"), false); } # send mail $Tools->ip_request_send_mail("reject", $_POST); } else { // fetch subnet $subnet_temp = $Addresses->transform_to_dotted($subnet['subnet']) . "/" . $subnet['mask']; //verify IP and subnet $Addresses->verify_address($Addresses->transform_address($_POST['ip_addr'], "dotted"), $subnet_temp, false, true); //check if already existing and die if ($Addresses->address_exists($Addresses->transform_address($_POST['ip_addr'], "decimal"), $subnet['id'])) { $Result->show("danger", _('IP address already exists'), true); }
$old_tag = $Admin->fetch_object("ipTags", "id", $_POST['id']); } else { $old_tag = new StdClass(); } /* checks */ if ($_POST['action'] == "delete" && $old_tag->locked != "No") { $Result->show("danger", _("Cannot delete locked tag"), true); } if ($_POST['action'] != "delete") { if (strlen($_POST['type']) < 3) { $Result->show("danger", _("Invalid tag name"), true); } if (strlen($_POST['bgcolor']) < 4) { $Result->show("danger", _("Invalid bg color"), true); } if (strlen($_POST['fgcolor']) < 4) { $Result->show("danger", _("Invalid fg color"), true); } } # create array of values for modification $values = array("id" => @$_POST['id'], "type" => $_POST['type'], "bgcolor" => @$_POST['bgcolor'], "fgcolor" => @$_POST['fgcolor'], "showtag" => @$_POST['showtag'], "compress" => @$_POST['compress']); # execute if (!$Admin->object_modify("ipTags", $_POST['action'], "id", $values)) { $Result->show("danger", _("Tag {$_POST['action']} error"), true); } else { $Result->show("success", _("Tag {$_POST['action']} success"), false); } # reset if delete to online if ($_POST['action'] == "delete") { $Admin->update_object_references("ipaddresses", "state", $old_tag->id, 0); }
} else { if (strlen($err = $Subnets->verify_subnet_overlapping($subnet_import['sectionId'], $Subnets->transform_to_dotted($subnet_import['subnet']) . "/" . $subnet_import['mask'], $subnet_import['vrfId'])) > 5) { $errors[] = $err; } else { $subnets_to_insert[] = $subnet_import; } } } # print errors if they exist or success if (isset($errors)) { print '<div class="alert alert-danger alert-absolute">' . _('Please fix the following errors before inserting') . ':<hr>' . "\n"; foreach ($errors as $line) { print $line . '<br>'; } print '</div>'; } else { $errors_import_failed = 0; //insert if all other is ok! foreach ($subnets_to_insert as $subnet_import) { //formulate insert query $values = array("sectionId" => $subnet_import['sectionId'], "subnet" => $subnet_import['subnet'], "mask" => $subnet_import['mask'], "description" => $subnet_import['description'], "vlanId" => $subnet_import['vlanId'], "vrfId" => $subnet_import['vrfId'], "masterSubnetId" => 0, "showName" => $subnet_import['showName']); if (!$Admin->object_modify("subnets", "add", "id", $values)) { $Result->show("danger", _('Failed to import subnet') . ' ' . $Subnets->transform_to_dotted($subnet_import['subnet']) . "/" . $subnet_import['mask'], false); $errors_import_failed++; } } //check if all is ok and print it! if ($errors_import_failed == 0) { $Result->show("success", _("Import successfull") . "!", false); } }