Ignore:
Timestamp:
Apr 13, 2012, 4:32:48 AM (13 years ago)
Author:
rick
Message:
  • Going for an template solution instead to avoid having all the issues with escapes.
  • '/tmp/network.status' will contain the results of various (local) nagios checks.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/releng-9.0/nanobsd/files/usr/local/www/wlportal/index.cgi

    r10419 r10471  
    3939import urlparse
    4040import yaml
     41
     42from jinja2 import Template
    4143
    4244# XXX: Make me dynamic for example put me in the conf file
     
    5557  'expire_time'   : None,
    5658  'accessdb'      : '/var/db/clients',
     59  'net_status'    : '/tmp/network.status',
    5760}
    5861
     
    6265if os.path.isfile(cfg['config_file']):
    6366  cfg.update(yaml.load(open(cfg['config_file'])))
     67
     68internet_up = True
     69if os.path.isfile(cfg['net_status']):
     70  internet_up = 'internet=up' in open(cfg['net_status'], 'r').read().lower()
     71
     72if not internet_up:
     73  cfg['warning_msg'] = "<b>Internet Problemen</b>: De laatste 15 minuten zijn er problemen met de (internet) verbinding geconstateerd, de gebruikers ervaring kan dus niet optimaal zijn. Onze excuses voor het eventuele ongemak. Bij aanhoudende problemen kunt u contact opnemen met gebruikers@lijst.wirelessleiden.nl"
    6474
    6575def log_registered_host(remote_mac, remote_host):
     
    233243# Helpers for HTML 'templates'
    234244content = cfg.copy()
    235 content.update(extra_header='',tech_footer='',status_msg='')
     245content.update(extra_header='')
    236246
    237247# IP or MAC on the whitelist does not need to authenticate, used for devices
     
    309319"""
    310320
    311 print page % content
     321print Template(page).render(content)
Note: See TracChangeset for help on using the changeset viewer.