<?php /* * Scan subnet for new hosts ***************************/ /* functions */ require dirname(__FILE__) . '/../../../functions/functions.php'; # initialize user object $Database = new Database_PDO(); $User = new User($Database); $Admin = new Admin($Database, false); $Subnets = new Subnets($Database); $Result = new Result(); # verify that user is logged in $User->check_user_session(); # ID must be numeric if (!is_numeric($_POST['subnetId'])) { $Result->show("danger", _("Invalid ID"), true, true); } # verify that user has write permissionss for subnet if ($Subnets->check_permission($User->user, $_POST['subnetId']) != 3) { $Result->show("danger", _('You do not have permissions to modify hosts in this subnet') . "!", true, true); } # fetch subnet details $subnet = $Subnets->fetch_subnet(null, $_POST['subnetId']); $subnet !== false ?: $Result->show("danger", _("Invalid ID"), true, true); # IPv6 scanning is not supported if ($Subnets->identify_address($subnet->subnet) == "IPv6") { $Result->show("danger", _('IPv6 scanning is not supported') . '!', true, true); } # fix description
/** * 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; } }
<?php /* * Print truncate subnet *********************/ /* functions */ require dirname(__FILE__) . '/../../../functions/functions.php'; # initialize user object $Database = new Database_PDO(); $User = new User($Database); $Admin = new Admin($Database, false); $Subnets = new Subnets($Database); $Addresses = new Addresses($Database); $Result = new Result(); # verify that user is logged in $User->check_user_session(); # create csrf token $csrf = $User->create_csrf_cookie(); # id must be numeric if (!is_numeric($_POST['subnetId'])) { $Result->show("danger", _("Invalid ID"), true, true); } # get subnet details $subnet = $Subnets->fetch_subnet(null, $_POST['subnetId']); # verify that user has write permissions for subnet $subnetPerm = $Subnets->check_permission($User->user, $subnet->id); if ($subnetPerm < 3) { $Result->show("danger", _('You do not have permissions to resize subnet') . '!', true, true); } ?>
foreach ($scan_subnets as $sk => $s) { if (isset($add_tmp[$s->id])) { $scan_subnets[$sk]->discovered = $add_tmp[$s->id]; } } } # print change if ($Scan->debugging) { "\nDiscovered addresses:\n----------\n"; print_r($scan_subnets); } # reinitialize objects $Database = new Database_PDO(); $Admin = new Admin($Database, false); $Addresses = new Addresses($Database); $Subnets = new Subnets($Database); $DNS = new DNS($Database); $Scan = new Scan($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) { // fetch subnet $subnet = $Subnets->fetch_subnet("id", $s->id); $nsid = $subnet === false ? false : $subnet->nameserverId; // try to resolve hostname $hostname = $DNS->resolve_address($ip, false, true, $nsid); //set update query
<?php /* * Print edit folder *********************/ /* functions */ require dirname(__FILE__) . '/../../../functions/functions.php'; # initialize user object $Database = new Database_PDO(); $User = new User($Database); $Admin = new Admin($Database, false); $Sections = new Sections($Database); $Subnets = new Subnets($Database); $Tools = new Tools($Database); $Result = new Result(); # verify that user is logged in $User->check_user_session(); # create csrf token $csrf = $User->csrf_cookie("create", "folder"); # strip tags - XSS $_POST = $User->strip_input_tags($_POST); # validate action $Admin->validate_action($_POST['action'], true); # ID must be numeric if ($_POST['action'] != "add") { if (!is_numeric($_POST['subnetId'])) { $Result->show("danger", _("Invalid ID"), true, true); } } # verify that user has permissions to add subnet if ($_POST['action'] == "add") {
<?php /** * Script to check edited / deleted / new IP addresses * If all is ok write to database *************************************************/ # include required scripts require dirname(__FILE__) . '/../../../functions/functions.php'; # initialize required objects $Database = new Database_PDO(); $Result = new Result(); $User = new User($Database); $Subnets = new Subnets($Database); $Tools = new Tools($Database); $Addresses = new Addresses($Database); $Log = new Logging($Database, $User->settings); $Zones = new FirewallZones($Database); $Ping = new Scan($Database); # verify that user is logged in $User->check_user_session(); # validate csrf cookie $User->csrf_cookie("validate", "address", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : ""; # validate action $Tools->validate_action($_POST['action']); $action = $_POST['action']; //reset delete action form visual visual if (isset($_POST['action-visual'])) { if (@$_POST['action-visual'] == "delete") { $action = "delete"; } }
<?php /** * Function to add / edit / delete subnet ********************************************/ /* functions */ require dirname(__FILE__) . '/../../../functions/functions.php'; # initialize user object $Database = new Database_PDO(); $User = new User($Database); $Admin = new Admin($Database, false); $Subnets = new Subnets($Database); $Sections = new Sections($Database); $Addresses = new Addresses($Database); $Tools = new Tools($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['sectionId'])) { $Result->show("danger", _("Invalid ID"), true); } } else { if (!is_numeric($_POST['subnetId'])) { $Result->show("danger", _("Invalid ID"), true); } if (!is_numeric($_POST['sectionId'])) { $Result->show("danger", _("Invalid ID"), true); } }
<?php # include required scripts require dirname(__FILE__) . '/../functions.php'; # limit $limit = 80; // 80 percent threshold # initialize objects $Database = new Database_PDO(); $Subnets = new Subnets($Database); $Addresses = new Addresses($Database); $Tools = new Tools($Database); $Result = new Result(); # fetch all subnets $all_subnets = $Tools->fetch_all_objects("subnets"); # loop and check usage for each, make sure it does not have any parent foreach ($all_subnets as $k => $s) { // marked as full should not be checked if ($s->isFull != 1) { // parent check if (!$Subnets->has_slaves($s->id)) { // count number of addresses $cnt = $Addresses->count_subnet_addresses($s->id); // calculate usage $usage = $Subnets->calculate_subnet_usage($cnt, $s->mask, $s->subnet, $s->isFull); // if more than $threshold report if ($usage['freehosts_percent'] < 100 - $limit) { // this subnet has high usage, save it to array $out[$k]['subnet'] = $Subnets->transform_address($s->subnet, "dotted") . "/" . $s->mask; $out[$k]['description'] = $s->description; $out[$k]['usage'] = $usage;
<?php /* * CSV import form + guide *************************************************/ /* functions */ require dirname(__FILE__) . '/../../../functions/functions.php'; # classes $Database = new Database_PDO(); $User = new User($Database); $Tools = new Tools($Database); $Addresses = new Addresses($Database); $Subnets = new Subnets($Database); $Result = new Result(); # verify that user is logged in $User->check_user_session(); # permissions $permission = $Subnets->check_permission($User->user, $_POST['subnetId']); # die if write not permitted if ($permission < 2) { $Result->show("danger", _('You cannot write to this subnet'), true); } # fetch subnet details $subnet = $Subnets->fetch_subnet(null, $_POST['subnetId']); $subnet !== false ?: $Result->show("danger", _("Invalid ID"), true, true); # full if ($_POST['type'] != "update-icmp" && $subnet->isFull == 1) { $Result->show("warning", _("Cannot scan as subnet is market as used"), true, true); } # get custom fields $custom_address_fields = $Tools->fetch_custom_fields('ipaddresses');
<?php /** * Function to add / edit / delete section *************************************************/ /* functions */ require dirname(__FILE__) . '/../../../functions/functions.php'; # initialize user object $Database = new Database_PDO(); $User = new User($Database); $Admin = new Admin($Database); $Sections = new Sections($Database); $Subnets = new Subnets($Database); $Addresses = new Addresses($Database); $Result = new Result(); # verify that user is logged in $User->check_user_session(); # If confirm is not set print delete warning if ($_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'>"; //fetch all subsections $subsections = $Sections->fetch_subsections($_POST['id']); //print what will be deleted if (sizeof($subsections) > 0) { $subnets = $Subnets->fetch_section_subnets($_POST['id']); //fetch all subnets in section $num_subnets = sizeof($subnets); //number of subnets to be deleted
$resolve_config['emptyonly'] = true; # if true it will only update the ones without DNS entry! $resolve_config['subnets'] = array(); # which subnets to check - by id # example -> array(1,3,5) will only update subnets with id 1,3,5 # you can get id's and descriptions with following MySQL query: # select `id`,`description` from `subnets`; $resolve_config['verbose'] = true; # verbose response - prints results, cron will email it to you! # include required scripts require dirname(__FILE__) . '/../functions.php'; require dirname(__FILE__) . '/../../functions/classes/class.Thread.php'; # initialize objects $Database = new Database_PDO(); $Admin = new Admin($Database, false); $Subnets = new Subnets($Database); $DNS = new DNS($Database); $Result = new Result(); // set to 1 in case of errors ini_set('display_errors', 0); error_reporting(E_ERROR); # cli required if ($resolve_config['clionly'] && !defined('STDIN')) { $Result->show_cli("cli only\n", true); } elseif (!$resolve_config['clionly'] && !defined('STDIN')) { $User = new User($Database); # verify that user is logged in $User->check_user_session(); } # # If id is provided via STDIN resolve hosts for 1 subnet only,
/** * Delete section, subsections, subnets and ip addresses * * @access private * @param mixed $values * @return void */ private function section_delete($values) { # subnets class $Subnets = new Subnets($this->Database); # save old values $old_section = $this->fetch_section("id", $values['id']); # check for subsections and store all ids $all_ids = $this->get_all_section_and_subsection_ids($values['id']); //array of section + all subsections # truncate and delete all subnets in all sections, than delete sections foreach ($all_ids as $id) { $section_subnets = $Subnets->fetch_section_subnets($id); if (sizeof($section_subnets) > 0) { foreach ($section_subnets as $ss) { //delete subnet $Subnets->modify_subnet("delete", array("id" => $ss->id)); } } # delete all sections try { $this->Database->deleteRow("sections", "id", $id); } catch (Exception $e) { $this->Log->write("Section {$old_section->name} delete", "Failed to delete section {$old_section->name}<hr>" . $e->getMessage() . "<hr>" . $this->array_to_log($this->reformat_empty_array_fields($values, "NULL")), 2); $this->Result->show("danger", _("Error: ") . $e->getMessage(), false); return false; } } # write changelog $this->Log->write_changelog('section', "delete", 'success', $old_section, array()); # log $this->Log->write("Section {$old_section->name} delete", "Section {$old_section->name} deleted<hr>" . $this->array_to_log($this->reformat_empty_array_fields((array) $old_section)), 0); return true; }
<?php /** * Script to print mail notification form ********************************************/ # include required scripts require dirname(__FILE__) . '/../../functions/functions.php'; # initialize required objects $Database = new Database_PDO(); $Result = new Result(); $User = new User($Database); $Subnets = new Subnets($Database); $Tools = new Tools($Database); $Addresses = new Addresses($Database); # verify that user is logged in $User->check_user_session(); # id must be numeric is_numeric($_POST['id']) || strlen($_POST['id']) == 0 ?: $Result->show("danger", _("Invalid ID"), true); # get IP address id $id = $_POST['id']; # fetch subnet, vlan and nameservers $subnet = (array) $Subnets->fetch_subnet(null, $_POST['id']); $vlan = (array) $Tools->fetch_object("vlans", "vlanId", $subnet['vlanId']); $vrf = (array) $Tools->fetch_object("vrf", "vrfId", $subnet['vrfId']); $nameservers = (array) $Tools->fetch_object("nameservers", "id", $subnet['nameserverId']); # get all custom fields $custom_fields = $Tools->fetch_custom_fields('subnets'); # checks sizeof($subnet) > 0 ?: $Result->show("danger", _("Invalid subnet"), true); # set title $title = _('Subnet details') . ' :: ' . $Subnets->transform_address($subnet['subnet'], "dotted") . "/" . $subnet['mask'];
<?php /** * Function to add / edit / delete section ********************************************/ /* functions */ require dirname(__FILE__) . '/../../../functions/functions.php'; # initialize user object $Database = new Database_PDO(); $User = new User($Database); $Admin = new Admin($Database, false); $Subnets = new Subnets($Database); $Sections = new Sections($Database); $Addresses = new Addresses($Database); $Tools = new Tools($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['sectionId'])) { $Result->show("danger", _("Invalid ID"), true); } } else { if (!is_numeric($_POST['subnetId'])) { $Result->show("danger", _("Invalid ID"), true); } } # verify that user has permissions to add subnet if ($_POST['action'] == "add") { if ($Sections->check_permission($User->user, $_POST['sectionId']) != 3) {
<?php /* * Print edit subnet *********************/ /* functions */ require dirname(__FILE__) . '/../../../functions/functions.php'; # initialize user object $Database = new Database_PDO(); $User = new User($Database); $Admin = new Admin($Database, false); $Sections = new Sections($Database); $Subnets = new Subnets($Database); $Tools = new Tools($Database); $Result = new Result(); # verify that user is logged in $User->check_user_session(); # verify that user has permissions to add subnet if ($_POST['action'] == "add") { if ($Sections->check_permission($User->user, $_POST['sectionId']) != 3) { $Result->show("danger", _('You do not have permissions to add new subnet in this section') . "!", true, true); } } else { if ($Subnets->check_permission($User->user, $_POST['subnetId']) != 3) { $Result->show("danger", _('You do not have permissions to add edit/delete this subnet') . "!", true, true); } } /** * This script can be called from administration, subnet edit in IP details page and from IPCalc! * * From IP address list we must also provide delete button!
<?php /** * Script to print add / edit / delete users *************************************************/ /* functions */ require dirname(__FILE__) . '/../../../functions/functions.php'; # initialize user object $Database = new Database_PDO(); $User = new User($Database); $Admin = new Admin($Database); $Subnets = new Subnets($Database); $Tools = new Tools($Database); $Result = new Result(); # verify that user is logged in $User->check_user_session(); # create csrf token $csrf = $User->csrf_cookie("create", "user"); # strip tags - XSS $_POST = $User->strip_input_tags($_POST); # validate action $Admin->validate_action($_POST['action'], true); # fetch custom fields $custom = $Tools->fetch_custom_fields('users'); # fetch all languages $langs = $Admin->fetch_all_objects("lang", "l_id"); # fetch all auth types $auth_types = $Admin->fetch_all_objects("usersAuthMethod", "id"); # fetch all groups $groups = $Admin->fetch_all_objects("userGroups", "g_id"); # set header parameters and fetch user
<?php /** * Export search results ****************************/ # include required scripts require dirname(__FILE__) . '/../../../functions/functions.php'; require dirname(__FILE__) . '/../../../functions/PEAR/Spreadsheet/Excel/Writer.php'; # initialize required objects $Database = new Database_PDO(); $Result = new Result(); $User = new User($Database); $Subnets = new Subnets($Database); $Sections = new Sections($Database); $Tools = new Tools($Database); $Addresses = new Addresses($Database); # verify that user is logged in $User->check_user_session(); # fetch search term $search_term = $_REQUEST['search_term']; //initialize Pear IPv6 object require_once dirname(__FILE__) . '/../../../functions/PEAR/Net/IPv6.php'; $Net_IPv6 = new Net_IPv6(); // ipv6 ? if ($Net_IPv6->checkIPv6($search_term) != false) { $type = "IPv6"; } elseif (strlen($search_term) == 17 && substr_count($search_term, ":") == 5) { $type = "mac"; //count : -> must be 5 } else { if (strlen($search_term) == 12 && substr_count($search_term, ":") == 0 && substr_count($search_term, ".") == 0) {
<?php /** * Script to print edit / delete / new IP address * * Fetches info from database *************************************************/ # include required scripts require dirname(__FILE__) . '/../../../functions/functions.php'; # initialize required objects $Database = new Database_PDO(); $Result = new Result(); $User = new User($Database); $Subnets = new Subnets($Database); $Tools = new Tools($Database); $Addresses = new Addresses($Database); # verify that user is logged in $User->check_user_session(); # create csrf token $csrf = $User->create_csrf_cookie(); # validate action $Tools->validate_action($_POST['action']); # validate post is_numeric($_POST['subnetId']) ?: $Result->show("danger", _("Invalid subnet ID"), true, true); is_numeric($_POST['id']) || strlen($_POST['id']) == 0 ?: $Result->show("danger", _("Invalid ID"), true, true); # get posted values $subnetId = $_POST['subnetId']; $action = $_POST['action']; $id = $_POST['id']; # fetch subnet $subnet = (array) $Subnets->fetch_subnet(null, $subnetId);
$Database = new Database_PDO(); } if (!isset($User)) { $User = new User($Database); } if (!isset($Admin)) { $Admin = new Admin($Database); } if (!isset($Tools)) { $Tools = new Tools($Database); } if (!isset($Sections)) { $Sections = new Sections($Database); } if (!isset($Subnets)) { $Subnets = new Subnets($Database); } # verify that user is logged in, to guard against direct access of page and possible exploits $User->check_user_session(); # Get mask check #automated $cidrformat = isset($_GET['cidrformat']) ? $_GET['cidrformat'] : "off"; #separate option $rebuildmnr = isset($_GET['rebuildmnr']) ? $_GET['rebuildmnr'] : "off"; # read again the custom fields, if any if (!isset($custom_fields)) { $custom_fields = $Tools->fetch_custom_fields("subnets"); } # fetch all l2 domains $vlan_domains = $Admin->fetch_all_objects("vlanDomains", "id"); # load VLANs and process for easier later check $vlan_data = array(); foreach ($vlan_domains as $vlan_domain) {
<?php /* * Print resize subnet *********************/ /* functions */ require dirname(__FILE__) . '/../../../functions/functions.php'; # initialize user object $Database = new Database_PDO(); $User = new User($Database); $Admin = new Admin($Database, false); $Subnets = new Subnets($Database); $Addresses = new Addresses($Database); $Result = new Result(); # verify that user is logged in $User->check_user_session(); # id must be numeric if (!is_numeric($_POST['subnetId'])) { $Result->show("danger", _("Invalid ID"), true); } # get subnet details $subnet_old = $Subnets->fetch_subnet(null, $_POST['subnetId']); # verify that user has write permissions for subnet $subnetPerm = $Subnets->check_permission($User->user, $subnet_old->id); if ($subnetPerm < 3) { $Result->show("danger", _('You do not have permissions to resize subnet') . '!', true); } # verify $Subnets->subnet_split($subnet_old, $_POST['number'], $_POST['prefix'], $_POST['group'], $_POST['strict']); # all good $Result->show("success", _("Subnet splitted ok") . "!", true);
# verify that user is logged in $User->check_user_session(); # set sorting $sort['direction'] = 'asc'; $sort['field'] = 'ip_addr'; $sort['directionNext'] = "desc"; } else { # use required functions require '../../../functions/functions.php'; # database object $Database = new Database_PDO(); # initialize objects $Result = new Result(); $User = new User($Database); $Sections = new Sections($Database); $Subnets = new Subnets($Database); $Tools = new Tools($Database); $Addresses = new Addresses($Database); # verify that user is logged in $User->check_user_session(); # set sorting $tmp = explode("|", $_POST['direction']); $sort['field'] = $tmp[0]; $sort['direction'] = $tmp[1]; if ($sort['direction'] == "asc") { $sort['directionNext'] = "desc"; } else { $sort['directionNext'] = "asc"; } # subnet-related variables $subnet = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']);
<?php # required functions if (!is_object($User)) { require dirname(__FILE__) . '/../../../functions/functions.php'; # classes $Database = new Database_PDO(); $User = new User($Database); $Tools = new Tools($Database); $Subnets = new Subnets($Database); } # user must be authenticated $User->check_user_session(); # if direct request that redirect to tools page if ($_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest") { header("Location: " . create_link("administration", "manageRequests")); } # fetch all requests $requests = $Tools->requests_fetch(false); ?> <?php if (!$requests) { print "<blockquote style='margin-top:20px;margin-left:20px;'>"; print "<small>" . _("No IP address requests available") . "!</small><br>"; print "</blockquote>"; } else { ?>
<?php /** * firewall zone fwzones-edit.php * add, edit and delete firewall zones ******************************************/ # functions require dirname(__FILE__) . '/../../../functions/functions.php'; # initialize classes $Database = new Database_PDO(); $User = new User($Database); $Admin = new Admin($Database); $Subnets = new Subnets($Database); $Result = new Result(); $Zones = new FirewallZones($Database); # validate session parameters $User->check_user_session(); # validate $_POST['id'] values if (!preg_match('/^[0-9]+$/i', $_POST['id'])) { $Result->show("danger", _("Invalid ID. Do not manipulate the POST values!"), true); } # validate $_POST['action'] values if ($_POST['action'] != 'add' && $_POST['action'] != 'edit' && $_POST['action'] != 'delete') { $Result->show("danger", _("Invalid action. Do not manipulate the POST values!"), true); } # fetch module settings $firewallZoneSettings = json_decode($User->settings->firewallZoneSettings, true); # fetch old zone if ($_POST['action'] != 'add') { $firewallZone = $Zones->get_zone($_POST['id']); }
<?php /* * Script to print some stats on home page.... *********************************************/ # required functions if requested via AJAX if (!is_object(@$User)) { require dirname(__FILE__) . '/../../../functions/functions.php'; # classes $Database = new Database_PDO(); $User = new User($Database); $Tools = new Tools($Database); $Subnets = new Subnets($Database); $Sections = new Sections($Database); $Log = new Logging($Database); $Result = new Result(); } # user must be authenticated $User->check_user_session(); # if direct request that redirect to tools page if ($_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest") { header("Location: " . create_link("tools", "changelog")); } # changelog to syslog if ($User->settings->log != "syslog") { /* get logs */ $clogs = $Log->fetch_all_changelogs(false, "", 50); } # syslog if ($User->settings->log == "syslog") { $Result->show("warning", _("Changelog files are sent to syslog"), false);
<?php /** * Script to print mail notification form ********************************************/ # include required scripts require dirname(__FILE__) . '/../../../functions/functions.php'; # initialize required objects $Database = new Database_PDO(); $Result = new Result(); $User = new User($Database); $Subnets = new Subnets($Database); $Tools = new Tools($Database); $Addresses = new Addresses($Database); # verify that user is logged in $User->check_user_session(); # id must be numeric is_numeric($_POST['id']) || strlen($_POST['id']) == 0 ?: $Result->show("danger", _("Invalid ID"), true); # get IP address id $id = $_POST['id']; # fetch address, subnet, vlan and nameservers $address = (array) $Addresses->fetch_address(null, $id); $subnet = (array) $Subnets->fetch_subnet(null, $address['subnetId']); $vlan = (array) $Tools->fetch_object("vlans", "vlanId", $subnet['vlanId']); $nameservers = (array) $Tools->fetch_object("nameservers", "id", $subnet['nameserverId']); # get all custom fields $custom_fields = $Tools->fetch_custom_fields('ipaddresses'); # checks sizeof($address) > 0 ?: $Result->show("danger", _("Invalid ID"), true); sizeof($subnet) > 0 ?: $Result->show("danger", _("Invalid subnet"), true); # set title
<?php /** * Generate XLS file for subnet *********************************/ # include required scripts require dirname(__FILE__) . '/../../../functions/functions.php'; require dirname(__FILE__) . '/../../../functions/PEAR/Spreadsheet/Excel/Writer.php'; # initialize required objects $Database = new Database_PDO(); $Result = new Result(); $User = new User($Database); $Subnets = new Subnets($Database); $Tools = new Tools($Database); $Addresses = new Addresses($Database); # verify that user is logged in $User->check_user_session(); # we dont need any errors! //ini_set('display_errors', 0); # fetch subnet details $subnet = (array) $Subnets->fetch_subnet(null, $_GET['subnetId']); # fetch all IP addresses in subnet $addresses = $Addresses->fetch_subnet_addresses($_GET['subnetId'], "ip_addr", "asc"); # get all custom fields $custom_fields = $Tools->fetch_custom_fields('ipaddresses'); # Create a workbook $filename = "phpipam_subnet_export.xls"; $workbook = new Spreadsheet_Excel_Writer(); //formatting headers $format_header =& $workbook->addFormat(); $format_header->setBold();
<?php /* * Print edit subnet *********************/ /* functions */ require dirname(__FILE__) . '/../../../functions/functions.php'; # initialize user object $Database = new Database_PDO(); $User = new User($Database); $Admin = new Admin($Database); $Sections = new Sections($Database); $Subnets = new Subnets($Database); $Result = new Result(); # verify that user is logged in $User->check_user_session(); # ID must be numeric if (!is_numeric($_POST['subnetId'])) { $Result->show("danger", _("Invalid ID"), true, true); } # get all groups $groups = $Admin->fetch_all_objects("userGroups", "g_id"); # get subnet details $subnet = $Subnets->fetch_subnet(null, $_POST['subnetId']); ?> <script type="text/javascript"> $(document).ready(function() { /* bootstrap switch */ var switch_options = {
<?php /* * Print graph of Top IPv4 hosts by percentage **********************************************/ # required functions if (!is_object(@$User)) { require dirname(__FILE__) . '/../../../functions/functions.php'; # classes $Database = new Database_PDO(); $User = new User($Database); $Tools = new Tools($Database); $Subnets = new Subnets($Database); $Result = new Result(); } # user must be authenticated $User->check_user_session(); # set size parameters $height = 200; $slimit = 10; # if direct request include plot JS if ($_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest") { # get widget details if (!($widget = $Tools->fetch_object("widgets", "wfile", $_REQUEST['section']))) { $Result->show("danger", _("Invalid widget"), true); } # reset size and limit $height = 350; $slimit = 20; # include flot JS print '<script language="javascript" type="text/javascript" src="js/1.2/flot/jquery.flot.js"></script>';
foreach ($addresses as $k => $a) { if ($a['newStatus'] == 0) { $Scan->ping_update_lastseen($a['id']); } } } # print change if ($Scan->debugging) { print "\nAddress changes:\n----------\n"; print_r($address_change); } # all done, mail diff? if (sizeof($address_change) > 0 && $send_mail) { if (!is_object(@$Scan)) { $Database = new Database_PDO(); $Subnets = new Subnets($Database); $Addresses = new Addresses($Database); $Tools = new Tools($Database); $Scan = new Scan($Database); $Result = new Result(); // set exit flag to true $Scan->ping_set_exit(true); // set debugging $Scan->reset_debugging(false); } # check for recipients foreach ($Tools->fetch_multiple_objects("users", "role", "Administrator") as $admin) { if ($admin->mailNotify == "Yes") { $recepients[] = array("name" => $admin->real_name, "email" => $admin->email); } }
<?php /** * creates mac address from provided IP address */ # include required scripts require dirname(__FILE__) . '/../../../functions/functions.php'; # initialize required objects $Database = new Database_PDO(); $Result = new Result(); $User = new User($Database); $Subnets = new Subnets($Database); # verify that user is logged in $User->check_user_session(); # check that multicast is enabled if ($User->settings->enableMulticast != "1") { die("False"); } # validations if ($Subnets->verify_cidr($_POST['ip']) === false) { die("False"); } if ($Subnets->is_multicast($_POST['ip']) === false) { die("False"); } # get mac $text = $Subnets->create_multicast_mac($_POST['ip']); # print mas if ($text === false) { die("False"); } else {