def profile(self, user): #profile page functions.checkLogged() #Open and read html file Page = functions.readHtml("profile") #Get online user list Page = functions.getUsers(cherrypy.session['username'], Page) data = functions.readUserData(user) #Displays user info Page += '<img src={} width="400" height="400"><br/>'.format(data[5]) Page += u"<b>Name: {}</b><br/>".format(data[1]) Page += u"<b>Position: {}</b><br/>".format(data[2]) Page += u"<b>Description: {}</b><br/>".format(data[3]) Page += u"<b>Location: {}</b><br/>".format(data[4]) if (cherrypy.session['username'] == user): #Button for profile editing Page += '<form action="/editProfile" method="post" enctype="multipart/form-data">' Page += '<input class= "button" type="submit" value="Edit Profile"/></form>' #Button to signout Page += '<form action="/logoff?username={0}&password={1}" method="post" enctype="multipart/form-data">'.format( cherrypy.session['username'], cherrypy.session['password']) Page += '<input class= "button" type="submit" value="Signout"/></form>' else: Page += '<form action="/profile" method="post" enctype="multipart/form-data">' Page += '<button name="user" value="{}" class="button"/>Return to Profile</button></form>'.format( cherrypy.session['username']) return Page
def login(self, ec=None): Page = functions.readHtml("login") try: if (ec == "2"): Page += "Your username and/or password was incorrect" elif (ec == "3"): Page += "You have supplied an incorrect location" except: pass return Page
def messaging(self, destination): functions.checkLogged() #Read the message html Page = functions.readHtml("messaginghead").format( cherrypy.session['username']) #Get online user list Page = functions.getUsers(cherrypy.session['username'], Page) db = sqlite3.connect("db/Conversation.db") cursor = db.cursor() #If it is the first time the user uses messaging, create a new table for that user cursor.execute( 'CREATE TABLE IF NOT EXISTS {}(UPI TEXT NOT NULL, Sender TEXT NOT NULL, Message TEXT NOT NULL, Stamp TEXT NOT NULL, Type TEXT NOT NULL)' .format(cherrypy.session['username'])) cursor.execute( 'SELECT * FROM {} WHERE UPI = ?'.format( cherrypy.session['username']), (destination, )) all_rows = cursor.fetchall() Page += '<div id="message-box" class="message-box">' for row in all_rows: #Display your messages in blue if (row[1] == cherrypy.session['username']): Page += '<span class="font-color1">' Page = functions.formatMessage(row[1], row[2], row[3], row[4], Page) Page += '</span>' #Display other person's message in red else: Page = functions.formatMessage(row[1], row[2], row[3], row[4], Page) db.close() Page += "</div>" #User input for message, and the send button Page += '<form action="/sendMessage"method="post" enctype="multipart/form-data">' Page += 'Message: <input type="text" id="input-box" name="message" required class="message-input"/><button name="destination" value="{0}" class="message-button"/>Send</button></form>'.format( destination) Page += '<form action="/sendFile"method="post" enctype="multipart/form-data">' Page += '<input type="file" name="fData" id="upload" required><button name="destination" value="{0}" class="message-button"/>Send File</button></form>'.format( destination) return Page
def index(self): return functions.readHtml("index")
def editProfile(self): functions.checkLogged() data = functions.readUserData(cherrypy.session['username']) Page = functions.readHtml("editProfile") return Page.format(data[1], data[2], data[3], data[4])