summaryrefslogtreecommitdiff
path: root/cgi-bin/nest.py
blob: 24838f1d42d16516a586504eb9f31b86b5ea7e92 (plain)
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
#!/usr/bin/python
# -*- coding: utf8 -*-

import cgi, cgitb, re, display, config

print ("Content-Type: text/html")
print ("")
# Enable CGI debugging
cgitb.enable()

query = cgi.FieldStorage()
param = query.getvalue("f")
page = query.getvalue("p")

print ("<!DOCTYPE html>")
print ("<html>")
print ("<head>")
print ("<meta charset=\"UTF-8\">")
print ("<title>HnĂ­zdo</title>")
print ("<link rel=\"stylesheet\" type=\"text/css\" href=\""+config.root+"style/style.css\">")
print ("<link rel="shortcut icon" href="style/favicon.ico" type="image/x-icon">")
print ("</head>")
print ("<body>")

if param == "latest":
    body=display.Body("latest", "")
if param == "index":
    if re.match("^[0-9]+$", str(page)):
        body=display.Body("index", str(page))
    else:
        body=display.Body("index", "0")
elif re.match("^20[0-9]{2}(0[0-9]|1[1-2])([0-2][0-9]|3[0-1])(0[0-9]|1[0-9]|2[0-3])([0-5][0-9])$", str(param)):
	body=display.Body(param, "")
else:
    body=display.Body("latest", "")

body.page()

print("</body>")
print("</html>")