* Rolf Bensch, rolf(at)bensch-net(dot)de * * Creation: 2016-08-25 jed * Last Update: $Id$ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. ************************************************************************** */ header('content-type: text/html; charset=utf-8;'); error_reporting(E_ALL); // if "require" fails /* capit2text AJaX-Routinen */ require('capi2text-default-params.inc'); require("../capi2text-params.inc"); require('capi2text-functions.php'); setlocale (LC_ALL, 'de_DE'); $ret = array(); if ($debug) { error_reporting(E_ALL); } else { // disable error handling in production mode error_reporting(0); // suppress php Warning|Notice|Error in output ob_start(); } try { if (! isset($_POST['do'])) throw new Exception("AJaX: missing parameter"); $do = $_POST["do"]; // create phonelist tbody if ($do == "getTbody" ) { $lastUpdate = (isset($_POST['lastUpdate'])) ? $_POST['lastUpdate'] : "0"; $filter_msn = (isset($_POST['filter_msn'])) ? $_POST['filter_msn'] : "0"; $filter_days = (isset($_POST['filter_days'])) ? $_POST['filter_days'] : "0"; if (! $call_file) throw new Exception("getTbody: 'call_file' not defined"); if (! file_exists($call_file)) throw new Exception("getTbody: '$call_file' not found"); $tbody = ''; $callFileTS = filemtime($call_file); $needUpdate = ($lastUpdate < $callFileTS); if ($needUpdate) { $ret['needUpdate'] = $callFileTS; $ret['filter'] = "Filter: Days: $filter_days; MSN: $filter_msn"; // get MSN list for select-box (filter) $arr_msn = getMsnList(); // read call logfile // // 'date' -> date stamp, e.g. '2012-03-13' // 'time' -> time stamp, e.g. '14:15:59' // 'from' -> incoming phone number, e.g. '0221334455' // 'to' -> called MSN (extension), e.g. '31' // 'name' -> name of caller, e.g. 'Hans Mueller' // 'address' -> address of caller, e.g. 'Hauptstr. 111, 41472 Neuss, DE' // 'to_replaced' -> called MSN replacement string, e.g. '31 - fax machine' // 'flag_file' -> path and name of country flag, e.g. './png/country-49.png' // 'country_abbr' -> abbreviation of the country, e.g. 'DE' // 'country_name' -> name of the country, e.g. 'Deutschland' // 'fcolor' -> individual foreground color for this call, based on the MSN, e.g. '#ffee00' // 'bcolor' -> individual background color for this call, based on the MSN, e.g. '#ffee00' // $arr_phone_calls = array(array('date' => '', 'time' => '', 'from' => '', 'to' => '', 'name' => '', 'address' => '', 'to_replaced' => '', 'flag_file' => '', 'country_abbr' => '', 'country_name' => '', 'fcolor' => '', 'bcolor' => '')); $cf = fopen($call_file, 'r'); if (! $cf) throw new Exception("Cannot open file '$call_file'!"); $i = 0; while (!feof($cf)) { // write calls to array list($arr_phone_calls[$i]['date'], $arr_phone_calls[$i]['time'], $arr_phone_calls[$i]['from'], $arr_phone_calls[$i]['to'], $arr_phone_calls[$i]['name'], $arr_phone_calls[$i]['address'], $arr_phone_calls[$i]['to_replaced'], $arr_phone_calls[$i]['flag_file'], $arr_phone_calls[$i]['fcolor'], $arr_phone_calls[$i]['bcolor']) = array_pad(explode("\t", rtrim(fgets($cf, 500))), 10, ''); // suppress loginfo, like '[Ws]' etc. if ($no_loginfo && preg_match("/ \[[CLW]s*\]/", $arr_phone_calls[$i]['name'])) { $arr_phone_calls[$i]['name'] = preg_replace("/ \[[CLW]s*\]/", "", $arr_phone_calls[$i]['name']); } // replace MSN by description $msn_search = $arr_phone_calls[$i]['to']; $arr_phone_calls[$i]['to_replaced'] = $arr_msn[$msn_search]['desc']; $arr_phone_calls[$i]['fcolor'] = $arr_msn[$msn_search]['fcolor']; $arr_phone_calls[$i]['bcolor'] = $arr_msn[$msn_search]['bcolor']; // add flag file name $arr_phone_calls[$i]['flag_file'] = find_flag($arr_phone_calls[$i]['from']); if ($no_flags) { // add country abbreviation $arr_phone_calls[$i]['country_abbr'] = find_country_abbr($arr_phone_calls[$i]['from']); } // add country name $arr_phone_calls[$i]['country_name'] = find_country_name($arr_phone_calls[$i]['from']); $i++; } $i--; fclose($cf); // output data in reverse order $arr_phone_calls=array_reverse($arr_phone_calls,true); $line_count = 0; $prevDate = strtotime("1970-01-02"); foreach($arr_phone_calls as $phone_call) { if ( $phone_call['date'] != "" ) { // not empty, go on ... if ($filter_msn == 0 || $filter_msn == $phone_call['to']) { // valid selection, go on ... if ( $prevDate <> strtotime($phone_call['date'])) { $prevDate = strtotime($phone_call['date']); // calculate the number of days $callDate = strtotime($phone_call['date']); $dateDiff = floor((strtotime("now") - $callDate)/3600/24); if ($filter_days > 0 && $dateDiff > $filter_days ) break; // print date header once per day $dummyDatum = date("d.m.Y",$callDate); $tbody .= "
";
// toggle backup color
$trclass = "call"; // default backgroud-color
$trclass .= " msn" . $phone_call['to']; // set color for MSN if defined in msn-replace
$trclass .= ($EditButton != '') ? " editable" : "";
$flag = ($no_flags) ? $phone_call['country_abbr'] : "