For my current project I need a detection if the cookies are enabled or not in the user’s browser.
The easiest way to do this is by using this code:
The CakePHP way is almost similar:
Ok, it’s not rocket science, but it helps
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
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
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
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
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.
Yesterday I found a tool which could be handy for rookie CakePHP developers. Atlas is a web code generator based in CakePHP. As a glance it’s a web alternative of CakePHP bake console which is a nice idea indeed.
My first impression was that tool is like diamond in the mud and I was wondering how I didn’t hear about this tool till now, but after installing I realized that it’s not so good as it looked like.
The first problem occurs in the generation of my first project – I’ve got a error message in Spanish which I couldn’t understand. I had to use Google translate for it, but after the translation, the message still doesn’t say much – “Failed to generate project skeleton”.
After debugging the code figuring out why this error means, I found that the application uses backslash as directory separator (\) ?!? and of course this lead to directories and files with strange names like /var/www/ctest\app\controllers directories where ctest\app\controllers was the full name of the directory
. I am on Ubuntu Desktop machine where backslash is not a directory separator.
Pros:
Cons
The conclusion:
Atlas looking like promising tool, still it’s far from the final version, but it’s worth to try it in Windows environment.
I definitely will follow that project in the future, so hopefully I could use it one day
Few weeks ago I’ve been contacted from Packt Publishing in order to review their new book Magento Beginners Guide and because I had experience with that e-commerce platform, I decided to accept the offer.
Magento Beginners Guide is a new book that covers the process of building an online store using the Magento e-commerce solution. It’s written by William Rice and is focused on the main key features of Magento to setup a unique on-line store and customize its appearance with the help of examples.
This book is for anyone who wants to create an online store using Magento. If you are a non-technical person and are discouraged by the complexity of this powerful e-commerce application, this book is ideal for you.
Magento is the world’s most evolved e-commerce solution which runs on the Apache/MySQL/PHP platform. From one installation, you can control multiple multilingual storefronts, all sharing customer and product information. Magento’s templates, themes and extensions gives the possibility to create an unique and powerful solution for e-commerce.
The book provides a step-by-step approach to building a simple and effective on-line store. It covers the key features of Magento that will help you get your store up and running. It guides you through the installation, configuration, adding categories and product attributes, filling your store with products from various types, payment configuration, maintaining relationships with your customers, and fulfilling orders.
Readers will be able to present and sell products in groups, sets, they can offer discounts based on quantities along with accepting various payments such as PayPal, CC, Checks, Bank transfers, Payment on delivery and many other payment gateways. Along with connecting to shippers such as UPS, FedEx, and USPS they will learn to apply tax rules to different shipping addresses and different types of products.
The publisher kindly provide two chapters from the book, so you can get a clue of the style in it.
If you like the book you can order it from here:
Magento: Beginner’s Guide
€27.89 save 10%
Have you ever wondering how to find MAX, MIN or AVG of a database table column in CakePHP way? Well I haven’t since yesterday. The solution is quite simple and obvious.
Lets say you want to show the average views per post (in the example we have the views field in every post).
The SQL should be something like this:
Instead of using query() function you can use the CakePHP way:
Hope this will help someone.
Today I found quite nice plug-in for Wordpress pretending that it will block at least 90% of the spam attempts. Quite ambitious indeed, but the time will show.
The general idea is that this plug-in adds a stylesheet to your blog’s html source code. When a browser loads that stylesheet a cookie is dropped. If that user then leaves a comment the cookie is checked. If it doesn’t exist the comment is marked as spam.
Installation is just plug-activate-play. Let’s see what will happen.
The plug-in details page: Cookies for Comments
The authors page: Donncha O Caoimh
Last few articles in this blog are only for stupid problems and unfortunately this one will be the same.
I had to use JSON to update some chained select boxes. I am using one jQuery plugin for this. The problem is that if you code, most likely your debug setting in the core.php file is set to 1 (or 2). This way the developer can see errors from CakePHP.
When the level is set to 1, at the end of the page, there is an comment, displaying the processing time for the page, but when you use JSON, this comment causes troubles (probably, because JSON doesn’t accept this type of comments) and the JS fail to process the response.
In order to check JSON, I needed to disable set debug level to 0 and after this to reset it again to 1 (for debugging purposes in other parts of the application).
So, the conclusion: bear in mind, that JSON doesn’t like HTML comments.
Hope this helps.