first pass session support, needs to be improved
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 4 Jan 2010 06:09:13 +0000 (06:09 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 4 Jan 2010 06:09:13 +0000 (06:09 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@90 01035d8c-6547-0410-b346-abe4f91aad63

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

index b4afbb61e36a1e2b4c55ece8c8589e78bf34917f..45912145971774d718f225fa648bb3e51ecdae3a 100644 (file)
@@ -9,4 +9,4 @@ TESTIP=192.168.1.150
 #      rcp index.html root@$(TESTIP):/var/lib/asterisk/static-http/
 
 test:
-       rcp login.sh dashboard.sh network.sh network.js set_network.sh tooltip.js tooltip.css root@$(TESTIP):/www/cgi-bin
+       rcp logout.sh login.sh dashboard.sh dashboard.js network.sh network.js set_network.sh tooltip.js tooltip.css root@$(TESTIP):/www/cgi-bin
diff --git a/easy-asterisk-gui/dashboard.js b/easy-asterisk-gui/dashboard.js
new file mode 100644 (file)
index 0000000..de163c2
--- /dev/null
@@ -0,0 +1,4 @@
+function localInit() {
+    $('internet').innerHTML = init_internet;    
+}
+
index ea2c4d2dc77fcf46ec99bafac56f7f0d26e3b5d9..a791856e43c3d751e0eff5d4564769a4668eb7c6 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/sh -x
 # dashboard.sh
 # David Rowe 4 Jan 2010
 # CGI for Easy Asterisk dashboard GUI
@@ -14,6 +14,16 @@ fi
 
 # Construct the web page -------------------------------
 
+echo $HTTP_COOKIE | grep "loggedin" > /dev/null
+if [ $? -eq 1 ]; then
+    echo "<html>"
+    echo "<head>"
+    echo '<meta http-equiv="REFRESH" content="0;url=http:login.sh">'
+    echo "</head>"
+    echo "</html>"
+    exit
+fi
+
 cat <<EOF
 <script src="prototype.js"></script>
 <link href="astman.css" media="all" rel="Stylesheet" type="text/css" />
@@ -23,7 +33,7 @@ EOF
 
 echo "<script>"
 echo 'var init_internet="'$internet'";'
-cat network.js
+cat dashboard.js
 echo "</script>"
 
 cat << EOF
@@ -44,6 +54,11 @@ cat << EOF
 </tr>
 </table>
 </form>
+EOF
+
+echo $HTTP_COOKIE
+cat<<EOF
+</body>
 </html>
 EOF
 
index 430216731a75f80aca8d3d30f1b8108e43eeab6d..afe42e3fca30782b0adc351e6831dc5cbd5c1409 100644 (file)
@@ -37,17 +37,16 @@ else
     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
+        echo "Content-type: text/html"
+        echo "Set-Cookie: loggedin=1"
+        echo ""
+       echo "<head>"
+       echo "<title>Easy Asterisk - Login</title>"
+       echo '<meta http-equiv="REFRESH" content="0;url=http:dashboard.sh">'
+       echo "<body>"
+       echo "Please wait a few seconds....."
+       echo "</body>"
+       echo "</head>"
     else
        # login failed
        cat <<EOF
diff --git a/easy-asterisk-gui/logout.sh b/easy-asterisk-gui/logout.sh
new file mode 100644 (file)
index 0000000..9359031
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+# logout.sh
+# David Rowe 4 Jan 2010
+# CGI for Easy Asterisk logout GUI
+
+cat <<EOF
+Content-type: text/html
+Set-Cookie: loggedin=1; expires=Thursday, 01-Jan-98 12:00:00 GMT
+
+<title>Easy Asterisk - Logout</title>
+EOF
+echo $HTTP_COOKIE