jag har redan ett konto hos f2s men jag får inte det att funka, snälla kan du kolla in scriptet o förklara för mig hur man gör sen... Hur gör man så att f2s tillåter scriptet att skriva en fil på deras server?
här e scriptet, om den kan komma till nytta:
\# The file that stores IP addresses and time they accessed the site
$guests_data = 'guests.txt';
\# How many seconds to keep an IP address in the list before it becomes invalid
$timeout = 10;
\# Logs at what time you had the most guests browsing your site
$max_log = 'maxguests.txt';
# Done! No need to go below unless you know what your doing!
##############################################################################
$line = $ENV{'REMOTE_ADDR'} . "\\t" . time . "\\n";
print "Content-type: text/html\\n\\n";
if ( -e $guests_data ne 0 or -s $guests_data eq 0 ) { &write_new; print '10'; exit; }
&write_update;
&write_new;
$count = &read_count;
print $count;
&log_max if $max_log;
exit;
##############################################################################
# Sub-Routines
sub log_max
{
if ( -e $max_log )
{
open(FILE,$max_log) || die $!;
$log = <FILE>;
close(FILE);
}
else { $log = "0\t0" }
($MAX,$TIME) = split(/\\t/,$log);
if ( $count \> $MAX )
{
($sec,$min,$hour,$mday,$mon,$year)=localtime(time);
$year = $year + 1900;
open(FILE,"\>$max_log") || die $!;
print FILE "$count\\t$hour:$min:$sec $mon/$mday/$year";
close(FILE);
}
}
sub read_count
{
open(FILE,$guests_data) || &error;
@file = <FILE>;
close(FILE);
$count = @file;
return($count);
}
sub write_new
{
open(FILE,">>$guests_data") || &error;
print FILE $line;
close(FILE);
}
sub write_update
{
open(FILE,$guests_data) || &error;
@file = <FILE>;
close(FILE);
open(FILE,"\>$guests_data") || &error;
foreach $fline ( @file )
{
($IP,$TIME) = split(/\\t/,$fline);
chomp($TIME);
if ( $IP ne $ENV{'REMOTE_ADDR'} )
{
if ( $TIME + $timeout \> time ) { print FILE "$IP\\t$TIME\\n"; }
}
}
close(FILE);
}
sub error
{
print "[Unexpected error ocurred]";
exit;
}