$base_url = "http://"; if ($HTTPS == 1) { $base_url = "https://"; } $base_url .= $_SERVER["SERVER_NAME"] . "/" . $INSTALL_HOME . "rca"; $activity_id = $_REQUEST["activity_id"]; $action = "PENDING APPROVAL"; $action_by = $username; $action_date = mktime(); $email = $_REQUEST["email"]; $sql = "select record_index,approver_name,approver_email,approver_key,item_order"; $sql .= " from rca_approval_history where activity_id='{$activity_id}' and approver_email='{$email}' order by record_index asc limit 1"; $result = mysql_query($sql); while ($row = mysql_fetch_row($result)) { $record_index = $row[0]; $approver_name = $row[1]; $approver_email = $row[2]; $approver_key = random_key(); $sql = "update rca_approval_history set approver_key='{$approver_key}' where record_index='{$record_index}'"; $result = mysql_query($sql); $item_order = $row[4]; $subject = "RCA APPROVAL REQUEST : {$activity_id}"; $url = $base_url . "/rca_view.php" . "?check_email=" . $approver_email . "&check_key=" . "{$approver_key}"; $body = "\nA Root Cause Analysis (RCA) is pending your approval. Kindly click on the URL : {$url} to view and approve the request.\n\n\n"; $body .= "PLEASE NOTE THAT THE ABOVE URL IS FOR ONE TIME USE ONLY. \nPLEASE DO NOT REPLY TO THIS E-MAIL"; ezmail($approver_email, $approver_name, $subject, $body, ""); } ?> <meta http-equiv="REFRESH" content="0;URL=index.php">
$message = str_replace('%%user', $row[2], $template); $sub_sql = "select a.assetid,a.assetidentifier,a.model,a.serialno,b.assetcategory from asset a, assetcategory b where a.assetcategoryid=b.assetcategoryid and a.employee='{$employee}'"; $sub_result = mysql_query($sub_sql); $asset = "<table border=1 cellspacing=0 cellpadding=3>"; $asset .= "<tr>"; $asset .= "<td><b>Asset ID</td>"; $asset .= "<td><b>Asset Tag</td>"; $asset .= "<td><b>Category</td>"; $asset .= "<td><b>Model</td>"; $asset .= "<td><b>Serial No </td>"; $asset .= "</tr>"; while ($sub_row = mysql_fetch_row($sub_result)) { $assetid = $ASSET_PREFIX . "-" . str_pad($sub_row[0], 5, "0", STR_PAD_LEFT); $assettag = $sub_row[1]; $category = $sub_row[4]; $model = $sub_row[2]; $serialno = $sub_row[3]; $asset .= "<tr>"; $asset .= "<td>{$assetid}</td>"; $asset .= "<td>{$assettag}</td>"; $asset .= "<td>{$category}</td>"; $asset .= "<td>{$model}</td>"; $asset .= "<td>{$serialno}</td>"; $asset .= "</tr>"; } $asset .= "</table>"; $message = str_replace('%%asset', $asset, $message); $subject = "Asset Verification Request"; ezmail("{$email}", "{$email}", $subject, $message, "", true); } echo "<center><br><font face=Arial size=2 color=black>The notification has been sent successfully.</font>";
// Send Notification ezmail($email, $full_name, $subject, $body, ""); } if ($action == "REJECTED") { // Notify the Owner of the POA $subject = "PLANNED ACTIVITY {$poa_display} : {$approver_name} {$action}"; $body = "\nThis is to inform you that, {$approver_name} has {$action} the Planned Activity with ID : {$poa_display} submitted by you.\n\nThe Planned Activity will not be processed further. Kindly get in touch with {$approver_name} for more information and re-submit the request.\n\n\n"; $body .= "PLEASE DO NOT REPLY TO THIS E-MAIL"; // Fetch the Owner Information $sql = "SELECT first_name,last_name,official_email FROM user_master a,poa_master b WHERE b.action_by=a.username and b.activity_id='{$activity_id}'"; $result = mysql_query($sql); $row = mysql_fetch_row($result); $full_name = $row[0] . " " . $row[1]; $email = $row[2]; // Send Notification ezmail($email, $full_name, $subject, $body, ""); $sql = "update poa_master set action='REJECTED' where activity_id='{$activity_id}'"; $result = mysql_query($sql); } } else { echo "<h2>You did not choose an action. Please hit the back button and re-submit your approval.</h2>"; } } if ($authorized == 1 && !isset($_REQUEST["action"]) && !isset($_REQUEST["comments"])) { ?> <center> <form method=POST action='pa_approve.php?check_email=<?php echo $check_email; ?> &check_key=<?php echo $check_key;
$approval_key = random_key(); $base_url = "http://"; if ($HTTPS == 1) { $base_url = "https://"; } $base_url .= $_SERVER["SERVER_NAME"] . "/" . $INSTALL_HOME . "eztickets/scp"; if ($authenticated == 1) { $sql = "insert into isost_ticket_approval (ticket_id,request_date,requested_by,approval_status,approval_by,approval_date,approval_comments,approval_key)"; $sql .= " values('{$ticket_id}','{$request_date}','{$requested_by}','PENDING','{$approval_by}','','','{$approval_key}')"; $result = mysql_query($sql); $sql = "update isost_ticket set pending_approval=1 where ticket_id='{$ticket_id}'"; $result = mysql_query($sql); $title = "Ticket Pending Approval"; $note = "Ticket is pending external approval from " . $approval_name . " requested by " . $requested_by; $sql = "insert into isost_ticket_note(ticket_id,staff_id,source,title,note,created)"; $sql .= " values('{$ticket_id}','0','system','{$title}','{$note}',NOW())"; $result = mysql_query($sql); $subject = "TICKET APPROVAL REQUEST : # {$ticket_id}"; $url = $base_url . "/ticket_view.php" . "?check_email=" . $approval_by . "&check_key=" . "{$approval_key}" . "&ticket_id=" . $ticket_id; $body = "\nA ticket is pending your approval. Kindly click on the URL : {$url} to view and approve the request.\n\n\n"; $body .= "PLEASE NOTE THAT THE ABOVE URL IS FOR ONE TIME USE ONLY. \nPLEASE DO NOT REPLY TO THIS E-MAIL"; ezmail($approval_by, $approval_by, $subject, $body, ""); ?> <h3>Approval Request has been sent</h3> <br><br> <h4><a href="javascript:refreshParent();">CLOSE THIS WINDOW</a></h4> <?php } ?>
<?php include "config.php"; include "header.php"; $email_to = $_REQUEST["email_to"]; $subject = $_REQUEST["subject"]; $body = $_REQUEST["body"]; $temp_path = $_REQUEST["target_path"]; $username = $_SESSION['username']; $subject1 = mysql_real_escape_string($subject); $body1 = mysql_real_escape_string($body); $broadcast_date = mktime(); $file_date = $broadcast_date . "_"; if (strlen($temp_path) > 0) { $target_path = str_replace("temp_", "{$file_date}", $temp_path); rename($temp_path, $target_path); } $return = ezmail($email_to, $email_to, $subject, $body, $target_path, true); if ($return == 1) { echo "<center><br><font face=Arial size=2 color=black>The notification has been sent successfully.</font>"; $sql = "insert into broadcast (broadcast_to,broadcast_subject,broadcast_msg,broadcast_date,username,attachment_path) values ('{$email_to}','{$subject1}','{$body1}','{$broadcast_date}','{$username}','{$target_path}')"; $result = mysql_query($sql); } else { echo "<center><br><font face=Arial size=2 color=black>The notification could not be sent.<br>Kindly verify your credentials or try and resend this notification later.</font>"; }
} //This section is used to send a notification mail to the respective people to say the service is UP again if ($svc_status == 1) { $limit = $alarm_threshold + 1; $select_up_query = "SELECT svc_status FROM hosts_service_log WHERE host_id='{$host_id}' and url='{$url}' ORDER BY record_id DESC LIMIT {$limit}"; $up_result = mysql_query($select_up_query); $up_count = 0; $down_count = 0; while ($up_row = mysql_fetch_row($up_result)) { if ($up_row[0] == 1) { $up_count++; } if ($up_row[0] == 0) { $down_count++; } } if ($down_count >= $alarm_threshold && $alert_status == 1) { $timestamp_human = date("d-M-Y H:i:s", $timestamp); $body = "{$svc}({$url}) UP on {$timestamp_human}"; $attachment = ""; // GET ALL THE EMAILS WHO ARE ASSOCIATED WITH THAT HOST ' $select_email_query = sprintf("SELECT email_id\r\n\t\t\t\t\t\t FROM sys_uptime_email\r\n\t\t\t\t\t\t WHERE status = 'active' AND host_id = '%d'", $host_id); $email_result = mysql_query($select_email_query); while ($email_row = mysql_fetch_assoc($email_result)) { $to_email = $email_row['email_id']; ezmail($to_email, $to_email, "URL {$url} UP", $body, $attachment); } } } } }
} // Prepare to send email $esc_subject = "Escalation Level : {$escalation_level} : # {$ticket_id} : {$priority_desc} : {$subject}"; $esc_body = "You are receiving this email, because a ticket has not been closed in the stipulated time\n\n"; $esc_body .= "Logged By : {$source_name} ({$source_email})\n\n"; $esc_body .= "Logged On : {$created_date_print}\n\n"; $esc_body .= "Ticket Type : {$ticket_type}\n\n"; $esc_body .= "Ticket Priority : {$priority_desc}\n\n"; $esc_body .= "Ticket Message : \n\n"; $esc_body .= $ticket_message; // Send EMail $sub_sql = "select * from escalation_email"; $sub_result = mysql_query($sub_sql); $sub_row = mysql_fetch_row($sub_result); $email = $sub_row[0]; ezmail("{$email}", "{$email}", "{$esc_subject}", "{$esc_body}", ""); } } } function rim_master_update($ticket_id, $ticket_date, $ticket_summary, $ticket_type, $ticket_priority, $assigned_to, $escalation_level) { global $MASTER_URL, $MASTER_API_KEY, $AGENCY_ID; // Update RIM Master $url = $MASTER_URL . "/api/rim_master_escalation.php"; $fields = array('key' => urlencode($MASTER_API_KEY), 'agency' => urlencode($AGENCY_ID), 'ticket_id' => urlencode($ticket_id), 'ticket_date' => urlencode($ticket_date), 'ticket_summary' => urlencode($ticket_summary), 'ticket_type' => urlencode($ticket_type), 'ticket_priority' => urlencode($ticket_priority), 'assigned_to' => urlencode($assigned_to), 'escalation_level' => urlencode($escalation_level)); foreach ($fields as $key => $value) { $fields_string .= $key . '=' . $value . '&'; } rtrim($fields_string, '&'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url);
} else { //This section is used to send a notification mail to the respective people to say the system is UP again //Check any server is UP after it went DOWN //$up_count_limit = $alarm_threshold; //Check the last three entries $limit = $alarm_threshold + 1; $select_up_query = "SELECT nw_status FROM hosts_nw_log WHERE host_id={$host_id} ORDER BY record_id DESC LIMIT {$limit}"; $up_result = mysql_query($select_up_query); $up_count = 0; $down_count = 0; while ($up_row = mysql_fetch_row($up_result)) { if ($up_row[0] == 1) { $up_count++; } if ($up_row[0] == 0) { $down_count++; } } if ($down_count >= $alarm_threshold && $alert_status == 1) { $timestamp_human = date("d-M-Y H:i:s", $timestamp); $body = "{$hostname} UP on {$timestamp_human}"; $attachment = ""; // GET ALL THE EMAILS WHO ARE ASSOCIATED WITH THAT HOST ' $select_email_query = sprintf("SELECT email_id\r\n\t\t\t\t\t\t FROM sys_uptime_email\r\n\t\t\t\t\t\t WHERE status = 'active' AND host_id = '%d'", $host_id); $email_result = mysql_query($select_email_query); while ($email_row = mysql_fetch_assoc($email_result)) { $to_email = $email_row['email_id']; ezmail($to_email, $to_email, "System {$hostname} UP", $body, $attachment); } } } }