Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8910693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:45:13+00:00 2026-06-15T03:45:13+00:00

I am using this tutorial Tracking Tool , I got it working. I’m trying

  • 0

I am using this tutorial Tracking Tool, I got it working. I’m trying to modify it to fit my needs, in tracking Verizon Wirless (my cell connection) to watch when they start throttling me my ip changes. My older brother has AT&T so I’v added in my database a hostname field so we can distinguish between our phones.. but can get it to display in the report page next to the IP. When I click on the view to show what pages I have visited I can display it in there but not on the main page, heres my code if anyone might be able to point out the reason why its not displaying or what I’m changing wrong

Just to mention noticed two posted deleted… I”M NOT TRACKING ANYONE BUT MYSELF,,, i have a rooted thunderbolt on verizon wirless,,, once i hit 4 gig of data in a day(still have the unlimited plan) verizon likes to boot me off of one IP and switch me to another thats slower, I’m trying to pin point which IPs i notice better bandwidth on, so i can cycle the radios until it gets back on a good one again

MySQL

DROP TABLE IF EXISTS `testing_db`;
CREATE TABLE IF NOT EXISTS `testing_db` (
  `entry_id` INT(11) NOT NULL AUTO_INCREMENT,
  `visitor_id` INT(11) DEFAULT NULL,
  `ip_address` VARCHAR(15) NOT NULL,
  `hostname` VARCHAR(295) NOT NULL,
  `server_name` text,
  `useragent` text,
  `page_name` text,
  `query_string` text,
  `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY  (`entry_id`),
  KEY `visitor_id` (`visitor_id`,`timestamp`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1;

ip_tracker.php

<?php
//define our "maximum idle period" to be 30 minutes

$mins = 1;

//set the time limit before a session expires
ini_set ("session.gc_maxlifetime", $mins * 60); 

session_start();

$ip_address = $_SERVER["REMOTE_ADDR"];
$page_name = $_SERVER["SCRIPT_NAME"];
$query_string = $_SERVER["QUERY_STRING"];
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$host_name = $hostname; //$_SERVER['HTTP_HOST'];
$server_name = $_SERVER['SERVER_NAME'];
$useragent=$_SERVER['HTTP_USER_AGENT'];

$current_page = $page_name."?".$query_string;

//connect to the database using your database settings
include("db_connect.php");

if(isset($_SESSION["tracking"])){

    //update the visitor log in the database, based on the current visitor    //id held in $_SESSION["visitor_id"]
    $visitor_id = isset($_SESSION["visitor_id"])?$_SESSION["visitor_id"]:0;

    if($_SESSION["current_page"] != $current_page){
        $sql = "INSERT INTO testing_db 
            (ip_address, page_name, query_string, visitor_id, hostname, host_name, server_name, useragent)
            VALUES ('$ip_address', '$page_name', '$query_string', '$visitor_id','$hostname','$host_name','$server_name','$useragent')";
        if(!mysql_query($sql)){
            echo "Failed to update visitor log";   
        }
        $_SESSION["current_page"] = $current_page;        
    }
    $_SESSION["tracking"] = false;
}else{
    //set a session variable so we know that this visitor is being tracked

    //insert a new row into the database for this person
    $sql = "INSERT INTO testing_db 
            (ip_address, page_name, query_string, visitor_id, hostname, host_name, server_name, useragent)
            VALUES ('$ip_address', '$page_name', '$query_string', '$visitor_id','$hostname','$host_name','$server_name','$useragent')";
    if(!mysql_query($sql)){
        echo "Failed to add new visitor into tracking log";
        $_SESSION["tracking"] = false;   
    } else {
        //find the next available visitor_id for the database
        //to assign to this person
        $_SESSION["tracking"] = true;
        $entry_id = mysql_insert_id();
        $lowest_sql = mysql_query("SELECT MAX(visitor_id) as next FROM testing_db");
        $lowest_row = mysql_fetch_array($lowest_sql);
        $lowest = $lowest_row["next"];
        if(!isset($lowest))
            $lowest = 1;
        else
            $lowest++;
        //update the visitor entry with the new visitor id
        //Note, that we do it in this way to prevent a "race condition"
        mysql_query("UPDATE testing_db SET visitor_id = '$lowest' WHERE entry_id = '$entry_id'");
        //place the current visitor_id into the session so we can use it on
        //subsequent visits to track this person
        $_SESSION["visitor_id"] = $lowest;
        //save the current page to session so we don't track if someone just refreshes the page
        $_SESSION["current_page"] = $current_page;

ip_report.php

<?php
include("db_connect.php");
//retrieve the appropriate visitor data
$view = $_GET["view"];
//set a default value for $view
if($view!="all" && $view!="record")
  $view = "all";
if($view == "all")
{
    //show all recent visitors
    $sql = "SELECT visitor_id, GROUP_CONCAT(DISTINCT ip_address) as ip_address_list,
COUNT(DISTINCT ip_address) as ip_total, COUNT(visitor_id) as page_count,
MIN(timestamp) as start_time, MAX(timestamp) as end_time FROM testing_db GROUP BY visitor_id";
    $result = mysql_query($sql);
    if($result==false){
        $view = "error";
        $error = "Could not retrieve values";
    }
} else {
    //show pages for a specific visitor
    $visitor_id = $_GET['id'];
    //rung $visitor_id through filter_var to check it's not an invalid
    //value, or a hack attempt
    if(!filter_var($visitor_id, FILTER_VALIDATE_INT, 0)){
        $error = "Invalid ID specified";
        $view = "error";
    } else {
        $sql = "SELECT timestamp, page_name, query_string, ip_address, hostname, host_name, server_name, useragent FROM
testing_db WHERE visitor_id = '$visitor_id'";
        $result = mysql_query($sql);
    }
}
function display_date($time){
    return date("F j, Y, g:i a", $time);
}

?>
<html>
<head>
<title>IP Tracker Report Page</title>
<style>
html {font-family:tahoma,verdana,arial,sans serif;}
body {font-size:62.5%;}
table tr th{
font-size:0.8em;
background-color:#ddb;
padding:0.2em 0.6em 0.2em 0.6em;
}
table tr td{
font-size:0.8em;
background-color:#eec;
margin:0.3em;
padding:0.3em;
}
</style>
</head>
<body>
<h1>IP Tracker Report</h1>
<?php if($view=="all") {
    //display all of the results grouped by visitor
    if($row = mysql_fetch_array($result)){
    ?>
<table>
<tbody>
<tr>
<th>Id</th>
<th>IP Address(es)</th>
<th>Host Name</th>
<th>Entry Time</th>
<th>Duration</th>
<th>Pages visited</th>
<th>Actions</th>
</tr>
<?php
      do{
        if($row["ip_total"] > 1)
            $ip_list = "Multiple addresses";
        else
            $ip_list = $row["ip_address_list"];
        $start_time = strtotime($row["start_time"]);
        $end_time = strtotime($row["end_time"]);
        $start = display_date($start_time);
        $end = display_date($end_time);
        $duration = $end_time - $start_time;
        if($duration >= 60) {
            $duration = number_format($duration/60, 1)." minutes";
        }
        else {
            $duration = $duration." seconds";
        }
        $host - $row["hostname"];
        echo "<tr>";
        echo "<td>{$row["visitor_id"]}</td>";
        echo "<td>$ip_list</td>";
        echo "<td>$host</td>";
        echo "<td>$start</td>";
        echo "<td>$duration</td>";
        echo "<td>{$row["page_count"]}</td>";
        echo "<td><a href='ip_report.php?view=record&id={$row["visitor_id"]}'>view</a></td>";
        echo "</tr>";
      } while ($row = mysql_fetch_array($result));
    ?>

</tbody>
</table>
<?php } else { ?>
<h3>No records in the table yet</h3>
<?php } ?>
<?php } elseif($view=="record"){ ?>
<h3>Showing records for Visitor <?php echo $visitor_id; ?></h3>
<p><a href="ip_report.php">back</a></p>
<?php
    //show all pages for a single visitor
    if($row = mysql_fetch_array($result)){
    ?>
<table>
<tbody>
<tr>
<th>Page viewed</th>
<th>User Agent</th>
<th>Time of view</th>
</tr>
<?php
      do{
        if($row["ip_total"] > 1)
            $ip_list = "More than 1";
        else
            $ip_list = $row["ip_address_list"];
        $time = display_date(strtotime($row["timestamp"]));
        echo "<tr>";
        echo "<td>{$row["page_name"]}</td>";
        echo "<td>{$row["hostname"]}</td>";
        echo "<td>$time</td>";
        echo "</tr>";
      } while ($row = mysql_fetch_array($result));
    ?>
</tbody>
</table>
<?php } else { ?>
<h3>No records for this visitor</h3>
<?php
    }
} elseif($view=="error") { ?>
<h3>There was an error</h3>
<?php echo $error;
}
?>

</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:45:14+00:00Added an answer on June 15, 2026 at 3:45 am

    Add this last line to your report script:

      do{
        if($row["ip_total"] > 1)
            $ip_list = "Multiple addresses";
        else
            $ip_list = $row["ip_address_list"];
    
            // Add the following line here
            $host = $row["hostname"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this tutorial right now and I got it working perfectly, but my
I'm using this tutorial for capturing images with AVFoundation. I'm trying to get the
i'm trying to use C2DM client with this tutorial:http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html I'm using this code for
I'm trying to learn wxWidgets using this tutorial . It directs me to use
I wrote a code using this tutorial http://marakana.com/forums/android/examples/311.html It is working fine except the
I'm working with Python and I've implemented the PCA using this tutorial . Everything
I'm trying to install Memcached on Mac using this tutorial: http://tugdualgrall.blogspot.de/2011/11/installing-memcached-on-mac-os-x-and.html but when I
I'm trying to create a game loop using this tutorial . I have tried
I'm using this tutorial to get internal messages working on my site: http://www.novawave.net/public/rails_messaging_tutorial.html But,
Using this tutorial: http://www.c-sharpcorner.com/uploadfile/UrmimalaPal/creating-a-windows-phone-7-application-consuming-data-using-a-wcf-service/ I have created sample/hello world application on the windows phone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.