Skip to content

Commit

Permalink
20 mai 2017 #6
Browse files Browse the repository at this point in the history
  • Loading branch information
loicdm committed May 21, 2017
1 parent e25d7ca commit 29ea955
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
31 changes: 31 additions & 0 deletions functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,37 @@ def get_channel_id(tablename):
return "err"


def rename_chan(userinput, self):
username = userinput[1]
userpassword = userinput[2]
channel = userinput[3]
password = userinput[4]
new_channel_name = userinput[5]
tablename = "channel_" + str(channel)
if check_login(username, self) is True and check_password_user(username, userpassword,
self) is True and check_password_channel(channel,
password,
self) is True and check_chan_owner(
channel, username) is True:
try:
cnx = connect_db(0)
cursor = cnx.cursor()
SQL = ("""UPDATE """ + readcfg(
['DATABASE', 'database_channels']) + """.channels_infos SET channel_name = '""" + str(
new_channel_name) + """' WHERE channels_infos.id = '""" + channel + """';""")
for query in cursor.execute(SQL, multi=True):
pass
cnx.commit()
cursor.close()
cnx.close()
self.clientsocket.send(pickle.dumps(True))
except mysql.connector.Error as err:
print(err)
self.clientsocket.send(pickle.dumps("err3"))
else:
self.clientsocket.send(pickle.dumps(False))


def get_chan_name(userinput, self):
id = str(userinput[1])
try:
Expand Down
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# coding: utf-8
from functions import *

version = "1.0.3"
version = "1.0.4"

check_cfg()
check_db()
Expand Down Expand Up @@ -55,6 +55,8 @@ def run(self):
self.clientsocket.send(pickle.dumps(True))
else:
self.clientsocket.send(pickle.dumps(False))
if command == "rename_chan":
rename_chan(received_message, self)


tcpsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Expand Down

0 comments on commit 29ea955

Please sign in to comment.