def check_logged_in(): rval = [] try: wrapdb.connect() cookie = Cookie.SimpleCookie(os.environ["HTTP_COOKIE"]) if ('user' in cookie) and ('pass' in cookie): user = cookie['user'].value password = cookie['pass'].value if user and password: doublecheck_user(user) doublecheck_pass(password) if wrapdb.user_check_creds(user, hashlib.sha1(password).hexdigest()): rval = [user, password] except (Cookie.CookieError, KeyError): rval = [] wrapdb.disconnect() return rval
import cgi if ('HTTP_HOST' in os.environ) and (os.environ['HTTP_HOST'] == 'localhost'): import cgitb cgitb.enable() page = common.PageLayout('index.py') page.startPage() wrapdb.connect() data = wrapdb.posts_get_latest() print '<br>' fields = {'display_title':'Latest Crackmes', \ 'title':1, \ 'author':1, \ 'date_posted':1, \ 'date_activity':1, \ 'num_replies':1, \ 'score':1, \ 'num_votes':1, \ 'downloads':1, \ 'solver':1 } common.posts_display(data, fields) wrapdb.disconnect() page.endPage()