#!/usr/bin/python import sys import sqlite3 from fce import * from PyQt4.QtGui import * from PyQt4.QtCore import * DEBUG=0 app=QApplication(sys.argv) mainWidget=QWidget() mainWidget.resize(1280,1024) mainWidget.setWindowTitle("BrmbarSAP - Edit user") mainWidget.setStyleSheet(STYLE_WIDGET) said=str(int(sys.argv[1])) san=brmSatanize(sys.argv[2]) sac=str(float(sys.argv[3])) sam=brmSatanize(sys.argv[4]) def brmStoreUser(mw=None): if DEBUG: print("brmStoreUser") le=mw.findChildren(QLineEdit) leid=str(le[-1].text()) lename=brmSatanize(le[0].text()) lecash=str(le[1].text()) lepass=hashlib.sha512(brmSatanize(le[2].text())).hexdigest() lenewpass=hashlib.sha512(brmSatanize(le[3].text())).hexdigest() lemail=str(le[4].text()) if lename=="": le[0].setStyleSheet(le[0].styleSheet()+STYLE_BADLE) return else: le[0].setStyleSheet(le[0].styleSheet()+STYLE_OKLE) if lecash=="": lecash="0" db=sqlite3.connect(BRMDB) dbc=db.cursor() # Usename already used? dbc.execute("SELECT id FROM users WHERE name='"+lename+"';") cname=dbc.fetchone() if cname!=None and str(cname[0])!=leid: db.close() le[0].setStyleSheet(le[0].styleSheet()+STYLE_BADLE) return else: le[0].setStyleSheet(le[0].styleSheet()+STYLE_OKLE) if leid=="0": # New user? dbc.execute("INSERT INTO users VALUES (NULL,'"+lename+"',"+lecash+"," "'"+lename+"','"+lenewpass+"','"+lemail+"');") db.commit() # Sync required before next insert if lecash!="0": # New credit? dbc.execute("INSERT INTO transactions VALUES (NULL,CURRENT_TIMESTAMP," "(SELECT id FROM users WHERE name='"+lename+"' LIMIT 1)," "0,1,"+lecash+",0);") else: # Existing user dbc.execute("SELECT pass,cash FROM users WHERE id="+leid+" LIMIT 1;") pswddb=dbc.fetchone() if lepass!=pswddb[0] and pswddb[0]!=NULL512: db.close() le[2].setText("") le[2].setStyleSheet(le[2].styleSheet()+STYLE_BADLE) return else: le[2].setStyleSheet(le[2].styleSheet()+STYLE_OKLE) if lename!="sachy_overflow": # Allow overflowers ignore the limit if ((int(pswddb[1])