예제 #1
0
def main():
    cookies = find_cookeis()
    # print()
    if (len(cookies) > 1):

        #print("username: "******"password: "******"username") == secret.username
                    and form.getvalue("password") == secret.password):
                print("Set-Cookie:username = "******"username") +
                      ";")
                print("Set-Cookie:password = "******"password") +
                      ";")
                print('Content-Type: text/html')
                print()
                print(templates.secret_page(secret.username, secret.password))
                # print('''<!doctype html>
                # <html>
                # <body>''')
                # print("<b>"+"Logged in as: " + form.getvalue("username")+"</b>")
                # print('''<ul> ''')
                # print("<li> <b>"+"username : "******"username")) + "</b> </li>")
                # print("<li> <b>"+"password: "******"password")) + "</b> </li>")

                # print('''</ul> ''')
                # print("<b>refresh page to see if the cookies work. i sent them to the template page!</b>")
                # print('''
                # </body>
                # </html>''')
            else:
                print('Content-Type: text/html')
                print()
                print(templates.after_login_incorrect())
예제 #2
0
password = s.getfirst('password')
#print(username, password)

form_ok = username == secret.username and password == secret.password
c = SimpleCookie(os.environ['HTTP_COOKIE'])
c_username = None
c_password = None
if c.get("username"):
    c_username = c.get('username').value
if c.get("password"):
    c_password = c.get('password').value

cookie_ok = c_username == secret.username and c_password == secret.password

if cookie_ok:
    username = c_username
    password = c_password

if form_ok:
    print("Set-Cookie: username="******"set-Cookie: password=", password)

print()

if not username and not password:
    print(login_page())
elif username == secret.username and password == secret.password:
    print(secret_page(username, password))
else:
    print(after_login_incorrect())
예제 #3
0
    if 'username' in cookie:
        username = cookie.split('=')[1]
    elif "password" in cookie:
        password = cookie.split('=')[1]

if username and password:
    print(templates.secret_page(username, password))

elif os.environ.get("REQUEST_METHOD", "GET") == "POST":   # no cookies was set
    form = cgi.FieldStorage()

    if "username" not in form or "password" not in form:
        print("<H2>Error</H2>")
        print("Please fill in the  name and addr fields.")
    else:
        username = form["username"].value
        password = form["password"].value
        print("<p>")
        print("username:"******"username"].value)
        print("password:"******"password"].value)
        print("</p>")

        if username == secret.username and password == secret.password:
            # correct login, set cookie
            print("Set-Cookie: username={};".format(username))
            print("Set-Cookie: password={};".format(password))
            print(templates.secret_page(username, password))
        else:
            print(templates.after_login_incorrect())
else:
    print(templates.login_page(), end="\n\n")