title: file_get_contents ($URL) returns "Permission Denied" error
body: <p>I lifted the following PHP code to enable me find users' location information, which will enable me execute some levels of restrictions.</p>
  
  <p>However, the code works well on my localhost server. But when I upload the same php files to my remote web server, it returns an error thus:</p>
  
  <blockquote>
    <p>Warning:
    file_get_contents(<a href="http://api.codehelper.io/ips/?php&amp;ip=192.168.1.1" rel="nofollow noreferrer">http://api.codehelper.io/ips/?php&amp;ip=192.168.1.1</a>):
    failed to open stream: Permission denied in
    /home/www/xyberinternational.com/lotto247.biz/visitorlocation/userip/ip.codehelper.io.php
    on line 41.</p>
  </blockquote>
  
  <p>I have included the following files and their codes below. How can I fix this error?</p>
  
  <h1>Index.php file</h1>
  
  <pre><code>&lt;?php
  require_once("userip/ip.codehelper.io.php");
  require_once("userip/php_fast_cache.php");
  $_ip = new ip_codehelper();
  
  $real_client_ip_address = $_ip-&gt;getRealIP();
  $visitor_location       = $_ip-&gt;getLocation($real_client_ip_address);
  
  $guest_ip   = $visitor_location['IP'];
  $guest_country = $visitor_location['CountryName'];
  $guest_city  = $visitor_location['CityName'];
  $guest_state = $visitor_location['RegionName'];
  
  echo "IP Address: ". $guest_ip. "&lt;br/&gt;";
  echo "Country: ". $guest_country. "&lt;br/&gt;";
  echo "State: ". $guest_state. "&lt;br/&gt;";
  echo "City: ". $guest_city. "&lt;br/&gt;";
  
  
  $ip             = $visitor_location['IP'];
  $Continent_Code     = $visitor_location['ContinentCode'];
  $Continent_Name     = $visitor_location['ContinentName'];
  $Country_Code2      = $visitor_location['CountryCode2'];
  $Country_Code3      = $visitor_location['CountryCode3'];
  $Country        = $visitor_location['Country'];
  $Country_Name       = $visitor_location['CountryName'];
  $State_Name         = $visitor_location['RegionName'];
  $City_Name      = $visitor_location['CityName'];
  $City_Latitude      = $visitor_location['CityLatitude'];
  $City_Longitude     = $visitor_location['CityLongitude'];
  $Country_Latitude   = $visitor_location['CountryLatitude'];
  $Country_Longitude  = $visitor_location['CountryLongitude'];
  $Country_Longitude  = $visitor_location['CountryLongitude'];
  $LocalTimeZone      = $visitor_location['LocalTimeZone'];
  $Calling_Code       = $visitor_location['CallingCode'];
  $Population     = $visitor_location['Population'];
  $Area_SqKm      = $visitor_location['AreaSqKm'];
  $Capital        = $visitor_location['Capital'];
  $Electrical     = $visitor_location['Electrical'];
  $Languages      = $visitor_location['Languages'];
  $Currency       = $visitor_location['Currency'];
  $Flag           = $visitor_location['Currency'];
  ?&gt;
  </code></pre>
  
  <h1>ip.coderhelper.io.php file</h1>
  
  <pre><code>&lt;?php
  class ip_codehelper {
  public function getRealIP() {
      $ipaddress = '';
      if(isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
          $ipaddress = $_SERVER['HTTP_CF_CONNECTING_IP'];
      } else if (isset($_SERVER['HTTP_X_REAL_IP'])) {
          $ipaddress = $_SERVER['HTTP_X_REAL_IP'];
      }
      else if (isset($_SERVER['HTTP_CLIENT_IP']))
          $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
      else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
          $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
      else if(isset($_SERVER['HTTP_X_FORWARDED']))
          $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
      else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
          $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
      else if(isset($_SERVER['HTTP_FORWARDED']))
          $ipaddress = $_SERVER['HTTP_FORWARDED'];
      else if(isset($_SERVER['REMOTE_ADDR']))
          $ipaddress = $_SERVER['REMOTE_ADDR'];
      else
          $ipaddress = 'UNKNOWN';
  
      return $ipaddress;
  }
  
  public function getLocation($ip="") {
      if($ip == "") {
          $ip = $this-&gt;getRealIP();
      }
      if(!class_exists("phpFastCache")) {
          die("Please required phpFastCache Class");
      }
      // you should change this to cURL()
      $data = phpFastCache::get("codehelper_ip_".md5($ip));
      // caching 1 week
  
  
     if($data == null) {
          $url = "http://api.codehelper.io/ips/?callback=codehelper_ip_callback&amp;ip=".$ip;
          $json = file_get_contents($url);
          $data = json_decode($json,true);
          phpFastCache::set("codehelper_ip_".md5($ip),$data,3600*24*7);
      }
  
      return $data;
  }
  
  public function SSLForwardJS() {
      $ip = $this-&gt;getRealIP();
      if(!class_exists("phpFastCache")) {
          die("Please required phpFastCache Class");
      }
  
      // you should change this to cURL()
      $data = phpFastCache::get("codehelper_ip_ssl".md5($ip));
      // caching 1 week
      if($data == null) {
          $url = "http://api.codehelper.io/ips/?callback=codehelper_ip_callback&amp;ip=".$ip;
          $data = file_get_contents($url);
  
              phpFastCache::set("codehelper_ip_ssl".md5($ip),$data,3600*24*7);
          }
          return $data;
      }
  }
  </code></pre>
  
  <p>Meanwhile, the fastcatch.php is quite large.</p>