function CallLog() { global $mysqli; $session =& $_SESSION['CallLog']; $smarty = smarty_init(dirname(__FILE__) . '/templates'); // Init no element on page (PageSize) $PageSize = 50; // Init sort order (Order) if ($session['Sort'] == $_REQUEST['Sort']) { $Order = $session['Order'] == "asc" ? "desc" : "asc"; } elseif ($session['Sort'] != $_REQUEST['Sort']) { $Order = 'desc'; } $session['Order'] = $Order; // Init sort field (Sort) if (isset($_REQUEST['Sort'])) { $Sort = $_REQUEST['Sort']; } else { $Sort = 'StartDate'; } $session['Sort'] = $Sort; // Init listing start (Start) if (isset($_REQUEST['Start'])) { $Start = $_REQUEST['Start']; } else { $Start = 0; } // Init Filter $Filter = init_filter(); // Init total entries (Total) $query = "\n\t\tSELECT COUNT(*) FROM CallLog\n\t\tWHERE\n\t\t\tDATE(StartDate) >= STR_TO_DATE('" . $mysqli->real_escape_string($Filter['StartDate']) . "','%m/%d/%Y')\n\t\t\tAND\n\t\t\tDATE(StartDate) <= STR_TO_DATE('" . $mysqli->real_escape_string($Filter['EndDate']) . "','%m/%d/%Y')\n\t"; $result = $mysqli->query($query) or die($mysqli->error); $row = $result->fetch_array(); $Total = $row[0]; // Init table fields (CDRs) $CDRs = array(); $query = "\n\t\tSELECT\n\t\t\t*,\n\t\t\tDATE_FORMAT(StartDate,'%m/%d/%y %h:%i:%s %p') AS StartDate_Formated\n\t\tFROM\n\t\t\tCallLog\n\t\tWHERE\n\t\t\tDATE(StartDate) >= STR_TO_DATE('" . $mysqli->real_escape_string($Filter['StartDate']) . "','%m/%d/%Y')\n\t\t\tAND\n\t\t\tDATE(StartDate) <= STR_TO_DATE('" . $mysqli->real_escape_string($Filter['EndDate']) . "','%m/%d/%Y')\n\t\tORDER BY\n\t\t\t{$Sort} {$Order}\n\t\tLIMIT {$Start}, {$PageSize}\n\t"; $result = $mysqli->query($query) or die($mysqli->error); while ($row = $result->fetch_assoc()) { $CDRs[] = $row; } // Init end record (End) $End = count($CDRs); $smarty->assign('CDRs', $CDRs); $smarty->assign('Filter', $Filter); $smarty->assign('Sort', $Sort); $smarty->assign('Order', $Order); $smarty->assign('Start', $Start); $smarty->assign('End', $End); $smarty->assign('Total', $Total); $smarty->assign('PageSize', $PageSize); return $smarty->fetch('CallLog.tpl'); }
$MY_GET = "?"; if (isset($_GET)) { foreach ($_GET as $key => $val) { $MY_GET = $MY_GET . "&" . rawurlencode($key) . "=" . rawurlencode($val); } } $MY_GET_NO_SORT = preg_replace('/[?&]{1}sort=[a-z]+/', '', $MY_GET); $MY_GET_NO_SORT = preg_replace('/[?&]{1}order=[01]+/', '', $MY_GET_NO_SORT); $MY_GET_NO_NEXT = preg_replace('/[?&]{1}next=[0-9]+/', '', $MY_GET); $MY_GET_NO_NEXT = preg_replace('/[?&]{1}prev=[0-9]+/', '', $MY_GET_NO_NEXT); $MY_GET_NO_FILT = preg_replace('/[?&]{1}clear=[^&]+/', '', $MY_GET_NO_NEXT); $MY_GET_NO_FILT = preg_replace('/[?&]{1}filter=[^&]+/', '', $MY_GET_NO_FILT); $MY_GET_NO_FILT = preg_replace('/[?&]{1}filtering=[^&]+/', '', $MY_GET_NO_FILT); $MY_GET_NO_FILT = preg_replace('/[?&]{1}clear=[^&]+/', '', $MY_GET_NO_FILT); $MY_QUERY_PARTS = array('define_host_search' => '', 'define_svc_search' => '', 'define_orderby' => '', 'define_expr_cols' => '', 'define_cvar_host_cols' => '', 'define_cvar_svc_cols' => '', 'define_cvar_host_joins' => '', 'define_cvar_svc_joins' => '', 'define_cvar_cols' => '', 'define_my_user' => mysql_real_escape_string($MY_USER, $dbconn), 'define_my_svcfilt' => mysql_real_escape_string($MY_SVCFILT, $dbconn), 'define_my_svcacklist' => mysql_real_escape_string($MY_SVCACKLIST, $dbconn), 'define_my_hostacklist' => mysql_real_escape_string($MY_HOSTACKLIST, $dbconn), 'define_my_hostdownop' => $MY_HOSTDOWNOP, 'define_my_hostdownval' => $MY_HOSTDOWNVAL, 'define_my_svcdownop' => $MY_SVCDOWNOP, 'define_my_svcdownval' => $MY_SVCDOWNVAL, 'define_my_acklistop' => $MY_ACKLISTOP, 'define_my_acklistval' => $MY_ACKLISTVAL, 'define_my_disable' => mysql_real_escape_string($MY_DISABLE, $dbconn), 'define_my_soft' => mysql_real_escape_string($MY_SOFT, $dbconn), 'define_my_nosvc' => mysql_real_escape_string($MY_NOSVC, $dbconn), 'define_my_hostfilt' => mysql_real_escape_string($MY_HOSTFILT, $dbconn), 'define_first' => mysql_real_escape_string($FIRST, $dbconn), 'define_step' => mysql_real_escape_string($LINE_BY_PAGE, $dbconn), 'define_track_anything' => $MY_TRACK_ANY, 'define_host_service' => mysql_real_escape_string($HOST_SERVICE, $dbconn)); if (!init_filter($err, $FILTER)) { die_refresh($err); } init_orderby(); terminate_query(); /* QUERY AND SET GLOBAL COUNTER */ $query_glob = str_replace(array_keys($MY_QUERY_PARTS), array_values($MY_QUERY_PARTS), $QUERY_GLOBAL_COUNT); if (!($rep_glob = mysql_query($query_glob, $dbconn))) { $errno = mysql_errno($dbconn); $txt_error = mysql_error($dbconn); error_log("invalid globalcount query: {$errno}, {$txt_error}"); die_refresh("invalid globalcount query: {$errno}, {$txt_error}"); } $glob_ok = 0; $glob_warning = 0; $glob_critical = 0;