def onUpdateDatabase(current, version): # Find the update table for the database driver in use driver = database.driver(WORLD) if driver == 'mysql': updates = MYSQL_UPDATES elif driver == 'sqlite': updates = SQLITE_UPDATES else: console.log(LOG_ERROR, "Unknown database driver: %s.\n" % driver) return False for i in range(version, current): # No update for this version available if not updates.has_key(i): console.log(LOG_ERROR, "No update available for database version %u.\n" % i) return False console.log(LOG_MESSAGE, "Updating database from version %u to %u.\n" % (i, i+1)) try: if not updates[i](): return False except Exception, e: console.log(LOG_ERROR, str(e) + "\n") return False wolfpack.setoption('db_version', str(i + 1)) try: if driver == 'mysql': database.execute("REPLACE INTO `settings` VALUES('db_version', '%u');" % (i + 1)) elif driver == 'sqlite': database.execute("REPLACE INTO settings VALUES('db_version', '%u');" % (i + 1)) except Exception, e: console.log(LOG_WARNING, "Unable to update database version to %u:\n%s\n" % (i + 1, str(e)))
def changechannelpassword(socket, password): # Get the Player, account and Channel player = socket.player account = socket.account channel = socket.gettag('ChatChannel') # Check if we're Moderators or Staffers if account.acl != 'player' or socket.hastag('Moderator'): conferences = int(wolfpack.getoption('channels', '0')) for i in range(1, conferences+1): channelname = wolfpack.getoption('channel_name_%u' % i, '') channelpass = wolfpack.getoption('channel_pass_%u' % i, '0') if channelname == channel: wolfpack.setoption('channel_pass_%u' % i, password) break send_msgpasschanged(socket) else: send_refuseaction(socket)
def onUpdateDatabase(current, version): # Find the update table for the database driver in use driver = database.driver(WORLD) if driver == 'mysql': updates = MYSQL_UPDATES elif driver == 'sqlite': updates = SQLITE_UPDATES else: console.log(LOG_ERROR, "Unknown database driver: %s.\n" % driver) return False for i in range(version, current): # No update for this version available if not i in updates: console.log(LOG_ERROR, "No update available for database version %u.\n" % i) return False console.log(LOG_MESSAGE, "Updating database from version %u to %u.\n" % (i, i + 1)) try: if not updates[i](): return False except Exception, e: console.log(LOG_ERROR, str(e) + "\n") return False wolfpack.setoption('db_version', str(i + 1)) try: if driver == 'mysql': database.execute( "REPLACE INTO `settings` VALUES('db_version', '%u');" % (i + 1)) else: database.execute( "REPLACE INTO settings VALUES('db_version', '%u');" % (i + 1)) except Exception, e: console.log( LOG_WARNING, "Unable to update database version to %u:\n%s\n" % (i + 1, str(e)))
def create_conference(socket, channelname, password, havepass): # Lets check if we already have a conference with this name if channelname == DEFAULTCHANNEL or checkchannelexist(channelname): send_alreadyconferencename(socket) return # Saving Channel conferences = int(wolfpack.getoption('channels', '0')) wolfpack.setoption('channel_name_' + str(conferences + 1), channelname) if havepass: wolfpack.setoption('channel_pass_' + str(conferences + 1), password) wolfpack.setoption('channels', str(conferences + 1)) # Channel Spam spam_createchannel(channelname, havepass) # Getting Moderator Status if socket.account.acl == 'player': socket.settag('Moderator', 1) # Enter this channel enterchannel(socket, channelname)
def destroychannel(channel): conferences = int(wolfpack.getoption('channels', '0')) for i in range(1, conferences+1): channelname = wolfpack.getoption('channel_name_%u' % i, '') channelpass = wolfpack.getoption('channel_pass_%u' % i, '0') if channelname == channel: for j in range(i + 1, conferences+1): channelname2 = wolfpack.getoption('channel_name_%u' % j, '') channelpass2 = wolfpack.getoption('channel_pass_%u' % j, '0') wolfpack.setoption('channel_name_' + str(j - 1), channelname2) if channelpass2: wolfpack.setoption('channel_pass_' + str(j - 1), channelpass2) wolfpack.setoption('channels', str(conferences - 1)) # Spam Destroy spam_destroychannel(channel)
def save(self): i = 0 for page in self.pages: i += 1 wolfpack.setoption('page_%u' % i, page.tostring()) wolfpack.setoption('pages', i)
def save(self): i = 0 for page in self.pages: i += 1 wolfpack.setoption('page_' + str(i), page.tostring()) wolfpack.setoption('pages', str(i))