From a9038c8009754693948ba92155e61529dd6d3fb7 Mon Sep 17 00:00:00 2001 From: k-paulius Date: Mon, 13 Jul 2015 21:12:24 -0500 Subject: vnstat2 XML file whitespace cleanup --- config/vnstat2/vnstat2.xml | 69 ++++++++++++++++++++--------------------- config/vnstat2/vnstati.xml | 9 +++--- config/vnstat2/vnstatoutput.xml | 9 +++--- 3 files changed, 42 insertions(+), 45 deletions(-) diff --git a/config/vnstat2/vnstat2.xml b/config/vnstat2/vnstat2.xml index 94b7cfc1..f696850a 100644 --- a/config/vnstat2/vnstat2.xml +++ b/config/vnstat2/vnstat2.xml @@ -2,10 +2,10 @@ - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. vnstat2 11.2,3 Vnstat2 @@ -203,36 +203,36 @@ select 3 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Enable vnstat php frontend (Note that no login will be needed) @@ -246,4 +246,3 @@ vnstat_install_config(); vnstat_install_deinstall(); - diff --git a/config/vnstat2/vnstati.xml b/config/vnstat2/vnstati.xml index 7cd3f3be..84a104dd 100644 --- a/config/vnstat2/vnstati.xml +++ b/config/vnstat2/vnstati.xml @@ -2,10 +2,10 @@ - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. vnstat2 1.0 Vnstat2 @@ -54,4 +54,3 @@ vnstat_install_config(); vnstat_install_deinstall(); - diff --git a/config/vnstat2/vnstatoutput.xml b/config/vnstat2/vnstatoutput.xml index 9d2e3d05..5062be1f 100644 --- a/config/vnstat2/vnstatoutput.xml +++ b/config/vnstat2/vnstatoutput.xml @@ -2,10 +2,10 @@ - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. vnstat2 1.0 Vnstat2 @@ -54,4 +54,3 @@ vnstat_install_config(); vnstat_install_deinstall(); - -- cgit v1.2.3 From 1d8944e08c21254c9e81b46c1edc64e9fde7da8e Mon Sep 17 00:00:00 2001 From: k-paulius Date: Mon, 13 Jul 2015 22:15:10 -0500 Subject: formatted vnstat2 php code --- config/vnstat2/vnstat2.inc | 273 ++++++++++++++++++------------------ config/vnstat2/www/diag_vnstat.php | 84 +++++------ config/vnstat2/www/diag_vnstat2.php | 106 +++++++------- config/vnstat2/www/vnstati.php | 1 - 4 files changed, 234 insertions(+), 230 deletions(-) diff --git a/config/vnstat2/vnstat2.inc b/config/vnstat2/vnstat2.inc index c875be52..afbf270a 100644 --- a/config/vnstat2/vnstat2.inc +++ b/config/vnstat2/vnstat2.inc @@ -1,15 +1,16 @@ 0) { + if ($is_installed == true) { + if ($x > 0) { unset($config['cron']['item'][$x]); write_config(); } @@ -55,8 +57,7 @@ function vnstat2_install_cron($vnstat_cron_value) { } } - -function change_vnstat_conf(){ +function change_vnstat_conf() { conf_mount_rw(); global $config; $config['installedpackages']['vnstat2']['config'][0]['monthrotate'] = $_POST['monthrotate']; @@ -64,21 +65,19 @@ function change_vnstat_conf(){ write_conf_f(); write_config(); - if ($config['installedpackages']['vnstat2']['config'][0]['vnstat_phpfrontend'] == "on"){ - vnstat_php_frontend(); - } - else { - exec("[ -d /usr/local/www/vnstat2 ] && rm -d -R /usr/local/www/vnstat2"); + if ($config['installedpackages']['vnstat2']['config'][0]['vnstat_phpfrontend'] == "on") { + vnstat_php_frontend(); + } else { + exec("[ -d /usr/local/www/vnstat2 ] && rm -d -R /usr/local/www/vnstat2"); } conf_mount_ro(); } -function write_conf_f(){ +function write_conf_f() { global $config; $monthrotate = $config['installedpackages']['vnstat2']['config'][0]['monthrotate']; -// ************ Write new vnstat.conf ***************** - + // ************ Write new vnstat.conf ***************** $vnstat_conf_file = << 'WAN', 'lan' => 'LAN'); + exec("ls /conf/vnstat/ | grep -v '\.'", $vnstat_nic_in); + $iface_list_array_items = implode("', '", $vnstat_nic_in); + $iface_list_array = "\$iface_list = array('$iface_list_array_items');"; + // $iface_title_array_items + $iface_title_array_items = array(); + $iface_title_array_items2 = array(); + foreach ($vnstat_nic_in as $vnstat_nic_out) { + $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN'); for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) { $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr']; } - foreach ($ifdescrs as $ifdescr => $ifname): - $real_nic_names3 = get_real_interface($ifdescr); - If ($real_nic_names3 == $vnstat_nic_out) - { - $ifname_out = convert_friendly_interface_to_friendly_descr($ifdescr); - $iface_title_array_items = "\$iface_title['$vnstat_nic_out'] = '$ifname_out';\n"; - array_push($iface_title_array_items2, $iface_title_array_items); - } - endforeach; + foreach ($ifdescrs as $ifdescr => $ifname) { + $real_nic_names3 = get_real_interface($ifdescr); + if ($real_nic_names3 == $vnstat_nic_out) { + $ifname_out = convert_friendly_interface_to_friendly_descr($ifdescr); + $iface_title_array_items = "\$iface_title['$vnstat_nic_out'] = '$ifname_out';\n"; + array_push($iface_title_array_items2, $iface_title_array_items); + } + } } - $iface_title_array = implode($iface_title_array_items2); + $iface_title_array = implode($iface_title_array_items2); // php in php static items // added to new items for the front end version 1.5.1 - $locale = "\$locale = 'en_US.UTF-8';"; - $language = "\$language = 'en';"; - $vnstat_bin2 = "\$vnstat_bin = '/usr/local/bin/vnstat';"; - $data_dir2 = "\$data_dir = './dumps';"; - $graph_format2 ="\$graph_format='svg';"; - $colorscheme2 = "\$colorscheme['light'] = array("; - $colorscheme3 = "\$colorscheme['red'] = array("; - $colorscheme4 = "\$colorscheme['pfSense'] = array("; -// ************ Write new config.php ****************** - $config_file = << /path/to/data_dir/vnstat_dump_ - // -$vnstat_bin2 -$data_dir2 + // + // There are two possible sources for vnstat data. If the + // variable is set then vnstat is called directly from the PHP script + // to get the interface data. + // + // The other option is to periodically dump the vnstat interface data to + // a file (e.g. by a cronjob). In that case the variable + // must be cleared and set to the location where the dumps + // are stored. Dumps must be named 'vnstat_dump_'. + // + // You can generate vnstat dumps with the command: + // vnstat --dumpdb -i > /path/to/data_dir/vnstat_dump_ + // + $vnstat_bin2 + $data_dir2 - // graphics format to use: svg or png -$graph_format2 - - // Font to use for PNG graphs - define('GRAPH_FONT',dirname(__FILE__).'/VeraBd.ttf'); + // graphics format to use: svg or png + $graph_format2 - // Font to use for SVG graphs - define('SVG_FONT', 'Verdana'); + // Font to use for PNG graphs + define('GRAPH_FONT',dirname(__FILE__).'/VeraBd.ttf'); - // color schemes - // colors are defined as R,G,B,ALPHA quads where R, G and B range from 0-255 - // and ALPHA from 0-127 where 0 is opaque and 127 completely transparent. - // - define('DEFAULT_COLORSCHEME', 'pfSense'); + // Font to use for SVG graphs + define('SVG_FONT', 'Verdana'); + + // color schemes + // colors are defined as R,G,B,ALPHA quads where R, G and B range from 0-255 + // and ALPHA from 0-127 where 0 is opaque and 127 completely transparent. + // + define('DEFAULT_COLORSCHEME', 'pfSense'); ?> EOF; - $hf = fopen("/usr/local/www/vnstat2/config.php","w"); - if(!$hf) { - log_error("could not open /usr/local/www/vnstat2/config.php for writing"); - exit; - } - fwrite($hf, $config_file); - fclose($hf); + $hf = fopen("/usr/local/www/vnstat2/config.php","w"); + if (!$hf) { + log_error("could not open /usr/local/www/vnstat2/config.php for writing"); + exit; + } + fwrite($hf, $config_file); + fclose($hf); } + ?> diff --git a/config/vnstat2/www/diag_vnstat.php b/config/vnstat2/www/diag_vnstat.php index 04e03911..5e6524c7 100644 --- a/config/vnstat2/www/diag_vnstat.php +++ b/config/vnstat2/www/diag_vnstat.php @@ -1,30 +1,30 @@ "; echo $text; @@ -80,7 +80,7 @@ include("head.inc"); if ($pf_version < 2.0) echo "

{$pgtitle}

"; echo "Go Back
"; - if($savemsg) { + if ($savemsg) { echo "
"; print_info_box($savemsg); echo "
"; @@ -89,25 +89,27 @@ include("head.inc"); print_input_errors($input_errors); ?> - - - + + +
- - - - -
-
- - -
-
- -
-
-
- -
+ + + + +
+
+ + + + +
+
+ +
+
+
+ +
diff --git a/config/vnstat2/www/diag_vnstat2.php b/config/vnstat2/www/diag_vnstat2.php index e5ce1de5..504fd534 100644 --- a/config/vnstat2/www/diag_vnstat2.php +++ b/config/vnstat2/www/diag_vnstat2.php @@ -1,30 +1,30 @@ @@ -87,16 +89,18 @@ else
{$pgtitle}

"; - echo "Go Back
"; - if($savemsg) { + } + echo "Go Back
"; + if ($savemsg) { echo "
"; print_info_box($savemsg); echo "
"; } - if ($input_errors) + if ($input_errors) { print_input_errors($input_errors); + } ?>
@@ -107,29 +111,31 @@ else - +

- - - + + +
- - - - -
-
- - -
-
- -
-
-
- -
+ + + + +
+
+ + + + +
+
+ +
+
+
+ +

diff --git a/config/vnstat2/www/vnstati.php b/config/vnstat2/www/vnstati.php index e5ddcd21..01eca208 100644 --- a/config/vnstat2/www/vnstati.php +++ b/config/vnstat2/www/vnstati.php @@ -14,4 +14,3 @@ echo "

{$pgtitle}

";


- -- cgit v1.2.3 From 3ae988896566a44710767d56cf60765e37350400 Mon Sep 17 00:00:00 2001 From: k-paulius Date: Mon, 13 Jul 2015 23:21:33 -0500 Subject: Declare $config as global variable. Fixes #4834. --- config/vnstat2/vnstat2.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/config/vnstat2/vnstat2.inc b/config/vnstat2/vnstat2.inc index afbf270a..ca8d869d 100644 --- a/config/vnstat2/vnstat2.inc +++ b/config/vnstat2/vnstat2.inc @@ -183,6 +183,7 @@ function vnstat_create_nic_dbs() { function vnstat_install_config() { $vnstat_db_prefix = "/conf/vnstat"; + global $config; conf_mount_rw(); // Create vnstat database dir where it also will work for nanobsd if (is_dir("/usr/local/pkg/vnstat2/vnstat")) { -- cgit v1.2.3 From 1f3536e071b893176cfef5c9c5580ea8e961fb6b Mon Sep 17 00:00:00 2001 From: k-paulius Date: Mon, 13 Jul 2015 23:30:51 -0500 Subject: Bump vnstat2 version --- pkg_config.10.xml | 2 +- pkg_config.8.xml | 2 +- pkg_config.8.xml.amd64 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg_config.10.xml b/pkg_config.10.xml index c164d923..734076bc 100644 --- a/pkg_config.10.xml +++ b/pkg_config.10.xml @@ -672,7 +672,7 @@ net/vnstat - 1.12_3 + 1.12_4 Stable 2.2 crazypark2@yahoo.dk diff --git a/pkg_config.8.xml b/pkg_config.8.xml index 542ad974..cc2b6625 100644 --- a/pkg_config.8.xml +++ b/pkg_config.8.xml @@ -779,7 +779,7 @@ vnstat-1.11.tbz vnstat-1.11_1-i386.pbi /usr/ports/net/vnstat - 1.11_1,3 + 1.11_1,4 Stable 2.0 bryan.paradis@gmail.com diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64 index 62c0c9cd..a1681c9d 100644 --- a/pkg_config.8.xml.amd64 +++ b/pkg_config.8.xml.amd64 @@ -766,7 +766,7 @@ vnstat-1.11.tbz vnstat-1.11_1-amd64.pbi /usr/ports/net/vnstat - 1.11_1,3 + 1.11_1,4 Stable 2.0 bryan.paradis@gmail.com -- cgit v1.2.3