本文整理汇总了PHP中Transform2long函数的典型用法代码示例。如果您正苦于以下问题:PHP Transform2long函数的具体用法?PHP Transform2long怎么用?PHP Transform2long使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Transform2long函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importCSVline
/**
* CSV import IP address
*
* provided input is CSV line!
*/
function importCSVline($line, $subnetId)
{
global $database;
/* get subnet details by Id */
$subnetDetails = getSubnetDetailsById($subnetId);
$subnet = Transform2long($subnetDetails['subnet']) . "/" . $subnetDetails['mask'];
/* verify! */
$err = VerifyIpAddress($line[0], $subnet);
if ($err) {
return _('Wrong IP address') . ' - ' . $err . ' - ' . $line[0];
}
/* check for duplicates */
if (checkDuplicate($line[0], $subnetId)) {
return _('IP address already exists') . ' - ' . $line[0];
}
/* get custom fields */
$myFields = getCustomFields('ipaddresses');
if (sizeof($myFields) > 0) {
$import['fieldName'] = "";
$import['fieldValue'] = "";
$m = 9;
foreach ($myFields as $field) {
//escape chars
$line[$m] = mysqli_real_escape_string($database, $line[$m]);
$import['fieldName'] .= ",`{$field['name']}`";
$import['fieldValue'] .= ",'{$line[$m]}'";
$m++;
}
}
/* escape chars */
foreach ($line as $k => $l) {
$line[$k] = mysqli_real_escape_string($database, $l);
}
/* all ok, set query */
$query = "insert into ipaddresses ";
$query .= "(`subnetId`, `ip_addr`, `state`, `description`, `dns_name`, `mac`, `owner`, `switch`, `port`, `note` {$import['fieldName']} ) ";
$query .= "values ";
$query .= "('{$subnetId}','" . Transform2decimal($line[0]) . "', '{$line['1']}','{$line['2']}','{$line['3']}','{$line['4']}','{$line['5']}','{$line['6']}','{$line['7']}','{$line['8']}' {$import['fieldValue']});";
/*
print "<pre>";
print_r($line);
die('alert alert-danger');
*/
/* set log details */
$log = prepareLogFromArray($line);
/* execute */
try {
$database->executeQuery($query);
} catch (Exception $e) {
$error = $e->getMessage();
}
if (!isset($e)) {
updateLogTable('CSV import of IP address ' . $line[1] . ' succeeded', $log, 0);
return true;
} else {
updateLogTable('CSV import of IP address ' . $line[1] . ' failed', $log, 2);
return $error;
}
}
示例2: Transform2long
print "<a class='\t\t\t\t btn btn-xs btn-default disabled' href='#'>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class='fa fa-gray fa-envelope-o'></i></a>";
print "<a class='delete_ipaddress btn btn-xs btn-default modIPaddr' data-action='delete' data-subnetId='" . $ipaddress[$n]['subnetId'] . "' data-id='" . $ipaddress[$n]['id'] . "' data-stopIP='" . $ipaddress[$n]['stopIP'] . "' href='#' id2='" . Transform2long($ipaddress[$n]['ip_addr']) . "'>\t\t<i class='fa fa-gray fa-times'></i></a>";
} else {
print "<a class='edit_ipaddress btn btn-xs btn-default modIPaddr' data-action='edit' data-subnetId='" . $ipaddress[$n]['subnetId'] . "' data-id='" . $ipaddress[$n]['id'] . "' href='#' >\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class='fa fa-gray fa-pencil'></i></a>";
print "<a class='ping_ipaddress btn btn-xs btn-default' data-subnetId='" . $ipaddress[$n]['subnetId'] . "' data-id='" . $ipaddress[$n]['id'] . "' href='#' rel='tooltip' data-container='body' title='" . _('Check avalibility') . "'>\t\t\t\t\t<i class='fa fa-gray fa-cogs'></i></a>";
print "<a class='search_ipaddress btn btn-xs btn-default ";
if (strlen($dnsResolved['name']) == 0) {
print "disabled";
}
print "' href='tools/search/{$dnsResolved['name']}' ";
if (strlen($dnsResolved['name']) != 0) {
print "rel='tooltip' data-container='body' title='" . _('Search same hostnames in db') . "'";
}
print ">\t<i class='fa fa-gray fa-search'></i></a>";
print "<a class='mail_ipaddress btn btn-xs btn-default ' href='#' data-id='" . $ipaddress[$n]['id'] . "' rel='tooltip' data-container='body' title='" . _('Send mail notification') . "'>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class='fa fa-gray fa-envelope-o'></i></a>";
print "<a class='delete_ipaddress btn btn-xs btn-default modIPaddr' data-action='delete' data-subnetId='" . $ipaddress[$n]['subnetId'] . "' data-id='" . $ipaddress[$n]['id'] . "' href='#' id2='" . Transform2long($ipaddress[$n]['ip_addr']) . "'>\t\t<i class='fa fa-gray fa-times'> </i></a>";
}
} else {
if ($ipaddress[$n]['class'] == "range-dhcp") {
print "<a class='edit_ipaddress btn btn-xs btn-default disabled' rel='tooltip' data-container='body' title='" . _('Edit IP address details (disabled)') . "'>\t<i class='fa fa-gray fa-pencil'></i></a>";
print "<a class='\t\t\t\t btn btn-xs btn-default disabled' href='#'>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class='fa fa-gray fa-cogs'></i></a>";
print "<a class='\t\t\t\t btn btn-xs btn-default disabled' href='#'>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class='fa fa-gray fa-search'></i></a>";
print "<a class='\t\t\t\t btn btn-xs btn-default disabled' href='#'>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class='fa fa-gray fa-envelope-o'></i></a>";
print "<a class='delete_ipaddress btn btn-xs btn-default disabled' rel='tooltip' data-container='body' title='" . _('Delete IP address (disabled)') . "'>\t\t\t<i class='fa fa-gray fa-times'></i></a>";
} else {
print "<a class='edit_ipaddress btn btn-xs btn-default disabled' rel='tooltip' data-container='body' title='" . _('Edit IP address details (disabled)') . "'>\t\t\t\t\t\t\t\t\t\t\t\t\t<i class='fa fa-gray fa-pencil'></i></a>";
print "<a class='\t\t\t\t btn btn-xs btn-default disabled' data-id='" . $ipaddress[$n]['id'] . "' href='#' rel='tooltip' data-container='body' title='" . _('Check avalibility') . "'>\t\t\t\t\t<i class='fa fa-gray fa-cogs'></i></a>";
print "<a class='search_ipaddress btn btn-xs btn-default ";
if (strlen($dnsResolved['name']) == 0) {
print "disabled";
}
示例3: die
} else {
$errors[] = $error;
}
}
/* ask must be > 8 */
if ($_POST['newMask'] < 8) {
die('<div class="alert alert-danger">' . _('New mask must be at least /8') . '!</div>');
}
/*
* if strict mode is enabled check that is is still inside master subnet!
*/
if ($section['strictMode'] == 1) {
if (!($overlap = verifySubnetNesting($subnetOld['masterSubnetId'], transform2long($subnetOld['subnet']) . "/" . $_POST['newMask'])) && $subnetOld['masterSubnetId'] != 0) {
# get master details
$master = getSubnetDetailsById($subnetOld['masterSubnetId']);
$master = Transform2long($master['subnet']) . "/" . $master['mask'] . " - " . $master['description'];
$errors[] = _("New subnet not in master subnet") . "!<br>({$master})";
}
}
/*
* If subnet has slaves make sure all slaves are still inside!
*/
if ($section['strictMode'] == 1) {
$slaves = getAllSlaveSubnetsBySubnetId($_POST['subnetId']);
if (sizeof($slaves) > 0) {
foreach ($slaves as $slave) {
if (!isSubnetInsideSubnet(transform2long($slave['subnet']) . "/" . $slave['mask'], transform2long($subnetOld['subnet']) . "/" . $_POST['newMask'])) {
$errors[] = _("Nested subnet out of new subnet") . "!<br>(" . transform2long($slave['subnet']) . "/{$slave['mask']} - {$slave['description']})";
}
}
}
示例4: sendIPResultEmail
/**
* Send IP result mail - reject or confirm reservation
*/
function sendIPResultEmail($request)
{
# get settings
global $settings;
global $mail;
# set subject based on action
if ($request['action'] == "accept") {
$subject = _("IP address request") . " (" . Transform2long($request['ip_addr']) . ") " . _("{$request['action']}ed");
} else {
$subject = _("IP address request {$request['action']}ed");
}
# set additional headers
$mail['recipients'] = $request['requester'];
// it is sent to requester this time!
$mail['subject'] = $subject;
# add admins to CC
$admins = getAllAdminUsers();
$cc = "";
foreach ($admins as $admin) {
$cc .= '' . $admin['email'] . ', ';
}
$cc = substr($cc, 0, -2);
$mail['headers'] .= 'Cc: ' . $cc . "\r\n";
# get active user name */
$sender = getActiveUserDetails();
# get subnet details
$subnet = getSubnetDetailsById($request['subnetId']);
$subnet2 = Transform2long($subnet['subnet']) . "/" . $subnet['mask'];
# get section detaiils
$section = getSectionDetailsById($subnet['sectionId']);
# reformat \n to breaks
$request['comment'] = str_replace("\n", "<br>", $request['comment']);
$request['adminComment'] = str_replace("\n", "<br>", $request['adminComment']);
# set html content
if ($settings['htmlMail'] == "1") {
$mail['content'] = $mail['header'];
$mail['content'] .= "<tr><td style='padding:5px;margin:0px;color:#333;font-size:16px;text-shadow:1px 1px 1px white;border-bottom:1px solid #eeeeee;' colspan='2'><font face='Helvetica, Verdana, Arial, sans-serif' style='font-size:16px;'>{$subject}</font></td></tr>";
$mail['content'] .= '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;border-top:1px solid white;padding-top:10px;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• ' . _('Section') . ' </font></td><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;border-top:1px solid white;padding-top:10px;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">' . $section['name'] . ' (' . $section['description'] . ')</font></td></tr>' . "\n";
$mail['content'] .= '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• ' . _('Subnet') . ' </font></td> <td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">' . $subnet2 . '</font></td></tr>' . "\n";
if ($request['action'] == "accept") {
$mail['content'] .= '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• ' . _('assigned IP address') . ' </font></td> <td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">' . Transform2long($request['ip_addr']) . '</font></td></tr>' . "\n";
}
$mail['content'] .= '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• ' . _('Description') . ' </font></td> <td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">' . $request['description'] . '</font></td></tr>' . "\n";
$mail['content'] .= '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• ' . _('Hostname') . ' </font></td> <td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">' . $request['dns_name'] . '</font></td></tr>' . "\n";
$mail['content'] .= '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• ' . _('Owner') . ' </font></td> <td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">' . $request['owner'] . '</font></td></tr>' . "\n";
$mail['content'] .= '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• ' . _('Requested from') . ' </font></td> <td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;"><a href="mailto:' . $request['requester'] . '" style="color:#08c;">' . $request['requester'] . '</a></font></td></tr>' . "\n";
$mail['content'] .= '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;vertical-align:top;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• ' . _('Comment (request)') . ' </font></td> <td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">' . $request['comment'] . '</font></td></tr>' . "\n";
$mail['content'] .= '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;vertical-align:top;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• ' . _('Admin accept/reject comment') . ' </font></td> <td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px; font-weight:bold;">' . $request['adminComment'] . '</font></td></tr>' . "\n";
$mail['content'] .= "<tr><td style='padding:5px;padding-left:15px;margin:0px;font-style:italic;padding-bottom:3px;text-align:right;color:#ccc;text-shadow:1px 1px 1px white;border-top:1px solid white;' colspan='2'><font face='Helvetica, Verdana, Arial, sans-serif' style='font-size:11px;'>" . _('Sent by user') . " " . $mail['sender']['real_name'] . " at " . date('Y/m/d H:i') . "</font></td></tr>";
$mail['content'] .= $mail['footer2'];
} else {
# reformat content
$content = str_replace("<br>", "\r\n", $content);
$content = str_replace("\t", " ", $content);
$content = strip_tags($content);
# reformat content
$request['comment'] = str_replace("<br>", "\r\n", $request['comment']);
$request['adminComment'] = str_replace("<br>", "\r\n", $request['adminComment']);
$mail['content'] = $mail['header'];
$mail['content'] .= "{$subject}" . "\r\n------------------------------\r\n\r\n";
$mail['content'] .= _("Section") . ": {$section['name']} ({$section['description']})\r\n";
$mail['content'] .= _("Subnet") . ": {$subnet2}\r\n";
if ($request['action'] == "accept") {
$mail['content'] .= _("Assigned IP address") . ": " . Transform2long($request['ip_addr']) . "\r\n";
}
$mail['content'] .= _("Description") . ": {$request['description']}\r\n";
$mail['content'] .= _("Hostname") . ": {$request['dns_name']}\r\n";
$mail['content'] .= _("Owner") . ": {$request['owner']}\r\n";
$mail['content'] .= _("Requested by") . ": {$request['requester']}\r\n";
$mail['content'] .= _("Comment (request)") . ": {$request['comment']}\r\n";
$mail['content'] .= _("Admin accept/reject comment") . ": {$request['adminComment']}\r\n";
$mail['content'] .= "\r\nSent by user " . $mail['sender']['real_name'] . " at " . date('Y/m/d H:i');
$mail['content'] .= $mail['footer'];
# reset headers
$mail['headers'] = 'From: ' . $mail['from'] . "\r\n";
$mail['headers'] .= 'Reply-To: ' . $settings['siteAdminMail'] . "\r\n";
$mail['headers'] .= 'X-Mailer: PHP/' . phpversion() . "\r\n";
$mail['headers'] .= 'Cc: ' . $cc . "\r\n";
}
# send mail and update log
if (!mail($mail['recipients'], $mail['subject'], $mail['content'], $mail['headers'])) {
# write log
updateLogTable("IP request response mail (confirm,reject) sending failed", "Sending notification mail to {$mail['recipients']} failed!", $severity = 2);
return false;
} else {
# write log
updateLogTable("IP request response mail (confirm,reject) sent ok", "Sending notification mail to {$mail['recipients']} succeeded!", $severity = 0);
return true;
}
}
示例5: _
<tr>
<th><?php
print _('Requested subnet');
?>
</th>
<td>
<select name="subnetId" id="subnetId" class="form-control input-sm input-w-auto">
<?php
$subnets = fetchAllSubnets();
foreach ($subnets as $subnet) {
/* show only subnets that allow IP exporting */
if ($subnet['allowRequests'] == 1) {
if ($request['subnetId'] == $subnet['id']) {
print '<option value="' . $subnet['id'] . '" selected>' . Transform2long($subnet['subnet']) . '/' . $subnet['mask'] . ' [' . $subnet['description'] . ']</option>';
} else {
print '<option value="' . $subnet['id'] . '">' . Transform2long($subnet['subnet']) . '/' . $subnet['mask'] . ' [' . $subnet['description'] . ']</option>';
}
}
}
?>
</select>
</td>
</tr>
<!-- IP address -->
<tr>
<th><?php
print _('IP address');
?>
</th>
<td>
<input type="text" name="ip_addr" class="ip_addr form-control input-sm" value="<?php
示例6: sizeof
//set max
$max = sizeof($ip);
}
$z = 0;
//addresses array index
// run per MAX_THREADS
for ($m = 0; $m <= $max; $m += $settings['scanMaxThreads']) {
// create threads
$threads = array();
// fork processes
for ($i = 0; $i <= $settings['scanMaxThreads'] && $i <= $max; $i++) {
//only if index exists!
if (isset($ip[$z])) {
//start new thread
$threads[$z] = new Thread('pingHost');
$threads[$z]->start(Transform2long($ip[$z]), $count, $timeout, true);
$z++;
//next index
}
}
// wait for all the threads to finish
while (!empty($threads)) {
foreach ($threads as $index => $thread) {
if (!$thread->isAlive()) {
//get exit code
$exitCode = $thread->getExitCode();
//online, save to array
if ($exitCode == 0) {
$out['alive'][] = $ip[$index];
} elseif ($exitCode == 1 || $exitCode == 2) {
$out['dead'][] = $ip[$index];
示例7: _
print _('Description');
?>
</th>
<th><?php
print _('Requested by');
?>
</th>
</tr>
<?php
# print requests
foreach ($allActiveRequests as $request) {
//get subnet details
$subnet = getSubnetDetailsById($request['subnetId']);
print '<tr>' . "\n";
print "\t<td><button class='btn btn-xs btn-default' data-requestid='{$request['id']}'><i class='fa fa-pencil'></i></button></td>";
print ' <td>' . Transform2long($subnet['subnet']) . '/' . $subnet['mask'] . ' (' . $subnet['description'] . ')</td>' . "\n";
print ' <td>' . $request['dns_name'] . '</td>' . "\n";
print ' <td>' . $request['description'] . '</td>' . "\n";
print ' <td>' . $request['requester'] . '</td>' . "\n";
print '</tr>' . "\n";
}
?>
</table>
<?php
}
?>
示例8: getIpAddrDetailsById
/**
* Get IP address details
*/
function getIpAddrDetailsById($id)
{
global $database;
/* set query, open db connection and fetch results */
$query = 'select * from `ipaddresses` where `id` = "' . $id . '";';
/* execute */
try {
$details = $database->getArray($query);
} catch (Exception $e) {
$error = $e->getMessage();
print "<div class='alert alert-danger'>" . _('Error') . ": {$error}</div>";
return false;
}
//we only fetch 1 field
$details = $details[0];
//change IP address formatting to dotted(long)
$details['ip_addr'] = Transform2long($details['ip_addr']);
/* return result */
return $details;
}
示例9: sendIPResultEmail
/**
* Send IP result mail - reject or confirm reservation
*/
function sendIPResultEmail($request)
{
# get settings
global $settings;
global $mailsettings;
global $mail;
global $pmail;
# set subject based on action
if ($request['action'] == "accept") {
$subject = _("IP address request") . " (" . Transform2long($request['ip_addr']) . ") " . _("{$request['action']}ed");
} else {
$subject = _("IP address request {$request['action']}ed");
}
# get active user name */
$sender = getActiveUserDetails();
# get subnet details
$subnet = getSubnetDetailsById($request['subnetId']);
$subnet2 = Transform2long($subnet['subnet']) . "/" . $subnet['mask'];
# get section detaiils
$section = getSectionDetailsById($subnet['sectionId']);
# reformat \n to breaks
$request['comment'] = str_replace("\n", "<br>", $request['comment']);
$request['adminComment'] = str_replace("\n", "<br>", $request['adminComment']);
# set html content
$mail['content'] = $mail['header'];
$mail['content'] .= "<tr><td style='padding:5px;margin:0px;color:#333;font-size:16px;text-shadow:1px 1px 1px white;border-bottom:1px solid #eeeeee;' colspan='2'><font face='Helvetica, Verdana, Arial, sans-serif' style='font-size:16px;'>{$subject}</font></td></tr>";
$mail['content'] .= '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;border-top:1px solid white;padding-top:10px;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• ' . _('Section') . ' </font></td><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;border-top:1px solid white;padding-top:10px;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">' . $section['name'] . ' (' . $section['description'] . ')</font></td></tr>' . "\n";
$mail['content'] .= '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• ' . _('Subnet') . ' </font></td> <td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">' . $subnet2 . '</font></td></tr>' . "\n";
if ($request['action'] == "accept") {
$mail['content'] .= '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• ' . _('assigned IP address') . ' </font></td> <td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">' . Transform2long($request['ip_addr']) . '</font></td></tr>' . "\n";
}
$mail['content'] .= '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• ' . _('Description') . ' </font></td> <td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">' . $request['description'] . '</font></td></tr>' . "\n";
$mail['content'] .= '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• ' . _('Hostname') . ' </font></td> <td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">' . $request['dns_name'] . '</font></td></tr>' . "\n";
$mail['content'] .= '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• ' . _('Owner') . ' </font></td> <td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">' . $request['owner'] . '</font></td></tr>' . "\n";
$mail['content'] .= '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• ' . _('Requested from') . ' </font></td> <td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;"><a href="mailto:' . $request['requester'] . '" style="color:#08c;">' . $request['requester'] . '</a></font></td></tr>' . "\n";
$mail['content'] .= '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;vertical-align:top;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• ' . _('Comment (request)') . ' </font></td> <td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">' . $request['comment'] . '</font></td></tr>' . "\n";
$mail['content'] .= '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;vertical-align:top;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• ' . _('Admin accept/reject comment') . ' </font></td> <td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px; font-weight:bold;">' . $request['adminComment'] . '</font></td></tr>' . "\n";
$mail['content'] .= "<tr><td style='padding:5px;padding-left:15px;margin:0px;font-style:italic;padding-bottom:3px;text-align:right;color:#ccc;text-shadow:1px 1px 1px white;border-top:1px solid white;' colspan='2'><font face='Helvetica, Verdana, Arial, sans-serif' style='font-size:11px;'>" . _('Sent by user') . " " . $mail['sender']['real_name'] . " at " . date('Y/m/d H:i') . "</font></td></tr>";
$mail['content'] .= $mail['footer2'];
# alt content
$request['comment'] = str_replace("<br>", "\r\n", $request['comment']);
$request['adminComment'] = str_replace("<br>", "\r\n", $request['adminComment']);
$mail['contentAlt'] = $mail['headerAlt'];
$mail['contentAlt'] .= "{$subject}" . "\r\n------------------------------\r\n\r\n";
$mail['contentAlt'] .= _("Section") . ": {$section['name']} ({$section['description']})\r\n";
$mail['contentAlt'] .= _("Subnet") . ": {$subnet2}\r\n";
if ($request['action'] == "accept") {
$mail['contentAlt'] .= _("Assigned IP address") . ": " . Transform2long($request['ip_addr']) . "\r\n";
}
$mail['contentAlt'] .= _("Description") . ": {$request['description']}\r\n";
$mail['contentAlt'] .= _("Hostname") . ": {$request['dns_name']}\r\n";
$mail['contentAlt'] .= _("Owner") . ": {$request['owner']}\r\n";
$mail['contentAlt'] .= _("Requested by") . ": {$request['requester']}\r\n";
$mail['contentAlt'] .= _("Comment (request)") . ": {$request['comment']}\r\n";
$mail['contentAlt'] .= _("Admin accept/reject comment") . ": {$request['adminComment']}\r\n";
$mail['contentAlt'] .= "\r\nSent by user " . $mail['sender']['real_name'] . " at " . date('Y/m/d H:i');
$mail['contentAlt'] .= $mail['footerAlt'];
# set mail parameters
try {
$pmail->SetFrom($mailsettings['mAdminMail'], $mailsettings['mAdminName']);
// send to requester
$pmail->AddAddress($request['requester']);
// add admins to CC
$admins = getAllAdminUsers();
foreach ($admins as $admin) {
$pmail->AddCC($admin['email']);
}
$pmail->ClearReplyTos();
$pmail->AddReplyTo($mailsettings['mAdminMail'], $mailsettings['mAdminName']);
// content
$pmail->Subject = $subject;
$pmail->AltBody = $mail['contentAlt'];
$pmail->MsgHTML($mail['content']);
# pošlji
$pmail->Send();
} catch (phpmailerException $e) {
updateLogTable("IP request response mail (confirm,reject) sending failed", "Sending notification mail to {$mail['recipients']} failed!\n" . $e->errorMessage(), 2);
return false;
} catch (Exception $e) {
updateLogTable("IP request response mail (confirm,reject) sending failed", "Sending notification mail to {$mail['recipients']} failed!\n" . $e->errorMessage(), 2);
return false;
}
# write log for ok
updateLogTable("IP request response mail (confirm,reject) sent ok", "Sending notification mail to {$mail['recipients']} succeeded!", 0);
return true;
}
示例10: importCSVline
/**
* CSV import IP address
*
* provided input is CSV line!
*/
function importCSVline($line, $subnetId)
{
/* array */
$line = explode(",", $line);
global $db;
# get variables from config file
$database = new database($db['host'], $db['user'], $db['pass'], $db['name']);
/* get subnet details by Id */
$subnetDetails = getSubnetDetailsById($subnetId);
$subnet = Transform2long($subnetDetails['subnet']) . "/" . $subnetDetails['mask'];
/* verify! */
if (VerifyIpAddress($line[0], $subnet)) {
return _('Wrong IP address') . ' - ' . $line[0];
}
/* check for duplicates */
if (checkDuplicate($line[0], $subnetId)) {
return _('IP address already exists') . ' - ' . $line[0];
}
/* reformat state */
switch ($line[5]) {
case "Active":
$line[5] = "1";
break;
case "active":
$line[5] = "1";
break;
case "Reserved":
$line[5] = "2";
break;
case "reserved":
$line[5] = "2";
break;
case "Offline":
$line[5] = "0";
break;
case "offline":
$line[5] = "0";
break;
}
/* reformat switch! */
$switch = getSwitchDetailsByHostname($line[7]);
/* get custom fields */
$myFields = getCustomIPaddrFields();
if (sizeof($myFields) > 0) {
$import['fieldName'] = "";
$import['fieldValue'] = "";
$m = 9;
foreach ($myFields as $field) {
$import['fieldName'] .= ",`{$field['name']}`";
$import['fieldValue'] .= ",'{$line[$m]}'";
$m++;
}
}
/* all ok, set query */
$query = "insert into ipaddresses ";
$query .= "(`subnetId`, `ip_addr`, `state`, `description`, `dns_name`, `mac`, `owner`, `switch`, `port`, `note` {$import['fieldName']} ) ";
$query .= "values ";
$query .= "('{$subnetId}','" . Transform2decimal($line[0]) . "', '{$line['1']}','{$line['2']}','{$line['3']}','{$line['4']}','{$line['5']}','{$line['6']}','{$switch['id']}','{$line['8']}' {$import['fieldValue']});";
/* set log details */
$log = prepareLogFromArray($line);
/* execute */
try {
$database->executeQuery($query);
} catch (Exception $e) {
$error = $e->getMessage();
}
if (!isset($e)) {
updateLogTable('CSV import of IP address ' . $line[1] . ' succeeded', $log, 0);
return true;
} else {
updateLogTable('CSV import of IP address ' . $line[1] . ' failed', $log, 2);
return $error;
}
}
示例11: foreach
</tr>
</tbody>
<?php
/* content */
$n = 0;
$m = $CalculateSubnetDetails['used'] - 1;
$n = 0;
# count for IP addresses - $n++ per IP address
/* print IP addresses
********************/
foreach ($ipaddresses as $ipaddress) {
print "<tr>";
print "\t<td class='ipaddress'>" . Transform2long($ipaddress['ip_addr']);
if (in_array('state', $setFields)) {
print reformatIPState($ipaddress['state']);
}
print "</td>";
# resolve dns name if not provided, else print it - IPv4 only!
if (empty($ipaddress['dns_name']) and $settings['enableDNSresolving'] == 1 and IdentifyAddress($ipaddress['ip_addr']) == "IPv4") {
$dnsResolved = ResolveDnsName($ipaddress['ip_addr']);
} else {
$dnsResolved['class'] = "";
$dnsResolved['name'] = $ipaddress['dns_name'];
}
print "<td class='{$dnsResolved['class']} hostname'>{$dnsResolved['name']}</td>";
# Print mac address icon!
if (in_array('mac', $setFields)) {
if (!empty($ipaddress['mac'])) {
示例12: Transform2long
} else {
if ($line['state'] == "3") {
$stateClass = "DHCP";
}
}
}
// </eNovance>
}
//print table
print '<tr class="ipSearch ' . $stateClass . '" id="' . $line['id'] . '" subnetId="' . $line['subnetId'] . '" sectionId="' . $subnet['sectionId'] . '" link="' . $section['name'] . '|' . $subnet['id'] . '">' . "\n";
// <eNovance>
// Add a link to an ip address to GLPI
if ($line['glpiId'] != '' and $line['glpiId'] != 0) {
print " <td><a href=\"http://" . $glpiurl . "/glpi/front/computer.form.php?id=" . $line['glpiId'] . "\" target=\"_blank\">" . Transform2long($line['ip_addr']) . "</a>";
} else {
print " <td>" . Transform2long($line['ip_addr']);
}
// </eNovance>
if (in_array('state', $setFields)) {
print reformatIPState($line['state']);
}
print ' </td>' . "\n";
print ' <td>' . $vlan['number'] . '</td>' . "\n";
print ' <td>' . ShortenText($line['description'], $chars = 50) . '</td>' . "\n";
print ' <td>' . $line['dns_name'] . '</td>' . "\n";
# mac
if (in_array('mac', $setFields)) {
print ' <td>' . "\n";
if (strlen($line['mac']) > 0) {
print '<i class="icon-mac" rel="tooltip" title=""MAC: ' . $line['mac'] . '"></i>' . "\n";
}
示例13: substr
# remove last or
$query = substr($query, 0, -3);
# get ony ip's with empty DNS
if ($resCnf['emptyonly'] == 1) {
$query .= ' and `dns_name` like "" ';
}
$query .= 'order by `ip_addr` ASC;';
}
# fetch records
$database = new database($db['host'], $db['user'], $db['pass'], $db['name']);
$ipaddresses = $database->getArray($query);
# try to update dns records
foreach ($ipaddresses as $ip) {
# try to resolve
$hostname = gethostbyaddr(Transform2long($ip['ip_addr']));
if ($hostname != Transform2long($ip['ip_addr'])) {
# update
$query = 'update `ipaddresses` set `dns_name` = "' . $hostname . '" where `id` = "' . $ip['id'] . '"';
$database->executeQuery($query);
# set text
$res[] = 'updated ip address ' . Transform2long($ip['ip_addr']) . ' with hostname ' . $hostname;
}
}
# if verbose print result so it can be emailed via cron!
if ($resCnf['verbose'] == 1) {
foreach ($res as $line) {
print $line . "\n";
}
}
# close database
$database->close();
示例14: Transform2long
print "\t\t<a class='\t\t\t\t btn btn-mini disabled' href='#'>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class='icon-gray icon-envelope'></i></a>";
print "\t\t<a class='delete_ipaddress btn btn-mini modIPaddr' data-action='delete' data-subnetId='" . $ipaddress[$n]['subnetId'] . "' data-id='" . $ipaddress[$n]['id'] . "' href='#' id2='" . Transform2long($ipaddress[$n]['ip_addr']) . "' rel='tooltip' title='" . _('Delete IP address') . "'>\t\t\t\t\t<i class='icon-gray icon-remove'> </i></a>";
} else {
print "\t\t<a class='edit_ipaddress btn btn-mini modIPaddr' data-action='edit' data-subnetId='" . $ipaddress[$n]['subnetId'] . "' data-id='" . $ipaddress[$n]['id'] . "' href='#' \t\t\t\t\t\t\t\t\t\t\t rel='tooltip' title='" . _('Edit IP address details') . "'>\t\t\t\t\t\t<i class='icon-gray icon-pencil'> </i></a>";
print "\t\t<a class='ping_ipaddress btn btn-mini' data-subnetId='" . $ipaddress[$n]['subnetId'] . "' data-id='" . $ipaddress[$n]['id'] . "' href='#' \t\t\t\t\t\t \t\t\t\t\t\t\t\t\t\t\t\t\trel='tooltip' title='" . _('Check avalibility') . "'>\t\t\t\t\t\t\t<i class='icon-gray icon-retweet'> </i></a>";
print "\t\t<a class='search_ipaddress btn btn-mini ";
if (strlen($dnsResolved['name']) == 0) {
print "disabled";
}
print "' href='tools/search/{$dnsResolved['name']}' ";
if (strlen($dnsResolved['name']) != 0) {
print "rel='tooltip' title='" . _('Search same hostnames in db') . "'";
}
print ">\t<i class='icon-gray icon-search'></i></a>";
print "\t\t<a class='mail_ipaddress btn btn-mini ' href='#' data-id='" . $ipaddress[$n]['id'] . "' rel='tooltip' title='" . _('Send mail notification') . "'>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class='icon-gray icon-envelope'></i></a>";
print "\t\t<a class='delete_ipaddress btn btn-mini modIPaddr' data-action='delete' data-subnetId='" . $ipaddress[$n]['subnetId'] . "' data-id='" . $ipaddress[$n]['id'] . "' href='#' id2='" . Transform2long($ipaddress[$n]['ip_addr']) . "' rel='tooltip' title='" . _('Delete IP address') . "'>\t\t\t\t\t<i class='icon-gray icon-remove'> </i></a>";
}
} else {
if ($ipaddress[$n]['class'] == "range-dhcp") {
print "\t\t<a class='edit_ipaddress btn btn-mini disabled' rel='tooltip' title='" . _('Edit IP address details (disabled)') . "'>\t<i class='icon-gray icon-pencil'> </i></a>";
print "\t\t<a class='\t\t\t\t btn btn-mini disabled' href='#'>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class='icon-gray icon-retweet'> </i></a>";
print "\t\t<a class='\t\t\t\t btn btn-mini disabled' href='#'>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class='icon-gray icon-search'></i></a>";
print "\t\t<a class='\t\t\t\t btn btn-mini disabled' href='#'>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class='icon-gray icon-envelope'></i></a>";
print "\t\t<a class='delete_ipaddress btn btn-mini disabled' rel='tooltip' title='" . _('Delete IP address (disabled)') . "'>\t\t\t<i class='icon-gray icon-remove'> </i></a>";
} else {
print "\t\t<a class='edit_ipaddress btn btn-mini disabled' rel='tooltip' title='" . _('Edit IP address details (disabled)') . "'>\t\t\t\t\t\t\t<i class='icon-gray icon-pencil'> </i></a>";
print "\t\t<a class='\t\t\t\t btn btn-mini disabled' data-id='" . $ipaddress[$n]['id'] . "' href='#' rel='tooltip' title='" . _('Check avalibility') . "'>\t\t<i class='icon-gray icon-retweet'> </i></a>";
print "\t\t<a class='search_ipaddress btn btn-mini ";
if (strlen($dnsResolved['name']) == 0) {
print "disabled";
}
示例15: printBreadcrumbs
/**
* 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>";
//.........这里部分代码省略.........