/** * Update log table */ function updateLogTable($command, $details = NULL, $severity = 0) { global $db; # get variables from config file $database = new database($db['host'], $db['user'], $db['pass']); /* select database */ try { $database->selectDatabase($db['name']); } catch (Exception $e) { return false; die; } /* Check connection */ if (!$database->connect_error) { /* set variable */ $date = date("Y-m-d H:i:s"); $user = getActiveUserDetails(); $user = $user['username']; /* set query */ $query = 'insert into logs ' . "\n"; $query .= '(`severity`, `date`,`username`,`ipaddr`,`command`,`details`)' . "\n"; $query .= 'values' . "\n"; $query .= '("' . $severity . '", "' . $date . '", "' . $user . '", "' . $_SERVER['REMOTE_ADDR'] . '", "' . $command . '", "' . $details . '");'; /* execute */ try { $database->executeMultipleQuerries($query); } catch (Exception $e) { $error = $e->getMessage(); return false; } return true; } else { return false; } }
/** * Update log table */ function updateLogTable($command, $details = NULL, $severity = 0) { # for db upgrade! if (strpos($_SERVER['SCRIPT_URI'], "databaseUpgrade.php") > 0) { global $db; $database = new database($db['host'], $db['user'], $db['pass'], $db['name']); } else { global $database; # check if broken because of cron if (isset($database->error)) { global $db; $database = new database($db['host'], $db['user'], $db['pass'], $db['name'], NULL, false); } } /* set variable */ $date = date("Y-m-d H:i:s"); $user = getActiveUserDetails(); $user = $user['username']; /* set query */ $query = 'insert into logs ' . "\n"; $query .= '(`severity`, `date`,`username`,`ipaddr`,`command`,`details`)' . "\n"; $query .= 'values' . "\n"; $query .= '("' . $severity . '", "' . $date . '", "' . $user . '", "' . $_SERVER['REMOTE_ADDR'] . '", "' . $command . '", "' . $details . '");'; /* execute */ try { $database->executeQuery($query); } catch (Exception $e) { $error = $e->getMessage(); die('<div class="alert alert-danger">' . _('Error') . ': ' . $error . '</div>'); } return true; }
/** * edit favourite */ function editFavourite($post) { global $db; # get variables from config file $database = new database($db['host'], $db['user'], $db['pass'], $db['name']); # get user details and favourites $user = getActiveUserDetails(); # empty $old = explode(";", $user['favourite_subnets']); # set query if ($post['action'] == "remove") { $new = implode(";", array_diff($old, array($post['subnetId']))); $query = "update `users` set `favourite_subnets` = '{$new}' where `id` = '{$user['id']}' limit 1;"; } elseif ($post['action'] == "add") { if (!is_array($old)) { $old = array(); } $new = implode(";", array_merge(array($post['subnetId']), $old)); $query = "update `users` set `favourite_subnets` = '{$new}' where `id` = '{$user['id']}' limit 1;"; } else { return false; } # execute try { $database->executeQuery($query); } catch (Exception $e) { $error = $e->getMessage(); print "<div class='alert alert-danger'>" . _('Error') . ": {$error}</div>"; return false; } return true; }
<?php /** * * User selfMod check end execute * */ /* include required scripts */ require_once '../../functions/functions.php'; /* verify posted data */ CheckReferrer(); /* get old details */ $user_old = getActiveUserDetails(); /* save widgets */ if (!setUserDashWidgets($user_old['id'], $_POST['widgets'])) { die('<div class="alert alert-danger alert-absolute">' . _('Error updating') . '!</div>'); } else { print '<div class="alert alert-success alert-absolute">' . _('Account updated successfully') . '!</div>'; }
<?php /** * * Usermenu - user can change password and email * */ /* verify that user is authenticated! */ isUserAuthenticated(); /* get username */ $ipamusername = getActiveUserDetails(); /* get languages */ $langs = getLanguages(); /* print hello */ print "<h4>{$ipamusername['real_name']}, " . _('here you can change your account details') . ":</h4>"; print "<hr><br>"; ?> <form id="userModSelf"> <table id="userModSelf" class="table table-striped table-condensed"> <!-- real name --> <tr> <td><?php print _('Real name'); ?> </td> <td> <input type="text" class="form-control input-sm" name="real_name" value="<?php
/** * 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; }
<?php /** * * Display usermenu on top right * */ /* get username */ $ipamusername = $_SESSION['ipamusername']; $userDetails = getActiveUserDetails(); ?> <div class="container-fluid"> <div class="input-group" id="searchForm"> <form id="userMenuSearch"> <input type="text" class="form-control searchInput input-sm" name='ip' placeholder='<?php print _('Search string'); ?> ' type='text' value='<?php print $_REQUEST['ip']; ?> '> </form> <span class="input-group-btn"> <button class="btn btn-default btn-sm searchSubmit" type="button"><?php print _('Search'); ?> </button> </span>
/** * Write new changelog */ function writeChangelog($ctype, $action, $result, $old, $new) { /* set query, open db connection and fetch results */ global $database; # get settings $settings = getAllSettings(); if ($settings['enableChangelog'] == 1) { # get user details $cuser = getActiveUserDetails(); # unset unneeded values and format if ($ctype == "ip_addr") { unset($new['action'], $new['subnet'], $new['type']); } elseif ($ctype == "subnet") { $new['id'] = $new['subnetId']; unset($new['action'], $new['subnetId'], $new['location'], $new['vrfIdOld'], $new['permissions']); # if section does not change if ($new['sectionId'] == $new['sectionIdNew']) { unset($new['sectionIdNew']); unset($new['sectionId']); unset($old['sectionId']); } else { $old['sectionIdNew'] = $old['sectionId']; } //transform subnet if (strlen($new['subnet']) > 0) { $new['subnet'] = Transform2decimal(substr($new['subnet'], 0, strpos($new['subnet'], "/"))); } } elseif ($ctype == "section") { unset($new['action']); } # calculate diff if ($action == "edit") { //old - checkboxes foreach ($old as $k => $v) { if (!isset($new[$k]) && $v == 1) { $new[$k] = 0; } } foreach ($new as $k => $v) { //change if ($old[$k] != $v && $old[$k] != str_replace("\\'", "'", $v)) { //empty if (strlen(@$old[$k]) == 0) { $old[$k] = "NULL"; } if (strlen(@$v) == 0) { $v = "NULL"; } //state if ($k == 'state') { $old[$k] = reformatIPStateText($old[$k]); $v = reformatIPStateText($v); } elseif ($k == 'sectionIdNew') { //get old and new device if ($old[$k] != "NULL") { $dev = getSectionDetailsById($old[$k]); $old[$k] = $dev['name']; } if ($v != "NULL") { $dev = getSectionDetailsById($v); $v = $dev['name']; } } elseif ($k == "masterSubnetId") { if ($old[$k] == 0) { $old[$k] = "Root"; } else { $dev = getSubnetDetailsById($old[$k]); $old[$k] = transform2long($dev['subnet']) . "/{$dev['mask']} [{$dev['description']}]"; } if ($v == 0) { $v = "Root"; } else { $dev = getSubnetDetailsById($v); $v = transform2long($dev['subnet']) . "/{$dev['mask']} [{$dev['description']}]"; } } elseif ($k == 'switch') { if ($old[$k] == 0) { $old[$k] = "None"; } elseif ($old[$k] != "NULL") { $dev = getDeviceDetailsById($old[$k]); $old[$k] = $dev['hostname']; } if ($v == 0) { $v = "None"; } if ($v != "NULL") { $dev = getDeviceDetailsById($v); $v = $dev['hostname']; } } elseif ($k == 'vlanId') { //get old and new device if ($old[$k] == 0) { $old[$k] = "None"; } elseif ($old[$k] != "NULL") { $dev = getVLANById($old[$k]); $old[$k] = $dev['name'] . " [{$dev['number']}]"; } if ($v == 0) { $v = "None"; } elseif ($v != "NULL") { $dev = getVLANById($v); $v = $dev['name'] . " [{$dev['number']}]"; } } elseif ($k == 'vrfId') { //get old and new device if ($old[$k] == 0) { $old[$k] = "None"; } elseif ($old[$k] != "NULL") { $dev = getVRFDetailsById($old[$k]); $old[$k] = $dev['name'] . " [{$dev['description']}]"; } if ($v == 0) { $v = "None"; } elseif ($v != "NULL") { $dev = getVRFDetailsById($v); $v = $dev['name'] . " [{$dev['description']}]"; } } elseif ($k == 'masterSection') { if ($old[$k] == 0) { $old[$k] = "Root"; } else { $dev = getSectionDetailsById($old[$k]); $old[$k] = "{$dev['name']}"; } if ($v == 0) { $v = "Root"; } else { $dev = getSectionDetailsById($v); $v = "{$dev['name']}"; } } elseif ($k == "permissions") { # get old and compare $new['permissions'] = str_replace("\\", "", $new['permissions']); //Remove / # Get all groups: $groups = getAllGroups(); $groups = rekeyGroups($groups); # reformat: $newp = json_decode($new['permissions']); $v = ''; foreach ($newp as $ke => $p) { $v .= "<br>" . $groups[$ke]['g_name'] . " : " . parsePermissions($p); } $old[$k] = ""; } $log["[{$k}]"] = "{$old[$k]} => {$v}"; } } } elseif ($action == "add") { $log['[create]'] = "{$ctype} created"; } elseif ($action == "delete") { $log['[delete]'] = "{$ctype} deleted"; $new['id'] = $old['id']; } elseif ($action == "truncate") { $log['[truncate]'] = "Subnet truncated"; } elseif ($action == "resize") { $log['[resize]'] = "Subnet Resized"; $log['[New mask]'] = "/" . $new['mask']; } elseif ($action == "perm_change") { # get old and compare $new['permissions_change'] = str_replace("\\", "", $new['permissions_change']); //Remove / # Get all groups: $groups = getAllGroups(); $groups = rekeyGroups($groups); # reformat if ($new['permissions_change'] != "null") { $newp = json_decode($new['permissions_change']); foreach ($newp as $k => $p) { $log['[Permissions]'] .= "<br>" . $groups[$k]['g_name'] . " : " . parsePermissions($p); } } } //if change happened write it! if (isset($log)) { # format change foreach (@$log as $k => $l) { $changelog .= "{$k} {$l}\n"; } $changelog = $database->real_escape_string(trim($changelog)); # set insert query $query = "insert into `changelog` (`ctype`,`coid`,`cuser`,`caction`,`cresult`,`cdate`,`cdiff`) values ('{$ctype}', '{$new['id']}', '{$cuser['id']}', '{$action}', '{$result}', NOW(), '{$changelog}');"; # execute try { $database->executeQuery($query); } catch (Exception $e) { $error = $e->getMessage(); return true; } # mail it! # all good return true; } } else { return true; } }
/** * Update log table */ function updateLogTable($command, $details = NULL, $severity = 0) { global $db; # get variables from config file $database = new database($db['host'], $db['user'], $db['pass'], $db['name']); /* set variable */ $date = date("Y-m-d H:i:s"); $user = getActiveUserDetails(); $user = $user['username']; /* set query */ $query = 'insert into logs ' . "\n"; $query .= '(`severity`, `date`,`username`,`ipaddr`,`command`,`details`)' . "\n"; $query .= 'values' . "\n"; $query .= '("' . $severity . '", "' . $date . '", "' . $user . '", "' . $_SERVER['REMOTE_ADDR'] . '", "' . $command . '", "' . $details . '");'; /* execute */ try { $database->executeMultipleQuerries($query); } catch (Exception $e) { $error = $e->getMessage(); die('<div class="alert alert-error">' . _('Error') . ': ' . $error . '</div>'); } return true; }
/** * 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; } }