if domain != None:
wildchar = "*." + ".".join(domain.split(".")[-domain.count("."):])
punycode = domain.encode('idna').decode('utf-8')
- fba.cursor.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM blocks WHERE blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? ORDER BY first_added ASC",
+ fba.cursor.execute("SELECT blocker, blocked, block_level, reason, first_seen, last_seen FROM blocks WHERE blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? ORDER BY first_seen ASC",
(domain, "*." + domain, wildchar, fba.get_hash(domain), punycode, "*." + punycode))
elif reverse != None:
- fba.cursor.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM blocks WHERE blocker = ? ORDER BY first_added ASC", [reverse])
+ fba.cursor.execute("SELECT blocker, blocked, block_level, reason, first_seen, last_seen FROM blocks WHERE blocker = ? ORDER BY first_seen ASC", [reverse])
else:
- fba.cursor.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM blocks WHERE reason like ? AND reason != '' ORDER BY first_added ASC", ["%" + reason + "%"])
+ fba.cursor.execute("SELECT blocker, blocked, block_level, reason, first_seen, last_seen FROM blocks WHERE reason like ? AND reason != '' ORDER BY first_seen ASC", ["%" + reason + "%"])
blocks = fba.cursor.fetchall()
result = {}
- for blocker, blocked, block_level, reason, first_added, last_seen in blocks:
+ for blocker, blocked, block_level, reason, first_seen, last_seen in blocks:
entry = {
"blocker" : blocker,
"blocked" : blocked,
"reason" : reason,
- "first_added": first_added,
+ "first_seen": first_seen,
"last_seen" : last_seen
}
if block_level in result:
blocks = blocks.json()
for block_level in blocks:
for block in blocks[block_level]:
- block["first_added"] = datetime.utcfromtimestamp(block["first_added"]).strftime('%Y-%m-%d %H:%M')
+ block["first_seen"] = datetime.utcfromtimestamp(block["first_seen"]).strftime('%Y-%m-%d %H:%M')
block["last_seen"] = datetime.utcfromtimestamp(block["last_seen"]).strftime('%Y-%m-%d %H:%M')
return templates.TemplateResponse("index.html", {
if domain != None:
wildchar = "*." + ".".join(domain.split(".")[-domain.count("."):])
punycode = domain.encode('idna').decode('utf-8')
- fba.cursor.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM blocks WHERE blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? ORDER BY first_added DESC LIMIT 50",
+ fba.cursor.execute("SELECT blocker, blocked, block_level, reason, first_seen, last_seen FROM blocks WHERE blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? ORDER BY first_seen DESC LIMIT 50",
(domain, "*." + domain, wildchar, fba.get_hash(domain), punycode, "*." + punycode))
else:
- fba.cursor.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM blocks ORDER BY first_added DESC LIMIT 50")
+ fba.cursor.execute("SELECT blocker, blocked, block_level, reason, first_seen, last_seen FROM blocks ORDER BY first_seen DESC LIMIT 50")
blocks = fba.cursor.fetchall()
result = []
- for blocker, blocked, block_level, reason, first_added, last_seen in blocks:
- first_added = utils.format_datetime(datetime.fromtimestamp(first_added))
+ for blocker, blocked, block_level, reason, first_seen, last_seen in blocks:
+ first_seen = utils.format_datetime(datetime.fromtimestamp(first_seen))
if reason == None or reason == '':
reason = "No reason provided."
else:
"blocked": blocked,
"block_level": block_level,
"reason": reason,
- "first_added": first_added
+ "first_seen": first_seen
})
timestamp = utils.format_datetime(datetime.now())
print("WARNING: Bad blocked:", blocked)
raise
- print("INFO: New block:", blocker, blocked, reason, block_level, first_added, last_seen)
+ print("INFO: New block:", blocker, blocked, reason, block_level, first_seen, last_seen)
try:
cursor.execute(
- "INSERT INTO blocks (blocker, blocked, reason, block_level, first_added, last_seen) VALUES(?, ?, ?, ?, ?, ?)",
+ "INSERT INTO blocks (blocker, blocked, reason, block_level, first_seen, last_seen) VALUES(?, ?, ?, ?, ?, ?)",
(
blocker,
blocked,
)
except BaseException as e:
- print(f"ERROR: failed SQL query: blocker='{blocker}',blocked='{blocked}',reason='{reason}',block_level='{block_level}',first_added='{first_added}',last_seen='{last_seen}',exception:'{e}'")
+ print(f"ERROR: failed SQL query: blocker='{blocker}',blocked='{blocked}',reason='{reason}',block_level='{block_level}',first_seen='{first_seen}',last_seen='{last_seen}',exception:'{e}'")
sys.exit(255)
# DEBUG: print("DEBUG: EXIT!")
# Check condition
registered = cursor.fetchone() != None
except BaseException as e:
- print(f"ERROR: failed SQL query: last_seen='{last_seen}'blocker='{blocker}',blocked='{blocked}',block_level='{block_level}',first_added='{first_added}',last_seen='{last_seen}',exception:'{e}'")
+ print(f"ERROR: failed SQL query: last_seen='{last_seen}'blocker='{blocker}',blocked='{blocked}',block_level='{block_level}',first_seen='{first_seen}',last_seen='{last_seen}',exception:'{e}'")
sys.exit(255)
# DEBUG: print(f"DEBUG: registered='{registered}' - EXIT!")