예제 #1
0
 def parsePacket(this, packet):
     code = packet.readShort()
     if code == 1:
         referidor, ip1, ip2, playerName = packet.readUTF(), packet.readUTF(
         ), packet.readUTF(), packet.readUTF()
         client = this.server.players.get(playerName)
         if client != None:
             print "[" + playerName + "]", referidor, ip1, ip2
             if client.nivel < 3:
                 client.referidor = referidor
                 client.fresasreferidos(referidor, ip1 != ip2)
             if ip1 == ip2:
                 packet = ByteArray().writeBoolean(
                     client.nivel < 3).writeUTF(client.playerName).writeUTF(
                         client.ipAddress).writeUTF(this.server.serverID)
                 this.sendPacket(2, packet.toByteArray())
     elif code == 2:
         keep = packet.readBoolean()
         cantidad = packet.readInt()
         if not keep: this.server.blackList = []
         for x in range(cantidad):
             site = packet.readUTF()
             this.server.blackList.append(site)
         this.server.log("[Frodo] Backlist: " +
                         str(len(this.server.blackList)) + " Sitios")
     elif code == 3:
         keep = packet.readBoolean()
         cantidad = packet.readInt()
         if not keep: this.server.whiteList = []
         for x in range(cantidad):
             site = packet.readUTF()
             this.server.whiteList.append(site)
         this.server.log("[Frodo] WhiteList: " +
                         str(len(this.server.whiteList)) + " Sitios")
예제 #2
0
def read_data(data):
    ba = ByteArray(data)
    #大端模式标准对齐方式
    ba.endian = "!"
    length = ba.readInt()

    print "length", length

    print "bytesAvailable", ba.bytesAvailable()

    #只用了1位字节存储 长度-128 - 127
    #业务大类
    actionName = ba.readByte()
    #具体业务类型
    type = ba.readByte()

    print "actionName", actionName
    print "type", type

    str = ba.readUTFBytes(3)
    print str


    i = ba.readInt()
    print i
예제 #3
0
 def lineReceived(self, line):
     print line
     ba = ByteArray(line)
     print ba.bytesAvailable()
     s = ba.readInt()
     print s
     s = ba.readUTFBytes(ba.bytesAvailable())
     print s
     self.factory.sendAll(self, line)
예제 #4
0
 def decode(self, data):
     ba = ByteArray(data)
     ba.endian = "!"
     #判断长度
     #print 'self.tempDataBuffer', self.tempDataBuffer
     if self.tempDataBuffer == "":
         self.id = ba.readInt()
         print self.id
         length = ba.readInt()
         s = ba.readUTFBytes(ba.bytesAvailable())
         print 'length', length, len(s)
         #判断长度
         if len(s) < length:
             self.tempDataBuffer = s
         else:
             print "content", s
             return {"id": self.id, "content": s}
     else:
         s = self.tempDataBuffer + ba.readUTFBytes(ba.bytesAvailable())
         print 'hebing', s
         return {"id": self.id, "content": s}
예제 #5
0
 def decode(self, data):
     ba = ByteArray(data)
     ba.endian = "!"
     #判断长度
     #print 'self.tempDataBuffer', self.tempDataBuffer
     if self.tempDataBuffer == "":
         self.id = ba.readInt()
         print self.id
         length = ba.readInt()
         s = ba.readUTFBytes(ba.bytesAvailable())
         print 'length', length, len(s)
         #判断长度
         if len(s) < length:
             self.tempDataBuffer = s
         else:
             print "content", s
             return {"id":self.id, "content":s}
     else:
         s = self.tempDataBuffer + ba.readUTFBytes(ba.bytesAvailable())
         print 'hebing', s
         return {"id":self.id, "content":s}
예제 #6
0
def read_data(data):
    ba = ByteArray(data)
    #大端模式标准对齐方式
    ba.endian = "!"
    length = ba.readInt()

    print "length", length

    print "bytesAvailable", ba.bytesAvailable()

    #只用了1位字节存储 长度-128 - 127
    #业务大类
    actionName = ba.readByte()
    #具体业务类型
    type = ba.readByte()

    print "actionName", actionName
    print "type", type

    str = ba.readUTFBytes(3)
    print str

    i = ba.readInt()
    print i
예제 #7
0
    def parseSkillPacket(this, skill, packet):
        p = ByteArray(packet)
        if this.client.isShaman:
            if skill == "fly":
                fly = p.readBool()
                this.sendShamanFly(fly)

            elif skill == "projection":
                posX = p.readShort()
                posY = p.readShort()
                dir = p.readShort()
                this.sendProjectionSkill(posX, posY, dir)

            elif skill == "demoliton":
                objectID = p.readInt()
                this.sendDemolitionSkill(objectID)

            elif skill == "convert":
                objectID = p.readInt()
                this.sendConvertSkill(objectID)
                        
            elif skill == "recycling":
                id = p.readShort()
                this.sendRecyclingSkill(id)
                        
            elif skill == "antigravity":
                objectID = p.readInt()
                this.sendAntigravitySkill(objectID)
                
            elif skill == "restorative":
                objectID = p.readInt()
                id = p.readInt()
                this.sendRestorativeSkill(objectID, id)
                
            elif skill == "handymouse":
                handyMouseByte = p.readByte()
                objectID = p.readInt()

                if this.client.room.lastHandymouse[0] == -1:
                    this.client.room.lastHandymouse = [objectID, handyMouseByte]
                else:
                    this.sendHandymouseSkill(handyMouseByte, objectID)
                    this.client.room.sendAllBin(Identifiers.send.Skill, chr(77) + chr(1))
                    this.client.room.lastHandymouse = [-1, -1]
                        
            elif skill == "gravitational":
                id = p.readInt()
                this.sendGravitationalSkill(0, id)
예제 #8
0
    def customItem(this, packet):
        p = ByteArray(packet)
        fullItem, length = p.readShort(), p.readByte()
        custom = length
        customs = list()

        i = 0
        while i < length:
            customs.append(p.readInt())
            i += 1

        items = this.client.shopItems.split(",")
        for shopItem in items:
            sItem = shopItem.split("_")[0] if "_" in shopItem else shopItem
            if fullItem == int(sItem):
                newCustoms = map(lambda color: "%06X" % (0xffffff & color),
                                 customs)

                items[items.index(
                    shopItem)] = sItem + "_" + "+".join(newCustoms)
                this.client.shopItems = ",".join(items)

                itemStr = str(fullItem)
                itemCat = (0 if fullItem / 10000 == 1 else fullItem /
                           10000) if len(itemStr) > 4 else fullItem / 100
                item = int(itemStr[2 if len(itemStr) > 3 else 1:]
                           ) if len(itemStr) >= 3 else fullItem
                equip = str(item) + this.getItemCustomization(fullItem, False)

                lookList = this.client.playerLook.split(";")
                lookItems = lookList[1].split(",")

                if "_" in lookItems[itemCat]:
                    if lookItems[itemCat].split("_")[0] == itemStr:
                        lookItems[itemCat] = equip

                elif lookItems[itemCat] == itemStr:
                    lookItems[itemCat] = equip

                this.client.playerLook = lookList[0] + ";" + ",".join(
                    lookItems)
                this.sendShopList(False)
                this.sendLookChange()
                break
예제 #9
0
    def customShamanItem(this, packet):
        p = ByteArray(packet)
        fullItem, length = p.readShort(), p.readByte()
        customs = list()

        i = 0
        while i < length:
            customs.append(p.readInt())
            i += 1

        items = this.client.shamanItems.split(",")
        for shopItem in items:
            sItem = shopItem.split("_")[0] if "_" in shopItem else shopItem
            if fullItem == int(sItem):
                newCustoms = map(lambda color: "%06X" % (0xffffff & color),
                                 customs)

                items[items.index(
                    shopItem)] = sItem + "_" + "+".join(newCustoms)
                this.client.shamanItems = ",".join(items)

                item = str(fullItem) + this.getItemCustomization(
                    fullItem, True)
                itemStr = str(fullItem)
                itemCat = int(itemStr[len(itemStr) - 2:])
                index = itemCat if itemCat <= 4 else itemCat - 1 if itemCat <= 7 else 7 if itemCat == 10 else 8 if itemCat == 17 else 9
                index -= 1
                lookItems = this.client.shamanLook.split(",")

                if "_" in lookItems[index]:
                    if lookItems[index].split("_")[0] == itemStr:
                        lookItems[index] = item

                elif lookItems[index] == itemStr:
                    lookItems[index] = item

                this.client.shamanLook = ",".join(lookItems)
                this.sendShopList(False)
                this.sendShamanLook()
                break
예제 #10
0
    def equipItem(this, packet):
        p = ByteArray(packet)
        fullItem = p.readInt()
        itemStr = str(fullItem)
        itemCat = (0 if fullItem / 10000 == 1 else fullItem /
                   10000) if len(itemStr) > 4 else fullItem / 100
        item = int(itemStr[2 if len(itemStr) > 3 else 1:]
                   ) if len(itemStr) >= 3 else fullItem
        itemStr = str(item)

        equip = str(item) + this.getItemCustomization(fullItem, False)

        lookList = this.client.playerLook.split(";")
        lookItems = lookList[1].split(",")
        lookCheckList = lookItems[:]
        idx = 0
        while idx < len(lookCheckList):
            lookCheckList[idx] = lookCheckList[idx].split(
                "_")[0] if "_" in lookCheckList[idx] else lookCheckList[idx]
            idx += 1

        if itemCat <= 10:
            if lookCheckList[itemCat] == itemStr:
                lookItems[itemCat] = "0"
            else:
                lookItems[itemCat] = str(equip)

        elif itemCat == 21:
            lookList[0] = "1"
            color = "bd9067" if item == 0 else "593618" if item == 1 else "8c887f" if item == 2 else "dfd8ce" if item == 3 else "4e443a" if item == 4 else "e3c07e" if item == 5 else "272220" if item == 6 else "78583a"
            this.client.MouseColor = "78583a" if this.client.MouseColor == color else color
        else:
            if lookList[0] == itemStr:
                lookList[0] = "1"
            else:
                lookList[0] = itemStr

        this.client.playerLook = lookList[0] + ";" + ",".join(
            map(str, lookItems))
        this.sendLookChange()
예제 #11
0
    def equipShamanItem(this, packet):
        p = ByteArray(packet)
        fullItem = p.readInt()
        item = str(fullItem) + this.getItemCustomization(fullItem, True)
        itemStr = str(fullItem)
        itemCat = int(itemStr[:len(itemStr) - 2])
        index = itemCat if itemCat <= 4 else itemCat - 1 if itemCat <= 7 else 7 if itemCat == 10 else 8 if itemCat == 17 else 9
        index -= 1
        lookItems = this.client.shamanLook.split(",")

        if "_" in lookItems[index]:
            if lookItems[index].split("_")[0] == itemStr:
                lookItems[index] = "0"
            else:
                lookItems[index] = item

        elif lookItems[index] == itemStr:
            lookItems[index] = "0"
        else:
            lookItems[index] = item

        this.client.shamanLook = ",".join(lookItems)
        this.sendShamanLook()
예제 #12
0
    def dataReceived(self, data):  # 446, 44442, 5557, 3726, 6114
        print data
        if data == "<policy-file-request/>\x00":
            self.transport.write(
                """<cross-domain-policy><allow-access-from domain="127.0.0.1" to-ports="443,44444,44440,5555,3724,6112" /></cross-domain-policy>\x00"""
            )

        else:

            opcode1 = data[4:5]
            opcode2 = data[5:6]
            opcodes = bytes([opcode1, opcode2])
            data = data[6:len(data)]
            print repr(opcodes)

            if opcode1 == "\x1c":

                if opcode2 == "\x01":
                    #Version
                    p = ByteArray(data)
                    v = p.readInt()
                    print v
                    if v == self.version:
                        #ForaList
                        self.versionValidated = True
                        self.online()
                        self.ForumsList()
                    else:
                        self.transport.connectionLost()
                elif opcode2 == "\x1c":
                    # Moderating Functions
                    self.RequireLevel(self.userTypeNeededForPeutModerer)
                    p = ByteArray(data)
                    params = p.readUTF().split(",")
                    if params[0] == "[E]renommer_sujet":
                        # Thread Rename
                        thread_id, message_id, new_title = params[
                            1], p.readShort(), p.readUTF()
                        dbcur.execute(
                            "INSERT INTO forum_log VALUES(?, ?, ?, ?, ?)", [
                                self.username, self.forum_id, thread_id,
                                message_id, "Konu İsmi", new_title,
                                "Olarak Değiştirildi."
                            ])
                        dbcur.execute(
                            "UPDATE forum_threads SET topic = ? WHERE thread_id = ?",
                            [new_title, thread_id])
                        self.openThread(int(thread_id), 0)
                    elif params[0] == "[E]mute":
                        # Kullanıcı susturma
                        mm = int(params[1])
                        ms = int(params[3])
                        mn = str(params[2])
                        fi = int(params[4])
                        ki = int(params[5])
                        mi = int(params[6])
                        p = ByteArray(data.split("\x01")[1])
                        sebep = p.readUTF()
                        if ms == 0:
                            if mn in om:
                                om.remove(mn)
                            dbcur.execute(
                                "DELETE FROM forum_mute where isim = ?", [mn])
                            self.message_forum(
                                mn + " Adlı Kullanıcının Mute'si Kaldırıldı.")
                        else:

                            if mm == 1:
                                dbcur.execute(
                                    'select * from forum_mute where isim = ?',
                                    [mn])
                                rrf = dbcur.fetchone()
                                if rrf is None:

                                    mod = "isim"

                                    if mn in nlol.online:
                                        md = "Online"
                                        om.append(mn)
                                    else:
                                        md = "Offline"
                                    self.message_forum(
                                        mn + " Adlı Kullanıcı " + str(ms) +
                                        " Saat Boyunca Mutelendi.")
                                    dbcur.execute(
                                        "INSERT INTO forum_mute VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
                                        [
                                            self.username, mn, fi, ki, mi,
                                            sebep, "ip",
                                            time.time(), ms, md
                                        ])
                                else:
                                    self.message_forum(
                                        rrf[1] + " " + rrf[0] +
                                        " Tarafından Mutelenmiş Zaten")
                            else:
                                self.message_forum(
                                    "Şimdilik Sadece Oyuncu Mutelenebiliyor ^_^"
                                )

                    elif params[0] == "deplacer_sujet":
                        # Thread Replace
                        thread_id, forum_id = int(params[1]), int(params[2])
                        dbcur.execute(
                            "INSERT INTO forum_log VALUES(?, ?, ?, ?, ?)", [
                                self.username, self.forum_id, thread_id, "",
                                "Konu " + forum_id + " Forumuna Taşındı."
                            ])
                        dbcur.execute(
                            "UPDATE forum_threads SET forum_id = ? WHERE thread_id = ?",
                            [forum_id, thread_id])
                        dbcur.execute(
                            "UPDATE forum_comments SET forum_id = ? WHERE thread_id = ?",
                            [forum_id, thread_id])

                        self.openForums(forum_id, 0)
                        self.openThread(thread_id, 0)

            elif self.versionValidated:
                print opcode1 + " - " + opcode2

                if opcode1 == "\x02":
                    if opcode2 == "\x03":
                        # REQUEST_FORUMS_LIST
                        self.online()
                        self.ForumsList()
                    elif opcode2 == "\x04":
                        # REQUEST_THREAD_LIST
                        p = ByteArray(data)
                        forum_id = p.readInt()
                        page = p.readInt()
                        self.forum_id = forum_id
                        self.openForums(forum_id, page)
                    elif opcode2 == "\x05":
                        print "rophl"
                        # REQUEST_MESSAGE_LIST
                        p = ByteArray(data)
                        thread_id = p.readInt()
                        page = p.readShort()
                        self.page = page
                        self.thread_id = thread_id
                        self.openThread(thread_id, page)

                elif opcode1 == "\x04":
                    if opcode2 == "\x02":
                        # New Thread
                        p = ByteArray(data)
                        forum_id = p.readInt()
                        self.forum_id = forum_id
                        if self.forum_id == 1:
                            self.RequireLevel(
                                self.userTypeNeededForPeutModerer)
                        threadTitle = str(p.readUTF()).decode(
                            'utf-8', 'replace')
                        message_utf = str(p.readLongString()).decode(
                            'utf-8', 'replace')
                        dbcur.execute(
                            "INSERT INTO forum_threads VALUES (?, NULL, ?, ?, ?, ?, 0, 0)",
                            [
                                int(forum_id), threadTitle,
                                str(time.time()).replace('.', '')[:10],
                                self.username, self.username
                            ])
                        thread_id = dbcur.lastrowid
                        self.thread_id = thread_id
                        dbcur.execute(
                            "INSERT INTO forum_comments VALUES (?, ?, NULL, ?, ?, ?, ?, 0, '', '')",
                            [
                                int(forum_id), thread_id, self.username,
                                threadTitle, message_utf,
                                str(time.time()).replace('.', '')[:10]
                            ])
                        self.openForums(self.forum_id, 0)
                        self.openThread(thread_id, 0)

                    elif opcode2 == "\x04":
                        # Repondre Sujet
                        p = ByteArray(data)
                        thread_id = p.readInt()
                        message_utf = str(p.readLongString()).decode(
                            'utf-8', 'replace')
                        dbcur.execute(
                            "INSERT INTO forum_comments VALUES (?, ?, NULL, ?, ' ', ?, ?, 0, '', '')",
                            [
                                self.forum_id, thread_id, self.username,
                                message_utf,
                                str(time.time()).replace('.', '')[:10]
                            ])

                        self.openThread(thread_id, 0)
                    elif opcode2 == "\x06":
                        # Message Edit
                        # needed edit for long string
                        self.RequireLevel(self.userTypeNeededForPeutModerer)

                        p = ByteArray(data)
                        thread_id = p.readInt()
                        message_id = p.readInt()
                        message_utf = str(p.readLongString()).decode(
                            'utf-8', 'replace')
                        dbcur.execute(
                            "SELECT * FROM forum_comments WHERE thread_id = ? AND message_id = ? AND username = ?",
                            [thread_id, message_id, self.username])
                        if len(dbcur.fetchall()) == 0:
                            self.RequireLevel(
                                self.userTypeNeededForPeutModerer)
                        dbcur.execute(
                            "INSERT INTO forum_log VALUES(?, ?, ?, ?, ?)", [
                                self.username, self.forum_id, thread_id,
                                message_id, message_utf
                            ])
                        dbcur.execute(
                            "UPDATE forum_comments SET message = ? WHERE thread_id = ? AND message_id = ?;",
                            [message_utf, thread_id, message_id])

                        self.openThread(thread_id, 0)
                elif opcode1 == "\x28":
                    if opcode2 == "\x02":
                        # Auth
                        p = ByteArray(data)
                        username, passwordHash = p.readUTF(), p.readUTF()
                        p = ByteArray("\x28\x02")
                        #print passwordHash
                        valid, forumPriv, validUsername = self.authenticate(
                            username,
                            hashlib.sha512(passwordHash).hexdigest())
                        p.writeByte(valid)
                        if valid != 0:
                            username = username.lower()
                            username = username.capitalize()
                            dbcur.execute(
                                "SELECT isim FROM forum_sentinel WHERE isim = ?",
                                [username])
                            sd = dbcur.fetchone()
                            try:
                                za = sd[0]
                                self.sentinel = True
                                forumPriv = 11
                            except:
                                pass
                            self.username = str(validUsername)
                            self.user_type = forumPriv
                            p.writeUTF(self.username)
                            p.writeInt(10000)
                            p.writeInt(forumPriv)
                            nlol.online.append(self.username)
                            self.login = True
                            self.mc()  #Mute Controller
                        self.transport.write(p.toPack())
                        self.online()

                    elif opcode2 == "\x16":
                        p = ByteArray(data)
                        ri, fa, fi, ti, ci, rml = p.readUTF(), p.readUTF(
                        ), p.readInt(), p.readInt(), p.readInt(), p.readUTF()
                        print ri, fa, fi, ti, ci, rml
                        self.message_forum(
                            "Raporlama Sistemi Daha Hazır Değil ^_^")
                        #### Bu Kod Rapor Kodudur Ancak Daha Bitmemiştir.####
                    elif opcode2 == "\n":

                        file = open("avatars/" + self.username + ".png", 'wb')
                        file.write(data)

                        file = open("avatars/" + self.username + ".png", 'rb')
                        img = Image.open(file)
                        img.load()
                        img.thumbnail((100, 100), Image.ANTIALIAS)
                        img.save("./avatars/" + self.username + "_Resize.png")

                        data = open("avatars/" + self.username + "_Resize.png",
                                    "rb")
                        upload.upload_file(self.username + ".png", data)

                    elif opcode2 == "\x0a":
                        # Avatar Change
                        try:
                            pass


##                            file = open("avatars/"+self.username+".png", 'wb')
##                            file.write(data)
##                            basewidth = 100
##                            img = Image.open(StringIO.StringIO(file))
##                            wpercent = (basewidth/float(img.size[0]))
##                            hsize = int((float(img.size[1])*float(wpercent)))
##                            img = img.resize((basewidth,hsize), PIL.Image.ANTIALIAS)
##                            img.save("avatars/"+self.username+".png")
                        except:
                            pass

                    elif opcode2 == "\x0b":
                        # Close Theme
                        if not self.sentinel:
                            self.RequireLevel(
                                self.userTypeNeededForPeutModerer)
                        else:
                            if not str(self.forum_id) in self.sf:
                                self.RequireLevel(
                                    self.userTypeNeededForPeutModerer)
                        p = ByteArray(data)
                        thread_id, closed = p.readInt(), p.readBoolean()
                        dbcur.execute(
                            "SELECT closed FROM forum_threads where thread_id=?",
                            [thread_id])
                        if int(dbcur.fetchone()[0]) == 0:
                            dbcur.execute(
                                "INSERT INTO forum_log VALUES(?, ?, ?, ?, ?)",
                                [
                                    self.username, self.forum_id, thread_id,
                                    "", "Konu Kilitlendi."
                                ])
                            dbcur.execute(
                                "UPDATE forum_threads SET closed=1 WHERE thread_id = ?",
                                [thread_id])
                        else:
                            dbcur.execute(
                                "INSERT INTO forum_log VALUES(?, ?, ?, ?, ?)",
                                [
                                    self.username, self.forum_id, thread_id,
                                    "", "Konu Kilidi Kaldırıldı."
                                ])
                            dbcur.execute(
                                "UPDATE forum_threads SET closed=0 WHERE thread_id = ?",
                                [thread_id])
                        if closed:
                            dbcur.execute(
                                "INSERT INTO forum_log VALUES(?, ?, ?, ?, ?)",
                                [
                                    self.username, self.forum_id, thread_id,
                                    "", "Konu Arşive Taşındı."
                                ])
                            dbcur.execute(
                                "UPDATE forum_threads SET forum_id = ? WHERE thread_id = ?",
                                [611, thread_id])
                            dbcur.execute(
                                "UPDATE forum_comments SET forum_id = ? WHERE thread_id = ?",
                                [611, thread_id])
                            self.forum_id = 611

                        self.openForums(self.forum_id, 0)
                        self.openThread(thread_id, 0)

                    elif opcode2 == "\x0c":
                        # Stick Theme
                        if not self.sentinel:
                            self.RequireLevel(
                                self.userTypeNeededForPeutModerer)
                        else:
                            if not str(self.forum_id) in self.sf:
                                self.RequireLevel(
                                    self.userTypeNeededForPeutModerer)
                        p = ByteArray(data)
                        thread_id = p.readInt()
                        dbcur.execute(
                            "SELECT sticky FROM forum_threads where thread_id=?",
                            [thread_id])
                        if int(dbcur.fetchone()[0]) == 0:
                            dbcur.execute(
                                "INSERT INTO forum_log VALUES(?, ?, ?, ?, ?)",
                                [
                                    self.username, self.forum_id, thread_id,
                                    "", "Konu Sabitlendi."
                                ])
                            dbcur.execute(
                                "UPDATE forum_threads SET sticky=1 WHERE thread_id = ?",
                                [thread_id])
                        else:
                            dbcur.execute(
                                "INSERT INTO forum_log VALUES(?, ?, ?, ?, ?)",
                                [
                                    self.username, self.forum_id, thread_id,
                                    "", "Konu Sabit'ten Çıkarıldı."
                                ])
                            dbcur.execute(
                                "UPDATE forum_threads SET sticky=0 WHERE thread_id = ?",
                                [thread_id])
                        self.openForums(self.forum_id, 0)
                        self.openThread(thread_id, 0)

                    elif opcode2 == "\x0f":
                        # Moderate theme
                        self.RequireLevel(self.userTypeNeededForPeutModerer)
                        p = ByteArray(data)
                        thread_id = p.readInt()
                        message_id = p.readInt()
                        type_modere = p.readInt()
                        comment = p.readUTF()

                        dbcur.execute(
                            "INSERT INTO forum_log VALUES(?, ?, ?, ?, ?)", [
                                self.username, self.forum_id, thread_id,
                                message_id, comment
                            ])

                        if type_modere == 0:
                            # Unsupperme Message
                            dbcur.execute(
                                "UPDATE forum_comments SET deleted=0, nomModerateur='', reason='' WHERE thread_id = ? AND message_id = ?",
                                [thread_id, message_id])

                        if type_modere == 1:
                            # Supperme Message
                            dbcur.execute(
                                "UPDATE forum_comments SET deleted=1, nomModerateur=?, reason=? WHERE thread_id = ? AND message_id = ?",
                                [
                                    self.username, comment, thread_id,
                                    message_id
                                ])

                        if type_modere == 2:
                            # Delete Message
                            dbcur.execute(
                                "UPDATE forum_comments SET deleted=2, nomModerateur=?, reason=? WHERE thread_id = ? AND message_id = ?",
                                [
                                    self.username, comment, thread_id,
                                    message_id
                                ])

                        self.openForums(self.forum_id, 0)
                        self.openThread(thread_id, 0)

                    elif opcode2 == "\x10":
                        # Moderer > 1 message
                        self.RequireLevel(self.userTypeNeededForPeutModerer)
                        p = ByteArray(data)
                        username = p.readUTF()
                        type_modere = p.readInt()
                        comment = p.readUTF()
                        dbcur.execute(
                            "INSERT INTO forum_log VALUES(?, ?, ?, ?, ?)",
                            [self.username, self.forum_id, "", "", comment])

                        if type_modere == 0:
                            # Unsupperme Message
                            dbcur.execute(
                                "UPDATE forum_comments SET deleted=0, nomModerateur='', reason='' WHERE username = ?",
                                [username])

                        if type_modere == 1:
                            # Supperme Message
                            dbcur.execute(
                                "UPDATE forum_comments SET deleted=1, nomModerateur=?, reason=? WHERE username = ?",
                                [self.username, comment, username])

                        if type_modere == 2:
                            # Delete Message
                            dbcur.execute(
                                "UPDATE forum_comments SET deleted=2, nomModerateur=?, reason=? WHERE username = ?",
                                [self.username, comment, username])

                    elif opcode2 == "\x17":
                        # Sanctions # In progress...
                        self.message_forum("You has no sanctions.")

                    elif opcode2 == "\x28":
                        # Online
                        threading.Timer(15.0, self.online).start()
                        #self.online()
                elif opcode1 == "(":
                    print repr(opcode2)
                    print repr(data)
                else:
                    pass  #print repr(data)
            else:
                self.transport.connectionLost()