]> git.pld-linux.org Git - projects/pld-ftp-admin.git/commitdiff
- wwwiface shows pkgs taken from ftpiod
authorMariusz Mazur <mmazur@pld-linux.org>
Sun, 16 Jan 2005 19:59:01 +0000 (19:59 +0000)
committerMariusz Mazur <mmazur@pld-linux.org>
Sun, 16 Jan 2005 19:59:01 +0000 (19:59 +0000)
Changed files:
    modules/cmds.py -> 1.8
    modules/ftpio.py -> 1.6
    modules/wwwcmds.py -> 1.2

modules/cmds.py
modules/ftpio.py
modules/wwwcmds.py

index 10e3072f4a58b3e5c3c87c61de80052870e07b61..ec19b1719c37f37ae6477ebd3ced27cc1142013f 100644 (file)
@@ -5,6 +5,7 @@ import time
 import config
 import common
 import md5
+import ftptree
 
 
 def parse(con):
@@ -15,7 +16,7 @@ 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:
@@ -105,6 +106,7 @@ def cmd_login_passwd(con, data):
         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:
@@ -116,6 +118,7 @@ def cmd_login_cookie(con, cookie):
     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)
@@ -125,13 +128,31 @@ def cmd_logout(con):
     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
 
@@ -139,5 +160,6 @@ BailOut="BailOut"
 locks={}
 logfile=open(common.ftpadmdir+'var/log', 'a')
 load_creds()
+reloadftptree()
 salt=md5.new(`time.time()`).hexdigest()
 
index 35dc1b0753d97cc5460e52ca1a260a96e4a9f91c..1adf490a3444226390e3cab1d1d0eac51ef35a21 100644 (file)
@@ -64,6 +64,12 @@ def unlock(path):
 def log(msg):
     sock.send('log1 %s\0' % msg)
 
-def name(newname):
-    sock.send('name %s\0' % newname)
+def gettree():
+    sock.send('gett\0')
+    pkgs=[]
+    len=int(sock.recv(6))
+    if len:
+        for pkg in sock.recv(len).split('\n'):
+            pkgs.append(pkg)
+    return pkgs
 
index 8425474c6a8f52e764c1f049832bf2579c2dda31..831d06fc0d803642b1cf66becab073804fefe585 100644 (file)
@@ -1,13 +1,18 @@
 # 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>&nbsp;</td><td><input type="submit" value="Move"></td></tr>')
+        wwwiface.addcontent('</table></form>')
 
 
 actions={}
This page took 0.04205 seconds and 4 git commands to generate.