Sunday, November 7, 2010

Last Insert Id of Embedded Form in Symfony

To get the last inserted id of an embedded form in symfony is pretty easy. But for that I had to search the internet whole day. So, I think I must share my experience with other people so, they can also know the ways to do that.

We know the code to embed form. It is simple.
$this->embedForm('billing', $billingform);
$this->embedRelation('CustomerToBill');    
Then when you are saving it, suppose, now you want to have the id of the embed form to use the value in another table with the same request.

Then you need to add the following in the form.
public function saveEmbeddedForms($con = null, $forms = null)
{
if (null === $con)
{
$con = $this->getConnection();
}

if (null === $forms)
{
$forms = $this->embeddedForms;
}

foreach ($forms as $form)
{
if ($form instanceof sfFormObject)
{
$form->saveEmbeddedForms($con);
$form->getObject()->save($con);
print_r($form->getObject()->getId());die();
}
else
{
$this->saveEmbeddedForms($con, $form->getEmbeddedForms());
}
}
}

To get the last insert id of the embed form I use
$form->getObject()->getId();
Thant's it.


See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Saturday, July 24, 2010

Documentation of Boxy tab

We will going to see a css only boxy tab. I use only css to create this tab. See the image of boxy tab:

Boxy tab

The blue color will available for the hover tab.

First let's see the html structure for this tab.


And we applied the following css for our tab:

ul#nav {
    position: relative;    
    float: left;
    width: 99%;
    height: 150px;
    border-bottom: 1px solid #d9d9d9;
    border-top: 1px solid #d9d9d9;
    border-left: 1px solid #d9d9d9;    
}

ul#nav li {
    float: left;
    list-style: none;
    border-bottom: 7px solid #a9a9a9;
    border-left: 1px solid #a9a9a9;
    border-right: 1px solid #a9a9a9;
    border-top: 2px solid #a9a9a9;
    width: 156px;
    height: 140px;
    background-color: #fcfcfc;
}

ul#nav li:hover {
    border-bottom: 7px solid #0066cc;
    background-color: #f9f9f9;
}


ul#nav li a {
    color: #a9a9a9;
    position: relative;
    z-index: 2;
    float: left;
    font-size: 15px;
    text-decoration: none;
    padding: 35px 15px;
    font-weight: normal;
    letter-spacing: 1px;
    word-spacing: 5px;
    width: 140px;
    height: 140px;
}

ul#nav li a:hover {
    color: #0066cc;
}

ul#nav #selected {
    border-bottom: 7px solid #0066cc;
}

ul#nav #selected a {
    color: #0066cc;
}

You can download the code from here


See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Download Boxy tab

We have seen the documentation of Boxy tab. You can download boxy tab from here.

Thanks for interest. Stay with us for more tahSin's gaRAge products.

See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Thursday, July 22, 2010

Documentation of My Form validation of codeigniter

We have seen the weakness of Form validation class for codeigniter. Let's see how we can fix this short comings. I have an extended Form validation class of codeigniter. we will discuss it here:

First of all, we are going to combine our $_FILES and $_POST variables together. we use php's array_merge to merge them.

/**
     * Constructor
     *
     * @author Tahsin Hasan 
     * @return void
     * @access public
     */
    public function __construct() {
        $_POST = (count($_FILES) > 0) ? array_merge($_POST,$_FILES) : $_POST;
        parent::__construct();
    }

After merging them together, we call our parent constructor function.
/**
     * Allowed types rule
     *
     * @author Tahsin Hasan 
     * @return bool
     * @param  str String field name to validate
     * @param  types String allowed types
     * @access public
     */
    public function allowed_types($str, $types)
    {
        $type = explode(',', $types);
        $filetype = pathinfo($str['name'],PATHINFO_EXTENSION);
        return (in_array($filetype, $type)) ? TRUE : FALSE;
    }

We are using two new rules for upload functions: allowed_types and max_file_size. In the allowed_types function we can set a range of allowed file types for our uploaded file.

/**
     * Setting maximum file upload size
     *
     * @author Tahsin Hasan 
     * @return bool
     * @param  str String field name to validate
     * @param  size Integer maximum upload size in bytes
     * @access public
     */

    public function max_file_size($str, $size)
    {
        return ($str['size']<=$size) ? TRUE : FALSE;
    }
In the max_file_size rule we checking the uploaded file whether it is uploaded in the specified file upload size.
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Weakness of codeigniter Form Validation

Codeigniter Form Validation is a very popular validation library. we use this library quite extensively. But it has some short comings. we will discuss the shortcomings here.

the Form Validation library only validates $_POST fields. so, if we have a upload image in our form, this validation library always shows that the uploaded field is empty.

we set the validation rule for our upload field as follows:

$val->set_rules('userfile', 'Profile Picture', 'required');

This is because our uploaded file resides in the $_FILES variable, not in the $_POST field. So, we need to make some way to validate our $_FILES variable.

See my extended Form Validation library for codeigniter. This weakness has been overcome.

Other Links:

Documentation of Codeigniter Extend MY Form Validation Library.

See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

How to use MY extended Codeigniter Form Validation Library

We have seen the documentation of Codeigniter Form Validation library. now we will see how we will use it in our coding.

First, we need to download our library. Then we need to place it under the Application-> library folder.

As it is an extended version of Form Validation, so, we can have it by loading our form validation library.

$this->load->library('Form_validation');

Now we will set rule for our upload field like this:

$this-form_validation->set_rules('userfile', 'Profile Picture', 'required|allowed_types[jpg,png,jpeg]|max_file_size[10]');

By allowed_types[jpg]
Here by allowed_types[jpg,png,jpeg] we mean our allowed types are jpg, png and jpeg. And with max_file_size we set the maximum bytes that is allowed to upload.

$this-form_validation->set_message('allowed_types','Please upload jpg, jpeg and png types');

With this we can set custom messages for our rules.

Other Links:

Documentation of Codeigniter Extend MY Form Validation Library.

Weakness of Codeigniter Form Validation Library
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Download MY Form Validation Library for Codeigniter

We have seen the codeigniter Form Validation library weaknesses and also shown how we can solve that problem with the extend My Form Validation library.

We can download the Extended Form Validation library from here.

Thanks for download the Extended Form Validation library.


See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Saturday, July 17, 2010

curl + cookie + redirect = nightmare

Sometime we use curl to store cookies in the remote server. and do our workings accordingly. Curl comes up with two options to deal with cookie settings remotely. They are the followings:

  • COOKIEJAR: it sets the cookie variables in the local machine and stores it in a file. we store it for later use. This file is written in netscap cookie file format. the values are delimited with a tab. A cookie is stored on a single line.
  • COOKIEFILE: This variable sends the cookie file to the remote server.

see the following code block. it explains the above discussion.

//create cURL connection
        $curl_connection = curl_init('remote_server_url');

        //set options
        curl_setopt($curl_connection, CURLOPT_POST, TRUE);
        curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, false);        
        curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);        
        //set data to be posted        
        curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
        curl_setopt($curl_connection, CURLOPT_COOKIEJAR, 'cookies.txt');
        curl_setopt($curl_connection, CURLOPT_COOKIEFILE, 'cookies.txt');

Here we send the cookie with the last two lines.

Now if we redirect our header in the remote server, then there will be a problem. your server then could not find the cookie file. and you will be signed out or related problem will be arose.

To solve this problem, you need to set your cookie after redirect call is made. So, you need to set cookie like this after a redirection is made.

setcookie('asite', $site, time()+60*60, '/', 'site.com'); 


See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Size of a request header field exceeds server limit.

I have come up a strange error. It shows me a bad server request and shows Size of a request header field exceeds server limit. So, it is a unusual problem. And I found that my server is requesting with another server with a corrupted cookie file. I am sharing with you the cookie file so you can understand the situation.

see the cookie:

Cookie: bbthreadview=a%3A70%3A%7Bi%3A18969%3Bi%3A103728909 5%3Bi%3A19045%3Bi%3A1037288969%3Bi%3A19048%3Bi%3A1 037251417%3Bi%3A19007%3Bi%3A1037265534%3Bi%3A15623 %3Bi%3A1037265450%3Bi%3A19044%3Bi%3A1037289051%3Bi %3A19056%3Bi%3A1037265739%3Bi%3A18908%3Bi%3A103731 8594%3Bi%3A19051%3Bi%3A1037266071%3Bi%3A14527%3Bi% 3A1037266336%3Bi%3A19055%3Bi%3A1037289037%3Bi%3A19 059%3Bi%3A1037295501%3Bi%3A19063%3Bi%3A1037295544% 3Bi%3A18848%3Bi%3A1037468521%3Bi%3A18876%3Bi%3A103 7295631%3Bi%3A18825%3Bi%3A1037295645%3Bi%3A19050%3 Bi%3A1037318211%3Bi%3A19067%3Bi%3A1037318506%3Bi%3 A19089%3Bi%3A1037318521%3Bi%3A19083%3Bi%3A10373185 24%3Bi%3A19086%3Bi%3A1037318545%3Bi%3A19049%3Bi%3A 1037326825%3Bi%3A18763%3Bi%3A1037326941%3Bi%3A1911 7%3Bi%3A1037370172%3Bi%3A19097%3Bi%3A1037370207%3B i%3A19119%3Bi%3A1037372349%3Bi%3A19104%3Bi%3A10374 02713%3Bi%3A19120%3Bi%3A1037374210%3Bi%3A19112%3Bi %3A1037374223%3Bi%3A19082%3Bi%3A1037374259%3Bi%3A1 9126%3Bi%3A1037377619%3Bi%3A19122%3Bi%3A1037377727 %3Bi%3A19133%3Bi%3A1037396564%3Bi%3A19145%3Bi%3A10 37396573%3Bi%3A19137%3Bi%3A1037396582%3Bi%3A17962% 3Bi%3A1037403501%3Bi%3A19147%3Bi%3A1037421857%3Bi% 3A19167%3Bi%3A1037486584%3Bi%3A19158%3Bi%3A1037487 034%3Bi%3A19164%3Bi%3A1037463102%3Bi%3A19021%3Bi%3 A1037464672%3Bi%3A19171%3Bi%3A1037464675%3Bi%3A191 77%3Bi%3A1037464740%3Bi%3A19170%3Bi%3A1037465207%3 Bi%3A19173%3Bi%3A1037479613%3Bi%3A19046%3Bi%3A1037 465984%3Bi%3A19105%3Bi%3A1037467344%3Bi%3A18672%3B i%3A1037467351%3Bi%3A19084%3Bi%3A1037467425%3Bi%3A 18576%3Bi%3A1037467487%3Bi%3A19038%3Bi%3A103746750 0%3Bi%3A18151%3Bi%3A1037467626%3Bi%3A19068%3Bi%3A1 037467661%3Bi%3A18367%3Bi%3A1037467689%3Bi%3A13042 %3Bi%3A1037467713%3Bi%3A16935%3Bi%3A1037467720%3Bi %3A19134%3Bi%3A1037468536%3Bi%3A19168%3Bi%3A103747 9552%3Bi%3A19184%3Bi%3A1037479564%3Bi%3A19116%3Bi% 3A1037480034%3Bi%3A17520%3Bi%3A1037484175%3Bi%3A19 192%3Bi%3A1037485540%3Bi%3A19190%3Bi%3A1037485306% 3Bi%3A19180%3Bi%3A1037485554%3Bi%3A19100%3Bi%3A103 7485629%3Bi%3A19196%3Bi%3A1037485666%3Bi%3A18554%3 Bi%3A1037486195%3Bi%3A19197%3Bi%3A1037486564%3Bi%3 A19132%3Bi%3A1037486640%3Bi%3A19210%; bbthreadview=a%3A70%3A%7Bi%3A18969%3Bi%3A103728909 5%3Bi%3A19045%3Bi%3A1037288969%3Bi%3A19048%3Bi%3A1 037251417%3Bi%3A19007%3Bi%3A1037265534%3Bi%3A15623 %3Bi%3A1037265450%3Bi%3A19044%3Bi%3A1037289051%3Bi %3A19056%3Bi%3A1037265739%3Bi%3A18908%3Bi%3A103731 8594%3Bi%3A19051%3Bi%3A1037266071%3Bi%3A14527%3Bi% 3A1037266336%3Bi%3A19055%3Bi%3A1037289037%3Bi%3A19 059%3Bi%3A1037295501%3Bi%3A19063%3Bi%3A1037295544% 3Bi%3A18848%3Bi%3A1037468521%3Bi%3A18876%3Bi%3A103 7295631%3Bi%3A18825%3Bi%3A1037295645%3Bi%3A19050%3 Bi%3A1037318211%3Bi%3A19067%3Bi%3A1037318506%3Bi%3 A19089%3Bi%3A1037318521%3Bi%3A19083%3Bi%3A10373185 24%3Bi%3A19086%3Bi%3A1037318545%3Bi%3A19049%3Bi%3A 1037326825%3Bi%3A18763%3Bi%3A1037326941%3Bi%3A1911 7%3Bi%3A1037370172%3Bi%3A19097%3Bi%3A1037370207%3B i%3A19119%3Bi%3A1037372349%3Bi%3A19104%3Bi%3A10374 02713%3Bi%3A19120%3Bi%3A1037374210%3Bi%3A19112%3Bi %3A1037374223%3Bi%3A19082%3Bi%3A1037374259%3Bi%3A1 9126%3Bi%3A1037377619%3Bi%3A19122%3Bi%3A1037377727 %3Bi%3A19133%3Bi%3A1037396564%3Bi%3A19145%3Bi%3A10 37396573%3Bi%3A19137%3Bi%3A1037396582%3Bi%3A17962% 3Bi%3A1037403501%3Bi%3A19147%3Bi%3A1037421857%3Bi% 3A19167%3Bi%3A1037486584%3Bi%3A19158%3Bi%3A1037487 034%3Bi%3A19164%3Bi%3A1037463102%3Bi%3A19021%3Bi%3 A1037464672%3Bi%3A19171%3Bi%3A1037464675%3Bi%3A191 77%3Bi%3A1037464740%3Bi%3A19170%3Bi%3A1037465207%3 Bi%3A19173%3Bi%3A1037479613%3Bi%3A19046%3Bi%3A1037 465984%3Bi%3A19105%3Bi%3A1037467344%3Bi%3A18672%3B i%3A1037467351%3Bi%3A19084%3Bi%3A1037467425%3Bi%3A 18576%3Bi%3A1037467487%3Bi%3A19038%3Bi%3A103746750 0%3Bi%3A18151%3Bi%3A1037467626%3Bi%3A19068%3Bi%3A1 037467661%3Bi%3A18367%3Bi%3A1037467689%3Bi%3A13042 %3Bi%3A1037467713%3Bi%3A16935%3Bi%3A1037467720%3Bi %3A19134%3Bi%3A1037468536%3Bi%3A19168%3Bi%3A103747 9552%3Bi%3A19184%3Bi%3A1037479564%3Bi%3A19116%3Bi% 3A1037480034%3Bi%3A17520%3Bi%3A1037484175%3Bi%3A19 192%3Bi%3A1037485540%3Bi%3A19190%3Bi%3A1037485306% 3Bi%3A19180%3Bi%3A1037485554%3Bi%3A19100%3Bi%3A103 7485629%3Bi%3A19196%3Bi%3A1037485666%3Bi%3A18554%3 Bi%3A1037486195%3Bi%3A19197%3Bi%3A1037486564%3Bi%3 A19132%3Bi%3A1037486640%3Bi%3A19208%; sessionhash=926269e87ab7c226dbe40079adbafb1e; bbthreadview=a%3A68%3A%7Bi%3A18969%3Bi%3A103728909 5%3Bi%3A19045%3Bi%3A1037288969%3Bi%3A19048%3Bi%3A1 037251417%3Bi%3A19007%3Bi%3A1037265534%3Bi%3A15623 %3Bi%3A1037265450%3Bi%3A19044%3Bi%3A1037289051%3Bi %3A19056%3Bi%3A1037265739%3Bi%3A18908%3Bi%3A103731 8594%3Bi%3A19051%3Bi%3A1037266071%3Bi%3A14527%3Bi% 3A1037266336%3Bi%3A19055%3Bi%3A1037289037%3Bi%3A19 059%3Bi%3A1037295501%3Bi%3A19063%3Bi%3A1037295544% 3Bi%3A18848%3Bi%3A1037468521%3Bi%3A18876%3Bi%3A103 7295631%3Bi%3A18825%3Bi%3A1037295645%3Bi%3A19050%3 Bi%3A1037318211%3Bi%3A19067%3Bi%3A1037318506%3Bi%3 A19089%3Bi%3A1037318521%3Bi%3A19083%3Bi%3A10373185 24%3Bi%3A19086%3Bi%3A1037318545%3Bi%3A19049%3Bi%3A 1037326825%3Bi%3A18763%3Bi%3A1037326941%3Bi%3A1911 7%3Bi%3A1037370172%3Bi%3A19097%3Bi%3A1037370207%3B i%3A19119%3Bi%3A1037372349%3Bi%3A19104%3Bi%3A10374 02713%3Bi%3A19120%3Bi%3A1037374210%3Bi%3A19112%3Bi %3A1037374223%3Bi%3A19082%3Bi%3A1037374259%3Bi%3A1 9126%3Bi%3A1037377619%3Bi%3A19122%3Bi%3A1037377727 %3Bi%3A19133%3Bi%3A1037396564%3Bi%3A19145%3Bi%3A10 37396573%3Bi%3A19137%3Bi%3A1037396582%3Bi%3A17962% 3Bi%3A1037403501%3Bi%3A19147%3Bi%3A1037421857%3Bi% 3A19167%3Bi%3A1037486584%3Bi%3A19158%3Bi%3A1037463 043%3Bi%3A19164%3Bi%3A1037463102%3Bi%3A19021%3Bi%3 A1037464672%3Bi%3A19171%3Bi%3A1037464675%3Bi%3A191 77%3Bi%3A1037464740%3Bi%3A19170%3Bi%3A1037465207%3 Bi%3A19173%3Bi%3A1037479613%3Bi%3A19046%3Bi%3A1037 465984%3Bi%3A19105%3Bi%3A1037467344%3Bi%3A18672%3B i%3A1037467351%3Bi%3A19084%3Bi%3A1037467425%3Bi%3A 18576%3Bi%3A1037467487%3Bi%3A19038%3Bi%3A103746750 0%3Bi%3A18151%3Bi%3A1037467626%3Bi%3A19068%3Bi%3A1 037467661%3Bi%3A18367%3Bi%3A1037467689%3Bi%3A13042 %3Bi%3A1037467713%3Bi%3A16935%3Bi%3A1037467720%3Bi %3A19134%3Bi%3A1037468536%3Bi%3A19168%3Bi%3A103747 9552%3Bi%3A19184%3Bi%3A1037479564%3Bi%3A19116%3Bi% 3A1037480034%3Bi%3A17520%3Bi%3A1037484175%3Bi%3A19 192%3Bi%3A1037485540%3Bi%3A19190%3Bi%3A1037485306% 3Bi%3A19180%3Bi%3A1037485554%3Bi%3A19100%3Bi%3A103 7485629%3Bi%3A19196%3Bi%3A1037485666%3Bi%3A18554%3 Bi%3A1037486195%3Bi%3A19197%3Bi%3A1037486564%3B%7D ; bbadminon=1; bblastvisit=1035563932; vbcodemode=1; i=7:8:1:1036068408:1|4:5:1:1035751419:1|6:7:1:1035 751394:1|||||||||||||||||||||||||||||||||; bbuserid=1; bbpassword=feedd820a172677f3211aefc8f7a2885; PHPSESSID=00534cd1247c4336f21e1fce60acf422; ADCYCLE_LOGIN=admin|5790622|; i1=7:8:453:1035755985:152|5:6:621:1035670005:152|4 :5:621:1035669976:152|6:7:620:1035670121:152|||||| ||||||||||||||||||||||||||; c1=5:6:1:1036141033:152||||||||||||||||||||; phpAds_banner[af62734b]=a%3A2%3A%7Bs%3A8%3A%22bannerid%22%3Bs%3A1%3A%223% 22%3Bs%3A4%3A%22dest%22%3Bs%3A60%3A%22http%3A%2F%2 Fplurplanet.com%2Fforum%2Fshowthread.php%3Fs%3D%26 threadid%3D17706%22%3B%7D; bbthreadview=a%3A69%3A%7Bi%3A18969%3Bi%3A103728909 5%3Bi%3A19045%3Bi%3A1037288969%3Bi%3A19048%3Bi%3A1 037251417%3Bi%3A19007%3Bi%3A1037265534%3Bi%3A15623 %3Bi%3A1037265450%3Bi%3A19044%3Bi%3A1037289051%3Bi %3A19056%3Bi%3A1037265739%3Bi%3A18908%3Bi%3A103731 8594%3Bi%3A19051%3Bi%3A1037266071%3Bi%3A14527%3Bi% 3A1037266336%3Bi%3A19055%3Bi%3A1037289037%3Bi%3A19 059%3Bi%3A1037295501%3Bi%3A19063%3Bi%3A1037295544% 3Bi%3A18848%3Bi%3A1037468521%3Bi%3A18876%3Bi%3A103 7295631%3Bi%3A18825%3Bi%3A1037295645%3Bi%3A19050%3 Bi%3A1037318211%3Bi%3A19067%3Bi%3A1037318506%3Bi%3 A19089%3Bi%3A1037318521%3Bi%3A19083%3Bi%3A10373185 24%3Bi%3A19086%3Bi%3A1037318545%3Bi%3A19049%3Bi%3A 1037326825%3Bi%3A18763%3Bi%3A1037326941%3Bi%3A1911 7%3Bi%3A1037370172%3Bi%3A19097%3Bi%3A1037370207%3B i%3A19119%3Bi%3A1037372349%3Bi%3A19104%3Bi%3A10374 02713%3Bi%3A19120%3Bi%3A1037374210%3Bi%3A19112%3Bi %3A1037374223%3Bi%3A19082%3Bi%3A1037374259%3Bi%3A1 9126%3Bi%3A1037377619%3Bi%3A19122%3Bi%3A1037377727 %3Bi%3A19133%3Bi%3A1037396564%3Bi%3A19145%3Bi%3A10 37396573%3Bi%3A19137%3Bi%3A1037396582%3Bi%3A17962% 3Bi%3A1037403501%3Bi%3A19147%3Bi%3A1037421857%3Bi% 3A19167%3Bi%3A1037486584%3Bi%3A19158%3Bi%3A1037487 034%3Bi%3A19164%3Bi%3A1037463102%3Bi%3A19021%3Bi%3 A1037464672%3Bi%3A19171%3Bi%3A1037464675%3Bi%3A191 77%3Bi%3A1037464740%3Bi%3A19170%3Bi%3A1037465207%3 Bi%3A19173%3Bi%3A1037479613%3Bi%3A19046%3Bi%3A1037 465984%3Bi%3A19105%3Bi%3A1037467344%3Bi%3A18672%3B i%3A1037467


This is a corrupted cookie file. Apache has a header size limit of

# allow up to 100 headers in a request
  LimitRequestFields 100
  # each header may be up to 8190 bytes long
  LimitRequestFieldsize 8190

Again, IIS 7 has a size of 16K and IIS 6 has 8K length of header size.

So, we need to manually delete this cookie file. As cookies are browser specific, you need to check our browser how to delete those. I was using firefox and the solution is to go to tools->clear private data.


See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Friday, July 16, 2010

Download My Input Library for Codeigniter

We seen the drawbacks of Input library of codeigniter and my extended input library comes to solve this problem. I have already mentioned how my library overcome the problem. so, let's get the extended codeigniter Input library.

Use this link to download it.

After downloading,


  • Just put the class file under the libraries folder under application folder.

See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

syntax error near unexpected token `('

We, the linux users sometime face this problem. when we want to open a file with terminal or doing some work like svn commits or deletion we need to do deal with files. if a file contains invalid character's, then we will come up with this erros.

syntax error near unexpected token `('

if we have a file named 'name (copy).html', then doing the following command will produce the above error:

vim name (copy).html

Here we need to escape the unwanted characters with '\'. So, we need to modify our code the following.

vim name\ \(copy\).html

Now our command will work like a charm!
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Documentation of Codeigniter My Input Library

Codeigniter Input Library comes up with many great security features. But it still lacks some of the security concerns. We have discussed those in our blog earlier. So, I have created an extended input library to minimize those security holes.

I have extend the xss_clean method of input class. and added some advanced level of security fixes. We have replaced the following code for naughty words in the xss_clean method.


/*
  * Sanitize naughty HTML elements
  *
  * If a tag containing any of the words in the list
  * below is found, the tag gets converted to entities.
  *
  * Becomes: <blink>
  *
        */
        $naughty = '\w*';
        $str = preg_replace_callback('#<(\w*/*\s*)('.$naughty.')([^><]*)([><]*)#is', array($this, '_sanitize_naughty_html'), $str);
instead of
/*
  * Sanitize naughty HTML elements
  *
  * If a tag containing any of the words in the list
  * below is found, the tag gets converted to entities.
  *
  * Becomes: <blink>
  *
  */
  $naughty = 'alert|applet|audio|basefont|base|behavior|bgsound|blink|body|embed|expression|form|frameset|frame|head|html|ilayer|iframe|input|isindex|layer|link|meta|object|plaintext|style|script|textarea|title|video|xml|xss';
  $str = preg_replace_callback('#<(/*\s*)('.$naughty.')([^><]*)([><]*)#is', array($this, '_sanitize_naughty_html'), $str);

Here In the input library we have defined many HTML keywords which will be treated as naughty keywords. But there are many more keywords which will do massive damage to our site. Like, the header tags 'h1', as we mentioned about the probable attack of it in our blog post earlier. So, I have treated every html words as naughty and convert them. In this regard, we use regular expression to check for any word character and it can occur any number of time.
\w*
See also: Download Codeigniter My input library from here.
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Weakness of Codeigniter Input Library

Codeigniter Input Library has minimized many security holes. But still there are some leaks in it. The input library has defined some html keywords as naughty entries. But these naughty keywords are not all to be aware of.

There are still many keywords which have significant threat for a website. So, we must need to take care of those malwords. Let's discuss some of them.

the header tags 'h1', h2, h3, h4, h5, h6 can have a significant impact, if we use it with the input library. if we use only the starting tag and never end those tags, then our page layout will be broken. Use the following with h1 tag at the beginning and you will see the result in the browser.

it is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the ye

Again if we use b, strong keywords the same will be the case.

See how to solve it here.
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Wednesday, July 14, 2010

Codeigniter Advanced Layout Library

We have several layout library in the wiki of codeigniter. But those has only one replacement block. Advanced codeigniter library solves this problem. You can find the features of advanced layout library here here. Let's discuss about Advanced Layout library for codeigniter.

we will see every code block of the library and discuss them seperately. At first we have defined our necessary variables.

#ci instance
    public $ci;
    #layout variable
    public $layout;

In the constructor function we have created an instance of codeigniter. the argument of the function gets the filename of our main codeigniter library.

/**
     * Constructor
     *
     * @author Tahsin Hasan 
     * @return void
     * @param  layout String layout file name
     * @access public
     */
    public function __construct($layout = "layout_main") {
        $this->ci =& get_instance();
        $this->layout = $layout;        
    }
Let's see the code block of the function that handles the block replacement of our layout. we are passing here three arguments: blocks array contains key-value relationship of block and their corresponding replacement code chunk. view is the filename of the main body content area.
/**
     * shows our blocks in the layout section
     *
     * @author Tahsin Hasan 
     * @return void
     * @param  blocks Array blocks to replace
     * @param  view String code to replace with
     * @param  data Array the data we need to pass
     * @access public
     */
    public function view($blocks, $view, $data)
    {   
        $layout       = $this->layout;
        $data['content_for_layout'] = $this->ci->load->view($view, $data, true);
        
        $view = $this->ci->load->view($layout, $data, true);
        foreach($blocks as $key=>$val)
        {
           if(empty($val))
           {
               $replaces[$key] = '';
           }
           else
           {
               $replaces[$key] = $this->ci->load->view ( $val, NULL, TRUE );
           }            
        }
        $view = str_replace(array_keys($replaces), array_values($replaces), $view);
        
        $this->ci->load->view ( 'view', array ('view' => $view) );
    }

The content_for_layout variable contains the main body section of a page. We replace this string value with our page specific content. with this page specific content, we then replace the layout with our values and store it in the view file.

Download Advanced Layout library from here.
The block variable contains the other replacements except the main content. we replace each varible with the foreach loop.

the str_replace function done the tricks here. it replaces the keys with the values of the view variable. And finally, we load the view file.

Download Advanced Layout library from here.


See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Features of Advanced Layout library of Codeigniter

We have seen the documentation of Advanced Layout Library of Codeigniter. But before using it, we must know what features it brings to us. Let's see them:

  • Other layout library give us the opportunity to make one single block replacement for our layout. But in Advanced Layout library, we can have as many blocks as we wish to have. We just have to define the block and a variable to represent it. Advanced Layout library will take care of the rest. it's simple.
  • We can even have multiple blocks in our main content block. we have shown how to use multiple blocks in layout and also in the main content block. So, we will have more control of your layout using Advanced Layout library for codeigniter.

Download Advanced Layout library from here.


See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

How to use Advanced layout library

We have seen the documentation. Now let's see how we can use the library. At first we need to load Advanced Layout Library for codeigniter.

$this->load->library('advancedLayout');

Now we will set our main layout file in it:

$this->advancedlayout->setLayout('path_to_layoutfile');

We have put our main layout file in the view file. The file is like this:


html xmlns="http://www.w3.org/1999/xhtml"
    head
//        stylesheets link will be here.
        
    /head
    body
        {HEADER_LAYOUT}
        
        
{FLASH_MSG_CONT}
{FOOTER_LAYOUT} /body /html

Here, you can see we have set some variable which will be replaced with our layout values. We can have here as many replacement block as we like. we have set header, top navigation, flash message, body and footer. Not necessary that we also need to implement all those blocks. just use as you like the blocks to be.

In the controller, from which the page is called, we need to replace our layout variables there. the following code does the trick:

$this->advancedlayout->view(array ('{HEADER_LAYOUT}' => 'common/header','{TOP_LAYOUT}'=>'', '{FLASH_MSG_CONT}' => 'common/flash_msg_cont', '{FOOTER_LAYOUT}' => 'common/footer' ),$viewName, $this->_data);

Here, you can see that each variables is set as key and there is a corresponding files in he view file. so, we just write the location of the specific view file. then the variable is replaced with our code.

we set multiple blocks even the main content block. just check the following code block.

echo $admin_right_column;

we are echoing a variable, this can be any variable that we set in the controller. now we need to write the following the controller:

$this->_data['admin_right_column'] = $this->load->view('common/admin_right',$this->_data, TRUE);

Here, the variable contains the content of the admin right column.

And finally, you need to have a view file named 'view' in our main view folder. the file will be like this:

echo $view;

Download Advanced Layout library from here.
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Download Advanced Layout Library for Codeigniter

We have discussed the features, documentation and user guide for Advanced Layout Library for Codeigniter. now Just download it from here. After downloading it:

  • Take the library and drop it under the library folder of Application folder.



See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Saturday, July 10, 2010

Technorati posting started

Every one tahSin's gaRAge is starting posting blog in technorati, code is SZ4QFYS9VB42.

See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Wednesday, July 7, 2010

tweetsigniter Documentation

Let's see step by step explanation of our tweetsigniter class, a twitter codeigniter library. Initially, we have declared all our necessary global variables, like username, password, path, template, timezone etc.

# username field
    public $username;
    # password field
    public $password;
    # maximum no. of values
    public $maxItems;
    # path value
    public $path;
    # timezone value
    public $timezone;
    public $configs = array();
    # template file name
    public $template;

Next comes the constructor method. it defines our template variable. we will replace the template values.

public function  __construct()
    {
        $this->template = "
  • {text}
  • "; }

    we set the necessary values with this method like username, password, maxItem shows the maximum no. of items to be displayed, and timezone will be your timezone.

    public function setInfo($username, $password, $maxItems = '5', $timezone = '+6')
        {
            $this->username = $username;
            $this->password = $password;
            $this->timezone = $timezone;
            $this->maxItems = $maxItems;
            $this->config();
        }
    
    

    We set necessary configuraion Information with these function.
    public function config()
        {
            $this->configs['template'] = $this->template;
            $this->configs['maxitems'] = $this->maxItems;
        }
    
    
    The following function shows all your tweets. you can apply css style within the html elements. the cut and resume functions process tweeter responses.

    public function easyfeeder()
        {
            $content=$this->twitterXml('http://twitter.com/statuses/user_timeline.xml');
            $items=explode("",$content);
            array_shift($items);
    
            $retstr="

    Latest News

      "; foreach($items as $cnt=>$item) { if($this->configs['maxitems']>0 and $cnt+1>$this->configs['maxitems']) break; $created_at=$this->cut("","",$item); $text=$this->cut("","",$item); $itemid=$this->cut("","",$item); $screenname=$this->cut("","",$item); $created_day = substr($created_at, 0, 3); $created_monthday = substr($created_at, 4, 6); $created_timehour = substr($created_at, 11, 2); $created_timehour = $created_timehour + $this->timezone; $created_timeminutes = substr($created_at, 14, 2); $created_year = substr($created_at, 26, 4); if ($created_timehour == 12) { $ampm = "pm"; } else if (($created_timehour > 12) AND ($created_timehour < 24)) { $ampm = "pm"; $created_timehour = $created_timehour - 12; } else if ($created_timehour == 24) { $ampm = "am"; $created_timehour = 12; } else { $ampm = "am"; } $created_at = $created_day . ", " . $created_monthday . ", " . $created_year . " - " . $created_timehour . ":" . $created_timeminutes . $ampm; $itemlink = "http://twitter.com/" . $screenname . "/statuses/" . $itemid; $tpl=$this->configs['template']; $tpl=str_replace("{created_at}",$created_at,$tpl); $tpl=str_replace("{text}",$text,$tpl); $tpl=str_replace("{itemlink}",$itemlink,$tpl); $retstr.=$tpl; } $retstr.="
    "; return $retstr; }

    Following is the cut and resume methods that we used in the above method.

    public function cut($start,$end,$word)
        {
            $word=substr($word,strpos($word,$start)+strlen($start));
            $word=substr($word,0,strpos($word,$end));
            return $word;
        }
    
        public function resume($text,$limit=7)
        {
            $words=@explode(" ",$text);
            $words=@array_splice($words,0,$limit);
            $retstr=@implode(" ",$words);
            return $retstr."... ";
        }
    

    The following method will show all you tweeter followers.

    public function twitterFollowers()
        {
            $this->template = "
    
  • "; $content=$this->twitterXml('http://twitter.com/statuses/followers.xml'); $items=explode("",$content); array_shift($items); $retstr="

    Latest News

      "; foreach($items as $cnt=>$item) { if($this->configs['maxitems']>0 and $cnt+1>$this->configs['maxitems']) break; $created_at=$this->cut("","",$item); $text=$this->cut("","",$item); $itemid=$this->cut("","",$item); $screenname=$this->cut("","",$item); $itemlink = "http://twitter.com/" . $screenname; $tpl=$this->template; $tpl=str_replace("{text}",$text,$tpl); $tpl=str_replace("{itemlink}",$itemlink,$tpl); $retstr.=$tpl; } $retstr.="
    "; return $retstr; }

    This method will show all your tweeter friends.

    public function twitterFriends()
        {
            $this->template = "
    
  • "; $content=$this->twitterXml('http://twitter.com/statuses/friends.xml'); $items=explode("",$content); array_shift($items); $retstr="

    Latest News

      "; foreach($items as $cnt=>$item) { if($this->configs['maxitems']>0 and $cnt+1>$this->configs['maxitems']) break; $created_at=$this->cut("","",$item); $text=$this->cut("","",$item); $itemid=$this->cut("","",$item); $screenname=$this->cut("","",$item); $itemlink = "http://twitter.com/" . $screenname; $tpl=$this->template; $tpl=str_replace("{text}",$text,$tpl); $tpl=str_replace("{itemlink}",$itemlink,$tpl); $retstr.=$tpl; } $retstr.="
    "; return $retstr; }

    let's see how we have connected with tweeter. we used curl to connect with tweeter. the following method done the trick for us.

    function twitterXml($url)
        {
            $curl_handle = curl_init();
            curl_setopt($curl_handle, CURLOPT_URL, "$url");
            curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
            curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($curl_handle, CURLOPT_USERPWD, "$this->username:$this->password");
            $buffer = curl_exec($curl_handle);
            curl_close($curl_handle);
    
            return $buffer;
        }
    

    Links:



    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Download Tweetsigniter

    Download Tweetsigniter, a twitter codeigniter library, from this link Download. Thanks for downloading Tweetsigniter.

    Links:


    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    How to use Tweetsigniter

    To use tweetsigniter, a twitter codeigniter library, grab your copy from here:

    Place the library file under the application->library folder. And in the controller, type the following code:

    $this->load->library('tweetsigniter');
    

    This will load our library. now we will set the requied info:
    $this->tweetsigniter->setInfo('username','password','3');
    

    Here 3 means max number of items. To show tweeter status, we use this function:

    $this->tweetsigniter->easyfeeder();        
    

    To show all followers use the following function.

    $this->tweetsigniter->twitterFollowers();        
    

    And to show all friends use the following function.

    $this->tweetsigniter->twitterFriends();        
    

    Links:


    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Tweetsigniter features

    Tweetsigniter, a twitter codeigniter library, comes up with following feature with version 1.0.

    • You can show all your tweeter status messages.
    • This library also shows list of all your friends.
    • It also shows list of all your followers.

    And the following are coming with the next release.

    • Updating status.

    Links:



    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Thursday, July 1, 2010

    Sample robots.txt to improve page rank

    Here we will see a helpful robots.txt file structure. first let us know what is a robots.txt file. it contains information for web search engine bots to not scroll the seleted pages. let's see a sample helpful robots.txt file that will be helpful for improving page rank.
    user-agent: *
    disallow: /images/
    disallow: /css/
    disallow: /js/
    disallow: /assets/
    disallow: /classes/
    disallow: /captcha/
    disallow: /admin/
    disallow: /system/ /* this is for codeigniter */
    disallow: /application/confiq/ /* this is for codeigniter */
    disallow: /application/controllers/ /* this is for codeigniter */
    disallow: /application/errors/ /* this is for codeigniter */
    disallow: /application/helpers/ /* this is for codeigniter */
    disallow: /application/hooks/ /* this is for codeigniter */
    disallow: /application/models/ /* this is for codeigniter */
    disallow: /application/libraries/ /* this is for codeigniter */
    disallow: /application/language/ /* this is for codeigniter */
    
    User-agent: Googlebot-Image
    Disallow:
    Allow: /*
    
    Sitemap: http://www.example.com/sitemap.xml
    

    Please feel free to suggest me on this topic through your helpful comments.

    see how to resolve svn conflict on http://newdailyblog.blogspot.com/2010/07/resolving-svn-conflict.html
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide.




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Resolving SVN conflict

    At times there may arise a conflict when working with svn. Let's see how we can minimize it. when a conflict occurs four new files are created. they are the followings:
    myfile – the original with markers
    myfile.mine – your version
    myfile.r5 – the original your worked with
    myfile.r6 – the most update version from your colleague
    
    There are several options for resolving conflicts.

    1. I can keep all my works and discard the changes my colleague made with the following command:
    $ cp myfile.mine myfile
    $ svn resolved myfile
    Resolved conflicted state of 'myfile'
    
    2. I will discard all my changes and keep my colleagues work with these commands:
    $ svn revert myfile
    Reverted 'myfile'
    $ svn update myfile
    At revision 6.
    
    The ‘resolved’ command will clean up all the special files that were generated. Now commit your changes.

    3. we can merge both version. we need to do this manually removing the markers and placing the codes of my mine and my colleagues as necessary. then do the following command:
    $ svn resolved myfile
    Resolved conflicted state of 'myfile'
    
    Now commit your changes.


    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Wednesday, June 30, 2010

    Submitting form remotely using curl

    Sometimes we want to a form to a remote server. We can do this using two different methods. One is curl and other is fsockopen. here we are going to see how curl works in this regard.

    First we need to know whether curl is enabled in our server. Check with phpinfo() function. If not enabled, then you need to enable it in php.ini.

    We need to initiate curl using curl_init() function. Then we will set options with curl_setopt() functions. For, form posting we need to use the following options:
    CURLOPT_RETURNTRANSFER
    CURLOPT_FOLLOWLOCATION
    CURLOPT_POSTFIELDS
    
    CURLOPT_POSTFIELDS contains the post variables that we want to pass. We pass those variable using:
    http_build_query()
    
    CURLOPT_RETURNTRANSFER indicates whether the request will return to the caller website after success, we will make it false for our case.

    curl_exec() will execute the connection. we can use curl_errno() and curl_close() for viewing error information and closing curl connection.


    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Tuesday, June 29, 2010

    Difference between rand and mt_rand

    We use rand() function to randomly generate a number.Now php has come up with another more powerful function named mt_rand. it is 10 times faster than the rand function. In php 5.2.1, Mersenne Twister algorithm uses a new seeding algorithm developed by Richard Wagner. Now identical seeds will not produce same results. mt_rand has the following defination:
    mt_rand([int min], [int max]);
    
    if we omit those values, it will product from 0 to mt_getrandmax() values. If we want to show a random number from 5 to 15 inclusive, then we need to write it like the following:
    mt_rand(5,15);
    

    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Saturday, June 26, 2010

    Creating page specific layout in Codeigniter

    I am using different layout libraries, But I found many problems using those libraries, So, I have create my own codeigniter layout library. Today I speak about how we can create a page specific layout with codeiginter.

    First of all think of our page as a collection of blocks. We will create each different view files for each block. So, when we want to show a block we simply load that view file and pass it into the variable in the controller, like the following way:
    $this->_data['news_right_column'] = $this->load->view('common/news_right',$this->_data, TRUE);
    

    Suppose, news_right has the following content in it:
    Hello world
    
    in the view file where we want to show the block, need to write the following code:
    echo $news_right_column;
    
    So, when we don't want to show the block, we simply remove the above code.
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Friday, June 25, 2010

    Resolving HMVC problem in Codeigniter

    HMVC comes with great features. But using it with codeigniter is a bit problematic, Today we will see how we can cross load library of a module into another module. Suppose we are using the DX_Auth library. And we have a module named 'Auth' and paste all the necessary file within it. We want to use it outside of all the modules, in the main controller folder. We can use the following command:
    $this->load->model('module/controller');
    
    $this->load->module('module/controller');
    

    But with DX_auth there would be a problem as it also need to have the libraries and config file to be loaded. For that purpose we will use a autoload file under config folder in our module. HMVC now autoloads a variable name $autoload. We can call it in the construct funtion, but then it will be called only once. The autoload file under config folder of auth module would be like this:
    
    $autoload['libraries'] = array('DX_Auth_Event');
    
    
    /*
    | -------------------------------------------------------------------
    |  Auto-load Helper Files
    | -------------------------------------------------------------------
    | Prototype:
    |
    | $autoload['helper'] = array('url', 'file');
    */
    
    $autoload['helper'] = array('url','form');
    
    
    /*
    | -------------------------------------------------------------------
    |  Auto-load Plugins
    | -------------------------------------------------------------------
    | Prototype:
    |
    | $autoload['plugin'] = array('captcha', 'js_calendar');
    */
    
    $autoload['plugin'] = array();
    
    
    /*
    | -------------------------------------------------------------------
    |  Auto-load Config files
    | -------------------------------------------------------------------
    | Prototype:
    |
    | $autoload['config'] = array('config1', 'config2');
    |
    | NOTE: This item is intended for use ONLY if you have created custom
    | config files.  Otherwise, leave it blank.
    |
    */
    
    $autoload['config'] = array('dx_auth');
    
    
    /*
    | -------------------------------------------------------------------
    |  Auto-load Language files
    | -------------------------------------------------------------------
    | Prototype:
    |
    | $autoload['language'] = array('lang1', 'lang2');
    |
    | NOTE: Do not include the "_lang" part of your file.  For example
    | "codeigniter_lang.php" would be referenced as array('codeigniter');
    |
    */
    
    $autoload['language'] = array();
    
    
    /*
    | -------------------------------------------------------------------
    |  Auto-load Models
    | -------------------------------------------------------------------
    | Prototype:
    |
    | $autoload['model'] = array('model1', 'model2');
    |
    */
    
    $autoload['model'] = array();
    
    
    
    And now we will create our necessary function within the auth controller or what ever controller you want to write in. suppose we write the following function:
    function is_logged_in()
    {
    $this->load->library('DX_Auth');
    // Set auth info        
    if($this->dx_auth->is_logged_in())
    {
    $this->userId   = $this->dx_auth->get_user_id();
    $this->_data['userId'] = $this->userId;
    }
    }
    
    Now we will call this function from our main root controller folder, like this :
    $this->load->module('auth');
    $this->auth->is_logged_in();
    

    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Thursday, June 24, 2010

    Google Earth installation problem

    To install google earth first download it. Then for ubuntu, go to the folder where you placed the binary file of google earth installation. To change it's permission type the following code :
    sudo chmod +X GoogleEarthLinux.bin
    
    Now run the following command to install google earth:
    ./GoogleEarthLinux.bin
    
    But you may come up with the following error as I have:
    Fatal error in __driConfigOptions line 1, column 0: unknown encoding.
    Google Earth has caught signal 6.
    
    This problem is for many users, Google is looking into this problem. If any one knows the answer, plz let me know.


    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Wednesday, June 23, 2010

    what is VPS?

    VPS means virtual private server. This is the bridge between shared hosting and dedicated hosting. In VPS, the user gets superuser privileges of his server. Here the entire server is partitioned into several blocks. Each block acts like a full hosting server with superuser privileges. VPS providers with cloud computing support gives the option of adding extra servers as our demand grows, we can remove that extra server at any time. Some VPS owners want to minimize their costing by renting their unused space. We can install partition software to partition our slice and then rent our unused slice to minimize our cost.


    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Tuesday, June 22, 2010

    creating multi-step form

    Sometimes we need to create multi-step form. But why should we create a multi-step form? and when should we create those? if our form has many fields to fill up, then at times our users may get bored typing texts, so, they may leave the form without submitting the form. But if we have multi-step forms then we can split a long form into several short forms, so, users can submit short group of informations and at any time they can leave the process, but their information upto which they have submitted will be stored at the database, and they can start filling up the form from thereon.

    we can use hidden input fields, sessions or store information to databases at each step to carry the information. if we use hidden fields we need to pass a great amount of data at each form submission except the first one, it is not the recommended process. we can store the values into sessions and it will prevent resubmitting the values. We can store the information into databases also.

    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Sunday, June 20, 2010

    Authorize.net's AVS

    Authorize.net uses a field named AVS in advanced integration method for validating the billing address of the customer against the information provided at the card issuing bank. If the information is not match, then the transaction will be rejected. For setting up of AVS, we need the zip code and address of the customers.


    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Paypal payflow pro

    We can use any payment gateway to make transaction and process the money to our paypal account using paypal's payflow pro api. We can use both debit/credit cards and express checkout for our transaction in payflow pro. If we use paypal as our payflow payment gateway, then we can use payflow edition which uses paypal as their payment gateway.

    You need to have a SDK for using this service. Their are three sdks available. One each for java and .net. Languages other than java and .net need to use HTTPS sdks.



    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Paypal masspayment

    Using paypal mass payment api, buyers can send payments to upto 250 recipients. We can set a specified amount for each different recipients of the payment. After a successful payment, two email notification is sent to the recipients. But you need to enable paypal instant payment notification first. One is process IPN and other is completed IPN. So, for calculating transaction fees and getting them into other accounts mass payment api is the required one.



    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Friday, June 18, 2010

    Creating opencart theme

    We can easily create a new opencart theme. Copying the whole default theme folder will make some problem during update of opencart. So, we need to copy files from default folder selectively. First get an opencart package from their site. Then copy the following files to your new theme folder which is under '/catalog/view/theme/'. We named it 'themecart'.
    catalog/view/theme/default/stylesheet/*
    catalog/view/theme/default/image/*
    catalog/view/theme/default/template/common/header.tpl
    
    Here * means all files. Choose theme 'themecart' from the main settings section under the admin area.

    Now we need to replace all the 'default' word with our theme name 'themecart' in the header.tpl file. And then save the file.

    Now Your new theme folder is ready for customization. Make change in the stylesheet.css and save it. Just copy the file from the default folder that you need to change. That's it.

    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Thursday, June 17, 2010

    Sudoers file modification

    We can change sudo privileges to users groups and also can do lots of new commands aliases with /etc/sudoers file. you need to type the following command to open the file:
    sudo visudo
    
    This will open the file in the vi window, then we will write our necessary commands within the file. to add a root user with all permissions from all terminals type the following commands:
    root ALL=(ALL) ALL
    
    This means root user gains previleges of executing all commands from all terminals. We can set a user with the following specific previleges:
    guest ALL=NOPASSWD: /usr/bin/
    
    this means user guest has can execute commands for path /usr/bin without any password.

    To make a command aliasing we can write the following command:
    cmnd_alias apache_restart /etc/init.d/apache2 restart
    
    Now we will have a command apache_restart which will perform the restart operation of apache.


    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Wednesday, June 16, 2010

    Restart Apache using Cron job in php

    Sometimes we need to restart apache from our scripts automatically. Other than root user privileges, other users need to use sudo keyword to restart apache. But it needs password for sudo command. We can change sudo permissions and set options with the /etc/sudoers flie. Edit the file with the following command:
    sudo visudo 
    

    php scripts are run with www-data user previleges. We can get the current user info with the command:
    whoami
    
    So, we need set options in the /etc/sudoers flie for user www-data. Set the following:
    www-data ALL=NOPASSWD
    
    So, sudo will not prompt for password while running the script.
    Use exec functions to execute your command through php.


    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Friday, May 28, 2010

    Pointing a domain in Godady

    Hi everyone, today we will see how to point to a domain registered with another registrar. First you need to create a subfolder within your primary domain name. Then add domain within the domain management section.

    In the registrar add Name servers:

    ns25.domaincontrol.ccom
    ns26.domaincontrol.com

    It will take 12-24 hrs to be active. Then upload files to the folder.

    You can find helpful information here also: http://help.godaddy.com/article/5399.
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Monday, April 19, 2010

    code of htemplate

    If we want to show a code block on htemplate, we will use eval keyword for this purpose. Eval will show the code block without printing anything directly.
    {eval}name = "Name: " + name.toUpperCase();{end}
    Alternatively, we can write it like the following way:
    {? Name = "Name: " + name.toUpperCase();}
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    haXe's htemplate system

    htemplate is a powerful system for haXe template system. It is simple and easy to use. it is still growing very rapidly and day by day it is evolving with new techniques. htemplate is cross-platform. It uses hscript to perform template logic. It has a well documented, rich and growing API.
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    attr of haXe templo

    This is a pseudo attribute. We can use it like the following:
    We will get the following result with it:
    We can write it in this way also:
    The attr is mainly helpful with select tag. We can generate multiple option values here. Following will the add the checked attribute when the condition is true.


    Now the following will generate option values:

    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    use in haXe templo

    At times we need to split our template into several different files. This will enhance reusability. The :: use :: will call en external template from our current template. The called template will share it’s context with the current template.
    The ::use X:: ::fill content:: ::end:: ::end:: syntax is repetitive and this syntax is useful in website template system.
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Foreach structure in Templo of haXe

    Templo uses foreach to iterate over an iterable. The syntax for foreach is the following:
    ::foreach value iterable::
    And the quantity is ::value::.
    ::end::
    For example, here variable i iterates over iterable members.
    ::foreach i members::
    User name is ::i::
    ::end::
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    haXe templo commands

    Templo supports several commands to explore. These commands ease our work load. We can run the following commands:
    Usage : temploc [options]
    -cp : this will add file search path
    -output : it will specify output directory
    -macros : we can add macro definition file using this
    -php : this will use php output
    -debug : and this will use debug mode
    -xml : don't use XHTML checks
    -compare : we can compare two files or directories structurally
    -compare-xml : we compare also XML files
    --compare-both : this will display both files position in comparisons

    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    installation of templo of haXe

    Templo is available in the Motion-Twin public haXe libraries. It is also available using cvs. Check this out:
    cvs -d :pserver:anonymous@cvs.motion-twin.com:/cvsroot co haxe_mtwin
    Now we need to follow the following steps:
    • If we see the lib/mtwin/templo directory in the directory path, we will find a file named temploc.hxml. We will run it to produce temploc executable.
    • Then we will put it under an accessible folder where Apache is able to execute it.
    • And we will have mtwin package installed in our haxe library path.
    We can also download and install in just two steps. To install haXe we need execute following commands:
    • haxelib install templo : this will download and install templo to current directory.
    • haxelib run templo : with this command we can run templo and create an executable temploc2. This will also be placed in the current directory.
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    template class in haXe

    haXe template class is growing fast to adorn itself with more possible options. This class has some useful methods. Many advanced template system uses this methods. Templo and htemplate uses these basic methods. Let’s discuss them one by one.
    • function new( str : String ) : Void – this is the constructor of template class.
    • function execute( context : Dynamic, ?macros : Dynamic ) : String – it executes the template variables with the template and returns a string. This will output the XHTML value. In the context we pass the value of the template variables and in the macros we can set an optional macro function.
    • static var globals : Dynamic – global variable.
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Template system in haXe

    haXe comes up with a simple, easy to use, proficient, efficient template system. This template system has very simple syntax to implement. HaXe has strong template library for this purpose. HaXe.template class brings all these features to us. We can create very sophisticated templates with it. This class is lightweight and well interpreted.
    As we have already learnt that a template is a string or a file that we use to produce some XHTML or XML output depending on our input. Let’s see an example:
    Welcome to ::name:: template system and it is ::quality::.

    Here we have two template variables - ::name:: and ::quality::. We will assign different values to them.
    Now we will save the above simple code into a file named: my_sample.mtt. We will use this file in our haXe code.
    class Templ {
    static function main() {
    var str = haxe.Resource.getString("my_sample");
    var t = new haxe.Template(str);
    var output = t.execute({ name : "HaXe", quality : “simple and easy”});
    trace(output);
    }
    }
    We pass value to our template variable like { name : "HaXe", quality : “simple and easy”}. Now we will compile our code. First we will create an hxml file like the following:
    #-swf appTemp.swf
    #-neko appTemp.n
    #-js appTemp.js
    -resource my_sample.mtt@my_first
    -main Templ
    Here we have included proper command for all the platforms. Just uncomment the specific portion that is useful for a targeted platform.
    This will produce an output which will have the template variables replaced by the values that we have passed to it. They will be replaced at runtime. It will show the following output:
    Welcome to HaXe template system and it is simple and easy.
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Inline methods in haXe

    We have seen inline variables; now we will see inline methods in haXe. When we use inline methods, the compiler will insert the complete body of the function in every place of the code where the function is called.
    But this inline method feature of haXe has some drawbacks. Let’s know about them:
    • We cannot redefine inline methods at runtime.
    • Also we cannot override subclass in inline method.
    • We cannot create inline function with a ‘super’ access or with an internal function.
    • Function arguments evaluation order is undefined and every function may not be evaluated.
    • If we return value with inline function, it will only return the final value.

    inline function prime(flag) { return flag?0:1; } // accepted
    inline function even(flag) { if( flag ) return 0; else return 1; } // accepted
    inline function odd(flag) { if( flag ) return 0; return 1; } // refused
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Unknown type in haXe

    In HaXe, we have a new keyword called ‘unknown’. When a type is not defined, haXe treat that as ‘unknown’. The variable that has unknown type, changes to the variable type that was used for the first time.

    function notknown() {
    var x;
    type(x); // print Unknown<0>
    x = 0;
    type(x); // print Int
    }
    Here the function first prints ‘Unknown’ and later it prints ‘Int’.
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    anonymous type in haXe

    We use anonymous type for anonymously defined object. We will use this type for class declaration also. Static fields can be of type anonymous. It can also be an enum identifier having all the constructors.

    Anonymous types are structural. So, we can have more fields in the value than in the type. We can declare it as follows:
    var a : { count : Int, prime : Int } = { count : 36, prime : 31, q : -4.6 };
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Return type in haXe

    We use return keyword to exit from a function. We also return a value from a function with this keyword. The return statement takes the general form:
    Return value;
    Where value is the value to be returned. Let’s see an example of return keyword.
    function func( i : Int ) : Bool {
    if( i % 2 != 0 ){
    return true;
    }
    return false;
    }
    To return a value the above function has the return type Boolean. We write the return type after the function declaration and the type precedes a colon(:). We can use the return statement without assigning a value to it. It causes the function to return immediately, before the function’s closing curly brace is reached. Let’s see another example of it.
    function nothing(x:Int) : Void {
    if( x==10 ){
    return;
    }
    // ....
    }
    Here the function has void return type. It checks x’s value against 10 and if it is true then it executes the return statement without any value.
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Shift operator in haXe

    Left bit-shift and right bit-shift operator are the two shift operators supported by HaXe.
    • expression1 << number-of-bits : we will shift number-of-bits places to left and zero is brought in on the right. • expression1 >> number-of-bits : we will shift number-of-bits places to right and zero is brought in on the left.
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    For conditional block in haXe

    We use for loop to repeat a statement or block of statements a specified number of times. For loop is considered to be the most flexible loop. The structure of for loop is:
    for(variable in initialization...limit) statement.
    Here variable is the variable that loops through the specified variable, initialization is used to set an initial value to the variable and limit is the last value up to which the variable will loop.
    for( i in 0...10 ) {
    trace(i);
    }
    In this example, i iterate over 1 to 10 and it prints values from 1 to 10.
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Naming convention in haXe

    Every language has a naming convention. HaXe needs to support several languages, as it is a multi-platform language. So, haXe has a naming convention which enables haXe to support multi-platforms.
    • Every haxe program must have a class in it.
    • Every class must have a static main function.
    • Class name and filename must be identical.
    • Type name has to start with an uppercase letter.
    • Package name is composed of several identifiers. Each of those are connected together with periods ‘.’. A package name will start with a lowercase letter.
    • Class name needs to start with an uppercase letter or underscore, can contain numbers in it.
    • Similarly, variable name will start with a letter or underscore, can contain numbers in it.
    • Constants should always be all-uppercase, with underscores to separate words.
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Function type in haXe

    Functions are integral part of haXe. We can’t think of haXe without functions. It must contain at least the Main() function. A function is a code block of a program that perform a specific task and which is independent of remaining code block.
    The syntax for function definitions are like the following:
    Access-modifier function function-name(var-name:type):return-type{}
    Here access-modifier may be public, private for the function function-name with argument var-name of type. This function will return return-type.
    Like objects, HaXe functions are typed. Their type depends on two things:
    • The arguments taken by the function.
    • The return type of the function.
    For example, we have the following function,
    public function prime(even : String, odd : String) : Int
    Here the function prime has arguments even and odd of type string. This returns an Int type. We can denote this as:
    String->String->Int
    We can even take a function as an argument to our function. And also can return a function. let’s take a look at the following function:
    public function prime(even : String, odd : String->Int) : Int
    We can write this like:
    String->(String->Int)->Int.
    Ok, now we will show a function which accepts the above arguments but returns a function with two arguments of type Int and returns a String. So, the function is like:
    function m2(arg1 : String, arg2 : String->Int) : Int->Int->String;
    Now let’s see how we will write that:
    String->(String->Int)->(Int->Int->String)
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    sugarlist of haXe

    SugarList extends a List, declares field object link references. It overrides every base List method so that they work identically. SugarList will be faster than List on SWF VM. But we can also use sugarList on other environments where List is supported.
    We use Lambda methods to manipulate List. But when it is used with SugarList, it slows down the process. ListTools play an important part in manipulation in this regard. ListTool is a package of methods that we use to create list from different types of iterables. We can use an optional argument –D sugarlist which will result into sugar list types.
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Iterator in haXe

    Iterator, as the name suggests, is an object that iterates all the elements of a collection. In haXe, iterator follows iterator typedef:
    typedef Iterator = {
    function hasNext() : Bool;
    function next() : T;
    }
    The type T denotes the iterator type.
    The simplest iterator is the IntIter iterator. We can easily built it with ...(three dots). The syntax is:
    for( i in 0...100 ) {
    // ...
    }
    We don’t need to declare the type of variable i, since it is automatically declared.
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Regular expressions in haXe

    We generally thought regular expressions as some kind of complex topic. Let’s see them with some very simple examples. Regular expressions are a set of matching rules. The real power of regular expression comes into play when we don’t know the exact string to match.
    HaXe has built-in support for regular expression. We use regular expression to match a given pattern or to extract a given pattern. In haXe, the match rule for regular expression starts with ~/ and ends with /. Let’s see the following example:
    var a : EReg = ~/John/;
    var msg = "welcome John";
    trace(a.match(msg)); // true : 'John' was found in the string
    trace(a.match("welcome !")); // false
    Here a contain the matching rule. We match this rule against the msg message. When it found the matched pattern it displays true, otherwise false.
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Multi-dimensional arrays in haXe

    We can create arrays with two or more dimensions. Multi-dimensional arrays are arrays of array. The syntax for such arrays will be like this:
    var variable-name : Array = new Array>
    For extra dimension we need to declare an extra ‘’ on the left. There is no support for associative array. But we can get it using Hash. See the following example in which we implement an associative array using hash data type.

    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    arrays in haXe

    Now we will see about arrays. An array is a list of elements. They are very useful in a variety of situations. Arrays form a convenient way to handle groups of related data. We can declare a one-dimensional array like this:
    var variable-name:Array = new Array();
    here variable-name is the name of the array variable with type of Type. For example, we can declare myarray like the following:
    var myarray:Array = new Array();
    An array element is accessed by indexing the array using the number of elements. To access a specified element in an array, we use the specified position number in square brackets. Like:
    myarray[10] = ”even”;
    This has value ‘even’ at an index of 10.
    HaXe stores one-dimensional arrays in one contiguous memory location with the first element at the lowest address.
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Local variable inference

    Local variable inference simplifies our code. Type inference makes our code strictly typed. We don’t need to use types everywhere in the program. It is not necessary to use type for a local variable. It will infer the type at the time it is first accessed in the program.
    var num;
    type(num); // print Unknown<0>
    num = 100;
    type(num); // print Int
    Here initially num has not been typed. So, it is showing type of Unknown. Then we assign a value of 100 and it then treats the variable as num.
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Type inference in haXe

    We will start this chapter with the excellent feature of type inference. Type inference is the way to automatically deduce the type of a variable in a program. This is a strongly static feature of haXe. What is strongly static type and dynamic type? Let’s know it first:
    • We can know the type of an expression only at runtime in dynamically type language.
    • If we can know the type of an expression at compile time, then it is statically typed.
    HaXe uses type inference at compile time. So, if we declare a variable without a type, the type of the variable will be set when it is first used. The compiler gathers the type information as an aggregate function of expression used or by understanding implicitly the type of the values that are used.
    See the book OpenCart 1.4 Template Design Cookbook. See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Sunday, April 18, 2010

    Boot Loader of Haxe

    We have already introduced with php boot class. HaXe and PHP are quite different in nature. Arrays in haXe start with 0 and every position between 0 and length must exist even if the value is null, but PHP is totally different from it. HaXe supports passing function by reference; we can pass function by names in PHP. The boot class unifies these differences.
    Another action of boot class is autoloading feature. This feature loads the required class at runtime and it avoids static references to all the files in the lib directory. So, with this feature though we may have 100 generated files, but will use only few of them at the time of execution.
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Friday, April 16, 2010

    features of haXe.

    We have run our first haXe program and have compiled for different targets. Cool, that’s great a feature of haXe. We have made only one haXe program which then has given us several different compiled codes targeting different platforms. That’s why HaXe is a multiplatform language.
    Let’s see some other magnificent features of HaXe.
    • It has complete type inference; no need to type local variables. Type inference refers to the ability to find automatically the type of a variable. So, when we set a value to a variable, the type of the variable automatically sets according to the value.
    • haXe provides runtime type information. Runtime type information is a mechanism that allows the type of an object to be determined during program execution. We will implement haxe.rtti.infos to get this information.
    • Conditional compilation is a process through which we can compile only selected portion of code excluding other sections. Haxe supports this feature with conditional compilation macros.
    • HaXe uses Inline methods and variables. This feature increases the compiled code size and also the execution speed of the program.
    • Debug compilation mode features enables the scope to debug our code in compile time. We can add additional exceptional handler in compile time for debugging purpose.
    • HaXe has Optimized generics. We use generics to check the type of a collection to the compiler. When the compiler knows the element type of the collection, then the compiler checks the consistency of the collection. Then it inserts the accurate cast on values of collection.
    • We can build Flash desktop application with ScreenweaverHX. Screenweaver is software for building cross platform Rich Interfaced Desktop Applications (RIDA). It separates application logic from application interface. ScreenweaverHX acts like a bridge between Neko VM and Flash.
    • Strongly typed language.
    • Haxe invented the useful ‘untyped’ keyword. Sometimes we want to implement a class or function or test case which is not allowed in HaXe. Then untyped keyword plays a big role.
    • HaXe comes with ‘magic’ keywords.
    • haXe has supports for packages.
    • It uses Polymorphic methods. A polymorphic method behaves differently, depending on the object type it is called with. In this way, the nuts and bolts of the code are hidden from us. We just call the object with the operation that we need to apply to the object. We need not to know what type the object is of, or how to adapt the operation to the type.
    • Unit testing support.
    • Cross platform serialization to web compatible format
    • High level type system: anonymous type , dynamic type,
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    Installation of haXe on linux

    We have seen the installation process on windows environment. Now let’s see it for Linux. As we have seen earlier, haXe has come up with automatic installer; download it and run the installer. For manual installation, we need to write some command.
    The haXe compiler is written on OCaml language. First, we will install the OCaml packages and some additional packages and tools, run the following single command:
    sudo apt-get install ocaml camlp4 ocaml-findlib cvs zlib1g-dev make wget tar subversion

    Now create a file named linuxHaxe.sh, a shell script. This will have the following code:

    #!/bin/sh
    # linuxHaxe.sh

    mkdir haxesrc
    cd haxesrc

    wget http://haxe.org/_media/install.ml
    ocaml install.ml

    # reset previous installations
    sudo rm -rf /usr/local/haxe
    sudo rm -rf /usr/local/bin/haxe*


    # install haxe in /usr/local
    sudo mkdir /usr/local/haxe
    sudo mkdir /usr/local/haxe/bin
    sudo cp bin/* /usr/local/haxe/bin
    sudo cp -r haxe/std /usr/local/haxe
    sudo ln -s /usr/local/haxe/bin/haxe /usr/local/bin/haxe

    # setup environment variables for haxe
    sudo grep "HAXE_LIBRARY_PATH" /etc/environment || echo "export HAXE_LIBRARY_PATH=/usr/local/haxe/std:." >> /etc/environment

    We need to change the permission of the file with the command:
    sudo chmod 0755 linuxHaxe.sh

    Then run it by the command:
    ./linuxHaxe.sh

    The installation is complete. Now we will validate installation like we did for windows earlier.
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide

    reasons behind success of haXe

    • HaXe is similar to ECMAScript. So, it is very much like to JavaScript and ActionScript.
    Compare to Flex or Flash compilers, HaXe compiler is tremendously speedy. Hence, HaXe is an easy transition from non-compiled languages like PHP and JavaScript.
    • Compare to Flex or Flash compilers, HaXe compiler is tremendously speedy. Hence, HaXe is an easy transition from non-compiled languages like PHP and JavaScript.
    • Unusual to programming languages, HaXe comes up with both dynamic and strong type checking. Having compile-time checking, we can test our code before placing it in browser. It makes a faster workflow. But it also enables the programmer to bypass type-checking and rely on the target platform's dynamic type-handling.
    • Adding lacking characteristics to targets, HaXe presents us an affluent set of quality accessible for use on all target platforms, like : inlining & generics to Flash development, packages & typing to JavaScript & PHP, dynamic objects & Runtime Type Information, enabling Reflection to C++, and much more.
    • We can use same codebase for different platforms. So, we can compile same classes for many platforms. Different platforms adorn themselves with different syntax and style. Learning Haxe will relives this pain. Haxe uses single syntax and styles for its development.
    • We can embed Flash in a Neko application using ScreenweaverHx. With this, we can use Flash application as a Desktop application.
    • We can read/write several types of files such as ‘abc’ (ActionScript Byte Code), SWF headers, ‘PHP’ & more.
    See the book OpenCart 1.4 Template Design Cookbook.
    See the book Joomla Mobile Development Beginners Guide




    List of my works:

    Opencart Extensions:

    1. Product Based Quantity Wise Shipping: Find it here.
    2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
    3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
    4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
    5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
    6. Formcaptcha - add captcha on the register page: Find it here.

    My Books:

    1. OpenCart 1.4 Template Design Cookbook.
    2. Joomla Mobile Development Beginners Guide