Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

PHP code problem...

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
NamecheapNamecheap
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
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
to fix the prolem will need to see the code for the Index1.php file
 
0
Close
0
Close
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
Close
1
Close
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
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Member card: see how many threads a member started
The member card now shows a Threads number, right after Posts. The member card is the box that opens when you point at a name. Profile...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back