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:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

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:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

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:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

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:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

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:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

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:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

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:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

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:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

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:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

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:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

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:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

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:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

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:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

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