diff options
author | Erik Fonnesbeck <efonnes@gmail.com> | 2010-07-10 23:20:40 -0600 |
---|---|---|
committer | Erik Fonnesbeck <efonnes@gmail.com> | 2010-07-10 23:40:56 -0600 |
commit | 7017b54ec4f8a53ce6af501fac1ce7c0ea60096a (patch) | |
tree | 3737e03abd82b51ec78176a5f72986c9c6937f13 | |
parent | 1fb064e86d12b5a70130e06e3748f345a534fb9b (diff) | |
download | pfsense-7017b54ec4f8a53ce6af501fac1ce7c0ea60096a.zip pfsense-7017b54ec4f8a53ce6af501fac1ce7c0ea60096a.tar.gz |
Speed up loading information from regdomain.xml
-rw-r--r-- | etc/inc/xmlparse_attr.inc | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/etc/inc/xmlparse_attr.inc b/etc/inc/xmlparse_attr.inc index 67cc857..06d02c4 100644 --- a/etc/inc/xmlparse_attr.inc +++ b/etc/inc/xmlparse_attr.inc @@ -127,10 +127,43 @@ function cData_attr($parser, $data) { } } -function parse_xml_regdomain(&$rdattributes, $rdfile = '/etc/regdomain.xml', $rootobj = 'regulatory-data') { - global $listtags; +function parse_xml_regdomain(&$rdattributes, $rdfile = '', $rootobj = 'regulatory-data') { + global $g, $listtags; + + if (empty($rdfile)) + $rdfile = $g['etc_path'] . '/regdomain.xml'; $listtags = listtags_rd(); - return parse_xml_config_raw_attr($rdfile, $rootobj, $rdattributes); + $parsed_xml = array(); + + if (file_exists($g['tmp_path'] . '/regdomain.cache')) { + $parsed_xml = unserialize(file_get_contents($g['tmp_path'] . '/regdomain.cache')); + if (!empty($parsed_xml)) { + $rdmain = $parsed_xml['main']; + $rdattributes = $parsed_xml['attributes']; + } + } + if (empty($parsed_xml) && file_exists($g['etc_path'] . '/regdomain.xml')) { + $rdmain = parse_xml_config_raw_attr($rdfile, $rootobj, $rdattributes); + + // unset parts that aren't used before making cache + foreach ($rdmain['regulatory-domains']['rd'] as $rdkey => $rdentry) { + if (isset($rdmain['regulatory-domains']['rd'][$rdkey]['netband'])) + unset($rdmain['regulatory-domains']['rd'][$rdkey]['netband']); + if (isset($rdattributes['regulatory-domains']['rd'][$rdkey]['netband'])) + unset($rdattributes['regulatory-domains']['rd'][$rdkey]['netband']); + } + if (isset($rdmain['shared-frequency-bands'])) + unset($rdmain['shared-frequency-bands']); + if (isset($rdattributes['shared-frequency-bands'])) + unset($rdattributes['shared-frequency-bands']); + + $parsed_xml = array('main' => $rdmain, 'attributes' => $rdattributes); + $rdcache = fopen($g['tmp_path'] . '/regdomain.cache', "w"); + fwrite($rdcache, serialize($parsed_xml)); + fclose($rdcache); + } + + return $rdmain; } function parse_xml_config_raw_attr($cffile, $rootobj, &$parsed_attributes, $isstring = "false") { |