#!/bin/sh #------------------------------------------------------------------------------ # __FLI4LVER__ # vbox.cgi - display vbox status and calls # based on the previous main_Vbox.cgi, created by tg/cp # # Creation: 2003-06-12 aw # Last Update: $Id$ # #------------------------------------------------------------------------------ # get main helper functions #set_debug=yes . /srv/www/include/cgi-helper case $FORM_action in "start*"|"stop*") sec="start" ;; del*) sec="delete" ;; *) sec="view" ;; esac check_rights "vbox" "$sec" SPOOLPREFX=/var/spool/vbox # header [refresh] # # Builds the http and html page header and optionally # inserts a meta refresh tag to automatically reload # a given URL header () { RTIME=$1 show_html_header "$_MP_vbox" "refresh=$RTIME; url=$myname" } # start [num] # # Starts the specified vbox start () { ttyi_n=$1 set -- `eval 'echo $VBOX_TTYI_'$ttyi_n` user=$2 case x$REMOTE_USER in x$user|x$VBOX_ADMIN_USERNAME|x) rm -f /var/run/vbox_stop_$ttyi_n ;; *) return 1 ;; esac } # stop [num] # # Stops the specified vbox stop () { ttyi_n=$1 set -- `eval 'echo $VBOX_TTYI_'$ttyi_n` user=$2 case x$REMOTE_USER in x$user|x$VBOX_ADMIN_USERNAME|x) if [ -f /var/run/vboxgetty-ttyI$ttyi_n.pid ] then echo >/var/run/vbox_stop_$ttyi_n kill `cat /var/run/vboxgetty-ttyI$ttyi_n.pid` rm -f /var/run/vboxgetty-ttyI$ttyi_n.pid fi ;; *) return 1 ;; esac } ls2date () { read zeile YEAR=`echo $zeile | cut -d " " -f 5 -` DAY=`echo $zeile | cut -d " " -f 3 -` if [ $DAY -lt 10 ] then DAY=`echo 0$DAY` fi TIME=`echo $zeile | cut -d " " -f 4 -` MONTHSUBST='s/Jan/01/g;s/Feb/02/g;s/Mar/03/g;s/Apr/04/g;s/May/05/g;s/Jun/06/g;s/Jul/07/g;s/Aug/08/g;s/Sep/09/g;s/Oct/10/g;s/Nov/11/g;s/Dec/12/g' MONTH=`echo $zeile | cut -d " " -f 2 - | sed -e $MONTHSUBST` echo $YEAR-$MONTH-$DAY $TIME } # Check, if vbox is running if [ -f /etc/vbox/vboxgetty.conf ] then #get variables . /var/run/vbox.conf RTIME=9999 case $FORM_action in "") header echo "

$_VBOX_cmd_startall | $_VBOX_cmd_stopall

" i='0' showbox= for i in `seq 1 $VBOX_USER_N` do set `eval echo '$VBOX_USER_'$i'_USERNAME'` USRNAME=$1 [ "$REMOTE_USER" = "$USRNAME" -o "$REMOTE_USER" = "$VBOX_ADMIN_USERNAME" -o -z "$REMOTE_USER" ] || continue SPOOLDIR=$SPOOLPREFX/$USRNAME/incoming showbox=yes show_tab_header "$USRNAME" no echo "
" # Show list of users incoming messages echo '' echo "" ROWCOLOR="#e9e9e9" MSGLIST=`ls -r $SPOOLDIR` for MSG in $MSGLIST do MSGFILE="$SPOOLDIR/$MSG" MSGINFO=`vboxmode $MSGFILE | sed 's/.*\.\.\.: //'` case $ROWCOLOR in "#ffffff") ROWCOLOR="#e9e9e9" ;; *) ROWCOLOR="#ffffff" ;; esac j='1' echo "$MSGINFO" | ( while read MSGVAL do case $j in 2 ) infodate=`echo $MSGVAL | ls2date` ;; 4 ) infolen=`echo "$MSGVAL" | sed -e 's/ seconds//'` ;; 5 ) infoname="$MSGVAL" ;; 6 ) infocid="$MSGVAL" ;; esac j=`/usr/bin/expr $j + 1` done echo "" ) done echo "
$_VBOX_table_date$_VBOX_table_callername$_VBOX_table_callerid$_VBOX_table_length$_VBOX_table_action
$infodate $infoname $infocid $infolen   $_VBOX_cmd_play  $_VBOX_cmd_info  $_VBOX_cmd_delete

      " # Show status of users MSNs echo '' echo "" for j in `seq $VBOX_TTYI_MIN $VBOX_TTYI_N` do set `eval echo '$VBOX_TTYI_'$j` case "$2" in "$USRNAME") if [ -f /var/run/vboxgetty-ttyI$j.pid ] then status="$_VBOX_state_running" startstopurl="$_VBOX_cmd_stop" color="#00FF00" else status="$_VBOX_state_stopped" startstopurl="$_VBOX_cmd_start" color="#FF0000" fi echo ""\ ""\ ""\ "" ;; esac done echo "
$_VBOX_table_msn$_VBOX_table_status$_VBOX_table_action
$1$status$startstopurl
" echo "

" show_tab_footer done case $showbox in yes) ;; *) show_error "" "$_VBOX_msg_novbox" ;; esac show_html_footer ;; play) eval USER='$VBOX_USER_'$FORM_nr'_USERNAME' MSG=$SPOOLPREFX/$USER/incoming/$FORM_msg if [ -f $MSG ] then [ -f /usr/bin/vboxbeep ] && vboxbeep > /dev/null 2>&1 MSGTMP=/tmp/vboxmsg.$$ vboxtoau <$MSG >$MSGTMP set -- `ls -l $MSGTMP` length=$5 echo "Content-type: audio/basic" echo "Content-Disposition: attachment; filename=vbox.au" echo "Content-Length: $length" echo cat $MSGTMP rm $MSGTMP else header 3 show_error "" "$_VBOX_msg_nomessage" show_html_footer fi ;; info) eval USER='$VBOX_USER_'$FORM_nr'_USERNAME' MSG=$SPOOLPREFX/$USER/incoming/$FORM_msg if [ -f $MSG ] then header MSGINFO=`vboxmode $MSG` show_tab_header "$_VBOX_table_messageinfo" no echo "
$MSGINFO

" echo "

$_MN_bck

" show_tab_footer show_html_footer else header 3 show_error "" "$_VBOX_msg_nomessage" show_html_footer fi ;; del) eval USER='$VBOX_USER_'$FORM_nr'_USERNAME' MSG=$SPOOLPREFX/$USER/incoming/$FORM_msg if [ -f $MSG ] then header MSGINFO=`vboxmode $MSG` show_tab_header "$_VBOX_table_confirmdelete" no echo "
$MSGINFO

" echo "

$_VBOX_msg_confirmdelete

" echo "

$_VBOX_cmd_yes | $_VBOX_cmd_no

" show_tab_footer show_html_footer else header 3 show_error "" "$_VBOX_msg_nomessage" show_html_footer fi ;; delc) eval USER='$VBOX_USER_'$FORM_nr'_USERNAME' MSG=$SPOOLPREFX/$USER/incoming/$FORM_msg if [ -f $MSG ] then header 2 rm $MSG show_info "" "$_VBOX_msg_deleted" echo "

$_MN_bck" show_html_footer else header 3 show_error "" "$_VBOX_msg_nomessage" show_html_footer fi ;; start) start $FORM_nr case $? in 1) header 3 show_error "" "$_VBOX_msg_notallowed" show_html_footer ;; *) sleep 3 echo "Location: $myname" echo ;; esac ;; stop) stop $FORM_nr case $? in 1) header 2 show_error "" "$_VBOX_msg_notallowed" show_html_footer ;; *) sleep 3 echo "Location: $myname" echo ;; esac ;; "startall" ) for i in `seq $VBOX_TTYI_MIN $VBOX_TTYI_N` do start "$i" done sleep 2 header 3 show_info "" "$_VBOX_msg_allstarted" echo "

$_MN_bck" show_html_footer ;; "stopall" ) for i in `seq $VBOX_TTYI_MIN $VBOX_TTYI_N` do stop "$i" done sleep 2 header 3 show_info "" "$_VBOX_msg_allstopped" echo "

$_MN_bck" show_html_footer ;; *) echo "Location: $myname" echo ;; esac else header show_error "" "

$_VBOX_msg_notavailable`grep -q VBOX /bootmsg.txt && echo '

' ; \
                   grep VBOX /bootmsg.txt ; echo '
'`" show_html_footer fi