summaryrefslogtreecommitdiffhomepage
path: root/applications/sgi-haserl
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-05-08 15:37:41 +0000
committerSteven Barth <steven@midlink.org>2008-05-08 15:37:41 +0000
commitaa9ccf77c6648515ba58c37b9345cdbd561028db (patch)
treeb0270202d47b6c5e179f8475302bb3ef0d1c9402 /applications/sgi-haserl
parenta3a51464fd8cffa6d18fa3f18be9c699901abd0d (diff)
* Mördercommit ;-)
* Major Repository Reorganisation * API 0.4 Softfreeze to come
Diffstat (limited to 'applications/sgi-haserl')
-rw-r--r--applications/sgi-haserl/Makefile2
-rwxr-xr-xapplications/sgi-haserl/root/www/cgi-bin/ffluci4
-rwxr-xr-xapplications/sgi-haserl/root/www/cgi-bin/ffluci-upload4
-rwxr-xr-xapplications/sgi-haserl/root/www/cgi-bin/index.cgi3
-rw-r--r--applications/sgi-haserl/root/www/index.html10
-rw-r--r--applications/sgi-haserl/src/sgi/haserl.lua76
6 files changed, 99 insertions, 0 deletions
diff --git a/applications/sgi-haserl/Makefile b/applications/sgi-haserl/Makefile
new file mode 100644
index 000000000..81a96f6a8
--- /dev/null
+++ b/applications/sgi-haserl/Makefile
@@ -0,0 +1,2 @@
+include ../../build/config.mk
+include ../../build/module.mk \ No newline at end of file
diff --git a/applications/sgi-haserl/root/www/cgi-bin/ffluci b/applications/sgi-haserl/root/www/cgi-bin/ffluci
new file mode 100755
index 000000000..183a6ad41
--- /dev/null
+++ b/applications/sgi-haserl/root/www/cgi-bin/ffluci
@@ -0,0 +1,4 @@
+#!/usr/bin/haserl --shell=luac
+package.path = "/usr/lib/lua/?.lua;/usr/lib/lua/?/init.lua;" .. package.path
+package.cpath = "/usr/lib/lua/?.so;" .. package.cpath
+require("ffluci.dispatcher").httpdispatch() \ No newline at end of file
diff --git a/applications/sgi-haserl/root/www/cgi-bin/ffluci-upload b/applications/sgi-haserl/root/www/cgi-bin/ffluci-upload
new file mode 100755
index 000000000..0128c2dd7
--- /dev/null
+++ b/applications/sgi-haserl/root/www/cgi-bin/ffluci-upload
@@ -0,0 +1,4 @@
+#!/usr/bin/haserl --shell=luac --upload-limit=6144
+-- This is a bit hacky: remove -upload from SCRIPT_NAME
+ENV.SCRIPT_NAME = ENV.SCRIPT_NAME:sub(1, #ENV.SCRIPT_NAME - 7)
+dofile("ffluci") \ No newline at end of file
diff --git a/applications/sgi-haserl/root/www/cgi-bin/index.cgi b/applications/sgi-haserl/root/www/cgi-bin/index.cgi
new file mode 100755
index 000000000..31705ccf2
--- /dev/null
+++ b/applications/sgi-haserl/root/www/cgi-bin/index.cgi
@@ -0,0 +1,3 @@
+#!/usr/bin/haserl --shell=luac
+print("Status: 302 Found")
+print("Location: ffluci\n")
diff --git a/applications/sgi-haserl/root/www/index.html b/applications/sgi-haserl/root/www/index.html
new file mode 100644
index 000000000..58387a5fe
--- /dev/null
+++ b/applications/sgi-haserl/root/www/index.html
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="refresh" content="0; URL=/cgi-bin/index.cgi" />
+</head>
+<body style="background-color: black">
+<a style="color: white; text-decoration: none" href="/cgi-bin/index.cgi">FFLuCI - Freifunk Lua Configuration Interface</a>
+</body>
+</html> \ No newline at end of file
diff --git a/applications/sgi-haserl/src/sgi/haserl.lua b/applications/sgi-haserl/src/sgi/haserl.lua
new file mode 100644
index 000000000..027697e2e
--- /dev/null
+++ b/applications/sgi-haserl/src/sgi/haserl.lua
@@ -0,0 +1,76 @@
+--[[
+FFLuCI - SGI-Module for Haserl
+
+Description:
+Server Gateway Interface for Haserl
+
+FileId:
+$Id: haserl.lua 2027 2008-05-07 21:16:35Z Cyrus $
+
+License:
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+]]--
+module("ffluci.sgi.haserl", package.seeall)
+
+-- Environment Table
+ffluci.http.env = ENV
+
+
+-- Returns a table of all COOKIE, GET and POST Parameters
+function ffluci.http.formvalues()
+ return FORM
+end
+
+-- Gets form value from key
+function ffluci.http.formvalue(key, default)
+ local c = ffluci.http.formvalues()
+
+ for match in key:gmatch("[%w-_]+") do
+ c = c[match]
+ if c == nil then
+ return default
+ end
+ end
+
+ return c
+end
+
+-- Gets a table of values with a certain prefix
+function ffluci.http.formvaluetable(prefix)
+ return ffluci.http.formvalue(prefix, {})
+end
+
+-- Sends a custom HTTP-Header
+function ffluci.http.header(key, value)
+ print(key .. ": " .. value)
+end
+
+-- Set Content-Type
+function ffluci.http.prepare_content(type)
+ print("Content-Type: "..type.."\n")
+end
+
+-- Asks the browser to redirect to "url"
+function ffluci.http.redirect(url)
+ ffluci.http.status(302, "Found")
+ ffluci.http.header("Location", url)
+ print()
+end
+
+-- Sets HTTP-Status-Header
+function ffluci.http.status(code, message)
+ print("Status: " .. tostring(code) .. " " .. message)
+end