#!/bin/sh
caller=${2}
called=${1}
# search name in contact list
entry=`cat /var/media/ftp/TransMemory-Partition-0-1/contacte.txt 2>/dev/null | fgrep "#=${caller}:" | sed "s/#contact=${caller}://"`
name=${entry%%\;*}
address=${entry#*\;}
address=${address%\;*}
street=${address%%\;*}
zip=${address##*\;}
# name not found?
if [ -z "${name}" ]
then
# do reverse lookup at [url]www.dasoertliche.de[/url]
/var/tmp/invers.sh ${caller}
name=`cat /var/tmp/name`
# found name?
if [ -n "${name}" ]
then
# add found contact to debug.cfg
address=`cat /var/tmp/address`
street=${address%%\;*}
zip=${address##*\;}
cat /var/media/ftp/TransMemory-Partition-0-1/contacte.txt | sed -e "s/^#CONTACTSEND$/#contact=${caller}:${name};${address};#CONTACTSEND/g" | sed -e 's/#CONTACTSEND$/\
#CONTACTSEND/g' > /var/tmp/contact
else
# add anonymous for contact to debug.cfg
cat /var/media/ftp/TransMemory-Partition-0-1/contacte.txt | sed -e "s/^#CONTACTSEND$/#contact=${caller}:${caller};#CONTACTSEND/g" | sed -e 's/#CONTACTSEND$/\
#CONTACTSEND/g' > /var/tmp/contact
fi
cat /var/tmp/contact > /var/media/ftp/TransMemory-Partition-0-1/contacte.txt
rm /var/tmp/contact
fi
# name not found?
if [ -z "${name}" ]
then
name=${caller}
fi
httpname=`echo "${name}" | sed -e '{s/ /%20/g;s/Ä/Ae/g;s/Ö/Oe/g;s/Ü/Ue/g;s/ä/ae/g;s/ö/oe/g;s/ü/ue/g;s/ß/ss/g;s/&/%26/g;}'`
httpstreet=`echo "${street}" | sed -e '{s/ /%20/g;s/Ä/Ae/g;s/Ö/Oe/g;s/Ü/Ue/g;s/ä/ae/g;s/ö/oe/g;s/ü/ue/g;s/ß/ss/g;s/&/%26/g;}'`
httpzip=`echo "${zip}" | sed -e '{s/ /%20/g;s/Ä/Ae/g;s/Ö/Oe/g;s/Ü/Ue/g;s/ä/ae/g;s/ö/oe/g;s/ü/ue/g;s/ß/ss/g;s/&/%26/g;}'`
echo "Name: ${name}"
echo "Strasse: ${street}"
echo "PLZ: ${zip}"
# search line in line list
theline=`cat /var/flash/ 2>/dev/null | fgrep "#line=${called}:" | sed "s/#line=${called}://"`
theline=${theline%%\;*}
# line not found?
if [ -z "${theline}" ]
then
theline=${called}
fi
httptheline=`echo "${theline}" | sed -e '{s/ /%20/g;s/Ä/Ae/g;s/Ö/Oe/g;s/Ü/Ue/g;s/ä/ae/g;s/ö/oe/g;s/ü/ue/g;s/ß/ss/g;s/&/%26/g;}'`
# Send information to all DHCP clients