Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    New Coder fireblade's Avatar
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    tracking the EXE hit count??

    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??
    FiŽe bLádę
    follow me on twitter

  • #2
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    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
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #3
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    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

  • #4
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Quote Originally Posted by rafiki
    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
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #5
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    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

  • #6
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    ahh.
    Ok.

    thx
    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #7
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Make something to check your apache log files?

  • #8
    New Coder fireblade's Avatar
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    thnx everyone trying to give me an idea.

    Is there any way of getting this done by making any edits in .htaccess file?

    Is there any way?
    FiŽe bLádę
    follow me on twitter

  • #9
    Regular Coder
    Join Date
    Apr 2007
    Posts
    295
    Thanks
    0
    Thanked 19 Times in 19 Posts
    Use mod_rewrite, add something like this to your .htaccess
    Code:
    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

  • #10
    New Coder fireblade's Avatar
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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??
    FiŽe bLádę
    follow me on twitter

  • #11
    New Coder fireblade's Avatar
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts
    where can I find the apache log files??? where it resides??
    FiŽe bLádę
    follow me on twitter

  • #12
    Regular Coder
    Join Date
    Apr 2007
    Posts
    295
    Thanks
    0
    Thanked 19 Times in 19 Posts
    Quote Originally Posted by fireblade View Post
    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

  • #13
    New Coder
    Join Date
    Sep 2006
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 Code:
    <?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 $ioLOCK_EX ) === false )
    {
        
    usleep 10000 );
    }

    fputs $iotime () . "\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 ();

    ?>

  • #14
    New Coder fireblade's Avatar
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation

    Quote Originally Posted by mr e View Post
    Use mod_rewrite, add something like this to your .htaccess
    Code:
    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?
    FiŽe bLádę
    follow me on twitter

  • #15
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    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!


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •