Alternative module configuration that does not affect main configuration

In Yii main application is actually a module (core one) so each module configuration actually shares nearly everything what you can put to main application’s configuration file.

Thus, you can configure any Yii module, just as you would do with your main application. The only difference is that you don’t use external configuration file, but CModule::configure() function instead.

Read More “Alternative module configuration that does not affect main configuration”

Passing current or last page full URL as a part of URL

By using five separate PHP functions, in correct order, you can easily pass (code and decode) entire page’s URL as a parameter of any other script call, redirect etc. And be sure that it will be read (decoded) correctly, no matter, how long your URL is or what kind of characters it is using.

You can encode any URL (current page, last visited page or any otherwise important) and pass it in another URL in the way that your user won’t notice that you’re actually passing an URL.

Presented solution can potentially be used as URL shortening service. Generated URLs aren’t that short (as maybe expected), but for really long URLs it does provides some shortening.

Read More “Passing current or last page full URL as a part of URL”

CMarkdown usage examples

You can use CMarkdown class as typical Yii widget:

[code language=”php”]
<?php $this->beginWidget(‘CMarkdown’); ?>
_Markdown_ *example*
<?php $this->endWidget(); ?>

or directly as a function:

[code language=”php”]
$text = ‘_Markdown_ *example*’;
$md = new CMarkdown;
echo $md->transform($text);

That’s pretty much everything, folks!

Too long URLs in Apache

It turned out that in current version of Apache you’re limited to 255 characters at most between each pair od slashes (after URL decoding is done). This short article discusses this issue and maybe useful to all developers, who are dealing with “beauty” (SEO-optimized) URLs, like for example URLs to blog posts containing entire title inside.

This is a rare situation (255 characters limit between slashes, not for the entire URL), but still worth exploring.

Read More “Too long URLs in Apache”

Things for which I trully hate PHP and its creators

PHP is the most popular programming language for development of webpages and web services. With addition of a good framework it can even produce a professional results. However, this does not change the fact, that it is also the most shitty programming language in the world, full of garbage and with number of stupidities beyond imagination. And professional programming (without a good framework) is impossible.

Even though this is a language of my choice (only after cleaning it from all the shit, by using a good framework), I decided to write this article, where I’m pointing out most annoying and stupid things, I ever found in PHP.

Notice, that I’m not talking here about things that some may see as wrong, while other will see as good. For example, I’m not talking about types auto-declaration and auto-change, which ones (mostly newbies) takes as ease of coding and others (mostly profs) as source of mess.

I’m talking here only about pure madness, confirmed piece of shit and horrible pain in the ass, this language is.

Please, take also into consideration that this text was written under strong emotional influence and thus it (intentionally!) contains a lot of harsh language and words or phrases that some readers may not accept.

Read More “Things for which I trully hate PHP and its creators”

screen: Force program to continue after logging-off from the console

So, there I was… needing to have any solution, that will allows me to write my very own port listener. Since the only language, in which I am handy is PHP, I was forced to be able to run PHP script without interruption, 24 hours a day, 7 days a week. That was a bit of challenge for me, given my quite very limited Linux knowledge, but — as they say — the only thing not possible in IT is to open an umbrella in your ass! :>

Read More “screen: Force program to continue after logging-off from the console”

Simple script for showing contents of a folder

Long long time ago in a galaxy far far away I wrote a very simple PHP script, that I usually put into index.php of a directory, which contents I’d like to print out to the browser. I’m using this solutions on all servers and hostings which has Apache-based directory listings disabled and thus are showing empty page or error screen, if folder does not contain index.php.

Here’s the code:

[code language=”php”]
$dir = getcwd();

if (is_dir($dir))
if ($dh = opendir($dir))
echo(‘Files in this folder:<ul>’);

while (($file = readdir($dh)) !== false)
if ($file != ‘.’ && $file != ‘..’ && $file != ‘index.php’)
echo(‘<li><a href="’.$file.’">’.$file.'</a></li>’);


That’s pretty much everything, folks!

Using PHP and Oracle database

I was working on bigger project using PHP (Yii) and Oracle database (through PDO and Yii). This isn’t a very common combination and many developers thinks, that writing PHP application to use Oracle database is a pure madness, mostly due to many strange behaviors and nasty bugs, that are present in PDO driver for Oracle. I can actually confirm this. Following article contains links to my Yii forum discussions on various aspects of using Oracle with Yii and PHP. You may find it useful, if you’re struggling with any problem.

Read More “Using PHP and Oracle database”