#!/bin/sh
version=0.1.5
pass_f=$PWD/../.cgi_pass
menat_dir=/var/menat/localhost/menat
rv=4
if [ "$QUERY_STRING" ];then
for t in ${QUERY_STRING//\&/ } ;do
if [ ${t%=*} = ch_list ];then
ch_list=${t#*=}
elif [ ${t%=*} = xml_dir ];then
xml_dir=${t#*=}
xml_dir=${xml_dir%/}
elif [ ${t%=*} = token ];then
token=${t#*=}
elif [ ${t%=*} = auth ];then
auth=${t#*=}
fi
done
cgi_pass=`cat $pass_f`
pass_date=`date '+%Y%m%d%H%M'`
check_auth=`echo $REMOTE_ADDR$pass_date$cgi_pass |md5sum`
if [ "$auth" = ${check_auth%% *} ];then
rv=0
else
rv=1
fi
else
rv=2
fi
lock_f=$menat_dir/tmp/lock.mkts2xml.${ch_list##*/}
lock_f_b=$menat_dir/tmp/b1.lock.mkts2xml.${ch_list##*/}
ex_YmdHM=`LANG=C date '+%Y-%m-%d %a %H:%M'`
echo "$ex_YmdHM: $REMOTE_ADDR: ch_list=$ch_list: xml_dir=$xml_dir
token=$token: auth=$auth; rv=$rv" >$lock_f
echo -ne "Content-type: text/plain\r\n\r\n"
#0=OK, 1=AUTH error, 2=request error, 4=unknown error
echo -n "$rv"
exec >/dev/null
if [ $rv = 0 ];then
./mkts2xml.sh $ch_list "$xml_dir" ; xv=$?
end_YmdHM=`LANG=C date '+%Y-%m-%d %a %H:%M'`
echo "$end_YmdHM: ${ch_list##*/}; rv=$rv; xv=$xv" >${xml_dir##*,}/$token.token
fi
echo "$end_YmdHM: ${ch_list##*/}; rv=$rv; xv=$xv" >>$lock_f
mv $lock_f $lock_f_b
exit 0
---
txt.cgi-0.1.5