Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //ini_set('display_errors',1);
- //error_reporting(E_ALL);
- session_start();
- require_once 'common.php';
- include_once 'header.php';
- include_once '../../config/DatabaseConnection.php';
- if(!isset($_SESSION['is_valid_user']) || empty($_SESSION['is_valid_user']) || ($_SESSION['user_type'] != 'admin'))
- {
- header('Location: login.php');
- }
- //Get normalized values of start/end date
- if(isset($_GET['start_date'])) {
- $start_date = trim($_GET['start_date']);
- $start_date = date('Y-m-d', strtotime($start_date));
- } else {
- $start_date = date('Y-m-d');
- }
- //Grouped or not grouped logic
- $grouped = $_GET["grouped"] === "1";
- //Fetch data
- $con = new DatabaseConnection('uk');
- $data = [];
- $count = 0;
- if(!$grouped) {
- $result = $con->Query("SELECT * FROM coukcons_debt.boberdoo_call_log
- WHERE DATE(date_created) BETWEEN '{$start_date}' AND '{$start_date}' ");
- while($row = mysqli_fetch_assoc($result)) {
- $data[] = [
- 'date_created' => date('m/d/y H:i:s', strtotime($row['date_created'])),
- 'ip' => $row['ip'],
- 'method' => $row['method'],
- 'page' => $row['page'],
- 'arguments' => $row['arguments']
- ];
- $count++;
- }
- } else {
- $result = $con->Query("SELECT DATE(date_created) as date_created, ip, method, page, COUNT(*) as count FROM coukcons_debt.boberdoo_call_log
- WHERE DATE(date_created) BETWEEN '{$start_date}' AND '{$start_date}'
- GROUP BY method, page, ip
- ");
- while($row = mysqli_fetch_assoc($result)) {
- $data[] = [
- 'date_created' => date('m/d/y', strtotime($row['date_created'])),
- 'ip' => $row['ip'],
- 'method' => $row['method'],
- 'page' => $row['page'],
- 'count' => $row['count'],
- ];
- $count += $row['count'];
- }
- }
- $time_label = ' - ' . date('n/d/Y', strtotime($start_date));
- //Switch to local format
- $start_date = date('m/d/Y', strtotime($start_date));
- ?>
- <title>Boberdoo Log</title>
- <script>
- $(document).ready(function() {
- $("#start_date").datepicker();
- });
- </script>
- </head>
- <body>
- <div class="container">
- <?php include_once 'menu.php'; ?>
- <form id="boberdoo_log" name="boberdoo_log" method="get" action="">
- <table class="form-table">
- <tr>
- <td>Date</td>
- <td><input type="text" name="start_date" id="start_date" value="<?php echo $start_date; ?>" class="textbox-size" /></td>
- </tr>
- <tr>
- <td><label for="group">Group</label></td>
- <td><input type="checkbox" name="grouped" id="grouped" value="1" <?=$grouped? "checked": ""?>/></td>
- </tr>
- <tr>
- <td> </td>
- <td><input name="Search" type="submit" id="Search" value="Search" /></td>
- </tr>
- </table>
- </form>
- <br>
- <div class="table-wrapper">
- <div class="table-title">
- Boberdoo Call Log <?=$time_label?>
- <a href="#" onclick="location.reload(); return false;" class="refresh"></a>
- </div>
- <table border="0" cellspacing="0" cellpadding="0" id="table-1">
- <thead>
- <th>Date/Time</th>
- <th>Method</th>
- <th>Page</th>
- <th>IP</th>
- <?php if(!$grouped) { ?>
- <th>Arguments</th>
- <?php } else { ?>
- <th>Count</th>
- <?php } ?>
- </thead>
- <tbody>
- <?php foreach($data as $row) { ?>
- <tr>
- <td align="right"><?=$row['date_created']?></td>
- <td align="right"><?=$row['method']?></td>
- <td align="right"><?=$row['page']?></td>
- <td align="right"><?=$row['ip']?></td>
- <?php if(!$grouped) { ?>
- <td align="left"><?=$row['arguments']?></td>
- <?php } else { ?>
- <td align="left"><?=$row['count']?></td>
- <?php } ?>
- </tr>
- <?php } ?>
- </tbody>
- <tfoot>
- <th>Totals</th>
- <th>-</th>
- <th>-</th>
- <th>-</th>
- <th align="left"><?=$count?></th>
- </tfoot>
- </table>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement