Beispiel #1
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)
Beispiel #2
0
    def buyItem(this, packet):
        p = ByteArray(packet)
        fullItem = p.readShort()
        withFraises = p.readBool()
        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
        itemCheck = str(itemCat) + "|" + str(item)

        this.client.shopItems += str(
            fullItem) if this.client.shopItems == "" else "," + str(fullItem)
        price = this.getItemPromotion(
            itemCat, item,
            this.server.shopListCheck[str(itemCat) + "|" +
                                      str(item)][1 if withFraises else 0])

        if withFraises:
            this.client.shopFraises -= price
        else:
            this.client.shopCheeses -= price

        this.sendItemBuy(fullItem)
        this.sendShopList(True)
        this.client.sendAnimZelda(0, fullItem)
        this.checkUnlockShopTitle()
        this.checkUnlockShopBadge(fullItem)
Beispiel #3
0
    def sendGift(this, packet):
        p = ByteArray(packet)
        username, isShamanItem, fullItem, message = p.readUTF(), p.readBool(
        ), p.readShort(), p.readUTF()

        if not this.server.checkExistingUser(username):
            this.sendGiftResult(1, username)
        else:
            player = this.server.players.get(username)
            if player != None:
                found = player.shopModule.checkInShamanShop(
                    fullItem
                ) if isShamanItem else player.shopModule.checkInShop(fullItem)

                if found:
                    this.sendGiftResult(2, username)
                else:
                    this.server.lastGiftID += 1

                    player.sendPacket(
                        Identifiers.send.Shop_Gift,
                        ByteArray().writeInt(this.server.lastGiftID).writeUTF(
                            this.client.Username).writeUTF(
                                this.client.playerLook).writeBool(isShamanItem)
                        .writeShort(fullItem).writeUTF(message).toByteArray(),
                        True)

                    this.sendGiftResult(0, username)
                    this.server.shopGifts[this.server.lastGiftID] = [
                        this.client.Username, isShamanItem, fullItem
                    ]
                    this.client.shopFraises -= this.getShamanShopItemPrice(
                        fullItem) if isShamanItem else this.getShopItemPrice(
                            fullItem)
                    this.sendShopList(False)
            else:
                found = this.checkInPlayerShop(
                    "ShamanItems" if isShamanItem else "ShopItems", username,
                    fullItem)

                if found:
                    this.sendGiftResult(2, username)
                else:
                    this.Cursor.execute(
                        "select LastReceivedGifts from Users where Username = ?",
                        [username])
                    rs = this.Cursor.fetchone()
                    lastReceivedGifts = rs["LastReceivedGifts"]

                lastReceivedGifts = ("" if lastReceivedGifts == "" else
                                     lastReceivedGifts + "/") + "[" + "|".join(
                                         map(str, [
                                             this.client.Username,
                                             this.client.playerLook,
                                             isShamanItem, fullItem, message
                                         ]))

                this.Cursor.execute(
                    "update Users set LastReceivedGifts = ? where Username = ?",
                    [lastReceivedGifts, username])
Beispiel #4
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
Beispiel #5
0
    def customShamanItemBuy(this, packet):
        p = ByteArray(packet)
        fullItem, withFraises = p.readShort(), p.readBool()

        items = this.client.shamanItems.split(",")
        for shopItem in items:
            item = shopItem.split("_")[0] if "_" in shopItem else shopItem
            if fullItem == int(item):
                items[items.index(shopItem)] = shopItem + "_"
                break

        this.client.shamanItems = ",".join(items)

        if withFraises:
            this.client.shopFraises -= 150
        else:
            this.client.shopCheeses -= 4000

        this.sendShopList(False)
Beispiel #6
0
    def buyShamanItem(this, packet):
        p = ByteArray(packet)
        fullItem, withFraises = p.readShort(), p.readBool()
        itemStr = str(fullItem)
        itemCat = int(itemStr[len(itemStr) - 2:])
        item = int(itemStr[:len(itemStr) - 2])
        price = this.server.shamanShopListCheck[itemStr][
            1 if withFraises else 0]

        this.client.shamanItems += str(
            fullItem) if this.client.shamanItems == "" else "," + str(fullItem)

        if withFraises:
            this.client.shopFraises -= price
        else:
            this.client.shopCheeses -= price

        this.sendShopList(False)
        this.client.sendAnimZelda(1, fullItem)
Beispiel #7
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
Beispiel #8
0
    def giftResult(this, packet):
        p = ByteArray(packet)
        loc1, giftID, isOpen, message, loc2 = p.readShort(), p.readShort(
        ), p.readBool(), p.readUTF(), p.readByte()

        if isOpen:
            values = this.server.shopGifts[int(giftID)]
            player = this.server.players.get(str(values[0]))
            if player != None:
                player.sendMessageLangue("$DonItemRecu", this.client.Username)

            isShamanItem = bool(values[1])
            fullItem = int(values[2])

            if isShamanItem:
                itemStr = str(fullItem)
                itemCat = int(itemStr[len(itemStr) - 2:])
                item = int(itemStr[:len(itemStr) - 2])
                this.client.shamanItems += str(
                    fullItem
                ) if this.client.shamanItems == "" else "," + str(fullItem)
                this.sendShopList(False)
                this.client.sendAnimZelda(1, fullItem)
            else:
                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
                this.client.shopItems += str(
                    fullItem
                ) if this.client.shopItems == "" else "," + str(fullItem)
                this.client.sendAnimZelda(itemCat, item)
                this.checkUnlockShopTitle()
                this.checkUnlockShopBadge(fullItem)

        elif not message == "":
            values = this.server.shopGifts[int(giftID)]
            player = this.server.players.get(str(values[0]))
            if player != None:
                player.sendPacket(
                    Identifiers.send.Shop_GIft_Message,
                    ByteArray().writeShort(0).writeShort(giftID).writeUTF(
                        this.client.Username).writeBool(bool(
                            values[1])).writeShort(int(
                                values[2])).writeUTF(message).writeUTF(
                                    this.client.playerLook).toByteArray(),
                    True)
            else:
                this.Cursor.execute(
                    "select LastReceivedMessages from Users where Username = ?",
                    [str(values[0])])
                rs = this.Cursor.fetchone()
                lastReceivedMessages = rs["LastReceivedMessages"]

                lastReceivedMessages = (
                    "" if lastReceivedMessages == "" else
                    lastReceivedMessages + "/") + "[" + "|".join(
                        map(str, [
                            this.client.Username, values[1], values[2],
                            this.client.playerLook, message
                        ])) + "]"

                this.Cursor.execute(
                    "update Users set LastReceivedMessages = ? where Username = ?",
                    [lastReceivedMessages,
                     str(values[0])])
Beispiel #9
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()