def AdminLogin(req,onlyhead):
global currentcookie
passwd = req.query.get('passwd',[''])[0]
salt = Config.conf['AdministratorPassword'][:2]
passwd = crypt.crypt(passwd,salt)
if passwd != Config.conf['AdministratorPassword']:
return Delegate('/errors/wrongpasswd.html',req,onlyhead)
random.seed(os.urandom(200));
currentcookie = str(random.getrandbits(200))
handler = EH_Generic_class()
handler.iamadmin = 1
(header,content) = Site['/adminmenu.html'].getresult(req,onlyhead,handler)
header['Set-Cookie'] = 'OKUSON='+currentcookie+ \
';Path=/;Max-Age=3600;Version=1'
# Max-Age is one hour
#header['Location'] = '/adminmenu.html'
# Taken out to please opera, which does not get the cookie for the
# login with this header. Max.
return (header,content)
评论列表
文章目录