Sjoerd Maessen blog

PHP and webdevelopment

Update PHP on DirectAdmin

without comments

Making sure a server is up-to-date is essential for security and performance reasons. If you have a server installed with DirectAdmin there really is no reason to wait any longer with the upgrade. Updating PHP, PHPMyAdmin, MySQL and other packages is done trough the “custombuild” script and it’s quite easy.

First make sure your OS is up to date, how to perform this update depends on your OS. In my case I’m running a CentOS server.
yum update
Make sure you double check which packages will be updated.

The next step is updating DirectAdmin
cd /usr/local/directadmin/custombuild

Let’s see if there are updates available
./build update

Which versions are we going to install?
./build versions

Perform the update, be patient, this can take a while.
./build versions

After the update make sure to check any feedback and recommendations of the CustomBuild script. It does perform some security checks to see if software is running as the correct user etc.

If you want to install a different PHP version, for example upgrade PHP 5.x to 7.x you can easily do this by changing the DirectAdmin config file. Make sure to first check the compatibility of PHP extensions you may need in your applications.
vi options.conf
Now hit “i” and change the values, after you are done press escape and enter “:wq” to save and exit VI. You can now run the update process to upgrade PHP.

Needless to say you should make sure backups are in place before performing any upgrade.

Written by Sjoerd Maessen

April 30th, 2016 at 7:46 am

Posted in DirectADmin,Server

How to accept Bitcoins donations?

with one comment

Wether you have a blog or a charitable company you may consider to start accepting donations in Bitcoins. By doing so you give people around the world an easy way to donate. Once you have a wallet with a public address  you are all set to go. When you are not familiar yet with Bitcoin, wallets or a public address, I suggest visiting the following Bitcoin site for more information before reading on.

Various ways to communicate the Bitcoin donation address
There are a few ways to communicate the donation address, all have there strong and weak points.

Plain text
One possibility is to simply list your public Bitcoin address like below:
176dStgJnMzYRMaSP77jpTu2WnrGmsPGV5

The problem with the above method is the fact there can easily occur a copy paste error and people who are willing to donate need to know they should enter this address in their wallet.

Using a donation link
To prevent copy paste errors it’s better to use a link that automatically starts the Bitcoin client with the BTC address pre-filled. Or even the amount and a label, the amount and label are both optional url parameters.

176dStgJnMzYRMaSP77jpTu2WnrGmsPGV5

  1. <a href="bitcoin:176dStgJnMzYRMaSP77jpTu2WnrGmsPGV5?amount=0.005&amp;label=Sjoerd">
  2.      176dStgJnMzYRMaSP77jpTu2WnrGmsPGV5
  3. </a>

 

Using a donate image or button
More appealing then a text link is a nice image or button. Consider changing the image below to an image that says “show some love” for your charity. This way it’s more personal.

Donate Bitcoin

  1. <a href="bitcoin:176dStgJnMzYRMaSP77jpTu2WnrGmsPGV5?amount=0.005&amp;label=Sjoerd">
  2. <img alt="Donate Bitcoin" src="/path-to-bitcoin-image.png" /></a>

 

Bitcoin url or wallet shortener
Another possibility is to use a shortener service that converts a Bitcoin wallet address in a shortened url. However I do feel this brings a greater risk because of the possibility the shortener service gets hacked and donations are sent to another public Bitcoin address. Examples of such services:

In the (nearby) future there will definitely come official Bitcoin user-friendly urls that can be used as an address for sending and receiving BTC but for now these services can be a great alternative.

Using a QR code
The methods above all have the same disadvantage, you have to visit the webpage with the public donation address trough a computer or smartphone to be able to click or copy paste it to you wallet. When you are fund raising on the streets people can’t click on your link and writing it down on a piece of paper won’t be very user-friendly neither. The solution for this problem comes in using a QR code. A QR code can be easily scanned by all modern smartphones, the QR code will then be translated into your public address without any change of copy paste mistakes. To generate a QR code of your public address you can use the Bitcoin wallet software on your computer or use a website like blockchain.info, simply enter the BTC address and watch it generate a QR code. A example or such a code can be seen below:

bitcoin-qr

 

 

 

 

 

Conclusion

Accepting donations is easy like that, there’s nothing more to it, good luck!

If you liked above information, don’t forget to tryout the link below:
176dStgJnMzYRMaSP77jpTu2WnrGmsPGV5

Written by Sjoerd Maessen

January 12th, 2014 at 7:56 pm

Posted in XML

Instant Magento Performance Optimization How-to

without comments

This week I received a review copy of the book “Instant Magento Performance Optimization How-to”, “Improve the performance of your Magento stores using pratical, hands-on recipes”. The book title sure sounds good since performance is often one of the main issues in any Magento project. The book is relatively compact (only 56 pages) and easy to read. It’s divided in clear subjects that cover a wide range of improvements going from merging css and js files to clustering, database replication and load balancing.

The good parts
One thing I really like about the book is that it offers small hands-on subjects with clear steps to take. It often shows the load time improvement that can be accomplished by implementing the solution so you will know what the benefit will be of a solution.

Although the book is specifically written for Magento projects some of the tips can be applied to any web project. All tips that are offered in the book can already be found on the internet but this book bundles them in a neat way for referencing.

The bad parts
I do think that the author of the book sometimes should warn the reader about drawbacks of a performance tip. For example the part about storing “sessions in the database”. It would be nice if the reader was warned that changing the session storage mechanism on a high traffic webshop would cause a big performance hit on the database and the performance result could be exactly opposite of what is intended to accomplish.

Another thing I really didn’t like was the fact the author advices to chmod the var/logs directory to 0777. This is just a bad practice and should never ever be done.

As a Magento developer I would have liked to see some more in-depth information on some topics but maybe that just isn’t in the scope of the book.

Verdict
The book is nice to read and useful to keep as a reference afterwards. It has some good tips for Magento administrators (beginner to advanced) and can be helpful in solving performance problems. Overall I would recommend buying this book but pay attention to what you are doing and what the possible drawbacks can be of some of the tips that are provided. Consider the book to be a fast reference and introduction to different performance improvements that can be done.

The Packt Publishing can be found here for only €6.79 at the moment.

Written by Sjoerd Maessen

April 18th, 2013 at 9:40 am

Posted in Magento

PHP hook, building hooks in your application

with 5 comments

Introduction
One of the real challenges in building any type of framework, core or application is making it possible for the developers to hook into the business logic at specific points. Since PHP is not event based, nor it works with interrupts you have to come up an alternative.

The test case
Lets assume we are the main developers of a webshop framework. Programmers can use our framework to build complete webshops. Programmers can manage the orders that are placed on the webshop with the order class. The order class is part of our framework and we don’t want it to be extended by any programmer. However we don’t want to limit to programmers in their possibilities to hook into the orders process. Read the rest of this entry »

Written by Sjoerd Maessen

May 23rd, 2011 at 8:02 pm

Posted in API

Tagged with , , ,

Passing the PHP 5.3 ZCE exam

with 4 comments

I passed the PHP 5.3 ZCE exam
Today I passed the exam to become a PHP 5.3 ZCE. Like everyone else I had to sign the non-disclosure contract so I can’t go into detail about the questions that were asked, I can however tell my impressions of the exam and how prepared for it.

Differences with the previous exam
The first thing I noticed when I bought the PHP 5.3 exam voucher was that there was no option to order a bundle of preparation tests. There was however a free study guide. The new study guide can not be compared with the previous php|architect’s Zend PHP 5 Certification Study Guide. Were the new free study guide gives a quick overview (including some example questions) of each topic in the exam the original study guide starts with basics of PHP and really covers each topic thorough, except for the new PHP 5.3 features. Read the rest of this entry »

Written by Sjoerd Maessen

December 30th, 2010 at 3:54 pm

Separating your controller from your view

without comments

What is a controller?
A controller can best be described as the set of instructions and algorithms that are responsible for making your application actually doing something. Often based on user input. You could say your controller is your business logic.

What is a view?
The view is the presentation of your application, the part that our user sees. The view won’t do any processing (like math, checking data,…) it will just show data.

Why don’t you separate your logic and view?
I don’t know how or I don’t use a framework. Those are both often heard excuses when I ask someone why he doesn’t separate the logic and view of his application. Even when you Read the rest of this entry »

Written by Sjoerd Maessen

August 9th, 2010 at 12:08 pm

ImageMagick installing and exploring it, a good alternative for the GD library

without comments

Although PHP GD library handles basic image operations quite good, you have probably run into the limitations of GD library as well, it is often slow, memory intensive and a bit complicated to use for advanced image effects. ImageMagick however is a very good alternative. It is an opensource software suite licensed under a BSD style license from IM itself. ImageMagick provides in all functionality that can be accomplished with the GD library but even goes a step further with support for more advanced image edit techniques. An example of such a technique is the recently added “liquid scaling” feature, this is a content aware scaling option. Read the rest of this entry »

Written by Sjoerd Maessen

July 19th, 2010 at 7:20 am

Posted in API,Server

Tagged with ,

Git tutorial, getting started with Git

with one comment

Below is a short comprehensive description of getting Git up and running in just a few minutes. I personally use OSX as a development machine and so the installation part of Git will cover an installation on OSX. If you like to install Git on another platform please take a look at the Git installation documentation. There are a lot of other ways to install Git, but the one described below seems to bring the least hassle on OSX.
Read the rest of this entry »

Written by Sjoerd Maessen

June 14th, 2010 at 7:23 am

Posted in Server

Tagged with ,

Input validation with filter functions

with 2 comments

Introduction
Although PHP has a lot of filter functions available, I found that still to many people are using (often incorrect) regular expressions to validate user input. The filter extension is simple, standard available and will fulfill the common validations. Below some pratical examples and things to consider when working with PHP filter functions.
Read the rest of this entry »

Written by Sjoerd Maessen

June 3rd, 2010 at 8:27 am

Posted in Security

Tagged with , ,

Tips that prevent your mailing being marked as ‘spam’

with one comment

Introduction

The last couple of weeks I was working on writing a mailing/newsletter system myself. One of the first questions that came up was “how do I prevent that my newsletter will be marked as spam”. Although this article has nothing to do with PHP I still like to put it in the spotlight. I will give some tips on how to avoid your mail being marked as spam, some you will know, others you won’t.

How is determined if my email is spam?
Mostly this is done by so called spam filters (server side or client side), some well known examples:

Some of them work with the Bayesian filter. This filter is one of the Read the rest of this entry »

Written by Sjoerd Maessen

May 3rd, 2010 at 7:13 am

Posted in Mail

Tagged with , ,