Salve a tutti
, ho inserito un contatore di accessi su spazio web altervista e mi funziona correttamente conteggiando gli accessi
, inserendolo invece su spazio web aruba non mi effettua il conteggio e non scrive nel file "count.txt" il numero di accessi
.
I files che ho utilizzato sono i seguenti :
File counter.php
Codice PHP:
<?
##########################################
# #
# Jinx M's Basic Hit Counter #
# #
# [url]www.jinxm.co.uk[/url] [email]spam@jinxm.co.uk[/email] #
# #
##########################################
###############################################################################################
#
# Although there are probably better ways of doing this, I had to work it out for myself.
# Its a simple script looking at it now, yes, but working out how to do it was a learning
# process for me.
#
# So please, don't pass this script off as your own work or make money out of it in any way.
# If you distribute it, please distributed it along with the readme.txt file.
#
###############################################################################################
#version 1.0
# Righto, get all the variables and stuff from the edit.me file
include ('edit.me');
# set a session ID
session_start();
# This is the bit which adds to the count.txt file
if ($count_what == 'visitors') {
# First it creates a session Id for each visit so that it counts
# visits rather than how many times a page is loaded.
if (!$PHPSESSID) {
$thefile = file("count.txt");
$count = implode("", $thefile);
$count++;
$myfile = fopen("count.txt","w");
fputs($myfile,$count);
fclose($myfile);
}
# done
}
else {
# Else it will count every page load
$thefile = file("count.txt");
$count = implode("", $thefile);
$count++;
$myfile = fopen("count.txt","w");
fputs($myfile,$count);
fclose($myfile);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Text Counter</title>
</head>
<body bgcolor="Black" text="Silver">
Jinx M's simple hit counter thingy.
You have had:
<?
$thefile = file("count.txt");
$count = implode("", $thefile);
# now print either the text version...
if ($print_what == 'text') {
print $count;
}
#else print graphics
else {
$num = strlen ($count);
$i = 0;
while ($i < $num) :
$graphic = substr ($count, $i, 1);
print "<img src=\"$url/$graphic.$ext\" border=\"0\" alt=\"$graphic\">";
$i++;
endwhile;
}
?>
hits.</p>
</body>
</html>
File edit.me
Codice PHP:
<?
# Set up some variables and stuff...
# What do you want? A plain text count or one with graphics?
# Its set to $print_what = 'text'; but if you want graphics
# change it to $print_what = 'graphics';
$print_what = 'text';
# Assuming you want graphics, what type do you want?
# Put the extention type here eg, gif, jpg, jpeg, png
$ext = 'gif';
# And where are these graphics? Put the URL to the folder
# they are in here but no trailing / though please :)
$url = 'http://www.yoursite.com/counter/graphics';
# And lastly, WHAT do you want to count? Do you want to count each
# time the page is loaded (refreshing the page will add to the count)
# or count each visitor only once (until they go away and come back again)
# Counting just visitors is much more accurate representation of visits to
# your site.
# $count_what = 'visitors' for visitors or $count_what = 'hits' for hits.
$count_what = 'visitors';
?>
Come mai? Non e che Aruba non permette l'operazione di Read e Write su count.txt?
Grazie a tutti quelli che mi risponderanno
.
Saluti