# rcp index.html root@$(TESTIP):/var/lib/asterisk/static-http/
test:
- rcp network.sh network.js set_network.sh tooltip.js tooltip.css root@$(TESTIP):/www/cgi-bin
+ rcp login.sh dashboard.sh network.sh network.js set_network.sh tooltip.js tooltip.css root@$(TESTIP):/www/cgi-bin
--- /dev/null
+#!/bin/sh
+# dashboard.sh
+# David Rowe 4 Jan 2010
+# CGI for Easy Asterisk dashboard GUI
+
+# See if we have Internet connectivity
+
+packet_loss=`ping google.com -c 1 -q | sed -n 's/.*received, \(.*\)% packet loss/\1/p'`
+if [ $packet_loss == "0" ]; then
+ internet="Good";
+else
+ internet="Not Available";
+fi
+
+# Construct the web page -------------------------------
+
+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 network.js
+echo "</script>"
+
+cat << EOF
+<html>
+<title>Easy Asterisk - Dashboard</title>
+<body onload="localInit()">
+<div id="t1" class="tip">Tells you if I can reach the Internet. If not "Good" check your network settings, in particular Gateway and DNS.</div>
+<form action="/cgi-bin/set_network.sh" onsubmit="return validate_form(this)" method="get">
+<table align="center" width=600>
+<tr>
+ <tr><td colspan="2" align="left"><h2>Dashboard</h2></td>
+ <tr onMouseOver="popUp(event,'t1')" onmouseout="popUp(event,'t1')">
+ <td>Internet Connection:</td>
+ <td><div id="internet" >
+ <span style="margin-left: 4px;font-weight:bold"> </span></div></td>
+
+ </tr>
+</tr>
+</table>
+</form>
+</html>
+EOF
+
--- /dev/null
+#!/bin/sh
+# login.sh
+# David Rowe 4 Jan 2010
+# CGI for Easy Asterisk login GUI
+
+user=`echo "$QUERY_STRING" | grep -oe "user=[^&?]*" | sed -n "s/user=//p"`
+pass=`echo "$QUERY_STRING" | grep -oe "pass=[^&?]*" | sed -n "s/pass=//p"`
+
+echo $QUERY_STRING | grep user > /dev/null
+if [ $? -eq 1 ]; then
+ # Display form -------------------------------
+
+ 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
+ cat << EOF
+ <html>
+ <title>Easy Asterisk - Login</title>
+ <form action="/cgi-bin/login.sh" method="get">
+ <table align="center" width=600>
+ <tr><td colspan="2" align="left"><h2>Login</h2></td>
+ <tr>
+ <tr><td>User:</td><td><input type="text" name="user" ></td></tr>
+ <tr><td>Password:</td><td><input type="text" name="pass" ></td></tr>
+ <tr><td><input type="submit" value="Login"></td></tr>
+ </tr>
+ <tr><td></td><td>Default is root/uClinux</td>
+ </table>
+ </form>
+ </html>
+EOF
+else
+ testuser $user $pass
+ if [ $? -eq 0 ]; then
+
+ # login sucessful
+ cat <<EOF
+ <html>
+ <head>
+ <title>Easy Asterisk - Login</title>
+ <meta http-equiv="REFRESH" content="0;url=http:dashboard.sh">
+ <body>
+ Please wait a few seconds.....
+ </body>
+ </head>
+ </html>
+EOF
+ else
+ # login failed
+ cat <<EOF
+ <html>
+ <head>
+ <title>Easy Asterisk - Login</title>
+ <meta http-equiv="REFRESH" content="0;url=http:login.sh">
+ <body>
+ Please wait a few seconds.....
+ </body>
+ </head>
+ </html>
+EOF
+ fi
+fi
+
#!/bin/sh
# network.sh
# David Rowe 4 Jan 2010
-# CGI for network GUI
+# CGI for Easy Asterisk network GUI
echo `date` " get_network.sh" >> /tmp/easy_gui.log
cat << EOF
<html>
-<title>Network</title>
+<title>Easy Asterisk - Network</title>
<body onload="localInit()">
<div id="t1" class="tip">Tells you if I can reach the Internet. If not "Good" check your network settings, in particular Gateway and DNS.</div>
<form action="/cgi-bin/set_network.sh" onsubmit="return validate_form(this)" method="get">
<table align="center" width=600>
<tr>
- <tr><td colspan="2" align="left"><h2>Easy Asterisk - Network</h2></td>
+ <tr><td colspan="2" align="left"><h2>Network</h2></td>
<tr>
<td><input type="radio" id="static" name="dhcp" value="no" onClick="doStatic()">Static</td>
<td><input type="radio" id="dhcp" name="dhcp" value="yes" onClick="doDHCP()">DHCP</td>
</html>
EOF
-#<td><input type="text" name="internet" id="internet" disabled=1 onMouseOver="popUp(event,'t1')" ></td></tr>
</html>
EOF
-dhcp=`echo "$QUERY_STRING" | grep -oe "dhcp=[^&]*" | sed -n "s/dhcp=//p"`
-ipaddress=`echo "$QUERY_STRING" | grep -oe "ipaddress=[^&]*" | sed -n "s/ipaddress=//p"`
-netmask=`echo "$QUERY_STRING" | grep -oe "netmask=[^&]*" | sed -n "s/netmask=//p"`
-gateway=`echo "$QUERY_STRING" | grep -oe "gateway=[^&]*" | sed -n "s/gateway=//p"`
-dns=`echo "$QUERY_STRING" | grep -oe "dns=[^&]*" | sed -n "s/dns=//p"`
+dhcp=`echo "$QUERY_STRING" | grep -oe "dhcp=[^&?]*" | sed -n "s/dhcp=//p"`
+ipaddress=`echo "$QUERY_STRING" | grep -oe "ipaddress=[^&?]*" | sed -n "s/ipaddress=//p"`
+netmask=`echo "$QUERY_STRING" | grep -oe "netmask=[^&?]*" | sed -n "s/netmask=//p"`
+gateway=`echo "$QUERY_STRING" | grep -oe "gateway=[^&?]*" | sed -n "s/gateway=//p"`
+dns=`echo "$QUERY_STRING" | grep -oe "dns=[^&?]*" | sed -n "s/dns=//p"`
echo `date` " set_network.sh $dhcp $ipaddress $netmask $gateway $dns" >> /tmp/easy_gui.log