SIDEBAR
»
S
I
D
E
B
A
R
«
Happy New Year Wishes from Pumka.net
Dec 31st, 2009 by Anton Oliinyk

Happy New Year!Hello!

2009 year was very interesting for us!
I defended my work for Ph.D. degree on Information Technology. I started working independent and fell in love with a freelance development.
Together with my wife, Anna, we started Pumka.net and this blog not so long ago.

We’re still learning web development and have many thing to do:

  • Completely reload and redesign our site.
  • Write more about SEO-friendly URL parsing and canonicalization with PHP, FFmpeg and MediaInfo.dll handling, Smarty template engine and many other interesting things.
  • Learn as many CMS’es as we can.
  • Exchange guest posts with some friendly blogs.
  • Have fun!

Thank you for you interest to our blog and our services!
We wish you success in all your endeavours in the new year!!!

Anton & Anna @ Pumka.net

Rewriting for SEO-Friendly URLs: .htaccess or PHP?
Dec 30th, 2009 by Anton Oliinyk

Modern database driven web sites implement SEO-friendly URLs emulating static directories and files. Switching to such “clean” URLs enables good indexing by search engines, makes URLs more user-friendly and hides the server-side language. For example, this clean URL may refer to the page in some product directory:


http://somesite.com/products/network/router.html

In fact, there is no /products/network folder on the server and no router.html file at all. The page is generated by server script using database query for “network” product category and “router” product. But who calls the script and where it gets the query parameter values?

This technique is usually referred as “URL rewriting”. It allows web server to recognize what information was requested by parsing the URL string. Apache and PHP allow multiple options to implement URL rewriting. So which one is the best?

Read the rest of this entry »

Use Result Variable to Prepare Function Return Value
Dec 29th, 2009 by Anton Oliinyk

Many many years ago I learned Delphi language. It has one interesting feature not found in other languages: you don’t need return statement to specify return value for a function. Instead, you can use a pseudo-variable called Result. You can change its value many times during function execution but only the last value is returned.

That’s really a great idea! Even if your programming language doesn’t have such a built-in variable, why not to create it?
Most functions actually need a variable to forge future return value, so why call it differently if we can always call it result?

Read the rest of this entry »

PHP Regular Expressions and UTF-8
Dec 27th, 2009 by Anton Oliinyk

Perl-compatible regular expression functions in PHP can properly work with Unicode strings. Just add /u modifier to turn on UTF-8 support in preg_replace, preg_match, preg_match_all, preg_split and other PCRE (preg) functions. This way you can parse strings with national characters. For example:

$clean = preg_replace('/\s\s+/u', ' ', $dirty);

If used without /u modifier this code damages UTF-8 encoded strings by replacing national character bytes improperly interpreted as whitespace characters. This and many other problems are caused by improper interpretation of every byte as ASCII character which is not always true for UTF-8.

The modifier is available from PHP 4.1.0 or greater on Unix and from PHP 4.2.3 on win32. UTF-8 validity of the pattern is checked since PHP 4.3.5.
I found this tip as well as many other useful info on regular-expressions.info. It’s not easy to find it in the PHP documentation but it’s actually hidden here.

SEO-Friendly URLs and Relative Links
Dec 24th, 2009 by Anton Oliinyk

The Web community is going crazy about SEO-friendly URLs like http://somesite.com/products/network/router/. Well, it looks much better than a script URL http://somesite.com/products.php?c=network&p=router which may actually serve the page behind the scenes. There are a lot of good articles on how to implement SEO-friendly URLs, for example this one or my own post. But they do not warn the reader about one usual problem: once you have updated your site to handle virtual paths you will probably get a bad surprise:

CSS, image and internal page links are totally broken!

Why? Because those links are usually relative to the page location. The browser has no idea about virtual folders and tries to get files from locations relative to the page URL context. For example, if there is a usual CSS link in the page header:

<link rel="stylesheet" href="style.css" type="text/css" media="screen" />

Then the browser will try to download non-existing file http://somesite.com/products/network/router/style.css and fail silently. No CSS style will be applied.

It’s incredible how many words were spoken about SEO-friendly URLs with almost no word about this relative link problem.
So, what you have to do? Don’t worry, there are multiple solutions available and I’ll try to explain them all.

Read the rest of this entry »

BlueMars – My Favorite Radio
Dec 21st, 2009 by Anton Oliinyk

My favorite radio station on the Web for years: BlueMars.org – Music for the Space traveler.

The radio features three outstanding ambient streams from “outer space”:
Tune In Bluemars. Tune In Cryosleep. Tune In VoicesFromWithin.

This is what I love to listen when assembling applications frame by frame…

Just want to say big “Thank You” to those people maintaining this wonderful radio absolutely free.

Reading, writing and converting RSA keys in PEM, DER, PUBLICKEYBLOB and PRIVATEKEYBLOB formats
Dec 19th, 2009 by Anton Oliinyk

This post finishes my epic about the implementation of RSA encryption. See the part I and part II of my post about RSA encryption for C++/Delphi (CryptoAPI) and PHP (OpenSSL) applications.

The main problem we faced was incompatibility of key formats. CryptoAPI uses PRIVATEKEYBLOB and PUBLICKEYBLOB formats to export and import RSA keys while OpenSSL extension for PHP uses PEM format. In order to use both libraries in communicating applications we needed some tool to convert keys from one format to another. The only tool we found for this was OpenSSL 1.0.x beta. Notice that earlier versions of OpenSSL do not support CryptoAPI BLOBs.

Update: It was found later that CryptoAPI has native functions for key conversion. See “Update” section at the bottom of the post.

Below is a command line syntax example for conversion of private key from PEM to PRIVATEKEYBLOB format:

openssl rsa -inform PEM -in private.pem -outform MS\ PRIVATEKEYBLOB -out private.blob

And this example converts PUBLICKEYBLOB to PEM format:

openssl rsa -pubin -inform MS\ PUBLICKEYBLOB -in public.blob -outform PEM -out public.pem

Notice that backslash (\) in format names. You need to type it as it actually escapes the space character.

However, we found some drawbacks in usage of OpenSSL 1.0.x beta:

  • There was no Windows build of it available at the time of the post but we wanted to convert keys on Windows.
  • We also wanted to convert keys directly in our code w/o any need for external application.

As far as PRIVATEKEYBLOBPUBLICKEYBLOB and PEM format structures are known, we decided to develop code that will read and write them using low-level functions. It actually took 1-2 days for me to develop that code so I don’t think it’s a really hard task.

Later we faced another problem: PHP versions prior to 5.2 don’t support openssl_pkey_get_details function. Once again, handling key formats directly helped us to resolve the issue by providing a replacement for the function.

So, let me explain how you can implement reading/writing PEM, DER, PRIVATEKEYBLOB and PUBLICKEYBLOB formats with some code examples in PHP for PEM and DER formats and in C++/VCL for CryptoAPI BLOBs. As the task was a part of a commercial project I cannot post a complete working example here. But I will do my best helping you to assemble such code on your own. You can also request our service at Pumka.net.

Read the rest of this entry »

RSA encryption for C++/Delphi (CryptoAPI) and PHP (OpenSSL) [part 2]
Dec 16th, 2009 by Anton Oliinyk

In my previous post I explained that we needed to encrypt a communication messages between Windows C++/VCL client and PHP based web service. We cannot use SSL and decided to use RSA encryption with the help of low-level functions provided by CryptoAPI at the client side and OpenSSL PHP extension at the server.

We also faced and resolved the key incompatibility problem. See my post about this.

In this post I will describe implementation or RSA encryption/decryption and digital signing.

Read the rest of this entry »

SIDEBAR
»
S
I
D
E
B
A
R
«

Valid XHTML 1.0 Transitional