How to convert relative URLs to absolute URLs in websites using PHP

You will probably not argue that relative URLs (Uniform Resource Locators) are very useful feature of websites, especially as for web creation process. If once some webpage had to move somewhere else (and it usually has to at least from developer’s localhost to production environment), it would be a tedious process to rewrite it, so using relative addresses is very convenient.

But there are situations when absolute URLs better fit our needs, or when they are even essential. A typical example is when you want to copy the source of some website or its part. There are relative URLs for images and included styles. Of course, you want to use it in another domain, so relative URLs are not what you want, if you don’t want to also copy all included content. Another example of usage is when you want to download that included content. Again, you need to have its absolute URL.

So the task is to convert all relative URL addresses to their absolute counterparts. But before I show you how to this, let’s discuss occurences and all possible forms of relative URLs. We will deal with HTTP(S) scheme URLs.

Read more

Essential Windows commands tips – part 1

I decided to write a series about Windows commands targeted to less skilled users (there will be nothing new for the advanced Windows users, so if you belong to this group, you may skip this article 🙂 )

This series is not intended to be a complete tutorial, its intent is just to show some of the most useful tricks. However, since as I already mentioned, it is targeted to rookies, so in this first part we will deal with the very basics – how to actually work with commands, command line and batch files in general.

Read more

Pepan Durak

Let me introduce MOYA’s new card game Pepan Durak. Pepan Durak is a variant of popular card game. While standard Russian Durak is played with a deck o 36 cards, Pepan Durak is based on variant that is played with 32 cards, which is count typical for German cards. It is a LAN game, it … Read more

Inner/Outer XHTML – or how to get truly original source of element in JavaScript?

There are some ways to get the original source of any HTML element in JavaScript. And they work fine in most situations. However, there are situations where these ways are not really sufficient and I especially mean not cross-browser enough.

innerHTML property is probably the most frequently used method, but it has some well-known drawbacks. First of all, innerHTML property does not contain (X)HTML written by original author of (X)HTML page. Instead, it contains some sort of browser specific Document Object Model string representation. Especially in IE this representation is quite ugly (missing quotes, capital letters of tags, …). And thus we encounter another problem – content of innerHTML property differs in different browsers!

But why is this important that it differs? Should we care? Maybe, we should. There might be situations when we may need the same value of innerHTML property for all browsers. There are always some tricks to get around this need and make it in other way, or simply make different solutions for different browsers. But wouldn’t it be nice to have function that not only returns same content in all modern major browsers, but moreover returns exactly the content that was created by author of webpage? Getting truly original source code is in fact another thing that might be sometimes useful.

Read more

Welcome to my blog!

So, this is the very first page of this blog. Where to begin? I’ll probably end up with simple wait and see! Useful articles from software world and articles about MOYA’s projects are coming soon. 🙂