Simple way for hiding your email address

They say that SPAM bots are really good these days and can figure out your e-mail out of many “traps”.

I wonder, if they can catch it out of something like this:

<a
    href="mailto:me.nononono@domain.nononono.com"
    onmousedown="this.href=this.href.replace('.nononono','')"
    onkeydown="this.onmousedown()">
contact me</a>

I prefer to think, they don’t and that they’ll crush their ugly spammy teeth on this! :]

Problems installing Google Earth client or plugin

Sometimes any attempt to install Google Earth standalone program or a plugin for your favorite browser ends up with error message: Error during execution of GoogleEarth.exe. Cannot find specified file. If you’re installing a plugin, directly from your browser, you can see an additional message saying that installation failed with error number 9. I don’t know, what exactly causes this to happen, but found an easy workaround for this.

Read More “Problems installing Google Earth client or plugin”

Application works fine on localhost but fails on web server

If you ever run into situation, that your application works fine on localhost (or one of webhosting) but fails completely on webhost (or another server), then first thing, you should look for, is to check, if you don’t have an extra XHTML line in on of your files that you’re loading using include or require — meaining, that your loading and PHP-parsing these files. Because problem doesn’t exist, if you’re loading this files as simple text files, using file_get_contents for example.

Situation, I’m talking about most times causes a PHP syntax error saying, that there is an unexcepted T_STRING in first line of one of the files used in an application. If you look to this file, you may find following line as first one:

<?xml version="1.0" encoding="iso-8859-2"?>

This usually happens, when environment, where your application works, has PHP short_tags enabled in configuration, while on failing webserver most probably this config option is disabled. PHP tries to parse it and fails. Since this is XHTML-related problem, most times it comes around template files or similar.

There are many questions here, but only one answer.

I don’t know, why some editors adds this line, when creating new XHTML file, while others doesn’t add them. I don’t know, why PHP parses this line correctly (doesn’t come out with any error), when short tags are enabled and while fails, when they’re disabled — in both cases this line seems to be unparsable, as it does not contains valid PHP code. Finally I don’t know, if removing this line will or won’t make your file / app valid and go through XHTML validators without any problems — i.e. if it is or isn’t necessary as a part of valid XHTML file. But the only answer, I know to all these conserns, is — remove this line.

That’s it. I tested layout file containing this line, being loaded and parsed via require, on both simple PHP app and large framework-based (Yii of course) project. When short tags were disabled, both apps failed. And removing this line was the only remedium in this case.

BTW: You can enable or disable short tags, no matter what your server configuration is, by adding:

php_value short_tags off

to .htaccess file placed in root folder of your PHP application.

That’s all I know for now. Go ahead, and write in comments, if you have any other solution to described problem or if you can add anything here.

Simple page rendering class

I have created a simple CPage class, which I use in my non-Yii projects for easily rendering views, templates and whole pages using object-oriented approach. This class can render given contents into given view and embeded it in a selected layout file. These are very limited versions of Yii framework’s view and layout rendering mechanisms. I have also added a simple alerting system, this time taken from Twitter Bootstrap.

Read More “Simple page rendering class”

Simple function for drawing HTML dropdown list from various sources

If you’re still lurking in the darkness of writing code with pure PHP and not using any framework then in this post you can find some nifty function, useful for drawing a HTML list boxes.

Basically it tries to render (draw) a <select> element basing on input data provided in $source variable. It can be either a list (key=>value) or string, where values and items’ texts are separated with delimiter. Such string can be provided directly or read from file. In this case you only provide path to a file (source of data).

Read More “Simple function for drawing HTML dropdown list from various sources”

Grouping controllers without using modules

Basic Yii application’s route consists of controller and action. Sometimes you have to add an extra separation layer, to group controllers and actions belonging to separate groups. Not everyone know, that you don’t have to use modules for this purpose. Controllers subdirectory can also be a considerable option. For me, this was a nifty discovery, so I decided to write this down as a personal memo.

Read More “Grouping controllers without using modules”

Multi-site multi-language Markdown-styled WordPress network

I’ve set myself quite big goal. To setup:

  • multi-site WordPress network (with top-level domain mapping),
  • with multi-language support,
  • that will use Markdown,
  • with auto-generated table of contents, based on headers and
  • with “coming soon” / “under construction” page for not ready sites.

To achieve my goal, I needed a bit tweaked version of WordPress (network) plus a bunch of plugins.

Read More “Multi-site multi-language Markdown-styled WordPress network”

Object-oriented plugin template for WordPress

I love WordPress, but the worst thing about it is that it is written with the most shitty code, I have ever seen.

WordPress development started years ago, and though during past years object-oriented programming has become de facto standard, WordPress still remains full of shit code and shitfull coding techniques. I can understand it about core code. After all — rewriting whole WordPress to OOP could be too big piece of cake. But I completely can’t understand it, why plugin’s authors follows this and write their plugins with pretty much the same shit code?

In this situation, any attempt of making things better is very welcomed (at least by me). The Object Oriented Plugin Template Solution plugin (or actually — plugin template), I ran into today, sounds like such promising star in a dark, dully sky of shit-code.

I recommend this plugin template to every WordPress plugin author. Even though it’s pretty new (published today) it looks very, very promising.

Sending app written in Yii through Gmail

Just a small notice, if you’re ever going to send a Yii application through Gmail. Make sure, that you browse archive, that you’re about to send, and delete all *.bat files from framework folder. If you miss that, Gmail will refuse to send email with such attachment, due to “executable file inside”.

Pity is, that this error pops up after attachment is uploaded to Gmail. An archive containing full framework code can take 10 MB or more and can waste some time to attache it to Gmail.

JS and PHP or Yii photo manipulation libraries

I was faced with a problem of picking a good photo manipulation library. Either client-side or server-side. Both for working with my newest Yii project. This article is a summary of my quick research in this field.

All JavaScript libraries works on Canvas, so require HTML5 and Canvas-enabled browsers. Most modern browsers supports both of them in newest versions.

The only PHP image manipulation library works mostly on uploaded image.

Read More “JS and PHP or Yii photo manipulation libraries”