-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfcgi.lua
60 lines (41 loc) · 1.33 KB
/
fcgi.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require( "inc.config" )
require( "inc.json" )
require( "inc.template" )
require( "inc.utils" )
local function parseQuery( str )
if not str then
return { }
end
local tokens = { }
str:gsub( "([^&]+)&?", function( token )
local idx = token:find( "=" )
if idx ~= nil then
tokens[ token:sub( 0, idx - 1 ) ] = token:sub( idx + 1 )
else
tokens[ token ] = ""
end
end )
return tokens
end
math.randomseed( os.time() )
Monsters, MonstersJSON = data( "monsters" )
Weapons, WeaponsJSON = data( "weapons" )
Guns, GunsJSON = data( "guns" )
Armors, ArmorsJSON = data( "armors" )
Decorations, DecorationsJSON = data( "decorations" )
Items, ItemsJSON = data( "items" )
Skills, SkillsJSON = data( "skills" )
Shots, ShotsJSON = data( "shots" )
Tips = data( "tips" )
Posts = data( "posts" )
LastModified = data( "modified" )
function FCGI_Accept( postString )
print( "Content-Type: text/html; charset=utf-8\r\n\r\n" )
Get = parseQuery( os.getenv( "QUERY_STRING" ) )
Post = parseQuery( postString )
IsLocalHost = os.getenv( "SERVER_NAME" ) == "localhost"
CurrentUrl = os.getenv( "REQUEST_URI" ):sub( BaseUrl:len() + 2 )
-- the server should always be passing us a legit request
-- so don't bother checking
dofile( os.getenv( "SCRIPT_FILENAME" ) )
end