first pass at working ip phones page
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 6 Jan 2010 03:55:11 +0000 (03:55 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 6 Jan 2010 03:55:11 +0000 (03:55 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@98 01035d8c-6547-0410-b346-abe4f91aad63

14 files changed:
easy-asterisk-gui/Makefile
easy-asterisk-gui/at-530.html [new file with mode: 0644]
easy-asterisk-gui/ipphones.js
easy-asterisk-gui/ipphones.pl [new file with mode: 0755]
easy-asterisk-gui/ipphones.sh
easy-asterisk-gui/login.sh
easy-asterisk-gui/menu.html
easy-asterisk-gui/phone.js [deleted file]
easy-asterisk-gui/phone.pl [deleted file]
easy-asterisk-gui/phone.sh [deleted file]
easy-asterisk-gui/phones.js [new file with mode: 0644]
easy-asterisk-gui/phones.pl [new file with mode: 0755]
easy-asterisk-gui/phones.sh [new file with mode: 0644]
easy-asterisk-gui/tooltips.html

index 544598a864e7f1c6958201f467b19e80fde049c0..2543554b01aef06027112593c893929af1574dcc 100644 (file)
@@ -9,5 +9,5 @@ TESTIP=192.168.1.150
 #      rcp index.html root@$(TESTIP):/var/lib/asterisk/static-http/
 
 test:
-       rcp ipphones.sh ipphones.js voipline.jpg anphone.png phoneline.jpg ipphone.png phone.pl tooltips.html phone.sh phone.js tick.png cross.png banner.html menu.html check_loggedin.sh logout.sh login.sh network.sh network.js set_network.sh tooltip.js tooltip.css root@$(TESTIP):/www/cgi-bin
+       rcp at-530.html ipphones.pl ipphones.sh ipphones.js voipline.jpg anphone.png phoneline.jpg ipphone.png phones.pl tooltips.html phones.sh phones.js tick.png cross.png banner.html menu.html check_loggedin.sh logout.sh login.sh network.sh network.js set_network.sh tooltip.js tooltip.css root@$(TESTIP):/www/cgi-bin
        rcp sip.conf extensions.conf root@$(TESTIP):/etc/asterisk
diff --git a/easy-asterisk-gui/at-530.html b/easy-asterisk-gui/at-530.html
new file mode 100644 (file)
index 0000000..ab94e3d
--- /dev/null
@@ -0,0 +1,15 @@
+<ol>
+<li>Connect the WAN port of the AT-530 to your LAN, it will boot and obtain an IP via DHCP.  
+<li>Find the <strong>IP</strong> of the phone by pressing the <strong>Sysinfo</strong> button a few times.  
+<li>Open another browser window.  Go to the phones <strong>IP</strong>, for example <strong>http://192.168.1.160</strong>
+<li>Login to the phone using the username/password <strong>admin/admin</strong>.  
+<li>Optional: set a static IP using the WAN menu (I like static IPs for SIP phones).  
+<li>Go to the phone <strong>SIP Config</strong> menu.
+<li>Set <strong>Register Server Address</strong> to your Phone System IP Address.
+<li>Set <strong>Register Username</strong> to the phone number (e.g. 6011).
+<li>Also set </strong>Register Password</strong> to the phone number (e.g. 6011) and
+the </strong>Phone Number</strong> to the phone number (e.g. 6011).
+<li>Check the *Enable Register* box.
+<li>Then click on <strong>Apply</strong>. 
+<li>Refresh this page to see if the phone is connected to your Phone system.
+</ol>
index 74d6eaf1bb5ad05e5f1cee5bdf6f08950807d404..9c50ceac6f166dfcc23e90096e25db968ff022ce 100644 (file)
@@ -1,7 +1,3 @@
 function localInit() {
-    if (init_internet == "yes")
-       $('internet').innerHTML = '<img src="tick.png" alt="tick" />';
-    else
-        $('internet').innerHTML = '<img src="cross.png" alt="tick" />';
 }
 
diff --git a/easy-asterisk-gui/ipphones.pl b/easy-asterisk-gui/ipphones.pl
new file mode 100755 (executable)
index 0000000..cdd93d1
--- /dev/null
@@ -0,0 +1,87 @@
+#!/sbin/microperl
+# ipphones.pl
+# David Rowe 6 Jan 2010
+#
+# Test processing for the ipphones screen
+
+$ipaddress = $ARGV[0];
+$more = $ARGV[1];
+
+# Slurp up SIP extension (Sip) data from extensions.conf
+
+my %ip = (); # ip extension keyed on sip.conf name
+
+open EXT, "/etc/asterisk/extensions.conf";
+while (<EXT>) { 
+    if (/.*=>[ ]*([0-9]*),1.*SIP\/([0-9]*)\)/) {
+        $ip{$2} = $1;
+       #print "'$1' '$2' $ip{$2}\n";
+    }
+}
+close EXT;
+
+my %sip = ();  # SIP IP phone status keyed on sip.conf names 
+               # if no entry we can't see IP phone device
+my %voip = (); # SIP trunks status keyed on sip.conf names 
+               # if no entry we can't see SIP trunk
+my %ipad = (); # IP address of SIP device keyed on sip.conf names
+
+open SIP, "sipshowpeers.txt";
+while (<SIP>) { 
+    if (/^([0-9]*)[\s\/].*(OK)/) {
+        $sip{$1} = $2;
+       #print "'$1' '$2' $sip{$1}\n";
+       $e = $1;
+       if (/\s([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s/) {
+           $ipad{$e} = $1;
+           #print "'$1'\n";
+       }
+    }
+    if (/^(voip[0-9]*)[\s\/].*(OK)/) {
+        $voip{$1} = $2;
+       #print "'$1' '$2' $voip{$1}\n";
+       $e = $1;
+       if (/\s([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s/) {
+           $ipad{$e} = $1;
+           #print "'$1'\n";
+       }
+    }
+}
+
+close SIP;
+
+# print list of IP phones with connection status
+
+$unconnected = 0;
+foreach $e (sort keys %ip) {
+    if ($sip{$e} eq "OK") {
+       $icon = "<img src=\"tick.png\" alt=\"Connected\" />";
+        $tooltip_status = "onMouseOver=\"popUp(event,'ipphones_connected')\" onmouseout=\"popUp(event,'ipphones_connected')\"";    
+        $comment=$ipad{$e};
+        $tooltip_ext = "onMouseOver=\"popUp(event,'phone_ext')\" onmouseout=\"popUp(event,'phone_ext')\"";
+       $tooltip_ip =  "onMouseOver=\"popUp(event,'phone_ipphone_ip')\" onmouseout=\"popUp(event,'phone_ipphone_ip')\"";
+    }
+    else {
+       $unconnected = $unconnected + 1;
+       $icon = "<img src=\"cross.png\" alt=\"Not Connected\" />";
+        $tooltip_status = "onMouseOver=\"popUp(event,'ipphones_notconnected')\" onmouseout=\"popUp(event,'ipphones_notconnected')\"";
+        $comment="Available";
+       $tooltip_id = "iphones_$e";
+       print "<div id=\"$tooltip_id\" class=\"tip\"> Configure your IP phone with username/password $e/$e, SIP Server IP $ipaddress</div>";
+        $tooltip_ext = "onMouseOver=\"popUp(event,'$tooltip_id')\" onmouseout=\"popUp(event,'$tooltip_id')\"";
+       $tooltip_ip = "";
+    }
+    
+    if ($more == 1 || ($unconnected < 5)) {
+       print "<tr><td $tooltip_ext>$e</td><td></td><td $tooltip_ip>$comment</td><td $tooltip_status>$icon</td></tr>\n";
+    }
+}
+
+if ($more == 0) {
+    print '<tr><td><a href="ipphones.sh?more=1">more</a></td></tr>';
+}
+else {
+    print '<tr><td><a href="ipphones.sh">less</a></td></tr>';
+}
+
+
index 6f63dab1c96abb8f75f1f07ea256b22b4208f92b..fccfb08a4b137c57acc7e6e99aa5d73804436013 100644 (file)
@@ -3,6 +3,9 @@
 # David Rowe 6 Jan 2010
 # Dashboard screen for Easy Asterisk GUI
 
+more=`echo "$QUERY_STRING" | grep -oe "more=[^&?]*" | sed -n "s/more=//p"`
+ipaddress=`ifconfig eth0 | sed -n 's/.*inet addr:\(.*\)  Bcast.*/\1/p'`
+
 # Construct the web page -------------------------------
 
 sh check_loggedin.sh
@@ -34,19 +37,27 @@ cat <<EOF
 
     <td valign="top">
 
-    <form action="/cgi-bin/set_network.sh" onsubmit="return validate_form(this)" method="get">
     <table align="right" width=600 border=0>
-      <tr><td colspan="3" align="left" valign="top" ><h2>Dashboard</h2></td></tr>
-      <tr onMouseOver="popUp(event,'network_internet')" onmouseout="popUp(event,'network_internet')">
-         <td>Internet Connection:</td>
-         <td><div id="internet" >
-         <span style="margin-left: 4px;font-weight:bold">&nbsp;</span></div></td>
-      </tr>
-    </table>
-    </form>
+      <tr><td  onMouseOver="popUp(event,'ipphones_ipphones')" onmouseout="popUp(event,'ipphones_ipphones')" 
+           colspan="4" align="left" valign="top" ><h2>IP Phones</h2></td></tr>
+      <tr onMouseOver="popUp(event,'phone_ipaddress')" onmouseout="popUp(event,'phone_ipaddress')">
+         <td colspan="3">Phone System IP Address:</td>
+EOF
+echo "<td>$ipaddress</td></tr><td>&nbsp;</td><tr></tr>"
+
+    # use perl to construct list of IP phones for us
+    asterisk "-rx sip show peers" 2>/dev/null > sipshowpeers.txt
+    ./ipphones.pl $ipaddress $more
 
-    </td>
+cat <<EOF
+    </table>
 
+    <h2>&nbsp;<br>How to Configure IP Phones</h2>
+    <h3>1. Atcom AT-530</h3>
+EOF
+cat at-530.html
+cat <<EOF
+     </td>
     </tr>
 
 </table>
index afe42e3fca30782b0adc351e6831dc5cbd5c1409..3213d685ca5041049425d286e6b8e9b1d40d0d60 100644 (file)
@@ -42,7 +42,7 @@ else
         echo ""
        echo "<head>"
        echo "<title>Easy Asterisk - Login</title>"
-       echo '<meta http-equiv="REFRESH" content="0;url=http:dashboard.sh">'
+       echo '<meta http-equiv="REFRESH" content="0;url=http:phones.sh">'
        echo "<body>"
        echo "Please wait a few seconds....."
        echo "</body>"
index c4bc9f74fd47b941d23b3d8eeb3aa48c31ecd0d7..d56b597dc29bd05a3d4a6125b8824816db21c2cf 100644 (file)
@@ -12,7 +12,7 @@
          <td><a href="network.sh">Network</a></td>
        </tr>
        <tr onMouseOver="popUp(event,'ipphones_tip')" onmouseout="popUp(event,'ipphones_tip')">
-         <td><a href="network.sh">IP Phones</a></td>
+         <td><a href="ipphones.sh">IP Phones</a></td>
        </tr>
        <tr onMouseOver="popUp(event,'phones_tip')" onmouseout="popUp(event,'phones_tip')">
          <td><a href="phones.sh">Phones</a></td>
diff --git a/easy-asterisk-gui/phone.js b/easy-asterisk-gui/phone.js
deleted file mode 100644 (file)
index 74d6eaf..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-function localInit() {
-    if (init_internet == "yes")
-       $('internet').innerHTML = '<img src="tick.png" alt="tick" />';
-    else
-        $('internet').innerHTML = '<img src="cross.png" alt="tick" />';
-}
-
diff --git a/easy-asterisk-gui/phone.pl b/easy-asterisk-gui/phone.pl
deleted file mode 100755 (executable)
index 93157bb..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-#!/sbin/microperl
-# phone.pl
-# David Rowe 5 Jan 2010
-#
-# Extracts the phone extension infor from /etc/asterisk/extensions.conf
-# and generate html.  Perl used as faster than equivalent shell script
-
-$tool_tip = "onMouseOver=\"popUp(event,'network_internet')\" onmouseout=\"popUp(event,'network_internet')\"";
-
-my %analog = (); # analog extension keyed on zap port
-
-open EXT, "/etc/asterisk/extensions.conf";
-while (<EXT>) { 
-    if (/.*=>[ ]*([0-9]*),1.*Zap\/([0-9]*)\)/) {
-        $analog{$2} = $1;
-       #print "'$1' '$2' $analog{$2}\n";
-    }
-}
-close EXT;
-
-my %zap = (); # zaptel port type keyed on zap port 
-              # (fxs/fxo or no entry if not live)
-open ZAP, "/etc/zaptel.conf";
-while (<ZAP>) { 
-    if (/fxoks=([0-9]*)/) {
-        $zap{$1} = "fxs";
-    }
-    if (/fxsks=([0-9]*)/) {
-        $zap{$1} = "fxo";
-    }
-}
-close ZAP;
-
-my %ip = (); # ip extension keyed on sip.conf name
-
-open EXT, "/etc/asterisk/extensions.conf";
-while (<EXT>) { 
-    if (/.*=>[ ]*([0-9]*),1.*Sip\/([0-9]*)\)/) {
-        $ip{$2} = $1;
-       #print "'$1' '$2' $ip{$2}\n";
-    }
-}
-close EXT;
-
-my %sip = ();  # SIP IP phone status keyed on sip.conf names 
-               # if no entry we can't see IP phone device
-my %voip = (); # SIP trunks status keyed on sip.conf names 
-               # if no entry we can't see SIP trunk
-my %ipad = (); # IP address of SIP device keyed on sip.conf names
-
-open SIP, "sipshowpeers.txt";
-while (<SIP>) { 
-    if (/^([0-9]*)[\s\/].*(OK)/) {
-        $sip{$1} = $2;
-       #print "'$1' '$2' $sip{$1}\n";
-       $e = $1;
-       if (/\s([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s/) {
-           $ipad{$e} = $1;
-           #print "'$1'\n";
-       }
-    }
-    if (/^(voip[0-9]*)[\s\/].*(OK)/) {
-        $voip{$1} = $2;
-       #print "'$1' '$2' $voip{$1}\n";
-       $e = $1;
-       if (/\s([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s/) {
-           $ipad{$e} = $1;
-           #print "'$1'\n";
-       }
-    }
-}
-
-close SIP;
-
-# print list of analog phones
-
-$tooltip_anphone = "onMouseOver=\"popUp(event,'phone_anphone')\" onmouseout=\"popUp(event,'phone_anphone')\"";
-$tooltip_ext = "onMouseOver=\"popUp(event,'phone_ext')\" onmouseout=\"popUp(event,'phone_ext')\"";
-$tooltip_port = "onMouseOver=\"popUp(event,'phone_port_phone')\" onmouseout=\"popUp(event,'phone_port_phone')\"";
-
-foreach $a (sort keys %analog) {
-    if ($zap{$a} eq "fxs") {
-       $icon = "<img src=\"anphone.png\" alt=\"Analog Phone\" />";
-       print "<tr><td $tooltip_ext>$analog{$a}</td><td $tooltip_anphone>Analog Phone</td><td $tooltip_port>Port $a</td><td>$icon</td></tr>\n";
-    }
-}
-
-# print list of IP phones
-
-$tooltip_ipphone = "onMouseOver=\"popUp(event,'phone_ipphone')\" onmouseout=\"popUp(event,'phone_ipphone')\"";
-$tooltip_ipphone_ip = "onMouseOver=\"popUp(event,'phone_ipphone_ip')\" onmouseout=\"popUp(event,'phone_ipphone_ip')\"";
-
-foreach $s (sort keys %sip) {
-    if ($sip{$s} eq "OK") {
-       $icon = "<img src=\"ipphone.png\" alt=\"IP Phone\" />";
-       print "<tr><td $tooltip_ext>$s</td><td $tooltip_ipphone>IP Phone</td<td $tooltip_ipphone_ip>$ipad{$s}</td><td>$icon</td></tr>\n";
-    }
-}
-
-$tool_tip = "onMouseOver=\"popUp(event,'phone_lines')\" onmouseout=\"popUp(event,'phone_lines')\"";
-
-print '<tr><td>&nbsp</td></tr>';
-print "<tr $tool_tip><td colspan=\"4\" align=\"left\" valign=\"top\" ><h2>Phone Lines</h2></td></tr>
-";
-
-# print list of analog phone lines
-
-$tooltip_phoneline = "onMouseOver=\"popUp(event,'phone_phoneline')\" onmouseout=\"popUp(event,'phone_phoneline')\"";
-$tooltip_port = "onMouseOver=\"popUp(event,'phone_port_line')\" onmouseout=\"popUp(event,'phone_port_line')\"";
-
-foreach $a (sort keys %analog) {
-    if ($zap{$a} eq "fxo") {
-       $icon = "<img src=\"phoneline.jpg\" alt=\"Phone Line\" />";
-       print "<tr><td>$analog{$a}</td><td $tooltip_phoneline>Analog</td><td $tooltip_port>Port $a</td><td>$icon</td></tr>\n";
-    }
-}
-
-# print list of SIP VOIP trunks
-
-$tooltip_voipline = "onMouseOver=\"popUp(event,'phone_voipline')\" onmouseout=\"popUp(event,'phone_voipline')\"";
-$tooltip_voipline_ip = "onMouseOver=\"popUp(event,'phone_voipline_ip')\" onmouseout=\"popUp(event,'phone_voipline_ip')\"";
-
-foreach $s (sort keys %voip) {
-    if ($voip{$s} eq "OK") {
-       $icon = "<img src=\"voipline.jpg\" alt=\"VOIP Line\" />";
-       print "<tr><td>$s</td><td $tooltip_voipline>VOIP</td><td $tooltip_voipline_ip>$ipad{$s}</td><td>$icon</td></tr>\n";
-    }
-}
-
diff --git a/easy-asterisk-gui/phone.sh b/easy-asterisk-gui/phone.sh
deleted file mode 100644 (file)
index 7a36ccb..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/bin/sh -x
-# phone.sh
-# David Rowe 4 Jan 2010
-# CGI for Easy Asterisk phones GUI
-
-# See if we have Internet connectivity, first check dns as time outs can be very slow
-
-dns=`cat /etc/resolv.conf | awk '/^nameserver/ {print $2}'`
-dns_packet_loss=`ping $dns -c 1 -q | sed -n 's/.*received, \(.*\)% packet loss/\1/p'`
-internet="no";
-if [ $dns_packet_loss == "0" ]; then
-  packet_loss=`ping google.com -c 1 -q | sed -n 's/.*received, \(.*\)% packet loss/\1/p'`
-  if [ $packet_loss == "0" ]; then
-    internet="yes";
-  fi
-fi
-
-ipaddress=`ifconfig eth0 | sed -n 's/.*inet addr:\(.*\)  Bcast.*/\1/p'`
-
-# Construct the web page -------------------------------
-
-sh check_loggedin.sh
-
-cat <<EOF
-<script src="prototype.js"></script>
-<link href="astman.css" media="all" rel="Stylesheet" type="text/css" />
-<script type="text/javascript" src="tooltip.js"></script>
-<link rel="stylesheet" href="tooltip.css" type="text/css" />
-EOF
-
-echo "<script>"
-echo 'var init_internet="'$internet'";'
-cat phone.js
-echo "</script>"
-
-cat << EOF
-<html>
-<title>Easy Asterisk - Phones</title>
-<body onload="localInit()">
-EOF
-
-cat tooltips.html
-echo '<table align="center" width=800>'
-cat banner.html
-echo "    <tr>"
-cat menu.html    
-cat <<EOF
-
-    <td valign="top">
-
-    <table align="right" width=600>
-      <tr>
-          <td onMouseOver="popUp(event,'phone_system')" onmouseout="popUp(event,'phone_system')" colspan="3" align="left" valign="top"><h2>Phone System</h2></td>
-         <td onMouseOver="popUp(event,'phone_addipphone')" onmouseout="popUp(event,'phone_addipphone')"><a href="addipphone.sh">Add IP Phone</a></td>
-      </tr>
-      <tr onMouseOver="popUp(event,'network_internet')" onmouseout="popUp(event,'network_internet')">
-         <td colspan="3">Internet Connection:</td>
-         <td><div id="internet" >&nbsp;</div></td>
-      </tr>
-      <tr onMouseOver="popUp(event,'phone_ipaddress')" onmouseout="popUp(event,'phone_ipaddress')">
-         <td colspan="3">Phone System IP Address:</td>
-EOF
-echo "<td>$ipaddress</td>"
-cat <<EOF
-      </tr>
-      <tr><td>&nbsp</td></tr>
-      <tr onMouseOver="popUp(event,'phone_phones')" onmouseout="popUp(event,'phone_phones')">
-          <td colspan="4" align="left" valign="top" ><h2>Phones</h2></td>
-      </tr>
-EOF
-
-# use perl to construct list of phones and phone lines for us
-asterisk "-rx sip show peers" 2>/dev/null > sipshowpeers.txt
-./phone.pl
-
-cat<<EOF
-    </table>
-
-    </td>
-
-    </tr>
-
-</table>
-</body>
-</html>
-EOF
-
diff --git a/easy-asterisk-gui/phones.js b/easy-asterisk-gui/phones.js
new file mode 100644 (file)
index 0000000..74d6eaf
--- /dev/null
@@ -0,0 +1,7 @@
+function localInit() {
+    if (init_internet == "yes")
+       $('internet').innerHTML = '<img src="tick.png" alt="tick" />';
+    else
+        $('internet').innerHTML = '<img src="cross.png" alt="tick" />';
+}
+
diff --git a/easy-asterisk-gui/phones.pl b/easy-asterisk-gui/phones.pl
new file mode 100755 (executable)
index 0000000..518b40f
--- /dev/null
@@ -0,0 +1,134 @@
+#!/sbin/microperl
+# phones.pl
+# David Rowe 5 Jan 2010
+#
+# Test processing for the phones screen.
+
+$tool_tip = "onMouseOver=\"popUp(event,'network_internet')\" onmouseout=\"popUp(event,'network_internet')\"";
+
+# Slurp up analog port (Zap) data from extensions.conf
+
+my %analog = (); # analog extension keyed on zap port
+
+open EXT, "/etc/asterisk/extensions.conf";
+while (<EXT>) { 
+    if (/.*=>[ ]*([0-9]*),1.*Zap\/([0-9]*)\)/) {
+        $analog{$2} = $1;
+       #print "'$1' '$2' $analog{$2}\n";
+    }
+}
+close EXT;
+
+# Slurp up data on installed zaptel ports from /etc/zaptel.conf
+
+my %zap = (); # zaptel port type keyed on zap port 
+              # (fxs/fxo or no entry if not live)
+open ZAP, "/etc/zaptel.conf";
+while (<ZAP>) { 
+    if (/fxoks=([0-9]*)/) {
+        $zap{$1} = "fxs";
+    }
+    if (/fxsks=([0-9]*)/) {
+        $zap{$1} = "fxo";
+    }
+}
+close ZAP;
+
+# Slurp up SIP extension (Sip) data from extensions.conf
+
+my %ip = (); # ip extension keyed on sip.conf name
+
+open EXT, "/etc/asterisk/extensions.conf";
+while (<EXT>) { 
+    if (/.*=>[ ]*([0-9]*),1.*Sip\/([0-9]*)\)/) {
+        $ip{$2} = $1;
+       #print "'$1' '$2' $ip{$2}\n";
+    }
+}
+close EXT;
+
+my %sip = ();  # SIP IP phone status keyed on sip.conf names 
+               # if no entry we can't see IP phone device
+my %voip = (); # SIP trunks status keyed on sip.conf names 
+               # if no entry we can't see SIP trunk
+my %ipad = (); # IP address of SIP device keyed on sip.conf names
+
+open SIP, "sipshowpeers.txt";
+while (<SIP>) { 
+    if (/^([0-9]*)[\s\/].*(OK)/) {
+        $sip{$1} = $2;
+       #print "'$1' '$2' $sip{$1}\n";
+       $e = $1;
+       if (/\s([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s/) {
+           $ipad{$e} = $1;
+           #print "'$1'\n";
+       }
+    }
+    if (/^(voip[0-9]*)[\s\/].*(OK)/) {
+        $voip{$1} = $2;
+       #print "'$1' '$2' $voip{$1}\n";
+       $e = $1;
+       if (/\s([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s/) {
+           $ipad{$e} = $1;
+           #print "'$1'\n";
+       }
+    }
+}
+
+close SIP;
+
+# print list of analog phones
+
+$tooltip_anphone = "onMouseOver=\"popUp(event,'phone_anphone')\" onmouseout=\"popUp(event,'phone_anphone')\"";
+$tooltip_ext = "onMouseOver=\"popUp(event,'phone_ext')\" onmouseout=\"popUp(event,'phone_ext')\"";
+$tooltip_port = "onMouseOver=\"popUp(event,'phone_port_phone')\" onmouseout=\"popUp(event,'phone_port_phone')\"";
+
+foreach $a (sort keys %analog) {
+    if ($zap{$a} eq "fxs") {
+       $icon = "<img src=\"anphone.png\" alt=\"Analog Phone\" />";
+       print "<tr><td $tooltip_ext>$analog{$a}</td><td $tooltip_anphone>Analog Phone</td><td $tooltip_port>Port $a</td><td>$icon</td></tr>\n";
+    }
+}
+
+# print list of IP phones
+
+$tooltip_ipphone = "onMouseOver=\"popUp(event,'phone_ipphone')\" onmouseout=\"popUp(event,'phone_ipphone')\"";
+$tooltip_ipphone_ip = "onMouseOver=\"popUp(event,'phone_ipphone_ip')\" onmouseout=\"popUp(event,'phone_ipphone_ip')\"";
+
+foreach $s (sort keys %sip) {
+    if ($sip{$s} eq "OK") {
+       $icon = "<img src=\"ipphone.png\" alt=\"IP Phone\" />";
+       print "<tr><td $tooltip_ext>$s</td><td $tooltip_ipphone>IP Phone</td<td $tooltip_ipphone_ip>$ipad{$s}</td><td>$icon</td></tr>\n";
+    }
+}
+
+$tool_tip = "onMouseOver=\"popUp(event,'phone_lines')\" onmouseout=\"popUp(event,'phone_lines')\"";
+
+print '<tr><td>&nbsp</td></tr>';
+print "<tr $tool_tip><td colspan=\"4\" align=\"left\" valign=\"top\" ><h2>Phone Lines</h2></td></tr>
+";
+
+# print list of analog phone lines
+
+$tooltip_phoneline = "onMouseOver=\"popUp(event,'phone_phoneline')\" onmouseout=\"popUp(event,'phone_phoneline')\"";
+$tooltip_port = "onMouseOver=\"popUp(event,'phone_port_line')\" onmouseout=\"popUp(event,'phone_port_line')\"";
+
+foreach $a (sort keys %analog) {
+    if ($zap{$a} eq "fxo") {
+       $icon = "<img src=\"phoneline.jpg\" alt=\"Phone Line\" />";
+       print "<tr><td>$analog{$a}</td><td $tooltip_phoneline>Analog</td><td $tooltip_port>Port $a</td><td>$icon</td></tr>\n";
+    }
+}
+
+# print list of SIP VOIP trunks
+
+$tooltip_voipline = "onMouseOver=\"popUp(event,'phone_voipline')\" onmouseout=\"popUp(event,'phone_voipline')\"";
+$tooltip_voipline_ip = "onMouseOver=\"popUp(event,'phone_voipline_ip')\" onmouseout=\"popUp(event,'phone_voipline_ip')\"";
+
+foreach $s (sort keys %voip) {
+    if ($voip{$s} eq "OK") {
+       $icon = "<img src=\"voipline.jpg\" alt=\"VOIP Line\" />";
+       print "<tr><td>$s</td><td $tooltip_voipline>VOIP</td><td $tooltip_voipline_ip>$ipad{$s}</td><td>$icon</td></tr>\n";
+    }
+}
+
diff --git a/easy-asterisk-gui/phones.sh b/easy-asterisk-gui/phones.sh
new file mode 100644 (file)
index 0000000..98bec0c
--- /dev/null
@@ -0,0 +1,89 @@
+#!/bin/sh -x
+# phones.sh
+# David Rowe 4 Jan 2010
+# Phones screen for Easy Asterisk GUI
+
+# See if we have Internet connectivity, first check dns as time outs can be very slow
+
+dns=`cat /etc/resolv.conf | awk '/^nameserver/ {print $2}'`
+dns_packet_loss=`ping $dns -c 1 -q | sed -n 's/.*received, \(.*\)% packet loss/\1/p'`
+internet="no";
+if [ $dns_packet_loss == "0" ]; then
+  packet_loss=`ping google.com -c 1 -q | sed -n 's/.*received, \(.*\)% packet loss/\1/p'`
+  if [ $packet_loss == "0" ]; then
+    internet="yes";
+  fi
+fi
+
+ipaddress=`ifconfig eth0 | sed -n 's/.*inet addr:\(.*\)  Bcast.*/\1/p'`
+
+# Construct the web page -------------------------------
+
+sh check_loggedin.sh
+
+cat <<EOF
+<script src="prototype.js"></script>
+<link href="astman.css" media="all" rel="Stylesheet" type="text/css" />
+<script type="text/javascript" src="tooltip.js"></script>
+<link rel="stylesheet" href="tooltip.css" type="text/css" />
+EOF
+
+echo "<script>"
+echo 'var init_internet="'$internet'";'
+cat phones.js
+echo "</script>"
+
+cat << EOF
+<html>
+<title>Easy Asterisk - Phones</title>
+<body onload="localInit()">
+EOF
+
+cat tooltips.html
+echo '<table align="center" width=800>'
+cat banner.html
+echo "    <tr>"
+cat menu.html    
+cat <<EOF
+
+    <td valign="top">
+
+    <table align="right" width=600>
+      <tr>
+          <td onMouseOver="popUp(event,'phone_system')" onmouseout="popUp(event,'phone_system')" colspan="4" align="left" valign="top"><h2>Phone System</h2></td>
+      </tr>
+      <tr onMouseOver="popUp(event,'network_internet')" onmouseout="popUp(event,'network_internet')">
+         <td colspan="3">Internet Connection:</td>
+         <td><div id="internet" >&nbsp;</div></td>
+      </tr>
+      <tr onMouseOver="popUp(event,'phone_ipaddress')" onmouseout="popUp(event,'phone_ipaddress')">
+         <td colspan="3">Phone System IP Address:</td>
+EOF
+echo "<td>$ipaddress</td>"
+cat <<EOF
+      </tr>
+      <tr><td>&nbsp</td></tr>
+      <tr>
+          <td onMouseOver="popUp(event,'phone_phones')" onmouseout="popUp(event,'phone_phones')" 
+               colspan="3" align="left" valign="top" ><h2>Phones</h2></td>
+         <td onMouseOver="popUp(event,'phone_addipphone')" onmouseout="popUp(event,'phone_addipphone')">
+               <a href="addipphone.sh">Add IP Phone</a></td>
+      </tr>
+EOF
+
+# use perl to construct list of phones and phone lines for us
+asterisk "-rx sip show peers" 2>/dev/null > sipshowpeers.txt
+./phones.pl
+
+cat<<EOF
+    </table>
+
+    </td>
+
+    </tr>
+
+</table>
+</body>
+</html>
+EOF
+
index 6b9963cbaa65d5c5d632b25660c8bec3bbad8002..20d90e12d33dc193a967346ce17091a4a74b63e6 100644 (file)
 
 <div id="phone_addipphone" class="tip">
                         Instructions and help on adding a new IP phone</div>
+
+<div id="ipphones_ipphones" class="tip">
+                        List of possible IP phones.  Choose a free one
+                        (cross) for a new phone.  Refresh this page tp
+                        update</div>
+
+<div id="ipphones_connected" class="tip">
+                        The IP phone is connected to your phone system and ready to use</div>
+
+<div id="ipphones_notconnected" class="tip">
+                        No IP phone is connected.  This could be
+                        because no IP phone is present, or the IP
+                        phone has not been set up.</div>
+