本文整理汇总了PHP中Tools::fetch_object方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::fetch_object方法的具体用法?PHP Tools::fetch_object怎么用?PHP Tools::fetch_object使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tools
的用法示例。
在下文中一共展示了Tools::fetch_object方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: type
if ($_POST['type'] !== "src" && $_POST['type'] !== "dst") {
$Result->show("danger", _("Invalid type"), true);
}
# if type (subnets, ipaddresses) is set and id than just link
if (isset($_POST['object_type']) && isset($_POST['object_id'])) {
// parameters
$obj_type = $_POST['object_type'];
// subnets, ipaddresses
$obj_id = $_POST['object_id'];
// object identifier
$nat_id = $_POST['id'];
// nat id
$nat_type = $_POST['type'];
// src, dst
// validate object
$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);
示例2: dirname
# include funtions
require dirname(__FILE__) . '/../../functions/functions.php';
// functions and objects from phpipam
require dirname(__FILE__) . '/controllers/Common.php';
// common methods
require dirname(__FILE__) . '/controllers/Responses.php';
// exception, header and response handling
# settings
$enable_authentication = true;
# database object
$Database = new Database_PDO();
$Tools = new Tools($Database);
# exceptions/result object
$Response = new Responses();
# get phpipam settings
$settings = $Tools->fetch_object("settings", "id", 1);
# set empty controller for options
if ($_SERVER['REQUEST_METHOD'] == "OPTIONS") {
if (!isset($_GET['controller']) || $_GET['controller'] == "") {
$_GET['controller'] = "Tools";
}
}
/* wrap in a try-catch block to catch exceptions */
try {
/* Validate application ---------- */
// verify that API is enabled on server
if ($settings->api != 1) {
$Response->throw_exception(503, "API server disabled");
}
# fetch app
$app = $Tools->fetch_object("api", "app_id", $_GET['app_id']);
示例3: Result
$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
$title = _('IP address details') . ' :: ' . $address['ip'];
# address
$content[] = "• " . _('IP address') . ": \t\t {$address['ip']}/{$subnet['mask']}";
# description
empty($address['description']) ?: ($content[] = "• " . _('Description') . ":\t\t {$address['description']}");
# hostname
empty($address['dns_name']) ?: ($content[] = "• " . _('Hostname') . ": \t {$address['dns_name']}");
# subnet desc
示例4: print_subnets_tools
/**
* Print all subnets in section
*
* @access public
* @param array $user
* @param array $subnets
* @param array $custom_fields
* @return none - print
*/
public function print_subnets_tools($user, $subnets, $custom_fields)
{
# tools object
$Tools = new Tools($this->Database);
# set hidden fields
$this->get_settings();
$hidden_fields = json_decode($this->settings->hiddenCustomFields, true);
$hidden_fields = is_array($hidden_fields['subnets']) ? $hidden_fields['subnets'] : array();
# set html array
$html = array();
# root is 0
$rootId = 0;
# remove all not permitted!
if (sizeof($subnets) > 0) {
foreach ($subnets as $k => $s) {
$permission = $this->check_permission($user, $s->id);
if ($permission == 0) {
unset($subnets[$k]);
}
}
}
# create loop array
if (sizeof($subnets) > 0) {
foreach ($subnets as $item) {
$item = (array) $item;
$children_subnets[$item['masterSubnetId']][] = $item;
}
} else {
return false;
}
# loop will be false if the root has no children (i.e., an empty menu!)
$loop = !empty($children_subnets[$rootId]);
# initializing $parent as the root
$parent = $rootId;
$parent_stack = array();
# return table content (tr and td's)
while ($loop && (($option = each($children_subnets[$parent])) || $parent > $rootId)) {
# repeat
$repeat = str_repeat(" - ", count($parent_stack));
# dashes
if (count($parent_stack) == 0) {
$dash = "";
} else {
$dash = "-";
}
if (count($parent_stack) == 0) {
$margin = "0px";
$padding = "0px";
} else {
# padding
$padding = "10px";
# margin
$margin = count($parent_stack) * 10 - 10;
$margin = $margin * 2;
$margin = $margin . "px";
}
# count levels
$count = count($parent_stack) + 1;
# get VLAN
$vlan = (array) $Tools->fetch_object("vlans", "vlanId", $option['value']['vlanId']);
if (@$vlan[0] === false) {
$vlan['number'] = "";
}
# no VLAN
# description
$description = strlen($option['value']['description']) == 0 ? "/" : $option['value']['description'];
# print table line
if (strlen($option['value']['subnet']) > 0) {
$html[] = "<tr>";
//which level?
if ($count == 1) {
# is folder?
if ($option['value']['isFolder'] == 1) {
$html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-sfolder fa-pad-right-3 fa-folder-open'></i> <a href='" . create_link("folder", $option['value']['sectionId'], $option['value']['id']) . "'> {$description}</a></td>";
$html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-sfolder fa-pad-right-3 fa-folder-open'></i> {$description}</td>";
} else {
# last?
if (!empty($children_subnets[$option['value']['id']])) {
$html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-gray fa-pad-right-3 fa-folder-open-o'></i><a href='" . create_link("subnets", $option['value']['sectionId'], $option['value']['id']) . "'> " . $this->transform_to_dotted($option['value']['subnet']) . "/" . $option['value']['mask'] . "</a></td>";
$html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-gray fa-pad-right-3 fa-folder-open-o'></i> {$description}</td>";
} else {
$html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-gray fa-pad-right-3 fa-angle-right'></i><a href='" . create_link("subnets", $option['value']['sectionId'], $option['value']['id']) . "'> " . $this->transform_to_dotted($option['value']['subnet']) . "/" . $option['value']['mask'] . "</a></td>";
$html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-gray fa-pad-right-3 fa-angle-right'></i> {$description}</td>";
}
}
} else {
# is folder?
if ($option['value']['isFolder'] == 1) {
# last?
$html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-gray fa-pad-right-3 fa-folder-open'></i> <a href='" . create_link("folder", $option['value']['sectionId'], $option['value']['id']) . "'> {$description}</a></td>";
$html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-gray fa-pad-right-3 fa-folder-open'></i> {$description}</td>";
//.........这里部分代码省略.........
示例5: User
# 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>';
print '<script language="javascript" type="text/javascript" src="js/1.2/flot/jquery.flot.categories.js"></script>';
print '<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="js/1.2/flot/excanvas.min.js"></script><![endif]-->';
# and print title
print "<div class='container'>";
print "<h4 style='margin-top:40px;'>{$widget->wtitle}</h4><hr>";
print "</div>";
}
$type = "IPv4";
示例6: array
}
//insert to ipaddresses table
$values = array("action" => "add", "ip_addr" => $Addresses->transform_address($_POST['ip_addr'], "decimal"), "subnetId" => $_POST['subnetId'], "description" => @$_POST['description'], "dns_name" => @$_POST['dns_name'], "mac" => @$_POST['mac'], "owner" => @$_POST['owner'], "state" => @$_POST['state'], "switch" => @$_POST['switch'], "port" => @$_POST['port'], "note" => @$_POST['note']);
if (!$Addresses->modify_address($values)) {
$Result->show("danger", _("Failed to create IP address"), true);
}
//accept message
$values2 = array("id" => $_POST['requestId'], "processed" => 1, "accepted" => 1, "adminComment" => $comment);
if (!$Admin->object_modify("requests", "edit", "id", $values2)) {
$Result->show("danger", _("Cannot confirm IP address"), true);
} else {
$Result->show("success", _("IP request accepted/rejected"), false);
}
# send mail
//save subnt
$tmp['subnetId'] = $_POST['subnetId'];
unset($_POST['subnetId']);
// gateway
$gateway = $Subnets->find_gateway($tmp['subnetId']);
if ($gateway !== false) {
$tmp['gateway'] = $Subnets->transform_address($gateway->ip_addr, "dotted");
}
//set vlan
$vlan = $Tools->fetch_object("vlans", "vlanId", $subnet['vlanId']);
$tmp['vlan'] = $vlan == false ? "" : $vlan->number . " - " . $vlan->description;
//set dns
$dns = $Tools->fetch_object("nameservers", "id", $subnet['nameserverId']);
$tmp['dns'] = $dns == false ? "" : $dns->description . " <br> " . str_replace(";", ", ", $dns->namesrv1);
$_POST = array_merge($tmp, $_POST);
$Tools->ip_request_send_mail("accept", $_POST);
}
示例7: Result
# 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'];
# address
$content[] = "• " . _('Subnet') . ": \t\t " . $Subnets->transform_address($subnet['subnet'], "dotted") . "/" . $subnet['mask'];
# description
empty($subnet['description']) ?: ($content[] = "• " . _('Description') . ":\t\t {$subnet['description']}");
# gateway
$gateway = $Subnets->find_gateway($subnet['id']);
if ($gateway !== false) {
示例8: Result
$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 and vlan
$address = (array) $Addresses->fetch_address(null, $id);
$subnet = (array) $Subnets->fetch_subnet(null, $address['subnetId']);
$vlan = (array) $Tools->fetch_object("vlans", "vlanId", @$address['vlanId']);
# 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
$title = _('IP address details') . ' :: ' . $address['ip'];
# address
$content[] = "• " . _('IP address') . ": \t {$address['ip']}/{$subnet['mask']}";
# description
empty($address['description']) ?: ($content[] = "• " . _('Description') . ":\t {$address['description']}");
# hostname
empty($address['dns_name']) ?: ($content[] = "• " . _('Hostname') . ": \t {$address['dns_name']}");
# subnet desc
$s_descrip = empty($address['description']) ? "" : " (" . $subnet['description'] . ")";
示例9: Result
# initialize install class
$Database = new Database_PDO();
$Result = new Result();
$Tools = new Tools($Database);
$Install = new Install($Database);
# reset url for base
$url = $Result->createURL();
# If User is not available create fake user object for create_link!
if (!is_object(@$User)) {
$User = new StdClass();
@($User->settings->prettyLinks = "No");
}
# if already installed than redirect !
if ($Install->check_db_connection(false) && $Install->check_table("vrf", false)) {
# check if installation parts 2 and 3 are running, otherwise die!
$admin = $Tools->fetch_object("users", "id", 1);
if ($admin->password != '$6$rounds=3000$JQEE6dL9NpvjeFs4$RK5X3oa28.Uzt/h5VAfdrsvlVe.7HgQUYKMXTJUsud8dmWfPzZQPbRbk8xJn1Kyyt4.dWm4nJIYhAV2mbOZ3g.') {
header("Location: " . create_link("dashboard"));
die;
}
}
# printout
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<base href="<?php
print $url . BASE;
?>
示例10: trim
if ($_POST['type'] !== "src" && $_POST['type'] !== "dst") {
$Result->show("danger", _("Invalid NAT direction"), true);
}
# set searchterm
if (isset($_REQUEST['ip'])) {
// trim
$_REQUEST['ip'] = trim($_REQUEST['ip']);
// escape
$_REQUEST['ip'] = htmlspecialchars($_REQUEST['ip']);
$search_term = @$search_term == "search" ? "" : $_REQUEST['ip'];
}
# change * to % for database wildchar
$search_term = trim($search_term);
$search_term = str_replace("*", "%", $search_term);
# fetch old details
$nat = $Tools->fetch_object("nat", "id", $_POST['id']);
$nat->src = json_decode($nat->src, true);
$nat->dst = json_decode($nat->dst, true);
// identify
$type = $Admin->identify_address($search_term);
//identify address type
# reformat if IP address for search
if ($type == "IPv4") {
$search_term_edited = $Tools->reformat_IPv4_for_search($search_term);
} elseif ($type == "IPv6") {
$search_term_edited = $Tools->reformat_IPv6_for_search($search_term);
}
//reformat the IPv4 address!
# search addresses
$result_addresses = $Tools->search_addresses($search_term, $search_term_edited['high'], $search_term_edited['low'], array());
# search subnets
示例11: foreach
$custom = $Tools->fetch_custom_fields('vlans');
//if it already exist die
if ($User->settings->vlanDuplicate == 0 && $_POST['action'] == "add") {
$check_vlan = $Admin->fetch_multiple_objects("vlans", "domainId", $_POST['domainId'], "vlanId");
if ($check_vlan !== false) {
foreach ($check_vlan as $v) {
if ($v->number == $_POST['number']) {
$Result->show("danger", _("VLAN already exists"), true);
}
}
}
}
// if unique required
if (isset($_POST['unique'])) {
if ($_POST['unique'] == "on") {
if ($Tools->fetch_object("vlans", "number", $_POST['number']) !== false) {
$Result->show("danger", _("VLAN already exists in another domain!"), true);
}
}
}
//if number too high
if ($_POST['number'] > $User->settings->vlanMax && $_POST['action'] != "delete") {
$Result->show("danger", _('Highest possible VLAN number is ') . $settings['vlanMax'] . '!', true);
}
if ($_POST['action'] == "add") {
if ($_POST['number'] < 0) {
$Result->show("danger", _('VLAN number cannot be negative') . '!', true);
} elseif (!is_numeric($_POST['number'])) {
$Result->show("danger", _('Not number') . '!', true);
}
}
示例12: implode
$errors[] = $e->getMessage();
}
}
# none and errors
if (sizeof($found) == 0 && isset($errors)) {
$Result->show("info", _("No new subnets found") . "</div><hr><div class='alert alert-warning'>" . implode("<hr>", $errors) . "</div>", true, $ajax_loaded);
} elseif (sizeof($found) == 0) {
$Result->show("info", _("No new subnets found") . "!", true, $ajax_loaded);
} else {
# fetch all permitted domains
$permitted_domains = $Sections->fetch_section_domains($_POST['sectionId']);
# fetch all belonging vlans
$cnt = 0;
foreach ($permitted_domains as $k => $d) {
//fetch domain
$domain = $Tools->fetch_object("vlanDomains", "id", $d);
// fetch vlans and append
$vlans = $Tools->fetch_multiple_objects("vlans", "domainId", $domain->id, "number");
//save to array
$out[$d]['domain'] = $domain;
$out[$d]['vlans'] = $vlans;
//count add
$cnt++;
}
//filter out empty
$permitted_domains = array_filter($out);
# fetch all permitted domains
$permitted_nameservers = $Sections->fetch_section_nameserver_sets($_POST['sectionId']);
# fetch all belonging nameserver set
$cnt = 0;
# Only parse nameserver if any exists
示例13: phpipamSNMP
# scan disabled
if ($User->settings->enableSNMP != "1") {
$Result->show("danger", _("SNMP module disbled"), true);
}
# admin check
if ($User->is_admin() !== true) {
$Result->show("danger", _('Admin privileges required'), true);
}
# set class
$Snmp = new phpipamSNMP();
# domain Id must be int
if (!is_numeric($_POST['domainId'])) {
$Result->show("danger", _("Invalid domain Id"), true);
}
# fetch domain
$domain = $Tools->fetch_object("vlanDomains", "id", $_POST['domainId']);
if ($domain === false) {
$Result->show("danger", _("Invalid domain Id"), true);
}
# get existing vlans
$existing_vlans = $Tools->fetch_multiple_objects("vlans", "domainId", $domain->id, "vlanId");
if ($existing_vlans !== false) {
foreach ($existing_vlans as $v) {
$ex_vlans[$v->number] = $name;
}
}
// no errors
error_reporting(E_ERROR);
# set devices
foreach ($_POST as $k => $p) {
if (strpos($k, "device-") !== false) {
示例14:
}
if ($_POST['action'] == "add" || $_POST['action'] == "edit") {
// name
if (strlen($_POST['name']) < 3) {
$Result->show("danger", _("Name must have at least 3 characters"), true);
}
// number
if (!is_numeric($_POST['start'])) {
$Result->show("danger", _("Start must be numeric"), true);
}
if (!is_numeric($_POST['stop'])) {
$Result->show("danger", _("Stop must be numeric"), true);
}
// check master
if ($_POST['master'] != 0) {
$master_prefix = $Tools->fetch_object("pstnPrefixes", "id", $_POST['master']);
if ($master_prefix === false) {
$Result->show("danger", _("Invalid master prefix"), true);
}
// ranges
$master_prefix->prefix_raw = $Tools->prefix_normalize($master_prefix->prefix);
$master_prefix->prefix_raw_start = $Tools->prefix_normalize($master_prefix->prefix . $master_prefix->start);
$master_prefix->prefix_raw_stop = $Tools->prefix_normalize($master_prefix->prefix . $master_prefix->stop);
$_POST['prefix_raw'] = $Tools->prefix_normalize($_POST['prefix']);
$_POST['prefix_raw_start'] = $Tools->prefix_normalize($_POST['prefix'] . $_POST['start']);
$_POST['prefix_raw_stop'] = $Tools->prefix_normalize($_POST['prefix'] . $_POST['stop']);
// prefix must be inside range
if ($_POST['prefix_raw_start'] == $master_prefix->prefix_raw_start && $_POST['prefix_raw_stop'] == $master_prefix->prefix_raw_stop) {
$Result->show("danger", _("Prefix cannot be same as master"), true);
}
if ($_POST['prefix_raw_start'] < $master_prefix->prefix_raw_start || $_POST['prefix_raw_stop'] > $master_prefix->prefix_raw_stop) {
示例15:
$subnet_text = '';
if ($subnet['isFolder']) {
$subnet_text = $subnet['description'] . " (folder)";
} else {
$subnet_text = $subnet['ip'] . "/" . $subnet['mask'];
}
$worksheet->write($lineCount, $rowCount, $subnet_text, $format_text);
$rowCount++;
}
if (isset($_GET['description']) && $_GET['description'] == "on") {
$worksheet->write($lineCount, $rowCount, $subnet['description'], $format_text);
$rowCount++;
}
if (isset($_GET['VLAN']) && $_GET['VLAN'] == "on") {
// get VLAN
$vlan = (array) $Tools->fetch_object("vlans", "vlanId", $subnet['vlanId']);
/* if(@$vlan[0]===false) { $vlan['number'] = "NA"; $vlan['name'] = "NA"; } # no VLAN
$worksheet->write($lineCount, $rowCount, $vlan['number']." [".$vlan['name']."]", $format_text); */
if (@$vlan[0] === false) {
$vlan['number'] = "NA";
}
# no VLAN
$worksheet->write($lineCount, $rowCount, $vlan['number'], $format_text);
$rowCount++;
// VLAN Domain
$vlan_domain = (array) $Tools->fetch_object("vlanDomains", "id", $vlan['domainId']);
$worksheet->write($lineCount, $rowCount, $vlan_domain['name'], $format_text);
$rowCount++;
}
if (isset($_GET['VRF']) && $_GET['VRF'] == "on") {
// get vrf