import os import re def DisplayLogin(): print 'Content-Type: text/html\n' print '' print """
""" print '' exit(0) def PrintMessages(): print 'Content-Type: text/html\n' print '' with open("messages", "r") as m_file: s = m_file.read() l = s.split('\n') for i in l: if len(i) == 0: continue i.replace('\\n','\n') print i print '

' print """

Message:

""" print """
""" print '' def ShowError(): print 'Content-Type: text/html\n' print '' print '

Error ocured :P

' print '' exit(0) def Login(): cookie_string = os.environ.get('HTTP_COOKIE') # for reading cookies g = re.search('session_id=(\w+)', cookie_string) # if g==None -- no cookie if not g: return False with open('sessions', 'r') as s_file: s = s_file.read() sid = g.group(1) g = re.search(sid + ' ' + '(\w+)', s) if not g: return False return g.group(1) def RedirectToBoard(): #go back to board.py print 'Content-Type: text/html\n' print '' exit(0) def RemoveAllUserSessions(user): tmp = '' f = open('sessions', 'r') for line in f: if user not in line: tmp += line f.close() with open('sessions','w') as f: f.write(tmp)