#! /bin/csh -f # Copyright 07/27/99 Sun Microsystems, Inc. All Rights Reserved. # "@(#)nf_html_main.cgi 1.39 99/07/27 Sun Microsystems" source ./profile.csh set getmimetype=./mimetypes set mapfile=./mimetypes.conf set homedir=$NF_HOMEDIR setenv nf_html yes set post_script="nf_html_main.cgi" if ("$WWW_timestamp" == "yes") then # call the C routine pencode to encrypt the password. #Added to fix the "$" symbol in password. echo $WWW_pass > /tmp/tmppass.$$ set tmppas=`cat /tmp/tmppass.$$` #$NF_SBIN/pencode '$WWW_pass' > /tmp/enpass.$$ $NF_SBIN/pencode $tmppas > /tmp/enpass.$$ setenv WWW_pass "`cat /tmp/enpass.$$`" rm /tmp/enpass.$$ rm /tmp/tmppass.$$ endif if ( "$?WWW_header" ) then setenv WWW_pass "$WWW_header" endif if ( "$WWW_type" != "NT" && "$WWW_type" != "WIN" ) then if ( "$?WWW_dir" ) then setenv WWW_dir "`echo $WWW_dir | sed -e 's#%#/#g'`" endif if ( "$?WWW_VMS" ) then setenv WWW_VMS "`echo $WWW_VMS | sed -e 's#%#/#g'`" endif if ( "$?WWW_priordir" ) then setenv WWW_priordir "`echo $WWW_priordir | sed -e 's#%#/#g'`" endif endif if ( "$?WWW_viewshares" ) then setenv WWW_func expandMachine setenv REQUEST_METHOD POST setenv nf_html yes $NF_CGIDIR/rp_util_java.cgi >& /tmp/share.$$ # call the C routine pdecode to decrypt the password. $NF_SBIN/pdecode $WWW_pass > /tmp/depass.$$ setenv WWW_pass "`cat /tmp/depass.$$`" rm /tmp/depass.$$ cat <

$NF_APPLICATION


EOM grep "ERROR:" /tmp/share.$$ >& /dev/null if ( $status == 0 ) then echo "
"
		cat /tmp/share.$$ | grep -v "Content-type:"
		echo "
" exit endif cat <

Windows Networking


System$WWW_machine
Password:
Sharename:


EOM exit endif if ( $?WWW_lineSelect ) then set foo="`/usr/ucb/printenv WWW_lineSelect | tr '\240' ' ' | tr '\!' ' '`" setenv WWW_lineSelect "$foo" endif if ( "`/usr/ucb/printenv WWW_updir`" != "" ) then set thedir="$WWW_priordir" else if ("`/usr/ucb/printenv WWW_mkdir`" != "" ) then if ( "$WWW_dir" == "" ) setenv WWW_dir "." cat << EOF content-type: text/html Create Folder/Directory
Create Folder/Directory


Current Folder/Directory: $WWW_dir

EOF if ( "$WWW_type" != "NT" && "$WWW_type" != "WIN" ) then set WWW_dir=`echo "$WWW_dir" | sed -e "s#/#%#"` set WWW_VMS=`echo "$WWW_VMS" | sed -e "s#/#%#"` set WWW_priordir=`echo "$WWW_priordir" | sed -e "s#/#%#"` endif cat << EOM
EOM exit else if ( $?WWW_newdir ) then echo 'content-type: text/html' echo '' if ( "$WWW_newdir" == "" ) then echo '' echo '' echo '' echo '' exit endif echo '' setenv WWW_func createDir setenv REQUEST_METHOD POST setenv nf_html yes $NF_CGIDIR/rp_util_java.cgi >& /tmp/create.$$ echo "
"
	cat /tmp/create.$$ | grep -vi "Content-type:" | grep -vi "Got a message line:" | grep -vi "ACTION=PUT" | grep -vi "Can't load"
	echo "
" rm -rf /tmp/create.$$ >& /dev/null if ( "$WWW_type" != "NT" && "$WWW_type" != "WIN" ) then set WWW_dir=`echo "$WWW_dir" | sed -e "s#/#%#"` set WWW_VMS=`echo "$WWW_VMS" | sed -e "s#/#%#"` set WWW_priordir=`echo "$WWW_priordir" | sed -e "s#/#%#"` endif cat << EOF
EOF /bin/rm -f /tmp/a.$$ /tmp/b.$$ exit else if ( "`/usr/ucb/printenv WWW_search`" != "" ) then echo 'content-type: text/html' echo '' if ( $?WWW_lineSelect ) then if ( "$WWW_lineSelect" != "nothing selected" ) then set type=`/usr/ucb/printenv WWW_lineSelect | awk -F\t ' { print $2 } '` if ( "$type" != "D" && "$type" != "d" ) then echo '' echo '

' echo '

' echo 'Please specify a Directory to search file.' echo '' echo '' exit endif set thisdir=`/usr/ucb/printenv WWW_lineSelect | awk -F\t ' { print $1 } '` if ( "$WWW_type" == "NT" || "$WWW_type" == "WIN" ) then setenv WWW_temp "`/usr/ucb/printenv WWW_dir`\$thisdir" else setenv WWW_temp "`/usr/ucb/printenv WWW_dir`/$thisdir" endif setenv WWW_dir "`/usr/ucb/printenv WWW_temp`" endif endif if ( "$WWW_dir" == "" ) then setenv WWW_dir "." endif cat << EOF $NF_APPLICATION Search File

$NF_APPLICATION Search File



Note: Searches that take long time may cause your browser to timeout.


Computer Name    : $WWW_machine
EOF if ( "$WWW_type" == "FTP" ) then echo "Directory : $WWW_dir
" else echo "Share/Volume Name: $WWW_VMS
" echo "Starting Folder : $WWW_dir
" endif if ( "$WWW_type" != "NT" && "$WWW_type" != "WIN" ) then set WWW_dir=`echo "$WWW_dir" | sed -e "s#/#%#"` set WWW_VMS=`echo "$WWW_VMS" | sed -e "s#/#%#"` set WWW_priordir=`echo "$WWW_priordir" | sed -e "s#/#%#"` endif cat << EOF

Pattern To Search For: 

EOF exit else if ( $?WWW_pattern ) then echo 'content-type: text/html' echo '' echo '' if ( "$WWW_pattern" == "" ) then echo 'Please specify a search pattern.' echo '' echo '' exit endif cat << EOF

$NF_APPLICATION Search File


EOF
        setenv WWW_func searchFile 
        setenv REQUEST_METHOD POST
        setenv nf_html yes

        $NF_CGIDIR/rp_util_java.cgi >& /tmp/find.$$
### added fix to remove perl regexp error and to remove find.$$ file from
### /tmp directory on completion of find.

	cat /tmp/find.$$ | grep -vi "Content-type:" | grep -vi "Got a message line:" | grep -vi "ACTION=PUT" | grep -vi "Can't" | grep -vi "Follows nothing in regexp"
echo "
" rm -f /tmp/find.$$ >& /dev/null if ( "$WWW_type" != "NT" && "$WWW_type" != "WIN" ) then set WWW_dir=`echo "$WWW_dir" | sed -e "s#/#%#"` set WWW_VMS=`echo "$WWW_VMS" | sed -e "s#/#%#"` set WWW_priordir=`echo "$WWW_priordir" | sed -e "s#/#%#"` endif cat << EOG

EOG exit else if ( "`/usr/ucb/printenv WWW_upload`" != "" ) then echo 'Content-type: text/html' echo '' set seedir="`/usr/ucb/printenv WWW_dir`" if ( "$seedir" =="" ) then set seedir='.' endif set foo='"' set weirdpswd=`echo $WWW_pass | grep '&'` if ( "$weirdpswd" == "" ) then set tmppswd=`echo $WWW_pass | tr '&' ''` else set tmppswd=`echo $WWW_pass` endif set utime=`time` cat < Remote File Upload Option

Remote File Upload Option


The destination system is: $WWW_machine
The destination folder is: $seedir
The sharename is: $WWW_VMS

Local file: Save as:

EOM if ( "$WWW_type" != "NT" && "$WWW_type" != "WIN" ) then set WWW_dir=`echo "$WWW_dir" | sed -e "s#/#%#"` set WWW_VMS=`echo "$WWW_VMS" | sed -e "s#/#%#"` set WWW_priordir=`echo "$WWW_priordir" | sed -e "s#/#%#"` endif cat << EOM

EOM exit else if ( "`/usr/ucb/printenv WWW_refresh`" != "" ) then set thedir="$WWW_dir" else if ( "`/usr/ucb/printenv WWW_mail`" != "" ) then if ( "$?WWW_lineSelect" ) then if ( "$WWW_lineSelect" == "nothing selected" ) then echo 'content-type: text/html' echo '' echo '' echo 'Please go back & select a document to mail.' echo '' echo '' exit endif else echo 'content-type: text/html' echo '' echo '' echo 'Please go back & select a document to mail.' echo '' echo '' exit endif set type=`/usr/ucb/printenv WWW_lineSelect | awk -F\t ' { print $2 } '` if ( "$type" == "D" || "$type" == "d" ) then echo 'content-type: text/html' echo '' echo '' echo You can only mail a document, not a folder or directory. echo '' echo '' exit endif set thefile=`/usr/ucb/printenv WWW_lineSelect | awk -F\t ' { print $1 } '` if ( "$WWW_type" == "WIN" || "$WWW_type" == "NT" ) then set filestuff="$WWW_dir"'\'"$thefile" else set filestuff="$WWW_dir"'/'"$thefile" endif set WWW_priordir="$WWW_dir" echo 'content-type: text/html' echo 'Expires: Thu, 01 Dec 1994 16:00:00 GMT' echo 'Pragma: no-cache' echo '' echo '' echo "

$NF_APPLICATION Mail File

" echo "

" echo "


" echo "
" # get the mailing preferences setenv WWW_func getThisSession setenv nf_html yes setenv REQUEST_METHOD POST $NF_CGIDIR/rp_util_java.cgi >& /tmp/user.$$ set mailserver=`grep "mailserver=" /tmp/user.$$ | sed -e 's/mailserver=//'` # the replyto setting is not used now because the replyto is never # written to the preferences server. Maybe used in the future. set replyto=`grep "replyto=" /tmp/user.$$ | sed -e 's/replyto=//'` rm -f /tmp/user.$$ >& /dev/null # Added the WWW_replyto setting since it is always empty and blocks # the replyto textarea. if ( "$replyto" == "" ) then set WWW_replyto=" " set replyto=" " endif if ( "$WWW_type" != "NT" && "$WWW_type" != "WIN" ) then set WWW_dir=`echo "$WWW_dir" | sed -e "s#/#%#"` set WWW_VMS=`echo "$WWW_VMS" | sed -e "s#/#%#"` set WWW_priordir=`echo "$WWW_priordir" | sed -e "s#/#%#"` endif cat << EOF
Preparing to send file: "$filestuff"

To:          
Cc:          
Subject:     
Reply-To:    
Msg Text: 


EOF exit else if ( "`/usr/ucb/printenv WWW_send`" != "" || "`/usr/ucb/printenv WWW_send.x`" != "" ) then echo 'content-type: text/html' echo '' echo '' if ( "$WWW_toname" == "" ) then echo '' echo 'You must enter a person to send the file to.' echo '' echo '' exit endif if ( "$WWW_replyto" == "" ) then echo '' echo 'You must enter a valid Reply To address.' echo '' echo '' exit endif setenv nf_html yes setenv WWW_func mailFile setenv REQUEST_METHOD POST $NF_CGIDIR/rp_util_java.cgi >& /tmp/mail.$$ cat /tmp/mail.$$ | grep -vi "Content-type:" | grep -vi "Got a message line:" | grep -vi "ACTION=PUT" | grep -vi "Can't" rm -f /tmp/mail.$$ >& /dev/null if ( "$WWW_type" != "NT" && "$WWW_type" != "WIN" ) then set WWW_dir=`echo "$WWW_dir" | sed -e "s#/#%#"` set WWW_VMS=`echo "$WWW_VMS" | sed -e "s#/#%#"` set WWW_priordir=`echo "$WWW_priordir" | sed -e "s#/#%#"` endif cat << EOF EOF exit else if ( "`/usr/ucb/printenv WWW_open`" != "" || "`/usr/ucb/printenv WWW_open.x`" != "" ) then if ( "$?WWW_lineSelect" ) then if ( "$WWW_lineSelect" == "nothing selected" ) then echo 'content-type: text/html' echo '' echo '' echo 'Please go back & select a document to open.' echo '' echo '' exit endif else echo 'content-type: text/html' echo '' echo '' echo 'Please select a document to open.' echo '' echo '' exit endif set type=`/usr/ucb/printenv WWW_lineSelect | awk -F\t ' { print $2 } '` if ( "$type" == "D" || "$type" == "d" ) then set WWW_thelist=`/usr/ucb/printenv WWW_lineSelect | awk -F\t ' { print $1 } '` if ( "$WWW_type" == WIN || "$WWW_type" == "NT" ) then set thedir="$WWW_dir"'\'"$WWW_thelist" set thedir=`echo $thedir | sed -e 's#\\\\#\\#'` else set thedir="$WWW_dir"'/'"$WWW_thelist" set thedir=`echo $thedir | sed -e "s#//#/#"` endif set WWW_priordir="$WWW_dir" else set temp=`/usr/ucb/printenv WWW_lineSelect | awk -F\t ' { print $1 } '` setenv WWW_filename "$temp" setenv WWW_func openFile $NF_CGIDIR/rp_util_java.cgi >& /tmp/re.$$ ##### fix to output correct error message for files with no read permission EOM grep "ERROR:" /tmp/re.$$ >& /tmp/null if ( $status == 0 ) then echo "
"
                        cat /tmp/re.$$ | grep -v "Content-type:"
                        echo "
" exit cat <& /dev/null endif else if ( "$?WWW_compress" ) then if ( "$?WWW_lineSelect" ) then if ( "$WWW_lineSelect" == "nothing selected" ) then echo 'content-type: text/html' echo '' echo '' echo 'Please select a document to compress' echo '' echo '' exit endif else echo 'content-type: text/html' echo '' echo '' echo 'Please select a document to compress' echo '' echo '' exit endif set type=`/usr/ucb/printenv WWW_lineSelect | awk -F\t ' { print $2 } '` if ( "$type" == "D" || "$type" == "d" ) then echo 'content-type: text/html' echo '' echo '' echo You can only compress a document, not a folder or directory. echo '' echo '' exit endif set thefile=`/usr/ucb/printenv WWW_lineSelect | awk -F\t ' { print $1 } '` setenv WWW_filename "$thefile" setenv nf_html yes setenv WWW_func compressFile setenv REQUEST_METHOD POST $NF_CGIDIR/rp_util_java.cgi >& /tmp/compress.$$ echo 'content-type: text/html' echo '' echo '' echo '
'

	cat /tmp/compress.$$ | grep -vi "Content-type:" | grep -vi "Got a message line:" | grep -vi "ACTION=PUT" | grep -vi "Can't"
	echo '
' rm -f /tmp/compress.$$ >& /dev/null if ( "$WWW_type" != "NT" && "$WWW_type" != "WIN" ) then set WWW_dir=`echo "$WWW_dir" | sed -e "s#/#%#"` set WWW_VMS=`echo "$WWW_VMS" | sed -e "s#/#%#"` set WWW_priordir=`echo "$WWW_priordir" | sed -e "s#/#%#"` endif cat << EOF
EOF exit endif ######################################################### cat << EOF Content-type: text/html $NF_APPLICATION

$NF_APPLICATION


EOF if ( $?WWW_username ) then set username=$WWW_username else if ( ! $?username ) then set username=$WWW_username endif if ( ! $?WWW_dir ) then set WWW_dir="" endif if ( "$WWW_dir" == "" ) then if ( "$WWW_type" == "WIN" || "$WWW_type" == "NT" ) then set WWW_dir="\" else set WWW_dir="/" endif endif if ( ! $?thedir ) then set thedir="$WWW_dir" endif #old #set temp=`echo $thedir | sed -e 's/ //g' | sed -e 's#/$##' | sed -e 's#\\$##'` #new echo $thedir > /tmp/thedir.$$ if ($?WWW_thelist) then echo $WWW_thelist > /tmp/wwwlst.$$ set wwwlst=`cat /tmp/wwwlst.$$` set temp=`sed -e "s/\$wwwlst//" /tmp/thedir.$$` echo $temp > /tmp/temp.$$ rm /tmp/wwwlst.$$ else set temp=`echo $thedir | sed -e 's/ //g' | sed -e 's#/$##' | sed -e 's#\\$##'` endif #rm /tmp/wwwlst.$$ rm /tmp/thedir.$$ if ( "$temp" == "" ) then if ( "$WWW_type" == "WIN" || "$WWW_type" == "NT" ) then set temp="\" else set temp="/" endif endif if ( "$WWW_type" == "WIN" || "$WWW_type" == "NT" ) then set WWW_priordir=`echo $temp | sed -e 's#\(.*\)\\[-_a-zA-Z0-9\.]*$#\1#'` else set WWW_priordir=`echo $temp | sed -e 's#\(.*\)/[-_a-zA-Z0-9\.]*$#\1#'` endif if ( "$WWW_priordir" == "" ) then if ( "$WWW_type" == "WIN" || "$WWW_type" == "NT" ) then set WWW_priordir="\" else set WWW_priordir="/" endif endif if ( ! $?WWW_machine ) then set WWW_machine="$1" set WWW_VMS="$2" set WWW_pass="$3" endif #set WWW_dir="$thedir" setenv WWW_func expandDir setenv REQUEST_METHOD POST setenv WWW_dir "$thedir" setenv nf_html yes $NF_CGIDIR/rp_util_java.cgi | grep -v "^Content-type:" | grep -v '^$' >& /tmp/1.$$ #if ( -z /tmp/1.$$ ) then # echo '
'
#        echo "Invalid directory $WWW_VMS$WWW_dir"
#        /bin/rm /tmp/1.$$
#        exit
#endif

grep 'ERROR:' /tmp/1.$$ >> /dev/null
if ( ! $status ) then
	grep -i 'Access denied' /tmp/1.$$ >> /dev/null
	if ( ! $status ) then
		echo '
'
		echo ERROR in PC system specification:
		echo 'You did not specify the correct password.'
		/bin/rm /tmp/1.$$
		exit
	endif
	grep -i 'Directory invalid' /tmp/1.$$ >> /dev/null
	if ( ! $status ) then
		echo '
'
		echo "Invalid directory."
		/bin/rm /tmp/1.$$
		exit
	endif
	grep -i 'invalid network name' /tmp/1.$$ >& /dev/null
	if ( ! $status ) then
		echo No such sharename.
		/bin/rm -f /tmp/1.$$
		exit
	endif
	echo "
"
	cat /tmp/1.$$ | grep -vi "Inappropriate" | grep -vi "understood" | grep -vi "ioctl" | grep -vi "^P" | grep -vi "^C" |grep -vi "^r" | grep -vi "device"
	echo "
" exit endif # source /tmp/remstat.$REMOTE_ADDR.$WWW_username.end if ( "$thedir" == "." ) then if ( "$WWW_type" == "FTP" ) then echo "Directory ' \ ' on machine $WWW_machine
" endif if ( "$WWW_type" == "NFS" ) then echo "Directory ' $WWW_VMS\ ' on machine $WWW_machine
" endif if ( "$WWW_type" == "NETWARE" ) then echo "Directory ' \ ', Volume $WWW_VMS on machine $WWW_machine
" endif if ( "$WWW_type" == "WIN" || "$WWW_type" == "NT" ) then echo "Folder ' \ ', Share $WWW_VMS on machine $WWW_machine
" endif else set temp=`echo $thedir | sed -e "s/\.//"` if ( "$WWW_type" == "FTP" ) then echo "Directory ' $temp ' on machine $WWW_machine
" endif if ( "$WWW_type" == "NFS" ) then echo "Directory ' $WWW_VMS$temp ' on machine $WWW_machine
" endif if ( "$WWW_type" == "NETWARE" ) then echo "Directory ' $temp ', Volume $WWW_VMS on machine $WWW_machine
" endif if ( "$WWW_type" == "WIN" || "$WWW_type" == "NT" ) then echo "Folder ' $temp ', Share $WWW_VMS on machine $WWW_machine
" endif endif cat << EOF

Type  Size          Date Modified                 File Name
EOF exit