function index() { global $db; #$sql = "SELECT * FROM scan_list as a,target_info as b where a.hash = b.hash"; $sql = "SELECT * FROM scan_list LEFT JOIN target_info ON scan_list.hash = target_info.hash order by createtime desc"; $results = $db->query($sql); if (mysql_num_rows($results) > 0) { $i = 1; while ($fs = $db->fetch_array($results)) { $id = $i; $url = $fs["1"]; $user = $fs["3"]; $pointserver = $fs["4"]; $hash = $fs["11"]; $finishtime = $fs["16"]; $banner = $fs["17"]; $responsive = $fs["18"]; $technologies = $fs["20"]; $os = $fs["19"]; $high = get_severity($hash, 'high'); $middle = get_severity($hash, 'middle'); $low = get_severity($hash, 'low'); if (strtolower($responsive) == 'true') { $class = 'success'; $responsive = "正常"; } else { if (strtolower($responsive) == 'false') { $class = 'error'; $responsive = "错误"; } else { $class = ''; } } $html_str .= "\r\n\t\t\t\t\t\t\t\t\t<tr class=\"{$class}\">\r\n\t\t\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t\t\t{$id}\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td style=\"word-break:break-all; word-wrap:break-word;\">\r\n\t\t\t\t\t\t\t\t\t\t\t<a href=\"?m=info&p={$hash}\">{$url}</a>\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t\t\t{$user}\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t\t\t{$responsive}\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t\t\t{$pointserver}\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t\t\t<a href=\"?m=info&p={$hash}&c=high\"><font color=\"red\">{$high}</font></a>\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t\t\t<a href=\"?m=info&p={$hash}&c=middle\"><font color=\"orange\">{$middle}</font></a>\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t\t\t<a href=\"?m=info&p={$hash}&c=low\"><font color=\"green\">{$low}</font></a>\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t\t\t{$banner}\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t\t\t{$os}\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t\t\t{$finishtime}\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t\t\t<a href=\"?m=info&p={$hash}\">详情</a>|<a href=\"?m=edit&p={$hash}\">编辑</a>|<a href=\"javascript:del('{$hash}')\">删除</a>|<a href=\"javascript:exportexcel('{$hash}')\">报告</a>\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n"; $i++; } return $html_str; } else { return ""; } }
// compress result $sep = $tick_str = ""; for ($i = 0; $i < count($tick_array3); $i++) { $tick_str .= $sep . $tick_array3[$i]; $sep = ","; } // dump($tick_str); $query = "SELECT *, \n\t\tUNIX_TIMESTAMP(problemstart) AS `problemstart`,\n\t\tUNIX_TIMESTAMP(problemend) AS `problemend`,\n\t\t`u`.`user` AS `theuser`,\n\t\tNULL AS `unit_name`,\n\t\t`t`.`scope` AS `tick_scope`,\n\t\t`t`.`id` AS `tick_id`,\n\t\t`t`.`description` AS `tick_descr`,\n\t\t`t`.`status` AS `tick_status`,\n\t\t`t`.`street` AS `tick_street`,\n\t\t`t`.`city` AS `tick_city`,\n\t\t`t`.`state` AS `tick_state`,\t\t\t\n\t\t`f`.`name` AS `facy_name` \n\t\tFROM `{$GLOBALS['mysql_prefix']}ticket`\t\t\t `t`\n\t\tLEFT JOIN `{$GLOBALS['mysql_prefix']}user`\t\t `u` ON (`t`.`_by` = `u`.`id`)\n\t\tLEFT JOIN `{$GLOBALS['mysql_prefix']}facilities` `f` ON (`t`.`facility` = `f`.`id`)\n\t\tWHERE `t`.`id` NOT IN ({$tick_str})\n\t\tAND `t`.`status` <> '{$GLOBALS['STATUS_RESERVED']}'\n\t\tORDER BY `problemstart` ASC"; $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); print "<TR><TD COLSPAN=99 ALIGN='center'><B>Not dispatched</B></TD></TR>"; $units_str = ""; while ($row = stripslashes_deep(mysql_fetch_assoc($result))) { // final while () $deltas[$row['severity']] += $row['problemend'] - $row['problemstart']; // stats $deltas[3] += $row['problemend'] - $row['problemstart']; $counts[$row['severity']]++; $counts[3]++; do_print($row); } print "</TABLE>"; print "<BR /><BR /><SPAN STYLE='margin-left:100px'>Mean incident close times by severity: "; for ($i = 0; $i < 3; $i++) { // each severity level $mean = round($deltas[$i] / $counts[$i]); print "<B>" . ucfirst(get_severity($i)) . "</B> ({$counts[$i]}): " . my_date_diff(0, $mean) . ", "; } $mean = round($deltas[3] / $counts[3]); // overall print "<B>Overall</B> ({$counts[3]}): " . my_date_diff(0, $mean); print "</SPAN><BR /><BR /><BR />";
} print "POST<BR/>\n"; if (!empty($_POST)) { dump($_POST); } } // $remotes = get_current(); // set auto-refresh if any mobile units // $interval = intval(get_variable('auto_poll')); // $refresh = ((($remotes['aprs']) || ($remotes['instam']) || ($remotes['locatea']) || ($remotes['gtrack']) || ($remotes['glat'])) && ($interval>0))? "\t<META HTTP-EQUIV='REFRESH' CONTENT='" . intval($interval*60) . "'>\n": ""; $temp = get_variable('auto_poll'); $poll_val = $temp == 0 ? "none" : $temp; $id = array_key_exists('id', $_GET) ? $_GET['id'] : NULL; $result = mysql_query("SELECT * FROM `{$GLOBALS['mysql_prefix']}ticket` WHERE id='{$id}'"); $row = mysql_fetch_assoc($result); $title = $row['scope']; $ticket_severity = get_severity($row['severity']); $ticket_type = get_type($row['in_types_id']); $ticket_status = get_status($row['status']); $ticket_updated = format_date_time($row['updated']); $ticket_addr = "{$row['street']}, {$row['city']} {$row['state']} "; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <HEAD><TITLE>Incident Popup - Incident <?php print $title; ?> <?php print $ticket_updated; ?> </TITLE> <LINK REL=StyleSheet HREF="stylesheet.php?version=<?php
function do_ticket($theRow, $theWidth, $search = FALSE, $dist = TRUE) { // returns table - 6/26/10 global $iw_width, $nature, $disposition, $patient, $incident, $incidents; // 12/3/10 $tickno = get_variable('serial_no_ap') == 0 ? " <I>(#" . $theRow['id'] . ")</I>" : ""; // 1/25/09 switch ($theRow['severity']) { //color tickets by severity case $GLOBALS['SEVERITY_MEDIUM']: $severityclass = 'severity_medium'; break; case $GLOBALS['SEVERITY_HIGH']: $severityclass = 'severity_high'; break; default: $severityclass = 'severity_normal'; break; } $print = "<TABLE BORDER='0' ID='left' width='" . $theWidth . "'>\n"; // $print .= "<TR CLASS='even'><TD ALIGN='left' CLASS='td_data' COLSPAN=2 ALIGN='center'><B>{$incident}: <I>" . highlight($search, $theRow['scope']) . "</B>" . $tickno . "</TD></TR>\n"; $print .= "<TR CLASS='odd' ><TD ALIGN='left'>" . get_text("Addr") . ":</TD>\t\t<TD ALIGN='left'>" . highlight($search, $theRow['tick_street']) . "</TD></TR>\n"; $print .= "<TR CLASS='even' ><TD ALIGN='left'>" . get_text("City") . ":</TD>\t\t\t<TD ALIGN='left'>" . highlight($search, $theRow['tick_city']); $print .= " " . highlight($search, $theRow['tick_state']) . "</TD></TR>\n"; $print .= "<TR CLASS='odd' ><TD ALIGN='left'>" . get_text("Priority") . ":</TD> <TD ALIGN='left' CLASS='" . $severityclass . "'>" . get_severity($theRow['severity']); $print .= " {$nature}: " . get_type($theRow['in_types_id']); $print .= "</TD></TR>\n"; $print .= "<TR CLASS='even' VALIGN='top'><TD ALIGN='left'>" . get_text("Synopsis") . ":</TD>\t<TD ALIGN='left'>" . replace_quotes(highlight($search, nl2br($theRow['tick_descr']))) . "</TD></TR>\n"; // 8/12/09 $print .= "<TR CLASS='odd' ><TD ALIGN='left'>" . get_text("Protocol") . ":</TD> <TD ALIGN='left' CLASS='{$severityclass}'>{$theRow['protocol']}</TD></TR>\n"; // 7/16/09 $print .= "<TR CLASS='even' VALIGN='top'><TD ALIGN='left'>" . get_text("911 Contacted") . ":</TD>\t<TD ALIGN='left'>" . highlight($search, nl2br($theRow['nine_one_one'])) . "</TD></TR>\n"; // 6/26/10 $print .= "<TR CLASS='odd'><TD ALIGN='left'>" . get_text("Reported by") . ":</TD>\t<TD ALIGN='left'>" . highlight($search, $theRow['contact']) . "</TD></TR>\n"; $print .= "<TR CLASS='even' ><TD ALIGN='left'>" . get_text("Phone") . ":</TD>\t\t\t<TD ALIGN='left'>" . format_phone($theRow['phone']) . "</TD></TR>\n"; $end_date = intval($theRow['problemend']) > 1 ? $theRow['problemend'] : time() - intval(get_variable('delta_mins')) * 60; $elapsed = my_date_diff($theRow['problemstart'], $end_date); $elaped_str = intval($theRow['problemend']) > 1 ? "" : " ({$elapsed})"; $print .= "<TR CLASS='odd'><TD ALIGN='left'>" . get_text("Status") . ":</TD>\t\t<TD ALIGN='left'>" . get_status($theRow['status']) . "{$elaped_str}</TD></TR>\n"; $by_str = $theRow['call_taker'] == 0 ? "" : " by " . get_owner($theRow['call_taker']) . " "; // 1/7/10 $print .= "<TR CLASS='even'><TD ALIGN='left'>" . get_text("Written") . ":</TD>\t\t<TD ALIGN='left'>" . format_date($theRow['date']) . $by_str; $print .= " Updated: " . format_date($theRow['updated']) . "</TD></TR>\n"; $print .= empty($theRow['booked_date']) ? "" : "<TR CLASS='odd'><TD ALIGN='left'>Scheduled date:</TD>\t\t<TD ALIGN='left'>" . format_date($theRow['booked_date']) . "</TD></TR>\n"; // 10/6/09 $print .= "<TR CLASS='even' ><TD ALIGN='left' COLSPAN='2'> \t<TD ALIGN='left'></TR>\n"; // separator $print .= empty($theRow['fac_name']) ? "" : "<TR CLASS='odd' ><TD ALIGN='left'>{$incident} at Facility:</TD>\t\t<TD ALIGN='left'>" . highlight($search, $theRow['fac_name']) . "</TD></TR>\n"; // 8/1/09 $print .= empty($theRow['rec_fac_name']) ? "" : "<TR CLASS='even' ><TD ALIGN='left'>Receiving Facility:</TD>\t\t<TD ALIGN='left'>" . highlight($search, $theRow['rec_fac_name']) . "</TD></TR>\n"; // 10/6/09 $print .= empty($theRow['comments']) ? "" : "<TR CLASS='odd' VALIGN='top'><TD ALIGN='left'>{$disposition}:</TD>\t<TD ALIGN='left'>" . replace_quotes(highlight($search, nl2br($theRow['comments']))) . "</TD></TR>\n"; $print .= "<TR CLASS='even' ><TD ALIGN='left'>" . get_text("Run Start") . ":</TD>\t\t\t\t\t<TD ALIGN='left'>" . format_date($theRow['problemstart']); $elaped_str = intval($theRow['problemend']) > 1 ? $elapsed : ""; $print .= " End: " . format_date($theRow['problemend']) . " ({$elaped_str})</TD></TR>\n"; $locale = get_variable('locale'); // 08/03/09 switch ($locale) { case "0": $grid_type = " USNG " . LLtoUSNG($theRow['lat'], $theRow['lng']); break; case "1": $grid_type = " OSGB " . LLtoOSGB($theRow['lat'], $theRow['lng']); // 8/23/08, 10/15/08, 8/3/09 break; case "2": $coords = $theRow['lat'] . "," . $theRow['lng']; // 8/12/09 $grid_type = " UTM " . toUTM($coords); // 8/23/08, 10/15/08, 8/3/09 break; default: print "ERROR in " . basename(__FILE__) . " " . __LINE__ . "<BR />"; } $print .= "<TR CLASS='odd'><TD ALIGN='left' onClick = 'javascript: do_coords(" . $theRow['lat'] . "," . $theRow['lng'] . ")'><U>" . get_text("Position") . "</U>: </TD>\n\t\t<TD ALIGN='left'>" . get_lat($theRow['lat']) . " " . get_lng($theRow['lng']) . $grid_type . "</TD></TR>\n"; // 9/13/08 $print .= "<TR><TD colspan=2 ALIGN='left'>"; $print .= show_log($theRow[0]); // log $print .= "</TD></TR>"; $print .= "<TR STYLE = 'display:none;'><TD colspan=2><SPAN ID='oldlat'>" . $theRow['lat'] . "</SPAN><SPAN ID='oldlng'>" . $theRow['lng'] . "</SPAN></TD></TR>"; $print .= "</TABLE>\n"; $print .= show_assigns(0, $theRow[0]); // 'id' ambiguity - 7/27/09 $print .= show_actions($theRow[0], "date", FALSE, FALSE); return $print; }
');"><?php print get_text("Priority"); ?> </SPAN>: <SELECT NAME="frm_severity" tabindex=6> <OPTION VALUE="0" SELECTED><?php print get_severity($GLOBALS['SEVERITY_NORMAL']); ?> </OPTION> <OPTION VALUE="1"><?php print get_severity($GLOBALS['SEVERITY_MEDIUM']); ?> </OPTION> <OPTION VALUE="2"><?php print get_severity($GLOBALS['SEVERITY_HIGH']); ?> </OPTION> </SELECT> </TD> </TR> <TR CLASS='odd'> <!-- 3/15/11 --> <TD CLASS="td_label" onmouseout="UnTip()" onmouseover="Tip('<?php print $titles["_proto"]; ?> ');"><?php print get_text("Protocol"); ?> </A>:</SPAN></TD>
function do_im_report($date_in, $func_in) { // incident mgmt report $frm_date, $mode as params - 9/27/10 global $types, $tick_array, $deltas, $counts, $severities, $units_str, $evenodd, $logs, $types; global $types, $incident, $disposition; // 12/7/10 global $w_tiny, $w_small, $w_medium, $w_large; // 4/14/11 $tick_array = array(0); $deltas = array(0, 0, 0, 0); // normal, medium, high, total $counts = array(0, 0, 0, 0); // $severities = array("", "M", "H"); // severity symbols $from_to = date_range($date_in, $func_in); // get date range as array $where = " WHERE `problemstart` >= '{$from_to[0]}' AND `problemstart` < '{$from_to[1]}'"; function do_print($row_in) { global $today, $today_ref, $line_ctr, $units_str, $severities, $evenodd; global $w_tiny, $w_small, $w_medium, $w_large; if (empty($today)) { $today_ref = date("z", $row_in['problemstart']); $today = substr(format_date($row_in['problemstart']), 0, 5); } else { if (!($today_ref == date("z", $row_in['problemstart']))) { // date change? $today_ref = date("z", $row_in['problemstart']); $today = substr(format_date($row_in['problemstart']), 0, 5); } } $def_city = get_variable('def_city'); $def_st = get_variable('def_st'); print "<TR CLASS = '{$evenodd[$line_ctr % 2]}' onClick = 'open_tick_window(" . $row_in['tick_id'] . ");' >\n"; print "<TD>{$today}</TD>\n"; // Date - $problemstart = format_date($row_in['problemstart']); $problemstart_sh = short_ts($problemstart); print "<TD onMouseover=\"Tip('{$problemstart}');\" onmouseout='UnTip();'>{$problemstart_sh}</TD>\n"; // start $problemend = format_date($row_in['problemend']); $problemend_sh = short_ts($problemend); print "<TD onMouseover=\"Tip('{$problemend}');\" onmouseout='UnTip();'>{$problemend_sh}</TD>\n"; // end $elapsed = intval($row_in['problemstart']) > 0 && intval($row_in['problemend']) > 0 ? my_date_diff($row_in['problemstart'], $row_in['problemend']) : "na"; print "<TD>{$elapsed}</TD>\n"; // Ending time print "<TD ALIGN='center'>{$severities[$row_in['severity']]}</TD>\n"; $scope = $row_in['tick_scope']; $scope_sh = shorten($row_in['tick_scope'], $w_medium); print "<TD onMouseover=\"Tip('{$scope}');\" onmouseout='UnTip();'>{$scope_sh}</TD>\n"; // Call type $comment = $row_in['comments']; $short_comment = shorten($row_in['comments'], $w_large); print "<TD onMouseover=\"Tip('{$comment}');\" onMouseout='UnTip();'>{$short_comment}</TD>\n"; // Comments/Disposition $facility = $row_in['facy_name']; $facility_sh = shorten($row_in['facy_name'], $w_small); print "<TD onMouseover=\"Tip('{$facility}');\" onmouseout='UnTip();'>{$facility_sh}</TD>\n"; // Facility $city = $row_in['tick_city'] == $def_city ? "" : ", {$row_in['tick_city']}"; $st = $row_in['tick_state'] == $def_st ? "" : ", {$row_in['tick_state']}"; $addr = "{$row_in['tick_street']}{$city}{$st}"; $addr_sh = shorten($row_in['tick_street'] . $city . $st, $w_medium); print "<TD onMouseover=\"Tip('{$addr}');\" onMouseout='UnTip();'>{$addr_sh}</TD>\n"; // Street addr print "<TD>{$units_str}</TD>\n"; // Units responding print "</TR>\n\n"; $line_ctr++; } // end function do print() function do_stats($in_row) { // global $deltas, $counts; if (intval($in_row['problemstart']) > 0 && intval($in_row['problemend']) > 0) { $deltas[$in_row['severity']] += $in_row['problemend'] - $in_row['problemstart']; $deltas[3] += $in_row['problemend'] - $in_row['problemstart']; } $counts[$in_row['severity']]++; $counts[3]++; } // end function do stats() // 12/7/10 function do_print_log($ary_in) { // ["code"]=> string(1) "3" ["info"]=> string(14) "test test test" ["when"]=> string(10) "1302117158" global $today, $today_ref, $line_ctr, $evenodd, $types; global $w_tiny, $w_small, $w_medium, $w_large; print "<TR CLASS = '{$evenodd[$line_ctr % 2]}'>\n"; print "<TD>{$today}</TD>\n"; // Date - $when = format_date($ary_in['when']); $when_sh = short_ts($when); print "<TD onMouseover=\"Tip('{$when}');\" onmouseout='UnTip();'>{$when_sh}</TD>\n"; // start print "<TD COLSPAN=3></TD>\n"; // end Ending time print "<TD><I>Log entry:</I></TD>\n"; // Call type $info = $ary_in['info']; $sh_info = shorten($ary_in['info'], $w_large); print "<TD onMouseover=\"Tip('{$info}');\" onMouseout='UnTip();'>{$sh_info}</TD>\n"; // Comments/Disposition print "<TD>{$ary_in['user']}</TD>\n"; // Facility print "<TD COLSPAN=2></TD>\n"; // Street addr, Units responding print "</TR>\n\n"; $line_ctr++; } // end function do print_log() // populate global logs array $where_l = str_replace("problemstart", "when", $where); // log version - 7/22/11 $query = "SELECT `l`.`code`, `l`.`info` AS `info`, UNIX_TIMESTAMP(`l`.`when`) AS `when`, `u`.`user`, `u`.`info` AS `user_info`\n\t\t\t\tFROM `{$GLOBALS['mysql_prefix']}log` `l`\n\t\t\t\tLEFT JOIN `{$GLOBALS['mysql_prefix']}user` u ON (`l`.who = u.id)\n\t\t\t\t{$where_l}\n\t\t\t\tAND (`code` = {$GLOBALS['LOG_COMMENT']})\n\t\t\t\tORDER BY `when` ASC"; $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); while ($row = stripslashes_deep(mysql_fetch_assoc($result))) { array_push($logs, $row); } unset($result); function check_logs($in_time) { // prints qualifying log entries global $logs; while (!empty($logs) && $logs[0]['when'] <= $in_time) { do_print_log($logs[0]); array_shift($logs); // remove 1st entry } } // end function check_logs() $query = "SELECT *, UNIX_TIMESTAMP(problemstart) AS `problemstart`,\n\t\t\t\tUNIX_TIMESTAMP(problemend) AS `problemend`,\n\t\t\t\t`a`.`id` AS `assign_id` ,\n\t\t\t\t`a`.`comments` AS `assign_comments`,\n\t\t\t\t`u`.`user` AS `theuser`, `t`.`scope` AS `tick_scope`,\n\t\t\t\t`t`.`id` AS `tick_id`,\n\t\t\t\t`t`.`description` AS `tick_descr`,\n\t\t\t\t`t`.`status` AS `tick_status`,\n\t\t\t\t`t`.`street` AS `tick_street`,\n\t\t\t\t`t`.`city` AS `tick_city`,\n\t\t\t\t`t`.`state` AS `tick_state`,\t\t\t\n\t\t\t\t`r`.`id` AS `unit_id`,\n\t\t\t\t`r`.`name` AS `unit_name` ,\n\t\t\t\t`r`.`type` AS `unit_type` ,\n\t\t\t\t`f`.`name` AS `facy_name` ,\n\t\t\t\t`a`.`as_of` AS `assign_as_of`\n\t\t\t\tFROM `{$GLOBALS['mysql_prefix']}assigns` `a`\n\t\t\t\tLEFT JOIN `{$GLOBALS['mysql_prefix']}ticket`\t `t` ON (`a`.`ticket_id` = `t`.`id`)\n\t\t\t\tLEFT JOIN `{$GLOBALS['mysql_prefix']}user`\t\t `u` ON (`a`.`user_id` = `u`.`id`)\n\t\t\t\tLEFT JOIN `{$GLOBALS['mysql_prefix']}responder`\t `r` ON (`a`.`responder_id` = `r`.`id`)\n\t\t\t\tLEFT JOIN `{$GLOBALS['mysql_prefix']}facilities` `f` ON (`a`.`facility_id` = `f`.`id`)\n\t\t\t\t{$where}\n\t\t\t\tAND `t`.`status` <> '{$GLOBALS['STATUS_RESERVED']}'\t\t\t\t\n\t\t\t\tORDER BY `problemstart` ASC"; $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); //dump($query); print "<TABLE BORDER=0 ALIGN='center' cellspacing = 1 CELLPADDING = 4 ID='IM' STYLE='display:block'>"; $to_str = $func_in == "dr" ? "" : " to {$from_to[3]} " . substr($from_to[1], 0, 4); print "<TR CLASS='even'><TH COLSPAN=99 ALIGN = 'center'>" . "{$incident} Management Report - " . $from_to[2] . $to_str . "</TH></TR>\n"; print "<TR CLASS='odd'>\n\t\t\t\t\t<TD><B>Date</B></TD>\n\t\t\t\t\t<TD><B>Opened</B></TD>\n\t\t\t\t\t<TD><B>Closed</B></TD>\n\t\t\t\t\t<TD><B>Elapsed</B></TD>\n\t\t\t\t\t<TD><B>Severity</B></TD>\n\t\t\t\t\t<TD><B>Call type</B></TD>\n\t\t\t\t\t<TD><B>Comments/{$disposition}</B></TD>\n\t\t\t\t\t<TD><B>Facility</B></TD>\n\t\t\t\t\t<TD><B>Address</B></TD>\n\t\t\t\t\t<TD><B>" . get_text("Unit") . " responding</B></TD>\n\t\t\t\t\t</TR>"; if (mysql_num_rows($result) == 0) { // empty? print "<TR CLASS = 'even'><TH COLSPAN=99>none</TH></TR>\n"; print "<TR CLASS = 'odd'><TD COLSPAN=99><BR /><BR /></TD></TR>\n"; } else { $units_str = ""; $i = 0; $today = $today_ref = ""; $buffer = ""; $sep = ", "; while ($row = stripslashes_deep(mysql_fetch_assoc($result))) { // major while () array_push($tick_array, $row['tick_id']); // stack them up if (empty($buffer)) { // first time $buffer = $row; $units_str = $row['unit_name']; } else { // not first time if ($row['tick_id'] == $buffer['tick_id']) { $units_str .= $sep . $row['unit_name']; // no change, collect unit names // $buffer = $row; } else { check_logs($buffer['problemstart']); // problemstart integer do_print($buffer); // print from buffer do_stats($buffer); $buffer = $row; $units_str = $row['unit_name']; } } // end if/else } // end while( check_logs(time()); // everything remaining do_print($buffer); // print from buffer do_stats($buffer); } // end else{} $tick_array2 = array_unique($tick_array); // delete dupes $tick_array3 = array_values($tick_array2); // compress result $sep = $tick_str = ""; for ($i = 0; $i < count($tick_array3); $i++) { $tick_str .= $sep . $tick_array3[$i]; $sep = ","; } $query = "SELECT *, \n\t\t\t\tUNIX_TIMESTAMP(problemstart) AS `problemstart`,\n\t\t\t\tUNIX_TIMESTAMP(problemend) AS `problemend`,\n\t\t\t\t`u`.`user` AS `theuser`,\n\t\t\t\tNULL AS `unit_name`,\n\t\t\t\t`t`.`scope` AS `tick_scope`,\n\t\t\t\t`t`.`id` AS `tick_id`,\n\t\t\t\t`t`.`description` AS `tick_descr`,\n\t\t\t\t`t`.`status` AS `tick_status`,\n\t\t\t\t`t`.`street` AS `tick_street`,\n\t\t\t\t`t`.`city` AS `tick_city`,\n\t\t\t\t`t`.`state` AS `tick_state`,\t\t\t\n\t\t\t\t`f`.`name` AS `facy_name` \n\t\t\t\tFROM `{$GLOBALS['mysql_prefix']}ticket`\t\t\t `t`\n\t\t\t\tLEFT JOIN `{$GLOBALS['mysql_prefix']}user`\t\t `u` ON (`t`.`_by` = `u`.`id`)\n\t\t\t\tLEFT JOIN `{$GLOBALS['mysql_prefix']}facilities` `f` ON (`t`.`facility` = `f`.`id`)\n\t\t\t\t{$where}\n\t\t\t\tAND `t`.`id` NOT IN ({$tick_str})\n\t\t\t\tAND `t`.`status` <> '{$GLOBALS['STATUS_RESERVED']}'\n\t\t\t\tORDER BY `problemstart` ASC"; // dump($query); $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); print "<TR><TD COLSPAN=99 ALIGN='center'><B>Not dispatched</B></TD></TR>"; if (mysql_num_rows($result) == 0) { print "<TR CLASS='even'><TD COLSPAN=99 ALIGN='center'><B>none</B></TD></TR>"; } else { $units_str = ""; while ($row = stripslashes_deep(mysql_fetch_assoc($result))) { // incidents not dispatched do_print($row); do_stats($row); } } if ($counts[3] > 0) { // any stats? print "<TR><TD COLSPAN=99 ALIGN='center'><B><BR />Mean incident close times by severity: "; for ($i = 0; $i < 3; $i++) { // each severity level if ($counts[$i] > 0) { $mean = round($deltas[$i] / $counts[$i]); print "<B>" . ucfirst(get_severity($i)) . "</B> ({$counts[$i]}): " . my_date_diff(0, $mean) . ", "; } } $mean = round($deltas[3] / $counts[3]); // overall print "<B>Overall</B> ({$counts[3]}): " . my_date_diff(0, $mean); print "</B></TD></TR>"; } print "</TABLE>"; return; }
function mail_it($to_str, $text, $ticket_id, $text_sel = 1, $txt_only = FALSE) { // 10/6/08, 10/15/08, 2/18/09, 3/7/09 global $istest; /* Subject A Inciden B Title Priorit C Priorit Nature D Nature Written E Written Updated F As of Reporte G By Phone: H Phone: Status: I Status: Address J Location Descrip K Descrip Disposi L Disposi Start/end M Map: " N Map: " Actions O Patients P Host Q 911 contact R // 6/26/10 */ switch ($text_sel) { // 7/7/09 case 1: $match_str = strtoupper(get_variable("msg_text_1")); // note case break; case 2: $match_str = strtoupper(get_variable("msg_text_2")); break; case 3: $match_str = strtoupper(get_variable("msg_text_3")); break; } if (empty($match_str)) { $match_str = " " . implode("", range("A", "R")); } // empty get all - force non-zero hit // require_once("cell_addrs.inc.php"); // 10/22/08 // snap (__LINE__, count($cell_addrs)); // $cell_addrs = array( "vtext.com", "messaging.sprintpcs.com", "txt.att.net", "vmobl.com", "myboostmobile.com"); // 10/5/08 // if ($istest) {array_push($cell_addrs, "gmail.com");}; $query = "SELECT * FROM `{$GLOBALS['mysql_prefix']}ticket` WHERE `id`='{$ticket_id}' LIMIT 1"; $ticket_result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); $t_row = stripslashes_deep(mysql_fetch_array($ticket_result)); // dump($t_row); $eol = "\n"; $locale = get_variable('locale'); $message = ""; $_end = good_date_time($t_row['problemend']) ? " End:" . $t_row['problemend'] : ""; // for ($i = 0; $i < strlen($match_str); $i++) { if (!($match_str[$i] == " ")) { switch ($match_str[$i]) { case "A": break; case "B": $message .= "Incident: " . $t_row['scope'] . $eol; break; case "C": $message .= "Priority: " . get_severity($t_row['severity']) . $eol; break; case "D": $message .= "Nature: " . get_type($t_row['in_types_id']) . $eol; break; case "J": $str = ""; $str .= empty($t_row['street']) ? "" : $t_row['street'] . " "; $str .= empty($t_row['city']) ? "" : $t_row['city'] . " "; $str .= empty($t_row['state']) ? "" : $t_row['state']; $message .= empty($str) ? "" : "Addr: " . $str . $eol; break; case "K": $message .= empty($t_row['description']) ? "" : "Descr: " . wordwrap($t_row['description']) . $eol; break; case "G": $message .= "Reported by: " . $t_row['contact'] . $eol; break; case "H": $message .= empty($t_row['phone']) ? "" : "Phone: " . format_phone($t_row['phone']) . $eol; break; case "E": $message .= empty($t_row['date']) ? "" : "Written: " . format_date_time($t_row['date']) . $eol; break; case "F": $message .= "Updated: " . format_date_time($t_row['updated']) . $eol; break; case "I": $message .= "Status: " . get_status($t_row['status']) . $eol; break; case "L": $message .= empty($t_row['comments']) ? "" : "Disp: " . wordwrap($t_row['comments']) . $eol; break; case "M": $message .= get_text("Run Start") . ": " . format_date_time($t_row['problemstart']) . $_end . $eol; break; case "N": if ($locale == 0) { $usng = LLtoUSNG($t_row['lat'], $t_row['lng']); $message .= "Map: " . $t_row['lat'] . " " . $t_row['lng'] . ", " . $usng . "\n"; } if ($locale == 1) { $osgb = LLtoOSGB($t_row['lat'], $t_row['lng']); $message .= "Map: " . $t_row['lat'] . " " . $t_row['lng'] . ", " . $osgb . "\n"; } if ($locale == 2) { $utm = LLtoUTM($t_row['lat'], $t_row['lng']); $message .= "Map: " . $t_row['lat'] . " " . $t_row['lng'] . ", " . $utm . "\n"; } break; case "P": $query = "SELECT * FROM `{$GLOBALS['mysql_prefix']}patient` WHERE ticket_id='{$ticket_id}'"; $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); if (mysql_affected_rows() > 0) { $message .= "\nPatient:\n"; while ($pat_row = stripslashes_deep(mysql_fetch_array($result))) { $message .= $pat_row['name'] . ", " . $pat_row['updated'] . "- " . wordwrap($pat_row['description'], 70) . "\n"; } } unset($result); break; case "O": $query = "SELECT * FROM `{$GLOBALS['mysql_prefix']}action` WHERE `ticket_id`='{$ticket_id}'"; // 10/16/08 $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); // 3/22/09 if (mysql_affected_rows() > 0) { $message .= "\nActions:\n"; $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); while ($act_row = stripslashes_deep(mysql_fetch_array($result))) { $message .= $act_row['updated'] . " - " . wordwrap($act_row['description'], 70) . "\n"; } } unset($result); break; case "Q": $message .= "Tickets host: " . get_variable('host') . $eol; break; case "R": // 6/26/10 $message .= empty($t_row['nine_one_one']) ? "" : get_text('911 Contacted') . ": " . wordwrap($t_row['nine_one_one']) . $eol; // 11/10/11 break; default: $message = "Match string error:" . $match_str[$i] . " " . $match_str . $eol; } // end switch () } // end if(!($match_...)) } // end for ($i...) $message = str_replace("\n.", "\n..", $message); // see manual re mail win platform peculiarities $subject = strpos($match_str, "A") ? $text . $t_row['scope'] . " (#" . $t_row['id'] . ")" : ""; if ($txt_only) { return $subject . "\n" . $message; // 2/16/09 } else { do_send($to_str, $subject, $message); } }
</TD></TR> <TR CLASS=even VALIGN="top"><TD CLASS="td_label" ALIGN="right">Type:</TD> <TD><?php print $row['type']; ?> </TD></TR> <TR CLASS=odd VALIGN="top"><TD CLASS="td_label" ALIGN="right">Description:</TD> <TD><?php print $row['description']; ?> </TD></TR> <TR CLASS=even VALIGN="top"><TD CLASS="td_label" ALIGN="right">Protocol:</TD> <TD><?php print $row['protocol']; ?> </TD></TR> <TR CLASS=odd VALIGN="top"><TD CLASS="td_label" ALIGN="right">Severity:</TD> <TD><?php print get_severity($row['set_severity']); ?> </TD></TR> <TR CLASS=even VALIGN="top"><TD CLASS="td_label" ALIGN="right">Group:</TD> <TD><?php print $row['group']; ?> </TD></TR> <TR CLASS=odd VALIGN="top"><TD CLASS="td_label" ALIGN="right">Sort:</TD> <TD><?php print $row['sort']; ?> </TD></TR> <TR CLASS=even VALIGN="top"><TD CLASS="td_label" ALIGN="right">Radius:</TD> <TD><?php print $row['radius']; ?> </TD></TR> <TR CLASS=odd VALIGN="top"><TD CLASS="td_label" ALIGN="right">Color:</TD> <TD><?php
function export() { global $db; require LDINC . '/XmlExcel.php'; $title1 = array('URL', 'User', 'Status', '节点IP', 'High', 'Middle', 'Low', 'Banner', 'OS', 'Finishtime'); $title2 = array('Id', 'Type', 'Level', 'Webpath', 'Param', 'details', 'Request'); if (!empty($_GET['hash'])) { $hash = $_GET['hash']; $xls = new XmlExcel(); $xls->setDefaultWidth(80); $xls->setDefaultAlign("center"); $xls->setDefaultHeight(30); $xls->addHead($title1, 'info'); $sql = "SELECT a.url,a.user,a.pointserver,b.finishtime,b.banner,b.os,b.responsive FROM scan_list as a,target_info as b where a.hash = b.hash and a.hash = '{$hash}'"; $results = $db->fetch_assoc($sql); $url = $results['url']; $user = $results['user']; $pointserver = $results['pointserver']; $finishtime = $results['finishtime']; $banner = $results['banner']; $os = $results['os']; $status = $results['responsive']; $high = get_severity($hash, 'high'); $middle = get_severity($hash, 'middle'); $low = get_severity($hash, 'low'); $data_arr = array($url, $user, $status, $pointserver, $high, $middle, $low, $banner, $os, $finishtime); $xls->addRow($data_arr, 'info'); $xls->addHead($title2, 'vulnerability'); $sql = "SELECT * FROM target_vul where hash='{$hash}' order by Severity"; $results = $db->query($sql); if (mysql_num_rows($results) > 0) { $i = 1; while ($fs = $db->fetch_array($results)) { $id = $i; $Name = $fs["name"]; $Affects = $fs["affects"]; $Parameter = $fs["parameter"]; $Severity = $fs["severity"]; $details = $fs["details"]; $Request = str_replace("\r\n", ' ', urldecode($fs["request"])); //$Response = str_replace("\r\n",' ',urldecode($fs["response"])); if (strtolower($Severity) == 'high') { $class = 'error'; } else { if (strtolower($Severity) == 'middle') { $class = 'warning'; } else { if (strtolower($Severity) == 'low' or strtolower($Severity) == 'info') { $class = 'info'; } } } if ($Parameter == 'Array') { $Parameter = ''; } if ($Request == 'Array') { $Request = ''; } /* if ($Response == 'Array'){ $Response = ''; } */ $vul_arr = array($id, $Name, $Severity, $Affects, $Parameter, $details, $Request); $xls->addRow($vul_arr, 'vulnerability'); } } $xls->export($hash); } }