first pass at login screen
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 4 Jan 2010 03:58:01 +0000 (03:58 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 4 Jan 2010 03:58:01 +0000 (03:58 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@89 01035d8c-6547-0410-b346-abe4f91aad63

easy-asterisk-gui/Makefile
easy-asterisk-gui/dashboard.sh [new file with mode: 0644]
easy-asterisk-gui/login.sh [new file with mode: 0644]
easy-asterisk-gui/network.sh
easy-asterisk-gui/set_network.sh

index d407d0ff050f59031a19f66f2ce8ceb6f6c6c905..b4afbb61e36a1e2b4c55ece8c8589e78bf34917f 100644 (file)
@@ -9,4 +9,4 @@ TESTIP=192.168.1.150
 #      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
diff --git a/easy-asterisk-gui/dashboard.sh b/easy-asterisk-gui/dashboard.sh
new file mode 100644 (file)
index 0000000..ea2c4d2
--- /dev/null
@@ -0,0 +1,49 @@
+#!/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">&nbsp;</span></div></td>
+      
+  </tr>
+</tr>
+</table>
+</form>
+</html>
+EOF
+
diff --git a/easy-asterisk-gui/login.sh b/easy-asterisk-gui/login.sh
new file mode 100644 (file)
index 0000000..4302167
--- /dev/null
@@ -0,0 +1,66 @@
+#!/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
+
index 46a606e03288e23b94ca1f65274e97d359405bb3..771cd8dcf47fe567bf5ba7a70eec54b033079268 100644 (file)
@@ -1,7 +1,7 @@
 #!/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
 
@@ -52,13 +52,13 @@ echo "</script>"
 
 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>
@@ -80,4 +80,3 @@ cat << EOF
 </html>
 EOF
 
-#<td><input type="text" name="internet" id="internet" disabled=1 onMouseOver="popUp(event,'t1')" ></td></tr>
index 5222625e5aea087a4c0238aa3f0faf368fb51d3d..7ad68c6eb69ae86609eb218d906ae5a7cefda203 100755 (executable)
@@ -15,11 +15,11 @@ Please wait a few seconds.....
 </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