def clicked(event=None): username = entry1.get() password = entry2.get() pass1 = encrypt_code(password) uname = str(username) ip=server_config(6) sql = "select * from users where username='******'" result = db_point(sql) if result: for x in result: pass2 = x[2] utype = x[3] eid = x[0] eid=str(eid) if pass1 == pass2: if utype == "standard": print(uname+" Logged in as standard user") update_ip(eid, ip) print(ip) label4.configure(text="Login Success!") user = "******" master.destroy() os.system(user+" "+eid) elif utype == "admin": print(uname+" Logged in as admin") update_ip(eid, ip) user = "******" master.destroy() os.system(user+" "+eid) label4.configure(text="Login Success!") else: messagebox.showerror('Login Failure', 'Invalid Password') else: messagebox.showerror('Login Failure', 'Invalid Username') entry1.delete(0, 'end') entry2.delete(0, 'end')
# server2.py import socket from threading import Thread from socketserver import ThreadingMixIn from test import server_config TCP_IP = server_config(1) TCP_PORT = server_config(5) BUFFER_SIZE = 1024 class ClientThread(Thread): def __init__(self, ip, port, sock): Thread.__init__(self) self.ip = ip self.port = port self.sock = sock print(" New thread started for " + 'ip' + ":" + str(port)) def run(self): filename = 'mytext.txt' f = open(filename, 'rb') while True: l = f.read(BUFFER_SIZE) while (l): self.sock.send(l) #print('Sent ',repr(l)) l = f.read(BUFFER_SIZE) if not l: f.close() self.sock.close() break
msg_list.pack(side=tkinter.LEFT, fill=tkinter.BOTH) msg_list.pack() messages_frame.pack() entry_field = tkinter.Entry(top, textvariable=my_msg) entry_field.bind("<Return>", send) entry_field.pack() send_button = tkinter.Button(top, text="Send", command=send) send_button.pack() #sql_query query = "SELECT sender_name,message_body FROM personal_chat WHERE (`sender_id`='" + sen_id + "' and `receiver_id`='" + rec_id + "') OR (`sender_id`='" + rec_id + "' and `receiver_id`='" + sen_id + "') ORDER BY `time` ASC" sql = query cursor.execute(sql) result = cursor.fetchall() for x in result: print(str(x[0])) msg_list.insert(tkinter.END, x[0] + " : " + x[1]) #Socket part #HOST = input('Enter host: ') # Enter host of the server without inverted commas HOST = server_config(1) PORT = server_config(4) BUFSIZ = 1024 ADDR = (HOST, PORT) client_socket = socket(AF_INET, SOCK_STREAM) client_socket.connect(ADDR) ReceiveThread = Thread(target=receive).start() SendThread = Thread(target=send).start() tkinter.mainloop() # for start of GUI Interface
from threading import Thread import datetime from DatabaseQuery import * from socket import AF_INET, SOCK_STREAM, socket from test import server_config, split HOST = server_config(1) PORT = server_config(4) uname = "" addresses = {} clients = {} eid = {} rec_Id = "" HOSTA = server_config(1) PORTA = server_config(3) BufferSize = 4096 addressesa = {} def AConnections(): while True: try: client, addr = serverAudio.accept() print("{} is connected(audio connection)!!".format(addr)) addressesa[client] = addr Thread(target=ClientConnectionSound, args=(client, )).start() except: continue
from socket import socket, AF_INET, SOCK_STREAM from imutils.video import WebcamVideoStream import pyaudio from array import array from threading import Thread import numpy as np import zlib import struct import cv2 from test import server_config HOST = server_config(1) PORT_VIDEO = server_config(2) PORT_AUDIO = server_config(3) BufferSize = 4096 CHUNK = 1024 lnF = 640 * 480 * 3 FORMAT = pyaudio.paInt16 CHANNELS = 2 RATE = 44100 def SendAudio(): while True: data = stream.read(CHUNK) dataChunk = array('h', data) vol = max(dataChunk) if (vol > 500): print("Recording Sound...") else:
import mysql.connector from test import split, server_config, encrypt_code # Db object mydb = mysql.connector.connect( host=server_config(6), # central db user="******", passwd="root", database="be_project") cursor = mydb.cursor() def db_point(a): cursor.execute(a) result = cursor.fetchall() return result def emp_ip(a, i=0): if i == 1: ip = 0 query = "select ip_address from employee where emp_id=" + a result = db_point(query) for x in result: ip = x[0] return ip elif i == 2: query = "select status from employee where emp_id=" + a result = db_point(query) status = "" for x in result: status = x[0]
height=30, width=100, yscrollcommand=scrollbar.set) scrollbar.pack(side=tkinter.RIGHT, fill=tkinter.Y) msg_list.pack(side=tkinter.LEFT, fill=tkinter.BOTH) msg_list.pack() messages_frame.pack() entry_field = tkinter.Entry(top, textvariable=my_msg) entry_field.bind("<Return>", send) entry_field.pack() send_button = tkinter.Button(top, text="Send", command=send) send_button.pack() t = 3 a, i = message_populate(str(t)) # code to populate previous messages j = 0 while j < i: msg_list.insert(tkinter.END, a[j]) j += 1 # Socket part HOST, PORT = server_config() BUFSIZ = 1024 ADDR = (HOST, PORT) client_socket = socket(AF_INET, SOCK_STREAM) client_socket.connect(ADDR) ReceiveThread = Thread(target=receive).start() SendThread = Thread(target=send).start() tkinter.mainloop() # for start of GUI Interface