PHP and Webstats

Discussion in 'PHP' started by mnemtsas, Oct 27, 2005.

  1. #1
    Anyone know an off the shelf php script to simply process a common log format web stat file and insert the field results into a mySQL table? I could roll my own but it's late and I'd rather use someone else's hard work......
     
    mnemtsas, Oct 27, 2005 IP
  2. smo

    smo Well-Known Member

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    123
    #2
    I have one but I use very less fields. Time, referrer, IP and page_name. I identify page name by its unique name and use a format to identify them. You have to add one unique identification name to each page. So if you have one existing site with many pages then it will take lot of time.
     
    smo, Oct 28, 2005 IP
  3. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #3
    Hey smo,

    can you PM me the script as well please?

    I'm looking to develope some software that uses what your script does. I'll email you a copy of my script when I'm done. :)
     
    Weirfire, Oct 28, 2005 IP
  4. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #4
    OK sounds great if you could send it to me. I'll make mine available to anyone when I'm done too.
     
    mnemtsas, Oct 28, 2005 IP
  5. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #5
    I'm going to be logging the activity of users that come from the search engines and calculating which keywords resulted in sales. Interested mnemtsas?
     
    Weirfire, Oct 28, 2005 IP
  6. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Ah well you know I'm already doing this, tracking adwords mostly. I knocked something up last night to do it. I'm just looking for something to go through all my old log files so I can do historical stuff too. My payment provider has only just started logging IP's so I've only just been able to do it. I'm happy to show mine if you show yours! :D
     
    mnemtsas, Oct 28, 2005 IP
  7. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #7
    lol ok :) Then maybe we can combine our scripts and come up with a piece of software every webmaster will want and will pay us $200 a time to use it.
     
    Weirfire, Oct 28, 2005 IP
  8. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hey that sounds like an idea :D
     
    mnemtsas, Oct 28, 2005 IP
  9. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Well here's my code for recordings stats from sites I'm interested in. The sale IP matching code is still under development. Know any good code to pull the search terms from google/yahoo/msn?

    
    <?php
      include("inc/settings.php");  
                   $tracked_referers=array('.capterra.','.business.com','.google.','.sharewareratings.','buyjoggingstrollers','vgcity');
    
      $referer=$_SERVER['HTTP_REFERER'];
      if (!strlen($referer)==0)
      {
        $matched_referer=0;
        for ($i=0;$i<count($tracked_referers);$i++)
        {
          if (stristr($referer,$tracked_referers[$i]))
          {
            $matched_referer=1;
          }
        }
        if ($matched_referer)
        {
          $ip=$_SERVER['REMOTE_ADDR'];
          $landing_page=$_SERVER['PHP_SELF'];
          $keywords=$_GET['kw'];
          $date_array=getdate();
          $day_start=$date_array["mday"];
          $month_start=$date_array["mon"];
          $year_start=$date_array["year"];
          $referer_date=sprintf("%04d%02d%02d", $year_start,$month_start, $day_start);
          $sql="INSERT INTO referer_log (ip,referer,landing_page,adword_keyword,referer_date) VALUES ('$ip','$referer','$landing_page','$keywords','$referer_date')";
          //echo $sql;
          $link_id = @mysql_connect($hostname,$userid,$userpassword);
          @mysql_select_db ($db_name);
          @mysql_query($sql,$link_id);
        }
      }
    ?>
    
    Code (markup):
     
    mnemtsas, Oct 28, 2005 IP
  10. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #10
    Well I know awstats does it but I was thinking of just scraping the keywords from the referred URLs. It would probably take me about 30 minutes to write the code and another 30 to display it lol.
     
    Weirfire, Oct 28, 2005 IP
  11. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Yeah that's all I'm going to do. I've got google working, going on msn now. Yahoo for breakky :)
     
    mnemtsas, Oct 28, 2005 IP
  12. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #12
    Did smo send you his script so far?
     
    Weirfire, Oct 28, 2005 IP
  13. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Nope. 1 2 3 4
     
    mnemtsas, Oct 28, 2005 IP
  14. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #14
    hehe you know you can just type Nope then 6 spaces and then fullstop and it will print Nope . ;)
     
    Weirfire, Oct 29, 2005 IP
  15. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #15
    No I didn't. But I must admit that adding different things to make up the characters amuses me. You know what they say about simple things and simple minds.....
     
    mnemtsas, Oct 29, 2005 IP
  16. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #16
    No! What do they say? Am I mad or something? :eek: My IQ is 132! :D
     
    Weirfire, Oct 29, 2005 IP
  17. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #17
    132? I thought a lower number was better. That's what my therapist keeps telling me. ;)
     
    mnemtsas, Oct 29, 2005 IP
  18. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #18
    hehe :)

    Yeah the lower the better mnemtsas. Just you keep thinking that ;)
     
    Weirfire, Oct 29, 2005 IP
  19. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #19
    Weirfire,

    I found some great php code that parses out the keywords from every search engine referrer I've ever heard of. Works pretty well. Let me know if you're interested and I'll PM it over to you.
     
    mnemtsas, Oct 30, 2005 IP