Tracking Code Stopped Working.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Tracking Code Stopped Working.

Post by nickman013 »

Hello,

I have a tracking code that I made that tracks who goes to the page, it worked perfect for 2 weeks or so. And today, it stopped working. I didnt change anything. Well here is the link that people will click for it to track

Code: Select all

http://www.mysite.com/index.php?THEIRSCREENNAME
And here is the pages:

add2stat ( this page adds the screen name, page, date, and IP to database.

Code: Select all

<?
$username= "muot_track";  
$password= "track";  
$database= "muot_tracker";  
$connection = mysql_connect('localhost',$username,$password);  
mysql_select_db($database); 
$get=array(); 
foreach(explode('|',$_SERVER['QUERY_STRING']) as $get) { 
     $get = explode('-',$get); 
     $my_get[$get[0]]=$get[1]; 
} 
$sn2 = str_replace("%20", "", $get[0]); 
$sn = str_replace("sn=", "", $sn2);
if ($_SERVER['REMOTE_ADDR']  != '68.195.158.8') 	{
if ($sn  != '') 						{
$date = date("m.d.y");
$time = date('g:i a',time()+3600);
$ip = @$REMOTE_ADDR; 
$sql = "INSERT INTO  `Tracker` (  `Number` ,  `Screen Name` ,  `Page` ,  `Date` ,  `Time` ,  `IP` ) 
VALUES (
'',  '$sn',  '$page',  '$date',  '$time',  '$ip'
);
";
$result = mysql_query($sql) or die(mysql_error()); 


													}
										}

?>
This script gets ignored if the screen name is blank, and the IP address is mine.

Here is the page I use to view the stats.

visit_log.php

Code: Select all

<?php 
$page = "stats.";
require('/home/muot/public_html/pages/login/head.php'); 
?>
<html>
	<font face=Arial size=1>
<?
$username= "muot_track";  
$password= "track";  
$database= "muot_tracker";  
$connection = mysql_connect('localhost',$username,$password);  
mysql_select_db($database); 
?>
		<table border=1>
			<tr>
				<td align=center><font color=red><b>Screen Name</b></font></td>
				<td align=center><font color=red><b>Date</b></font></td>
				<td align=center><font color=red><b>Time</b></font></td>
				<td align=center><font color=red><b>IP</b></font></td>
				<td algign=center><font color=red><b>Delete</b></font></td>
<?php
$sql = "SELECT * 
FROM  `Tracker`
GROUP BY `Screen Name` 
ORDER BY Date DESC";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query)) {
echo "<tr>";
echo "<td align=left><a href=/pages/includes/viewsn.php?sn=".$row['Screen Name']." target=_blank><font color=black>".$row['Screen Name']."</font></a></td>";
echo "<td align=center>".$row['Date']."</td>";
echo "<td align=center>".$row['Time']."</td>";
echo "<td align=center>".$row['IP']."</td>";
echo "<td align=center> <a href=/pages/includes/deleterow.php?row=".$row['Screen Name'].">delete</a></td>";
echo "</tr>";
}
?>
		</table>
And this is viewsn.php (used to sort out all screen names besides one specific)

Code: Select all

<?php 
error_reporting(E_ALL);
$page = "stats.";
require('/home/muot/public_html/pages/login/head.php'); 
?>
<html>
	<font face=Arial size=1>
<?
$username= "muot_track";  
$password= "track";  
$database= "muot_tracker";  
$connection = mysql_connect('localhost',$username,$password);  
mysql_select_db($database); 
?>
		<table border=1>
			<tr>
				<td align=center><font color=red><b>Screen Name</b></font></td>
				<td align=center><font color=red><b>Page</b></font></td>
				<td align=center><font color=red><b>Date</b></font></td>
				<td align=center><font color=red><b>Time</b></font></td>
				<td align=center><font color=red><b>IP</b></font></td>
				<?php
$sql = "SELECT * 
FROM  `Tracker`
where `Screen Name` = '$sn' 
ORDER BY Date DESC";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query)) {
echo "<tr>";
echo "<td align=left>".$row['Screen Name']."</td>";
echo "<td align=center>".$row['Page']."</td>";
echo "<td align=center>".$row['Date']."</td>";
echo "<td align=center>".$row['Time']."</td>";
echo "<td align=center>".$row['IP']."</td>";
echo "</tr>";
}
?>
		</table>
And this is deleterow.php (used for deleting screen names out of DB)

Code: Select all

<?
require('/home/muot/public_html/pages/login/head.php');
$username= "muot_track";  
$password= "track";  
$database= "muot_tracker";  
$connection = mysql_connect('localhost',$username,$password);  
mysql_select_db($database); 
$sql = "DELETE FROM `Tracker` WHERE `Screen Name` = '$row';";
$query = mysql_query($sql);
?>
<META HTTP-EQUIV="Refresh" CONTENT="0; URL=/visit_log.php">
Deletes screenname and redirects using HTML.

It worked perfect all up until today, I went to check out the stats and when I clicked the screen name to view the pages.

A blank table came up, with these errors

Notice: Undefined variable: sn in /home/muot/public_html/pages/includes/menu.php on line 8

Notice: Undefined variable: sn in /home/muot/public_html/pages/includes/menu.php on line 9

Notice: Undefined variable: sn in /home/muot/public_html/pages/includes/menu.php on line 10

Notice: Undefined variable: sn in /home/muot/public_html/pages/includes/menu.php on line 11

Notice: Undefined variable: sn in /home/muot/public_html/pages/includes/menu.php on line 12

Notice: Undefined variable: sn in /home/muot/public_html/pages/includes/viewsn.php on line 26
And when I try to delete the rows, it doesnt delete.

Also, the script stopped tracking IP addresses too.

I checked my Database and all the data besides the IP address are being recorded. I truncated the table because I thought it was too big or somthing, but the problem didnt change.

If anybody sees something wrong with this please help me.

Ive been stumped for hours. It just stopped working out of nowhere!

Thank You!
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

anybody see anything wrong?
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

Well, I was noticing some of my other scripts were not working! So I went to my hosts website, filled out a ticket. While I was waiting for the response I came across this message:
A security hole has been discovered in PHP. The vulnerability is best described at http://www.hardened-php.net/advisory_202005.79.html

We have applied a fix, which includes disabling register_globals in the default server configuration.

Althought our customers are safe now, occasional php scripts might display errors like this:

\"FATAL ERROR: register_globals is disabled in php.ini, please enable it!\"

So, if your site has an error mentioning register_globals, please, contact our support team. We will fix it as soon as we can

Mike
They responded in 2 minutes with a positive answer. They fixed it for me :) !

Thank you guys anyway.
Post Reply