title: PHP: how to check if the client is local?
body: <p>I need to check if a file is opened "locally" (same machine or network). I'm using:</p>
  
  <pre><code>&lt;?php
  if ((substr($_SERVER['REMOTE_ADDR'],0,8) == "192.168.") || ($_SERVER['REMOTE_ADDR'] == "127.0.0.1")) {
      // client is local
  } else {
      // client is not local
  }
  </code></pre>
  
  <p>But I'm not sure this is the best way. </p>
  
  <p>What is a more foolproof way of doing this?</p>