本文整理汇总了PHP中IdentifyAddress函数的典型用法代码示例。如果您正苦于以下问题:PHP IdentifyAddress函数的具体用法?PHP IdentifyAddress怎么用?PHP IdentifyAddress使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IdentifyAddress函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkSubnetPermission
/* verify that user has write permissions for subnet */
$subnetPerm = checkSubnetPermission($_REQUEST['subnetId']);
if ($subnetPerm < 3) {
die('<div class="alert alert-danger">' . _('You do not have permissions to resize subnet') . '!</div>');
}
/* verify post */
CheckReferrer();
# get subnet details
$subnet = getSubnetDetailsById($_POST['subnetId']);
# check if it has slaves - if yes it cannot be splitted!
$slaves = getAllSlaveSubnetsBySubnetId($_POST['subnetId']);
if (sizeof($slaves) > 0) {
die("<div class='alert alert-warning'>" . 'Only subnets that have no nested subnets can be splitted' . "!</div>");
}
# calculate max split
$type = IdentifyAddress(transform2long($subnet['subnet']));
# type for max resize
if ($type == "IPv4") {
$maxMask = "30";
$type = 0;
} else {
$maxMask = "126";
$type = 1;
}
$n = 2;
# step
$m = 0;
# array id
for ($mask = $subnet['mask'] + 1; $mask <= $maxMask; $mask++) {
# set vars
$opts[$m]['mask'] = $mask;
示例2: searchSubnets
/**
* Search subnets
*/
function searchSubnets($searchterm, $searchTermEdited = "")
{
global $database;
# get custom subnet fields
$myFields = getCustomFields('subnets');
$custom = '';
if (sizeof($myFields) > 0) {
/* set inserts for custom */
foreach ($myFields as $myField) {
$custom .= ' or `' . $myField['name'] . '` like "%' . $searchterm . '%" ';
}
}
/* set query */
if ($searchTermEdited['low'] == 0 && $searchTermEdited['high'] == 0) {
$query[] = 'select * from `subnets` where `description` like "%' . $searchterm . '%" ' . $custom . ';';
} else {
$query[] = 'select * from `subnets` where `description` like "%' . $searchterm . '%" or `subnet` between "' . $searchTermEdited['low'] . '" and "' . $searchTermEdited['high'] . '" ' . $custom . ';';
}
/* search inside subnets even if IP does not exist! */
if ($searchTermEdited['low'] == $searchTermEdited['high']) {
$allSubnets = fetchAllSubnets();
foreach ($allSubnets as $s) {
// first verify address type
$type = IdentifyAddress($s['subnet']);
if ($type == "IPv4") {
require_once 'PEAR/Net/IPv4.php';
$net = Net_IPv4::parseAddress(transform2long($s['subnet']) . '/' . $s['mask']);
if ($searchTermEdited['low'] > transform2decimal($net->network) && $searchTermEdited['low'] < transform2decimal($net->broadcast)) {
$query[] = "select * from `subnets` where `id` = {$s['id']}; \n";
}
}
}
}
/* execute each query */
foreach ($query as $q) {
try {
$search[] = $database->getArray($q);
} catch (Exception $e) {
$error = $e->getMessage();
}
}
/* filter results - remove blank */
$search = array_filter($search);
/* die if errors */
if (isset($error)) {
print "<div class='alert alert-danger'>" . _('Error') . ": {$error}</div>";
return false;
}
/* return result */
return $search;
}
示例3: _
</td>
<td>
<div class='checkbox info2'>
<input type="checkbox" name="unique" value="1" <?php
print $delete;
?>
><?php
print _('Unique hostname');
?>
</div>
</td>
</tr>
<?php
#get type
$type = IdentifyAddress($subnet2['subnet']);
if ($subnet2['mask'] < 31 && ($action == 'add' || substr($action, 0, 4) == "all-") && $type == "IPv4") {
?>
<!-- ignore NW /BC checks -->
<tr>
<td><?php
print _('Not strict');
?>
</td>
<td>
<div class='checkbox info2'>
<input type="checkbox" name="nostrict" value="yes"><?php
print _('Permit adding network/broadcast as IP');
?>
</div>
</td>
示例4: _
$hTooltip = "rel='tooltip' data-container='body' data-html='true' data-placement='left' title='" . _("Device is offline") . "<hr>" . _("Last seen") . ": " . _("Never") . "'";
} else {
$hStatus = "neutral";
$hTooltip = "rel='tooltip' data-container='body' data-html='true' data-placement='left' title='" . _("Device status unknown") . "'";
}
} else {
$hStatus = "hidden";
$hTooltip = "";
}
print "\t<td class='ipaddress'><span class='status status-{$hStatus}' {$hTooltip}></span><a href='subnets/{$_REQUEST['section']}/{$_REQUEST['subnetId']}/ipdetails/" . $ipaddress[$n]['id'] . "/'>" . Transform2long($ipaddress[$n]['ip_addr']);
if (in_array('state', $setFields)) {
print reformatIPState($ipaddress[$n]['state']);
}
print "</td>";
# resolve dns name if not provided, else print it - IPv4 only!
if (empty($ipaddress[$n]['dns_name']) and $settings['enableDNSresolving'] == 1 and IdentifyAddress($ipaddress[$n]['ip_addr']) == "IPv4") {
$dnsResolved = ResolveDnsName($ipaddress[$n]['ip_addr']);
} else {
$dnsResolved['class'] = "";
$dnsResolved['name'] = $ipaddress[$n]['dns_name'];
}
print "<td class='{$dnsResolved['class']} hostname'>{$dnsResolved['name']}</td>";
# print description - mandatory
print "<td class='description'>" . $ipaddress[$n]['description'] . "</td>";
# Print mac address icon!
if (in_array('mac', $setFields)) {
if (!empty($ipaddress[$n]['mac'])) {
print "<td class='narrow'><i class='info fa fa-gray fa-sitemap' rel='tooltip' data-container='body' title='" . _('MAC') . ": " . $ipaddress[$n]['mac'] . "'></i></td>";
} else {
print "<td class='narrow'></td>";
}
示例5: create_link
print "\t<td class='small description'><a href='" . create_link("subnets", $section['id'], $slave['id']) . "'>{$slave['description']}</a></td>";
print "\t<td><a href='" . create_link("subnets", $section['id'], $slave['id']) . "'>" . transform2long($slave['subnet']) . "/{$slave['mask']}</a></td>";
# count IP addresses
$hasSlaves = getAllSlaveSubnetsBySubnetId($slave['id']);
# slaves details are provided with ipaddressprintslaves script
if (sizeof($hasSlaves) > 0) {
$ipCount = sizeof(getIpAddressesBySubnetIdSlavesSort($slave['id']));
} else {
$ipCount = countIpAddressesBySubnetId($slave['id']);
}
//ip count - direct subnet
$calculate = calculateSubnetDetails(gmp_strval($ipCount), $slave['mask'], $slave['subnet']);
print ' <td class="small hidden-xs hidden-sm">' . $calculate['used'] . '/' . $calculate['maxhosts'] . '</td>' . "\n";
print ' <td class="small hidden-xs hidden-sm">' . $calculate['freehosts_percent'] . '</td>';
# add to sum if IPv4
if (IdentifyAddress($slave['subnet']) == "IPv4") {
$usedSum = $usedSum + $calculate['used'];
$allSum = $allSum + $calculate['maxhosts'];
}
# allow requests
if ($slave['allowRequests'] == 1) {
print '<td class="allowRequests small hidden-xs hidden-sm"><i class="fa fa-gray fa-check"></i></td>';
} else {
print '<td class="allowRequests small hidden-xs hidden-sm"><i class="fa fa-gray fa-check"></i></td>';
}
# edit
$subnetPerm = checkSubnetPermission($slave['id']);
if ($subnetPerm == 3) {
print "\t<td class='actions'>";
print "\t<div class='btn-group'>";
print "\t\t<button class='btn btn-xs btn-default editSubnet' data-action='edit' data-subnetid='" . $slave['id'] . "' data-sectionid='" . $slave['sectionId'] . "'><i class='fa fa-gray fa fa-pencil'></i></button>";
示例6: checkAdmin
<?php
/**
* Function to get RIPe info for network
********************************************/
# required functions */
require_once '../../functions/functions.php';
# verify that user is admin
checkAdmin();
# verify post
CheckReferrer();
/* http://apps.db.ripe.net/whois/lookup/ripe/inetnum/212.58.224.0-212.58.255.255.html.xml */
/* http://apps.db.ripe.net/whois/lookup/ripe/inet6num/2102:840::/32.xml */
# identify address and set proper url
$type = IdentifyAddress($_REQUEST['subnet']);
if ($type == "IPv4") {
$url = "http://apps.db.ripe.net/whois/lookup/ripe/inetnum/{$_REQUEST['subnet']}.xml";
} else {
$url = "http://apps.db.ripe.net/whois/lookup/ripe/inet6num/{$_REQUEST['subnet']}.xml";
}
/* querry ripe db and parse result */
$xml = @simplexml_load_file($url);
/* fail */
if (!$xml) {
/* save to json and return */
header("Content-type: text/javascript");
echo json_encode(array("Error" => "Subnet not present in RIPE DB<br>Error opening URL {$url}"));
} else {
foreach ($xml->objects->object[0]->attributes->children() as $m => $subtag) {
$a = (string) $subtag->attributes()->name;
$b = (string) $subtag->attributes()->value;
示例7: str_replace
$searchTerm = str_replace("*", "%", $searchTerm);
// sanitize
/* check if mac address */
if (strlen($searchTerm) == 17) {
//count : -> must be 5
if (substr_count($searchTerm, ":") == 5) {
$type = "mac";
}
} else {
if (strlen($searchTerm) == 12) {
//no dots or : -> mac without :
if (substr_count($searchTerm, ":") == 0 && substr_count($searchTerm, ".") == 0) {
$type = "mac";
}
} else {
$type = IdentifyAddress($searchTerm);
}
}
# identify address type
# reformat
if ($type == "IPv4") {
$searchTermEdited = reformatIPv4forSearch($searchTerm);
} else {
if ($type == "mac") {
} else {
$searchTermEdited = reformatIPv6forSearch($searchTerm);
}
}
# reformat the IPv4 address!
# check also subnets!
$subnets = searchSubnets($searchTerm, $searchTermEdited);
示例8: Transform2decimal
/**
* Transform IP address from dotted to decimal (10.2.1.0 -> 167903488)
*/
function Transform2decimal($ip)
{
if (IdentifyAddress($ip) == "IPv4") {
return sprintf("%u", ip2long($ip));
} else {
return ip2long6($ip);
}
}
示例9: isUserAuthenticated
***************************/
/* required functions */
require_once '../../../functions/functions.php';
/* verify that user is logged in */
isUserAuthenticated(false);
/* verify that user has write permissions for subnet */
$subnetPerm = checkSubnetPermission($_REQUEST['subnetId']);
if ($subnetPerm < 2) {
die('<div class="pHeader">Error</div><div class="alert alert-danger">' . _('You do not have permissions to modify hosts in this subnet') . '!</div><div class="pFooter"><button class="btn btn-sm btn-default hidePopups">' . _('Cancel') . '</button></div>');
}
/* verify post */
CheckReferrer();
# get subnet details
$subnet = getSubnetDetailsById($_POST['subnetId']);
# IPv6 is not supported
if (IdentifyAddress($subnet['subnet']) == "IPv6") {
die('<div class="pHeader">Error</div><div class="alert alert-danger">' . _('IPv6 scanning is not supported') . '!</div><div class="pFooter"><button class="btn btn-sm btn-default hidePopups">' . _('Cancel') . '</button></div>');
}
# get all IP addresses
$ip_addr = getIpAddressesBySubnetId($_POST['subnetId']);
?>
<!-- header -->
<div class="pHeader"><?php
print _('Scan subnet');
?>
</div>
<!-- content -->
示例10: gmp_strval
$diff = gmp_strval(gmp_sub($slaves[$m + 1]['subnet'], gmp_strval(gmp_add($slave['subnet'], $slave['maxip']))));
# if diff print free space
if ($diff > 0) {
print "<tr class='success'>";
print "\t<td></td>";
print "\t<td class='small description'><a href='#' data-sectionId='{$section['id']}' data-masterSubnetId='{$subnetId}' class='btn btn-sm btn-default createfromfree' data-cidr='" . getFirstPossibleSubnet(transform2long(gmp_strval(gmp_add($slave['maxip'], $slave['subnet']))), $diff, false) . "'><i class='fa fa-plus'></i></a> " . _('Free space') . "</td>";
print "\t<td colspan='5'>" . transform2long(gmp_strval(gmp_add($slave['maxip'], $slave['subnet']))) . " - " . transform2long(gmp_strval(gmp_add(gmp_add($slave['maxip'], $slave['subnet']), gmp_sub($diff, 1)))) . " ( " . $diff . " )</td>";
print "</tr>";
}
}
# next - for free space check
$m++;
# if last check for free space
if ($m == $slaveSize) {
# get IP type
if (IdentifyAddress($master['subnet']) == "IPv4") {
$type = 0;
} else {
$type = 1;
}
# set $diffAdd based on mask!
if ($slaves[$m - 1]['mask'] == "32") {
$diffAdd = 0;
} elseif ($slaves[$m - 1]['mask'] == "31") {
$diffAdd = 0;
} else {
$diffAdd = 2;
}
# calculate end of master and last slave
$maxh_m = gmp_strval(gmp_add(MaxHosts($master['mask'], $type), 2));
$maxh_s = gmp_strval(gmp_add(MaxHosts($slave['mask'], $type), $diffAdd));
示例11: checkAdmin
/**
* Function to get RIPe info for network
********************************************/
# required functions */
require_once '../../functions/functions.php';
# verify that user is admin
checkAdmin();
# verify post
CheckReferrer();
/* filter input */
$_POST = filter_user_input($_POST, true, true, false);
/* http://apps.db.ripe.net/whois/lookup/ripe/inetnum/212.58.224.0-212.58.255.255.html.xml */
/* http://apps.db.ripe.net/whois/lookup/ripe/inet6num/2102:840::/32.xml */
# identify address and set proper url
$type = IdentifyAddress($_POST['subnet']);
if ($type == "IPv4") {
$url = "http://apps.db.ripe.net/whois/lookup/ripe/inetnum/{$_POST['subnet']}.xml";
} else {
$url = "http://apps.db.ripe.net/whois/lookup/ripe/inet6num/{$_POST['subnet']}.xml";
}
/* querry ripe db and parse result */
$xml = @simplexml_load_file($url);
/* fail */
if (!$xml) {
/* save to json and return */
header("Content-type: text/javascript");
echo json_encode(array("Error" => "Subnet not present in RIPE DB<br>Error opening URL {$url}"));
} else {
foreach ($xml->objects->object[0]->attributes->children() as $m => $subtag) {
$a = (string) $subtag->attributes()->name;