import config
import common
import md5
+import ftptree
def parse(con):
for cmd in cmds:
con.data=con.data[len(cmd)+1:]
cmdname=cmd[:4]
- if not con.authorized and not (cmdname=='linp' or cmdname=='linc'):
+ if not con.authorized and cmdname not in ('linp', 'linc', 'name'):
raise BailOut
# TODO: log unauthorized access
if cmdname in cmdlist_noargs:
cookie=`time.time()`.split('.')[0]+'_'+md5.new(md5pass+salt).hexdigest()
cookies[cookie]=login
write_cookies()
+ con.username=login
con.authorized=True
con.sock.send('OK '+cookie)
else:
if cookie in cookies:
con.cookie=cookie
con.authorized=True
+ con.username=cookies[cookie]
con.sock.send('OK '+cookies[cookie])
else:
# TODO: log this (or not)
if con.cookie in cookies:
del cookies[con.cookie]
write_cookies()
- pass
+
+def reloadftptree():
+ global srctree, pkglist
+ srctree=ftptree.FtpTree(config.value['default_to'], loadall=True)
+ pkglist=srctree.keys()
+ pkglist.sort()
+
+def cmd_gettree(con):
+ buf=''
+ for pkg in pkglist:
+ # TODO: show only user's own pkgs
+ # TODO: show if already marked
+ buf=buf+'\n'+pkg
+ if buf:
+ con.sock.send('%.6d' % (len(buf)-1))
+ con.sock.send(buf[1:])
+ else:
+ con.sock.send('000000')
+
cmdlist_args={'lcks':cmd_lock_soft, 'lckh':cmd_lock_hard, 'ulck':cmd_unlock,
'log1':cmd_log, 'name':cmd_name, 'linp':cmd_login_passwd,
'linc':cmd_login_cookie}
-cmdlist_noargs={'lout':cmd_logout}
+cmdlist_noargs={'lout':cmd_logout, 'gett':cmd_gettree}
# Global stuff and initializations
locks={}
logfile=open(common.ftpadmdir+'var/log', 'a')
load_creds()
+reloadftptree()
salt=md5.new(`time.time()`).hexdigest()
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-import wwwiface
+import wwwiface, ftpio
def handlecmds(options):
if 'action' in options and options['action'] in actions:
pass
else:
- pass
+ wwwiface.addcontent('<form action="index.py" method="post"><table border="1">')
+ wwwiface.addcontent('<tr><td>Mv</td><td>Package</td></tr>\n')
+ for pkg in ftpio.gettree():
+ wwwiface.addcontent('<tr><td><input type="checkbox"></td><td>'+pkg+'</td></tr>\n')
+ wwwiface.addcontent('<tr><td> </td><td><input type="submit" value="Move"></td></tr>')
+ wwwiface.addcontent('</table></form>')
actions={}