コード例 #1
0
/**
 *	print breadcrumbs
 */
function printBreadcrumbs($req)
{
    # subnets
    if (isset($req['ipaddrid'])) {
        if (isset($req['subnetId'])) {
            # get all parents
            $parents = getAllParents($req['subnetId']);
            print "<ul class='breadcrumb'>";
            # remove root - 0
            array_shift($parents);
            # section details
            if (is_numeric($req['section'])) {
                $section = getSectionDetailsById($req['section']);
            } else {
                $section = getSectionDetailsByName($req['section']);
            }
            # if name is provided
            print "\t<li><a href='subnets/{$section['id']}/'>{$section['name']}</a> <span class='divider'></span></li>";
            # section name
            foreach ($parents as $parent) {
                $subnet = getSubnetDetailsById($parent);
                if ($subnet['isFolder'] == 1) {
                    print "\t<li><a href='subnets/{$section['id']}/{$parent}/'><i class='icon-folder-open icon-gray'></i> {$subnet['description']}</a> <span class='divider'></span></li>";
                    # subnets in between
                } else {
                    print "\t<li><a href='subnets/{$section['id']}/{$parent}/'>{$subnet['description']} (" . Transform2long($subnet['subnet']) . '/' . $subnet['mask'] . ")</a> <span class='divider'></span></li>";
                    # subnets in between
                }
            }
            # parent subnet
            $subnet = getSubnetDetailsById($req['subnetId']);
            print "\t<li><a href='subnets/{$section['id']}/{$subnet['id']}/'>{$subnet['description']} (" . Transform2long($subnet['subnet']) . '/' . $subnet['mask'] . ")</a> <span class='divider'></span></li>";
            # active subnet
            # ip
            $ip = getIpAddrDetailsById($req['ipaddrid']);
            print "\t<li class='active'>{$ip['ip_addr']}</li>";
            # IP address
            print "</ul>";
        }
    } elseif ($req['page'] == "subnets") {
        if (isset($req['subnetId'])) {
            # get all parents
            $parents = getAllParents($req['subnetId']);
            print "<ul class='breadcrumb'>";
            # remove root - 0
            array_shift($parents);
            # section details
            if (is_numeric($req['section'])) {
                $section = getSectionDetailsById($req['section']);
            } else {
                $section = getSectionDetailsByName($req['section']);
            }
            # if name is provided
            print "\t<li><a href='subnets/{$section['id']}/'>{$section['name']}</a> <span class='divider'></span></li>";
            # section name
            foreach ($parents as $parent) {
                $subnet = getSubnetDetailsById($parent);
                if ($subnet['isFolder'] == 1) {
                    print "\t<li><a href='subnets/{$section['id']}/{$parent}/'><i class='icon-folder-open icon-gray'></i> {$subnet['description']}</a> <span class='divider'></span></li>";
                    # subnets in between
                } else {
                    print "\t<li><a href='subnets/{$section['id']}/{$parent}/'>{$subnet['description']} (" . Transform2long($subnet['subnet']) . '/' . $subnet['mask'] . ")</a> <span class='divider'></span></li>";
                    # subnets in between
                }
            }
            $subnet = getSubnetDetailsById($req['subnetId']);
            print "\t<li class='active'>{$subnet['description']} (" . Transform2long($subnet['subnet']) . '/' . $subnet['mask'] . ")</li>";
            # active subnet
            print "</ul>";
        }
    }
    # subnets
    if ($req['page'] == "folder") {
        if (isset($req['subnetId'])) {
            # get all parents
            $parents = getAllParents($req['subnetId']);
            print "<ul class='breadcrumb'>";
            # remove root - 0
            array_shift($parents);
            # section details
            if (is_numeric($req['section'])) {
                $section = getSectionDetailsById($req['section']);
            } else {
                $section = getSectionDetailsByName($req['section']);
            }
            # if name is provided
            print "\t<li><a href='subnets/{$section['id']}/'>{$section['name']}</a> <span class='divider'></span></li>";
            # section name
            foreach ($parents as $parent) {
                $subnet = getSubnetDetailsById($parent);
                print "\t<li><a href='subnets/{$section['id']}/{$parent}/'><i class='icon-folder-open icon-gray'></i> {$subnet['description']}</a> <span class='divider'></span></li>";
                # subnets in between
            }
            $subnet = getSubnetDetailsById($req['subnetId']);
            print "\t<li class='active'>{$subnet['description']}</li>";
            # active subnet
            print "</ul>";
        }
    } else {
        if ($req['page'] == "admin") {
        } else {
            if ($req['page'] == "tools") {
                if (isset($req['tpage'])) {
                    print "<ul class='breadcrumb'>";
                    print "\t<li><a href='tools/'>" . _('Tools') . "</a> <span class='divider'></span></li>";
                    print "\t<li class='active'>{$req['tpage']}></li>";
                    print "</ul>";
                }
            }
        }
    }
}
コード例 #2
0
ファイル: ipDetails.php プロジェクト: retexica/phpipam
    $settings = getAllSettings();
}
/* filter input */
$_GET = filter_user_input($_GET, true, true, false);
/* must be numeric */
if (!is_numeric($_GET['subnetId'])) {
    die('<div class="alert alert-danger">' . _("Invalid ID") . '</div>');
}
if (!is_numeric($_GET['section'])) {
    die('<div class="alert alert-danger">' . _("Invalid ID") . '</div>');
}
if (!is_numeric($_GET['ipaddrid'])) {
    die('<div class="alert alert-danger">' . _("Invalid ID") . '</div>');
}
# get IP address details
$ip = getIpAddrDetailsById($_GET['ipaddrid']);
$subnet = getSubnetDetailsById($_GET['subnetId']);
$section = getSectionDetailsById($_GET['section']);
# get all selected fields for IP print
$setFieldsTemp = getSelectedIPaddrFields();
// format them to array!
$setFields = explode(";", $setFieldsTemp);
# get all custom fields
$myFields = getCustomFields('ipaddresses');
# set ping statuses
$statuses = explode(";", $settings['pingStatus']);
# permissions
$permission = checkSubnetPermission($_GET['subnetId']);
# section permissions
$permissionsSection = checkSectionPermission($_GET['section']);
# if 0 die
コード例 #3
0
 * otherwise format the $ip field
 *
 */
if ($action == "all-add") {
    $details = array("ip_addr" => transform2long($id), "description" => "", "dns_name" => "", "owner" => "", "switch" => "", "port" => "");
} else {
    if ($action == "add") {
        $first = getFirstAvailableIPAddress($subnetId);
        if (!$first) {
            $first = "";
        } else {
            $first = transform2long($first);
        }
        $details = array("ip_addr" => $first, "description" => "", "dns_name" => "", "owner" => "", "switch" => "", "port" => "");
    } else {
        $details = getIpAddrDetailsById($id);
    }
}
/**
 *	Get first available IP address!
 */
/* Set title and button text */
if ($action == "add") {
    $btnName = _("add");
    $act = "add";
} else {
    if ($action == "all-add") {
        $btnName = _("add");
        $act = "add";
    } else {
        if ($action == "edit") {
コード例 #4
0
ファイル: pingCheck.php プロジェクト: krys1976/phpipam-1
/* include required scripts */
require_once '../../functions/functions.php';
// <eNovance>
require_once '../../functions/dbfunctions.php';
global $db;
// </eNovance>
/* verify that user is logged in */
isUserAuthenticated(false);
// verify that user has write access
$subnetPerm = checkSubnetPermission($_POST['subnetId']);
if ($subnetPerm < 2) {
    echo _("error") . ":" . _("Insufficient permissions");
    die;
}
//get IP address details
$ip = getIpAddrDetailsById($_POST['id']);
//verify that pign path is correct
if (!file_exists($pathPing)) {
    $pingError = true;
}
//try to ping it
if (pingHost($ip['ip_addr'], 1) == '0') {
    $status = "Online";
    @updateLastSeen($_POST['id']);
    // <eNovance>
    // Set the new state of an ip addresse
    if (intval($ip['state']) == 0) {
        $database = new database($db['host'], $db['user'], $db['pass'], $db['name']);
        $query = 'UPDATE ipaddresses SET state = 1 WHERE id = ' . $ip['id'] . ';';
        $database->executeQuery($query);
    }
コード例 #5
0
/**
 * Modify ( add / edit / delete ) IP address
 */
function modifyIpAddress($ip)
{
    global $database;
    /* set query, open db connection and fetch results */
    $query = SetInsertQuery($ip);
    /* save old if delete */
    if ($ip['action'] == "delete") {
        $dold = getIpAddrDetailsById($ip['id']);
    } elseif ($ip['action'] == "edit") {
        $old = getIpAddrDetailsById($ip['id']);
    }
    /* execute */
    try {
        $id = $database->executeQuery($query, true);
    } catch (Exception $e) {
        print "<div class='alert alert-danger'>" . _('Error') . ": " . $e->getMessage() . "</div>";
        //save changelog
        writeChangelog('ip_addr', $ip['action'], 'error', $old, $new);
        return false;
    }
    /* for changelog */
    if ($ip['action'] == "add") {
        $ip['id'] = $id;
        writeChangelog('ip_addr', $ip['action'], 'success', array(), $ip);
    } elseif ($ip['action'] == "delete") {
        writeChangelog('ip_addr', $ip['action'], 'success', $dold, array());
    } else {
        writeChangelog('ip_addr', $ip['action'], 'success', $old, $ip);
    }
    # success
    return true;
}
コード例 #6
0
ファイル: ipDetails.php プロジェクト: btorresgil/phpipam
<?php

/**
 * Script to display IP address info and history
 ***********************************************/
/* verify that user is authenticated! */
isUserAuthenticated();
# get site settings
if (sizeof($settings) == 0) {
    $settings = getAllSettings();
}
# get IP address details
$ip = getIpAddrDetailsById($_REQUEST['ipaddrid']);
$subnet = getSubnetDetailsById($_REQUEST['subnetId']);
$section = getSectionDetailsById($_REQUEST['section']);
# get all selected fields for IP print
$setFieldsTemp = getSelectedIPaddrFields();
// format them to array!
$setFields = explode(";", $setFieldsTemp);
# get all custom fields
$myFields = getCustomFields('ipaddresses');
# set ping statuses
$statuses = explode(";", $settings['pingStatus']);
# permissions
$permission = checkSubnetPermission($_REQUEST['subnetId']);
# section permissions
$permissionsSection = checkSectionPermission($_REQUEST['section']);
# if 0 die
if ($permission == "0") {
    die("<div class='alert alert-danger'>" . _('You do not have permission to access this network') . "!</div>");
}
コード例 #7
0
ファイル: mailNotifyIP.php プロジェクト: krys1976/phpipam-1
 * Script to print mail notification form
 ********************************************/
/* use required functions */
require_once '../../functions/functions.php';
/* First chech referer and requested with */
CheckReferrer();
/* verify that user is authenticated! */
isUserAuthenticated(false);
/* get all site settings */
$settings = getAllSettings();
/* user details */
$userDetails = getActiveUserDetails();
/* get IP address id */
$id = $_REQUEST['id'];
/* fetch all IP address details */
$ip = getIpAddrDetailsById($id);
$subnet = getSubnetDetailsById($ip['subnetId']);
/* get VLAN details */
$subnet['VLAN'] = subnetGetVLANdetailsById($subnet['vlanId']);
$subnet['vlan'] = $subnet['VLAN']['number'];
if (!empty($subnet['VLAN']['name'])) {
    $subnet['vlan'] .= ' (' . $subnet['VLAN']['name'] . ')';
}
/* set title */
$title = _('IP address details') . ' :: ' . $ip['ip_addr'];
/* Preset content */
$content .= '&bull; ' . _('IP address') . ': ' . "\t" . $ip['ip_addr'] . '/' . $subnet['mask'] . "\n";
# desc
if (!empty($ip['description'])) {
    $content .= '&bull; ' . _('Description') . ':' . "\t" . $ip['description'] . "\n";
}
コード例 #8
0
/**
 * Modify ( add / edit / delete ) IP address
 */
function modifyIpAddress($ip)
{
    global $db;
    # get variables from config file
    $database = new database($db['host'], $db['user'], $db['pass'], $db['name']);
    /* escape special characters */
    $ip['description'] = mysqli_real_escape_string($database, $ip['description']);
    $ip['note'] = mysqli_real_escape_string($database, $ip['note']);
    /* set query, open db connection and fetch results */
    $query = SetInsertQuery($ip);
    /* save old if delete */
    if ($ip['action'] == "delete") {
        $dold = getIpAddrDetailsById($ip['id']);
    } elseif ($ip['action'] == "edit") {
        $old = getIpAddrDetailsById($ip['id']);
    }
    /* execute */
    try {
        $id = $database->executeQuery($query, true);
    } catch (Exception $e) {
        $error = $e->getMessage();
        print "<div class='alert alert-danger'>" . _('Error') . ": {$error}</div>";
        //save changelog
        writeChangelog('ip_addr', $ip['action'], 'error', $old, $new);
        return false;
    }
    /* for changelog */
    if ($ip['action'] == "add") {
        $ip['id'] = $id;
        writeChangelog('ip_addr', $ip['action'], 'success', array(), $ip);
    } elseif ($ip['action'] == "delete") {
        writeChangelog('ip_addr', $ip['action'], 'success', $dold, array());
    } else {
        writeChangelog('ip_addr', $ip['action'], 'success', $old, $ip);
    }
    # success
    return true;
}