Quantcast
Viewing all articles
Browse latest Browse all 5767

Reverse Lookup in Germany

Sysopsis:

This is an agi-script that does a reverse lookup of german telephone numbers.

For example:
  • you receive a call from 0049-69-123456.
  • The script looks the number up from the german telephone book and gives you the name in the variable ${LONGNAME} back.
  • in case of phone book lookup failure, it optionally supports lookup in older isdn4linux isdnlog callerid.conf content and as a last-ditch effort at least lookup of city names via isdnlog's isdnrate.

There is also a cache for storing already resolved numbers and a logfile.

Description:

The script returns ${LONGNAME} - it's also easily possible to get the address information (if provided by the public phonebook).
There are two interesting files:
  • CACHE="/var/spool/asterisk/invsuche_cache" - Here all numbers and resolved numbers are stored for faster lookup in the future (or manual resolving if number is not in phonebook)
  • LOG="/var/log/asterisk/anrufliste_log" - A logfile containing all callers

Example Dialplan

new Asterisk (1.4+?):


exten => _X.,1,Set(CHANNEL(language)=de)
exten => _X.,2,AGI(reverse.agi, ${CALLERID(num)})
exten => _X.,3,Set(CALLERID(name)=${LONGNAME})



old Asterisk:


exten => 12345,1,SetLanguage(de)
exten => 12345,2,AGI,reverse.agi| ${CALLERIDNUM}
exten => 12345,3,SetCIDName(${LONGNAME})
exten => 12345,4,SetCIDNum(${CALLERIDNUM}) 




This is the "reverse.agi"-script - place it in the AGI directory



#!/bin/sh
#
#read agi_request
#read agi_language
#read agi_channel
#read agi_type
#read agi_uniqueid
#read agi_callerid
#read agi_dnid
#read agi_rdnis
#read agi_context
#read agi_extension
#read agi_priority
#read agi_enhanced
#read agi_accountcode
#read emptyline

#pfad zum cachefile
CACHE="/var/spool/asterisk/invsuche_cache"

#pfad um das tempfile anzulegen
TMPFILE="/tmp/tmpsuche.html"
TMPFILE2="/tmp/tmpclir"
LOG="/var/log/asterisk/anrufliste_log"

echo "$1-$2-$3" >/tmp/reverse.tmp

if [ "$1" = " " ] || [ -z "$1" ]; then
    echo "Keine Nummer"
    #echo | tail -n 10 /var/log/syslog | grep "RING (" >>$TMPFILE2
    #if [ "`tail -c 10 $TMPFILE2`" = "z audio)  " ]; then
       NAME="analoger Anrufer"
       DETAILS="Keine details"
    #fi
    #if [ "`tail -c 10 $TMPFILE2`" = "(Speech) " ]; then
    #   NAME="aktiv unterdrueckt"
    #   DETAILS="ISDN anrufer ohne Nummer"
    #fi
else
    NUMMER=`echo $1 | sed -e "s/\ //g" -e "s/+49/0/"`
    echo "Suche nach $NUMMER im cache"
    NAME=`awk  -F '\t' '{ if ($1 == "'$NUMMER'") print $2 }' $CACHE`
    DETAILS=`awk  -F '\t' '{ if ($1 == "'$NUMMER'") print $3 }' $CACHE`
    echo "Name: \"$NAME\""
    echo "Details: \"$DETAILS\""
    #echo "name $NAME details $DETAILS" >> /tmp/reverse.tmp
    if [ -z "$NAME" ]; then
        wget -q --tries=3 --timeout=5 -O $TMPFILE "http://www1.dasoertliche.de/?form_name=search_inv&ph=$NUMMER"
        NAME=`grep 'na:' $TMPFILE | sed 's/.*na: "// ;s/",.*//'`
        DETAILS=`grep 'st:' $TMPFILE | sed 's/.*st: "// ;s/",.*//;s/%20/ /g'`", "`grep 'pc:' $TMPFILE | sed 's/.*pc: "// ;s/",.*//'`" "`grep 'ci:' $TMPFILE | sed 's/.*ci: "// ;s/",. ...

Viewing all articles
Browse latest Browse all 5767

Trending Articles