def main(): utility.header("Upload Instance Run", "player") info = sess.data loggedIn = info.get("loggedIn") if not loggedIn or sess.data.get("PlayerType") != "S": utility.redirect("login.py") else: generate_form()
def main(): # print web header utility.header("Add new Players","") # check user identity info=sess.data loggedIn = info.get("loggedIn") if not loggedIn or sess.data.get("UserType")!="A": utility.redirect("login.py") else: generate_form()
def main(): # print web header utility.header("Add new Players", "") # check user identity info = sess.data loggedIn = info.get("loggedIn") if not loggedIn or sess.data.get("UserType") != "A": utility.redirect("login.py") else: generate_form()
def main(): usertype = utility.header("new game distributor", "") if usertype != "A": utility.redirect("login.py") else: generate_form()
def main(): usertype = utility.header("new game distributor","") if usertype != "A": utility.redirect("login.py") else: generate_form()
def main(): user_type = utility.header("Update Profile", "player") info = sess.data loggedIn = info.get("loggedIn") if not loggedIn or info.get("UserType") == 'V': utility.redirect("home.py") else: db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) latest_address_cursor = db.cursor() current_address_cursor = db.cursor() sql1 = "select PlayerID, AddressID, StartDate, EndDate \ from PlayerAddress \ where PlayerID = %s and EndDate is null" \ % (sess.data["UserID"]) latest_address_cursor.execute(sql1) latest_address_row = latest_address_cursor.fetchone() sql2 = "select * from PlayerAddress \ inner join Player On Player.PlayerID = PlayerAddress.PlayerID \ inner join Address on Address.AddressID = PlayerAddress.AddressID \ where PlayerAddress.PlayerID = %s \ and PlayerAddress.AddressID = %s " \ % (latest_address_row[0], latest_address_row[1] ) current_address_cursor.execute(sql2) current_address_row = current_address_cursor.fetchone() Gamehandle = to_null(current_address_row[12]) Email = to_null(current_address_row[11]) Phone = to_null(current_address_row[13]) Voip = to_null(current_address_row[14]) Street_num = to_null(current_address_row[16]) Street_num_suffix = to_null(current_address_row[17]) Street_name = to_null(current_address_row[18]) Street_type = to_null(current_address_row[19]) Address_type = to_null(current_address_row[20]) Minor = to_null(current_address_row[22]) Major = to_null(current_address_row[23]) District = to_null(current_address_row[24]) Post = to_null(current_address_row[25]) Country = to_null(current_address_row[26]) # close after use db.close() generate_form(Gamehandle, Email, Phone, Voip, Street_num, Street_num_suffix, Street_name, Street_type, Address_type, Minor, Major, District, Post, Country)
def main(): # get user type usertype = utility.header("Upload Instance Run","") info=sess.data loggedIn = info.get("loggedIn") if not loggedIn or sess.data.get("PlayerType")!="S": utility.redirect("login.py") else: form = cgi.FieldStorage() game_name = form.getvalue("game_name") name = form.getvalue("name") category = form.getvalue("category") date = form.getvalue("date") num_of_players = (int) (form.getvalue("num_of_players")) num_of_videos = (int)(form.getvalue("num_of_videos")) num_of_achievements = (int)(form.getvalue("num_of_achievements")) notes = form.getvalue("notes") generate_form(game_name, name, category, date, num_of_players, num_of_videos, num_of_achievements, notes)
def main(): # check if it is administrator usertype = utility.header("new game", "") if usertype != "A": utility.redirect("login.py") else: generate_form()
def main(): # check if it is administrator usertype = utility.header("new equipment","") if usertype != "A": utility.redirect("login.py") else: generate_form()
def main(): user_type = utility.header("Update Instance Run", "player") info = sess.data loggedIn = info.get("loggedIn") if not loggedIn and user_type[1] != "S": print " You don't have access" utility.redirect("home.py") else: generate_form()
def main(): user_type = utility.header("Update Instance Run","player") info=sess.data loggedIn = info.get("loggedIn") if not loggedIn and user_type[1] != "S": print " You don't have access" utility.redirect("home.py") else: generate_form()
def main(): usertype = utility.header("New adding Players","") if usertype != "A": utility.redirect("login.py") else: # Define main function. form = cgi.FieldStorage() try: num_of_players = (int) (form.getvalue("num_of_new_players")) except: utility.redirect("admin_add_Player.py") sys.exit(0) generate_form(num_of_players )
import utility, cgi, MySQLdb, session sess = session.Session(expires=20 * 60, cookie_path='/') # check if it is administrator usertype = utility.header("Add distributor address", "") if usertype != "A": utility.redirect("login.py") sys.exit(0) form = cgi.FieldStorage() # get form values Distributor_id = form.getvalue("GameDistributorID") Street_num = form.getvalue("Street_num") Street_name = form.getvalue("Street_name") Street_type = form.getvalue("Street_type") Major = form.getvalue("Major") District = form.getvalue("District") Post = form.getvalue("Post") Country = form.getvalue("Country") Street_num_suffix = form.getvalue("Street_num_suffix") Address_type = form.getvalue("Address_type") Address_type_identifier = form.getvalue("Address_type_identifier") Minor = form.getvalue("Minor") # connect to db db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306)
def main(): utility.header("Adding new Players","") form = cgi.FieldStorage() # connect to db db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) # get number of new players num_of_players = (int) (form.getvalue("num_of_players")) # lists to hold details supervisor_ids = [] player_first_names = [] player_last_names = [] player_roles = [] player_types = [] player_emails = [] player_gamehandles = [] player_voips = [] player_phones = [] profile_descriptions = [] # get Player details into lists ------------------------- for i in range(0,num_of_players): # supervisor name to find id sn = form.getvalue("supervisor_name%s"%(i+1)) # get id sid = get_supervisor_id(db, sn) # insert into supervisor id list supervisor_ids.append(sid) # first name fn = form.getvalue("player_first_name%s"%(i+1)) player_first_names.append(fn) # last name ln = form.getvalue("player_last_name%s"%(i+1)) player_last_names .append(ln) # role r = form.getvalue("player_role%s"%(i+1)) player_roles.append(r) # type t = form.getvalue("player_type%s"%(i+1)) player_types.append(t) # email email = form.getvalue("player_email%s"%(i+1)) player_emails .append(email) # gamehandle gh = form.getvalue("player_gamehandle%s"%(i+1)) player_gamehandles.append(gh) # voip v = form.getvalue("player_voip%s"%(i+1)) player_voips.append(v) # phone tel = form.getvalue("player_phone%s"%(i+1)) if tel is None: tel = '' player_phones.append(tel) # profile description pd = form.getvalue("profile_description%s"%(i+1)) if pd is None: pd = '' profile_descriptions.append(pd) # end of for loop -------------------------------------------------- result = extract_results(num_of_players, supervisor_ids, player_first_names, player_last_names, player_roles , player_types, player_emails, player_gamehandles, player_voips) # if all needed inputs are valid------------------------------------ if result == True: for i in range(0, num_of_players): # insert new UserAccount first # first name as default username and last name as default password id = insert_user(db, player_first_names[i], player_last_names[i] ) # insert Player insert_player(db, id, supervisor_ids[i],player_first_names[i], player_last_names[i], player_roles[i], player_types[i], player_emails[i], player_gamehandles[i], player_voips[i], player_phones[i], profile_descriptions[i]) display_success(result,num_of_players )
import sys, MySQLdb, utility, session, cgi sess = session.Session(expires=20 * 60, cookie_path='/') info = sess.data loggedIn = info.get("loggedIn") if not loggedIn or info.get("UserType") != 'P': utility.redirect("login.py") sys.exit(0) elif info.get("PlayerType") != "S": utility.redirect("login.py") sys.exit(0) utility.header("Update Venue", "venue") print """ <h1>Update Venue</h1> <h3>Please select the venue you would like to update.</h3> <form method="post" action="venue_update2.py">""" db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) cursor = db.cursor() cursor.execute("""select VenueID,VenueName from Venue""") rows = cursor.fetchall() print """ <div class="col-lg-5">
import session, MySQLdb, utility utility.header("Venue", "venue") # Connect to DB db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) cursor = db.cursor() supervisor_cursor = db.cursor() cursor.execute("SELECT * FROM Venue") rows = cursor.fetchall() print """ <p> <font size="8" color="White" > <center><b>Venue</b></center> </font> </p> """ for row in rows: id = row[0] name = row[1] discription = row[2] power = row[3] lighting = row[4] supervisor_id = row[5] supervisor_sql = "select * from Player \
db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) cursor = db.cursor() #create new order cursor.execute( """insert into GameDistributorOrder Values (default,CURDATE(),{0})""". format(form["dis"].value)) cursor.execute("""set @EID=LAST_INSERT_ID()""") db.commit() ids = form.getlist("id") for id in ids: if not form.has_key(id + "Q"): quantity = 1 else: quantity = form[id + "Q"].value cursor.execute("""select Cost from Game where GameID={0}""".format(id)) row = cursor.fetchone() cursor.execute( """insert into OrderDetail values (@EID,{0},{1},{2})""".format( id, quantity, row[0])) db.commit() utility.header("Game Order Result", "game") print """<br><br><br><br><h3>Your order placement is successful!</h3>""" print """<p><a href="game_order.py">Back</a></p>""" utility.footer()
import session, MySQLdb, utility utility.header("Instance Run", "instance run") # Connect to DB db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) cursor = db.cursor() cursor.execute("SELECT * FROM InstanceRun") # get all instance runs rows = cursor.fetchall() # display one instance run at a time for row in rows: InsId = row[0] SuperId = row[1] Name = row[2] Time = row[3] Category = row[4] # get supervisor's name cursor.execute("SELECT * FROM Player where PlayerID={0}".format(SuperId)) superrow = cursor.fetchone() supername = superrow[2]+" "+superrow[3] print """ <hr class="featurette-divider"> <div class="row featurette"> <div class="col-md-7"> <h3 class="featurette-heading"> <span class="text-muted">{0}</span></h3>
# Import the CGI moduleWork import cgi, MySQLdb, utility, session, sys sess = session.Session(expires=20 * 60, cookie_path='/') # --------------------------------------------------------------------------------------------------------------------- # send session cookie info = sess.data loggedIn = info.get("loggedIn") # check user identity if not loggedIn or sess.data.get("UserType") != "A": utility.redirect("login.py") sys.exit(0) utility.header("Adding new Players", "") form = cgi.FieldStorage() # connect to db db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) # get all attribute values name = form.getvalue("game_name") genre = form.getvalue("genre") review = form.getvalue("review") star = form.getvalue("star") classification = form.getvalue("classification") platform = form.getvalue("platform") link = form.getvalue("link")
def main(): utility.header("User Registration", "") # Define main function. form = cgi.FieldStorage() # connect to db db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) supervisor_id = sess.data["UserID"] # Get data from fields game_name = form.getvalue("game_name") name = form.getvalue("name") category = form.getvalue("category") date = form.getvalue("date") # get length of each list num_of_players = (int)(form.getvalue("num_of_players")) num_of_videos = (int)(form.getvalue("num_of_videos")) num_of_achievements = (int)(form.getvalue("num_of_achievements")) ### get PerformanceNotes for InstanceRunPlayer performance_notes = form.getvalue("notes") ### get Player names ----------------------------------- player_names = [] for i in range(0, num_of_players): n = form.getvalue("player_name%s" % (i + 1)) player_names.append(n) ### Videos and Game names ------------------------------ video_urls = [] video_prices = [] video_types = [] game_names = [] for i in range(0, num_of_videos): url = form.getvalue("video_url%s" % (i + 1)) price = form.getvalue("video_price%s" % (i + 1)) Type = form.getvalue("video_type%s" % (i + 1)) game_name = form.getvalue("game_name%s" % (i + 1)) video_urls.append(url) video_prices.append(price) video_types.append(Type) game_names.append(game_name) # Achievements ------------------------------------------ achievement_names = [] achievement_rewards = [] for i in range(0, num_of_achievements): name = form.getvalue("achievement_name%s" % (i + 1)) reward = form.getvalue("achievement_reward%s" % (i + 1)) achievement_names.append(name) achievement_rewards.append(reward) # check all needed inputs are valid ---------------------------------------- result = extract_results(game_name, name, date, category, performance_notes, player_names, video_urls, video_prices, video_types, achievement_names, achievement_rewards, num_of_players, num_of_videos, num_of_achievements) # if all needed inputs are valid---------------------------------------------------- if result == True: ### insert new row into InstanceRun instance_run_insert(db, game_name, name, date, category) ### get latest id of instance run latest_id = latest_instance_run_id(db) ### insert new rows into InstanceRunPlayer for i in range(0, num_of_players): # get player id by search firstname player_id = get_player_id(db, player_names[i]) # then insert instance_run_player_insert(db, player_id, performance_notes, latest_id) ### insert new rows for Achievement for i in range(0, num_of_achievements): insert_achievement(db, latest_id, date, achievement_names[i], achievement_rewards[i]) ### insert new rows for Video for i in range(0, num_of_videos): # get game id game_id = get_game_id(db, game_names[i]) # then insert insert_video(db, url, price, video_types[i], latest_id, game_id) display_success(result) db.close()
rows=cursor.fetchall() adds=[] for row in rows: if form.has_key(row[0]): cursor.execute("""update Venue set {0}='{1}' where VenueID='{2}'""".format(row[0],form[row[0]].value,venueID)) db.commit() delIDs=form.getlist("delEquipmentID") for delID in delIDs: try: cursor.execute("""Delete from VenueEquipment where VenueID={0} and EquipmentID={1}""".format(venueID,delID)) db.commit() except: db.rollback() ids=form.getlist("EquipmentID") for id in ids: cursor.execute("""insert into VenueEquipment values ({2},{0},CURDATE(),{1})""".format(id,form[id+"V"].value,venueID)) db.commit() utility.header("Venue Updating Result","venue") print """<br><br><br><br><h3>Update successfully!</h3>""" print """<p><a class= "btn btn-primary" href="venue_update.py">Back</a></p>""" utility.footer()
def main(): utility.header("Sign up", "") generate_form()
Id = row[0] Supervisor_id = row[1] First_name = row[2] Last_name = row[3] Gamehandle = row[8] Role = row[4] Type = row[5] Description = row[6] cursor.execute("SELECT * FROM Player WHERE PlayerID=%s"%Supervisor_id) # Fetch one row at a time row = cursor.fetchone() Supervisor = row[2]+" "+row[3] utility.header((First_name+" "+Last_name+" detail"),"player") print """ <ul> <li>First Name: %s</li> <li>Last Name: %s</li> <li>Supervised by: %s</li> <li>Gamehandle: %s</li> <li>Role: %s</li> <li>Type: %s</li> <li>Description: %s</li> </ul> <a href="player_display.py">Back</a> </body> </html> """%(First_name, Last_name, Supervisor, Gamehandle, Role, Type, Description)
def main(): user_type = utility.header("Update Instance Run","player") info=sess.data loggedIn = info.get("loggedIn") if not loggedIn and user_type[1] != "S": utility.redirect("login.py") else: form = cgi.FieldStorage() db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) # 0 for no # 1 for yes edit_instance_run = form.getvalue("edit_instance_run") print edit_instance_run instance_run_id = form.getvalue("instance_run_num ") print instance_run_id # 0 for no # 1 for add into IR # 2 for delete from IR edit_player = form.getvalue("edit_player") edit_video = form.getvalue("edit_video") edit_achievement = form.getvalue("edit_achievement") print edit_player # ----------------------------------------------------------------------------------------------------- # update instance run detail if edit_instance_run == "1": # instance run detail for update new_instance_run_name = form.getvalue("new_instance_run_name") instance_run_date = form.getvalue("instance_run_date") instance_run_cate = form.getvalue("instance_run_cate") update_InstanceRun(db, instance_run_id, new_instance_run_name , instance_run_date, instance_run_cate)# # add one player into IR ------------------------------------------------------------------------------ if edit_player == "1" : # new player detail player_chosed = form.getvalue("player_chosed_for_add") insert_InstanceRunPlayer(db, player_chosed, instance_run_id)# # delete player from IR if edit_player == "2": # player name for deletion player_chosed_for_del = form.getvalue("player_chosed_for_del") remove_InstanceRunPlayer(db, player_chosed_for_del, instance_run_id )# # add one Video related to IR ------------------------------------------------------------------------- if edit_video == "1": # new Video detail new_video_url= form.getvalue("new_video_url") new_video_price= form.getvalue("new_video_price") new_video_type = form.getvalue("new_video_type") new_video_game = form.getvalue("game") insert_Video(db, instance_run_id, new_video_url, new_video_price, new_video_type, game)# # delelte Video related to IR if edit_video == "2": # Video URL for deletion video_url_for_delete = form.getvalue("video_url_for_delete") remove_Video(db, video_url_for_delete) # # add Achievement realted to IR ----------------------------------------------------------------------- if edit_achievement == "1": # new achievement detail achievement_date= form.getvalue("achievement_date") achievement_name= form.getvalue("achievement_name") achievement_reward= form.getvalue("achievement_reward") insert_Achievement(db, instance_run_id, achievement_date, achievement_name, achievement_reward)# # delete Achievement realted to IR if edit_achievement == "2": # achievement name for deletion achievement_for_delete = form.getvalue("achievement_for_delete") remove_Achievement(db, achievement_for_delete )# db.close()
def main(): viewer_type = utility.header("Update Profile","") info=sess.data loggedIn = info.get("loggedIn") if not loggedIn or info.get("UserType") != 'V': utility.redirect("home.py") else: db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) vc_cursor = db.cursor() vp_cursor = db.cursor() first_name = "" last_name = "" donation = "" renew_date = "" # get detail of CrowdFundingViewer if ( viewer_type == "VC" ) : sql = "select * from CrowdFundingViewer \ where ViewerID = %s" \ % ( sess.data["UserID"]) vc_cursor.execute(sql) detail_row = vc_cursor.fetchone() first_name = detail_row[1] last_name = detail_row[2] donation = detail_row[3] # get detail of PremiumViewer if ( viewer_type == "VP" ) : sql = "select * from PremiumViewer \ where ViewerID = %s" \ % ( sess.data["UserID"]) vp_cursor.execute(sql) detail_row = vp_cursor.fetchone() renew_date = detail_row[1] # get latest address id --------------------------------- sql1 = "select ViewerID, AddressID, StartDate, EndDate \ from ViewerAddress \ where ViewerID = %s and EndDate is null" \ % (sess.data["UserID"]) latest_address_cursor = db.cursor() latest_address_cursor.execute(sql1) latest_address_row = latest_address_cursor.fetchone() # -------------------------------------------------------- # get current address ---------------------------------------------------------- sql2 = "select * from ViewerAddress \ inner join Viewer On Viewer.ViewerID = ViewerAddress.ViewerID \ inner join Address on Address.AddressID = ViewerAddress.AddressID \ where ViewerAddress.ViewerID = %s \ and ViewerAddress.AddressID = %s " \ % (latest_address_row[0], latest_address_row[1] ) current_address_cursor= db.cursor() current_address_cursor.execute(sql2) current_address_row = current_address_cursor.fetchone() # ------------------------------------------------------------------------------ dob = to_null(current_address_row[6]) Email = to_null(current_address_row[7]) Street_num = to_null(current_address_row[9]) Street_num_suffix = to_null(current_address_row[10]) Street_name = current_address_row[11] Street_type = current_address_row[12] Address_type = current_address_row[13] Address_type_identifier = to_null(current_address_row[14]) Minor = to_null(current_address_row[15]) Major = current_address_row[16] District = current_address_row[17] Post = current_address_row[18] Country = current_address_row[19] # close after use db.close() generate_form(viewer_type, dob, Email, first_name, last_name, donation, Street_num, Street_num_suffix, Street_name, Street_type, Address_type,Address_type_identifier, Minor, Major, District, Post, Country)
import cgi, MySQLdb,utility,session,sys sess = session.Session(expires=20*60, cookie_path='/') # --------------------------------------------------------------------------------------------------------------------- # send session cookie info=sess.data loggedIn = info.get("loggedIn") if not loggedIn or sess.data.get("UserType")!="A": utility.redirect("login.py") sys.exit(0) utility.header("Adding new Equipment","") form = cgi.FieldStorage() # connect to db db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) # get all attribute values ModelAndMake = form.getvalue("ModelAndMake") EquipmentReview = form.getvalue("EquipmentReview") ProcessorSpeed = form.getvalue("ProcessorSpeed") sql = "insert into Equipment(EquipmentID, ModelAndMake, EquipmentReview, ProcessorSpeed) values (DEFAULT, '{0}', '{1}', '{2}')".format(ModelAndMake, EquipmentReview, ProcessorSpeed)
if not form.has_key("disOrder"): utility.redirect("admin_add_GameShipment.py") sys.exit(0) db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) cursor = db.cursor() cursor.execute ("""insert into GameShipment Values (default,CURDATE(),{0})""".format(form["disOrder"].value)) cursor.execute("""set @EID=LAST_INSERT_ID()""") db.commit() cursor.execute("select @EID") shipmentID=cursor.fetchone()[0] utility.header("Log a Game Shipment","game") print""" <h1>Log a Game Shipment</h1> <h3>Please select the games and quantities you have received.</h3> <form method="post" action="do_admin_add_GameShipment.py"><input type="hidden" name="shipID" value={0}>""".format(shipmentID) cursor.execute("""select GameID,QuantityOrdered from OrderDetail where GameDistributorOrderID={0}""".format(form["disOrder"].value)) rows=cursor.fetchall() for row in rows: cursor.execute("""select GameName from Game where GameID={0}""".format(row[0])) gameName=cursor.fetchone()[0] print """<p><input type="checkbox" name="id" value="{0}"/>{1} <input type="number" name={2}Q min="1" max={3} value="1" id="ddd"\></p>""".format(row[0],gameName,row[0],row[1])
def main(): # check user identity info = sess.data loggedIn = info.get("loggedIn") if not loggedIn or info.get("UserType") == 'V': utility.redirect("login.py") else: utility.header("", "player") form = cgi.FieldStorage() p_num = 0 a_num = 0 # 3 Compulsory fields of Player Gamehandle = form.getvalue("Gamehandle") if Gamehandle is not None: p_num += 1 Email = form.getvalue("Email") if Email is not None: p_num += 1 Voip = form.getvalue("Voip") if Voip is not None: p_num += 1 # 1 Voluntary fields of Player Phone = to_null(form.getvalue("Phone")) # 7 Compulsory fields of Address Street_num = form.getvalue("Street_num") # if string is an int if Street_num is not None: a_num += 1 if Street_num.isdigit(): Street_num = int(Street_num) Street_name = form.getvalue("Street_name") if Street_name is not None: a_num += 1 Street_type = form.getvalue("Street_type") if Street_type is not None: a_num += 1 Major = form.getvalue("Major") if Major is not None: a_num += 1 District = form.getvalue("District") if District is not None: a_num += 1 Post = form.getvalue("Post") if Post is not None: a_num += 1 Country = form.getvalue("Country") if Country is not None: a_num += 1 # 3 Voluntary fields of Address Street_num_suffix = to_null(form.getvalue("Street_num_suffix")) Address_type = to_null(form.getvalue("Address_type")) Minor = to_null(form.getvalue("Minor")) # connect to database db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) player_cursor = db.cursor() adrress_cursor = db.cursor() player_address_cursor = db.cursor() # Check what has been changed # # 0 - nothing changed # 1 - player changed # 2 - address changed # 3 - both changed status = check_detail(db, Gamehandle, Email, Voip, Phone, Street_num, Street_num_suffix, Street_name, Street_type, Address_type, Minor, Major, District, Post, Country) if status == 1 and p_num == 3: update_player(db, Gamehandle, Email, Phone, Voip) print """ <h2> "Your personal detail has been updated \n"</h2> """ elif status == 2 and a_num == 7: # insert address entered as a new row into Address table insert_address(db, Street_num, Street_num_suffix, Street_name, Street_type, Address_type, Minor, Major, District, Post, Country) # update EndDate of last address update_last_address_date(db) # get latest inserted AddressId current_address_id = new_address_id(db) # insert player_address insert_player_address(db, current_address_id) print """ <h2> "Your address detail has been updated! \n"</h2> """ elif status == 3 and p_num == 3 and a_num == 7: update_player(db, Gamehandle, Email, Phone, Voip) # insert address entered as a new row into Address table insert_address(db, Street_num, Street_num_suffix, Street_name, Street_type, Address_type, Minor, Major, District, Post, Country) # update EndDate of last address update_last_address_date(db) # get latest inserted AddressId current_address_id = new_address_id(db) # insert player_address insert_player_address(db, current_address_id) print """ <h2> "Your personal detail has been updated! \n"</h2> <h2> "Your address  detail has been updated! \n"</h2> """ else: if p_num < 3 or a_num < 7: print """ <h2> "Compulsory fields cannot be blank \n"</h2> """ else: print """ <h2> "Nothing has changed! \n"</h2> """ db.close()
def main(): utility.header("User Registration","") # Define main function. form = cgi.FieldStorage() # connect to db db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) supervisor_id = sess.data["UserID"] # Get data from fields game_name = form.getvalue("game_name") name = form.getvalue("name") category = form.getvalue("category") date = form.getvalue("date") # get length of each list num_of_players = (int) (form.getvalue("num_of_players")) num_of_videos = (int)(form.getvalue("num_of_videos")) num_of_achievements = (int)(form.getvalue("num_of_achievements")) ### get PerformanceNotes for InstanceRunPlayer performance_notes = form.getvalue("notes") ### get Player names ----------------------------------- player_names = [] for i in range(0,num_of_players): n = form.getvalue("player_name%s"%(i+1)) player_names.append(n) ### Videos and Game names ------------------------------ video_urls = [] video_prices = [] video_types = [] game_names = [] for i in range(0,num_of_videos): url = form.getvalue( "video_url%s" % (i+1) ) price = form.getvalue( "video_price%s" % (i+1) ) Type = form.getvalue( "video_type%s" % (i+1) ) game_name = form.getvalue( "game_name%s" % (i+1) ) video_urls.append(url) video_prices.append(price) video_types.append(Type) game_names.append(game_name) # Achievements ------------------------------------------ achievement_names = [] achievement_rewards = [] for i in range(0,num_of_achievements): name = form.getvalue("achievement_name%s"%(i+1)) reward = form.getvalue("achievement_reward%s"%(i+1)) achievement_names.append(name) achievement_rewards.append(reward) # check all needed inputs are valid ---------------------------------------- result = extract_results(game_name, name, date, category, performance_notes , player_names, video_urls, video_prices, video_types, achievement_names, achievement_rewards,num_of_players,num_of_videos ,num_of_achievements) # if all needed inputs are valid---------------------------------------------------- if result == True: ### insert new row into InstanceRun instance_run_insert(db, game_name, name, date, category) ### get latest id of instance run latest_id = latest_instance_run_id(db) ### insert new rows into InstanceRunPlayer for i in range(0, num_of_players): # get player id by search firstname player_id = get_player_id(db, player_names[i]) # then insert instance_run_player_insert(db, player_id, performance_notes, latest_id) ### insert new rows for Achievement for i in range(0, num_of_achievements): insert_achievement(db, latest_id, date, achievement_names[i], achievement_rewards[i]) ### insert new rows for Video for i in range(0, num_of_videos ): # get game id game_id = get_game_id(db, game_names[i]) # then insert insert_video(db, url, price, video_types[i], latest_id , game_id) display_success(result) db.close()
def main(): utility.header("Sign up","") generate_form()
# The libraries we'll need import sys, session, cgi, MySQLdb, utility sess = session.Session(expires=20*60, cookie_path='/') usertype = utility.header("Home", "home") print """ <!-- Carousel ================================================== --> <div id="myCarousel" class="carousel slide" data-ride="carousel"> <!-- Indicators --> <ol class="carousel-indicators"> <li data-target="#myCarousel" data-slide-to="0" class="active"></li> <li data-target="#myCarousel" data-slide-to="1"></li> <li data-target="#myCarousel" data-slide-to="2"></li> </ol> <div class="carousel-inner"> <div class="item active"> <img src="home1.jpg" alt="First slide"> <div class="container"> <div class="carousel-caption"> <h1>New to WWAG ?</h1> <p>'Wil Wheaton Appreciation Guild' is an interactive gaming community comprised of elite players around the world. Join us and enjoy tons of entertaining gameplay videos today !</p> <p><a class="btn btn-lg btn-primary" href="about_page.py" role="button">Learn more</a></p> </div> </div> </div> <div class="item"> <img src="home2.jpg" alt="Second slide"> <div class="container">
import MySQLdb, utility utility.header("Equipment", "equipment") # connect to database db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) cursor = db.cursor() cursor.execute("SELECT * FROM Equipment") # fetch first row row = cursor.fetchone() # display each equipment's information while row is not None: id = row[0] model = row[1] review = row[2] speed = row[3] print """ <hr class="featurette-divider"> <div class="row featurette"> <div class="col-md-7"> <h2 class="featurette-heading"><span class="text-muted">{0}</span></h2> <p class="lead">Processor speed: {2}</p> <p class="lead">{2}</p> </div>
# Import the CGI moduleWork import cgi, MySQLdb, utility, session, sys sess = session.Session(expires=20 * 60, cookie_path='/') # --------------------------------------------------------------------------------------------------------------------- # send session cookie info = sess.data loggedIn = info.get("loggedIn") if not loggedIn or sess.data.get("UserType") != "A": utility.redirect("login.py") sys.exit(0) utility.header("Adding new Equipment", "") form = cgi.FieldStorage() # connect to db db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) # get all attribute values ModelAndMake = form.getvalue("ModelAndMake") EquipmentReview = form.getvalue("EquipmentReview") ProcessorSpeed = form.getvalue("ProcessorSpeed") sql = "insert into Equipment(EquipmentID, ModelAndMake, EquipmentReview, ProcessorSpeed) values (DEFAULT, '{0}', '{1}', '{2}')".format( ModelAndMake, EquipmentReview, ProcessorSpeed) cursor = db.cursor()
"info20003g15_2014", "info20003g15", 3306) cursor = db.cursor() cursor.execute("""show columns from Venue""") rows = cursor.fetchall() adds = [] for row in rows: if form.has_key(row[0]): adds.append(form[row[0]].value) cursor.execute( """insert into Venue values (default,'{0}','{1}',{2},'{3}',{4})""".format( adds[0], adds[1], adds[2], adds[3], adds[4])) cursor.execute("""set @EID=LAST_INSERT_ID()""") db.commit() ids = form.getlist("EquipmentID") for id in ids: cursor.execute( """insert into VenueEquipment values (@EID,{0},CURDATE(),{1})""". format(id, form[id + "V"].value)) db.commit() utility.header("Venue Creating Result", "venue") print """<br><br><br><br><h3>Your venue creating is successful!</h3>""" print """<p><a class= "btn btn-primary" href="admin_add_venue.py">Back</a></p>""" utility.footer()
import sys,MySQLdb,utility,session,cgi sess = session.Session(expires=20*60, cookie_path='/') info=sess.data loggedIn = info.get("loggedIn") if not loggedIn or info.get("UserType") != 'A': utility.redirect("login.py") sys.exit(0) utility.header("Order Games","game") print""" <h1>Order Games</h1> <h3>Please select the games you would like to purchase.</h3> <form method="post" action="do_game_order.py">""" db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) cursor=db.cursor() cursor.execute("""select GameID,GameName from Game""") rows=cursor.fetchall() for row in rows: print """<p><input type="checkbox" name="id" value="{0}"/>{1} <input type="number" min="1" name={2}Q placeholder="quantity" id="ddd"/></p>""".format(row[0],row[1],row[0]) print """<h3>Please select the distributor that you wish to purchase games from</h3>"""
if len(fingerengine.fingerprints) is 0: continue utility.Msg("Fingerprinting completed.", LOG.UPDATE) # We've got the host fingerprinted, now kick off the # exploitation engine for the service utility.Msg("Loading auxiliary for '%s'..." % fingerengine.service, LOG.DEBUG) # execute the auxiliary engine auxengine(fingerengine) if __name__ == "__main__": utility.header() options = parse(sys.argv[1:]) # set platform state.platform = platform.system().lower() utility.Msg("Started at %s" % (utility.timestamp())) # log the CLI args utility.log(' '.join(sys.argv)) try: prerun(options) if options.ip or options.input_list: run(options)
adds = [] for row in rows: if form.has_key(row[0]): cursor.execute( """update Venue set {0}='{1}' where VenueID='{2}'""".format( row[0], form[row[0]].value, venueID)) db.commit() delIDs = form.getlist("delEquipmentID") for delID in delIDs: try: cursor.execute( """Delete from VenueEquipment where VenueID={0} and EquipmentID={1}""" .format(venueID, delID)) db.commit() except: db.rollback() ids = form.getlist("EquipmentID") for id in ids: cursor.execute( """insert into VenueEquipment values ({2},{0},CURDATE(),{1})""".format( id, form[id + "V"].value, venueID)) db.commit() utility.header("Venue Updating Result", "venue") print """<br><br><br><br><h3>Update successfully!</h3>""" print """<p><a class= "btn btn-primary" href="venue_update.py">Back</a></p>""" utility.footer()
def main(): user_type = utility.header("Update Instance Run", "player") info = sess.data loggedIn = info.get("loggedIn") if not loggedIn and user_type[1] != "S": utility.redirect("login.py") else: form = cgi.FieldStorage() db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) # 0 for no # 1 for yes edit_instance_run = form.getvalue("edit_instance_run") print edit_instance_run instance_run_id = form.getvalue("instance_run_num ") print instance_run_id # 0 for no # 1 for add into IR # 2 for delete from IR edit_player = form.getvalue("edit_player") edit_video = form.getvalue("edit_video") edit_achievement = form.getvalue("edit_achievement") print edit_player # ----------------------------------------------------------------------------------------------------- # update instance run detail if edit_instance_run == "1": # instance run detail for update new_instance_run_name = form.getvalue("new_instance_run_name") instance_run_date = form.getvalue("instance_run_date") instance_run_cate = form.getvalue("instance_run_cate") update_InstanceRun(db, instance_run_id, new_instance_run_name, instance_run_date, instance_run_cate) # # add one player into IR ------------------------------------------------------------------------------ if edit_player == "1": # new player detail player_chosed = form.getvalue("player_chosed_for_add") insert_InstanceRunPlayer(db, player_chosed, instance_run_id) # # delete player from IR if edit_player == "2": # player name for deletion player_chosed_for_del = form.getvalue("player_chosed_for_del") remove_InstanceRunPlayer(db, player_chosed_for_del, instance_run_id) # # add one Video related to IR ------------------------------------------------------------------------- if edit_video == "1": # new Video detail new_video_url = form.getvalue("new_video_url") new_video_price = form.getvalue("new_video_price") new_video_type = form.getvalue("new_video_type") new_video_game = form.getvalue("game") insert_Video(db, instance_run_id, new_video_url, new_video_price, new_video_type, game) # # delelte Video related to IR if edit_video == "2": # Video URL for deletion video_url_for_delete = form.getvalue("video_url_for_delete") remove_Video(db, video_url_for_delete) # # add Achievement realted to IR ----------------------------------------------------------------------- if edit_achievement == "1": # new achievement detail achievement_date = form.getvalue("achievement_date") achievement_name = form.getvalue("achievement_name") achievement_reward = form.getvalue("achievement_reward") insert_Achievement(db, instance_run_id, achievement_date, achievement_name, achievement_reward) # # delete Achievement realted to IR if edit_achievement == "2": # achievement name for deletion achievement_for_delete = form.getvalue("achievement_for_delete") remove_Achievement(db, achievement_for_delete) # db.close()
import globals as gl import time import os from analysis import run_analysis from utility import read_params, clear_previous_results, load_last_csv, create_zip, check_database, header from draw import draw_from_analysis # --------------- INITIAL START TIME -------------- start_time = time.time() header() # -------------- INITIAL MAIN -------------- print("----- INITIAL SHELL PARAMETERS -----") read_params() if gl.mode_input == 0: print("----- CLEAN PREVIOUS RESULTS -----") clear_previous_results() starting_depth = 1 else: print("----- LOAD LAST RESULTS (CSV) SAVED -----") starting_depth = load_last_csv() print("----- CHECK DATABASE -----") check_database() print("----- START ANALYSIS -----") run_analysis(starting_depth) print("----- END ANALYSIS -----")
import utility utility.header("About","") print """\ <hr class="featurette-divider"> <div class="row featurette"> <div class="col-md-5"> <img class="featurette-image img-responsive" src="about.gif" alt="Generic placeholder image"> </div> <div class="col-md-7"> <h2 class="featurette-heading"> About <span class="text-muted">WWAG</span></a></h2> <p class="lead">The 'Wil Wheaton Appreciation Guild' (WWAG) is a company that creates and uploads videos of entertaining gameplay to a 3rd party website for the public and premium viewers to enjoy. Over the last 13 years WWAG has become one of the most successful groups of players in the Asia-Pacific region, growing to 10 times its original size. Currently the players win regular in-game achievements, such as world-firsts, and have gained a large following of fans.</p> </div> </div> """ utility.footer()
def main(): info=sess.data loggedIn = info.get("loggedIn") if not loggedIn or info.get("UserType") != 'V': utility.redirect("login.py") else: utility.header("Update Viewer","player") form = cgi.FieldStorage() viewer_type = form.getvalue("viewer_type") # 2 fields of Viewer dob = form.getvalue("dob") email = form.getvalue("email") # 2 CrowdFundingViewer fields first_name = form.getvalue("first_name") last_name = form.getvalue("last_name") a_num = 0 # 7 Compulsory fields of Address Street_num = form.getvalue("Street_num") if Street_num is not None: a_num += 1 if Street_num.isdigit(): Street_num = int(Street_num) Street_name = form.getvalue("Street_name") if Street_name is not None: a_num += 1 Street_type = form.getvalue("Street_type") if Street_type is not None: a_num += 1 Major = form.getvalue("Major") if Major is not None: a_num += 1 District = form.getvalue("District") if District is not None: a_num += 1 Post = form.getvalue("Post") if Post is not None: a_num += 1 Country = form.getvalue("Country") if Country is not None: a_num += 1 # 4 Voluntary fields of Address Street_num_suffix = form.getvalue("Street_num_suffix") Address_type = form.getvalue("Address_type") Address_type_identifier = form.getvalue("Address_type_identifier") Minor = form.getvalue("Minor") # connect to database db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) #81 None pviewer RD None None Parkvile Melbourne VIC 3000 Australia address_changed = check_detail(db, Street_num, Street_num_suffix, Street_name, Street_type, Address_type, Address_type_identifier, Minor, Major, District, Post, Country) # address is not changed if address_changed == 0 or address_changed == 1: # update Viewer viewer_cursor = db.cursor() sql1 = """UPDATE Viewer SET DateOfBirth ="%s", Email = '%s' \ WHERE ViewerID = %s """ \ % (dob, email, sess.data["UserID"]) viewer_detail_cursor = db.cursor() sql2 = None # update CrowdFundingViewer if viewer_type == "C": sql2 = """UPDATE CrowdFundingViewer SET FirstName='%s', LastName='%s' \ WHERE ViewerID = %s """ \ % (first_name , last_name, sess.data["UserID"]) try: viewer_cursor.execute(sql1) if (sql2 !=None): viewer_detail_cursor.execute(sql2) db.commit() except: # Rollback in case there is any error db.rollback() print "up rollback" # address is changed ---------------------------------------------------------------------------------------------------------------------------- if address_changed == 1 and a_num == 7: # update address address_cursor = db.cursor() address_sql = "INSERT INTO Address(AddressID, StreetNumber, StreetNumberSuffix, StreetName, StreetType, AddressType, AddressTypeIdentifier, \ MinorMunicipality, MajorMunicipality, GoverningDistrict, PostalArea, Country) \ VALUES (%s, %s, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')" \ % ("default", Street_num, Street_num_suffix, Street_name, Street_type, Address_type, Address_type_identifier, Minor, Major, District, Post, Country) # Commit if successs try: address_cursor.execute(address_sql) db.commit() print "Address is updated" except: # Rollback in case there is any error db.rollback() print "insert address -> rollback" # --------------------------------------------------------------------------- # update EndDate of last address update_last_viewer_date(db) # get address id just inserted new_id = new_address_id(db) # insert viewer address insert_viewer_address(db, new_id) print """
sys.exit(0) db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) cursor=db.cursor() cursor.execute("""select VideoID from ViewerOrder natural join ViewerOrderLine where ViewerID={0}""".format(sess.data["UserID"])) rows=cursor.fetchall() ids=[] for row in rows: ids.append(row[0]) utility.header("Order Videos","video") print""" <h1>Order Videos</h1> <h7>{0}</h7> <h3>Please select the videos you would like to order.</h3> <form method="post" action="do_video_order.py">""".format("Your membership has expired, please renew" if sess.data.get("Expired")==1 else "") if sess.data.get("Expired")==1: sess.data["Expired"]=0 cursor.execute("""select VideoID,GameName,InstanceName from Video natural join Game natural join InstanceRun where VideoType='premium' or VideoType='behind the scene'""") rows=cursor.fetchall() for row in rows:
def main(): info = sess.data loggedIn = info.get("loggedIn") if not loggedIn or info.get("UserType") != 'V': utility.redirect("login.py") else: utility.header("Update Viewer", "player") form = cgi.FieldStorage() viewer_type = form.getvalue("viewer_type") # 2 fields of Viewer dob = form.getvalue("dob") email = form.getvalue("email") # 2 CrowdFundingViewer fields first_name = form.getvalue("first_name") last_name = form.getvalue("last_name") a_num = 0 # 7 Compulsory fields of Address Street_num = form.getvalue("Street_num") if Street_num is not None: a_num += 1 if Street_num.isdigit(): Street_num = int(Street_num) Street_name = form.getvalue("Street_name") if Street_name is not None: a_num += 1 Street_type = form.getvalue("Street_type") if Street_type is not None: a_num += 1 Major = form.getvalue("Major") if Major is not None: a_num += 1 District = form.getvalue("District") if District is not None: a_num += 1 Post = form.getvalue("Post") if Post is not None: a_num += 1 Country = form.getvalue("Country") if Country is not None: a_num += 1 # 4 Voluntary fields of Address Street_num_suffix = form.getvalue("Street_num_suffix") Address_type = form.getvalue("Address_type") Address_type_identifier = form.getvalue("Address_type_identifier") Minor = form.getvalue("Minor") # connect to database db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) #81 None pviewer RD None None Parkvile Melbourne VIC 3000 Australia address_changed = check_detail(db, Street_num, Street_num_suffix, Street_name, Street_type, Address_type, Address_type_identifier, Minor, Major, District, Post, Country) # address is not changed if address_changed == 0 or address_changed == 1: # update Viewer viewer_cursor = db.cursor() sql1 = """UPDATE Viewer SET DateOfBirth ="%s", Email = '%s' \ WHERE ViewerID = %s """ \ % (dob, email, sess.data["UserID"]) viewer_detail_cursor = db.cursor() sql2 = None # update CrowdFundingViewer if viewer_type == "C": sql2 = """UPDATE CrowdFundingViewer SET FirstName='%s', LastName='%s' \ WHERE ViewerID = %s """ \ % (first_name , last_name, sess.data["UserID"]) try: viewer_cursor.execute(sql1) if (sql2 != None): viewer_detail_cursor.execute(sql2) db.commit() except: # Rollback in case there is any error db.rollback() print "up rollback" # address is changed ---------------------------------------------------------------------------------------------------------------------------- if address_changed == 1 and a_num == 7: # update address address_cursor = db.cursor() address_sql = "INSERT INTO Address(AddressID, StreetNumber, StreetNumberSuffix, StreetName, StreetType, AddressType, AddressTypeIdentifier, \ MinorMunicipality, MajorMunicipality, GoverningDistrict, PostalArea, Country) \ VALUES (%s, %s, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')" \ % ("default", Street_num, Street_num_suffix, Street_name, Street_type, Address_type, Address_type_identifier, Minor, Major, District, Post, Country) # Commit if successs try: address_cursor.execute(address_sql) db.commit() print "Address is updated" except: # Rollback in case there is any error db.rollback() print "insert address -> rollback" # --------------------------------------------------------------------------- # update EndDate of last address update_last_viewer_date(db) # get address id just inserted new_id = new_address_id(db) # insert viewer address insert_viewer_address(db, new_id) print """
# Get the session and check if logged in sess = session.Session(expires=20*60, cookie_path='/') loggedIn = sess.data.get('loggedIn') # --------------------------------------------------------------------------------------------------------------------- # debug - what's in the session #print(sess.data) #sys.exit() if loggedIn: utility.redirect("home.py") else: utility.header("Login","home") print""" <div class="container marketing"> <div class="row featurette" > <div class="well"> <form class="bs-example form-horizontal" method="post" action="do_login.py"> <fieldset> <div class="form-group"> <div class="col-lg-5" col-lg-offset-5"> <p> <font size="4" color="red" > <b><u>Login</u></b> </font> </p> <p>{0}</p> </div> </div> </fieldset>
fingerengine.run() if len(fingerengine.fingerprints) is 0: continue utility.Msg("Fingerprinting completed.", LOG.UPDATE) # We've got the host fingerprinted, now kick off the # exploitation engine for the service utility.Msg("Loading auxiliary for '%s'..." % fingerengine.service, LOG.DEBUG) # execute the auxiliary engine auxengine(fingerengine) if __name__ == "__main__": utility.header() options = parse(sys.argv[1:]) utility.Msg("Started at %s" % (utility.timestamp())) # log the CLI args utility.log(' '.join(sys.argv)) try: prerun(options) if options.ip or options.input_list: run(options) postrun(options) except KeyboardInterrupt:
def main(): user_type = utility.header("Update Profile","player") info=sess.data loggedIn = info.get("loggedIn") if not loggedIn or info.get("UserType") == 'V': utility.redirect("home.py") else: db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) latest_address_cursor = db.cursor() current_address_cursor= db.cursor() sql1 = "select PlayerID, AddressID, StartDate, EndDate \ from PlayerAddress \ where PlayerID = %s and EndDate is null" \ % (sess.data["UserID"]) latest_address_cursor.execute(sql1) latest_address_row = latest_address_cursor.fetchone() sql2 = "select * from PlayerAddress \ inner join Player On Player.PlayerID = PlayerAddress.PlayerID \ inner join Address on Address.AddressID = PlayerAddress.AddressID \ where PlayerAddress.PlayerID = %s \ and PlayerAddress.AddressID = %s " \ % (latest_address_row[0], latest_address_row[1] ) current_address_cursor.execute(sql2) current_address_row = current_address_cursor.fetchone() Gamehandle = to_null(current_address_row[12]) Email = to_null(current_address_row[11]) Phone = to_null(current_address_row[13]) Voip = to_null(current_address_row[14]) Street_num = to_null(current_address_row[16]) Street_num_suffix = to_null(current_address_row[17]) Street_name = to_null(current_address_row[18]) Street_type = to_null(current_address_row[19]) Address_type = to_null(current_address_row[20]) Minor = to_null(current_address_row[22]) Major = to_null(current_address_row[23]) District = to_null(current_address_row[24]) Post = to_null(current_address_row[25]) Country = to_null(current_address_row[26]) # close after use db.close() generate_form(Gamehandle, Email, Phone, Voip, Street_num, Street_num_suffix, Street_name, Street_type, Address_type, Minor, Major, District, Post, Country)
Url = row[1] Price = row[2] Type = row[3] Instance_run_id = row[4] Game_id = row[5] cursor.execute("SELECT * FROM InstanceRun WHERE InstanceRunID=%s" % Instance_run_id) row = cursor.fetchone() Instance_run_name = row[2] cursor.execute("SELECT * FROM Game WHERE GameID=%s" % Game_id) row = cursor.fetchone() Game_name = row[1] utility.header("Video of {0}".format(Instance_run_name), "video") print """ <h3> Video %s from %s </h3> <ul> <li>Game: %s</li> <li>Type: %s</li> <li>Price: %s</li> %s </ul>""" % (Id, Instance_run_name, Game_name, Type, Price, ( "<li><a href=\"do_video_order.py?id={0}\">Watch This Video</a></li>". format(Id)) if Type != "free" else """<div class="embed-responsive embed-responsive-16by9"> <iframe class="embed-responsive-item" src={0}></iframe> </div>""" .format(Url))
sess = session.Session(expires=20*60, cookie_path='/') info=sess.data loggedIn = info.get("loggedIn") if not loggedIn or info.get("UserType") != 'A': utility.redirect("login.py") sys.exit(0) form = cgi.FieldStorage() # no id or distributor then back if not form.has_key("id"): utility.redirect("admin_add_GameShipment2.py") sys.exit(0) db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) cursor = db.cursor() ids=form.getlist("id") for id in ids: quantity=form[id+"Q"].value cursor.execute ("""insert into GameShipmentDetail values ({0},{1},{2})""".format(id,form["shipID"].value,quantity)) db.commit() utility.header("Shipment Logging Result","game") print """<br><br><br><br><h3>Your shipment logging is successful!</h3>""" print """<p><a href="admin_add_GameShipment.py">Back</a></p>""" utility.footer()
import sys, MySQLdb, utility, session, cgi sess = session.Session(expires=20 * 60, cookie_path='/') # check user identity info = sess.data loggedIn = info.get("loggedIn") if not loggedIn or info.get("UserType") != 'A': utility.redirect("login.py") sys.exit(0) utility.header("Log a Game Shipment", "game") print """ <h1>Log a Game Shipment</h1> <h3>Please select a distributor order of the shippment.</h3> <form method="post" action="admin_add_GameShipment2.py">""" print """ <div class="col-lg-5"> <select name="disOrder" class="form-control" id="select">""" # connect to database db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) cursor = db.cursor() cursor.execute("""select * from GameDistributorOrder""") rows = cursor.fetchall() for row in rows: cursor.execute(
import MySQLdb, utility utility.header("Games", "game") db = MySQLdb.connect("info20003db.eng.unimelb.edu.au", "info20003g15", "info20003g15_2014", "info20003g15", 3306) cursor = db.cursor() cursor.execute("SELECT * FROM Game") # fetch first row row = cursor.fetchone() while row is not None: Id = row[0] Game = row[1] Genre = row[2] Review = row[3] Star_rating = row[4] Cost = row[8] # fetch another one row = cursor.fetchone() print """ <hr class="featurette-divider"> <div class="row featurette"> <div class="col-md-5"> <img class="featurette-image img-responsive" src="game_pic_{1}.jpg" alt="Generic placeholder image"> </div>
Url = row[1] Price = row[2] Type = row[3] Instance_run_id = row[4] Game_id = row[5] cursor.execute("SELECT * FROM InstanceRun WHERE InstanceRunID=%s"%Instance_run_id) row = cursor.fetchone() Instance_run_name = row[2] cursor.execute("SELECT * FROM Game WHERE GameID=%s"%Game_id) row = cursor.fetchone() Game_name = row[1] utility.header("Video of {0}".format(Instance_run_name),"video") print """ <h3> Video %s from %s </h3> <ul> <li>Game: %s</li> <li>Type: %s</li> <li>Price: %s</li> %s </ul>"""%(Id, Instance_run_name, Game_name, Type, Price,("<li><a href=\"do_video_order.py?id={0}\">Watch This Video</a></li>".format(Id)) if Type!="free" else """<div class="embed-responsive embed-responsive-16by9"> <iframe class="embed-responsive-item" src={0}></iframe> </div>""".format(Url)) #API for video embedding key='Show{0}'.format(Id)
import utility, sys # check user identity usertype = utility.header("Administration","") if usertype != 'A': utility.redirect("login.py") sys.exit(0) print """ <div class="row featurette" > <div class="well"> <fieldset> <div class="form-group"> <div class="col-lg-8"> <p> <font size="6" color="White" > <b><i>Add new Game Distributor Address</i></b> </font> </p> </div> </div> <div class="form-group"> <div class="col-lg-6"> <p> <font size="4" color="red" > <b><u>Please fill all fields with *</u></b> </font> </p> </div> </div> </fieldset> <form class="bs-example form-horizontal" method=post action="do_admin_add_GameDistributorAddress.py"> <div class="form-group"> <label for="Street_num" class="col-lg-5 control-label">GameDistributor ID*</label>