Wiki Spam Throttle
def isForbidden(self): """ only allow two anonymous posts per hour per ip address""" if self.request_method == 'POST' and not self.user.name: lasthour=str(time.time()-3600) log=os.path.join(config.data_dir, 'event.log') file=open(log) pages={} for line in file: if line>lasthour and line.find("SAVEPAGE")>=0: if self.remote_addr == line.split('&')[1].split('=')[1]: pages[line.split('&')[0].split('=')[1]]='1' if len(pages) >= 2: return True file.close()
Update: I've changed it to allow only two pages to be updated per hour. A single page may be updated multiple times without penalty.