#!/bin/sh cat<

# DD-WRT Control Panel

Firmware: <% get_firmware_version(); %>
Uptime: <% get_uptime(); %>
WAN IP: <% nvram_status_get("wan_ipaddr"); %>

## Help

More...
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<

# Phonebook: Save 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 " cp /var/dbtext/ser/aliases /tmp/ser/ "; cp /var/dbtext/ser/aliases /tmp/ser/; echo "cp /var/dbtext/ser/location /tmp/ser/ "; cp /var/dbtext/ser/location /tmp/ser/; echo "cp /var/dbtext/ser/subscriber /tmp/ser/ "; cp /var/dbtext/ser/subscriber /tmp/ser/; echo "cp /var/dbtext/ser/version /tmp/ser/ "; cp /var/dbtext/ser/version /tmp/ser/; serctl start ser|awk 'sub("", " ") {print}'; sleep 3s; #route -n|awk ' #function td(s) { # printf(" | %s", 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("%s", $i); # printf "
\n"; #} #END { # print "

"; #}' cat<

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

# 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 elif [ -n "$post_details" ]; then #if [ -n "$post_details" ]; then #else cat<

# 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<

# 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 elif [ -n "$post_rmalias" ]; then cat<

# 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 elif [ -n "$post_rmaor" ]; then cat<

# 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 elif [ -n "$post_sendmsg" ]; then cat<

# 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 <"; 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: 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 #elif [ -n "$post_contacts" ]; then #cat< #EOF else cat<

# 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 fi cat<
EOF