NameSilo

PHP code problem...

Spaceship Spaceship
Watch

xxll_martin_llxx

Established Member
Impact
3
Hey

I'm a total PHP coding noobie so not sure what the problem is. I'm trying to get a site stats script up on my site.

Basically there is 2 files to the "system" - 'index1.php' and 'stats.txt' + the read me file.


This is from the Read me file....
Step 1. Upload all files from this folder to the same directory where your index page is
(or where ever you want your stats to appear)
Step 2. CHMOD 'stats.txt' to 777!
Step 3. Include this line into your index page html code

<? include 'index1.php' ?>

and voila!

----------------------------------------------

Installing
-Unzip
-Upload
-Command "stats.txt" to 777!!
-include the stats into your site!


Index1.php can be located here and from the error on my site I figure it has something to do with index1.php.

I've CHMODD'ed 'stats.txt' to 777 and I've placed
Code:
<?php include ('index1.php'); ?>
where I want the information to appear.

What's gone wrong in 'index1.php'?
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
to fix the prolem will need to see the code for the Index1.php file
 
0
•••
0
•••
Contents of index1.php:

Code:
<body>
<font face="Verdana" size="1">
<?php
// Our log file;
$counter = "stats.txt";

// Date logging;
$today = getdate();
$month = $today[month];
$mday = $today[mday];
$year = $today[year];
$current_date = $mday . $month . $year;


// Log visit;
$fp = fopen($counter, "a");
$line = $REMOTE_ADDR . "|" . $mday . $month . $year . "\n";
$size = strlen($line);
fputs($fp, $line, $size);
fclose($fp);

// Read log file into array;
$contents = file($counter);

// Total hits;
$total_hits = sizeof($contents);

// Total hosts;
$total_hosts = array();
for ($i=0;$i<sizeof($contents);$i++) {
	$entry = explode("|", $contents[$i]);
	array_push($total_hosts, $entry[0]);
}
$total_hosts_size = sizeof(array_unique($total_hosts));

// Daily hits;
$daily_hits = array();
for ($i=0;$i<sizeof($contents);$i++) {
	$entry = explode("|", $contents[$i]);
	if ($current_date == chop($entry[1])) {
		array_push($daily_hits, $entry[0]);
	}
}
$daily_hits_size = sizeof($daily_hits);

// Daily hosts;
$daily_hosts = array();
for ($i=0;$i<sizeof($contents);$i++) {
	$entry = explode("|", $contents[$i]);
	if ($current_date == chop($entry[1])) {
		array_push($daily_hosts, $entry[0]);
	}
}
$daily_hosts_size = sizeof(array_unique($daily_hosts));

?>
<? echo "
Todays Page hits: <b> " . $daily_hits_size . "</b><br /><br />
Todays unique hits: <b>" . $daily_hosts_size;<br /><br /> 
Page hits:<b> " . $total_hits . "</b><br /><br />
Unique hits: <b> " . $total_hosts_size . "</b>
?>
 
0
•••
1
•••
change

Code:
<? echo "
Todays Page hits: <b> " . $daily_hits_size . "</b><br /><br />
Todays unique hits: <b>" . $daily_hosts_size;<br /><br /> 
Page hits:<b> " . $total_hits . "</b><br /><br />
Unique hits: <b> " . $total_hosts_size . "</b>
?>

to

Code:
<? echo "
Todays Page hits: <b> " . $daily_hits_size . "</b><br /><br />
Todays unique hits: <b>" . $daily_hosts_size . "<br /><br /> 
Page hits:<b> " . $total_hits . "</b><br /><br />
Unique hits: <b> " . $total_hosts_size . "</b>";
?>
 
1
•••

We're social

Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back