diff --git a/dashboard/pgs/config.inc.php b/dashboard/pgs/config.inc.php index 180c778..2c69ed5 100755 --- a/dashboard/pgs/config.inc.php +++ b/dashboard/pgs/config.inc.php @@ -13,35 +13,33 @@ ShowLast3ByteOfIP $Service = array(); $CallingHome = array(); $PageOptions = array(); +$VNStat = array(); -$PageOptions['ContactEmail'] = 'your_email'; // Support E-Mail address +$PageOptions['ContactEmail'] = 'your_mail'; // Support E-Mail address -$PageOptions['DashboardVersion'] = '2.3.7'; // Dashboard Version - -$PageOptions['PageRefreshActive'] = true; // Activate automatic refresh -$PageOptions['PageRefreshDelay'] = '10000'; // Page refresh time in miliseconds +$PageOptions['DashboardVersion'] = '2.3.8'; // Dashboard Version +$PageOptions['PageRefreshActive'] = true; // Activate automatic refresh +$PageOptions['PageRefreshDelay'] = '10000'; // Page refresh time in miliseconds $PageOptions['RepeatersPage'] = array(); -$PageOptions['RepeatersPage']['LimitTo'] = 99; // Number of Repeaters to show -$PageOptions['RepeatersPage']['IPModus'] = 'ShowFullIP'; // See possible options above -$PageOptions['RepeatersPage']['MasqueradeCharacter'] = '*'; // Character used for masquerade - +$PageOptions['RepeatersPage']['LimitTo'] = 99; // Number of Repeaters to show +$PageOptions['RepeatersPage']['IPModus'] = 'ShowFullIP'; // See possible options above +$PageOptions['RepeatersPage']['MasqueradeCharacter'] = '*'; // Character used for masquerade $PageOptions['PeerPage'] = array(); -$PageOptions['PeerPage']['LimitTo'] = 99; // Number of peers to show -$PageOptions['PeerPage']['IPModus'] = 'ShowFullIP'; // See possible options above -$PageOptions['PeerPage']['MasqueradeCharacter'] = '*'; // Character used for masquerade +$PageOptions['PeerPage']['LimitTo'] = 99; // Number of peers to show +$PageOptions['PeerPage']['IPModus'] = 'ShowFullIP'; // See possible options above +$PageOptions['PeerPage']['MasqueradeCharacter'] = '*'; // Character used for masquerade $PageOptions['LastHeardPage']['LimitTo'] = 39; // Number of stations to show -$PageOptions['ModuleNames'] = array(); // Module nomination +$PageOptions['ModuleNames'] = array(); // Module nomination $PageOptions['ModuleNames']['A'] = 'Int.'; $PageOptions['ModuleNames']['B'] = 'Regional'; $PageOptions['ModuleNames']['C'] = 'National'; $PageOptions['ModuleNames']['D'] = ''; - $PageOptions['MetaDescription'] = 'XLX is a D-Star Reflector System for Ham Radio Operators.'; // Meta Tag Values, usefull for Search Engine $PageOptions['MetaKeywords'] = 'Ham Radio, D-Star, XReflector, XLX, XRF, DCS, REF, '; // Meta Tag Values, usefull forSearch Engine $PageOptions['MetaAuthor'] = 'LX1IQ'; // Meta Tag Values, usefull for Search Engine @@ -50,27 +48,24 @@ $PageOptions['MetaRobots'] = 'index,follow'; $PageOptions['UserPage']['ShowFilter'] = true; // Show Filter on Users page +$PageOptions['Traffic']['Show'] = false; // Enable vnstat traffic statistics + $Service['PIDFile'] = '/var/log/xlxd.pid'; $Service['XMLFile'] = '/var/log/xlxd.xml'; -$CallingHome['Active'] = false; // xlx phone home, true or false -$CallingHome['MyDashBoardURL'] = 'http://your_dashboard'; // dashboard url +$CallingHome['Active'] = false; // xlx phone home, true or false +$CallingHome['MyDashBoardURL'] = 'http://your_dashboard'; // dashboard url $CallingHome['ServerURL'] = 'http://xlxapi.rlx.lu/api.php'; // database server, do not change !!!! $CallingHome['PushDelay'] = 600; // push delay in seconds $CallingHome['Country'] = "your_country"; // Country -$CallingHome['Comment'] = "your_comment"; // Comment. Max 100 character +$CallingHome['Comment'] = "your_comment"; // Comment. Max 100 character $CallingHome['HashFile'] = "/tmp/callinghome.php"; // Make sure the apache user has read and write permissions in this folder. $CallingHome['OverrideIPAddress'] = ""; // Insert your IP address here. Leave blank for autodetection. No need to enter a fake address. $CallingHome['InterlinkFile'] = "/xlxd/xlxd.interlink"; // Path to interlink file - -/* - include an extra config file for people who dont like to mess with shipped config.ing.php - this makes updating dashboard from git a little bit easier -*/ - -if (file_exists("../config.inc.php")) { - include ("../config.inc.php"); -} +$VNStat['Interfaces'] = array(); +$VNStat['Interfaces'][0]['Name'] = 'eth0'; +$VNStat['Interfaces'][0]['Address'] = 'eth0'; +$VNStat['Binary'] = '/usr/bin/vnstat'; ?> diff --git a/dashboard/pgs/functions.php b/dashboard/pgs/functions.php index 353b2d3..ea68472 100755 --- a/dashboard/pgs/functions.php +++ b/dashboard/pgs/functions.php @@ -60,4 +60,133 @@ function CreateCode ($laenge) { return $out; } + +function UpdateHashFile($HashFile, $newLastSync, $newHash) { + if (version_compare(phpversion(), "5.6", ">=")) { + $Ressource = @fopen($HashFile, "c"); + if ($Ressource) { + if (flock($Ressource, LOCK_EX)) { + @fwrite($Ressource, "'); + + @fflush($Ressource); + @ftruncate($Ressource, ftell($Ressource)); + @flock($Ressource, LOCK_UN); + } + @fclose($Ressource); + @chmod($HashFile, 0777); + return true; + } + } + else { + $Ressource = @fopen($HashFile, "w"); + if ($Ressource) { + @fwrite($Ressource, "'); + @fclose($Ressource); + @exec("chmod 777 ".$CallingHome['HashFile']); + $CallHomeNow = true; + } + } + + return false; +} + +function VNStatLocalize($str) { + global $L; + if (isset($L[$str])) { + return $L[$str]; + } + else { + return $str; + } +} + +function VNStatGetData($iface, $vnstat_bin) { + $vnstat_data = array(); + + $fd = @popen("$vnstat_bin --dumpdb -i $iface", "r"); + if (is_resource($fd)) { + $buffer = ''; + while (!feof($fd)) { + $buffer .= fgets($fd); + } + $vnstat_data = explode("\n", $buffer); + pclose($fd); + } + + $day = array(); + $hour = array(); + $month = array(); + $top = array(); + + if (isset($vnstat_data[0]) && strpos($vnstat_data[0], 'Error') !== false) { + return; + } + + foreach($vnstat_data as $line) { + $d = explode(';', trim($line)); + if ($d[0] == 'd') { + $day[$d[1]]['time'] = $d[2]; + $day[$d[1]]['rx'] = $d[3] * 1024 + $d[5]; + $day[$d[1]]['tx'] = $d[4] * 1024 + $d[6]; + $day[$d[1]]['act'] = $d[7]; + $day[$d[1]]['rx2'] = $d[5]; + $day[$d[1]]['tx2'] = $d[6]; + } + else if ($d[0] == 'm') { + $month[$d[1]]['time'] = $d[2]; + $month[$d[1]]['rx'] = $d[3] * 1024 + $d[5]; + $month[$d[1]]['tx'] = $d[4] * 1024 + $d[6]; + $month[$d[1]]['act'] = $d[7]; + $month[$d[1]]['rx2'] = $d[5]; + $month[$d[1]]['tx2'] = $d[6]; + } + else if ($d[0] == 'h') { + $hour[$d[1]]['time'] = $d[2]; + $hour[$d[1]]['rx'] = $d[3]; + $hour[$d[1]]['tx'] = $d[4]; + $hour[$d[1]]['act'] = 1; + } + else if ($d[0] == 't') { + $top[$d[1]]['time'] = $d[2]; + $top[$d[1]]['rx'] = $d[3] * 1024 + $d[5]; + $top[$d[1]]['tx'] = $d[4] * 1024 + $d[6]; + $top[$d[1]]['act'] = $d[7]; + } + else { + $summary[$d[0]] = isset($d[1]) ? $d[1] : ''; + } + } + + rsort($day); + rsort($month); + rsort($hour); + + return array($day, $month, $hour, $day, $month, $top, $summary); +} + + +function kbytes_to_string($kb) { + $byte_notation = null; + $units = array('TB','GB','MB','KB'); + $scale = 1024*1024*1024; + $ui = 0; + $custom_size = isset($byte_notation) && in_array($byte_notation, $units); + + while ((($kb < $scale) && ($scale > 1)) || $custom_size) { + $ui++; + $scale = $scale / 1024; + if ($custom_size && $units[$ui] == $byte_notation) { + break; + } + } + return sprintf("%0.2f %s", ($kb/$scale),$units[$ui]); +} + + ?> \ No newline at end of file diff --git a/dashboard/pgs/traffic.php b/dashboard/pgs/traffic.php new file mode 100644 index 0000000..7b57ff2 --- /dev/null +++ b/dashboard/pgs/traffic.php @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + '; + +for ($i=0;$i 0) { + echo ' + + + + + + + '; + } +} + +echo '
Network interfacesStatistics
'.$VNStat['Interfaces'][$i]['Name'].''; + if ($i < count($VNStat['Interfaces'])) { + echo '
'; + } + } + + ?>
+
DayRXTXAvg RxAvg TX
'.date("d.m.Y", $Data[0][$i]['time']).''.kbytes_to_string($Data[0][$i]['rx']).''.kbytes_to_string($Data[0][$i]['tx']).''.kbytes_to_string($Data[0][$i]['rx2']).''.kbytes_to_string($Data[0][$i]['tx2']).'
'; + + + + +echo ' +
+ + + + + + + '; + +for ($i=0;$i 0) { + echo ' + + + + + + + '; + } +} + +echo '
MonthRXTXAvg RxAvg TX
'.date("F", $Data[1][$i]['time']).''.kbytes_to_string($Data[1][$i]['rx']).''.kbytes_to_string($Data[1][$i]['tx']).''.kbytes_to_string($Data[1][$i]['rx2']).''.kbytes_to_string($Data[1][$i]['tx2']).'
'; +?> + + +
\ No newline at end of file