PHP workaround – how to use file_get_contents() without allow_url_fopen

php_artikel_logoI 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 […]

C#-API for the Wortschatz Leipzig webservices

csharp webserviceAt 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.
Since this web service can not be easily integrated in the Visual Studio into your own projects and it took me some time and energy to figure out how to get things up and running, I have enclosed my whole web service client code into a small library.
If you’re not interested in a “ready-to-use” library, but in the technical sight of […]

How to setup DDclient on Raspberry Pi for use with Namecheap DynDNS

raspberry pi logoOnce 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 another article I have explained how to do this using a Fritzbox. As for me, I have not only my Fritzbox 24/7 connected to the internet, but also my Raspberry Pi. So I will show you how to setup your Raspberry Pi to use it as a DynDNS client for use with Namecheap.
How to use Namecheap DynDNS service with ddclient on the Raspberry
Log into your Raspberry Pi (by ssh for example) or open a terminal window if you are working directly on Pi. In the first step we have […]

How to configure Namecheap DynDNS in Fritzbox

dyndns refreshIn 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.
While this also possible through various clients for PC or MAC, I find the configuration with Fritzbox particularly attractive, because it is anyway running around the clock and thus no PC or MAC unnecessarily consumes more power.
(Who prefers a Raspberry Pi over a Fritzbox, should read this article here.)
Set up Namecheap DynDNS in the Fritzbox
Log into the webpanel of your Fritzbox. This should be normally accessible by navigating to http://fritz.box or http://192.168.178.1  in a browser of your choice.

Setting up DynDNS for domains with Namecheap.com

Also, if I rent my webspace (and now my VPS) always from german companies, my domains are with a foreign supplier. Specifically at Namecheap.com. This has several reasons. I’ve only had good experience there, I really like their web interface, the payment by Paypal and also the support is really fast.
One of the features which suits me very well at Namecheap.com is the possibility to use DynDNS with all domains registered there. And moreover it’s free. With other providers, you pay for it often.
How to configure a domain on Namecheap backend, so that the DNS records can be updated automatically, I want to show you in the following.
Configure domains with Namecheap for use with DynDNS
namecheap_dyndns_setup_1In the first step you log into your account at Namecheap.com. Then select the domain for which you want […]