Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def doAuthentification():
- global expDate
- global enableCoolFeatures
- failedConnecting = False
- try:
- connectString = (
- "DRIVER={MySQL ODBC 3.51 Driver};"
- "SERVER=auth.server.ip;"
- "PORT=3306;"
- "DATABASE=authdatabase;"
- "USER=authuser;"
- "PASSWORD=authpass;"
- "OPTION=3;"
- )
- query = "SELECT * FROM authtable"
- connection = OdbcConnection(connectString)
- adaptor = OdbcDataAdapter(query, connection)
- dataSet = DataSet()
- connection.Open()
- adaptor.Fill(dataSet)
- rows = []
- for row in dataSet.Tables[0].Rows:
- rows.append(list(row))
- except:
- if failedConnecting==False:
- failedConnecting = True
- if failedConnecting == False:
- licensedUser = ""
- try:
- for _row in rows:
- userFound = ((Player._Tools.UserMatch([str(_row[1])]) == True) | (str(_row[1])=="Demo"))
- if userFound:
- if expDate < DateTime.SpecifyKind(_row[2],DateTimeKind.Utc).ToLocalTime():
- expDate = DateTime.SpecifyKind(_row[2],DateTimeKind.Utc).ToLocalTime()
- licensedUser = str(_row[1])
- connection.Close()
- except:
- pass
- localDate = DateTime.SpecifyKind(DateTime.Now,DateTimeKind.Local)
- if localDate<=expDate:
- if enableCoolFeatures == False:
- enableCoolFeatures = True
- Player._Tools.Log("license issued to "+licensedUser)
- else:
- enableCoolFeatures = False
Add Comment
Please, Sign In to add comment