= 1; $num--) { $fname = './png/country-' . substr($phonenumber, 2, $num) . '.png'; if (file_exists($fname)) { // file found break; } } } elseif (($GLOBALS["default_ccode"] <> "423") && (!preg_match('/^0[^0]/', $phonenumber))) { // not country Liechtenstein and not starting with 0, internal caller $fname = './internal-call.png'; } else // national number $fname = './png/country-'. $GLOBALS["default_ccode"] . '.png'; if (!file_exists($fname)) // use default $fname = './country-unknown.png'; return $fname; } // -------------------------------------------------------------------------- // grep country abbreviation from file // -------------------------------------------------------------------------- function find_country_abbr($phonenumber) { // read file and remove all comments $lines = file($GLOBALS["country_code_file"]); $lines = preg_grep('/^#/', $lines, PREG_GREP_INVERT); $country_abbr = ''; if ($phonenumber == $GLOBALS["call_unknown"]) { // unknown caller $country_abbr = '--'; } elseif (preg_match("/^00/", $phonenumber)) { // international number for ($num = 4; $num >= 1; $num--) { // 31#NL#Niederlande $keys = preg_grep('/^'.substr($phonenumber, 2, $num).'#/', $lines); foreach ( $keys as $key ) { list($ccode, $cabbr, $cname) = preg_split('/#/', str_replace("\n", '', $key), 3); if ($cabbr) { // use first match $country_abbr = $cabbr; break 2; } } } } else { // national number // 49#DE#Deutschland $keys = preg_grep('/^'.$GLOBALS["default_ccode"].'#/', $lines); foreach ($keys as $key) { list($ccode, $cabbr, $cname) = preg_split('/#/', str_replace("\n", '', $key), 3); if ("$cabbr" != "") { // use first match $country_abbr = "$cabbr"; break; } } } if ($country_abbr == "") { // set default $country_abbr = '--'; } return $country_abbr; } // -------------------------------------------------------------------------- // grep country name from file // -------------------------------------------------------------------------- function find_country_name($phonenumber) { // read file and remove all comments $lines = file($GLOBALS["country_code_file"]); $lines = preg_grep('/^#/', $lines, PREG_GREP_INVERT); $country_name = ''; if ($phonenumber == $GLOBALS["call_unknown"]) { // unknown caller $country_name = $GLOBALS["call_unknown"]; } elseif (preg_match("/^00/", $phonenumber)) { // international number for ($num = 4; $num >= 1; $num--) { // 31#NL#Niederlande $keys = preg_grep('/^'.substr($phonenumber, 2, $num).'#/', $lines); foreach ( $keys as $key ) { list($ccode, $cabbr, $cname) = preg_split('/#/', str_replace("\n", '', $key), 3); if ($cname) { // use first match $country_name = $cname; break 2; } } } } elseif (($GLOBALS["default_ccode"] <> "423") && (!preg_match('/^0[^0]/', $phonenumber))) { // not starting with 0, internal caller $country_name = $GLOBALS["call_internal"]; } else { // national number // 49#DE#Deutschland $keys = preg_grep('/^'.$GLOBALS["default_ccode"].'#/', $lines); foreach ($keys as $key) { list($ccode, $cabbr, $cname) = preg_split('/#/', str_replace("\n", '', $key), 3); if ("$cname" != "") { // use first match $country_name = "$cname"; break; } } } if ($country_name == "") { // set default $country_name = $GLOBALS["call_unknown"]; } return $country_name; } // ---end of functions------------------------------------------------------- if (isset($_COOKIE['capi2text_filter'])) { // if exists refresh COOKIES setcookie("capi2text_filter", $_COOKIE['capi2text_filter'], time()+60*60*24*30); // valid for 30 days setcookie("capi2text_filter_msn", $_COOKIE['capi2text_filter_msn'], time()+60*60*24*30); } if (isset($_POST['filter'])) { // if exists update COOKIES setcookie("capi2text_filter", $_POST['filter'], time()+60*60*24*30); // valid for 30 days setcookie("capi2text_filter_msn", $_POST['filter_msn'], time()+60*60*24*30); } // read MSN replace file if it exists // // 'msn' -> valid MSN (extension), e.g. '31' // 'desc' -> description of MSN, e.g. 'Living Room' // 'fcolor' -> MSN specific foreground color, e.g. '#ffee00' // 'bcolor' -> MSN specific background color, e.g. '#00eeff' // $arr_msn_replace = array(array('msn' => '', 'desc' => '', 'fcolor' => '', 'bcolor' => '')); $arr_msn_color = array(); $msn_replace = false; $i = 0; if ($msn_replace_file <> '' && file_exists($msn_replace_file)) { $msn_replace = true; $mf = fopen($msn_replace_file, 'r') or die("Cannot open file '$msn_replace_file'!"); while (!feof($mf)) { $line = trim(fgets($mf, 500)); if (!preg_match("/^#/", $line) && !preg_match("/^$/", $line)) { // ignore comments and empty lines list($arr_msn_replace[$i]['msn'], $arr_msn_replace[$i]['desc'], $arr_msn_replace[$i]['fcolor'], $arr_msn_replace[$i]['bcolor']) = array_pad(explode("\t", $line), 4, ''); if ( $arr_msn_replace[$i]['desc'] == "" ) $arr_msn_replace[$i]['desc'] = $arr_msn_replace[$i]['msn']; if ( $arr_msn_replace[$i]['fcolor'] <> "" ) $arr_msn_color['msn' . $arr_msn_replace[$i]['msn']]['fcolor'] = $arr_msn_replace[$i]['fcolor']; if ( $arr_msn_replace[$i]['bcolor'] <> "" ) $arr_msn_color['msn' . $arr_msn_replace[$i]['msn']]['bcolor'] = $arr_msn_replace[$i]['bcolor']; $i++; } } fclose($mf); } ?> Capi2Text

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' => '')); // MSN selection box $arr_msn = array($selection_msn_all); $i = 0; if ($call_file <> '' && file_exists($call_file)) { $cf = fopen($call_file, 'r') or die("Cannot open file '$call_file'!"); 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']); if ($msn_replace) { // replace MSN by description $msn_search = $arr_phone_calls[$i]['to']; foreach ($arr_msn_replace as $msn_replace) { if ($msn_replace['msn'] == $msn_search) { $arr_phone_calls[$i]['to_replaced'] = $msn_replace['desc']; $arr_phone_calls[$i]['fcolor'] = $msn_replace['fcolor']; $arr_phone_calls[$i]['bcolor'] = $msn_replace['bcolor']; break; } else // no MSN description for replacement defined $arr_phone_calls[$i]['to_replaced'] = $arr_phone_calls[$i]['to']; } } // 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']); // write msn to array (Selectbox MSN) if ($arr_phone_calls[$i]['to'] <> "") { if (! in_array($arr_phone_calls[$i]['to_replaced'], $arr_msn)) { $arr_msn[] = $arr_phone_calls[$i]['to_replaced']; } } $i++; } $i--; fclose($cf); } else die("File '$call_file' doesn't exist!"); ?> $phone_call['date']) { $prev_date = $phone_call['date']; // calculate the number of days $call_date = explode("-", $phone_call['date']); // mktime( hours, minutes, seconds, month, day, year ) // https://bytes.com/topic/php/answers/820464-mktime-expects-parameter-6-long-string-given $date_diff = intval((mktime() - mktime(0, 0, 0, (int) $call_date[1], (int) $call_date[2], (int) $call_date[0])) / (3600 * 24)); if ( $date_diff > $filter ) break; // print date header once per day echo " \n"; $line_count = 0; } // set link to edit script file $ClickEvent = "javascript:window.open('$edit_script_file?nbr=" . urlencode($phone_call['from']) . "&N=" . urlencode($phone_call['name']) . "&A=" . urlencode($phone_call['address']) . "', 'capi2text_edit')"; $EditButton = "edit entry"; $NoButton = false; if (! file_exists($edit_script_file)) $NoButton = true; // don't edit generally if ($phone_call['from'] == $call_unknown) $NoButton = true; // no caller-number if ( $NoButton) { unset($EditButton); unset($ClickEvent); } // toggle backup color $trclass = ($line_count % 2 == 0 ) ? '' : 'eq'; // default backgroud-color $trclass .= (isset($ClickEvent)) ? ' edit' : ''; // change cursor if editable $trclass .= " msn" . $phone_call['to']; // set color for MSN if defined in msn-replace // print call data echo " \n"; echo " \n"; if ($no_flags) // use country abbreviation echo " \n"; else // use country flags echo " \n"; if (($no_from_link) || ($phone_call['from'] == $call_unknown)) echo " \n"; else // show from phone number as link echo " \n"; echo " \n"; if (htmlspecialchars($phone_call['address']) == '') echo " \n"; else echo " \n"; echo " \n"; echo " \n"; $line_count++; } } } // end of table echo " \n"; ?>
       
 
 
 " . strftime($date_format, mktime(0, 0, 0, (int) $call_date[1], (int) $call_date[2], (int) $call_date[0])) . "
" . $phone_call['time'] . "
" . $phone_call['country_abbr'] . "
" . htmlspecialchars($phone_call['from']) . "" . htmlspecialchars($phone_call['from']) . "" . htmlspecialchars($phone_call['to_replaced']) . "" . htmlspecialchars($phone_call['name']) . "" . htmlspecialchars($phone_call['name']) . ", " . htmlspecialchars($phone_call['address']) . "" . $EditButton . "
 © the eisfair team