displayError("--sircrit needs to be bigger than --sirwarn"); } $iCurrentEpoch = date('U'); $iDiffEpoch = $iCurrentEpoch - $data['SearchIndexRebuildLast']; if (empty($data['SearchIndexRebuildLast'])) { update_err_state(3, "Search Index never built"); } elseif ($data['SearchIndexRebuildLast'] < $iCurrentEpoch - $crit) { update_err_state(1, "Search Index older than {$crit} sec|time=" . $iDiffEpoch . "s;;;0"); } elseif ($data['SearchIndexRebuildLast'] < $iCurrentEpoch - $warn) { update_err_state(1, "Search Index older than {$warn} sec|time=" . $iDiffEpoch . "s;;;0"); } elseif ($data['SearchIndexRebuildLast'] > $iCurrentEpoch - $warn) { update_err_state(0, "Search Index is fresh|time=" . $iDiffEpoch . "s;;;0"); } else { update_err_state(3, "Search index state unknown"); } } $options = get_opts(); if (empty($options) or isset($options['h'])) { help(); exit(1); } $data = get_data($options); if (isset($options['c'])) { $check = 'check_' . $options['c']; $check($data, $options); } else { check_bcc($data, $options); check_db($data, $options); check_searchindex($data, $options); } report();
</td> <td class="bar-search" align="center"> По : <select name="tostatsday"> <?php echo get_opts(1, 31, $tostatsday); ?> </select> <select name="tostatsmonth"> <?php echo get_opts(1, 12, $tostatsmonth); ?> </select> <select name="tostatsyear"> <?php echo get_opts(2010, Date("Y"), $tostatsyear); ?> </select> </td></tr></table> </td> </tr> <tr> <td class="bar-search" align="left" bgcolor="#777777"> </td> <td class="bar-search" align="center" bgcolor="#eeeeee"> <input type="submit" name="image16" align="top" border="0" value="Поиск" /> </td> </tr> </tbody></table> </FORM>
echo jquery_date_control("to", "tostatsday", "tostatsmonth", "tostatsyear"); ?> <?php echo __('Часы'); ?> : <select name="fromhour"> <?php echo get_opts(0, 23, $fromhour); ?> </select> - <select name="tohour"> <?php echo get_opts(0, 23, $tohour); ?> </select> <input type="submit" value=" <?php echo __('Просмотреть'); ?> "> </FORM></center> <?php for ($i = 0; $i < count($period); $i++) { $calls_c = values("SELECT COUNT(*) AS c, SUM(duration) AS timesum, AVG(billsec) AS timeavg FROM asteriskcdrdb.cdr WHERE calldate BETWEEN " . $period[$i] . "" . $time[$i] . $queue_restr . " AND dcontext LIKE '%incoming%' AND lastapp!='Transferred Call' AND ((lastapp!='Transferred Call' AND (dst LIKE '" . mysql_escape_string($restr) . "' OR userfield LIKE '" . mysql_escape_string($restr) . "' OR dstchannel LIKE '" . $agent_restr . "')) OR (lastapp='Transferred Call' AND lastdata LIKE 'Local/" . mysql_escape_string($restr) . "@%'))"); $vals[$i][0] = $calls_c[0]['c']; //echo "<!--SELECT COUNT(*) AS c, SUM(duration) AS timesum, AVG(billsec) AS timeavg FROM asteriskcdrdb.cdr WHERE calldate BETWEEN ".$period[$i]."".$time[$i].$queue_restr." AND dcontext LIKE '%incoming%' AND ((lastapp!='Transferred Call' AND (dst LIKE '".mysql_escape_string($restr)."' OR userfield LIKE '".mysql_escape_string($restr)."' OR dstchannel LIKE '".$agent_restr."')) OR (lastapp='Transferred Call' AND lastdata LIKE 'Local/".mysql_escape_string($restr)."@%'))-->"; $calls_out = values("SELECT COUNT(*) AS c, SUM(duration) AS timesum, AVG(billsec) AS timeavg FROM asteriskcdrdb.cdr WHERE calldate BETWEEN " . $period[$i] . "" . $time[$i] . $queue_restr . " AND dcontext NOT LIKE '%incoming%' AND src LIKE '" . mysql_escape_string($restr) . "'");
function get_filters($set, $add_custom = "", $silent_out = 0) { global $sModule, $iUsrId, $fromstatsday, $fromstatsmonth, $fromstatsyear, $tostatsday, $tostatsmonth, $tostatsyear, $filter_status_ans, $filter_status_noans, $filter_dst1, $filter_dst2, $filter_dst3, $filter_number1, $filter_number2, $filter_number3, $cur_lang, $conf_realtime_db, $per_page_arr, $perpage, $fromhour, $tohour; if (!isset($fromstatsday)) { $fromstatsday = date("d"); } if (!isset($fromstatsmonth)) { $fromstatsmonth = date("m"); } if (!isset($fromstatsyear)) { $fromstatsyear = date("Y"); } if (!isset($tostatsday)) { $tostatsday = date("d"); } if (!isset($tostatsmonth)) { $tostatsmonth = date("m"); } if (!isset($tostatsyear)) { $tostatsyear = date("Y"); } if (!isset($filter_status)) { $filter_status = 1; } if (!isset($filter_status_ans)) { $filter_status_ans = 1; } if (!isset($filter_status_noans)) { $filter_status_noans = 1; } if (!isset($filter_dst1)) { $filter_dst1 = 1; } if (!isset($filter_dst2)) { $filter_dst2 = 1; } if (!isset($filter_dst3)) { $filter_dst3 = 1; } list($from, $to) = prepare_dates($fromstatsday, $fromstatsmonth, $fromstatsyear, $tostatsday, $tostatsmonth, $tostatsyear); $sel_status = array('', '', '', ''); $sel_status[$filter_status] = ' selected'; $out = '<center> <FORM METHOD=POST ACTION="index.php"> <INPUT TYPE="hidden" NAME="posted" value=1> <table class="bar-status" width="90%" border="0" cellspacing="1" cellpadding="2" align="center"> <tbody> '; if (strpos(" " . $set, "periods")) { $out .= ' <tr> <td align="left" height="22" bgcolor="#777777"> <font face="verdana" size="1" color="#ffffff"><b> ' . __('Периоды') . '</b></font> </td> <td align="left" bgcolor="#eeeeee"> <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#eeeeee"><tr> <td class="bar-search" align="left"> <a href="index.php?module=' . $sModule . '&posted=1&fromstatsday=' . Date("d") . '&fromstatsmonth=' . Date("m") . '&fromstatsyear=' . Date("Y") . '&tostatsday=' . Date("d") . '&tostatsmonth=' . Date("m") . '&tostatsyear=' . Date("Y") . '">' . __('Сегодня') . '</a> | <a href="index.php?module=' . $sModule . '&posted=1&fromstatsday=' . Date("d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))) . '&fromstatsmonth=' . Date("m", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))) . '&fromstatsyear=' . Date("Y", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))) . '&tostatsday=' . Date("d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))) . '&tostatsmonth=' . Date("m", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))) . '&tostatsyear=' . Date("Y", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))) . '">' . __('Вчера') . '</a> | <a href="index.php?module=' . $sModule . '&posted=1&fromstatsday=' . Date("d", mktime(0, 0, 0, date("m"), date("d") - 7, date("Y"))) . '&fromstatsmonth=' . Date("m", mktime(0, 0, 0, date("m"), date("d") - 7, date("Y"))) . '&fromstatsyear=' . Date("Y", mktime(0, 0, 0, date("m"), date("d") - 7, date("Y"))) . '&tostatsday=' . Date("d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))) . '&tostatsmonth=' . Date("m", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))) . '&tostatsyear=' . Date("Y", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))) . '">' . __('Неделя') . '</a> | <a href="index.php?module=' . $sModule . '&posted=1&fromstatsday=' . Date("d", mktime(0, 0, 0, date("m") - 1, date("d"), date("Y"))) . '&fromstatsmonth=' . Date("m", mktime(0, 0, 0, date("m") - 1, date("d"), date("Y"))) . '&fromstatsyear=' . Date("Y", mktime(0, 0, 0, date("m") - 1, date("d"), date("Y"))) . '&tostatsday=' . Date("d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))) . '&tostatsmonth=' . Date("m", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))) . '&tostatsyear=' . Date("Y", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))) . '">' . __('Месяц') . '</a> | <a href="index.php?module=' . $sModule . '&posted=1&fromstatsday=' . Date("d", mktime(0, 0, 0, date("m"), 1, date("Y"))) . '&fromstatsmonth=' . Date("m", mktime(0, 0, 0, date("m"), 1, date("Y"))) . '&fromstatsyear=' . Date("Y", mktime(0, 0, 0, date("m"), 1, date("Y"))) . '&tostatsday=' . Date("d") . '&tostatsmonth=' . Date("m") . '&tostatsyear=' . Date("Y") . '">' . __('В текущем месяце') . '</a> | <a href="index.php?module=' . $sModule . '&posted=1&fromstatsday=' . Date("d", mktime(0, 0, 0, date("m") - 1, 1, date("Y"))) . '&fromstatsmonth=' . Date("m", mktime(0, 0, 0, date("m") - 1, 1, date("Y"))) . '&fromstatsyear=' . Date("Y", mktime(0, 0, 0, date("m") - 1, 1, date("Y"))) . '&tostatsday=' . Date("d", mktime(0, 0, 0, date("m") - 1, 31, date("Y"))) . '&tostatsmonth=' . Date("m", mktime(0, 0, 0, date("m") - 1, 31, date("Y"))) . '&tostatsyear=' . Date("Y", mktime(0, 0, 0, date("m") - 1, 31, date("Y"))) . '">' . __('В прошлом месяце') . '</a> </td> </tr></table> </td> </tr> '; } if (strpos(" " . $set, "dates")) { $out .= ' <tr> <td align="left" bgcolor="#777777"> <font face="verdana" size="1" color="#ffffff"><b> ' . __('Выбор периода') . '</b></font> </td> <td align="left" bgcolor="#eeeeee"> <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#eeeeee"><tr> <td class="bar-search" align="left"> ' . __('С') . ' : <select name="fromstatsday" id="fromstatsday"> ' . get_opts(1, 31, $fromstatsday) . ' </select> <select name="fromstatsmonth" id="fromstatsmonth"> ' . get_opts(1, 12, $fromstatsmonth) . ' </select> <select name="fromstatsyear" id="fromstatsyear"> ' . get_opts(2010, Date("Y"), $fromstatsyear) . ' </select> ' . jquery_date_control("from", "fromstatsday", "fromstatsmonth", "fromstatsyear") . ' ' . __('По') . ' : <select name="tostatsday" id="tostatsday"> ' . get_opts(1, 31, $tostatsday) . ' </select> <select name="tostatsmonth" id="tostatsmonth"> ' . get_opts(1, 12, $tostatsmonth) . ' </select> <select name="tostatsyear" id="tostatsyear"> ' . get_opts(2010, Date("Y"), $tostatsyear) . ' </select> ' . jquery_date_control("to", "tostatsday", "tostatsmonth", "tostatsyear") . ' </td> </tr></table> </td> </tr> '; } if (strpos(" " . $set, "hours")) { $out .= ' <tr> <td align="left" bgcolor="#777777"> <font face="verdana" size="1" color="#ffffff"><b> ' . __('Выбор часов') . '</b></font> </td> <td align="left" bgcolor="#eeeeee"> <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#eeeeee"> <tr><td class="bar-search" align="left"> ' . __('С часа') . ' : <select name="fromhour"> <option value="">' . __('любой') . '</option> ' . get_opts(1, 24, $fromhour) . ' </select> ' . __('по час') . ' : <select name="tohour"> <option value="">' . __('любой') . '</option> ' . get_opts(1, 24, $tohour) . ' </select> ' . __('включительно') . ' </td></tr></table> </td> </tr> '; } if (strpos(" " . $set, "status")) { $out .= ' <tr> <td class="bar-search" align="left" bgcolor="#777777"> <font face="verdana" size="1" color="#ffffff"><b> ' . __('Статус/Направление') . '</b></font> </td> <td align="left" bgcolor="#eeeeee"> <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#eeeeee"><tr> <td class="bar-search" align="left" bgcolor="#eeeeee""> <input type="hidden" name="filter_status_ans" value="0"><input type="checkbox" NAME="filter_status_ans" value="1"' . ($filter_status_ans ? ' checked' : '') . '> <img src="images/phone_ans.png" alt="' . __('Отвеченные') . '"> <a href="index.php?filter_status_ans=' . ($filter_status_ans ? 0 : 1) . '">' . __('Отвеченные') . '</a> <input type="hidden" name="filter_status_noans" value="0"><input type="checkbox" NAME="filter_status_noans" value="1"' . ($filter_status_noans ? ' checked' : '') . '> <img src="images/phone_notanswered.png" alt="' . __('Неотвеченные') . '"> <a href="index.php?filter_status_noans=' . ($filter_status_noans ? 0 : 1) . '">' . __('Неотвеченные') . '</a> </tr></table></td> </tr> '; } if (strpos(" " . $set, "directions")) { $out .= ' <tr> <td class="bar-search" align="left" bgcolor="#777777"> <font face="verdana" size="1" color="#ffffff"><b> ' . __('Статус/Направление') . '</b></font> </td> <td align="left" bgcolor="#eeeeee"> <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#eeeeee"><tr> <td class="bar-search" align="left" bgcolor="#eeeeee""> <input type="hidden" name="filter_dst1" value="0"><input type="checkbox" NAME="filter_dst1" value="1"' . ($filter_dst1 ? ' checked' : '') . '> <img src="images/downarrow.png" alt="' . __('Входящие') . '"> <a href="index.php?filter_dst1=' . ($filter_dst1 ? 0 : 1) . '">' . __('Входящие') . '</a> <input type="hidden" name="filter_dst2" value="0"><input type="checkbox" NAME="filter_dst2" value="1"' . ($filter_dst2 ? ' checked' : '') . '> <img src="images/uparrow3.png" alt="' . __('Исходящие') . '"> <a href="index.php?filter_dst2=' . ($filter_dst2 ? 0 : 1) . '">' . __('Исходящие') . '</a> <input type="hidden" name="filter_dst3" value="0"><input type="checkbox" NAME="filter_dst3" value="1"' . ($filter_dst3 ? ' checked' : '') . '> <img src="images/inner.png" alt="' . __('Внутренние') . '"> <a href="index.php?filter_dst3=' . ($filter_dst3 ? 0 : 1) . '">' . __('Внутренние') . '</a> </tr></table></td> </tr> '; } if (strpos(" " . $set, "serchbynumber")) { $out .= ' <tr> <td class="bar-search" align="left" bgcolor="#777777"> <font face="verdana" size="1" color="#ffffff"><b> ' . __('Поиск по номеру') . '</b></font> </td> <td align="left" bgcolor="#eeeeee"> <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#eeeeee"><tr> <td class="bar-search" align="left"> ' . __('Номер') . ': <input type="text" NAME="filter_number1" value="' . $filter_number1 . '"> ' . __('или') . ' <select name="filter_number2"> <OPTION value="">' . __('Все') . '</option> '; $sipusers = values("SELECT * FROM " . $conf_realtime_db . ".sipusers WHERE 1 ORDER BY name"); for ($i = 0; $i < count($sipusers); $i++) { if ($sipusers[$i]["name"] == $filter_number2) { $sel = ' selected'; } else { $sel = ''; } $out .= '<OPTION value="' . $sipusers[$i]["name"] . '"' . $sel . '>' . $sipusers[$i]["name"] . '</option> '; } $out .= ' </select> ' . __('или') . ' <select name="filter_number3"> <OPTION value="">' . __('Все') . '</option> '; $qs = get_params_array(0, 'input_lines'); for ($i = 0; $i < count($qs); $i++) { $ar = explode(':', $qs[$i]); if (!empty($filter_number3) && strpos(' ' . $qs[$i], $filter_number3)) { $sel = ' selected'; } else { $sel = ''; } $out .= '<OPTION value="' . $ar[1] . '"' . $sel . '>' . $ar[0] . '</option> '; } $out .= ' </select></td> </tr></table> </td> </tr> '; } $out .= $add_custom; $out .= ' <tr> <td class="bar-search" align="left" bgcolor="#777777"> </td> <td class="bar-search" align="left" bgcolor="#eeeeee"> '; if (strpos(" " . $set, "perpage")) { $out .= __('Записей на страницу') . ' <select name="perpage"> '; for ($i = 0; $i < count($per_page_arr); $i++) { if ($per_page_arr[$i] == $perpage) { $sel = ' selected'; } else { $sel = ''; } $out .= '<OPTION value="' . $per_page_arr[$i] . '"' . $sel . '>' . $per_page_arr[$i] . '</option> '; } $out .= ' </select>'; } else { $out .= ' '; } $out .= ' <input type="submit" name="image16" align="top" border="0" value=" ' . __('Обновить') . ' " /> </td> </tr> </tbody></table> </FORM> </center> '; if (!$silent_out) { echo $out; } list($from, $to) = prepare_dates($fromstatsday, $fromstatsmonth, $fromstatsyear, $tostatsday, $tostatsmonth, $tostatsyear); $cdr_restr = " calldate BETWEEN '" . $from . "' AND '" . $to . "'"; if ($fromhour < 10) { $fromhour = '0' . $fromhour; } if ($tohour < 10) { $tohour = '0' . $tohour; } if ($fromhour > 0) { $cdr_restr .= " AND DATE_FORMAT(`calldate`, '%H') >= " . ($fromhour - 1); } if ($fromhour > 0) { $cdr_restr .= " AND DATE_FORMAT(`calldate`, '%H') <= " . ($tohour - 1); } if (!$filter_dst1 and !$filter_dst2 and !$filter_dst3) { $cdr_restr .= " AND dcontext LIKE 'show_nothing'"; } elseif (!$filter_dst1 and !$filter_dst2 and $filter_dst3) { $cdr_restr .= " AND src<=9999 AND dst<=9999"; } elseif (!$filter_dst1 and $filter_dst2 and !$filter_dst3) { $cdr_restr .= " AND dcontext LIKE '%out%' AND (src>9999 OR dst>9999)"; } elseif (!$filter_dst1 and $filter_dst2 and $filter_dst3) { $cdr_restr .= " AND (dcontext LIKE '%out%' OR (src<=9999 AND dst<=9999))"; } elseif ($filter_dst1 and !$filter_dst2 and !$filter_dst3) { $cdr_restr .= " AND dcontext LIKE '%incom%' AND (src>9999 OR dst>9999)"; } elseif ($filter_dst1 and !$filter_dst2 and $filter_dst3) { $cdr_restr .= " AND (dcontext LIKE '%incom%' OR (src<=9999 AND dst<=9999))"; } elseif ($filter_dst1 and $filter_dst2 and !$filter_dst3) { $cdr_restr .= " AND (src>9999 OR dst>9999)"; } else { $cdr_restr .= ""; } if (!$filter_status_ans and !$filter_status_noans) { $cdr_restr .= " AND dcontext LIKE 'show_nothing'"; } elseif ($filter_status_ans and !$filter_status_noans) { $cdr_restr .= " AND disposition = 'ANSWERED' AND dstchannel!=''"; } elseif (!$filter_status_ans and $filter_status_noans) { $cdr_restr .= " AND (disposition != 'ANSWERED' OR dstchannel='')"; } else { $cdr_restr .= ""; } $numbers_restr = get_params($iUsrId, 0, 'numbers_restrictions'); if ($numbers_restr != false and $numbers_restr != '') { $num_restr = ''; $numbers = explode(';', $numbers_restr); for ($i = 0; $i < count($numbers); $i++) { $num_restr .= " OR src='" . mysql_real_escape_string(trim($numbers[$i])) . "' OR dst='" . mysql_real_escape_string(trim($numbers[$i])) . "' OR dstchannel LIKE 'SIP/" . mysql_real_escape_string(trim($numbers[$i])) . "-%'"; } $cdr_restr .= " AND (" . substr($num_restr, 4) . ")"; } if (isset($filter_number1) and trim($filter_number1) != '') { $cdr_restr .= " AND (src LIKE '%" . $filter_number1 . "%' OR dst LIKE '%" . $filter_number1 . "%' OR dstchannel LIKE '%" . $filter_number1 . "%')"; } if (isset($filter_number2) and trim($filter_number2) != '') { $cdr_restr .= " AND (src='" . $filter_number2 . "' OR dst='" . $filter_number2 . "' OR dstchannel LIKE 'SIP/" . $filter_number2 . "-%' OR userfield = '" . $filter_number2 . "')"; } if (isset($filter_number3) and trim($filter_number3) != '') { $cdr_restr .= " AND dcontext LIKE '%" . $filter_number3 . "%'"; } $cs_restr = ''; return array($cdr_restr, $cs_restr); }