From 3a7497ce62b693025cb60e05626647495f54de48 Mon Sep 17 00:00:00 2001 From: Perry Mason Date: Wed, 5 Jan 2011 20:36:42 +0100 Subject: [vnstat2] Make php frontend an option --- config/vnstat2/bin/vnstati.abc | 3 +-- config/vnstat2/vnstat2.inc | 31 +++++++++++++++++++++++-------- config/vnstat2/vnstat2.sh | 0 config/vnstat2/vnstat2.xml | 6 ++++++ 4 files changed, 30 insertions(+), 10 deletions(-) mode change 100755 => 100644 config/vnstat2/vnstat2.sh (limited to 'config/vnstat2') diff --git a/config/vnstat2/bin/vnstati.abc b/config/vnstat2/bin/vnstati.abc index 10fa8bfb..aa76a4b3 100644 --- a/config/vnstat2/bin/vnstati.abc +++ b/config/vnstat2/bin/vnstati.abc @@ -5,8 +5,7 @@ include("head.inc"); include("fbegin.inc"); $aaaa = $config['installedpackages']['vnstat2']['config'][0]['vnstat_interface']; $bbbb = convert_friendly_interface_to_real_interface_name($aaaa); -$cccc = convert_friendly_interface_to_friendly_descr($aaaa); -$pgtitle = gettext("Vnstati info for $cccc ($bbbb)"); +$pgtitle = gettext("Vnstati info for $aaaa ($bbbb)"); echo "Go Back
"; echo "

{$pgtitle}

"; ?> diff --git a/config/vnstat2/vnstat2.inc b/config/vnstat2/vnstat2.inc index 08c6a28c..896dfd92 100644 --- a/config/vnstat2/vnstat2.inc +++ b/config/vnstat2/vnstat2.inc @@ -63,8 +63,17 @@ function vnstat2_install_cron($vnstat_cron_value) { function change_vnstat_conf(){ conf_mount_rw(); global $config; - $config['installedpackages']['vnstat2']['config'][0]['monthrotate'] = $_POST['monthrotate']; + $config['installedpackages']['vnstat2']['config'][0]['monthrotate'] = $_POST['monthrotate']; + $config['installedpackages']['vnstat2']['config'][0]['vnstat_phpfrontend'] = $_POST['vnstat_phpfrontend']; write_conf_f(); + write_config(); + $no_vnstat_phpfrontend = $config['installedpackages']['vnstat2']['config'][0]['vnstat_phpfrontend']; + if ($no_vnstat_phpfrontend == "on"){ + vnstat_php_frontend(); + } + else { + exec("[ -d /usr/local/www/vnstat2 ] && rm -d -R /usr/local/www/vnstat2"); +} conf_mount_ro(); } @@ -145,15 +154,15 @@ function vnstat_install_config() { exec("[ ! -f /usr/local/www/diag_vnstat.php ] && cp /usr/local/pkg/diag_vnstat.abc /usr/local/www/diag_vnstat.php"); exec("[ ! -f /usr/local/www/vnstati.php ] && cp /usr/local/pkg/vnstati.abc /usr/local/www/vnstati.php"); exec("[ ! -f /usr/local/www/vnstat2_img.php ] && cp /usr/local/pkg/vnstat2_img.abc /usr/local/www/vnstat2_img.php"); -// Unpack and move Vnstat frontend - exec("cd .."); - exec("tar -zxovf /usr/local/pkg/vnstat_php_frontend-1.4.1.tar.gz"); - exec("mv vnstat_php_frontend-1.4.1 /usr/local/www/vnstat2"); // Add MonthRotate value to config.xml and write /usr/local/etc/vnstat.conf $no_monthrotate = $config['installedpackages']['vnstat2']['config'][0]['monthrotate']; if ($no_monthrotate == ""){ $config['installedpackages']['vnstat2']['config'][0]['monthrotate'] = "1"; } + $no_vnstat_phpfrontend = $config['installedpackages']['vnstat2']['config'][0]['vnstat_phpfrontend']; + if ($no_vnstat_phpfrontend == "on"){ + vnstat_php_frontend(); + } write_conf_f(); // Add cron job to config.xml vnstat2_install_cron(true); @@ -177,7 +186,16 @@ function vnstat_install_config() { { exec("/usr/local/bin/vnstat -u -i ". $result2); } + write_config(); + conf_mount_ro(); +} +function vnstat_php_frontend(){ + global $config; +// Unpack and move Vnstat frontend + exec("cd .."); + exec("tar -zxovf /usr/local/pkg/vnstat_php_frontend-1.4.1.tar.gz"); + exec("mv vnstat_php_frontend-1.4.1 /usr/local/www/vnstat2"); // Find information to be writing in config.php // $iface_list_array_items exec("ls /conf/vnstat/ | grep -v '\.'", $vnstat_nic_in); @@ -210,7 +228,6 @@ function vnstat_install_config() { $colorscheme2 = "\$colorscheme['light'] = array("; $colorscheme3 = "\$colorscheme['red'] = array("; $colorscheme4 = "\$colorscheme['pfSense'] = array("; - // ************ Write new config.php ****************** $config_file = << diff --git a/config/vnstat2/vnstat2.sh b/config/vnstat2/vnstat2.sh old mode 100755 new mode 100644 diff --git a/config/vnstat2/vnstat2.xml b/config/vnstat2/vnstat2.xml index 9357a145..08bfc91d 100644 --- a/config/vnstat2/vnstat2.xml +++ b/config/vnstat2/vnstat2.xml @@ -124,6 +124,12 @@ + + Enable vnstat php frontend (Note that no login will be needed) + Enable php frontend for vnstat + vnstat_phpfrontend + checkbox + change_vnstat_conf(); -- cgit v1.2.3