Results 1 to 7 of 7

Thread: How to log $_SERVER['HTTP_USER_AGENT'] to a file

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Talking How to log $_SERVER['HTTP_USER_AGENT'] to a file

    Hi all . Could any one show me how i can log $_SERVER['HTTP_USER_AGENT'] to a file. I want to point diffrent programs to it to see what string they send.Thanks

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: How to log $_SERVER['HTTP_USER_AGENT'] to a file

    1. Open file
    2. Append UA string
    3. Close file handle


    Do you need cod?

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: How to log $_SERVER['HTTP_USER_AGENT'] to a file

    penagate thank u for u reply. yes i need the code i just want to point diffrent sofware to it to see what strings they send.Thanks

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: How to log $_SERVER['HTTP_USER_AGENT'] to a file

    Code:
    // Open log in append mode. If it doesn't exist it will be created.
    $file = fopen('ua-strings.txt', 'a');
    
    // Append the UA string
    fwrite($file, $_SERVER['HTTP_USER_AGENT'].'\n');
    
    // Close
    fclose($file);

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: How to log $_SERVER['HTTP_USER_AGENT'] to a file

    Quote Originally Posted by penagate
    Code:
    // Open log in append mode. If it doesn't exist it will be created.
    $file = fopen('ua-strings.txt', 'a');
    
    // Append the UA string
    fwrite($file, $_SERVER['HTTP_USER_AGENT'].'\n');
    
    // Close
    fclose($file);
    thank u for u reply. Could tell me how in both php and visual basic app i can change the default string sent to $_SERVER['HTTP_USER_AGENT'] log file? For example if the default is :Microsoft URL Control - 6.00.8862\n

    and i want to send this :

    Media Player Classic\nMedia Player Classic\nshoutcastsource\nMozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; {BE6B3C18-D43F-BBA3-8046-F416968AB502}; (R1 1.5))\n

  6. #6
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: How to log $_SERVER['HTTP_USER_AGENT'] to a file

    Quote Originally Posted by tony007
    Could tell me how in both php and visual basic app i can change the default string sent to $_SERVER['HTTP_USER_AGENT'] log file?
    Well PHP won't be sending a UA but if you want to do it in VB, you'll want to post into the VB forums.

    Most controls for VB have a UA Microsoft created and you'd have to completely write your own control to have a custom UA.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  7. #7
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: How to log $_SERVER['HTTP_USER_AGENT'] to a file

    I do apologise. I meant the UA strings to be on separate lines. However I used the wrong quote marks

    The second line should be thus:
    PHP Code:
    fwrite($file$_SERVER['HTTP_USER_AGENT']."\n"); 

Posting Permissions

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



Click Here to Expand Forum to Full Width