title: Restrict direct access to script based on joomla authentication
body: <p>Hello i found Aron Rotteveel script:</p>
  
  <pre><code>&lt;?php
  
  $file = $_GET['file'];
  $fileDir = '/path/to/files/';
  
  if (file_exists($fileDir . $file))
  {
      // Note: You should probably do some more checks 
      // on the filetype, size, etc.
      $contents = file_get_contents($fileDir . $file);
  
      // Note: You should probably implement some kind 
      // of check on filetype
      header('Content-type: image/jpeg');
  
      echo $contents;
  }
  </code></pre>
  
  <p>?></p>
  
  <p>is there any possibility to add authentication to this, based on joomla users session? I mean when user logged to my site he got access to this script, but cannot access direcly.</p>
  
  <p>Sorry for my English.</p>