From dadfceb224e638604ab3fa8043d2475763141ac5 Mon Sep 17 00:00:00 2001 From: Colin Smith Date: Sun, 9 Oct 2005 17:11:15 +0000 Subject: Move sync_package_pfstat() into global functions. Second part of ticket #595. --- packages/pfstat.xml | 108 +++++++++++++++++++++++++--------------------------- 1 file changed, 52 insertions(+), 56 deletions(-) diff --git a/packages/pfstat.xml b/packages/pfstat.xml index 00231b30..90aff5fa 100644 --- a/packages/pfstat.xml +++ b/packages/pfstat.xml @@ -206,61 +206,61 @@ + + function sync_package_pfstat() { + conf_mount_rw(); + config_lock(); + global $config; + $fout = fopen("/usr/local/etc/pfstat.conf","w"); + if($config['installedpackages']['pfstat']['config'] != "") { + foreach($config['installedpackages']['pfstat']['config'] as $rowhelper) { + $leftgraphtext = ""; + $rightgraphtext = ""; + $isfirstleft = 0; + $isfirstright = 0; + $fromclassification = $rowhelper['fromclassification']; + $imagename = $rowhelper['imagename']; + $pos = strrpos($imagename, ".jpg"); + if ($pos === false) { + $imagename .= ".jpg"; + } + $from = $rowhelper['from']; + $graphsizewidth = $rowhelper['graphsizewidth']; + $graphsizeheight = $rowhelper['graphsizeheight']; + 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; + } + } + fwrite($fout, "image \"/usr/local/www/pfstat/" . $imagename ."\" { \n"); + if($from == "") $from = "30"; + fwrite($fout, "from " . $from . " " . $fromclassification . " to now \n"); + fwrite($fout, "width " . $graphsizewidth . " height " . $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"); + } + } + fclose($fout); + conf_mount_ro(); + config_unlock(); + } + - function sync_package_pfstat() { - conf_mount_rw(); - config_lock(); - global $config; - $fout = fopen("/usr/local/etc/pfstat.conf","w"); - if($config['installedpackages']['pfstat']['config'] != "") { - foreach($config['installedpackages']['pfstat']['config'] as $rowhelper) { - $leftgraphtext = ""; - $rightgraphtext = ""; - $isfirstleft = 0; - $isfirstright = 0; - $fromclassification = $rowhelper['fromclassification']; - $imagename = $rowhelper['imagename']; - $pos = strrpos($imagename, ".jpg"); - if ($pos === false) { - $imagename .= ".jpg"; - } - $from = $rowhelper['from']; - $graphsizewidth = $rowhelper['graphsizewidth']; - $graphsizeheight = $rowhelper['graphsizeheight']; - 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; - } - } - fwrite($fout, "image \"/usr/local/www/pfstat/" . $imagename ."\" { \n"); - if($from == "") $from = "30"; - fwrite($fout, "from " . $from . " " . $fromclassification . " to now \n"); - fwrite($fout, "width " . $graphsizewidth . " height " . $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"); - } - } - fclose($fout); - conf_mount_ro(); - config_unlock(); - } sync_package_pfstat(); - - sync_package_pfstat(); @@ -273,8 +273,4 @@ unlink_if_exists("/usr/local/etc/pfstat"); rmdir_recursive("/usr/local/www/pfstat"); - -- cgit v1.2.3