July 1, 2013

How to write text on existing image using php

The post below describes an easy and quick way to write text over an existing image using PHP. You can use this method to watermark your images and can put it to use in number of other ways.   First […]
May 31, 2013

How to use PDO-MySQL with PHP

PDO is a PHP extension that allows multiple PHP's database connections by creating a single cohesive interface. It allows code portability and compatibility across various platforms. It can be considered as a database access layer providing a uniform method of […]
May 28, 2013

PHP PHAR Package

The phar extension is used to put entire PHP applications into a single file called a "phar" (PHP Archive) for easy distribution and installation. It provides the means for distributing code as a single archive, that does not have to […]
May 27, 2013

How to set timezone at application level and user login level using PHP

To set timezone in php at user level, you have to use the function date_default_timezone_set(). This function is available in version 5 and later of PHP   <?php date_default_timezone_set('America/Los_Angeles'); // To see a list of all supported time zones please […]
May 20, 2013

Customer Review Date Changer for Magento

The customer review date changer extension for Magento is a small, lightweight plugin that allows you to change the date for customer reviews at your Magento store. While importing your store from one CMS like WordPress to Magento, you have […]
May 16, 2013

Magento Admin Fix for CSS and JS Not Loading

After transferring the magento store to new server and database you might find that the magento admin is not loading the CSS and JS files. Because of that, the design would look out of order and the categories pages would […]
May 16, 2013

Alternate Method For Magento Incremental Update

In order to maintain all your tables and data the way it is, you often require to perform an incremental update for magento, doing it otherwise might make some of your data obsolete. Here is a simple step by step […]
May 8, 2013

SALT implementation in YII

A salt is a random data string that is used as an input to hash a password. The salt and the password are concatenated and encrypted with a cryptographic hash function and the output is then stored in the database. […]
April 19, 2013

Uploading Extension to MagentoConnect: Invalid Package Name

While uploading to magento connect, we often receive an error “Invalid Pakage Name- the Package name without ext should be ……..”. We have to take care of few things while packaging and uploading extension to magento connect. Following is the […]
April 12, 2013

Multiple Attachments using PHPMailer Class

  To send an email with multiple attachments using php, we would be using a class PHPMailer. You can download that class from this link: http://phpmailer.worxware.com/index.php?pg=sf&p=dl To add more than one attachments to our email we would be using the […]
April 10, 2013

How to use BB code with PHP

  What is BB code? Bulletin Bar Code or simply BB Code is a lightweight markup language that is used to impose strict formatting rules in discussion boards, forums and occasionally in blogs. Its main objective is to facilitate a […]
April 9, 2013

Nonce Implementation in PHP

What is Nonce? Literally it means a number that can be used only once. Nonce is often a random or pseudo random number that is used in authentication protocols in preventing semantic URL and replay attacks using old communications. Each […]
November 28, 2012

Website Security Measures

I would like to share my personal observations and knowledge relating website security. You can add more by commenting this post. Password Hashing Passwords and other credentials must be stored hashed in Database. Use md5() or sha1() functions. Password Renew […]
November 28, 2012

Verify HTTP URL with PHP

Developers often require verifying the URLs of external sites in various situations like for Affiliate Program, Link Building and many more. We can create a simple function named verifyURL()  which accepts the URL as string parameter and return Boolean if […]
November 18, 2011

Protect Magento Product Images from getting Stolen

It is good that magneto offers watermarking for securing the catalog/product images but this security is not sufficient for advance internet users. Suppose, following is the link for your watermarked image http://www.yourwebsite.com/media/catalog/product/cache/1/image/de684549e4151748e56ee0dd7902c19f/m/y/my-first-image.jpg But if anyone removes the cache/1/image/de684549e4151748e56ee0dd7902c19f part of […]
September 24, 2011

Magento Admin URL Error 404 Fix

After moving Magento site to new server/location we often get "Error: 404 Not Found" while accessing the admin / back-end. The reason of this error is store_id and website_id should be set to "0" (zero). For some reason when you […]
August 14, 2011

Magento Google Checkout 401 Failed to Get Basic Authentication Headers

If you are struggeling to integrate the google checkout with Magento and facing the following error in google checkout console  We encountered an error trying to access your server at https://yourdomain.com/googlecheckout/api -- the error we got is Send failed with […]
June 18, 2011

Enable In-place Editing in Yii Grid

Today someone asked me for help to integrate Jeditable with Yii CGridView. So I thought why not write a little tutorial that can help others as well. In this article I assume that you are comfortable working with Yii; you […]
June 8, 2011

How to create custom validation rule

In the scenarios where validation rules provided by the Yii framework won’t handle your requirements, you can create custom validation rules. One example is the "authenticate" validation rule provided in "LoginForm" model of Yii blog demo. You can create your […]
May 12, 2011

Constructor Overloading in PHP

There is no simple method of overloading constructors in PHP. There are few workarounds to achieve this. I use the following technique. class UserIdentity extends CUserIdentity { public function __construct() { $arg_list = func_get_args(); switch(func_num_args()) { case 1: // calling […]
April 26, 2011

Yii’s default validator Aliases

Below is the complete list of predefined validator aliases: boolean: alias of CBooleanValidator, ensuring the attribute has a value that is either CBooleanValidator::trueValue or CBooleanValidator::falseValue. captcha: alias of CCaptchaValidator, ensuring the attribute is equal to the verification code displayed in […]
April 12, 2011

Specifying nested relations for eager loading

Eager loading can be nested. For example, if for every comment, we also want to know its author, we could use the following ‘with’ find:   // find all posts together with their author and the author's profile Post::model()->with('author','author.profile')->findAll();  
April 12, 2011

Replace text box with drop down list in filter of CGridView

By default, Yii displays a textbox to search (filter) within results/records displayed by CGridView. In order to change those textboxes to drop down list (combo boxes), all you need to do is to assign an array to "filter" property of […]
April 9, 2011

Add conditions in search for relational tables

Let’s discuss example relationship given on following URL http://www.yiiframework.com/doc/guide/1.1/en/database.arr If you want to be able to filter results in grid using Posts’ author name then modify the search function of  Post model to similar to the one given below.
April 6, 2011

Change CGridView CSS file for entire application

To use your custom css file globally, set the cssfile property in config file   'components'=>array( 'widgetFactory'=>array( 'widgets' => array ( 'cssFile' => '/css/style-gridview.css', ) ), );  
April 3, 2011

Accessing modules method in Yii

Yii::app()->getModule('user')->encrypting($this->password)  or Yii::app()->controller->module->encrypting($this->password)  
April 3, 2011

Check for Ajax’ed request in Yii

if( Yii::app()->request->isAjaxRequest) {     // do some thing…. }
April 3, 2011

Session Handling in Yii

Yii::app()->session->add(‘product’, $productId); Yii::app()->session->get(‘product’); Yii::app()->session->remove(‘product’);
April 3, 2011

Send & retrieve cookies in Yii

To retrieve a cookie with the specified name: $cookie=Yii::app()->request->cookies[$name]; $value=$cookie->value;   To send a cookie:  $cookie=new CHttpCookie($name,$value); Yii::app()->request->cookies[$name]=$cookie;
April 3, 2011

Get & Set current language in Yii

To get current language:  $lang = Yii::app()->language;   To set current language: Yii::app()->language = ‘en’;
April 3, 2011

Get current Controller & action in Yii

 In view file  $this->uniqueid        (controller name) $this->action->Id      (action name) ($this is CController instance) In other files Yii::app()->controller->id  Yii::app()->controller->action->id
April 3, 2011

Get Id of an active form element in Yii

March 25, 2011

CAutocomplete to display one value and submit another

  Source: http://www.yiiframework.com/wiki/25/using-cautocomplete-to-display-one-value-and-submit-another/ Don’t forget to use the attached Javascript and CSS files. This code does not work with jQuery UI auto complete. Javascript File CSS File
October 26, 2010

Correct way to access components in your modules

You can also configure modules’ components in the main config file   'modules'=>array( 'my'=>array( 'components'=>array( 'foo'=>array( 'class'=>'FooComponent', 'a'=>'hello', ), ), ), ),  
October 10, 2010

How to customize the error message of a validation rule

The following validation rule uses an error message that is different from the default one class Post extends CActiveRecord { public function rules() { return array( array('title, content', 'required', 'message'=>'Please enter a value for {attribute}.'), // ... other rules ); […]
October 9, 2010

DropDown for pageSize in CGridView

A convenient drop down to select page size and save in User state. Step 1: On top of my controller action for the gridview (if you used CRUD, this is actionAdmin() ) i added: // page size drop down changed if […]
October 8, 2010

Steps required to change project to production mode

Step 1: In config/main.php, add following element to "components" array 'cache'=>array( 'class'=>'system.caching.CApcCache', ),   Step2: In config/main.php, add following element to " components[‘db’] " array 'schemaCachingDuration' => 3600   Step 3: Comment out the following line of index.php defined('YII_DEBUG') or […]
October 6, 2010

Upload and resize image using YII

Download and extract this file in protected/extensions directory.   In config/main.php file, add the following element to components array  'image'=>array( 'class'=>'application.extensions.image.CImageComponent', 'driver'=>'GD', )   Now in action, insert the following code and modify paths $model->Picture = CUploadedFile::getInstance($model,'Picture'); if( is_object($model->Picture) ) […]
October 4, 2010

Automated display of flash messages

Step 1. Put this method into your WebUser class: public function getFlashKeys ( ) { $counters=$this->getState(self::FLASH_COUNTERS); if(empty($counters)) return array(); return array_keys($counters); }  
October 4, 2010

How to change content of a cell in Grid View to a link

If you want to link content of cell in Grid View to some page e.g In orders list, if you want customer’s name to be link that takes admin to customer’s detail page, change the columns of CGrid View as […]
October 4, 2010

Ajax button in CGridView

To add an ajax button to CGridView modify the buttons column  as   'columns' => array( 'id', 'name', array( 'class'=>'CButtonColumn', 'template' => '{view} {update} {delete}', 'buttons'=>array( 'view' => array( 'url'=>'"index.php?r=admin/view&id=".$data->user_id."&m=users"', 'click' => "function (){ $('#viewTab').load($(this).attr('href'));return false; }" ) ), ), […]
September 27, 2010

Exception with Twitter Library "twitter-async" when hosted on Media Temple

Issue: Twitter Library developed by "Jaisen Mathai" throws an exception when uploaded on Media Temple Servers. EpiOAuthException::raise(Object(EpiCurlManager), false) #1 /nfs/c07/h03/mnt/12345/domains/abcde.com/html/protected/components/twitter/EpiOAuth.php(367): EpiOAuthResponse->__get('_resp')  
September 22, 2010

Working with flash messages in Yii

If you would like to inform the user, that his changes were successfully saved, you could add the following line to your Controller: Yii::app()->user->setFlash('success',"Data saved!");   Displaying the flash message in a view is done by if( Yii::app()->user->hasFlash('success') ) { […]
September 21, 2010

Installing Zend 5 on Windows 7

Here’s how I installed it, taken from zend forums (http://www.zend.com/forums/index.php?t=msg&th=7855). This worked for me in Windows 7. Modify the paths below as needed for your installation of Windows 7. Download and install the latest JRE for Windows: http://java.com/en/download/manual.jsp Download and […]
Installing Zend 5 on Windows 7
This website uses cookies to provide necessary website functionality, improve your experience and analyze our traffic. By using our website, you agree to our Privacy Policy and our cookies usage.