...

View Full Version : tracking the EXE hit count??



fireblade
06-03-2007, 12:00 PM
I have an exe file.
every time it get a hit, i want to record it to a text file or a record in mysql.
my problem is, how to track each hit to the exe file.
the exe file is downloded within the site and from the out side using a direct link to exe.
Remember, i cant append any query strings to the dowlod exe path with in the site and in the external like, coz i have already supplied the direct exe path to the software directories.

can any have suggestion on this??

whizard
06-03-2007, 12:42 PM
Send someone to a page like

download.php?file=file.exe

which initiates the download, as well as updating the hit total for the file

HTH
Dan

rafiki
06-03-2007, 12:49 PM
Remember, i cant append any query strings to the dowlod exe path
guess your options out the window then dan :(
thats the only way i can think of though, so he should use querysting to dload the file, and append the hit counterm send the link out to all the people you did in the firstplace

whizard
06-03-2007, 12:54 PM
Quote:
Remember, i cant append any query strings to the dowlod exe path
guess your options out the window then dan
thats the only way i can think of though, so he should use querysting to dload the file, and append the hit counterm send the link out to all the people you did in the firstplace


I didn't append any query strings to the exe path, I supplied the .exe path to a file that will initiate the download, after updating the counter

Right? or did I miss something?

Dan

rafiki
06-03-2007, 01:04 PM
i think what he meant by appending a querystring is making a querystring, he gave a direct link to the .exe e.g
http://www.hissite.com/apps/author/im/program.exe
so he could not use the query string to help him in this case, unless he redistributes the link to http://www.hissite.com/apps/download.php?file=file.exe

whizard
06-03-2007, 01:06 PM
ahh.
Ok.

thx
Dan

Nightfire
06-03-2007, 02:17 PM
Make something to check your apache log files?

fireblade
06-03-2007, 03:42 PM
thnx everyone trying to give me an idea.
:confused:
Is there any way of getting this done by making any edits in .htaccess file?

Is there any way?

mr e
06-03-2007, 06:53 PM
Use mod_rewrite, add something like this to your .htaccess


RewriteEngine on
RewriteBase /

RewriteRule ^SUB/FOLDER/file\.exe?$ download.php?f=file.exe

Then in the download.php code increment a value in a file or a database and send them the exe file

fireblade
06-04-2007, 04:51 AM
yea um re,

But you have to see this point


Remember, i cant append any query strings to the dowlod exe path with in the site and in the external like, coz i have already supplied the direct exe path to the software directories.

as I have already submitted the links of my .exe files directly I hav no way of catching the download with any scripts.

is there any alterntive solutions using only the .htaccess file??

fireblade
06-04-2007, 04:52 AM
where can I find the apache log files??? where it resides??

mr e
06-04-2007, 05:20 AM
yea um re,

But you have to see this point



as I have already submitted the links of my .exe files directly I hav no way of catching the download with any scripts.

is there any alterntive solutions using only the .htaccess file??
I saw that point, either you didn't read my post or you don't understand how .htaccess works

Using what I gave you in your .htaccess file, when somebody requests www.yoursite.com/SUB/FOLDER/file.exe the server will actually serve them www.yoursite.com/download.php?f=file.exe

In which case in download.php you would increment a counter and send them file.exe

Try it and see if you're still unsure of what I mean

printf
06-04-2007, 12:29 PM
You could also do...

// htaccess file... (in directory where exe files are)

<FilesMatch "(program_one|program_two)\.exe$">
php_value auto_prepend_file /path/logger.php
</FilesMatch>

// php file, logger.php


<?php

/* logger.php */

/* valid files this script handles */

$valid = array ( 'program_one.exe', 'program_two.exe' );


/* log path and name */

$log = './path/log.txt';


/* get the working path and file name */

if ( ! empty ( $_SERVER['SCRIPT_FILENAME'] ) )
{
$file = $_SERVER['SCRIPT_FILENAME'];
$name = strtolower ( basename ( $file ) );
}
else
{
$file = $_SERVER['PATH_TRANSLATED'];
$name = strtolower ( basename ( $file ) );
}

/* not valid prepend request, exit */

if ( ! in_array ( $name, $valid ) )
{
exit ();
}

/* log the request */

$io = fopen ( $log, 'a' );

while ( flock ( $io, LOCK_EX ) === false )
{
usleep ( 10000 );
}

fputs ( $io, time () . "\t" . $_SERVER['REMOTE_ADDR'] . "\t" . $name . "\r\n" );

fclose ( $io );

/* serve the file */

header ( 'Cache-Control: max-age=31536000' );

header ( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );

header ( 'Content-Length: ' . filesize ( $file ) );

header ( 'Content-Disposition: filename="' . $name . '"' );

header ( 'Content-Type: application/octet-stream; name="' . $name . '"' );

readfile ( $file );

exit ();

?>

fireblade
06-05-2007, 07:46 AM
Use mod_rewrite, add something like this to your .htaccess


RewriteEngine on
RewriteBase /

RewriteRule ^SUB/FOLDER/file\.exe?$ download.php?f=file.exe

Then in the download.php code increment a value in a file or a database and send them the exe file

Thanks once again mr e for the post.

as i undestand, when the exe file is requested, the web server will serve download.php. now how do i redirect the user to the exe from download.php?

Assume i put a HeaderLocation() inside the download.php. now what happen if a user copy the exe file path and directly past it in to his download manager and start downloading. in this case i think he will receive download.php insted of exe file.

Any comment?

rafiki
06-05-2007, 12:18 PM
you could send the file threw the php script with header(content type: Application/Force Download); i think, but you would not want to header("Location: /file.exe"); as it would just send them on a ever lasting loop with htaccess sending them to download.php and download.php sending them to file.exe which htaccess would just send back, so on so forth!

fireblade
06-05-2007, 12:38 PM
you could send the file threw the php script with header(content type: Application/Force Download); i think, but you would not want to header("Location: /file.exe"); as it would just send them on a ever lasting loop with htaccess sending them to download.php and download.php sending them to file.exe which htaccess would just send back, so on so forth!

Thanks rafiki,

one final question

Ok if use the > header(content type: Application/Force Download);

what happen if a user copy the exe file path and directly past it in to his download manager and start downloading. will he be redirected to the downlod exe or he will endup in downloading the downlod.php?

rafiki
06-05-2007, 12:47 PM
im not sure, he should download an executed version of download.php, so he couldnt see your php, just what you see when you visit the page, you may want confirmation on that one :)

fireblade
06-05-2007, 01:12 PM
Thanks rafiki, Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum