#!/bin/sh #------------------------------------------------------------------------------ # calls.cgi - show calls loged by telmond # # Creation: 03.02.2001 tg # Last Update: $Id$ # #------------------------------------------------------------------------------ # get main helper functions . /srv/www/include/cgi-helper dump_log () { imond-send "client-ip $REMOTE_ADDR" "telmond-log-file" | sed 's/.$//;/^OK/ d;s/^ //' } format_output () { tr -d '\r' < /etc/phonebook > $tmp.phbk # Build sed script cat > $tmp.sed <<-EOF s/^// s/$/<\/td><\/tr>/ s/ \+/<\/td>/g EOF # Convert phonebook to sed-expressions and append to script sed '/^[0-9*#^=]*=[][[:alnum:]äöüßÄÖÜ[:punct:]()"%|&*#_[.-.] ]*$/!d; \ s/,[^,]*$//; s/|/-/g; s/&/\\\&/g; s/*/\\\*/g; \ s/^\([^=]*\)=\(.*\)/s|>\1<| title="\1">\2<|/;' $tmp.phbk >> $tmp.sed # do the transformation sed -f $tmp.sed } : ${FORM_action:=view} # Security check_rights "logs" "$FORM_action" # Check if imond and telmond are running if [ ! -f /var/run/telmond.pid -o ! -f /var/run/imond.port ] then show_html_header "$_MN_err" show_error "$_MN_err" "Imond $_MN_or Telmond $_MN_notrun.
$_MN_rbfix" show_html_footer exit 1 fi tmp="/tmp/$myname.$$" case $FORM_action in reset|$_MN_reset) show_html_header "$_MN_resetting $_CALL_telmondlog ..." "refresh=1;url=$myname" show_info "" "$_MN_resetting $_CALL_telmondlog ... `imond-send "client-ip $REMOTE_ADDR" "reset-telmond-log-file"`" show_html_footer ;; download|$_MN_download) http_header download "ctype=text/plain;filename=calls.txt" dump_log ;; *) # standard sort method is reverse : ${FORM_sort:=reverse} case $FORM_sort in reverse) sort="normal" ;; *) sort="reverse" ;; esac # show all rows if the "all rows" button is pressed case $FORM_showall in "") ;; *) FORM_lines="$_MN_all" ;; esac # sanitize no. of rows: show the default of 50 rows if nothing or nonsens (no integer) is specified case $FORM_lines in all|"$_MN_all") ;; *[^0-9]*|"") FORM_lines=50 ;; esac case $FORM_lines in all|"$_MN_all") # is "all" or no integer n="$_MN_all" case $FORM_sort in normal) dump_log | format_output > $tmp.out ;; *) dump_log | format_output | sed '1!G;h;$!d' > $tmp.out ;; esac ;; *) # is an integer n=$FORM_lines case $FORM_sort in normal) dump_log | do_tail $n | format_output > $tmp.out ;; *) dump_log | do_tail $n | format_output | sed '1!G;h;$!d' > $tmp.out ;; esac ;; esac show_html_header "$_MP_calls" show_tab_header "$_MP_calls" no echo "

$_MP_calls ($n $_MN_rows)

" cat <<-EOF
 $_MN_rows  

EOF echo '' echo "" cat $tmp.out echo "
$_MN_date\"sort\"$_MN_time$_CALL_ingnr$_CALL_dnr
" show_tab_footer show_html_footer rm $tmp.* ;; esac