Advertisement
j7sx

step1

Apr 28th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.61 KB | None | 0 0
  1. #!/usr/bin/python
  2. #--*--coding: utf-8--*--
  3.  
  4. import cgi
  5. import MySQLdb
  6. import user
  7. from dbconfig import read_param, game_server
  8. from premium_user import isPremiumUser
  9.  
  10. status, username = user.isAuth()
  11. premium_account = isPremiumUser()
  12.  
  13. form = cgi.FieldStorage()
  14. if form.getvalue("char_select"):
  15.     player = form.getvalue("char_select")
  16.    
  17. dict_with_all_good_items = {57:"Adena", 5:"DC gloves", 8:"DC helmet"}
  18.  
  19. all_good_items = set()
  20.  
  21. for i in dict_with_all_good_items.keys():
  22.     all_good_items.add(i)
  23.  
  24. if status:
  25.     if premium_account:
  26.         db_config = game_server()
  27.         db = MySQLdb.connect(**db_config)
  28.         cursor = db.cursor()
  29.         cursor.execute("SELECT charId FROM characters WHERE char_name=%s", (player))
  30.         owner = cursor.fetchone()
  31.         owner = int(owner[0])
  32.         cursor.execute("SELECT item_id FROM items WHERE owner_id=%s AND loc=%s", (owner, 'INVENTORY'))
  33.         items = cursor.fetchall()
  34.         user_items = set()
  35.         for item in items:
  36.             user_items.add(item[0])
  37.         user_access_items = (all_good_items & user_items)
  38.         print "<center><h3>Шаг 2-й:</h3>"
  39.         print "Выберите итем для продажи"
  40.         print "<form action=\"step2.cgi\" method=\"post\">"
  41.         print "<select name=\"item_select\">"
  42.         for i in user_access_items:
  43.             u = dict_with_all_good_items[i]
  44.             print """
  45.                    <option value="%s">%s</option>
  46.                    """ % (i, u)
  47.         print """</select><br><br>
  48.                   <input type="submit" value="Дальше"> """
  49.         db.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement