Added more updates
[soho-sigint.git] / client-freqwatch / index.php
diff --git a/client-freqwatch/index.php b/client-freqwatch/index.php
new file mode 100644 (file)
index 0000000..93f4778
--- /dev/null
@@ -0,0 +1,73 @@
+<html>
+<head>
+<script src="Chart.js/Chart.js"></script>
+</head>
+<body>
+<?
+  $r=open_database("freqwatch", "select count(id) as tot,freq from freqs group by freq asc");
+  $num=mysql_numrows($r);
+  $skipper=50;
+  while ($i<$num) {
+    $tot=mysql_result($r,$i,"tot");
+    $freq=mysql_result($r,$i,"freq");
+    #if ($skipper==50) {
+      $labels=$labels.'"'.$freq.'",';
+    #  $skipper=0;
+    #} else {
+    #  $labels=$labels.'" ",';
+    #}
+    $data=$data.'"'.$tot.'",';
+    $i++;
+    #$skipper++;
+    #echo $freq;
+  }
+  $labels=rtrim($labels,',');
+  $data=rtrim($data,",");
+  #$num=150;
+?>
+       <div style="width: 50%">
+                       <canvas id="canvas" height="800" width="<? echo $num*5; ?>"></canvas>
+               </div>
+
+
+       <script>
+       var barChartData = {
+               labels : [<? echo $labels; ?>],
+               datasets : [
+                       {
+                               fillColor : "rgba(151,187,205,0.5)",
+                               strokeColor : "rgba(151,187,205,0.8)",
+                               highlightFill : "rgba(151,187,205,0.75)",
+                               highlightStroke : "rgba(151,187,205,1)",
+                               data : [<? echo $data; ?>]
+                       }
+               ]
+       }
+       window.onload = function(){
+               var ctx = document.getElementById("canvas").getContext("2d");
+               window.myBar = new Chart(ctx).Bar(barChartData, {
+                       animation: false,
+                       scaleLineWidth: 1,
+                       barStrokeWidth : 0.01,
+                       responsive : false
+               });
+       }
+       </script>
+</body>
+</html>
+<?
+function open_database($dab,$sqlquery)
+{
+  $db = mysql_connect("localhost", "freqwatch", "DAPASSWORD");
+  if (!$db) {
+    echo "Cant connect to server.<br>";
+    exit();
+  }
+  if (! @mysql_select_db($dab)) {
+    echo "Cant connect to DB.<br>";
+    exit();
+  }
+  $result=mysql_query($sqlquery);
+  return($result);
+}
+?>