WordPress.org

Ready to get started?Download WordPress

Forums

PHP - Parsing text from logfile (5 posts)

  1. macwise
    Member
    Posted 7 years ago #

    Hello all!

    I'm just poking around with some log files, and was curious as to how I could parse the data and extract some specific information based on parameters which are determined by my marketing campaign. I suppose I should go to a more specific PHP forum for this, but I thought I'd throw it out here first, just in case anyone had some experience here.

    I'm ultimately thinking of creating a plugin which will analyze CUSTOM data which a user can set to any value they like in the admin panel of either WP or BB.

    I need to read line by line, and extract certain parts of a line, compare some of those parts with other lines to find similarities. I think an example is best:

    88.88.888.88 - - [02/Mar/2007:00:56:38 -0800] "POST /url/of/page/requested/ HTTP/1.1" 304 256 "/url/of/page/referring/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/418.9.1 (KHTML, like Gecko) Safari/419.3"

    This line has a lot of data. All I need is to find out if the url of page requested matches a pre-defined value. Then, I need to find out what the ip address is if it does match the value. I would then need to parse back through the file and pull every line that had a matching ip address.

    Hope this explanation is clear. If anyone has any suggestions, or knows of any simple resources to start this happening, that would be extremely helpful.

    Thanks,

    Ron

    P.S. I've read up a little on fget() and file(), but they're still a little greek to me. A simple example that might work in my case would be most helpful.

  2. pizdin_dim
    Member
    Posted 7 years ago #

    I take it you're trying to process Apache logfiles. If so, contact these people. I know they have done some work in this area recently and I'm sure they'd be happy to provide you with some code.

  3. macwise
    Member
    Posted 7 years ago #

    pizdin_dim,

    that link just goes back here...did you maybe paste the wrong link?

    thanks, ron

  4. pizdin_dim
    Member
    Posted 7 years ago #

    Sorry about that, I don't know how I managed to do that. This link is correct.

  5. pizdin_dim
    Member
    Posted 7 years ago #

    Macwise, how did you go? Did you manage to get some help on this?

Topic Closed

This topic has been closed to new replies.

About this Topic