PHP workaround – how to use file_get_contents() without allow_url_fopen
I admit, the title of this article is somewhat misleading. The PHP function file_get_contents(), which can be used to read files from the internet into a string, just does not work with allow_url_fopen disabled. On that not even this article will change anything.
However, if you want to develop an application or a script, that should work on as many server environments as possible, such as a wordpress plugin, so there is a good workaround for all the environments where allow_url_fopen is disabled. And just this little snippet/workaround is what I want to show and explain to you today.
$file = "http://www.example.com/my_page.php";
if (function_exists(‘curl_version’))
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $file);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($curl);
curl_close($curl);
}
else if (file_get_contents(__FILE__) && ini_get(‘allow_url_fopen’))
{
$content = file_get_contents($file);
}
else
{
echo ‘You have neither cUrl installed nor allow_url_fopen activated. Please setup one of those!’;
}
First, it is checked whether the cURL extension is available […]
At the weekend I was looking for a way to find synonyms for a given word. After a quick search on the net I came across the Openthesaurus project, which offers an offline database of synonyms for download. However, I wanted to have a second source for comparison. After further searching, I went to the thesaurus of the “Wortschatz Leipzig” project. Although they offer no offline synonym database, but a free webservice.
Once we have clarified in this article how to set up a the DynDNS (Dynamic DNS) service for your domains rented at Namecheap.com, we will have to focus on how keep the IP/DNS records for each DynDNS domain up to date.
In the previous article I have explained, how you can set up your domains, which are rented from Namecheap.com, for use with DynDNS (Dynamic DNS). In this article, we will focus on how to configure your Fritzbox, so that it always sends the current IP to the Namecheap DynDNS interface.
In the first step you log into your account at Namecheap.com. Then select the domain for which you want […]