Guest User

Untitled

a guest
Oct 21st, 2017
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.97 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4.     <meta charset="utf-8">
  5.     <meta http-equiv="refresh" content="10">
  6.    
  7.     <title>Pocsag v1.0</title>
  8.     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  9.  
  10.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  11.     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  12. </head>
  13. <body>
  14.  
  15. <?php
  16. $mongo_user = "----";
  17. $mongo_pass = "----";
  18. $mongo_authdb = "----";
  19.  
  20. require_once __DIR__ . '/vendor/autoload.php';
  21. // Connect to MongoDB
  22. $m = new MongoDB\Client("mongodb://{$mongo_user}:{$mongo_pass}@localhost/{$mongo_authdb}");
  23. $db = $m->pocsag;
  24. $coll = $db->messages;
  25.  
  26. // Query
  27. $options = ['sort' => ['_id' => -1], 'limit' => 500];
  28. $cursor = $coll->find([], $options);
  29.  
  30. // Filter by gateway ID
  31. if (!empty($_GET['ric'])&&!empty($_GET['ric2'])) {
  32.     $options = ['sort' => ['_id' => -1], 'limit' => 500];
  33.     $cursor = $coll->find('$and' => array(array('ric' => $_GET['ric']),array('ric' => $_GET['ric2'])), $options);
  34. }
  35. elseif (!empty($_GET['ric'])) {
  36.     $options = ['sort' => ['_id' => -1], 'limit' => 500];
  37.     $cursor = $coll->find(array('ric' => $_GET['ric']), $options);
  38. }
  39.  
  40. echo "<div class=\"container-fluid\">";
  41. echo "    <table class=\"table\">";
  42. echo "      <thead>";
  43. echo "        <tr> ";
  44. echo "          <th>Timestamp</th>";
  45. echo "          <th>Ric Code</th>";
  46. echo "          <th>Message</th>";
  47. echo "        </tr> ";
  48. echo "      </thead> ";
  49. echo "      <tbody> ";
  50.  
  51. #$cursor = $cursor->sort(array('_id' => -1))->limit(500)->timeout(-1);
  52. #while ($cursor->hasNext()) {
  53. foreach ($cursor as $doc) {
  54.     $ric = $doc['ric'];
  55.     print "<tr class='info'>";
  56.     print "<td>" . $doc['timestamp'] . "</td>";
  57.     print "<td><a href=\"index.php?ric={$ric}\">{$ric}</td>";
  58.     print "<td>" . $doc['message'] . "</td>";
  59.     print "</tr>";
  60. }
  61. echo "      </tbody> ";
  62. echo "    <table> ";
  63. echo "</div>"
  64. ?>
Add Comment
Please, Sign In to add comment