#!/bin/sh
echo "Content-type: text/unl
"
#///*
#//*************************************************************************
#//** *
#//** Copyright (C) 2002-2011 Trans-Mit Pty. Ltd. Melbourne Australia *
#//** This software may not be loaned, resold, changed or copied *
#//** in any way without the express written permission of author *
#//** and Trans-Mit Pty. Ltd., Australia. *
#//** *
#//*************************************************************************
#//**
#//** $Header: $
#//** $Author: $
#//** $Date: $
#//** $Locker: $
#//**
#//*************************************************************************
#//*/
DODBG="false"; export DODBG
NOAUTH=""; export NOAUTH
#------------------------------
# Testing
#DODBG="true"; export DODBG
#export DODBG
#REMOTE_ADDR="10.67.124.99"
#conf_remuser="bilmax21"
#apassword="test"
#userpwdes="test"
#export conf_remuser
#export apassword
#export userpwdes
#------------------------------
# set environment variables.
. /u/catcom/catcom_vars
####################################
## get lock
#LOCKFILE="/tmp/t21websql.lok"
#while true
#do
# if [ ! -f "$LOCKFILE" ]; then
# break;
# fi
# sleep 2
#done
#touch $LOCKFILE
###################################
datetime=`date "+%d/%m/%Y %H:%M"`
myprogname=`basename "$0"`
mytitle="Directory Export 1"
##################################
# process query string
if [ ! -z "$QUERY_STRING" ]; then
qstr=`echo "$QUERY_STRING" | tr "&" " "`
$DODBG && echo "qstr=[$qstr]
" >>"$tmplog" 2>&1
for qtok in `echo "$qstr"`
do
$DODBG && echo "qtok=[$qtok]
" >>"$tmplog" 2>&1
fixqtok=`echo "$qtok" | wbt_fixqstr`
$DODBG && echo "fixqtok=[$fixqtok]
" >>"$tmplog" 2>&1
eval $fixqtok >>"$tmplog" 2>&1
done
fi
if [ "$DEBUG" = "1" ]; then
DODBG="true"
fi
export DODBG
####################################################################
# validate input
if [ "$NOAUTH" = "" -a \
"$REMOTE_ADDR" != "172.22.2.8" -a \
"$REMOTE_ADDR" != "10.242.35.30" -a \
"$REMOTE_ADDR" != "10.241.35.40" -a \
"$REMOTE_ADDR" != "10.240.35.149" -a \
"$REMOTE_ADDR" != "10.1.124.61" -a \
"$REMOTE_ADDR" != "10.1.122.10" -a \
"$REMOTE_ADDR" != "10.1.122.91" -a \
"$REMOTE_ADDR" != "10.1.122.75" -a \
"$REMOTE_ADDR" != "10.67.122.93" ]; then
echo "Not Authorised"
exit 0
fi
###################################
# export data
tmpfile1="/tmp/webdirtmp$$.unl"
rm -f $tmpfile1
txsql -d catcom -F "|" -o "$tmpfile1" < "$CSVOUTFILE"
)
##cp "$tmpfile1" /tmp/1
#rm -f "$tmpfile1"
################################
## hit file
#
#hitsfile="hits.ecut21dir"
#lasthit=`ls -altr $hitsfile | cut -c41-53`
#touch $hitsfile
#hits=`cat $hitsfile`
#if [ -z "$hits" ]; then
# hits="0"
#fi
#hits=`expr $hits + 1`
#echo "$hits" > $hitsfile
#echo "999998,~HITS $hits - LAST on $lasthit"
################################################################
#
###############################
# remove lock
#rm -f "$LOCKFILE"
###############################
exit 0