def table_body(content, loggedIn):
    print """                <tr>
                    <th><a href="%s">%s</a></th>"""%(redirect.getQualifiedURL("viewer_order.py?vidid=%s"%content[0]) if loggedIn in (1, 2) else redirect.getQualifiedURL("login.py"), content[1])
    for item in content[2:5]:
        print"                    <td>%s</td>"%item
    print"""<td><a href="%s">%s</a></td>"""%(redirect.getQualifiedURL("view_player_details.py?playerID=%s"%content[6]), content[5])
    print"""<td><a href="%s">%s</a></td>"""%(redirect.getQualifiedURL("view_equipment_details.py?equipID=%s"%content[8]), content[7])
    print "                </tr>"
    return
def table_body(content):
    url = redirect.getQualifiedURL("player_manage_a_game.py?gameID=%s"%(content[0]))
    
    print """                <tr>
                    <th>%s</th>"""%content[0]
    print """                <td><a href="%s">%s</a></td>"""%(redirect.getQualifiedURL("player_manage_a_game.py?gameID=%s"%content[0]), content[1])
    for item in content[2:]:
        print"                    <td>%s</td>"%item
    print "                </tr>"
    return
Example #3
0
def main():
    print "%s\nContent-Type: text/html\n" % (sess.cookie)
    if sess.data.get('loggedIn') not in (1, 2):
        if not do_login():
            where_to_next = redirect.getQualifiedURL("renew_subscription.py")
        else:
            where_to_next = redirect.getQualifiedURL("home.py") if sess.data['loggedIn'] in (1, 2) else redirect.getQualifiedURL("login.py?error=1")
    sess.close()
    do_redirect(where_to_next)
    return
def edit_instancerun_form(InstanceRunID):
    print """            <div class="row">
                <div class="col-lg-4 col-md-offset-4">
                     <div class="well">
                        <form method="post" action="%s">
                            <fieldset>"""%(redirect.getQualifiedURL("player_edit_instancerun_update.py?instancerunID=%s"%(InstanceRunID)))
    return
def edit_video_form(vidID):
    print """            <div class="row">
                <div class="col-lg-4 col-md-offset-4">
                     <div class="well">
                        <form method="post" action="%s">
                            <fieldset>"""%redirect.getQualifiedURL("player_edit_video_update.py?videoID=%s"%vidID)
    return
def table_body(content, loggedIn):
    print """                <tr>
                    <th><a href="%s">%s</a></th>"""%(redirect.getQualifiedURL("player_edit_an_achievement.py?achievementID=%s"%content[0]) if loggedIn == 2 else redirect.getQualifiedURL("login.py"), content[1])
    for item in content[2:]:
        print"                    <td>%s</td>"%item
    print "                </tr>"
    return
def close_form(viewerID):
    print """                            <div class="form-group">
                                <div class="col-lg-2 col-lg-offset-2">
                                    <a class="btn btn-primary btn-block" roll="button" href="%s">Yes</a>
                                </div>
                                <div class="col-lg-4">
                                    <a class="btn btn-primary btn-block" roll="button" href="%s">No, I want to cancel my subscription</a>
                                </div>
                                <div class="col-lg-2">
                                    <a class="btn btn-primary btn-block" roll="button" href="%s">Logout</a>
                                </div>
                        </fieldset>
                     </form>
                </div>
            </div>
        </div>""" % (
        redirect.getQualifiedURL("renew_subscription_update.py?viewerID=%s" % viewerID),
        redirect.getQualifiedURL("renew_subscription_update.py?viewerID=%s&cancel=1" % viewerID),
        redirect.getQualifiedURL("do_logout.py"),
    )
    return
Example #8
0
def do_redirect(script, delay=0):
    """Constructs and returns the html header"""
    url = os.path.split(os.environ['REQUEST_URI'])[0] + '/' + script
    return"""
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="{};url={}">
</head>
<body>
    """.format(delay, redirect.getQualifiedURL(url))
def close_form(gameID):
    print"""                            <div class="form-group">
                                <div class="col-lg-4 col-lg-offset-1">
                                    <button type="submit" class="btn btn-primary btn-block">Submit</button>
                                </div>
                                <div class="col-lg-4 col-lg-offset-2">
                                    <a class="btn btn-primary btn-block" roll="button" href="%s">Delete</a>
                                </div>
                            </div>
                        </fieldset>
                    </form>
                </div>
            </div>"""%(redirect.getQualifiedURL("player_manage_a_game_update.py?gameID=%s&delete=1"%gameID))
    return
def open_field_form(order):
    print """        <div class="row">
              <div class="col-lg-4 col-md-offset-4">
                <div class="page-header">
                  <h1>Confirm Order</h1>
                </div>
              </div>
            </div>
            <div class="row">
                <div class="col-lg-4 col-md-offset-4">
                    <div class="well">
                        <form method="post" action="%s">
                            <fieldset>"""%redirect.getQualifiedURL("viewer_order_confirm.py?vidid=%s"%order[7])
    return
def close_form_player(viewerID):
    print"""                            <div class="form-group">
                                <div class="col-lg-4 col-lg-offset-1">
                                    <button type="submit" class="btn btn-primary btn-block">Submit</button>
                                </div>
                                <div class="col-lg-4 col-lg-offset-2">
                                    <a class="btn btn-primary btn-block" roll="button" href="%s">Delete Account</a>
                                </div>
                            </div>
                        </fieldset>
                    </form>
                </div>
            </div>"""%(redirect.getQualifiedURL("viewer_edit_profile_update.py?viewerID=%s&delete=1"%viewerID))
    return
def add_game():
    print """                <tr>
                    <th style="text-align:center"><a class="btn btn-primary btn-block" roll="button" href="%s">Add Game</a></th>"""%(redirect.getQualifiedURL("add_game.py"))
    return
Example #13
0
#######################################################################################################

if not alreadyLoggedOut:
    sess.data['loggedIn'] = 0 # log them out
    sess.data['userName'] = "******"
    sess.set_expires('') # expire session
    sess.close()

#######################################################################################################

# send session cookie
print "%s\nContent-Type: text/html\n" % (sess.cookie)

#######################################################################################################

# redirect to home page
print """\
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="0;url=%s">
</head>
<body>
</body>
""" % redirect.getQualifiedURL("home.py")

#######################################################################################################

Example #14
0
    </div>
    """

    # Footer at the end
    print """
        <div id="footer">
            <p>This discussion board is designed for the final project of informatics 3 by group04 team members.</p>
        </div>
    </body>
    </html>
    """

else:

    # redirect to home page
    print """\
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="refresh" content="0;url=%s">
    </head>
    <body>
    </body>
    """ % redirect.getQualifiedURL("serve/hojh/info3/group4/forum/login.py")



# Tidy up and free resources
sess.close()    
Example #15
0
# The libraries we'll need
import sys, cgi, session, redirect

# ---------------------------------------------------------------------------------------------------------------------
sess = session.Session(expires=20*60, cookie_path='/')
alreadyLoggedOut = not sess.data.get('loggedIn')

if not alreadyLoggedOut:
    sess.data['loggedIn'] = 0 # log them out
    sess.data['mod'] = 0
    sess.set_expires('') # expire session
    sess.close()

# ---------------------------------------------------------------------------------------------------------------------
# send session cookie
print "%s\nContent-Type: text/html\n" % (sess.cookie)

# ---------------------------------------------------------------------------------------------------------------------
# redirect to home page
print """\
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="0;url=%s">
</head>
<body>
</body>
""" % redirect.getQualifiedURL( "/serve/wangw/info3/group4/forum/home.py") # kevin

Example #16
0
File: mod.py Project: 2666fff/demo
# What came on the URL string?
params = cgi.FieldStorage()

if not sess.data.get('mod') or sess.data['loggedIn'] == 0:
    # redirect to home page
    print """\
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="refresh" content="0;url=%s">
    </head>
    <body>
    </body>
    """ % redirect.getQualifiedURL( "/serve/wangw/info3/group4/forum/home.py")
    
else:
    # ---------------------------------------------------------------------------------------------------------------------
    # Send head of HTML document, pointing to our style sheet
    if params.has_key('forum') and params.has_key('thread'):
        
        #get information from database.
        sql = """
            select p.title, replace(p.body,'\n','<BR>'), p.date_posted, t.num_views, u.user_name, t.thread_id, t.num_posts, p.post_id,t.date_closed
            from thread t
            inner join post p on t.thread_id=p.thread_id
            inner join reg_user u on p.user_id=u.user_id
            where t.forum_id=%s
              and t.thread_id=%s
            order by p.post_id asc limit 1                
Example #17
0
# ---------------------------------------------------------------------------------------------------------------------
# login logic
if loggedIn:
    
    # redirect to home page
    print """\
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="refresh" content="0;url=%s">
    </head>
    <body>
    </body>
    """ % redirect.getQualifiedURL( "/serve/wangw/info3/group4/forum/home.py")
    
else:
    form = cgi.FieldStorage()
    if not (form.has_key('username') and form.has_key('password')):
        sess.data['loggedIn'] = 0
    else:
        #check admin
        if form['username'].value == "admin" and form['password'].value == "adminpass":
            sess.data['loggedIn'] = 1
            sess.data['mod'] = 1
            sess.data['adm'] = 1
            sess.data['userName'] = "******"
            # redirect to admin page
            print """\
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Example #18
0
# What came on the URL string?
params = cgi.FieldStorage()

if not sess.data.get('mod') or sess.data['loggedIn'] == 0:
    # redirect to home page
    print """\
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="refresh" content="0;url=%s">
    </head>
    <body>
    </body>
    """ % redirect.getQualifiedURL("/serve/wangw/info3/group4/forum/home.py")
else:
    if params.has_key('r_id'):
        if params['r_id'].value.isdigit():
            cursor.execute(
                """
                               select thread_id_1,thread_id_2 from related_thread where thread_id_1 = %s and thread_id_2=%s
                               """,
                (params['r_id'].value, params['thread'].value))
            a = cursor.rowcount

            cursor = db.cursor()
            cursor.execute(
                """
                               select thread_id_1,thread_id_2 from related_thread where thread_id_2 = %s and thread_id_1=%s
                               """,
Example #19
0
#print(sess.data)
#sys.exit()

if loggedIn:
    
    # redirect to home page
    print """\
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="refresh" content="0;url=%s">
    </head>
    <body>
    </body>
    """ % redirect.getQualifiedURL("/~seanbm/Junk/W9LectFiles/home.py")
    
else:

    # ---------------------------------------------------------------------------------------------------------------------
    # Send head of HTML document, pointing to our style sheet
    print """
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Our Sample - Login page</title>
    <link href="css/style.css" rel="stylesheet" type="text/css" media="screen" />
    </head>
    <body>
def print_other_fields(order):
    print """                   <div class="form-group">
                                    <label class="col-lg-4 col-lg-offset-1 control-label">Viewed Status: </label>
                                    <div class="col-lg-6">
                                        <label class="control-label">%s</label>
                                    </div>
                                </div></br>
                                <div class="form-group">
                                    <label class="col-lg-4 col-lg-offset-1 control-label">Date Viewed: </label>
                                    <div class="col-lg-6">
                                        <label class="control-label">%s</label>
                                    </div>
                                </div></br>
                                <div class="form-group">
                                    <label class="col-lg-4 col-lg-offset-1 control-label">URL: </label>
                                    <div class="col-lg-6">
                                        <label class="control-label"><a href="%s">%s</a></label>
                                    </div>
                                </div></br>"""%(order[7], order[10] if order[10] != None else "Not viewed yet", redirect.getQualifiedURL("viewer_order_watch.py?orderID=%s"%order[9]), order[8])
    return
Example #21
0
# What came on the URL string?
params = cgi.FieldStorage()

if not sess.data.get('mod') or sess.data['loggedIn'] == 0:
    # redirect to home page
    print """\
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="refresh" content="0;url=%s">
    </head>
    <body>
    </body>
    """ % redirect.getQualifiedURL("/serve/wangw/info3/group4/forum/home.py")

else:
    # ---------------------------------------------------------------------------------------------------------------------
    # Send head of HTML document, pointing to our style sheet
    if params.has_key('forum') and params.has_key('thread'):

        #get information from database.
        sql = """
            select p.title, replace(p.body,'\n','<BR>'), p.date_posted, t.num_views, u.user_name, t.thread_id, t.num_posts, p.post_id,t.date_closed
            from thread t
            inner join post p on t.thread_id=p.thread_id
            inner join reg_user u on p.user_id=u.user_id
            where t.forum_id=%s
              and t.thread_id=%s
            order by p.post_id asc limit 1                
Example #22
0
        </div>
        </div>

    </div>
    """

    # Footer at the end
    print """
        <div id="footer">
            <p>This discussion board is designed for the final project of informatics 3 by group04 team members.</p>
        </div>
    </body>
    </html>
    """

else:

    # redirect to home page
    print """\
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="refresh" content="0;url=%s">
    </head>
    <body>
    </body>
    """ % redirect.getQualifiedURL("serve/hojh/info3/group4/forum/login.py")

# Tidy up and free resources
sess.close()