Nemanja015
6.1.2009, 16:09
Ne mogu da otvorim PHP u localhostu!
Npr stranicu sa kodom: <?php
$id = htmlentities($_GET['id']);
$error = "No page id mentioned to count!";
if ($id =="")
{
echo "document.write('$error');";
}
else
{
/////////////////////////////// Code for counting hits ////////////////////////////
//Name of hit count file
$count_file = "counts/" . $id . ".txt";
if (! @$file = fopen($count_file,"r+"))
{
$count="1";
}
else {
$count = @fread($file, filesize($count_file)) or $count=0;
fclose($file);
$count++;
}
$file = fopen($count_file,"w+") or die("Error to write logs!");
fputs($file, $count);
fclose($file);
echo "document.write('$count');";
//================================================== ========
/////////////////////////// Code for creating logs ////////////////////////////////////
//Name of log file
$log_file = "logs/" . $id . ".txt";
// Sets different variable for getting different informations of visitor of the page
$time = date("l, j F Y [h:i a]");
$ip = $_SERVER['REMOTE_ADDR'];
$browser = $_SERVER['HTTP_USER_AGENT'];
$fp = fopen("$log_file", "a");
fputs($fp, "<p>Time: $time<br>IP: $ip<br>Browser: $browser</p>");
fclose($fp);
//================================================== ========
exit();
}
?>
Otvara Ovako:
http://nemanjan00.googlepages.com/Snap122.jpg
Npr stranicu sa kodom: <?php
$id = htmlentities($_GET['id']);
$error = "No page id mentioned to count!";
if ($id =="")
{
echo "document.write('$error');";
}
else
{
/////////////////////////////// Code for counting hits ////////////////////////////
//Name of hit count file
$count_file = "counts/" . $id . ".txt";
if (! @$file = fopen($count_file,"r+"))
{
$count="1";
}
else {
$count = @fread($file, filesize($count_file)) or $count=0;
fclose($file);
$count++;
}
$file = fopen($count_file,"w+") or die("Error to write logs!");
fputs($file, $count);
fclose($file);
echo "document.write('$count');";
//================================================== ========
/////////////////////////// Code for creating logs ////////////////////////////////////
//Name of log file
$log_file = "logs/" . $id . ".txt";
// Sets different variable for getting different informations of visitor of the page
$time = date("l, j F Y [h:i a]");
$ip = $_SERVER['REMOTE_ADDR'];
$browser = $_SERVER['HTTP_USER_AGENT'];
$fp = fopen("$log_file", "a");
fputs($fp, "<p>Time: $time<br>IP: $ip<br>Browser: $browser</p>");
fclose($fp);
//================================================== ========
exit();
}
?>
Otvara Ovako:
http://nemanjan00.googlepages.com/Snap122.jpg