Php script line break..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xxweekxx
    Confirmed User
    • Oct 2002
    • 6780

    #1

    Php script line break..

    Ok i found this script that shows referrer logs for traffic you send to it..
    <?php
    $myFile = "./data.txt";
    $fh = fopen($myFile, 'a') or die("can't open file");
    fwrite($fh,"nReferer: ");
    fwrite($fh, ($_SERVER['HTTP_REFERER']) );
    fwrite($fh,", ");
    fwrite($fh, ($_SERVER['HTTP_USER_AGENT']) );
    fwrite($fh,", ");
    fwrite($fh, $_SERVER['REMOTE_ADDR']);
    fwrite($fh,", ");
    fwrite($fh, date('l jS of F Y h:i:s A') );
    fclose($fh);
    ?>

    Anyone of making it seperate each new one and put it in a diff line.. right now it just jumbles em up..
    _________________
    I am the best
  • nojob
    The Original NoJob
    • Feb 2004
    • 3682

    #2
    If you want to pay I can have one of my progammers on bench create a solution for you. If so , hit me on icq.

    Comment

    • drocd
      Confirmed User
      • Aug 2007
      • 128

      #3
      PHP Code:
      <?php
      $myFile = "./data.txt";
      $fh = fopen($myFile, 'a') or die("can't open file");
      fwrite($fh,"nReferer: ");
      fwrite($fh, ($_SERVER['HTTP_REFERER']) );
      fwrite($fh,", ");
      fwrite($fh, ($_SERVER['HTTP_USER_AGENT']) );
      fwrite($fh,", ");
      fwrite($fh, $_SERVER['REMOTE_ADDR']);
      fwrite($fh,", ");
      fwrite($fh, date('l jS of F Y h:i:s A')."\n");
      fclose($fh);
      ?>
      230-699

      Comment

      • xxweekxx
        Confirmed User
        • Oct 2002
        • 6780

        #4
        thanks drocd..
        _________________
        I am the best

        Comment

        • xxweekxx
          Confirmed User
          • Oct 2002
          • 6780

          #5
          Will the script lag if a lot of hits r sent?

          I mean i dont know how reliable it is to write to a text file every time someone hits the page.
          _________________
          I am the best

          Comment

          • borked
            Totally Borked
            • Feb 2005
            • 6284

            #6
            Yes, Disk I/O will be a drag whore if you're getting a lot of traffic to it.

            If you dont want to be scouring/parsing apache logs, hit me up on ICQ - I've just the (free) things that is right up your street....

            For coding work - hit me up on andy // borkedcoder // com
            (consider figuring out the email as test #1)



            All models are wrong, but some are useful. George E.P. Box. p202

            Comment

            • borked
              Totally Borked
              • Feb 2005
              • 6284

              #7
              why aren't you storing this stuff in mysql? The problem with what you have now is that there are no file locks (flock), so you're going to be getting into a whole lotta mess with those kind of file writes with traffic.

              Anyway, in answer to your original question, a line break is \n. *always* in within double quotes, never single eg

              fwrite($fh, $_SERVER['REMOTE_ADDR'] . "\n");

              For coding work - hit me up on andy // borkedcoder // com
              (consider figuring out the email as test #1)



              All models are wrong, but some are useful. George E.P. Box. p202

              Comment

              • fris
                Too lazy to set a custom title
                • Aug 2002
                • 55679

                #8
                that is some horrible code
                Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

                Comment

                • Tempest
                  Too lazy to set a custom title
                  • May 2004
                  • 10217

                  #9
                  Originally posted by borked
                  why aren't you storing this stuff in mysql? The problem with what you have now is that there are no file locks (flock), so you're going to be getting into a whole lotta mess with those kind of file writes with traffic.
                  You're kidding right???

                  Comment

                  Working...