0117198cfb3e668bc5ae5ab5078dcd79c6e3afe6
[project/luci.git] / contrib / package / luci-splash / src / luci_splash / htdocs / cgi-bin / index.cgi
1 #!/usr/bin/haserl --shell=luac
2 dofile("/usr/lib/luci_splash")
3
4 require("ffluci.template")
5
6 function dispatch()
7         local mac = get_usermac()
8         if not mac then
9                 return action_nodata()
10         end
11         
12         if isblacklisted(mac) then
13                 return action_blocked()
14         end
15         
16         if iswhitelisted(mac) or haslease(mac) then
17                 return action_allowed()
18         end
19
20         return action_splash(mac)
21 end
22
23 function action_splash(mac)
24         if ffluci.http.formvalue("activate") then
25                 add_lease(mac)
26                 ffluci.http.textheader()
27                 print("Got splashed!")
28         else
29                 ffluci.http.textheader()
30                 print("Get splashed!")
31         end
32 end
33
34 function action_allowed()
35         ffluci.http.textheader()
36         print("Already allowed!")
37 end
38
39 function action_blocked()
40         ffluci.http.textheader()
41         print("Blocked!")
42 end
43
44 function action_nodata()
45         ffluci.http.textheader()
46         print("No data!")
47 end
48
49 dispatch()