Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 03-31-2004, 03:51 AM   #1
savas
Registered User
 
Join Date: Aug 2002
Posts: 1,045
how to count traffic? php

hi. i am selling some traffic and i need some php script to count ourgoing hits. what to use?

now i am using this one:
<?
$counthandle=fopen("file.txt","r");
$getcurrent=fread($counthandle,filesize("file.txt" ));
$getcurrent=$getcurrent+1;
fclose($counthandle);
$counthandle1=fopen("file.txt","w");
fputs($counthandle1,$getcurrent);
fclose($counthandle1);
header("Location: XXX");
?>

but i have problem with this. counter is sometime reseting to 1 and i don't know why?
savas is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-31-2004, 03:55 AM   #2
Mishi
Confirmed User
 
Join Date: Feb 2002
Location: Scottsdale, AZ
Posts: 1,054
It's very very late and I am tired and I'm probably missing something, but my first thought is that, for some reason, "file.txt" is not being read properly, thus $getcurrent is initially 0. I'm sure a higher power than myself can give you more to go on.

Edited because commas are nice.
__________________
Looking for PHP/MySQL solutions? Check out Cyboriginal - custom scripts, installation services and more.
Mishi is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-31-2004, 04:58 AM   #3
Ash@phpFX
Confirmed User
 
Join Date: Nov 2003
Posts: 4,292
you are using the filesize() function, thats not what you are looking for because that returns the size of the file in bytes

try something like this

$num = file_get_contents(file.txt);
$new = $num + 1;
file_put_contents(file.txt, $new);

then your header tag

note: i just made this up on the spot, and im tired, so it might not work properly, icq me 18502614 if it doesnt

also, if you arent running php 5 file_put_contents isnt available, so add this

if (!function_exists("file_put_contents")) {
function file_put_contents($filename,$content) {
if(!$file = fopen($filename, "w+"))
{
return false;
}
if($file)
{
if(!fwrite($file,$content))
{
return false;
}

fclose($file);
}
return true;
}
}


i hope this helps
Ash@phpFX is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-31-2004, 05:02 AM   #4
swedguy
Confirmed User
 
Industry Role:
Join Date: Jan 2002
Posts: 7,981
Locking a file is good!

http://se.php.net/manual/en/function.flock.php
swedguy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-31-2004, 05:35 AM   #5
savas
Registered User
 
Join Date: Aug 2002
Posts: 1,045
Quote:
Originally posted by asher
you are using the filesize() function, thats not what you are looking for because that returns the size of the file in bytes

try something like this

$num = file_get_contents(file.txt);
$new = $num + 1;
file_put_contents(file.txt, $new);

then your header tag

note: i just made this up on the spot, and im tired, so it might not work properly, icq me 18502614 if it doesnt

also, if you arent running php 5 file_put_contents isnt available, so add this

if (!function_exists("file_put_contents")) {
function file_put_contents($filename,$content) {
if(!$file = fopen($filename, "w+"))
{
return false;
}
if($file)
{
if(!fwrite($file,$content))
{
return false;
}

fclose($file);
}
return true;
}
}


i hope this helps
ok, thank you, it works
savas is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-31-2004, 10:11 AM   #6
savas
Registered User
 
Join Date: Aug 2002
Posts: 1,045
Quote:
Originally posted by savas


ok, thank you, it works
but still reseting
savas is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.