Archive for the ‘Development’ category

CakePHP: CakeMenu plugin

September 1st, 2010

I am using it for a while, but today I’ve decided to publish in the github.com.

What this plugin does?

The plugin is complete solution to add menu in your applications. It uses the nifty Superfish – jQuery menu plugin. You can find more info for it at http://users.tpg.com.au/j_birch/plugins/superfish/

Cakemenu can work with multilevel menus and reduces the database calls by caching the menu nodes. The plugin working with Authake plugin if you need to apply filter to menu nodes (user need to see only allowed locations)

Cakemenu working with CakePHP 1.2 but it’s tested with Cakephp 1.3 (RC3) and it would not have any problems with the future releases so far.

Requirements

  • CakePHP 1.3 (of course)
  • jQuery in the head tag
  • Authake (optional) if you require your menu nodes to be filtered when user with limited privileges is logged in. Actually it’s possible to use other authorization class, but you have to extend it.

I believe that’s it. Check the large README file in the project’s directory.

CakePHP: Authake plugin with installation guide

August 30th, 2010

Finally the Authake Plugin have an Installation guide.

Basically the plugin provide Authentication and Authorization functionality for CakePHP’s appliation with few line of code. Authake has advanced User-Group-Role interface and allow you to secure your CakePHP’s application within a minute.

The current version of the Plugin is “wrapped” in a single folder (according to CakePHP 1.3 conventions) under the Plugins.

Online html to pdf tool

June 27th, 2010

html to pdf converter I just want to present a new tool for converting HTML to PDF – html-2-pdf.com. It’s basically an online converter which could transform any* web site to a PDF document. Generally it could be useful if you want to print a website, or for example if you want to save the content of the website for offline reading.

The site is really simple – just insert the address of the web page which you want to be converted and few seconds after that it is ready to be downloaded. The site is just an interface of the amazing wkhtmltopdf library.

I am open for suggestions about the functionality of the site.

* – for some reasons there are web sites which are not converted correctly. This is because of HTTP headers which these sites restricting.

Careful with the links in the layout

April 24th, 2010

When you building application most likely there are common links within the layout. They could be in a menu, or let’s say “edit profile” and ‘logout’ links which are visible everywhere. As you probably know if you use Html Helper the link could be either Cake-relative URL or array of URL parameters.

The problem may occur if you using the second option – the array.
» Read more: Careful with the links in the layout

Quick tip how to use url() in the controller – CakePHP

April 22nd, 2010

Sometimes you need to use url() in the controller.

It’s possible to use Html Helper in this case, but for url() only, you can use:

$link = Router::url(array('controller'=>'my_controller', 'action'=>'my_acton'), false);

Wll, not a rocket science indeed, but let’s hope this help someone.

How to – layout with fixed sidebar

March 13th, 2010

Today I was working on a page layout where a page width had to be fluid, while the sidebar had to be with fixed width. So here is my solution:

The layout looked like this in the beginning:

Layout

» Read more: How to – layout with fixed sidebar

Problem with mysql_real_escape_string when Sanitize your data.

February 28th, 2010

When building applications is always smart to check and clean the user input. This is a must when you building a website or public application.

I create always an instance of Sanitize class in my AppController and then using it in all of my controllers like this
» Read more: Problem with mysql_real_escape_string when Sanitize your data.

CakePHP Excel Helper

November 21st, 2009

This is a helper for building multi-sheets Excel documents in CakePHP. The hepler was inspired from Yuen Ying’s blog post, but it’s extended to support multiple sheets.
» Read more: CakePHP Excel Helper

How to secure selectively admin location

November 15th, 2009

Securing the admin part of the site is always tricky, especially for open source software CMS. A very good practice is to protect your admin directory with an extra .htaccess, because most of the damages has been done from exploits of the applications rather than brute force cracking.

There are many articles how to set up .htaccess authentication on Apache web server, but here I will explain how to set an extra password request only for Internet users while the users from Local Network should spare the extra password.

The scenario:
When the user in in the local network the administration part need to be accessible with the CMS default authentication, while if the user access the Administration from Internet, an extra password prompt will be shown.

1. Create your password file

# htpasswd -c /your_secret_location/.htpassword user
New password:
Re-type new password:
Adding password for user user

If you writing in an existing file don’t use the option -c

2. Setting the .htaccess
Depending of the server set up you can do this in your httpd.conf, or in apache2 style – in sites-available directory. So, let’s say we have a file in /etc/apache/sites-available called site.com which holds the record of the domain

<VirtualHost *:80>
        ServerAdmin email@site.com
        ServerName  site.com
        ...
        <Location /admin>
                 AuthType Basic
                 AuthName intranet
                 Satisfy any
                 Allow from 192.168
                 Order allow,deny
                 AuthUserFile /your_secret_location/.htpasswd
                 Require valid-user
        </Location>
        ...
</VirtualHost>

Here is the tricky part: The directive “Satisfy any”. By default the directive is set to all so it’s like AND:
If (you are in local net AND you are valid user) {access the location}

while Satisfy any is like OR
If (you are in local net OR you are valid user) {access the location}

More on this topic: Satisfy directive

Adding notification when new order arrives. Magento

October 28th, 2009

It’s very common practice the administrators to get notification mail when a new order is placed on the shop. Here is how to activate this feature in Magento for free (there is paid Admin Notification Module as well):

Log in into admin area, then go to System->Configuration menu. Scroll down to Sales section and click on the Sales Emails and select the first section Orders. Enter your admin e-mail in the field “Send Order Email Copy To”.

And here comes the tricky one :) Select the option “Separate email” from the “Send Order Email Copy Method” field. I don’t know why, but if it’s selected “Bcc”, the e-mail to the admin wasn’t send.

It’s possible that this is fixed in the versions above 1.2.x, but I haven’t tested.

hope this helps someone.