port changes from bantracker page.
This commit is contained in:
parent
9d6dfd01f2
commit
583ea422d9
|
@ -0,0 +1,13 @@
|
||||||
|
div.main {
|
||||||
|
text-align: left;
|
||||||
|
max-width: 500px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#hform > fieldset, #comment_form > fieldset {
|
||||||
|
max-width: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight {
|
||||||
|
background-color: yellow;
|
||||||
|
}
|
||||||
|
|
|
@ -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(/</g, '<');
|
||||||
|
}
|
||||||
|
|
||||||
|
String.prototype.HTMLEscape = function HTMLEscape() {
|
||||||
|
return this.HalfHTMLEscape().replace(/"/g, '"').replace(/'/g, ''');
|
||||||
|
}
|
||||||
|
|
||||||
|
var banlog = {
|
||||||
|
doneSetup: false,
|
||||||
|
hform: null,
|
||||||
|
log_id: null,
|
||||||
|
mark: null,
|
||||||
|
regex: null,
|
||||||
|
textlog: null,
|
||||||
|
lines: null,
|
||||||
|
force: false,
|
||||||
|
|
||||||
|
log: function() {},
|
||||||
|
|
||||||
|
highlight: function() {
|
||||||
|
var term = banlog.mark.value;
|
||||||
|
|
||||||
|
banlog.log("term: " + term + "\nbanlog.regex.checked: " + banlog.regex.checked)
|
||||||
|
|
||||||
|
if(term == "") {
|
||||||
|
for(var i=0; i<banlog.lines.length; ++i)
|
||||||
|
banlog.lines[i].className = "";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if(banlog.regex.checked) {
|
||||||
|
banlog.log("term: " + term.HalfHTMLEscape());
|
||||||
|
term = new RegExp(term.HalfHTMLEscape(), 'i')
|
||||||
|
} else {
|
||||||
|
banlog.log("term: " + RegExp.escape(term.HTMLEscape()));
|
||||||
|
term = new RegExp(RegExp.escape(term.HTMLEscape()), 'i')
|
||||||
|
}
|
||||||
|
} catch(err) {
|
||||||
|
banlog.log(err);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(var i=0; i<banlog.lines.length; ++i) {
|
||||||
|
var line = banlog.lines[i];
|
||||||
|
if(term.test(line.innerHTML)) {
|
||||||
|
line.className = "highlight"
|
||||||
|
} else {
|
||||||
|
line.className = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
keyup: function() {
|
||||||
|
banlog.highlight();
|
||||||
|
},
|
||||||
|
|
||||||
|
submit: function(e) {
|
||||||
|
if(banlog.force)
|
||||||
|
return true;
|
||||||
|
banlog.highlight();
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
dolog: function() {
|
||||||
|
banlog.log("this: " + this + ", arguments:" + arguments[0]);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
setup: function() {
|
||||||
|
if(banlog.doneSetup) return;
|
||||||
|
banlog.doneSetup = true;
|
||||||
|
// if(window.console && console.log)
|
||||||
|
// banlog.log = console.log;
|
||||||
|
|
||||||
|
banlog.hform = document.getElementById("hform");
|
||||||
|
banlog.log_id = document.getElementById("log").value;
|
||||||
|
banlog.mark = document.getElementById("mark");
|
||||||
|
banlog.regex = document.getElementById("regex");
|
||||||
|
banlog.textlog = document.getElementById("textlog");
|
||||||
|
banlog.lines = banlog.textlog.getElementsByTagName("span");
|
||||||
|
|
||||||
|
banlog.hform.addEventListener("submit", banlog.submit , false);
|
||||||
|
banlog.mark.addEventListener("keyup", banlog.keyup , false);
|
||||||
|
banlog.regex.addEventListener("change", banlog.keyup , false);
|
||||||
|
|
||||||
|
var really_submit = document.createElement("input");
|
||||||
|
really_submit.type = 'submit';
|
||||||
|
really_submit.className = 'input';
|
||||||
|
really_submit.value = 'Refresh';
|
||||||
|
really_submit.addEventListener('click', function() { banlog.force = true; }, false);
|
||||||
|
banlog.hform.appendChild(really_submit);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if(window.addEventListener) {
|
||||||
|
window.addEventListener('load', banlog.setup, false);
|
||||||
|
} else if(document.addEventListener) {
|
||||||
|
document.addEventListener('load', banlog.setup, false);
|
||||||
|
} else {
|
||||||
|
window.onload = document.onload = banlog.setup;
|
||||||
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ from commoncgi import *
|
||||||
db = '/home/bot/data/bans.db'
|
db = '/home/bot/data/bans.db'
|
||||||
num_per_page = 100
|
num_per_page = 100
|
||||||
pagename = os.path.basename(sys.argv[0])
|
pagename = os.path.basename(sys.argv[0])
|
||||||
|
disable_anonymous = False # Set this to True to disable anonymous access
|
||||||
|
|
||||||
t1 = time.time()
|
t1 = time.time()
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ con = sqlite.connect(db)
|
||||||
cur = con.cursor()
|
cur = con.cursor()
|
||||||
|
|
||||||
# Login check
|
# Login check
|
||||||
error = ''
|
error = ''
|
||||||
user = None
|
user = None
|
||||||
|
|
||||||
# Delete old sessions
|
# Delete old sessions
|
||||||
|
@ -45,35 +46,113 @@ except:
|
||||||
if form.has_key('sess'):
|
if form.has_key('sess'):
|
||||||
cookie['sess'] = form['sess'].value
|
cookie['sess'] = form['sess'].value
|
||||||
if cookie.has_key('sess'):
|
if cookie.has_key('sess'):
|
||||||
|
sess = cookie['sess'].value
|
||||||
try:
|
try:
|
||||||
sess = cookie['sess'].value
|
|
||||||
cur.execute('SELECT user FROM sessions WHERE session_id=%s',(sess,))
|
cur.execute('SELECT user FROM sessions WHERE session_id=%s',(sess,))
|
||||||
user = cur.fetchall()[0][0]
|
user = cur.fetchall()[0][0]
|
||||||
except:
|
except:
|
||||||
con.commit()
|
con.commit()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if not user:
|
if not user and disable_anonymous:
|
||||||
print "Sorry, bantracker has been shut down for anonymous users due to server load<br>"
|
print "Sorry, bantracker is not available for anonymous users<br />"
|
||||||
print "Join <a href=irc://irc.freenode.net/ubuntu-ops>#ubuntu-ops</a> on irc.freenode.net to discuss bans"
|
print "Join <a href=irc://irc.freenode.net/ubuntu-ops>#ubuntu-ops</a> on irc.freenode.net to discuss bans"
|
||||||
send_page('bans.tmpl')
|
send_page('bans.tmpl')
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
# Log
|
# Log
|
||||||
if form.has_key('log'):
|
if form.has_key('log'):
|
||||||
cur.execute('SELECT log FROM bans WHERE id=%s', (form['log'].value,))
|
log_id = form['log'].value
|
||||||
log = cur.fetchall()
|
plain = False
|
||||||
con.commit()
|
mark = False
|
||||||
if form.has_key('mark'):
|
mark_value = ''
|
||||||
marked = form['mark'].value
|
regex = False
|
||||||
lines = log[0][0].splitlines()
|
regex_value = ''
|
||||||
for line in lines:
|
|
||||||
if marked.lower() in line.lower():
|
if form.has_key('plain') and form['plain'].value.lower() in ('1', 'true', 'on'):
|
||||||
print '<font style="BACKGROUND-COLOR: yellow">%s</font><br>' % q(line)
|
plain = True
|
||||||
else:
|
|
||||||
print "%s<br>" % q(line)
|
if form.has_key('mark'):
|
||||||
else:
|
mark = True
|
||||||
print q(log[0][0]).replace('\n', '<br />')
|
mark_value = form['mark'].value
|
||||||
send_page('empty.tmpl')
|
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, '<div id="error">No such log with ID: %s' % q(log_id)
|
||||||
|
send_page('empty.tmpl')
|
||||||
|
else:
|
||||||
|
print >> sys.stderr, 'No such log with ID: %s' % q(log_id)
|
||||||
|
send_page('log.tmpl')
|
||||||
|
|
||||||
|
log = log[0][0]
|
||||||
|
|
||||||
|
if not plain:
|
||||||
|
print ' <div class="main">'
|
||||||
|
print ' <form id="hform" action="%s" method="get">' % pagename
|
||||||
|
print ' <fieldset>'
|
||||||
|
print ' <input type="hidden" name="log" id="log" value="%s">' % q(log_id)
|
||||||
|
print ' <label for="mark">Highlight:</label>'
|
||||||
|
print ' <input type="text" name="mark" id="mark" value="%s"/>' % q(mark_value)
|
||||||
|
print ' <input type="checkbox" name="regex" id="regex" %s>' % regex_value
|
||||||
|
print ' <label for="regex">Regex</label>'
|
||||||
|
print ' </fieldset>'
|
||||||
|
print ' <input class="input" type="submit" id="hform_submit" value="Update">'
|
||||||
|
print ' </form>'
|
||||||
|
print ' </div>'
|
||||||
|
|
||||||
|
pad = '<br />'
|
||||||
|
if plain:
|
||||||
|
pad = ''
|
||||||
|
print '<pre id="textlog">'
|
||||||
|
else:
|
||||||
|
print '<div id="textlog">'
|
||||||
|
|
||||||
|
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 ' <span class="highlight">%s</span>%s' % (q(line), pad)
|
||||||
|
else:
|
||||||
|
print " <span>%s</span>%s" % (q(line), pad)
|
||||||
|
else:
|
||||||
|
print ' <span>%s</span>%s' % (q(line), pad)
|
||||||
|
|
||||||
|
if plain:
|
||||||
|
print '</pre>'
|
||||||
|
send_page('empty.tmpl')
|
||||||
|
|
||||||
|
print '</div><br />'
|
||||||
|
print '<div>'
|
||||||
|
print ' <form id="comment_form" action="%s" method="post">' % pagename
|
||||||
|
print ' <fieldset>'
|
||||||
|
print ' <legend>Add a comment</legend>'
|
||||||
|
print ' <textarea cols="50" rows="5" class="input" name="comment"></textarea><br />'
|
||||||
|
print ' <input type="hidden" name="comment_id" value="%s" />' % log_id
|
||||||
|
print ' <input class="submit" type="submit" value="Send" />'
|
||||||
|
print ' </fieldset>'
|
||||||
|
print ' </form>'
|
||||||
|
print '</div>'
|
||||||
|
|
||||||
|
send_page('log.tmpl')
|
||||||
|
|
||||||
# Main page
|
# Main page
|
||||||
# Process comments
|
# Process comments
|
||||||
|
@ -103,48 +182,63 @@ else:
|
||||||
cookie['tz'] = tz
|
cookie['tz'] = tz
|
||||||
print '<select class="input" name="tz">'
|
print '<select class="input" name="tz">'
|
||||||
for zone in pytz.common_timezones:
|
for zone in pytz.common_timezones:
|
||||||
print '<option value="%s"' % zone
|
|
||||||
if zone == tz:
|
if zone == tz:
|
||||||
print ' selected="selected"'
|
print '<option value="%s" selected="selected">%s</option>' % (zone, zone)
|
||||||
print ">%s</option>" % zone
|
else:
|
||||||
print '</select><input class="submit" type="submit" value="change" /></form><br />'
|
print '<option value="%s">%s</option>' % (zone, zone)
|
||||||
|
print '</select>'
|
||||||
|
print '<input class="submit" type="submit" value="change" />'
|
||||||
|
print '</form><br />'
|
||||||
print '</div>'
|
print '</div>'
|
||||||
|
|
||||||
tz = pytz.timezone(tz)
|
tz = pytz.timezone(tz)
|
||||||
|
|
||||||
|
haveQuery = form.has_key('query') or form.has_key('channel') or form.has_key('operator')
|
||||||
|
|
||||||
|
def isOn(k):
|
||||||
|
default = not haveQuery
|
||||||
|
if not form.has_key(k):
|
||||||
|
return default
|
||||||
|
if form[k].value.lower() in ('on', '1', 'true', 'yes'):
|
||||||
|
return True
|
||||||
|
if form[k].value.lower() in ('off', '0', 'false', 'no'):
|
||||||
|
return False
|
||||||
|
return default
|
||||||
|
|
||||||
|
def makeInput(name, label, before=False, type="checkbox", extra=''):
|
||||||
|
if before:
|
||||||
|
print '<label for="%s">%s</label>' % (name, label)
|
||||||
|
value = ''
|
||||||
|
if type == "checkbox":
|
||||||
|
if isOn(name):
|
||||||
|
value = ' checked="checked"'
|
||||||
|
else:
|
||||||
|
if form.has_key(name):
|
||||||
|
value = ' value="%s"' % form[name].value,
|
||||||
|
|
||||||
|
print '<input class="input" type="%s" name="%s" id="%s"%s /> %s' \
|
||||||
|
% (type, name, name, value, extra)
|
||||||
|
if not before:
|
||||||
|
print '<label for="%s">%s</label>' % (name, label)
|
||||||
|
print '<br />'
|
||||||
|
|
||||||
# Search form
|
# Search form
|
||||||
print '<div class="search">'
|
print '<div class="search">'
|
||||||
print '<form action="%s" method="GET">' % pagename
|
print '<form action="%s" method="GET">' % pagename
|
||||||
print '<input class="input" type="text" name="query"'
|
makeInput("channel", "Channel:", True, "text")
|
||||||
if form.has_key('query'):
|
makeInput("operator", "Operator:", True, "text")
|
||||||
print 'value="%s" ' % form['query'].value
|
makeInput("query", "Search:", True, "text", extra="(% and _ are wildcards)")
|
||||||
print '/> Search string (% is wildcard)<br />'
|
|
||||||
|
|
||||||
# Search fields
|
# Search fields
|
||||||
print '<div style="float:left">'
|
print '<div style="float:left">'
|
||||||
print '<input class="input" type="checkbox" name="kicks" '
|
makeInput("kicks", "Kicks")
|
||||||
if form.has_key('kicks') or not form.has_key('query'):
|
makeInput("bans", "Bans")
|
||||||
print 'checked="checked" '
|
makeInput("oldbans", "Removed bans")
|
||||||
print '/> Kicks<br />'
|
|
||||||
print '<input class="input" type="checkbox" name="oldbans" '
|
|
||||||
if form.has_key('oldbans') or not form.has_key('query'):
|
|
||||||
print 'checked="checked" '
|
|
||||||
print '/> Removed bans<br />'
|
|
||||||
print '<input class="input" type="checkbox" name="bans" '
|
|
||||||
if form.has_key('bans') or not form.has_key('query'):
|
|
||||||
print 'checked="checked" '
|
|
||||||
print '/> Bans<br />'
|
|
||||||
print '</div>'
|
print '</div>'
|
||||||
|
|
||||||
print '<div style="float:left">'
|
print '<div style="float:left">'
|
||||||
print '<input class="input" type="checkbox" name="mutes" '
|
makeInput("mutes", "Include mutes")
|
||||||
if form.has_key('mutes') or not form.has_key('query'):
|
makeInput("floodbots", "Include Floodbots")
|
||||||
print 'checked="checked" '
|
|
||||||
print '/> Include mutes<br />'
|
|
||||||
print '<input class="input" type="checkbox" name="floods" '
|
|
||||||
if form.has_key('floods') or not form.has_key('query'):
|
|
||||||
print 'checked="checked" '
|
|
||||||
print '/> Include FloodBots<br />'
|
|
||||||
print '</div>'
|
print '</div>'
|
||||||
|
|
||||||
print '<div style="clear:both"><input class="submit" type="submit" value="search" /></div>'
|
print '<div style="clear:both"><input class="submit" type="submit" value="search" /></div>'
|
||||||
|
@ -156,9 +250,9 @@ if not form.has_key('query'):
|
||||||
if form.has_key('sort'):
|
if form.has_key('sort'):
|
||||||
sort='&sort=' + form['sort'].value
|
sort='&sort=' + form['sort'].value
|
||||||
print '<div style="clear: both">·'
|
print '<div style="clear: both">·'
|
||||||
cur.execute('SELECT COUNT(id) FROM bans')
|
cur.execute('SELECT COUNT(*) FROM bans')
|
||||||
nump = int(math.ceil(int(cur.fetchall()[0][0]) / float(num_per_page)))
|
nump = math.ceil(int(cur.fetchall()[0][0]) / float(num_per_page))
|
||||||
for i in range(nump):
|
for i in range(int(nump)):
|
||||||
print '<a href="%s?page=%d%s">%d</a> ·' % (pagename, i, sort, i+1)
|
print '<a href="%s?page=%d%s">%d</a> ·' % (pagename, i, sort, i+1)
|
||||||
print '</div>'
|
print '</div>'
|
||||||
|
|
||||||
|
@ -167,20 +261,27 @@ print '<div id="log" class="log"> </div>'
|
||||||
|
|
||||||
# Main bans table
|
# Main bans table
|
||||||
# Table heading
|
# Table heading
|
||||||
print '<table cellspacing="0" ><tr>'
|
print '<div>'
|
||||||
for h in [['Channel',0], ['Nick/Mask',1], ['Operator',2], ['Time',6]]:
|
print '<table cellspacing="0">'
|
||||||
|
print '<thead>'
|
||||||
|
print '<tr>'
|
||||||
|
for h in [['Channel',0, 45], ['Nick/Mask',1, 25], ['Operator',2, 0], ['Time',6, 15]]:
|
||||||
# Negative integers for backwards searching
|
# Negative integers for backwards searching
|
||||||
try:
|
try:
|
||||||
v = int(form['sort'].value)
|
v = int(form['sort'].value)
|
||||||
if v < 10: h[1] += 10
|
if v < 10: h[1] += 10
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
print '<th><a href="%s?sort=%s">%s</a></th>' % (pagename, h[1], h[0])
|
print '<th style="width: %s%%"><a href="%s?sort=%s">%s</a></th>' % (pagename, h[2], h[1], h[0])
|
||||||
print '<th>Log</th></tr>'
|
print '<th style="width: 15%">Log</th>'
|
||||||
|
print '<th>ID</th>'
|
||||||
|
print '</tr>'
|
||||||
|
print '</thead>'
|
||||||
|
print '<tbody>'
|
||||||
|
|
||||||
# Select and filter bans
|
# Select and filter bans
|
||||||
def getBans(id=None, mask=None, kicks=True, oldbans=True, bans=True, floods=True, operator=None,
|
def getBans(id=None, mask=None, kicks=True, oldbans=True, bans=True, floodbots=True, operator=None,
|
||||||
channel=None):
|
channel=None):
|
||||||
sql = "SELECT channel, mask, operator, time, removal, removal_op, id FROM bans"
|
sql = "SELECT channel, mask, operator, time, removal, removal_op, id FROM bans"
|
||||||
args = []
|
args = []
|
||||||
where = []
|
where = []
|
||||||
|
@ -190,7 +291,7 @@ def getBans(id=None, mask=None, kicks=True, oldbans=True, bans=True, floods=True
|
||||||
if mask:
|
if mask:
|
||||||
where.append("mask LIKE %s")
|
where.append("mask LIKE %s")
|
||||||
args.append('%' + mask + '%')
|
args.append('%' + mask + '%')
|
||||||
if not floods:
|
if not floodbots:
|
||||||
where.append("operator NOT LIKE 'floodbot%%'")
|
where.append("operator NOT LIKE 'floodbot%%'")
|
||||||
if operator:
|
if operator:
|
||||||
where.append("operator LIKE %s")
|
where.append("operator LIKE %s")
|
||||||
|
@ -242,16 +343,17 @@ if form.has_key('query'):
|
||||||
bans = getBans(id=int(query))
|
bans = getBans(id=int(query))
|
||||||
start = 0; end = 1
|
start = 0; end = 1
|
||||||
else:
|
else:
|
||||||
if "chan:" in query:
|
if form.has_key('channel'):
|
||||||
(query, chan) = getQueryTerm(query, "chan:")
|
chan = form['channel'].value
|
||||||
if "oper:" in query:
|
if form.has_key('operator'):
|
||||||
(query, oper) = getQueryTerm(query, "oper:")
|
oper = form['operator'].value
|
||||||
|
|
||||||
bans = getBans(mask=query, kicks=form.has_key('kicks'),
|
bans = getBans(mask=query, kicks=form.has_key('kicks'),
|
||||||
oldbans=form.has_key('oldbans'),
|
oldbans=form.has_key('oldbans'),
|
||||||
bans=form.has_key('bans'),
|
bans=form.has_key('bans'),
|
||||||
floods=form.has_key('floods'),
|
floodbots=form.has_key('floodbots'),
|
||||||
operator=oper,
|
operator=oper,
|
||||||
channel=chan)
|
channel=chan)
|
||||||
|
|
||||||
if not form.has_key('mutes'):
|
if not form.has_key('mutes'):
|
||||||
bans = filter(lambda x: filterMutes(x), bans)
|
bans = filter(lambda x: filterMutes(x), bans)
|
||||||
|
@ -286,57 +388,67 @@ if form.has_key('sort'):
|
||||||
# And finally, display them!
|
# And finally, display them!
|
||||||
i = 0
|
i = 0
|
||||||
for b in bans[start:end]:
|
for b in bans[start:end]:
|
||||||
print '<tr'
|
|
||||||
if i % 2:
|
if i % 2:
|
||||||
print ' class="bg2"'
|
print '<tr class="bg2">'
|
||||||
i += 1
|
else:
|
||||||
print '>'
|
print "<tr>"
|
||||||
# Channel
|
# Channel
|
||||||
print '<td> %s</td>' % b[0]
|
print '<td id="channel-%d">%s %s</td>' % (b[6],'',b[0])
|
||||||
# Mask
|
# Mask
|
||||||
print '<td>%s' % b[1]
|
print '<td id="mask-%d">%s' % (b[6], b[1])
|
||||||
# Ban removal
|
# Ban removal
|
||||||
if b[4]:
|
if b[4]:
|
||||||
print '<br /><span class="removal">(Removed)</span>'
|
print '<br /><span class="removal">(Removed)</span>'
|
||||||
print'</td>'
|
print'</td>'
|
||||||
# Operator
|
# Operator
|
||||||
print '<td>%s' % b[2]
|
print '<td id="operator-%d">%s' % (b[6], b[2])
|
||||||
if b[4]: # Ban removal
|
if b[4]: # Ban removal
|
||||||
print u'<br /><span class="removal">%s</span>' % b[5]
|
print u'<br /><span class="removal">%s</span>' % b[5]
|
||||||
print '</td>'
|
print '</td>'
|
||||||
# Time
|
# Time
|
||||||
print '<td>%s' % pickle.loads(b[3]).astimezone(tz).strftime("%b %d %Y %H:%M:%S")
|
print '<td id="time-%d">%s' % (b[6], pickle.loads(b[3]).astimezone(tz).strftime("%b %d %Y %H:%M:%S"))
|
||||||
if b[4]: # Ban removal
|
if b[4]: # Ban removal
|
||||||
print '<br /><span class="removal">%s</span>' % pickle.loads(b[4]).astimezone(tz).strftime("%b %d %Y %H:%M:%S")
|
print '<br /><span class="removal">%s</span>' % pickle.loads(b[4]).astimezone(tz).strftime("%b %d %Y %H:%M:%S")
|
||||||
print '</td>'
|
print '</td>'
|
||||||
# Log link
|
# Log link
|
||||||
print '<td><span class="pseudolink" onclick="showlog(\'%s\')">Show/Hide log</span></td>' % b[6]
|
print """<td>
|
||||||
print '</tr>'
|
Show log <a class="pseudolink" id="loglink-%s" onclick="showlog('%s')">inline</a>
|
||||||
|
| <a href="%s?log=%d">full</a>
|
||||||
|
</td>""" % (b[6], b[6], pagename, b[6])
|
||||||
|
|
||||||
|
# ID
|
||||||
|
print '<td id="id-%d">%d</td>' % (b[6], b[6])
|
||||||
|
print "</tr>"
|
||||||
|
|
||||||
# Comments
|
# Comments
|
||||||
print '<tr'
|
if i % 2:
|
||||||
if not i % 2:
|
print '<tr class="bg2">'
|
||||||
print ' class="bg2"'
|
else:
|
||||||
print '>'
|
print "<tr>"
|
||||||
print '<td colspan="5" class="comment">'
|
|
||||||
cur.execute('SELECT who, comment, time FROM comments WHERE ban_id = %d', (b[6],))
|
cur.execute('SELECT who, comment, time FROM comments WHERE ban_id = %d', (b[6],))
|
||||||
comments = cur.fetchall()
|
comments = cur.fetchall()
|
||||||
if len(comments) == 0:
|
if len(comments) == 0:
|
||||||
|
print '<td colspan="5" class="comment">'
|
||||||
|
print '<div class="invisible" id="comments">%d</div>' % b[6]
|
||||||
print '<span class="removal">(No comments) </span>'
|
print '<span class="removal">(No comments) </span>'
|
||||||
else:
|
else:
|
||||||
|
print '<td colspan="5" class="comment" id="comments-%d">' % b[6]
|
||||||
|
print '<div class="invisible" id="comments">%d</div>' % b[6]
|
||||||
for c in comments:
|
for c in comments:
|
||||||
print q(c[1])
|
print q(c[1]).replace('\n', '<br />')
|
||||||
print u' <span class="removal"><br />%s, %s</span><br />' % \
|
print u' <span class="removal"><br />%s, %s</span><br />' % \
|
||||||
(c[0],pickle.loads(c[2]).astimezone(tz).strftime("%b %d %Y %H:%M:%S"))
|
(c[0],pickle.loads(c[2]).astimezone(tz).strftime("%b %d %Y %H:%M:%S"))
|
||||||
if user:
|
if user:
|
||||||
print """<span class="pseudolink" onclick="toggle('%s','comment')">Add comment</span>""" % b[6]
|
print """<span class="pseudolink" onclick="toggle('%s','comment')">Add comment</span>""" % b[6]
|
||||||
print """<div class="invisible" id="comment_%s"><br />""" % b[6]
|
print """<div class="invisible" id="comment_%s"><br />""" % b[6]
|
||||||
print """<form action="%s" method="POST">""" % pagename
|
print """ <form action="%s" method="POST">""" % pagename
|
||||||
print """ <textarea cols="50" rows="5" class="input" name="comment"></textarea><br />"""
|
print """ <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" />"""
|
print """ <input class="submit" type="submit" value="Send" />"""
|
||||||
print """</form>"""
|
print """ </form>"""
|
||||||
print '</td></tr>'
|
print """</div>"""
|
||||||
|
print '</td><td></td></tr>'
|
||||||
|
i += 1
|
||||||
|
|
||||||
print '</table>'
|
print '</table>'
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
window.addEventListener("load", function() {
|
||||||
|
sc = document.createElement("script");
|
||||||
|
sc.setAttribute("type", "text/javascript");
|
||||||
|
sc.setAttribute("src", "banlog.js");
|
||||||
|
document.getElementsByTagName("head")[0].appendChild(sc);
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
s = null;
|
||||||
|
r = null;
|
||||||
|
|
||||||
|
function getObj(name) {
|
||||||
|
if (document.getElementById) {
|
||||||
|
this.obj = document.getElementById(name);
|
||||||
|
this.style = document.getElementById(name).style;
|
||||||
|
}
|
||||||
|
else if (document.all) {
|
||||||
|
this.obj = document.all[name];
|
||||||
|
this.style = document.all[name].style;
|
||||||
|
}
|
||||||
|
else if (document.layers) {
|
||||||
|
this.obj = document.layers[name];
|
||||||
|
this.style = document.layers[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggle(item,prefix) {
|
||||||
|
var c = new getObj(prefix + '_' + item);
|
||||||
|
if ( c.style.display == 'inline' ) {
|
||||||
|
c.style.display = 'none';
|
||||||
|
} else {
|
||||||
|
c.style.display = 'inline';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function showlog(item) {
|
||||||
|
if (s == item) {
|
||||||
|
c = new getObj('log');
|
||||||
|
if( c.style.display == 'block' || c.style.display == '' ) {
|
||||||
|
c.style.display = 'none';
|
||||||
|
document.getElementById("loglink-" + item).textContent = "inline";
|
||||||
|
} else {
|
||||||
|
c.style.diaply = 'block';
|
||||||
|
document.getElementById("loglink-" + item).textContent = "Hide";
|
||||||
|
}
|
||||||
|
s = null;
|
||||||
|
} else {
|
||||||
|
loadlog(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadlog(id) {
|
||||||
|
r = new XMLHttpRequest();
|
||||||
|
var qobj = new getObj("query");
|
||||||
|
/*
|
||||||
|
var objv = [];
|
||||||
|
for(var i in qobj)
|
||||||
|
objv.push(i);
|
||||||
|
alert(objv);
|
||||||
|
*/
|
||||||
|
var reqUri = "bans.cgi?log=" + id;
|
||||||
|
if(qobj.obj.value && qobj.obj.value != '')
|
||||||
|
reqUri += "&mark=" + qobj.obj.value.split(' ').pop();
|
||||||
|
reqUri += "&plain=1";
|
||||||
|
r.onreadystatechange = printlog;
|
||||||
|
r.open("GET", reqUri, true);
|
||||||
|
r.send(null);
|
||||||
|
s = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
function printlog() {
|
||||||
|
if (r.readyState == 4) {
|
||||||
|
var c = new getObj('log');
|
||||||
|
c.obj.innerHTML = r.responseText;
|
||||||
|
document.getElementById("loglink-" + s).textContent = "Hide";
|
||||||
|
c.style.display = 'block';
|
||||||
|
setupHighlight();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,74 +1,21 @@
|
||||||
<html>
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en" xml:lang="en">
|
||||||
<head>
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
<title>Ubottu bantracker</title>
|
<title>Ubottu bantracker</title>
|
||||||
<link rel="stylesheet" href="bot.css" />
|
<link rel="stylesheet" href="bot.css" />
|
||||||
<link rel="shortcut icon" href="favicon.ico" type="image/png" />
|
<link rel="shortcut icon" href="favicon.ico" type="image/png" />
|
||||||
<script type="text/javascript">
|
<script type="text/javascript" src="bans.js"></script>
|
||||||
var DHTML = (document.getElementById || document.all || document.layers);
|
|
||||||
|
|
||||||
function getObj(name) {
|
|
||||||
if (document.getElementById) {
|
|
||||||
this.obj = document.getElementById(name);
|
|
||||||
this.style = document.getElementById(name).style;
|
|
||||||
}
|
|
||||||
else if (document.all) {
|
|
||||||
this.obj = document.all[name];
|
|
||||||
this.style = document.all[name].style;
|
|
||||||
}
|
|
||||||
else if (document.layers) {
|
|
||||||
this.obj = document.layers[name];
|
|
||||||
this.style = document.layers[name];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function toggle(item,prefix) {
|
|
||||||
var c = new getObj(prefix + '_' + item);
|
|
||||||
if ( c.style.display == 'inline' ) {
|
|
||||||
c.style.display = 'none';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
c.style.display = 'inline';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var s = 0;
|
|
||||||
function showlog(item) {
|
|
||||||
if (s == item) {
|
|
||||||
c = new getObj('log');
|
|
||||||
if( c.style.display == 'block' ) {
|
|
||||||
c.style.display = 'none';
|
|
||||||
} else {
|
|
||||||
c.style.diaply = 'block';
|
|
||||||
}
|
|
||||||
s = 0;
|
|
||||||
} else {
|
|
||||||
loadlog(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var r;
|
|
||||||
function loadlog(id) {
|
|
||||||
r = new XMLHttpRequest();
|
|
||||||
r.onreadystatechange = printlog;
|
|
||||||
r.open("GET",'bans.cgi?log=' + id, true);
|
|
||||||
r.send(null);
|
|
||||||
s = id;
|
|
||||||
}
|
|
||||||
function printlog() {
|
|
||||||
if (r.readyState == 4) {
|
|
||||||
var c = new getObj('log');
|
|
||||||
c.obj.innerHTML = r.responseText;
|
|
||||||
c.style.display = 'block';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<h1>Ubottu Bantracker</h1>
|
<h1>Ubottu Bantracker</h1>
|
||||||
|
<div class="errors">
|
||||||
%e
|
%e
|
||||||
<p>
|
</div>
|
||||||
|
<div>
|
||||||
%s
|
%s
|
||||||
</p>
|
</div>
|
||||||
<p>©2006 Dennis Kaarsemaker<br>
|
<p>©2006 Dennis Kaarsemaker<br>
|
||||||
Edited by Terence Simpson</p>
|
Edited by Terence Simpson</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
4
bot.css
4
bot.css
|
@ -6,6 +6,10 @@ body {
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tbody {
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
|
||||||
div.home {
|
div.home {
|
||||||
margin: 20px auto;
|
margin: 20px auto;
|
||||||
width: 300px;
|
width: 300px;
|
||||||
|
|
10
commoncgi.py
10
commoncgi.py
|
@ -55,14 +55,14 @@ def send_page(template):
|
||||||
fd = open(template)
|
fd = open(template)
|
||||||
tmpl = fd.read()
|
tmpl = fd.read()
|
||||||
fd.close()
|
fd.close()
|
||||||
print tmpl[:tmpl.find('%e')]
|
sys.stdout.write(tmpl[:tmpl.find('%e')])
|
||||||
for e in errdata:
|
for e in errdata:
|
||||||
print e
|
sys.stdout.write(e)
|
||||||
print tmpl[tmpl.find('%e')+2:tmpl.find('%s')]
|
sys.stdout.write(tmpl[tmpl.find('%e')+2:tmpl.find('%s')])
|
||||||
# print tmpl[:tmpl.find('%s')]
|
# print tmpl[:tmpl.find('%s')]
|
||||||
for d in data:
|
for d in data:
|
||||||
print d
|
sys.stdout.write(d)
|
||||||
print tmpl[tmpl.find('%s')+2:]
|
sys.stdout.write(tmpl[tmpl.find('%s')+2:])
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
def q(txt):
|
def q(txt):
|
||||||
|
|
Loading…
Reference in New Issue