Set up Namecheap.com DDNS in Synology DSM

namecheap-ddns-synology-dsm-en

Today’s article is about how to update DNS entries for domains from Namecheap.com via the Synology DSM function DDNS (Dynamic DNS). Since Namecheap.com is neither available as a provider in Synology DSM, nor do the formerly common intermediary services work, this is only possible with a small workaround. And this is exactly what I would like to show you today.

You need the following things for today’s tutorial:

A domain at Namecheap.comA Synology NAS (or a custom NAS with XPEnology)A webserver with PHP support

In the next paragraph we will outline the actual problem again in detail. If you are only interested in the solution, you can skip the following paragraph…

What is the problem with Synology DSN and Namecheap?

Namecheap provides a url/web service that you can call to set a DNS […]

Benchmark: strtotime() vs DateTime vs getTimestamp in PHP

Recently I wrote about how one can implement date comparison in PHP. In the article I presented two approaches. Firstly, using the strtotime() method and another with the DateTime class.
Then, in the comments on the german division of this blog, it was pointed out that the strtotime() variant is probably faster. Because I wasn’t sure about this, I decided to make a small performance test and share the results with you in this article.
How did I test the performance?

Since the question aims on strtotime() vs. DateTime, the DateTime class is contrary to the strtotime() function. So because DateTime class offers more functionality, I had first to create the DateTime object and then get the timestamp of it, because the strtotime function gives a timestamp as return value and I wanted to compare the time needed to generate the identical output.
As input I have taken a date without a custom time […]

TagKeywordFinder – a free WordPress SEO plugin

Last while browsing I came across a WordPress plugin called wpSuggest. This links Google’s autocomplete function (the thing called “Google Suggest”, which ensures that you get suggestions while typing your question) with the title field in the WordPress editor. So if you write an article in the WordPress backend and type the title wpSuggest will make suggestions for the perfect title.
I liked the way the Google Suggest feature was used here. However, I found that the combination of Google Suggest and the input field for the keywords/tags would make much more sense.  So in short I have developed a small WordPress plugin named “TagKeywordFinder”. This plugin works similar to the above mentioned wpSuggest, with the small difference that it is used when tagging the article. And this is how it looks like:

(If you’re not intrested in the setup process, skip it to 1:00.)
When you begin to assign tags for your […]

How to make simple syntax hightlighter in PHP

PHP SyntaxhighlighterIn the following article I will show you how you can write your own syntax highlighter with a few lines of PHP. By use of the following PHP snippet you can easily display PHP code on your homepage.
The whole thing is much more easily than you think. Most of the work is done by an internal PHP function named highlight_file. This function reads a file and formats the source code in color. We then merely have to count the lines of the file and output the line numbers, as well as preformat the font.
Since the snippet is not that long, I think the comments in the snippet itself are sufficient. If you still have any questions, just write a comment.

<?php
function highlight_sourcecode($file)
{
//Count the lines of the input file
$amount_of_lines = count(file($file));

//Create a list with all line numbers
$list_linenumbers = range(1, $amount_of_lines);

//Format […]

PHP: rand() vs. mt_rand() – what is more accurate, what is faster?

After I was pointed out, that it would be better to use the PHP function mt_rand() instead of rand() for generating random numbers (because mt_rand() should be more accurate), I decided to investigate on that statement. But at first, where is the difference between rand() and mt_rand()?
By use of mt_rand() you can generate random numbers just like with the rand() function. The function call also looks equal on both functions. Though the PHP documentation says mt_rand() is up to 4-times faster and would be create more random/arbitrary numbers. By implication this would mean, that the rand() function creates inaccurate random numbers.
I was not aware of this problem, but after some googleing I discovered that there are a lot of people who think that mt_rand() is the better function. However I had to notice that most of the contributions which complain that rand() is not clean are a “little older”.
Often cited […]