diff --git a/Bantracker/banlog.css b/Bantracker/banlog.css
new file mode 100644
index 0000000..190979a
--- /dev/null
+++ b/Bantracker/banlog.css
@@ -0,0 +1,13 @@
+div.main {
+ text-align: left;
+ max-width: 500px;
+}
+
+#hform > fieldset, #comment_form > fieldset {
+ max-width: 400px;
+}
+
+.highlight {
+ background-color: yellow;
+}
+
diff --git a/Bantracker/banlog.js b/Bantracker/banlog.js
new file mode 100644
index 0000000..fae19ce
--- /dev/null
+++ b/Bantracker/banlog.js
@@ -0,0 +1,118 @@
+RegExp.escape = function escape(text) {
+ if (!arguments.callee.sRE) {
+ var specials = [
+ '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^'
+ ];
+ arguments.callee.sRE = new RegExp(
+ '(\\' + specials.join('|\\') + ')', 'g'
+ );
+ }
+ return text.replace(arguments.callee.sRE, '\\$1');
+}
+
+String.prototype.HalfHTMLEscape = function() {
+ return this.replace(/&/g, '&').replace(/>/g, '>').replace(/"
+if not user and disable_anonymous:
+ print "Sorry, bantracker is not available for anonymous users
"
print "Join #ubuntu-ops on irc.freenode.net to discuss bans"
send_page('bans.tmpl')
+ sys.exit(0)
# Log
if form.has_key('log'):
- cur.execute('SELECT log FROM bans WHERE id=%s', (form['log'].value,))
- log = cur.fetchall()
- con.commit()
- if form.has_key('mark'):
- marked = form['mark'].value
- lines = log[0][0].splitlines()
- for line in lines:
- if marked.lower() in line.lower():
- print '%s
' % q(line)
- else:
- print "%s
" % q(line)
- else:
- print q(log[0][0]).replace('\n', '
')
- send_page('empty.tmpl')
+ log_id = form['log'].value
+ plain = False
+ mark = False
+ mark_value = ''
+ regex = False
+ regex_value = ''
+
+ if form.has_key('plain') and form['plain'].value.lower() in ('1', 'true', 'on'):
+ plain = True
+
+ if form.has_key('mark'):
+ mark = True
+ mark_value = form['mark'].value
+ if form.has_key('regex') and form['regex'].value in ('1', 'true', 'on'):
+ regex = True
+ regex_value = 'checked="checked"'
+
+ con = sqlite.connect(db)
+ cur = con.cursor()
+ cur.execute("SELECT log FROM bans WHERE id=%s", log_id)
+ log = cur.fetchall()
+ con.commit()
+ con.close()
+
+ if not log or not log[0] or not log[0][0]:
+ if plain:
+ print >> sys.stderr, '
' + else: + print '' + + if mark: + if regex: + mark = re.compile(mark_value, re.I) + else: + escaped = re.escape(mark_value).replace('%', '.*') + mark = re.compile(escaped, re.I) + + lines = log.splitlines() + for line in lines: + if plain: + print q(line) + elif mark: + if mark.search(line): + print ' %s%s' % (q(line), pad) + else: + print " %s%s" % (q(line), pad) + else: + print ' %s%s' % (q(line), pad) + + if plain: + print '' + send_page('empty.tmpl') + + print '
' + print '' + print ' ' + print '' + + send_page('log.tmpl') # Main page # Process comments @@ -103,48 +182,63 @@ else: cookie['tz'] = tz print '
' + print '' % (zone, zone) + else: + print '' % (zone, zone) +print '' +print '' +print '
' print '