-
Notifications
You must be signed in to change notification settings - Fork 24
/
browserhistoryfetch.php
63 lines (59 loc) · 2.12 KB
/
browserhistoryfetch.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
include_once("connection.php");
include_once("function.php");
include_once("configfetch.php");
$tsqlInformation = "select count(*) Total FROM [NOAH].[dbo].[BrowserHistoryAudited] tableInf, [NOAH].[dbo].[ServerAudited] sa, [NOAH].[dbo].[Hunt] hu
WHERE
tableInf.serverID = sa.serverID
AND hu.huntingID = sa.huntingID $sqlFilter";
$getInformation = sqlsrv_query($conn, $tsqlInformation);
if ( $getInformation === false)
die( print_r( sqlsrv_errors(), true));
$data = array();
$data['data'] = '';
if(sqlsrv_has_rows($getInformation)) {
if( $row = sqlsrv_fetch_array( $getInformation, SQLSRV_FETCH_ASSOC)) {
$total = $row['Total'];
}
//break records into pages
$total_pages = ceil($total/$item_per_page);
//position of records
$page_position = (($page_number-1) * $item_per_page);
$tsqlInformation = "SELECT
hu.huntingGUID, sa.serverName,[BrowserHistoryAuditedID],[BrowserType],[UserName],[URL]
FROM [NOAH].[dbo].[BrowserHistoryAudited] tableInf, [NOAH].[dbo].[ServerAudited] sa, [NOAH].[dbo].[Hunt] hu
WHERE
tableInf.serverID = sa.serverID
AND hu.huntingID = sa.huntingID
$sqlFilter
GROUP BY hu.huntingGUID, sa.serverName,BrowserHistoryAuditedID,[BrowserType],[UserName],[URL]
ORDER BY [BrowserHistoryAuditedID]
OFFSET ".$page_position." ROWS
FETCH NEXT ".$item_per_page." ROWS ONLY
";
}
$getInformation = sqlsrv_query($conn, $tsqlInformation);
if ( $getInformation === false)
die( print_r( sqlsrv_errors(), true));
$data = array();
$data['data'] = '';
if(sqlsrv_has_rows($getInformation)) {
while( $row = sqlsrv_fetch_array( $getInformation, SQLSRV_FETCH_ASSOC)) {
$browserType='';
switch ($row['BrowserType']) {
case 1:
$browserType="IE";
break;
case 2:
$browserType="Chrome";
break;
case 3:
$browserType="Firefox";
break;
}
echo '<tr><td>'.$row['huntingGUID'].'</td><td>'.$row['serverName'].'</td><td>'.$browserType.'</td><td>'.$row['UserName'].'</td><td>'.$row['URL'].'</td></tr>';
}
}
echo '<tr><td><br>';
echo paginate_function($item_per_page, $page_number, $total, $total_pages);
echo '</td></tr>';