#!/bin/sh # &fullscreen= if [ "${QUERY_STRING}" != "" ] && [ "$FULLSCREEN" = "" ]; then FULLSCREEN=`echo ${QUERY_STRING} | sed -n 's/.*fullscreen=\(.*\)/\1/p' | sed -e 's/&.*//g'` fi head_begin PAGE="" HELPPAGE="" RESET="" WEBIFPASS="" NEWPATH="" START="" DELETE="" RUN_CMD="" CLOSE_CMD="" FILE_SEL="" # read get variables if [ "${QUERY_STRING}" != "" ]; then # &page= if [ "$PAGE" = "" ]; then PAGE=`echo ${QUERY_STRING} | sed -n 's/.*page=\(.*\)/\1/p' | sed -e 's/&.*//g'` fi # &help= if [ "$HELPPAGE" = "" ]; then HELPPAGE=`echo ${QUERY_STRING} | sed -n 's/.*help=\(.*\)/\1/p' | sed -e 's/&.*//g'` fi # &direct_edit= _DIRECT_EDIT=`echo ${QUERY_STRING} | sed -n 's/.*direct_edit=\(.*\)/\1/p' | sed -e 's/&.*//g'` if [ ! -z "$_DIRECT_EDIT" ]; then DIRECT_EDIT="$_DIRECT_EDIT"; fi # &new_patht= if [ "$NEWPATH" = "" ]; then NEWPATH=$($HTTPD -d "`echo ${QUERY_STRING} | sed -n 's/.*new_path=\(.*\)/\1/p' | sed -e 's/&.*//g'`") fi # &webifpass= if [ "$WEBIFPASS" = "" ]; then WEBIFPASS=$($HTTPD -d "`echo ${QUERY_STRING} | sed -n 's/.*webifpass=\(.*\)/\1/p' | sed -e 's/&.*//g'`") fi # &new_path= if [ "$NEWPATH" = "" ]; then NEWPATH=$($HTTPD -d "`echo ${QUERY_STRING} | sed -n 's/.*new_path=\(.*\)/\1/p' | sed -e 's/&.*//g'`") fi # &reset= if [ "$RESET" = "" ]; then RESET=`echo ${QUERY_STRING} | sed -n 's/.*reset_type=\(.*\)/\1/p' | sed -e 's/&.*//g'` fi if [ "$RESET" != "" ]; then if [ "$RESET" = "path" ]; then show_title "Pfad ändern" # stop dtmfbox /var/dtmfbox/rc.dtmfbox stop # No path? Then install to /var/dtmfbox-bin if [ "$NEWPATH" = "" ] || [ "$NEWPATH" = "/var/dtmfbox" ]; then NEWPATH="/var/dtmfbox-bin" fi echo "

" echo "Pfad wird auf \"$NEWPATH\" geändert.
" echo "Bitte warten, bis alle Dateien kopiert wurden...

" if [ "$DTMFBOX_PATH" = "$NEWPATH" ]; then echo "Hinweis: Alter und neuer Pfad nicht unterschiedlich!
" echo "
Abgebrochen!" head_end return 1; fi echo -n "
"

			# Copy required files to new path			
			mkdir -p $NEWPATH			
			if [ "$FREETZ" = "0" ];
			then
				# Copy the current files (minimum)
				cp -Rf /var/dtmfbox/rc.dtmfbox $NEWPATH
				cp -Rf /var/dtmfbox/dtmfbox $NEWPATH
				cp -Rf /var/dtmfbox/busybox-tools $NEWPATH
				cp -Rf /var/dtmfbox/script $NEWPATH
				cp -Rf /var/dtmfbox/httpd $NEWPATH
				cp -Rf /var/dtmfbox/default $NEWPATH
				cp -Rf /var/dtmfbox/*.so $NEWPATH
				cp -Rf /var/dtmfbox/*.cfg $NEWPATH

				# USB? Then copy all files (including recordings)...
				if [ "$NEWPATH" != "/var/dtmfbox-bin" ]; then	
					cp -Rf /var/dtmfbox/* $NEWPATH
				fi
			fi

			# Save config
			export DTMFBOX_PATH="$NEWPATH"			# Export new pathname
			rm /var/dtmfbox					# Remove link dir

			if [ "$FREETZ" = "0" ]; then
 			  $DTMFBOX_PATH/rc.dtmfbox check_busybox	# Relink busybox
			  $DTMFBOX_PATH/rc.dtmfbox install bypath	# Reinstall dtmfbox (USB/RAM)
			else
			  /etc/init.d/rc.dtmfbox install bypath		# Reinstall dtmfbox (FREETZ)
			fi

			echo -n "
" show_page "dtmfbox_scriptedit.cgi" "SAVE" # Save config (change debug.cfg) # Finished! echo "
Fertig!" head_end return 1; fi if [ "$RESET" = "reset" ]; then show_title "Die Konfiguration wird zurückgesetzt..." echo -n "
"
			/var/dtmfbox/rc.dtmfbox defaults
			echo -n "
Fertig!" head_end return 1; fi if [ "$RESET" = "uninstall" ]; then show_page "dtmfbox_scriptedit.cgi" "UNINSTALL" show_title "dtmfbox deinstallieren..." # stop dtmfbox /var/dtmfbox/rc.dtmfbox stop >/dev/null # remove entry from /var/flash/debug.cfg /var/dtmfbox/rc.dtmfbox uninstall rm /var/dtmfbox echo "
Fertig!" head_end return 1; fi if [ "$RESET" = "password" ]; then if [ ! -z "$WEBIFPASS" ]; then # save pass to httpd.conf WEBIFPASS_ENC="/:admin:`$HTTPD -m $WEBIFPASS`" echo "$WEBIFPASS_ENC" > /var/dtmfbox/httpd/httpd.conf else rm /var/dtmfbox/httpd/httpd.conf fi show_page "dtmfbox_scriptedit.cgi" "SAVE" echo "<< zurück zur Statusseite..." # reload httpd configuration kill -1 0 sleep 1 return 1; fi fi # &delete=true if [ "$DELETE" = "" ]; then DELETE=`echo ${QUERY_STRING} | sed -n 's/.*delete=\(.*\)/\1/p' | sed -e 's/&.*//g'` fi if [ "$DELETE" = "true" ]; then # read security PID for runcmd! if [ -f /var/dtmfbox/tmp/webinterface.pid ]; then SEC_PID1=`echo ${QUERY_STRING} | sed -n 's/.*pid=\(.*\)/\1/p' | sed -e 's/&.*//g'` SEC_PID2=`cat /var/dtmfbox/tmp/webinterface.pid` # both PIDs equal? Then run! if [ "$SEC_PID1" = "$SEC_PID2" ]; then if [ "$CMD_LOCAL" = "" ]; then CMD_LOCAL=`echo ${QUERY_STRING} | sed -n 's/.*cmd_local=\(.*\)/\1/p' | sed -e 's/&.*//g'` CMD_LOCAL=$($HTTPD -d "$CMD_LOCAL") echo "$CMD_LOCAL" > /var/dtmfbox/tmp/dtmfbox_delete_local.sh chmod +x /var/dtmfbox/tmp/dtmfbox_delete_local.sh . /var/dtmfbox/tmp/dtmfbox_delete_local.sh rm /var/dtmfbox/tmp/dtmfbox_delete_local.sh fi if [ "$CMD_REMOTE" = "" ]; then CMD_REMOTE=`echo ${QUERY_STRING} | sed -n 's/.*cmd_remote=\(.*\)/\1/p' | sed -e 's/&.*//g'` CMD_REMOTE=$($HTTPD -d "$CMD_REMOTE") echo "$CMD_REMOTE" > /var/dtmfbox/tmp/dtmfbox_delete_ftp.sh chmod +x /var/dtmfbox/tmp/dtmfbox_delete_ftp.sh echo "
"
					. /var/dtmfbox/tmp/dtmfbox_delete_ftp.sh
					echo "
" rm /var/dtmfbox/tmp/dtmfbox_delete_ftp.sh fi fi fi fi # &start= if [ "$START" = "" ]; then START=`echo ${QUERY_STRING} | sed -n 's/.*start=\(.*\)/\1/p' | sed -e 's/&.*//g'` fi if [ "$START" != "" ]; then # Daemon starten if [ "$START" = "daemon" ]; then /var/dtmfbox/rc.dtmfbox restart > /dev/null fi # Daemon geloggt starten if [ "$START" = "logged" ]; then /var/dtmfbox/rc.dtmfbox stop >/dev/null rm /var/dtmfbox/tmp/dtmfbox.log 2>/dev/null /var/dtmfbox/rc.dtmfbox log >/dev/null touch /var/dtmfbox/tmp/dtmfbox.log fi # Daemon stoppen if [ "$START" = "stop" ]; then /var/dtmfbox/rc.dtmfbox stop >/dev/null fi # Fritzbox rebooten if [ "$START" = "reboot" ]; then echo "
Reboot wird durchgeführt...
" echo "
" reboot return 1; fi fi # &close= if [ "$CLOSE_CMD" = "" ]; then CLOSE_CMD=`echo ${QUERY_STRING} | sed -n 's/.*close=\(.*\)/\1/p' | sed -e 's/&.*//g'` fi # &run_cmd= if [ "$RUN_CMD" = "" ]; then RUN_CMD=`echo ${QUERY_STRING} | sed -n 's/.*run_cmd=\(.*\)/\1/p' | sed -e 's/&.*//g'` fi if [ "$RUN_CMD" != "" ]; then # read security PID for runcmd! if [ -f /var/dtmfbox/tmp/webinterface.pid ]; then SEC_PID1=`echo ${QUERY_STRING} | sed -n 's/.*pid=\(.*\)/\1/p' | sed -e 's/&.*//g'` SEC_PID2=`cat /var/dtmfbox/tmp/webinterface.pid` # both PIDs equal? Then run! if [ "$SEC_PID1" = "$SEC_PID2" ]; then RUN_CMD=$($HTTPD -d "$RUN_CMD") $RUN_CMD >/dev/null 2>/dev/null if [ "$CLOSE_CMD" = "1" ]; then echo "Fenster wird geschlossen! Bitte warten..." echo "" exit 1; fi fi fi fi fi if [ "$PAGE" = "" ]; then PAGE="status"; fi # returns am-messages to $status_recordings (as links) get_am_messages() { . /var/dtmfbox/script/funcs.sh status_recordings="" let tmp_acc_no=$DTMFBOX_MAX_ACCOUNTS; while [ $tmp_acc_no -ge 1 ]; do let msg_cnt=0; for file in `find $DTMFBOX_PATH/record/${tmp_acc_no}/* 2>/dev/null` do if [ ! -d $file ]; then let msg_cnt=msg_cnt+1 fi done if [ "$msg_cnt" != "0" ]; then get_cfg_value "/var/dtmfbox/dtmfbox.cfg" "acc${tmp_acc_no}" "name" status_recordings="Account #${tmp_acc_no} ($CFG_VALUE) - $msg_cnt Nachricht(en)
$status_recordings" fi let tmp_acc_no=$tmp_acc_no-1 done } # Security PID for run_cmd= and dtmfbox_cmd.cgi! echo "$$" > /var/dtmfbox/tmp/webinterface.pid #################################################################################### ## STATUS #################################################################################### if [ "$PAGE" = "status" ]; then show_title "Status" # Get am messages to $status_recordings get_am_messages if [ "$status_recordings" != "" ]; then echo "
$status_recordings

" fi cat << EOF
EOF if [ "$DTMFBOX_APACHE" != "1" ]; then cat << EOF EOF fi cat << EOF
Installiert unter: $DTMFBOX_PATH
EOF fi #################################################################################### ## Basiseinstellungen #################################################################################### if [ "$PAGE" = "dtmfbox_cfg" ]; then FILE_EDIT="/var/dtmfbox/dtmfbox.cfg"; SHOW_FILE_SELECTION="0" CHECK_REBOOT="1" COMMENT_PREFIX="//" if [ -z "$DIRECT_EDIT" ]; then DIRECT_EDIT="0"; fi show_page "dtmfbox_scriptedit.cgi" fi #################################################################################### ## Skripteinstellungen #################################################################################### if [ "$PAGE" = "script_cfg" ]; then FILE_EDIT="/var/dtmfbox/script.cfg"; SHOW_FILE_SELECTION="0" CHECK_REBOOT="0" COMMENT_PREFIX="#" if [ -z "$DIRECT_EDIT" ]; then DIRECT_EDIT="0"; fi show_page "dtmfbox_scriptedit.cgi" fi #################################################################################### ## Menü bearbeiten #################################################################################### if [ "$PAGE" = "menu_cfg" ]; then FILE_EDIT="/var/dtmfbox/menu.cfg"; SHOW_FILE_SELECTION="0" CHECK_REBOOT="1" COMMENT_PREFIX="//" SHOW_ADD_REMOVE="1" if [ -z "$DIRECT_EDIT" ]; then DIRECT_EDIT="0"; fi show_page "dtmfbox_scriptedit.cgi" fi #################################################################################### ## Skripte bearbeiten #################################################################################### if [ "$PAGE" = "scripts" ]; then SHOW_CONFIG_FILES="0" CHECK_REBOOT="0" DIRECT_EDIT="1" show_page "dtmfbox_scriptedit.cgi" fi #################################################################################### ## Webphone #################################################################################### if [ "$PAGE" = "webphone" ]; then show_title "Java Webphone" echo '' echo '
' echo '
' let LOC_RTP_START=$WEBPHONE_LOC_RTP_PORT let LOC_RTCP_START=$LOC_RTP_START+1 let REM_RTP_START=$WEBPHONE_REM_RTP_PORT let REM_RTCP_START=$REM_RTP_START+1 if [ ! -z "$(pidof 'dtmfbox')" ]; then dtmfbox_running="1" else dtmfbox_running="0" fi cat << EOF EOF if [ "$dtmfbox_running" = "1" ]; then if [ -f "../sWebPhone.jar" ]; then WEBPHONE_CODEBASE="../" else WEBPHONE_CODEBASE="./" fi cat << EOF
Account:
CAPI-Controller:
Rufnummer:
EOF echo '
' # STATUS: echo "
" echo "" echo "
" echo '


' else echo "dtmfbox not running!" fi echo '
' echo '
' fi #################################################################################### ## dtmfbox zurücksetzen #################################################################################### if [ "$PAGE" = "reset" ] || [ "$PAGE" = "reset_path_only" ]; then if [ "$PAGE" != "reset_path_only" ]; then show_title "Pfad, Reset, Deinstallieren, WebIf-Passwort ..." else show_title "Pfad ändern ..." fi echo "
" cat << EOF EOF echo "" echo "" echo "Auswahl: " echo "" echo "" echo "" echo "


" echo "" echo "" echo "" echo "
Neuer Pfad:
Leer lassen, falls kein USB!
" echo "
" echo "
" if [ "$FREETZ" = "1" ] && [ -z "$DTMFBOX_PATH" ]; then head_end return fi fi #################################################################################### ## Nachrichten #################################################################################### if [ "$PAGE" = "am_messages" ]; then let ITEMS_PER_PAGE=10 acc_no_str=`echo ${QUERY_STRING} | sed -n 's/.*acc=\(.*\)/\1/p' | sed -e 's/&.*//g'` page_str=`echo ${QUERY_STRING} | sed -n 's/.*page_msg=\(.*\)/\1/p' | sed -e 's/&.*//g'` if [ -z "$page_str" ]; then page_str="1"; fi if [ -z "$acc_no_str" ]; then acc_no_str="1"; fi let acc_no=$acc_no_str let page=$page_str let page=page-1; if [ $page -le 0 ] || [ "$page" = "" ]; then let page=0; fi if [ $acc_no -le 0 ] || [ "$acc_no" = "" ]; then acc_no="1"; fi # load ftp account settings from funcs.sh script if [ -f /var/dtmfbox/script/funcs.sh ]; then . /var/dtmfbox/script/am_funcs.sh load_am_settings "${acc_no}" fi delimiter="\n" ftp_user="$AM_FTP_USERNAME" ftp_pass="$AM_FTP_PASSWORD" ftp_path="$AM_FTP_PATH" ftp_server="$AM_FTP_SERVER" ftp_port="$AM_FTP_PORT" ftp_login=`eval echo "USER \\$ftp_user\"$delimiter\"PASS \\$ftp_pass\"$delimiter\"CWD \\$ftp_path\"$delimiter\""` cat << EOF EOF echo '' echo '
' show_title "Aufnahmen - Account #${acc_no}" echo "
" echo "
" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" let rec_no=1 let p=0; let position=0; let start_position="$page" let start_position=start_position*$ITEMS_PER_PAGE; let end_position=$start_position+$ITEMS_PER_PAGE-1; for file in `ls -r $DTMFBOX_PATH/record/$acc_no/* 2>/dev/null` do if [ -f $file ]; then if [ $position -ge $start_position ] && [ $position -le $end_position ]; then filename=`echo $file | sed 's/^.*\/\(.*\..*\)$/\1/g'` FILE_DATE=`echo $filename | sed 's/^\(..\).\(..\).\(..\)--\(..\).\(..\).*$/\3.\2.20\1, \4:\5/g'` CALLER_NO=`echo $filename | sed 's/^.*---.*-\(.*\)[\.]...$/\1/g'` ACCOUNT_NO=`echo $filename | sed 's/^.*---\(.*\)-.*$/\1/g'` IS_FTP=`echo $filename | sed 's/^.*\.raw$/FTP/g'` if [ "$IS_FTP" != "FTP" ]; then let FILE_DURATION=`$DU "$file" | sed -e "s/\([0-9]*\).*/\1/g"` let FILE_DURATION=$FILE_DURATION*1024/17500 FILE_DURATION="$FILE_DURATION sec" else FILE_DURATION="~" fi if [ "$IS_FTP" != "FTP" ]; then IS_FTP="HDD"; else IS_FTP="FTP"; fi if [ "$IS_FTP" != "FTP" ]; then DOWNLOAD_CMD="dtmfbox_cmd.cgi?pid=$$&script=cat%20$file&binary=true&download_name=$filename" else DOWNLOAD_CMD="ftp://$ftp_user:$ftp_pass@$ftp_server:$ftp_port/$ftp_path/$filename" fi if [ $p -eq 0 ]; then echo "" else echo "" fi echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" let rec_no=rec_no+1; let p=p+1; if [ $p -eq 2 ]; then p=0; fi fi let position=position+1; fi done echo "
FTP/HDDDatum, UhrzeitLängeNummer
$IS_FTP
$FILE_DATE
$FILE_DURATION
$CALLER_NO an $ACCOUNT_NO

" echo "" echo "" let pages=$position/$ITEMS_PER_PAGE; let pages2=$pages*$ITEMS_PER_PAGE; if [ "$pages2" -ne "$position" ]; then let pages=pages+1; fi echo "" echo "" echo "
$position Nachricht(en) - Seite: " let page=1; while [ $page -le $pages ]; do let p=$page-1; echo -n "$page" if [ $page -ne $pages ]; then echo -n ", "; fi let page=page+1 done echo "
" echo '
' # show links to other accounts get_am_messages echo "
$status_recordings
" echo "" echo '
' fi #################################################################################### ## Hilfe #################################################################################### if [ "$PAGE" = "help" ]; then show_page "dtmfbox_help.cgi" else if [ "$FULLSCREEN" != "1" ]; then head_end else echo "" fi fi