From 4a52f3949a3f47bc5dadf9c8671bd9749b7ca879 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Tue, 13 Oct 2015 20:13:40 +0000 Subject: [PATCH] (captiveportal, new) add address_active to db class --- .../scripts/OPNsense/CaptivePortal/lib/db.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/opnsense/scripts/OPNsense/CaptivePortal/lib/db.py b/src/opnsense/scripts/OPNsense/CaptivePortal/lib/db.py index 3854685c5..6f3b301f6 100644 --- a/src/opnsense/scripts/OPNsense/CaptivePortal/lib/db.py +++ b/src/opnsense/scripts/OPNsense/CaptivePortal/lib/db.py @@ -63,6 +63,23 @@ class DB(object): cur.executescript(open(init_script_filename, 'rb').read()) cur.close() + def address_active(self, zoneid, ip_address): + """ check if address / network is active + :param zoneid: cp zone number + :param ip_address: ip address (to unlock) + :return: active status (boolean) + """ + cur = self._connection.cursor() + request = {'zoneid':zoneid, 'ip_address': ip_address} + cur.execute("""select count(*) + from cp_clients + where deleted = 0 and zoneid = :zoneid and ip_address = :ip_address""", request) + + if cur.fetchall()[0][0] > 0: + return True + else: + return False + def add_client(self, zoneid, authenticated_via, username, ip_address, mac_address): """ add a new client to the captive portal administration :param zoneid: cp zone number