parent
4105f4f2db
commit
6aa0afdf2c
|
@ -212,9 +212,11 @@ cur.execute("SELECT channel,mask,operator,time,removal,removal_op,id FROM bans O
|
||||||
bans = cur.fetchall()
|
bans = cur.fetchall()
|
||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
def myfilter(item, regex, kick, ban, oldban, mute, oldmute, floods, operator):
|
def myfilter(item, regex, kick, ban, oldban, mute, oldmute, floods, operator, channel)
|
||||||
if operator:
|
if operator:
|
||||||
if not operator.lower() in item[2].lower(): return False
|
if not operator.lower() in item[2].lower(): return False
|
||||||
|
if channel:
|
||||||
|
if not channel.lower() in item[0].lower(): return False
|
||||||
if '!' not in item[1]:
|
if '!' not in item[1]:
|
||||||
if not kick: return False
|
if not kick: return False
|
||||||
if not floods:
|
if not floods:
|
||||||
|
@ -230,22 +232,34 @@ def myfilter(item, regex, kick, ban, oldban, mute, oldmute, floods, operator):
|
||||||
else:
|
else:
|
||||||
if not ban: return False
|
if not ban: return False
|
||||||
if operator:
|
if operator:
|
||||||
return regex.search(item[0]) or regex.search(item[1]) or (item[5] and regex.search(item[5]))
|
return regex.search(item[1]) or regex.search(item[0]) or (item[5] and regex.search(item[5]))
|
||||||
return regex.search(item[0]) or regex.search(item[1]) or regex.search(item[2]) or (item[5] and regex.search(item[5]))
|
return regex.search(item[1]) or regex.search(item[2]) or regex.search(item[0]) or (item[5] and regex.search(item[5]))
|
||||||
|
|
||||||
|
def getQueryTerm(query, term):
|
||||||
|
if term[-1] != ':':
|
||||||
|
term += ':'
|
||||||
|
if term in query:
|
||||||
|
idx = query.index(term) + len(term)
|
||||||
|
ret = query[idx:].split(None, 1)[0]
|
||||||
|
query = query.replace(term + ret, '', 1).strip()
|
||||||
|
return (query, ret)
|
||||||
|
return (query, None)
|
||||||
|
|
||||||
if form.has_key('query'):
|
if form.has_key('query'):
|
||||||
k = b = ob = m = om = fb = oper = False
|
k = b = ob = m = om = fb = False
|
||||||
|
oper = chan = False
|
||||||
if form.has_key('kicks'): k = True
|
if form.has_key('kicks'): k = True
|
||||||
if form.has_key('oldbans'): ob = True
|
if form.has_key('oldbans'): ob = True
|
||||||
if form.has_key('bans'): b = True
|
if form.has_key('bans'): b = True
|
||||||
if form.has_key('oldmutes'): om = True
|
if form.has_key('oldmutes'): om = True
|
||||||
if form.has_key('mutes'): m = True
|
if form.has_key('mutes'): m = True
|
||||||
if form.has_key('floods'): fb = True
|
if form.has_key('floods'): fb = True
|
||||||
if form['query'].value.startswith("oper:"):
|
if "chan:" in form['query'].value:
|
||||||
oper = form['query'].value[4:].split(':', 1)[1].split(None, 1)[0]
|
(form['query'].value, chan) = getQueryTerm(form['query'].value, "chan:")
|
||||||
form['query'].value = form['query'].value[5+len(oper):].strip()
|
if "oper:" in form['query'].value:
|
||||||
|
(form['query'].value, oper) = getQueryTerm(form['query'].value, "oper:")
|
||||||
regex = re.compile(re.escape(form['query'].value).replace('\%','.*'), re.DOTALL | re.I)
|
regex = re.compile(re.escape(form['query'].value).replace('\%','.*'), re.DOTALL | re.I)
|
||||||
bans = filter(lambda x: myfilter(x, regex, k, b, ob, m, om, fb, oper), bans)
|
bans = filter(lambda x: myfilter(x, regex, k, b, ob, m, om, fb, oper, chan), bans)
|
||||||
start = 0; end = len(bans)
|
start = 0; end = len(bans)
|
||||||
else:
|
else:
|
||||||
page = 0
|
page = 0
|
||||||
|
@ -327,10 +341,17 @@ for b in bans[start:end]:
|
||||||
print '<form action="bans.cgi" method="POST"><textarea cols="50" rows="5" class="input" name="comment"></textarea><br />'
|
print '<form action="bans.cgi" method="POST"><textarea cols="50" rows="5" class="input" name="comment"></textarea><br />'
|
||||||
print '<input type="hidden" name="comment_id" value="%s" />' % b[6]
|
print '<input type="hidden" name="comment_id" value="%s" />' % b[6]
|
||||||
print '<input class="submit" type="submit" value="Send" /></form>'
|
print '<input class="submit" type="submit" value="Send" /></form>'
|
||||||
print '</td></tr>'
|
print '</div></td></tr>'
|
||||||
|
|
||||||
print '</table>'
|
print '</table>'
|
||||||
if not bans and form.has_key('query'):
|
if not bans and form.has_key('query'):
|
||||||
|
if chan and oper:
|
||||||
|
print "<center><u>No matches for:</u> "%s" in %s by %s;</center>" % (form['query'].value, chan, oper)
|
||||||
|
elif chan:
|
||||||
|
print "<center><u>No matches for:</u> "%s" in %s</center>" % (form['query'].value, chan)
|
||||||
|
elif oper:
|
||||||
|
print "<center><u>No matches for:</u> "%s" by %s</center>" % (form['query'].value, oper)
|
||||||
|
else:
|
||||||
print "<center><u>No matches for:</u> "%s"</center>" % form['query'].value
|
print "<center><u>No matches for:</u> "%s"</center>" % form['query'].value
|
||||||
|
|
||||||
# Aaaaaaaaaaaaaaaaand send!
|
# Aaaaaaaaaaaaaaaaand send!
|
||||||
|
|
|
@ -65,6 +65,7 @@
|
||||||
<body>
|
<body>
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<h1>Ubottu Bantracker</h1>
|
<h1>Ubottu Bantracker</h1>
|
||||||
|
%e
|
||||||
<p>
|
<p>
|
||||||
%s
|
%s
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
|
%e
|
||||||
%s
|
%s
|
||||||
|
|
2
bot.css
2
bot.css
|
@ -84,7 +84,7 @@ div.invisible {
|
||||||
div.log {
|
div.log {
|
||||||
display: none;
|
display: none;
|
||||||
color: black;
|
color: black;
|
||||||
width: 100%%;
|
width: 100%;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
|
|
@ -37,10 +37,12 @@ class IOWrapper:
|
||||||
return self.buf
|
return self.buf
|
||||||
|
|
||||||
sys.stdout = IOWrapper()
|
sys.stdout = IOWrapper()
|
||||||
|
sys.stderr = IOWrapper()
|
||||||
|
|
||||||
def send_page(template):
|
def send_page(template):
|
||||||
data = sys.stdout.getvalue()
|
data = sys.stdout.getvalue()
|
||||||
sys.stdout = sys.__stdout__
|
sys.stdout = sys.__stdout__
|
||||||
|
sys.stderr = sys.__stderr__
|
||||||
print "Content-Type: text/html"
|
print "Content-Type: text/html"
|
||||||
print cookie
|
print cookie
|
||||||
print ""
|
print ""
|
||||||
|
@ -48,7 +50,11 @@ def send_page(template):
|
||||||
fd = open(template)
|
fd = open(template)
|
||||||
tmpl = fd.read()
|
tmpl = fd.read()
|
||||||
fd.close()
|
fd.close()
|
||||||
print tmpl[:tmpl.find('%s')]
|
print tmpl[:tmpl.find('%e')]
|
||||||
|
for e in errdata:
|
||||||
|
print e
|
||||||
|
print tmpl[tmpl.find('%e')+2:tmpl.find('%s')]
|
||||||
|
# print tmpl[:tmpl.find('%s')]
|
||||||
for d in data:
|
for d in data:
|
||||||
print d
|
print d
|
||||||
print tmpl[tmpl.find('%s')+2:]
|
print tmpl[tmpl.find('%s')+2:]
|
||||||
|
|
Loading…
Reference in New Issue