Views Counter script!

Discussion in 'PHP' started by scutari, Jul 22, 2008.

  1. #1
    here is the code:

    <?php
    // Our log file;
    $counter = "counter.txt";
    
    // Read log file into array;
    $contents = file($counter);
    
    // Total hits;
    $total_hits = sizeof($contents);
    
    echo $total_hits . " views ";
    
    
    
    PHP:
    So what I am not sure is how to protect the counter.txt from being accessed from others. What should I do, create a .htacces file or chmod?
    If I put this script on my remote server what should I do to protect the .txt file?
    Should I put it to my log folder and give any perms?
     
    scutari, Jul 22, 2008 IP
  2. BrisbaneWebmaster

    BrisbaneWebmaster Peon

    Messages:
    63
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Robots.txt?
     
    BrisbaneWebmaster, Jul 22, 2008 IP
  3. scutari

    scutari Peon

    Messages:
    431
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i think robots.txt is for web crawlers..
     
    scutari, Jul 22, 2008 IP
  4. rob_v

    rob_v Peon

    Messages:
    72
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    just put it under the doc root and you should be fine.
     
    rob_v, Jul 22, 2008 IP