# Phonebook of $(nvram get lan_ipaddr)

#!/bin/sh echo Content-type: text/html echo cat<<EOF

Home

# Navigation

Phonebook
Status

EOF if [ "$REQUEST_METHOD" = "POST" ]; then read QUERY_STRING fi if [ -n "$QUERY_STRING" ]; then eval $(echo "$QUERY_STRING"|awk -F'&' '{for(i=1;i<=NF;i++){print $i}}') fi if [ -n "$post_savedb" ]; then cat<<EOF

# Phonebook: Save Database

", s); #} #function ip(s) { ## if(s!~/\.0$/) { ## td(sprintf("%s", s, s)); ## } ## else { # td(s); ## } # #} #BEGIN { # print "

"; #} #/^[0-9]/ { # printf "
"; # ip($1); # ip($2); # for(i=3;i<=NF;i++) td($i); # printf "
\n"; #} #/^Destination/ { # printf "
"; # for(i=1;i<=NF;i++) printf("
", $i); # printf "
%s
\n"; #} #END { # print "

"; #}' cat<<EOF

EOF if [ $(nvram get sip_domain) ]; then export SIP_DOMAIN=$(nvram get sip_domain); else export SIP_DOMAIN=$(ifconfig $(nvram get lan_ifname)|awk 'sub("inet addr:","") {print $1}'); fi; serctl stop ser|awk 'sub("", "
") {print}'; sleep 3s; echo "
cp /var/dbtext/ser/aliases /etc/ser/
"; cp /var/dbtext/ser/aliases /etc/ser/; echo "cp /var/dbtext/ser/location /etc/ser/
"; cp /var/dbtext/ser/location /etc/ser/; echo "cp /var/dbtext/ser/subscriber /etc/ser/
"; cp /var/dbtext/ser/subscriber /etc/ser/; echo "cp /var/dbtext/ser/version /etc/ser/
"; cp /var/dbtext/ser/version /etc/ser/; serctl start ser|awk 'sub("", "
") {print}'; sleep 3s; echo "Done
"; #route -n|awk ' #function td(s) { # printf("

%s

EOF elif [ -n "$post_flushdb" ]; then cat<<EOF

# Phonebook: Flush Database

EOF if [ $(nvram get sip_domain) ]; then export SIP_DOMAIN=$(nvram get sip_domain); else export SIP_DOMAIN=$(ifconfig $(nvram get lan_ifname)|awk 'sub("inet addr:","") {print $1}'); fi; serctl stop ser|awk 'sub("", "
") {print}'; sleep 3s; echo "
Emptying /var/dbtext/ser/aliases
"; echo "username(str) domain(str,null) contact(str,null) expires(int,null) q(double,null) callid(str,null) cseq(int,null) last_modified(str,null) replicate(int,null) state(int,null) flags(int) user_agent(str) received(str,null)" > /var/dbtext/ser/aliases; echo "
Emptying /var/dbtext/ser/location
"; echo "username(str) domain(str,null) contact(str,null) expires(int,null) q(double,null) callid(str,null) cseq(int,null) last_modified(str,null) replicate(int,null) state(int,null) flags(int) user_agent(str) received(str,null)" > /var/dbtext/ser/location; echo "
Emptying /var/dbtext/ser/subscriber
"; echo "sername(str) domain(str) password(str) first_name(str) last_name(str) phone(str) email_address(str) datetime_created(int) datetime_modified(int) confirmation(str) flag(str) sendnotification(str) greeting(str) ha1(str) ha1b(str) perms(str) allow_find(str) timezone(str,null) rpid(str,null) uuid(str,null)" > /var/dbtext/ser/subscriber; echo "
Emptying /var/dbtext/ser/version
"; echo "table_name(str) table_version(int) subscriber:3 location:6 aliases:6" > /var/dbtext/ser/version; serctl start ser|awk 'sub("", "
") {print}'; sleep 3s; echo "Done
"; cat<<EOF

EOF elif [ -n "$post_details" ]; then #if [ -n "$post_details" ]; then #else cat<<EOF

# Phonebook: Details

SER Userlist:

Contact Details$(if [ $(nvram get sip_domain) ]; then export SIP_DOMAIN=$(nvram get sip_domain); else export SIP_DOMAIN=$(ifconfig $(nvram get lan_ifname)|awk 'sub("inet addr:","") {print $1}'); fi; serctl ul show| grep "^domain :\|^aor :\|^Contact\|^Expires\|^Call-ID\|^User-Agent\|^State" | \ sed -e "s/^\(domain \)/======================================\n\1/" | awk 'sub("", "
") {print}';)

$(if [ $(nvram get sip_domain) ]; then export SIP_DOMAIN=$(nvram get sip_domain); else export SIP_DOMAIN=$(ifconfig $(nvram get lan_ifname)|awk 'sub("inet addr:","") {print $1}'); fi; serctl ul show | grep 'aor :' | awk 'sub("","") {print $3}' | cut -f2 -d"'" | awk ' function td(s) { printf("1 %s 2", s); } function ip(s) { # if(s!~/\.0$/) { # td(sprintf("%s", s, s)); # } # else { td(s); # } } BEGIN { print "

Alias:

$(if [ $(nvram get sip_domain) ]; then export SIP_DOMAIN=$(nvram get sip_domain); else export SIP_DOMAIN=$(ifconfig $(nvram get lan_ifname)|awk 'sub("inet addr:","") {print $1}'); fi; serctl ul show | grep 'Contact :' | awk 'sub("","") {print $3}' | cut -f2 -d"'" | awk ' function td(s) { printf("1 %s 2", s); } function ip(s) { # if(s!~/\.0$/) { # td(sprintf("%s", s, s)); # } # else { td(s); # } } BEGIN { print "

EOF #if [ $(nvram get sip_domain) ]; # | grep "^aor :\|^User-Agent: 'SIP Express Router FIFO'" | \ # then export SIP_DOMAIN=$(nvram get sip_domain); # else export SIP_DOMAIN=$(ifconfig $(nvram get lan_ifname)|awk 'sub("inet addr:","") {print $1}'); fi; #serctl restart ser|awk 'sub("", "
") {print}'; sleep 3s; elif [ -n "$post_newalias" ]; then cat<<EOF

# Phonebook: Alias addition

EOF #test -z "$(nvram get ff_lan_proto)" && lan_proto=noconfig; if [ $(nvram get sip_domain) ]; then export SIP_DOMAIN=$(nvram get sip_domain); else export SIP_DOMAIN=$(ifconfig $(nvram get lan_ifname)|awk 'sub("inet addr:","") {print $1}'); fi; # echo "$URI
"; echo "serctl alias add $newalias $(echo "$URI" | sed -n -f html.sed)
"; serctl alias add $newalias $(echo "$URI" | sed -n -f html.sed;); echo "
"; cat<<EOF

EOF elif [ -n "$post_rmalias" ]; then cat<<EOF

# Phonebook: Alias removal

EOF #test -z "$(nvram get ff_lan_proto)" && lan_proto=noconfig; if [ $(nvram get sip_domain) ]; then export SIP_DOMAIN=$(nvram get sip_domain); else export SIP_DOMAIN=$(ifconfig $(nvram get lan_ifname)|awk 'sub("inet addr:","") {print $1}'); fi; # echo "$URI "; echo "serctl alias rm $newalias "; serctl alias rm $newalias; echo " "; cat<<EOF

EOF elif [ -n "$post_rmaor" ]; then cat<<EOF

# Phonebook: URI removal

EOF #test -z "$(nvram get ff_lan_proto)" && lan_proto=noconfig; if [ $(nvram get sip_domain) ]; then export SIP_DOMAIN=$(nvram get sip_domain); else export SIP_DOMAIN=$(ifconfig $(nvram get lan_ifname)|awk 'sub("inet addr:","") {print $1}'); fi; # echo "$URI "; echo "serctl ul rm $AOR "; serctl ul rm $AOR; echo " "; cat<<EOF

EOF elif [ -n "$post_sendmsg" ]; then cat<<EOF

# Phonebook: SIP Messaging

EOF ##test -z "$(nvram get ff_lan_proto)" && lan_proto=noconfig; # if [ $(nvram get sip_domain) ]; # then export SIP_DOMAIN=$(nvram get sip_domain); # else export SIP_DOMAIN=$(ifconfig $(nvram get lan_ifname)|awk 'sub("inet addr:","") {print $1}'); fi; ## echo "$URI
"; # echo "serctl ul rm $AOR
"; # serctl ul rm $AOR; # echo "
"; # echo ("cat > /tmp/ser_fifo <<EOF echo "Sending message...<br>"; echo ":t_uac_dlg:ser_fifo_replies MESSAGE $(echo "$URI" | sed -n -f html.sed;) . From: sip:mf@$(nvram get sip_domain) To: $(echo "$URI" | sed -n -f html.sed;) foo: bar_special_header x: y p_header: p_value Contact: <sip:devnull@$(nvram get sip_domain):9> Content-Type: text/plain; charset=UTF-8 . $(echo "$sendmsg" | sed -n -f html.sed) . EOF" > /tmp/msg; # cat /tmp/msg; mkfifo -m 666 /tmp/ser_fifo_replies; cat /tmp/msg > /tmp/ser_fifo; echo "
"; cat /tmp/ser_fifo_replies | awk 'sub("", "
") {print}'; echo "
"; rm /tmp/ser_fifo_replies; #if [ $(nvram get sip_domain) ]; #then export SIP_DOMAIN=$(nvram get sip_domain); #else export SIP_DOMAIN=$(ifconfig $(nvram get lan_ifname)|awk 'sub("inet addr:","") {print $1}'); fi; #serctl restart | awk 'sub("", "
") {print}'; cat<<EOF

EOF #elif [ -n "$post_contacts" ]; then #cat<<EOF # #EOF else cat<<EOF

# Phonebook: Contacts

Active URIs

Phone URI / Alias $(if [ $(nvram get sip_domain) ]; then export SIP_DOMAIN=$(nvram get sip_domain); else export SIP_DOMAIN=$(ifconfig $(nvram get lan_ifname)|awk 'sub("inet addr:","") {print $1}'); fi; serctl ul show | grep 'aor :' | awk 'sub("","") {print $3}' | \ sed -e "s/^\('\)/======================================\n\1/" | awk 'sub("", "
") {print}';)
======================================

Messaging:

$(if [ $(nvram get sip_domain) ]; then export SIP_DOMAIN=$(nvram get sip_domain); else export SIP_DOMAIN=$(ifconfig $(nvram get lan_ifname)|awk 'sub("inet addr:","") {print $1}'); fi; serctl ul show | grep 'Contact :' | awk 'sub("","") {print $3}' | cut -f2 -d"'" | awk ' function td(s) { printf("1 %s 2", s); } function ip(s) { # if(s!~/\.0$/) { # td(sprintf("%s", s, s)); # } # else { td(s); # } } BEGIN { print "

EOF cat<<EOF

EOF fi cat<<EOF
Top of page
Copyright © 2005 SIP at Home Project Crew - All rights reserved.
Logos and trademarks are the property of their respective owners.
This web page is licensed under the GNU Free Documentation License
The software promoted on this website is licensed under the GNU General Public License
Please note that this software is under development
and comes with absolutely no warranty, to the extend permitted by applicable law.
Definition of Open Source
EOF