author: Krasimir Tsonev

Krasimir is a blogger, who writes and speaks.
He loves open source and codes awesome stuff.

ExpressionEngine: thumbnail could not be created for the image under Windows

posted in PHP on 2013-11-28
I'm a Windows user and I'm working on a ExpressionEngine based site. I'm using EasyPHP as a server and everything works as expected. However, once I decided to upload a file I got "Thumbnail could not be created for the image. Please make sure the thumbnail directory is writable.". read more comments

PHP: please, please, clear my cookies

posted in PHP on 2013-10-31

I'm currently working on a JavaScript application which is using the facebook API. There are some things which I need to pass from one page to the other. So, I decided to use cookies. The storing works like a charm, but the deleting doesn't. I needed one hour to find the exact problem.

read more comments

PHP: simple captcha script

posted in PHP on 2013-08-08

In my company, we have a lot of WordPress sites. Some of them require contact form with captcha field. The short way for solving such task is to use a plugin. However, as you may guess, the add-ons are available for everyone, which means that they could be easily explored and probably hacked. That's why I suggested a simple, custom script, which is developed by us.

read more comments

Deploying ExpressionEngine based site

posted in PHP on 2013-06-25

I found ExpressionEngine framework very good. It brings the flexibility which I need and still has a good amount of features. However, as many other similar tools, the deployment could be a little bit difficult.

read more comments

Importing huge MySQL dump under Windows.

posted in PHP on 2013-06-17
I just received a 250MB dump of a database and I needed to see what is it inside. As you may guess, PHPMyAdmin is not a good option in this case. I decided to use the command line. read more comments

mod_rewrite, one simple rule and two stupidly lost hours

posted in PHP on 2013-06-05

Ok, I should admit that mod_rewrite and regular expressions are not my strongest part. Today - as every other day I realize how little knowledge I have. Actually it's good to have such moments. I lost almost two hours fighting with a really really simple mod_rewrite rule in my .htaccess file. read more comments

A short review of ExpressionEngine framework

posted in PHP on 2013-05-20
I'm going to start a new project with ExpressionEngine. So, I made a short review of the framework's capabilities. The article is available at my account in tech.pro. read more comments

Cleaning up <pre> tag content

posted in PHP on 2013-02-02
I'm blogging for different technologies, but very often I need to add some code in my articles. This little PHP function helps me to keep the text in my <pre> tags clean for prettify. It simply removes the <br>'s and keeps the html tags. read more comments

PHP developers - wake up!

posted in PHP on 2013-01-16
PHP is one of the most popular back-end solutions available. However, I think that there is something wrong with the way we are using it. It is really popular to use some giant framework, with a lot of features. Generally, I'm not a big fan of this approach. Even if the framework is well documented and has big community it still adds some restrictions and complexity. Many people are trying to build the perfect framework, which covers as many cases as possible, but the true is that it is not possible. In this article I'll present you my vision about PHP programming and I will be very happy if you share yours. read more comments

Discussion about PHP at VarnaLab

posted in PHP on 2012-11-22
A screen capture of the discussion about PHP at VarnaLab. read more comments

PHP: the right way

posted in PHP on 2012-07-09
[1]There’s a lot of bad information on the Web (I’m looking at you, W3Schools) that leads new PHP users astray, propagating bad practices and bad code. This must stop. PHP: The Right Way is an easy-to-read, quick reference for PHP best practices, accepted coding standards, and links to authoritative tutorials around the Web.http://www.phptherightway.com/ read more comments

Dependency Injection in PHP. Create your own DI container.

posted in PHP on 2012-05-12
By my opinion one of the biggest problems in programming are dependencies. If you want to have a good well written application you should avoid dependencies between your modules/classes. There is a design pattern which could help and it's called Dependency Injection (DI). It allows you to inject objects into a class, instead of creating them there. read more comments

PEAR PHP Coding Standarts

posted in PHP on 2012-02-29
The PEAR Coding Standards apply to code that is part of the official PEAR distribution. Coding standards often abbreviated as CS among developers and they aim to keep code consistent to be easily readable and maintainable by most of PEAR folks.http://pear.php.net/manual/en/standards.php read more comments

MySQL vs JSON file data storing

posted in PHP on 2012-02-12
I'm not exactly a performance perfectionist, but currently I'm working on a tool which will be used in a large system. It will deliver texts to a multi-language environment and there will be several sites/apps which will performe big amount of request to it. It is the right moment for me to choose how to speed up my code and the work of the tool overall. read more comments

Basic PHP authentication

posted in PHP on 2011-10-17
The .htaccess file is actually a possible solution for this purpose. The problem with this approach is that the value of AuthUserFile should contain an absolute path. It also works with relative paths, but it is relative based on ServerRoot, which in most of the cases is different from DocumentRoot. I also didn't want to deal with sessions or cookies and after a short research I found the answer. read more comments

\"This page contains both secure and non secure items\" message

posted in PHP on 2011-05-26
When you are opening a site via https protocol and there are items loaded with absolute addresses started with http some browsers, like IE, throw a message This page contains both secure and non-secure items. It is really annoying and if the user decides to can prevent these items of showing and he can brake the whole layout or some functionality. read more comments

PHP: add text to transparent PNG image

posted in PHP on 2011-03-10
Simple way to produce numbered image with PHP. The script uses PHP GD. read more comments

PHP: convert emails to mailto links

posted in PHP on 2011-02-17
It looks like an easy task, but I decided to share it. read more comments

PHP: Simple javascript obfuscator (merging files)

posted in PHP on 2010-12-30
Currently I'm working on a big JavaScript project. It has a lot of files that have to be compressed. I wrote a simple php class that merges all the files into one. It has also a useful simple obfuscator method. read more comments

PHP: export data to XLS file

posted in PHP on 2010-12-01
Sometimes it is necessary to present your data in format which is popular and easy to work with. In most cases the CSV format will fit perfectly you and your clients, but sometimes you have to export the information in XLS file. These several functions will help you to do that. read more comments

PHP: find links in a string and replace them with actual html link tags

posted in PHP on 2010-11-24
Currently I'm working on an application that gets data from Twitter. The tweet's string contains links that have to be transformed into html link tags. Here is a simple PHP function that helped me. read more comments

Remove html tags from a string wtih PHP

posted in PHP on 2010-11-12
Sometimes you don't need any formatting. That's just a nice way to remove all the html tags. read more comments

How to import images directly into the html code (base64)

posted in PHP on 2010-11-11
A couple of months ago I received an interesting task - to create a small html application for iPhone. To be honest, for me that meant creating a small site with a specific size. Of course I was wrong. Together with couple of small bugs I had to deal with one other requirement - everything had to be in one html file. It was clear how to add the javascript and the css, but what about the images.The solution was to use base64 encoding. I wrote a small php script that accepts an image and shows me the equivalent in base64 string.
<?php      $base64 = "";    $css = "";    $tag = "";      if(isset($_FILES['f']['name'])){        $file = rand(0, 10000000).$_FILES['f']['name'];        if (move_uploaded_file($_FILES['f']['tmp_name'], $file)) {            if($fp = fopen($file,"rb", 0))            {               $picture = fread($fp,filesize($file));               fclose($fp);               // base64 encode the binary data, then break it               // into chunks according to RFC 2045 semantics               $base64 = base64_encode($picture);               $tag = '';               $css = 'url(data:image/jpg;base64,'.str_replace("\\n", "", $base64).'); ';            }        }    }      ?><html><head><title>Base64 img convert</title></head><body>    <form action="./index.php" method="post" enctype="multipart/form-data">        <input type="file" name="f">        <input type="submit">    </form>      The CSS code:      <textarea style="width:800px;height:100px;font-size:10px;"><?php echo $css; ?></textarea>        The HTML code:      <textarea style="width:800px;height:100px;font-size:10px;"><?php echo $tag; ?></textarea>        <?php echo $tag; ?></body></html>
Just browse your image and click "Submit Query".P.S.base64 doesn't work in IE read more comments

How to display php errors when display_errors is set to off

posted in PHP on 2010-09-17
I successfully finished an interactive project for one of my clients. We did a great job and finally I had to install the system on their server. I received the FTP and MySQL information from their IT team, but when I uploaded all my files the site didn't work at the first time. The server didn't show any errors and I wasn't able to find out the problem. read more comments

Export mysql data to SQL script or CSV

posted in PHP on 2010-09-04
Yesterday I received host name, user name and password for a MySQL server. I needed to export the data from it. I didn't have access to PHPMyAdmin, I tried to connect to the server by mysql.exe on my PC, but it didn't work. And then I found really good solution - PHPMyAdmin in only one php file. I launched it from my localhost and it works. So if you need to export data or just see it, use Adminer. I also uploaded the file on my server, you can download it from here. read more comments

How to exclude directory from .htaccess file

posted in PHP on 2010-06-17
Did you ever wonder how to exclude a directory from a .htaccess file. Here is the solution, it works perfect for me. read more comments