Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta http-equiv="refresh" content="10">
- <title>Pocsag v1.0</title>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
- </head>
- <body>
- <?php
- $mongo_user = "----";
- $mongo_pass = "----";
- $mongo_authdb = "----";
- require_once __DIR__ . '/vendor/autoload.php';
- // Connect to MongoDB
- $m = new MongoDB\Client("mongodb://{$mongo_user}:{$mongo_pass}@localhost/{$mongo_authdb}");
- $db = $m->pocsag;
- $coll = $db->messages;
- // Query
- $options = ['sort' => ['_id' => -1], 'limit' => 500];
- $cursor = $coll->find([], $options);
- // Filter by gateway ID
- if (!empty($_GET['ric'])&&!empty($_GET['ric2'])) {
- $options = ['sort' => ['_id' => -1], 'limit' => 500];
- $cursor = $coll->find('$and' => array(array('ric' => $_GET['ric']),array('ric' => $_GET['ric2'])), $options);
- }
- elseif (!empty($_GET['ric'])) {
- $options = ['sort' => ['_id' => -1], 'limit' => 500];
- $cursor = $coll->find(array('ric' => $_GET['ric']), $options);
- }
- echo "<div class=\"container-fluid\">";
- echo " <table class=\"table\">";
- echo " <thead>";
- echo " <tr> ";
- echo " <th>Timestamp</th>";
- echo " <th>Ric Code</th>";
- echo " <th>Message</th>";
- echo " </tr> ";
- echo " </thead> ";
- echo " <tbody> ";
- #$cursor = $cursor->sort(array('_id' => -1))->limit(500)->timeout(-1);
- #while ($cursor->hasNext()) {
- foreach ($cursor as $doc) {
- $ric = $doc['ric'];
- print "<tr class='info'>";
- print "<td>" . $doc['timestamp'] . "</td>";
- print "<td><a href=\"index.php?ric={$ric}\">{$ric}</td>";
- print "<td>" . $doc['message'] . "</td>";
- print "</tr>";
- }
- echo " </tbody> ";
- echo " <table> ";
- echo "</div>"
- ?>
Add Comment
Please, Sign In to add comment