def log_btn(self): username = self.username.get() password = self.password.get() db.cursor.execute( 'SELECT * FROM users WHERE username = %s AND password = %s', (username, password)) account = db.cursor.fetchone() if account: # set user status to ON and all other users to NULL # Keep track of which user is logged in on this device db.cursor.execute("UPDATE users SET status = NULL") db.cursor.execute( "UPDATE users SET status = 'ON' where username = '******'" % username) #check repScore and change if neccessary repScore = db.getRepScore() if repScore > 30: db.cursor.execute( "UPDATE users SET user_type = 'VIP' WHERE status = 'ON'") elif repScore < 25 and repScore > 0: db.cursor.execute( "UPDATE users SET user_type = 'OU' WHERE status = 'ON'") #Check if first time login db.cursor.execute( "SELECT login_time FROM users WHERE username = '******'" % username) firstLogin = db.cursor.fetchone()[0] if firstLogin == "FIRST": self.changePass() else: # Direct to user page based on type db.cursor.execute( "SELECT user_type FROM users WHERE username = '******'" % username) acct_type = db.cursor.fetchone()[0] if acct_type == "OU": self.ou() elif acct_type == "VIP": self.vip() elif acct_type == "SU": self.su() elif username == "" or password == "": messagebox.showwarning("Login Status", "All fields are required!") else: messagebox.showerror("Login Status", "Account does not exist!")
def __init__(self): self.win = Tk() self.win.title('Post Updates') self.win.configure(bg="#36393F") self.win.geometry('{}x{}'.format(600, 400)) #Get and store user info from database name = db.getName() db.cursor.execute("SELECT id FROM projects WHERE viewing = 'ON'") groupID = db.cursor.fetchone()[0] db.cursor.execute( "SELECT postid FROM posts WHERE group_id = '%s' ORDER BY postid DESC LIMIT 1" % groupID) postCount = db.cursor.fetchone()[0] tabooCount = db.getTabooCount() reputation = db.getRepScore() # Parent widget for the buttons self.buttons_frame = Frame(self.win) self.buttons_frame.configure(bg="black") self.buttons_frame.grid(row=0, column=0, sticky=W + E) self.btn_Image = Button(self.buttons_frame, text='Clear', command=self.clear) self.btn_Image.grid(row=0, column=0, padx=(10), pady=10) self.btn_File = Button(self.buttons_frame, text='File', command=self.open_file) self.btn_File.grid(row=0, column=2, padx=(10), pady=10) self.submit_btn = Button( self.buttons_frame, text='Submit', command=lambda: self.submit(name, groupID, postCount + 1, tabooCount, reputation)) self.submit_btn.grid(row=0, column=4, padx=(10), pady=10) self.frame = LabelFrame(self.win, text="Hive Post", padx=5, pady=5, bg="#36393F", fg="white") self.frame.grid(row=1, column=0, columnspan=3, padx=10, pady=10, sticky=E + W + N + S) self.win.columnconfigure(0, weight=1) self.win.rowconfigure(1, weight=1) self.frame.rowconfigure(0, weight=1) self.frame.columnconfigure(0, weight=1) # Create the textbox self.textbox = scrolledtext.ScrolledText(self.frame, width=40, height=10) self.textbox.grid(row=0, column=0, sticky=E + W + N + S) self.win.mainloop()
def initUI(self): # UI bckground Settings canvas = Canvas(self) self.master.title("Super User") self.pack(fill=BOTH, expand=TRUE) canvas.pack(fill=BOTH, expand=1) canvas.configure(bg='#36393F') #If user is kicked out db.cursor.execute("SELECT login_time FROM users WHERE status = 'ON'") lastTime = db.cursor.fetchone()[0] if lastTime == "LAST": messagebox.showwarning("Reminder", "This is the last time you can log in! Finish all required business before logging out as you may not log in again afterwards.") #Get and store user info from database name = db.getName() rep_score = db.getRepScore() tabooCount = db.getTabooCount() hello = "Hello " + name # scoreDisplay = "Reputation Score: " + str(rep_score) # db.cursor.close() # greeting for user canvas.create_text(120, 50, text = hello, font = ("Pursia",25), fill = "#7289DB") # display user score # canvas.create_text(120, 100, text = scoreDisplay, font = ("Pursia",15), # fill = "#7289DB") # Calculate dimensions: https://www.mathopenref.com/coordpolycalc.html user_select_1 = [674,401,587,351, 587,351,500,401, 500,401,500,501, 500,501,587,551, 587,551,674,501, 674,501,674,401] user_select_2 = [499,401,412,351, 412,351,325,401, 325,401,325,501, 325,501,412,551, 412,551,499,501, 499,501,499,401] user_select_3 = [587,250,500,200, 500,200,413,250, 413,250,413,350, 413,350,500,400, 500,400,587,350, 587,350,587,250] user_display_name = [552,370,500,340, 500,340,448,370, 448,370,448,430, 448,430,500,460, 500,460,552,430, 552,430,552,370] canvas.create_polygon(user_select_1, outline='black', fill='#2C92D6', width=2) canvas.create_polygon(user_select_2, outline='black', fill='#37CAEF', width=2) canvas.create_polygon(user_select_3, outline='black', fill='#3EDAD8', width=2) canvas.create_polygon(user_display_name, outline='black', fill='#ffffff', width=2) # hexagon for user select s1 = [412,325,390,312, 390,312,368,325, 368,325,368,350, 368,350,390,362, 390,362,412,350, 412,350,412,325] s2 = [632,325,610,312, 610,312,588,325, 588,325,588,350, 588,350,610,362, 610,362,632,350, 632,350,632,325] s3 = [522,515,500,502, 500,502,478,515, 478,515,478,540, 478,540,500,552, 500,552,522,540, 522,540,522,515] canvas.create_polygon(s1, fill='white', width=1) canvas.create_polygon(s2, fill='white', width=1) canvas.create_polygon(s3, fill='white', width=1) # Left Side Hexagon p1 = [97,388,75,375, 75,375,53,388, 53,388,53,413, 53,413,75,425, 75,425,97,413, 97,413,97,388] p2 = [97,463,75,450, 75,450,53,463, 53,463,53,488, 53,488,75,500, 75,500,97,488, 97,488,97,463] p3 = [97,538,75,525, 75,525,53,538, 53,538,53,563, 53,563,75,575, 75,575,97,563, 97,563,97,538] canvas.create_polygon(p1,fill='#2C92D6', width=1) canvas.create_polygon(p2,fill='#37CAEF', width=1) canvas.create_polygon(p3,fill='#3EDAD8', width=1) # Left labels canvas.create_text(125, 400, text = "My Projects", font = ("Pursia",15), fill = "white", anchor=W) canvas.create_text(125, 475, text = "Pending Users", font = ("Pursia",15), fill = "white",anchor=W) canvas.create_text(125, 550, text = "Evaluate Group", font = ("Pursia",15), fill = "white", anchor=W) # Right Side Hexagon g1 = [947,388,925,375, 925,375,903,388, 903,388,903,413, 903,413,925,425, 925,425,947,413, 947,413,947,388] g2 = [947,463,925,450, 925,450,903,463, 903,463,903,488, 903,488,925,500, 925,500,947,488, 947,488,947,463] g3 = [947,538,925,525, 925,525,903,538, 903,538,903,563, 903,563,925,575, 925,575,947,563, 947,563,947,538] canvas.create_polygon(g1, fill='white', width=1) canvas.create_polygon(g2, fill='white', width=1) canvas.create_polygon(g3, fill='white', width=1) # group Labels canvas.create_text(875, 400, text = "Comment", font = ("Pursia",15), fill = "white", anchor=E) canvas.create_text(875, 475, text = "Schedule", font = ("Pursia",15), fill = "white", anchor=E) canvas.create_text(875, 550, text = "Kick Out", font = ("Pursia",15), fill = "white", anchor=E) # display date date = datetime.datetime.now() current_date = date.strftime("%B %d") canvas.create_text(500, 385, text = current_date, font = ("Pursia",20), fill = "black") canvas.create_text(500, 415, text = " ", fill = "black", tags='timer') def time_now(): now = datetime.datetime.now() s = '{0:0>2d}:{1:0>2d}:{2:0>2d}'.format(now.hour, now.minute, now.second) canvas.itemconfig('timer', text = s) self.after(100, time_now) time_now()
from tkinter import * import mysql.connector import sys import db import checkForTaboo as checkT import reputationScore as repScore #Get and store user info from database name = db.getName() username = '******' + name + ']: ' db.cursor.execute("SELECT name FROM projects WHERE viewing = 'ON'") groupName = db.cursor.fetchone()[0] groupFileName = groupName + '_chat.txt' tabooCount = db.getTabooCount() reputation = db.getRepScore() # send message through button def Press_Button(name, tabooCount, reputation): get_input = input_field.get() messages.configure(state='normal') hasTaboo = checkT.check(get_input) post = get_input if hasTaboo: tabooCount += 1 newRep = repScore.tabooWord(reputation, tabooCount) db.cursor.execute( "Update users SET reputation_score = %s where username = %s", (newRep, name)) db.cursor.execute(