Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.64 KB | None | 0 0
  1. <?php
  2. //ini_set('display_errors',1);
  3. //error_reporting(E_ALL);
  4.  
  5. session_start();
  6. require_once 'common.php';
  7. include_once 'header.php';
  8. include_once '../../config/DatabaseConnection.php';
  9.  
  10.  
  11. if(!isset($_SESSION['is_valid_user']) || empty($_SESSION['is_valid_user']) || ($_SESSION['user_type'] != 'admin'))
  12. {
  13.     header('Location: login.php');
  14. }
  15.  
  16. //Get normalized values of start/end date
  17. if(isset($_GET['start_date'])) {
  18.     $start_date = trim($_GET['start_date']);
  19.     $start_date = date('Y-m-d', strtotime($start_date));
  20. } else {
  21.     $start_date = date('Y-m-d');
  22. }
  23.  
  24. //Grouped or not grouped logic
  25. $grouped = $_GET["grouped"] === "1";
  26.  
  27. //Fetch data
  28. $con = new DatabaseConnection('uk');
  29. $data = [];
  30. $count = 0;
  31. if(!$grouped) {
  32.     $result = $con->Query("SELECT * FROM coukcons_debt.boberdoo_call_log
  33.         WHERE DATE(date_created) BETWEEN '{$start_date}' AND '{$start_date}' ");
  34.        
  35.  
  36.     while($row = mysqli_fetch_assoc($result)) {
  37.         $data[] = [
  38.             'date_created' => date('m/d/y H:i:s', strtotime($row['date_created'])),
  39.             'ip' => $row['ip'],
  40.             'method' => $row['method'],
  41.             'page' => $row['page'],
  42.             'arguments' => $row['arguments']
  43.         ];
  44.         $count++;
  45.     }
  46. } else {
  47.     $result = $con->Query("SELECT DATE(date_created) as date_created, ip, method, page, COUNT(*) as count FROM coukcons_debt.boberdoo_call_log
  48.         WHERE DATE(date_created) BETWEEN '{$start_date}' AND '{$start_date}'
  49.         GROUP BY method, page, ip
  50.     ");
  51.    
  52.     while($row = mysqli_fetch_assoc($result)) {
  53.         $data[] = [
  54.             'date_created' => date('m/d/y', strtotime($row['date_created'])),
  55.             'ip' => $row['ip'],
  56.             'method' => $row['method'],
  57.             'page' => $row['page'],
  58.             'count' => $row['count'],
  59.         ];
  60.         $count += $row['count'];
  61.     }
  62. }
  63.  
  64. $time_label = ' - ' . date('n/d/Y', strtotime($start_date));
  65.  
  66. //Switch to local format
  67. $start_date = date('m/d/Y', strtotime($start_date));
  68.  
  69. ?>
  70. <title>Boberdoo Log</title>
  71. <script>
  72.     $(document).ready(function() {
  73.         $("#start_date").datepicker();
  74.     });
  75. </script>
  76. </head>
  77.  
  78. <body>
  79. <div class="container">
  80. <?php include_once 'menu.php'; ?>
  81.  
  82. <form id="boberdoo_log" name="boberdoo_log" method="get" action="">
  83.     <table class="form-table">
  84.         <tr>
  85.             <td>Date</td>
  86.             <td><input type="text" name="start_date" id="start_date" value="<?php echo $start_date; ?>" class="textbox-size" /></td>
  87.         </tr>
  88.         <tr>
  89.             <td><label for="group">Group</label></td>
  90.             <td><input type="checkbox" name="grouped" id="grouped" value="1" <?=$grouped? "checked": ""?>/></td>
  91.         </tr>
  92.         <tr>
  93.             <td>&nbsp;</td>
  94.             <td><input name="Search" type="submit" id="Search" value="Search" /></td>
  95.         </tr>
  96.     </table>
  97. </form>
  98.  
  99. <br>
  100.  
  101. <div class="table-wrapper">
  102.     <div class="table-title">
  103.         Boberdoo Call Log <?=$time_label?>
  104.         <a href="#" onclick="location.reload(); return false;" class="refresh"></a>
  105.     </div>
  106.     <table border="0" cellspacing="0" cellpadding="0" id="table-1">
  107.         <thead>
  108.             <th>Date/Time</th>
  109.             <th>Method</th>
  110.             <th>Page</th>
  111.             <th>IP</th>
  112.             <?php if(!$grouped) { ?>
  113.             <th>Arguments</th>
  114.             <?php } else { ?>
  115.             <th>Count</th>
  116.             <?php } ?>
  117.         </thead>
  118.         <tbody>
  119.             <?php foreach($data as $row) { ?>
  120.             <tr>
  121.                 <td align="right"><?=$row['date_created']?></td>
  122.                 <td align="right"><?=$row['method']?></td>
  123.                 <td align="right"><?=$row['page']?></td>
  124.                 <td align="right"><?=$row['ip']?></td>
  125.                 <?php if(!$grouped) { ?>
  126.                 <td align="left"><?=$row['arguments']?></td>
  127.                 <?php } else { ?>
  128.                 <td align="left"><?=$row['count']?></td>
  129.                 <?php } ?>
  130.             </tr>
  131.             <?php } ?>
  132.         </tbody>
  133.         <tfoot>
  134.             <th>Totals</th>
  135.             <th>-</th>
  136.             <th>-</th>
  137.             <th>-</th>
  138.             <th align="left"><?=$count?></th>
  139.         </tfoot>
  140.     </table>
  141.    
  142. </div>
  143.  
  144.  
  145. </body>
  146. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement