Tag Archives: PHP

Showing future posts in WordPress RSS feeds

I have a web site which announces future events. In WordPress, you would adapt the publish date of the  post to suit the event’s start date. All is good on the web site itself. I use the c2c_get_upcoming_posts plugin to display them on the front page, but there are other ways.

Read more »

New Top Level Domains and software implications

Many software applications rely on validation routines to check the validity of domain names. By validation, I mean here to test the string submitted by the user and see if it matches a pre-defined pattern. A typical example are web forms that need to validate e-mail addresses.

This is by no means a new issue. It first appeared with the introduction of the .info TLD. Before that TLDs were only two or three letters long, and many validation routines could not cope with the 4 letters of .info. At the time, ICANN had developed a testing tool which allowed developers to test if their code took into account the requirement for 4 letters. Still, you find today on the Internet tons of library routines that do not support 4 or more letter TLDs.

Some of these routines also rely on a hard-coded list of TLDs. Even today, I sometimes find that some web sites cannot deal with my .eu domain, which was introduced 4 years ago.There are hundreds of thousands of these routines written in Javascript, PHP, Perl, ColdFusion, ASP and just about any programming or scripting language you can think of.

Read more »

Test your IPv6 connectivity

If you are connected to this blog using a IPv6 link, you will notice that near the top of the right column of the front page there is a message saying: "Congratulations ! You're using IPv6 ! Your address is XXXXXXX" In case you ask, the PHP code that performs this check is below:
if (substr_count($_SERVER['REMOTE_ADDR'],":") > 0 &&substr_count($_SERVER['REMOTE_ADDR'],".") == 0) {
echo 'Congratulations ! You're using IPv6 ! Your address is'.$_SERVER['REMOTE_ADDR'].'.';
}  else {
echo "You're just using IPv4. Your address is '.$_SERVER['REMOTE_ADDR'].'.';
Update: Martin J. Levy suggested the following, more compact code:
function is_connected_ipv6(){
return (substr_count($_SERVER['REMOTE_ADDR'], ":") > 0 && substr_count($_SERVER['REMOTE_ADDR'], ".") == 0);
echo is_connected_ipv6() ? "(via IPv6)" : "(via IPv4)";