aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/pfstat.xml67
1 files changed, 38 insertions, 29 deletions
diff --git a/packages/pfstat.xml b/packages/pfstat.xml
index 2f6e8aa2..1349bb55 100644
--- a/packages/pfstat.xml
+++ b/packages/pfstat.xml
@@ -177,44 +177,53 @@
</rowhelper>
</field>
</fields>
- <custom_add_php_command_late>
- </custom_add_php_command_late>
- <custom_php_resync_config_command>
+ <custom_php_command_before_form>
+ function sync_package() {
+ global $config;
$fout = fopen("/usr/local/etc/pfstat.conf","w");
$leftgraphtext = "";
$rightgraphtext = "";
$isfirstleft = 0;
$isfirstright = 0;
- foreach($config['installedpackages']['pfstat']['config'] as $rowhelper) {
- foreach($rowhelper['row'] as $row) {
- if($row['location'] == "left") {
- if($isfirstleft == 1) $leftgraphtext .= ",\n";
- $leftgraphtext .= "graph " . $row['counters'] . " label \"" . $row['counters'] . "\" color " . $row['color'] . " " . $row['appearance'];
- $isfirstleft = 1;
- } else {
- if($isfirstright == 1) $rightgraphtext .= ",\n";
- $rightgraphtext .= "graph " . $row['counters'] . " label \"" . $row['counters'] . "\" color " . $row['color'] . " " . $row['appearance'];
- $isfirstright = 1;
+ if($config['installedpackages']['pfstat']['config'] != "") {
+ foreach($config['installedpackages']['pfstat']['config'] as $rowhelper) {
+ foreach($rowhelper['row'] as $row) {
+ if($row['location'] == "left") {
+ if($isfirstleft == 1) $leftgraphtext .= ",\n";
+ $leftgraphtext .= "graph " . $row['counters'] . " label \"" . $row['counters'] . "\" color " . $row['color'] . " " . $row['appearance'];
+ $isfirstleft = 1;
+ } else {
+ if($isfirstright == 1) $rightgraphtext .= ",\n";
+ $rightgraphtext .= "graph " . $row['counters'] . " label \"" . $row['counters'] . "\" color " . $row['color'] . " " . $row['appearance'];
+ $isfirstright = 1;
+ }
}
}
- }
- foreach($config['installedpackages']['pfstat']['config'] as $pkgconfig) {
- fwrite($fout, "image \"/usr/local/www/pfstat/" . $pkgconfig['imagename'] ."\" { \n");
- $from = $pkgconfig['from'];
- if($from == "") $from = "30";
- fwrite($fout, "from " . $from . " " . $pkgconfig['fromclassification'] . " to now \n");
- fwrite($fout, "width " . $pkgconfig['graphsizewidth'] . " height " . $pkgconfig['graphsizeheight'] . " \n");
- if($leftgraphtext != "") {
- fwrite($fout, " left \n");
- fwrite($fout, " " . $leftgraphtext . "\n");
- }
- if($rightgraphtext != "") {
- fwrite($fout, " right \n");
- fwrite($fout, " " . $rightgraphtext . "\n");
+ foreach($config['installedpackages']['pfstat']['config'] as $pkgconfig) {
+ fwrite($fout, "image \"/usr/local/www/pfstat/" . $pkgconfig['imagename'] ."\" { \n");
+ $from = $pkgconfig['from'];
+ if($from == "") $from = "30";
+ fwrite($fout, "from " . $from . " " . $pkgconfig['fromclassification'] . " to now \n");
+ fwrite($fout, "width " . $pkgconfig['graphsizewidth'] . " height " . $pkgconfig['graphsizeheight'] . " \n");
+ if($leftgraphtext != "") {
+ fwrite($fout, " left \n");
+ fwrite($fout, " " . $leftgraphtext . "\n");
+ }
+ if($rightgraphtext != "") {
+ fwrite($fout, " right \n");
+ fwrite($fout, " " . $rightgraphtext . "\n");
+ }
+ fwrite($fout, "}\n\n");
}
- fwrite($fout, "}\n\n");
+ fclose($fout);
}
- fclose($fout);
+ }
+ sync_package();
+ </custom_php_command_before_form>
+ <custom_add_php_command_late>
+ </custom_add_php_command_late>
+ <custom_php_resync_config_command>
+ sync_package();
</custom_php_resync_config_command>
<custom_php_install_command>
system("mkdir -p /usr/local/www/pfstat 2>/dev/null");