/users/patterns/www2_Hacked_x/counter/view.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <title>Hit viewer</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>

<?php

    
include("counter_config.php");
    
// ###########################
// ### Connect to database ###
// ###########################

$link mysql_connect($localhost$dbuser$dbpass); 
if (!
$link
    {
        die(
'Could not connect to database : ' mysql_error());
    }
$db_selected mysql_select_db($dbname$link);

if (!
$db_selected
    {
        die (
'Can\'t use database : ' mysql_error());
    }


// ######################
// ### get total hits ###
// ######################
    
    
$query "SELECT SUM(count)  AS totalhits FROM hits"
     
    
$result mysql_query($query) or die(mysql_error());

    
    while(
$row mysql_fetch_array($result))
    {
        
$totalhits $row['totalhits']  ;
    }

// ####################
// ### Display hits ###
// ####################

    
echo '<h3>Hits</h3>' ;

    
$result mysql_query("SELECT * FROM " $dbtablehits " ORDER BY count DESC");
    
    echo 
"<table width='100%' border='0'>";
    echo 
'    <tr>
        <td height="2" bgcolor="#1AC414" width="40">Page</td> 
        <td height="2" bgcolor="#1AC414" width="169"> Hits</td>
        </tr>' 
;

    
// keeps getting the next row until there are no more to get
    
while($row mysql_fetch_array$result )) 
    {
    
// Print out the contents of each row into a table
    
echo '<tr><td bgcolor="#75D169">'
    echo 
$row['page'];
    echo 
'</td><td bgcolor="#75D169">'
    echo 
$row['count'];
    echo 
'</td></tr>';     
    } 
    echo 
"<tr><td bgcolor=\"#1AC414\"> <strong> Total Hits </strong> </td><td bgcolor=\"#1AC414\"> <strong> $totalhits </strong> </td></tr>" ;
    echo 
"</table><br /> ";

// ############################
// ### get total unique IPs ###
// ############################

$result=mysql_query("SELECT MAX(id) FROM info");
while (
$row mysql_fetch_array($resultMYSQL_NUM)) 
{
$totalips $row[0] ;  
}


// ########################
// ### Display visitors ###
// ########################

echo '<h3> Visitors </h3>' ;

$result mysql_query("SELECT * FROM $dbtableinfo ORDER BY id DESC"
or die(
mysql_error());  

echo 
"<table width='100%' border='0'>";
echo 
'<tr> <td width="200" bgcolor="#1AC414">  IP </td> <td height="2" bgcolor="#1AC414" width="400">User agent</td> <td height="2" bgcolor="#1AC414" width="169"> Date &amp; Time</td> <td height="2" bgcolor="#1AC414" width="169"> Country</td> <td height="2" bgcolor="#1AC414" width="169"> Region</td> <td height="2" bgcolor="#1AC414" width="169"> City</td></tr>';

// keeps getting the next row until there are no more to get
while($row mysql_fetch_array$result )) 
{
    
// Print out the contents of each row into a table
    
echo '<tr><td bgcolor="#75D169">'
    echo 
$row['ip_address'];
    echo 
'</td><td bgcolor="#75D169">'
    echo 
$row['user_agent'];
    echo 
'</td><td bgcolor="#75D169">'
    echo 
$row['datetime'];
    echo 
'</td><td bgcolor="#75D169">'
    echo 
$row['country'];
    echo 
'</td><td bgcolor="#75D169">'
    echo 
$row['region'];
    echo 
'</td><td bgcolor="#75D169">'
    echo 
$row['city'];
    echo 
"</td></tr>";         

    echo 
"<tr><td bgcolor=\"#1AC414\"> <strong> Total unique IP´s </strong> </td><td bgcolor=\"#1AC414\"> <strong> $totalips </strong> </td></tr>" ;
    echo 
"</table><br /> ";
?>

</body>
</html>