]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blob - cgi-bin/index.py
- the ftp handling module is mostly done (and working) - now need to work
[projects/pld-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=ziew=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     from ftptree import FtpTree
32     import config
33     srctree=FtpTree(config.value['default_to'], loadall=True)
34     wwwiface.addheader('Logged in: '+u.login)
35     wwwiface.addmenu(file='loggedinmenu')
36     wwwiface.addcontent('<form action="index.py" method="post"><table border="1">')
37     wwwiface.addcontent('<tr><td>Mv</td><td>Package</td></tr>\n')
38     pkglist=srctree.keys()
39     pkglist.sort()
40     for pkg in pkglist:
41         wwwiface.addcontent('<tr><td><input type="checkbox"></td><td>'+srctree[pkg].name+'</td></tr>\n')
42     wwwiface.addcontent('<tr><td>&nbsp;</td><td><input type="submit" value="Move"></td></tr>')
43     wwwiface.addcontent('</table></form>')
44 else:
45     wwwiface.addheader('Login form')
46     wwwiface.addcontent(file='regform')
47
48 wwwiface.sendhttpheaders()
49 contenttypesent=True
50
51 wwwiface.sendhtml()
52
This page took 0.029938 seconds and 3 git commands to generate.