var express = require('express'); var router = express.Router(); var fs = require('fs'); var template_render = require('../lib/render_template.js'); function human_time (time){ var time = new Date(time); var year = time.getFullYear(); var month = time.getMonth()+1; var date1 = time.getDate(); var hour = time.getHours(); var minutes = time.getMinutes(); var seconds = time.getSeconds(); return year + "-" + month+"-"+date1+" "+hour+":"+minutes+":"+seconds; } router.post('/', function(req, res, next) { var request = req.body; var search = request.search; dhcp_leases = template_render.get_template("dhcp_lease_search"); table_data = ''; var count = 0; for (var key in dhcp_lease_data) { var matcher = new RegExp(search, "i"); if( !matcher.test(dhcp_lease_data[key].mac_oui_vendor) && !matcher.test(dhcp_lease_data[key].host) && !matcher.test(key) && !matcher.test(dhcp_lease_data[key].mac) && !matcher.test(JSON.stringify(dhcp_lease_data[key].options, null, 2)) ) continue; table_row = ''; table_row = table_row + '