PHP frontend for the vnStatI utility. Easily get up to date graphs of your network traffic using vnStat.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.8 KiB

8 years ago
8 years ago
  1. <?php
  2. //
  3. // index.php
  4. // vnStatGraphP
  5. //
  6. // Created by Mr. Gecko on 3/28/16.
  7. // Copyright (c) 2016 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
  8. //
  9. require("config.php");
  10. ?>
  11. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  12. <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  15. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  16. <meta name="Copyright" content="Copyright (c) 2016 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/" />
  17. <meta name="Author" content="James Coleman" />
  18. <title>vnStat GraphP</title>
  19. <style type="text/css">
  20. #optionsBox {
  21. border-style: solid;
  22. border-color: #afafaf;
  23. border-width: 1pt;
  24. padding: 3pt;
  25. width: 490px;
  26. }
  27. #optionsTitle {
  28. background-color: #5f5f5f;
  29. color: #ffffff;
  30. margin: -1pt;
  31. padding: 2pt;
  32. padding-left: 5pt;
  33. }
  34. #optionsBox hr {
  35. color: #afafaf;
  36. }
  37. label.optionName {
  38. width: 60pt;
  39. display: inline-block;
  40. text-align: right;
  41. }
  42. span.optionContainer {
  43. }
  44. </style>
  45. </head>
  46. <body>
  47. <?
  48. if (!isset($_REQUEST['i']) && count($defaultGraphs)>=1) {
  49. foreach ($defaultGraphs as $thisGraph) {
  50. ?><img src="<?=$thisGraph?>" /><br /><?
  51. }
  52. ?><br /><br /><?
  53. }
  54. ?>
  55. <form action=""><div id="optionsBox">
  56. <div id="optionsTitle">vnStatGraphP Options</div><br />
  57. <label class="optionName" for="iface">Interface:</label>
  58. <span class="optionContainer"><select name="i" id="iface"><?
  59. foreach ($ifaceList as $interface) {
  60. $name = $interface;
  61. if (!empty($ifaceTitles[$interface])) {
  62. $name = $interface." - ".$ifaceTitles[$interface];
  63. }
  64. ?><option value="<?=$interface?>"<?=($iface==$interface ? " selected" : "")?>><?=$name?></option><?
  65. }
  66. ?></select></span><br />
  67. <label class="optionName" for="graph">Graph:</label>
  68. <span class="optionContainer"><select name="g" id="graph">
  69. <option value="vs"<?=($graph=="vs" ? " selected" : "")?>>Vertical summary with hours</option>
  70. <option value="hs"<?=($graph=="hs" ? " selected" : "")?>>Horizontal summary with hours</option>
  71. <option value="s"<?=($graph=="s" ? " selected" : "")?>>Summary</option>
  72. <option value="t"<?=($graph=="t" ? " selected" : "")?>>Top 10</option>
  73. <option value="m"<?=($graph=="m" ? " selected" : "")?>>Months</option>
  74. <option value="d"<?=($graph=="d" ? " selected" : "")?>>Days</option>
  75. <option value="h"<?=($graph=="h" ? " selected" : "")?>>Hours</option>
  76. </select></span><br />
  77. <label class="optionName" for="noHeader">No Header:</label>
  78. <span class="optionContainer"><input type="checkbox" name="nh" id="noHeader"<?=($noHeader ? " checked" : "")?> /></span><br />
  79. <label class="optionName" for="noEdge">No Edge:</label>
  80. <span class="optionContainer"><input type="checkbox" name="ne" id="noEdge"<?=($noEdge ? " checked" : "")?> /></span><br />
  81. <label class="optionName" for="noLegend">No Legend:</label>
  82. <span class="optionContainer"><input type="checkbox" name="nl" id="noLegend"<?=($noLegend ? " checked" : "")?> /></span><br />
  83. <label class="optionName" for="rateUnit">Rate Unit:</label>
  84. <span class="optionContainer"><input type="checkbox" name="ru" id="rateUnit"<?=($rateUnit ? " checked" : "")?> /></span> - Swap configured rate unit<br />
  85. <hr />
  86. <input type="submit" value="Generate Graph" />
  87. </div></form><br />
  88. <?
  89. if (isset($_REQUEST['i']) || count($defaultGraphs)==0) {
  90. $data = "i=".urlencode($iface);
  91. $data .= "&g=".$graph;
  92. if ($noHeader) {
  93. $data .= "&nh";
  94. }
  95. if ($noEdge) {
  96. $data .= "&ne";
  97. }
  98. if ($noLegend) {
  99. $data .= "&nl";
  100. }
  101. if ($rateUnit) {
  102. $data .= "&ru";
  103. }
  104. ?>
  105. <span id="vnStatResult"><img src="vnstati.php?<?=$data?>" /></span>
  106. <?}?>
  107. </body>
  108. </html>