]> TLD Linux GIT Repositories - tld-ftp-admin.git/blob - cgi-bin/index.py
- raw from PLD
[tld-ftp-admin.git] / cgi-bin / index.py
1 #!/usr/bin/env python
2 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
3
4 # Printing errors (no SyntaxErrors though, but that's not a problem)
5 import sys, os
6 sys.stderr=sys.stdout
7
8 contenttypesent=False
9
10 def myexceptionhandler(type, value, traceback):
11     if contenttypesent:
12         print '<pre>'
13         sys.__excepthook__(type, value, traceback)
14         print '</pre>'
15     else:
16         print "Content-Type: text/plain\n"
17         sys.__excepthook__(type, value, traceback)
18     sys.exit(1)
19
20 sys.excepthook=myexceptionhandler
21 # End printing errors
22
23 sys.path.insert(0, '../modules')
24
25 import wwwiface, user
26
27 opts, cks = wwwiface.getopts()
28 u=user.User(cks, opts)
29
30 if u.loggedin:
31     wwwiface.addheader('Logged in: '+u.login)
32     wwwiface.addmenu(file='loggedinmenu')
33     import wwwcmds
34     wwwcmds.handlecmds(opts)
35 else:
36     wwwiface.addheader('Login form')
37     wwwiface.addcontent(file='regform')
38
39 wwwiface.sendhttpheaders()
40 contenttypesent=True
41
42 wwwiface.sendhtml()
43