diff --git a/orig/README b/orig/README new file mode 100644 index 0000000..6bd8070 --- /dev/null +++ b/orig/README @@ -0,0 +1,23 @@ +This is the source code for the Lua live demo that is available at + http://www.lua.org/cgi-bin/demo + +It has three parts: + demo the CGI script + demo.html the HTML page + demo.lua the Lua program that runs user programs + +The CGI script is a sh script that handles both GET and POST requests. +Empty GET requests return demo.html, which is what you see when you +visit the URL above. Nonempty GET requests fill the text box with one of +the demo programs listed in demo.html. Lua programs in the text box are +run in reply to POST requests via a stock Lua interpreter. + +An important concern of the CGI script is security. Pains are taken to avoid +executing scripts outside the cgi-bin directory and to avoid consuming too +much time or memory when runnning user programs. + +The Lua program reads and parses the POST input and runs user programs in +a constrained environment, again for security. + +This code is hereby placed in the public domain. +Please send comments, suggestions, and bug reports to lhf@tecgraf.puc-rio.br . diff --git a/orig/demo b/orig/demo new file mode 100755 index 0000000..2d62386 --- /dev/null +++ b/orig/demo @@ -0,0 +1,46 @@ +#!/bin/sh + +LUA=/home/lhf/websites/lua.org/www/bin/lua +LOG=log +ECHO="/bin/echo -E" + +cat <> $LOG +if [ "$REQUEST_METHOD" = "GET" ] +then + if [ "$QUERY_STRING" = "" ] + then + exec cat demo.html + else + $ECHO "$QUERY_STRING" >> $LOG + F=`basename -- "$QUERY_STRING"`.lua + sed '/TEXTAREA/q' demo.html + $ECHO "-- $F" + (cat -- "$F" 2>&1) + sed '1,/TEXTAREA/d' demo.html + fi +else + sed '/TEXTAREA/q' demo.html + tee -a $LOG | (ulimit -t 1 ; $LUA demo.lua 2>&1 | head -c 8k) + cat <

+Your program was aborted. +

+ +


+ +EOF + $LUA -v 2>&1 + cat < + + + +EOF + echo '' >> $LOG +fi diff --git a/orig/demo.html b/orig/demo.html new file mode 100644 index 0000000..6fa0253 --- /dev/null +++ b/orig/demo.html @@ -0,0 +1,54 @@ + + + +Lua: demo + + + + + + + + +
+

+Lua +Demo +

+ +Try Lua before +downloading it. +Enter your Lua program +or +choose one of the demo programs below. +

+ helloglobalsbisectsieveaccount +

+ +

+ + + +

+

+ +


+ +Last update: +Wed Mar 19 17:01:42 GMT 2008 + + + + + diff --git a/orig/demo.lua b/orig/demo.lua new file mode 100644 index 0000000..3f21c12 --- /dev/null +++ b/orig/demo.lua @@ -0,0 +1,56 @@ +local T,E,I +T=io.read"*a" +T=string.match(T,"=(.-)$") or "" +T=string.gsub(T,"+"," ") +T=string.gsub(T,"%%(%x%x)",function (x) return string.char(tonumber(x,16)) end) +T=string.gsub(T,"^%s*=%s*","return ") + +local write=io.write + +write(T) +write[[ +

+ + + + +

+ +

Output

+

]] +write('\n') +write("Your program ",E,".") +write("