port changes from bantracker page.
This commit is contained in:
13
Bantracker/banlog.css
Normal file
13
Bantracker/banlog.css
Normal file
@ -0,0 +1,13 @@
|
||||
div.main {
|
||||
text-align: left;
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
#hform > fieldset, #comment_form > fieldset {
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.highlight {
|
||||
background-color: yellow;
|
||||
}
|
||||
|
118
Bantracker/banlog.js
Normal file
118
Bantracker/banlog.js
Normal file
@ -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'
|
||||
num_per_page = 100
|
||||
pagename = os.path.basename(sys.argv[0])
|
||||
disable_anonymous = False # Set this to True to disable anonymous access
|
||||
|
||||
t1 = time.time()
|
||||
|
||||
@ -31,7 +32,7 @@ con = sqlite.connect(db)
|
||||
cur = con.cursor()
|
||||
|
||||
# Login check
|
||||
error = ''
|
||||
error = ''
|
||||
user = None
|
||||
|
||||
# Delete old sessions
|
||||
@ -45,35 +46,113 @@ except:
|
||||
if form.has_key('sess'):
|
||||
cookie['sess'] = form['sess'].value
|
||||
if cookie.has_key('sess'):
|
||||
sess = cookie['sess'].value
|
||||
try:
|
||||
sess = cookie['sess'].value
|
||||
cur.execute('SELECT user FROM sessions WHERE session_id=%s',(sess,))
|
||||
user = cur.fetchall()[0][0]
|
||||
except:
|
||||
con.commit()
|
||||
pass
|
||||
|
||||
if not user:
|
||||
print "Sorry, bantracker has been shut down for anonymous users due to server load<br>"
|
||||
if not user and disable_anonymous:
|
||||
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"
|
||||
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 '<font style="BACKGROUND-COLOR: yellow">%s</font><br>' % q(line)
|
||||
else:
|
||||
print "%s<br>" % q(line)
|
||||
else:
|
||||
print q(log[0][0]).replace('\n', '<br />')
|
||||
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, '<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
|
||||
# Process comments
|
||||
@ -103,48 +182,63 @@ else:
|
||||
cookie['tz'] = tz
|
||||
print '<select class="input" name="tz">'
|
||||
for zone in pytz.common_timezones:
|
||||
print '<option value="%s"' % zone
|
||||
if zone == tz:
|
||||
print ' selected="selected"'
|
||||
print ">%s</option>" % zone
|
||||
print '</select><input class="submit" type="submit" value="change" /></form><br />'
|
||||
print '<option value="%s" selected="selected">%s</option>' % (zone, zone)
|
||||
else:
|
||||
print '<option value="%s">%s</option>' % (zone, zone)
|
||||
print '</select>'
|
||||
print '<input class="submit" type="submit" value="change" />'
|
||||
print '</form><br />'
|
||||
print '</div>'
|
||||
|
||||
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
|
||||
print '<div class="search">'
|
||||
print '<form action="%s" method="GET">' % pagename
|
||||
print '<input class="input" type="text" name="query"'
|
||||
if form.has_key('query'):
|
||||
print 'value="%s" ' % form['query'].value
|
||||
print '/> Search string (% is wildcard)<br />'
|
||||
makeInput("channel", "Channel:", True, "text")
|
||||
makeInput("operator", "Operator:", True, "text")
|
||||
makeInput("query", "Search:", True, "text", extra="(% and _ are wildcards)")
|
||||
|
||||
# Search fields
|
||||
print '<div style="float:left">'
|
||||
print '<input class="input" type="checkbox" name="kicks" '
|
||||
if form.has_key('kicks') or not form.has_key('query'):
|
||||
print 'checked="checked" '
|
||||
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 />'
|
||||
makeInput("kicks", "Kicks")
|
||||
makeInput("bans", "Bans")
|
||||
makeInput("oldbans", "Removed bans")
|
||||
print '</div>'
|
||||
|
||||
print '<div style="float:left">'
|
||||
print '<input class="input" type="checkbox" name="mutes" '
|
||||
if form.has_key('mutes') or not form.has_key('query'):
|
||||
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 />'
|
||||
makeInput("mutes", "Include mutes")
|
||||
makeInput("floodbots", "Include Floodbots")
|
||||
print '</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'):
|
||||
sort='&sort=' + form['sort'].value
|
||||
print '<div style="clear: both">·'
|
||||
cur.execute('SELECT COUNT(id) FROM bans')
|
||||
nump = int(math.ceil(int(cur.fetchall()[0][0]) / float(num_per_page)))
|
||||
for i in range(nump):
|
||||
cur.execute('SELECT COUNT(*) FROM bans')
|
||||
nump = math.ceil(int(cur.fetchall()[0][0]) / float(num_per_page))
|
||||
for i in range(int(nump)):
|
||||
print '<a href="%s?page=%d%s">%d</a> ·' % (pagename, i, sort, i+1)
|
||||
print '</div>'
|
||||
|
||||
@ -167,20 +261,27 @@ print '<div id="log" class="log"> </div>'
|
||||
|
||||
# Main bans table
|
||||
# Table heading
|
||||
print '<table cellspacing="0" ><tr>'
|
||||
for h in [['Channel',0], ['Nick/Mask',1], ['Operator',2], ['Time',6]]:
|
||||
print '<div>'
|
||||
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
|
||||
try:
|
||||
v = int(form['sort'].value)
|
||||
if v < 10: h[1] += 10
|
||||
except:
|
||||
pass
|
||||
print '<th><a href="%s?sort=%s">%s</a></th>' % (pagename, h[1], h[0])
|
||||
print '<th>Log</th></tr>'
|
||||
print '<th style="width: %s%%"><a href="%s?sort=%s">%s</a></th>' % (pagename, h[2], h[1], h[0])
|
||||
print '<th style="width: 15%">Log</th>'
|
||||
print '<th>ID</th>'
|
||||
print '</tr>'
|
||||
print '</thead>'
|
||||
print '<tbody>'
|
||||
|
||||
# Select and filter bans
|
||||
def getBans(id=None, mask=None, kicks=True, oldbans=True, bans=True, floods=True, operator=None,
|
||||
channel=None):
|
||||
def getBans(id=None, mask=None, kicks=True, oldbans=True, bans=True, floodbots=True, operator=None,
|
||||
channel=None):
|
||||
sql = "SELECT channel, mask, operator, time, removal, removal_op, id FROM bans"
|
||||
args = []
|
||||
where = []
|
||||
@ -190,7 +291,7 @@ def getBans(id=None, mask=None, kicks=True, oldbans=True, bans=True, floods=True
|
||||
if mask:
|
||||
where.append("mask LIKE %s")
|
||||
args.append('%' + mask + '%')
|
||||
if not floods:
|
||||
if not floodbots:
|
||||
where.append("operator NOT LIKE 'floodbot%%'")
|
||||
if operator:
|
||||
where.append("operator LIKE %s")
|
||||
@ -242,16 +343,17 @@ if form.has_key('query'):
|
||||
bans = getBans(id=int(query))
|
||||
start = 0; end = 1
|
||||
else:
|
||||
if "chan:" in query:
|
||||
(query, chan) = getQueryTerm(query, "chan:")
|
||||
if "oper:" in query:
|
||||
(query, oper) = getQueryTerm(query, "oper:")
|
||||
if form.has_key('channel'):
|
||||
chan = form['channel'].value
|
||||
if form.has_key('operator'):
|
||||
oper = form['operator'].value
|
||||
|
||||
bans = getBans(mask=query, kicks=form.has_key('kicks'),
|
||||
oldbans=form.has_key('oldbans'),
|
||||
bans=form.has_key('bans'),
|
||||
floods=form.has_key('floods'),
|
||||
operator=oper,
|
||||
channel=chan)
|
||||
oldbans=form.has_key('oldbans'),
|
||||
bans=form.has_key('bans'),
|
||||
floodbots=form.has_key('floodbots'),
|
||||
operator=oper,
|
||||
channel=chan)
|
||||
|
||||
if not form.has_key('mutes'):
|
||||
bans = filter(lambda x: filterMutes(x), bans)
|
||||
@ -286,57 +388,67 @@ if form.has_key('sort'):
|
||||
# And finally, display them!
|
||||
i = 0
|
||||
for b in bans[start:end]:
|
||||
print '<tr'
|
||||
if i % 2:
|
||||
print ' class="bg2"'
|
||||
i += 1
|
||||
print '>'
|
||||
print '<tr class="bg2">'
|
||||
else:
|
||||
print "<tr>"
|
||||
# Channel
|
||||
print '<td> %s</td>' % b[0]
|
||||
print '<td id="channel-%d">%s %s</td>' % (b[6],'',b[0])
|
||||
# Mask
|
||||
print '<td>%s' % b[1]
|
||||
print '<td id="mask-%d">%s' % (b[6], b[1])
|
||||
# Ban removal
|
||||
if b[4]:
|
||||
print '<br /><span class="removal">(Removed)</span>'
|
||||
print'</td>'
|
||||
# Operator
|
||||
print '<td>%s' % b[2]
|
||||
print '<td id="operator-%d">%s' % (b[6], b[2])
|
||||
if b[4]: # Ban removal
|
||||
print u'<br /><span class="removal">%s</span>' % b[5]
|
||||
print '</td>'
|
||||
# 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
|
||||
print '<br /><span class="removal">%s</span>' % pickle.loads(b[4]).astimezone(tz).strftime("%b %d %Y %H:%M:%S")
|
||||
print '</td>'
|
||||
# Log link
|
||||
print '<td><span class="pseudolink" onclick="showlog(\'%s\')">Show/Hide log</span></td>' % b[6]
|
||||
print '</tr>'
|
||||
print """<td>
|
||||
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
|
||||
print '<tr'
|
||||
if not i % 2:
|
||||
print ' class="bg2"'
|
||||
print '>'
|
||||
print '<td colspan="5" class="comment">'
|
||||
if i % 2:
|
||||
print '<tr class="bg2">'
|
||||
else:
|
||||
print "<tr>"
|
||||
cur.execute('SELECT who, comment, time FROM comments WHERE ban_id = %d', (b[6],))
|
||||
comments = cur.fetchall()
|
||||
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>'
|
||||
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:
|
||||
print q(c[1])
|
||||
print q(c[1]).replace('\n', '<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"))
|
||||
if user:
|
||||
print """<span class="pseudolink" onclick="toggle('%s','comment')">Add comment</span>""" % b[6]
|
||||
print """<div class="invisible" id="comment_%s"><br />""" % b[6]
|
||||
print """<form action="%s" method="POST">""" % pagename
|
||||
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 class="submit" type="submit" value="Send" />"""
|
||||
print """</form>"""
|
||||
print '</td></tr>'
|
||||
print """ <form action="%s" method="POST">""" % pagename
|
||||
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 class="submit" type="submit" value="Send" />"""
|
||||
print """ </form>"""
|
||||
print """</div>"""
|
||||
print '</td><td></td></tr>'
|
||||
i += 1
|
||||
|
||||
print '</table>'
|
||||
|
||||
|
78
Bantracker/bans.js
Normal file
78
Bantracker/bans.js
Normal file
@ -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>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>Ubottu bantracker</title>
|
||||
<link rel="stylesheet" href="bot.css" />
|
||||
<link rel="shortcut icon" href="favicon.ico" type="image/png" />
|
||||
<script type="text/javascript">
|
||||
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>
|
||||
<script type="text/javascript" src="bans.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="main">
|
||||
<h1>Ubottu Bantracker</h1>
|
||||
<div class="errors">
|
||||
%e
|
||||
<p>
|
||||
</div>
|
||||
<div>
|
||||
%s
|
||||
</p>
|
||||
</div>
|
||||
<p>©2006 Dennis Kaarsemaker<br>
|
||||
Edited by Terence Simpson</p>
|
||||
</div>
|
||||
|
4
bot.css
4
bot.css
@ -6,6 +6,10 @@ body {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
tbody {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
div.home {
|
||||
margin: 20px auto;
|
||||
width: 300px;
|
||||
|
10
commoncgi.py
10
commoncgi.py
@ -55,14 +55,14 @@ def send_page(template):
|
||||
fd = open(template)
|
||||
tmpl = fd.read()
|
||||
fd.close()
|
||||
print tmpl[:tmpl.find('%e')]
|
||||
sys.stdout.write(tmpl[:tmpl.find('%e')])
|
||||
for e in errdata:
|
||||
print e
|
||||
print tmpl[tmpl.find('%e')+2:tmpl.find('%s')]
|
||||
sys.stdout.write(e)
|
||||
sys.stdout.write(tmpl[tmpl.find('%e')+2:tmpl.find('%s')])
|
||||
# print tmpl[:tmpl.find('%s')]
|
||||
for d in data:
|
||||
print d
|
||||
print tmpl[tmpl.find('%s')+2:]
|
||||
sys.stdout.write(d)
|
||||
sys.stdout.write(tmpl[tmpl.find('%s')+2:])
|
||||
sys.exit(0)
|
||||
|
||||
def q(txt):
|
||||
|
Reference in New Issue
Block a user