Google Hits

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Google Hits

    Ok, well I was bored yesterday n wanted to code a little hit counter for my site that logs hits by matching ip, browser, n platform since there's no login... anyways, a few minutes later, i noticed Googlebot popping up, n was curious as to what pages google was visiting, so added a few lines of code to single out googlebot n log which urls it was loading...

    thought it might be useful for some people... then you can see where you might need to block robots, etc...

    ok, there's a readme included, lol all three lines of it, but here's the basics...
    Step 1. Input DB info in dbconnect.php
    Step 2. Upload To Server in a subdirectory or whereever it will be most convenient for you...
    Step 3. Include it in your index.php either after database connection with out using dbconnect, although obviously you will need to create tables, etc... Or just use it in standalone mode running with the dbconnect file in which case you can even use a separate database for logging hits...

    Will update it a bit n upload improved version a bit later...

    Hope it helps someone, n enjoy optimising your site for google...
    Attached Files
    C3 Themes: http://c3themes.wen.ru/index.html
    Find Files: http://mystarter.tk/?goto=X-search

    #2
    ok, updated to make it an image counter as basic a counter as it is, lol and also for anyone who is using include method, updated to log page hits by unique browser, ip n platform matches, sorry the filesize suddenly shot up, had to incude a font in zip file...

    ok, i didn't really need to include it, but just makes things a bit more foolproof...

    Demo:

    oh n you need to include if you want it to log urls loaded, will be trying to figure out a way around that...
    ok, on line 11... change:
    PHP Code:
    $pageurl htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES); 
    for
    PHP Code:
    $pageurl htmlspecialchars($_SERVER['HTTP_REFERER'], ENT_QUOTES); 
    and you will log which page counter loads from as image...
    Attached Files
    Last edited by pmbguy; 13.11.13, 20:21.
    C3 Themes: http://c3themes.wen.ru/index.html
    Find Files: http://mystarter.tk/?goto=X-search

    Comment


      #3
      Originally posted by pmbguy View Post
      ok, on line 11... change:
      PHP Code:
      $pageurl htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES); 
      for
      PHP Code:
      $pageurl htmlspecialchars($_SERVER['HTTP_REFERER'], ENT_QUOTES); 
      referer can be easily spoofed which makes the script vulnerable to sql injection :/

      Comment


        #4
        Originally posted by something else View Post
        referer can be easily spoofed which makes the script vulnerable to sql injection :/
        i know, one reason the script runs on separate database with different user n password from main database, lol... n i forgot to sanitise in what i posted here, but thanks for the reminder... Sanitise your urls...

        PHP Code:
        function cleanurl($url) {
            
        $bad_entities = array("&""\"""'"'\"'"\'""<"">""("")""*");
            
        $safe_entities = array("&amp;""""""""""""""""""");
            
        $url str_replace($bad_entities$safe_entities$url);
            return 
        $url;

        Last edited by pmbguy; 14.11.13, 14:14.
        C3 Themes: http://c3themes.wen.ru/index.html
        Find Files: http://mystarter.tk/?goto=X-search

        Comment


          #5
          thnks here bro

          Comment

          Working...
          X