#!/usr/bin/bsh
set -f
deroot="$DOCUMENT_ROOT/de"
expr "$deroot" :deroot '/de/de' '/de'
arg="$QUERY_STRING"
ok=0
expr "$arg" :zn '^%([0-9]%{1,2%}%.[0-9]%{1,3%}%):.' && {
expr "$arg" :nam ':%(..*%)$' || nam=
expr "$nam" =:nam '%%2f' += '/'
expr "$nam" :dir '^%(.*/%)[^/]*$' || dir=
expr "$nam" :nam '%([^/]*%)$' || nam=
expr "$nam" :erw '%.%([^/.]%{1,%}%)$' || erw=
pre=XXXXXXXXXX
[ -s "$dir$pre$nam" ] && ok=1
}
[ ok -eq 0 ] && {
echo "Content-type: text/plain%n"
exit 0
}
HTTP_REFERER="$HTTP_REFERER::$dir$nam"
export HTTP_REFERER
expr "$REMOTE_ADDR" :: '127%.0%.0%.' || extern icnt.pl $zn.i0
ifset erw || erw=bin
conv -l erw
ctyp=text/plain
case "$erw" in
shtml|html|htm|php3) ctyp=text/html ;;
txt|bsh|pl|text) ctyp=text/plain ;;
exe|bin|zip|gz|tar|drv|z|obj|o)
ctyp=application/octet-stream ;;
gif) ctyp=image/gif ;;
jpg|jpeg) ctyp=image/jpeg ;;
*) ctyp=text/plain ;;
esac
systime Time
cd "$deroot"
set +f
for lkn in *[0-9][0-9]_[0-9]*
do
expr "$lkn" :time '^%([0-9]%{8,10}%)_[0-9]%{1,}_' || continue
let "Time-time>400" && remove "$lkn"
done
set -f
cd -
http_lkn="${Time}_$$_$nam"
lkn="$deroot/$http_lkn"
[ -e "$lkn" ] && remove "$lkn"
link "$dir$pre$nam" "$lkn"
clen=0
fstat -sv clen "$dir$pre$nam"
Out="Content-Type: $ctyp
Location: ../$http_lkn
Content-Length: $clen
"
catv Out
exit 0 |