Guest User

Untitled

a guest
May 15th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.66 KB | None | 0 0
  1. def doAuthentification():
  2.     global expDate
  3.     global enableCoolFeatures
  4.     failedConnecting = False
  5.     try:
  6.         connectString = (
  7.         "DRIVER={MySQL ODBC 3.51 Driver};"
  8.         "SERVER=auth.server.ip;"
  9.         "PORT=3306;"
  10.         "DATABASE=authdatabase;"
  11.         "USER=authuser;"
  12.         "PASSWORD=authpass;"
  13.         "OPTION=3;"
  14.         )
  15.         query = "SELECT * FROM authtable"
  16.         connection = OdbcConnection(connectString)
  17.         adaptor = OdbcDataAdapter(query, connection)
  18.         dataSet = DataSet()
  19.         connection.Open()
  20.         adaptor.Fill(dataSet)
  21.         rows = []
  22.         for row in dataSet.Tables[0].Rows:
  23.             rows.append(list(row))
  24.     except:
  25.         if failedConnecting==False:
  26.             failedConnecting = True
  27.     if failedConnecting == False:
  28.         licensedUser = ""
  29.         try:
  30.             for _row in rows:
  31.                 userFound = ((Player._Tools.UserMatch([str(_row[1])]) == True) |  (str(_row[1])=="Demo"))
  32.                 if userFound:
  33.                     if expDate < DateTime.SpecifyKind(_row[2],DateTimeKind.Utc).ToLocalTime():
  34.                         expDate = DateTime.SpecifyKind(_row[2],DateTimeKind.Utc).ToLocalTime()
  35.                         licensedUser = str(_row[1])                                      
  36.             connection.Close()
  37.         except:
  38.             pass
  39.         localDate = DateTime.SpecifyKind(DateTime.Now,DateTimeKind.Local)
  40.         if localDate<=expDate:
  41.             if enableCoolFeatures == False:
  42.                 enableCoolFeatures = True
  43.                 Player._Tools.Log("license issued to "+licensedUser)
  44.         else:
  45.             enableCoolFeatures = False
Add Comment
Please, Sign In to add comment