Monday, November 14, 2016

PHP- function to correct all the images orientation in a given path or directory

<?php
/*
This function correct all the images orientation in a given path or directory.

Run:    php -r "require 'correctImageOrientation.php'; correctImageOrientation('test/');"
        or
        php -r "require 'correctImageOrientation.php'; correctImageOrientation('test/test1');"
        or
        php -r "require 'correctImageOrientation.php'; correctImageOrientation('test');"
*/
function correctImageOrientation($directory) {
   
    ini_set('memory_limit','2048M');
   
    $scanned_directory = array_diff(scandir($directory), array('..', '.'));
    echo "<pre>";
    print_r("scanned directory: \r\n");
    print_r($scanned_directory);
    echo "</pre>\r\n";
    foreach ($scanned_directory as &$file) {

        if (is_dir($directory."/".$file)) {
            correctImageOrientation($directory."/".$file);
        } else {                                   
            $filen = explode(".", $file);
            $ext = end($filen);
            try {

                $exif = @exif_read_data($directory."/".$file);

                $orientation = $exif['Orientation'];

                if (isset($orientation) && $orientation != 1){
                    switch ($orientation) {
                        case 3:
                        $deg = 180;
                        break;
                        case 6:
                        $deg = 270;
                        break;
                        case 8:
                        $deg = 90;
                        break;
                    }

                    if ($deg) {

                        // If png
                        if ($ext == "png") {
                            $img_new = imagecreatefrompng($directory."/".$file);
                            $img_new = imagerotate($img_new, $deg, 0);

                            // Save rotated image
                            imagepng($img_new,$directory.$file);
                        }else {
                            $img_new = imagecreatefromjpeg($directory."/".$file);
                            $img_new = imagerotate($img_new, $deg, 0);

                            // Save rotated image
                            imagejpeg($img_new,$directory."/".$file,80);
                        }
                    }
                    echo "<pre>";
                    print_r("image changed: \r\n");
                    print_r($directory."/".$file);
                    echo "</pre>\r\n";
                }

            } catch (Exception $e) {
                echo "error:";
                echo $e;
                echo "error";
            }
        }
    }
    unset($file);
}


correctImageOrientation('test/test1') ;
?>

Sunday, October 16, 2016

Wordpress- How to Stay Logged in for Longer Periods

// Stay logged in for longer periods
add_filter( 'auth_cookie_expiration', 'keep_me_logged_in' );
function keep_me_logged_in( $expirein ) {
    return 31556926; // 1 year in seconds
}

Tuesday, September 20, 2016

How to Change the Login Logo in WordPress

function custom_loginlogo() {
echo '<style type="text/css">
h1 a {background-image: url('.get_bloginfo('template_directory').'/assets/images/logo.png) !important; }
</style>';
}
add_action('login_head', 'custom_loginlogo');

How to Change the Login Logo URL in WordPress

add_filter( 'login_headerurl', 'custom_loginlogo_url' );
function custom_loginlogo_url($url) {
    return 'http://www.your-site-url.com';
}

Tuesday, September 6, 2016

Javascript: Download PDF using javascript

Javascript: Download PFD using javascript



              var x= 'http://your-site/pdf-report/purchasing-report.pdf'; //PDF URL
              myTempWindow = window.open(x,'','left=10000,screenX=10000');
              myTempWindow.document.execCommand('SaveAs','null','download.pdf');

Javascript: Download PDF using javascript

Javascript: Download PFD using javascript



              var x= 'http://your-site/pdf-report/purchasing-report.pdf'; //PDF URL
              myTempWindow = window.open(x,'','left=10000,screenX=10000');
              myTempWindow.document.execCommand('SaveAs','null','download.pdf');

Javascript: Download PDF using javascript

Javascript: Download PFD using javascript



              var x= 'http://your-site/pdf-report/purchasing-report.pdf'; //PDF URL
              myTempWindow = window.open(x,'','left=10000,screenX=10000');
              myTempWindow.document.execCommand('SaveAs','null','download.pdf');

Monday, August 22, 2016

Wordpress - localhost url not found

you will need to edit the http.conf file in the Apache -> Conf folder
1. Open in a plain text editor
2. Find the line that looks like this
#LoadModule rewrite_module modules/mod_rewrite.so
3. Remove hash
LoadModule rewrite_module modules/mod_rewrite.so
4. save
5. regenerate .htaccess

Enjoy :)

Wednesday, August 17, 2016

Magento: Load record of my model by custom Field

Magento: Load record of my model by custom Field


$model = Mage::getModel('foo_bar/baz');
$model->load($id, 'field_name');

Thursday, August 4, 2016

Magento- Country and States in Magento

Magento has inbuilt model for Country and State as seen in Checkout page.
In checkout page if you select Country like ‘France’ , a drop down will be seen in place of textbox for States.
I am writing here the code to directly get country name from ID and also to get States info from country.

<?php
    $countryName = Mage::getModel('directory/country')->load('FR')->getName(); //get country name
 
     
    echo 'Country Name ->'.$countryName.'<br/>';
 
 
    $states = Mage::getModel('directory/country')->load('FR')->getRegions();
 
     
 
    //state names
 
    foreach ($states as $state)
 
    {      
 
        echo 'ID->'.$state->getId().'<br/>';
        echo 'Name->'.$state->getName().'<br/>';
 
    }
?>

Wednesday, August 3, 2016

PHP- How to change the array key to start from 1 instead of 0 ?

how to change the array key to start from 1 instead of 0 ?

$newarr = array_combine(range(1, count($oldarr)), array_values($oldarr));

Wednesday, July 27, 2016

Magento: list all values of a single attribute

 $name='product_attribue_name';
    $attributeInfo =     Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter($name)->getFirstItem();
    $attributeId = $attributeInfo->getAttributeId();
    $attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);
    $attributeOptions = $attribute ->getSource()->getAllOptions(false);
    echo '<pre>'; print_r($attributeOptions);

Tuesday, July 26, 2016

Magento- get product collection by customer reviews

Magento- get product collection by customer reviews

<?php
$collection = Mage::getModel('review/review')
                ->getResourceCollection()
                ->addStoreFilter(Mage::app()->getStore()->getId())
                ->addFieldToSelect('*')
                ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
                ->addRateVotes();
$collection->getSelect()->group('entity_pk_value');
               
//echo $collection->getSelect();

print_r($collection->getData());

?>

Monday, July 18, 2016

CSS- Responsive Masonry Layout using Only CSS without jQuery

<html>
<head>
<title>Masonry Layout</title>
<style>

*, *:before, *:after {box-sizing:  border-box !important;}
article {-moz-column-width: 13em; -webkit-column-width: 13em;-moz-column-gap: 1em; -webkit-column-gap: 1em; }
section {display: inline-block;margin:  0.25rem;padding:  1rem;width:  100%; background:  #efefef;}



</style>

</head>

<body>
<h1>Pure CSS Masonry</h1>
<p>By using CSS3 columns, we can easily create a Masonry.js-like layout where random-height blocks fit together.</p>

<article>

  <section>
    <p>Lorem ipsum dolor sit amet, consectetur.</p>
  </section>
 
  <section>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Error aliquid reprehenderit expedita odio beatae est.</p>
  </section>
 
  <section>
    <p>Lorem ipsum dolor sit amet, consectetur.</p>
  </section>
 
  <section>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nobis quaerat suscipit ad.</p>
  </section>

  <section>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Rem nihil alias amet dolores fuga totam sequi a cupiditate ipsa voluptas id facilis nobis.</p>
  </section>


  <section>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Rem ut debitis dolorum earum expedita eveniet voluptatem quibusdam facere eos numquam commodi ad iusto laboriosam rerum aliquam.</p>
  </section>
 
  <section>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
  </section>
 
  <section>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quaerat  architecto quis tenetur fugiat veniam iste molestiae fuga labore!</p>
  </section>
 
  <section>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Odit accusamus tempore at porro officia rerum est impedit ea ipsa tenetur. Labore libero hic error sunt laborum expedita.</p>
  </section>
 
  <section>
    <p>Lorem ipsum dolor sit.</p>
  </section>
 
  <section>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima asperiores eveniet vero velit eligendi aliquid in.</p>
  </section>
 
  <section>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloribus dolorem maxime minima animi cum.</p>
  </section>
 
</article>
</body>

</html>

OUTPUT:  

 

Friday, July 15, 2016

Some Very Common Interview Questions and Answer

Here are some possible interview questions with answers, answers may not be the perfect one but it will give an idea what actually interviewer wants to ask.

Q1.How would you describe your personality?
Answer: "I'm pretty even-tempered. I enjoy being part of a team and feel comfortable both making decisions and following directions."

Q2.Tell me about yourself and your past experience?
Answer: "I have been working in Information Technology industry for last 4-5 years. I had an opportunity to work in teams and independently. I am very comfortable in both the environments. I have developed Client/Server and Intranet applications, involving full life cycle, which includes Requirement Phase, Analysis/Design, Development, Unit Testing, Integrating Testing, Customer/User Testing, and Rollout/Implementation. I have worked on various tools in my career, which includes MS Access, MS SQL Server, SQL, VBA, JavaScript, VB Script, COM/DCOM, ADO, Active X, ASP, HTML, DHTML, XML, XSL, CSS, Visual InterDev, Visual Basic, FrontPage, Dreamweaver, Flash, Visual Source Safe and Adobe PhotoShop. I have always met the project deadlines, for which I had to work late hours and weekends. For the past two years, I have been working as a Web Developer. Where I have involved in the beginning of the project itself, i.e., Requirement gathering phase. Online Job Search is a successful multi-tier web-based application, which uses MS SQL Server 7.0 as backend data store and Visual Basic 6.0 and ASP as front-end. It provides a user-friendly platform for Job Seekers as well as Job Submitters, from across the globe to register, search and submit Vacancies in their local areas. We had meetings with the Customers/Users to get all the required information. This application gives various functionalities (forgotten password, Mailing list and etc) and different security levels to the Users and Administrators. My strengths are my client-relationship management skills, and my leadership ability."


Q3.Why are you leaving your current job?
Answer:Forget about the fact that you hate your boss and your co-workers drive you crazy. Instead, say, "I'm ready to take on more responsibilities and learn more, but the opportunities at my current job are limited. Or I've set some goals for myself and my career, and unfortunately I'm at a standstill in my current situation. I have begun to explore options available before I spend too much time in a job where I can't advance. My goal is to continue to take on new responsibilities and be a key contributor to the success of an online venture."

Thursday, June 23, 2016

Wordpress- Delete users between two registration dates programatically .

function get_users_registered_between_date($start='', $end='' ){
     global $wpdb;
     $prefix =$wpdb->prefix;
     $user_table= $prefix.'users';
     
     if( empty($start) )
          $date = date('Y-m-d');

     if ( empty($end) )
          $end = $start;

     $start_dt = new DateTime($start. ' 00:00:00');
     $s = $start_dt->format('Y-m-d H:i:s');

     $end_dt = new DateTime($end.' 23:59:59');
     $e = $end_dt->format('Y-m-d H:i:s');
   
     $sql = $wpdb->prepare("SELECT ID FROM $user_table WHERE 1=1 AND CAST(user_registered AS DATE) BETWEEN %s AND %s ORDER BY user_login ASC",$s,$e);
     $users = $wpdb->get_results($sql);

     return $users;
}



$start_date='2015-02-14';  // registration date
$end_date='2015-04-17';  // registration date
$users= get_users_registered_between_date($start_date, $end_date ); // users list between date  '2015-02-14' and '2015-04-17'

require_once(ABSPATH.'wp-admin/includes/user.php' );
foreach($users as $usr){
    $user_id= $usr->ID;
    $roles= array();
    $user = get_userdata( $user_id );
    $capabilities = $user->{$wpdb->prefix . 'capabilities'};

    if ( !isset( $wp_roles ) )
        $wp_roles = new WP_Roles();

    foreach ( $wp_roles->role_names as $role => $name ) :

        if ( array_key_exists( $role, $capabilities ) )
            $roles[]=$role;

    endforeach;
   
    if (!in_array("administrator", $roles)) {
       if(wp_delete_user($user_id)){
        echo 'User deleted'.$user_id;
        echo '<br>';
      }
    
    } 
}

Friday, June 10, 2016

Wordpress- Delete user programatically

global $wpdb;
$curr_date= date('Ymd');

require_once(ABSPATH.'wp-admin/includes/user.php' );
$users = get_users(array(
    'meta_key'     => 'user_delete_date',
    'meta_value'  => "$curr_date",
));

foreach($users as $usr){
    $user_id= $usr->ID;
    $roles= array();
    $user = get_userdata( $user_id );
    $capabilities = $user->{$wpdb->prefix . 'capabilities'};

    if ( !isset( $wp_roles ) )
        $wp_roles = new WP_Roles();

    foreach ( $wp_roles->role_names as $role => $name ) :

        if ( array_key_exists( $role, $capabilities ) )
            $roles[]=$role;

    endforeach;
  
    if (!in_array("administrator", $roles)) {
       if(wp_delete_user($user_id)){
        echo 'User deleted'.$user_id;
        echo '<br>';
      }
   
    }
}

Thursday, May 19, 2016

Magento- Magento Sort Attribute by Decimal not Alphanumerically

The best solution I found was to override the ORDER BY for the query by calling a primitive method of the Collection class, here's the example they give:

$_productCollection = Mage::getModel('catalog/product')->getCollection();
$_productCollection->setOrder('weight', 'asc');
$_productCollection->getSelect()->reset(Zend_Db_Select::ORDER);
$_productCollection->getSelect()->order('CAST(`weight` AS SIGNED) ASC'));

Thursday, May 12, 2016

JavaScript - Fullscreen API JavaScript Code

<p>
  <label>Click the button below to toggle fullscreen</label><br>
  <button id="btnFullscreen" type="button">Toggle Fullscreen</button>
</p>
<p>
<img id="exampleImage" src="https://aftabhusain.files.wordpress.com/2016/06/my-wp-profile-page.png">
</p>

<script>
function toggleFullscreen(elem) {
  elem = elem || document.documentElement;
  if (!document.fullscreenElement && !document.mozFullScreenElement &&
    !document.webkitFullscreenElement && !document.msFullscreenElement) {
    if (elem.requestFullscreen) {
      elem.requestFullscreen();
    } else if (elem.msRequestFullscreen) {
      elem.msRequestFullscreen();
    } else if (elem.mozRequestFullScreen) {
      elem.mozRequestFullScreen();
    } else if (elem.webkitRequestFullscreen) {
      elem.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
    }
  } else {
    if (document.exitFullscreen) {
      document.exitFullscreen();
    } else if (document.msExitFullscreen) {
      document.msExitFullscreen();
    } else if (document.mozCancelFullScreen) {
      document.mozCancelFullScreen();
    } else if (document.webkitExitFullscreen) {
      document.webkitExitFullscreen();
    }
  }
}

document.getElementById('btnFullscreen').addEventListener('click', function() {
  toggleFullscreen();
});

document.getElementById('exampleImage').addEventListener('click', function() {
  toggleFullscreen(this);
});

/*
if (document.addEventListener)
{
    document.addEventListener('webkitfullscreenchange', exitHandler, false);
    document.addEventListener('mozfullscreenchange', exitHandler, false);
    document.addEventListener('fullscreenchange', exitHandler, false);
    document.addEventListener('MSFullscreenChange', exitHandler, false);
}

function exitHandler()
{
  if (!document.fullscreenElement && !document.mozFullScreenElement &&
        !document.webkitFullscreenElement && !document.msFullscreenElement) {
      jQuery('.click-to-full-scr').html('Full Screen');
      jQuery('#toPopup_photodet').removeClass('done-fullscreen');
  }
}*/
</script>

Sunday, May 1, 2016

Google Map- How to add Google Maps Autocomplete search box?


<html>
<head>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places"></script>
</head>
<body>
<input id="searchTextField" type="text" size="50">
<script>
function initialize() {

var input = document.getElementById('searchTextField');
var autocomplete = new google.maps.places.Autocomplete(input);
}

google.maps.event.addDomListener(window, 'load', initialize);
</script>
</body>
</html>

Thursday, April 28, 2016

jQuery- Count characters in textarea

Topic: 1.Character Counting Remaining on textarea using jQuery.
Topic: 2. jQuery- Count characters in textarea
Topic: 3. How can I count characters in textarea on onkeyup() event using jQuery?
 
We can find above topics solutions in below code.

 
<!DOCTYPE html>
<html>
  <head>
    <script src="http://code.jquery.com/jquery-1.5.js"></script>
    <script>
      function countChar(val) {
        var len = val.value.length;
        if (len >= 500) {
          val.value = val.value.substring(0, 500);
        } else {
          $('#charNum').text(500 - len);
        }
      };
    </script>
  </head>

  <body>
    <textarea id="field" onkeyup="countChar(this)"></textarea>
    <div id="charNum"></div>
  </body>

</html>

Wednesday, April 27, 2016

Magento- upload multiple files with Varien_File_Uploader

Topic 1:  upload  file with Varien_File_Uploader .
Topic 2:  How can I upload image using Varien_File_Uploader in magento?
Topic 3:  Upload image using default magento function.

We can find above topic's solution in below code.
 

 if(isset($_FILES['add_image']['name']) && $_FILES['add_image']['name'] != '') {
            try {
                /* Starting upload */
                $uploader = new Varien_File_Uploader('add_image');

                // Any extention would work
                $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
                $uploader->setAllowRenameFiles(false);

                $uploader->setFilesDispersion(true);

                // We set media as the upload dir
                $path = Mage::getBaseDir('media') . DS . 'projectphoto' . DS . 'image' . DS;
                $uploader->save($path, $_FILES['add_image']['name'] );
                echo '-->'.$img_name = $uploader->getUploadedFileName();
            } catch (Exception $e) {

            }
        }

Thursday, April 21, 2016

jQuery- get multiple image's file name on browse image

Topic: 1.jQuery- get multiple image's file name on browse image
Topic: 2. How can I get file's name on browse the image?
  
We can find above topics solutions in below code.


<input type="file" id="inputFile" name="award_images[]" multiple />

<script>
jQuery("#inputFile").change(function (event) {
   var files = event.target.files;
    for(var i=0; i < files.length; i++) {
        var f = files[i];
        alert(f.name);
    }
});
</script>

magento- uplaod mupltile images using Varien_File_Uploader(

Topic 1:  upload multiple files with Varien_File_Uploader .
Topic 2:  How can I upload multiple images using Varien_File_Uploader in magento?
Topic 3:  Upload multiple images using default magento function.


We can find above topic's solution in below code.

<?php
if(isset($_FILES['award_images']) and $_FILES['award_images']['name'][0] != ''){
                 
                    $extension=array("jpeg","jpg","png","gif");
                        foreach($_FILES["award_images"]["tmp_name"] as $key=>$tmp_name)
                        {
                           
                                $uploader = new Varien_File_Uploader(
                                        array(
                                    'name' => $_FILES['award_images']['name'][$key],
                                    'type' => $_FILES['award_images']['type'][$key],
                                    'tmp_name' => $_FILES['award_images']['tmp_name'][$key],
                                    'error' => $_FILES['award_images']['error'][$key],
                                    'size' => $_FILES['award_images']['size'][$key]
                                        )
                                );
                               
                                $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png')); // or pdf or anything
                                $uploader->setAllowRenameFiles(false);
                                $uploader->setFilesDispersion(false);
                                $imgname= $file_name;        
                                $path = Mage::getBaseDir('media') . DS . 'awardimage/image/';
                                $img = $uploader->save($path, $_FILES['award_images']['name'][$key]);
                               
                            
       
                        }
                  
                 }
?>

Wednesday, March 23, 2016

Wordpress- How to Create Custom Controls for the WordPress Theme Customizer

If we want to add textarea under Theme Customizer, we use the below code.

Put the below code in function.php

/*Customizer1 Code HERE*/
add_action('customize_register', 'theme_bannertext1_customizer' , 11);
function theme_bannertext1_customizer($wp_customize){
 //adding section in wordpress customizer  
    $wp_customize->add_section('banne1_settings_section', array(
      'title'          => 'Banner Text 1'
     ));
    //adding setting for footer text area
    $wp_customize->add_setting('banne1_settings_section', array(
     'default'        => 'Modern Axure template for Beautiful prototypes',
     ));
    $wp_customize->add_control('banne1_settings_section', array(
     'label'   => 'Banner Text1 Here',
      'section' => 'banne1_settings_section',
     'type'    => 'textarea',
    ));

 }

 /*Customizer2 Code HERE*/
add_action('customize_register', 'theme_bannertext2_customizer' , 12);
function theme_bannertext2_customizer($wp_customize){
 //adding section in wordpress customizer  
    $wp_customize->add_section('banne2_settings_section', array(
      'title'          => 'Banner Text 2'
     ));
    //adding setting for footer text area
    $wp_customize->add_setting('banne2_settings_section', array(
     'default'        => 'Modern Axure template for Beautiful prototypes',
     ));
    $wp_customize->add_control('banne2_settings_section', array(
     'label'   => 'Banner Text1 Here',
      'section' => 'banne2_settings_section',
     'type'    => 'textarea',
    ));

 }

Tuesday, March 22, 2016

Wordpress- Create Database Tables When on plugin actication hook

//create table               
function creat_table_on_actvation() {
         global $wpdb;
        $your_table_name = $wpdb->prefix . 'custom_contact_us';
     
        $sql = "CREATE TABLE IF NOT EXISTS " . $your_table_name . " (
          `id` int(11) NOT NULL AUTO_INCREMENT,
          `contact_name` varchar(255) NOT NULL,
          `contact_email` varchar(255) NOT NULL,
          `contact_subject` varchar(255) NOT NULL,
          `contact_message` text NOT NULL,
          `status` int(11) NOT NULL,
          `date_time` datetime NOT NULL,
          PRIMARY KEY (`id`)
        )";
        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
        dbDelta($sql);
}
// run the install scripts upon plugin activation
register_activation_hook(__FILE__,'creat_table_on_actvation');

PayPal - Adaptive Chained Payments

<?php

class PaypalTest {

public $api_user = "XXXXXXXXXXXXXXXXXXXXXX";
public $api_pass = "XXXXXXXXXXXXXXXXX";
public $api_sig = "XXXXXXXXXXXXXXXXXXXXXXX";
public $app_id = "APP-80W284485P519543T";
public $apiUrl = 'https://svcs.sandbox.paypal.com/AdaptivePayments/';
//public $paypalUrl="https://www.paypal.com/webscr?cmd=_ap-payment&paykey=";
public $paypalUrl="https://sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=";
public $headers;

public function __construct(){
    $this->headers = array(
        "X-PAYPAL-SECURITY-USERID: ".$this->api_user,
        "X-PAYPAL-SECURITY-PASSWORD: ".$this->api_pass,
        "X-PAYPAL-SECURITY-SIGNATURE: ".$this->api_sig,
        "X-PAYPAL-REQUEST-DATA-FORMAT: JSON",
        "X-PAYPAL-RESPONSE-DATA-FORMAT: JSON",
        "X-PAYPAL-APPLICATION-ID: ".$this->app_id,
    );
  
    $this->envelope= array(
            "errorLanguage" => "en_US",
            "detailLevel" => "ReturnAll",
        );
  
  
}

public function getPaymentOptions($paykey){

//echo $paykey; die;
   $packet = array(
          "requestEnvelope" => $this->envelope ,
          "payKey" => $paykey
   );
 
   return $this->_paypalSend( $packet ,'GetPaymentOptions');
}

public function _paypalSend($data,$call){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $this->apiUrl.$call);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
    curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
    $response = json_decode(curl_exec($ch),true);
    return $response;

}

public function splitPay(){


    // create the pay request
    $createPacket = array(
        "actionType" =>"PAY_PRIMARY",
        "applicationId" =>"APP-80W284485P519543T",
        "currencyCode" => "USD",
        "receiverList" => array(
            "receiver" => array(
               array(
                    "amount"=> "7.00",
                    "primary" => true,
                    "email"=>"primary-reciever@gmail.com"
                ),
                array(
                    "amount"=> "3.00",
                    "primary" => false,
                    "email"=>"secondary-reciever@gmail.com"
                ),
            ),
        ),
        "returnUrl" => "http://your-site-url/confirm.php",
        "cancelUrl" => "http://your-site-url//cancel.php",
        "requestEnvelope" => $this->envelope
    );

    $response = $this->_paypalSend($createPacket,"Pay");
  
  
    
    $paykey =  $response['payKey'];
    //echo '9999<pre>'; print_r($response);
  
    //SET payment details
  
     $detailsPacket=array(
"requestEnvelope" =>$this->envelope,
"payKey" => $paykey,
"receiverOptions" => array(
    array(
    "receiver" => array("email" => "primary-reciever@gmail.com"),
            "invoiceData" => array(
                "item" => array(
                    array(
                        "name" => "product1",
                        "price" => "7.00",
                        "identifier" => "p1"
                    ),
                   )
            )
    ),
    array(
        "receiver" => array("email" => 'secondary-reciever@gmail.com'),
        "invoiceData" => array(
        "item" => array(
            array(
                "name" => "product1",
                "price" => "3.00",
                "identifier" => "p1"
            ),
        )
      )
    ),
)
);


    $response1 = $this->_paypalSend($detailsPacket,"SetPaymentOptions");
  
  
    //$dets= $this->getPaymentOptions($paykey);
    $dets= $this->getPaymentOptions($paykey);
  
  

    $msg = $paykey;
  
    mail("amu02.aftab@gmail.com","My subject",$msg);
    //echo $this->paypalUrl.$paykey; die;
    header("Location: ".$this->paypalUrl.$paykey);
}

    public function _paymentExecute($url, $data){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
        curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
        $response = json_decode(curl_exec($ch),true);
        return $response;
    }

}


if($_GET['exe_pay'] == 1){
  
    $url = "https://svcs.sandbox.paypal.com/AdaptivePayments/ExecutePayment";
  
    $payment = new PaypalTest();
    
    $packet = array(
          "requestEnvelope" => $payment->envelope,
          "payKey" => "AP-96831732KV5898725"
   );
    $response = $payment->_paymentExecute($url, $packet);
    echo '<pre>';print_r($response);
}elseif($_GET['get_info'] == 1){
    $url = "https://svcs.sandbox.paypal.com/AdaptivePayments/PaymentDetails";
  
    $payment = new PaypalTest();
  
    $packet = array(
          "requestEnvelope" => $payment->envelope,
          "payKey" => "AP-96831732KV5898725"
   );
    $response = $payment->_paymentExecute($url, $packet);
    echo '<pre>';print_r($response);
}else{
      
      
    $payment = new PaypalTest();
    $payment->splitPay();
  
}?>

PayPal - Adaptive parallel Payments

<?php
class PaypalTest {

public $api_user = "XXXXXXXXXXXXXXXXXXXXXXXXXXX";
public $api_pass = "XXXXXXXXXXXXXXXXXXXX";
public $api_sig = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
public $app_id = "APP-80W284485P519543T";
public $apiUrl = 'https://svcs.sandbox.paypal.com/AdaptivePayments/';
//public $paypalUrl="https://www.paypal.com/webscr?cmd=_ap-payment&paykey=";
public $paypalUrl="https://sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=";
public $headers;

public function __construct(){
    $this->headers = array(
        "X-PAYPAL-SECURITY-USERID: ".$this->api_user,
        "X-PAYPAL-SECURITY-PASSWORD: ".$this->api_pass,
        "X-PAYPAL-SECURITY-SIGNATURE: ".$this->api_sig,
        "X-PAYPAL-REQUEST-DATA-FORMAT: JSON",
        "X-PAYPAL-RESPONSE-DATA-FORMAT: JSON",
        "X-PAYPAL-APPLICATION-ID: ".$this->app_id,
    );
    $this->envelope= array(
            "errorLanguage" => "en_US",
            "detailLevel" => "ReturnAll",
        );
}

public function getPaymentOptions($paykey){

   $packet = array(
          "requestEnvelope" => $this->envelope ,
          "payKey" => $paykey
   );
  
   return $this->_paypalSend( $packet ,'GetPaymentOptions');
}

public function _paypalSend($data,$call){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $this->apiUrl.$call);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
    curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
    $response = json_decode(curl_exec($ch),true);
    return $response;

}
public function splitPay(){
    // create the pay request
    $createPacket = array(
        "actionType" =>"PAY",
        "currencyCode" => "USD",
        "receiverList" => array(
            "receiver" => array(
               array(
                    "amount"=> "2.00",
                    "email"=>"First Reciever Email"
                ),
                array(
                    "amount"=> "2.00",
                    "email"=>"Second Reciever Email"
                ),
            ),
        ),
        "returnUrl" => "http://your-site/confirm.php",
        "cancelUrl" => "http://your-site/cancel.php",
        "requestEnvelope" => $this->envelope
    );

    $response = $this->_paypalSend($createPacket,"Pay");
    $paykey =  $response['payKey'];
    //SET payment details
   
     $detailsPacket=array(
"requestEnvelope" =>$this->envelope,
"payKey" => $paykey,
"receiverOptions" => array(
    array(
    "receiver" => array("email" => "First Reciever Email"),
            "invoiceData" => array(
                "item" => array(
                    array(
                        "name" => "product1",
                        "price" => "2.00",
                        "identifier" => "p1"
                    ),
                   )
            )
    ),
    array(
        "receiver" => array("email" => 'Second Reciever Email'),
        "invoiceData" => array(
        "item" => array(
            array(
                "name" => "product1",
                "price" => "2.00",
                "identifier" => "p1"
            ),
        )
      )
    ),
)
);


    $response = $this->_paypalSend($detailsPacket,"SetPaymentOptions");
    $dets= $this->getPaymentOptions($paykey);
   
   
      header("Location: ".$this->paypalUrl.$paykey);
}
}


$payment = new PaypalTest();
$payment->splitPay();

?>

Friday, March 18, 2016

WORDPRESS- Replacing a textarea with WordPress TinyMCE wp_editor()

WORDPRESS- Replacing a textarea with WordPress TinyMCE wp_editor()

$content= 'default content';
$editor_id ='textarea_id';
$settings = array( 'textarea_name' => 'post_text' );
wp_editor( $content, $editor_id, $settings );

Monday, March 14, 2016

Magento- Custom RWD default magento slider

Magento- Custom RWD default magento slider


<?php   $dynemicid = 1?>
                 <div class="class-toPopup" id="toPopup_<?php echo $dynemicid;?>" >
         
                <div class="slider-background">
                    <div class="slideshow-container-pop<?php echo $dynemicid;?>">
                        <ul class="slideshow">
                        <li><a href="javascript:void(0);"><img alt="" src="PUT IMAGE URL HRE" /> </a></li>
                        <li><a href="javascript:void(0);"><img alt="" src="PUT IMAGE URL HRE" /> </a></li>
                        <li><a href="javascript:void(0);"><img alt="" src="PUT IMAGE URL HRE" /> </a></li>
                        <li><a href="javascript:void(0);"><img alt="" src="PUT IMAGE URL HRE" /> </a></li>
                        <li><a href="javascript:void(0);"><img alt="" src="PUT IMAGE URL HRE" /> </a></li>
                        <li><a href="javascript:void(0);"><img alt="" src="PUT IMAGE URL HRE" /> </a></li>
                        <li><a href="javascript:void(0);"><img alt="" src="PUT IMAGE URL HRE" /> </a></li>
                        <li><a href="javascript:void(0);"><img alt="" src="PUT IMAGE URL HRE" /> </a></li>
                        <li><a href="javascript:void(0);"><img alt="" src="PUT IMAGE URL HRE" /> </a></li>
                       
                        </ul>
                    <div class="slideshow-pager<?php echo $dynemicid;?>">&nbsp;</div>
                    <span class="slideshow-prev">Previous</span>
                    <span class="slideshow-next">Next</span>
                    </div>
                </div>
              
                </div>
              
                <style>
                .slideshow-pager<?php echo $dynemicid;?> {
                    -moz-user-select: none;
                    overflow-x: hidden;
                    overflow-y: hidden;
                    position: absolute;
                    text-align: center;
                    top: auto;
                    width: 100%;
                    z-index: 115;
                }
                .slideshow-pager<?php echo $dynemicid;?> span {
                 color: #dddddd;
                    cursor: pointer;
                    display: inline-block;
                    font-family: "Roboto",sans-serif;
                    height: 10px;
                    width: 10px;
                }
                .slideshow-pager<?php echo $dynemicid;?> span:before {
                 background-color: #ccc;
                    border-radius: 10px;
                    content: "";
                    display: block !important;
                    height: 8px;
                    left: 50%;
                    margin-left: -8px;
                    margin-top: -8px;
                    position: relative;
                    top: 50%;
                    width: 8px;
                }
                .slideshow-pager<?php echo $dynemicid;?> span:hover:before {
                  background-color: #fff;
                  border:1px #999 solid;
                }
                .slideshow-pager<?php echo $dynemicid;?> span.cycle-pager-active:before {
                  background-color: #fff;
                  border:1px #999 solid;
                }
                .slideshow-pager<?php echo $dynemicid;?> > * {
                  cursor: pointer;
                }
      
                </style>
              
            <script>          

            $j(document).ready(function () {
          
                 $j('.slideshow-container-pop<?php echo $dynemicid;?> .slideshow').cycle({
                    slides: '> li',
                    pager: '.slideshow-pager<?php echo $dynemicid;?>',
                    pagerTemplate: '<span class="pager-box"></span>',
                    speed: 600,
                    pauseOnHover: true,
                    swipe: true,
                    prev: '.slideshow-prev',
                    next: '.slideshow-next',
                    fx: 'scrollHorz',
                    timeout: 0
                });  
        });
        </script>  
        <!--popup slide-->

Wednesday, March 9, 2016

PHP- check if image exists php

if (getimagesize($user_profilr_pic_url) !== false) {
                echo 'Image Exist';
            }else{
                 echo 'Image Does Not Exist';
            }

Friday, February 26, 2016

WORDPRESS-How to Create a Custom MetaBox With Color Picker?

Step 1 – Register Custom Metabox

function aft_add_meta_box() {
    add_meta_box('aft_sectionid', 'Post Background', 'aft_meta_box_callback', 'post');
}

add_action( 'add_meta_boxes', 'aft_add_meta_box' );

Step 2 – Creating Custom Metabox

function aft_meta_box_callback( $post ) {
    wp_nonce_field( 'aft_meta_box', 'aft_meta_box_nonce' );
    $color = get_post_meta( $post->ID, 'country_bg_color', true );
    ?>
    <script>
    (function( $ ) {
        // Add Color Picker to all inputs that have 'color-field' class
        $(function() {
        $('.color-field').wpColorPicker();
        });
    })( jQuery );
    </script>
    <div class="custom_meta_box">
    <p>
    <label>Select Post Background Color: </label>
    <input class="color-field" type="text" name="country_bg_color" value="<?php if($color !=''){ echo '#'.$color; } ?>"/>
    </p>
    <div class="clear"></div>
    </div>
    <?php
}

Step 3 – Saving Metabox

function aft_save_meta_box_data( $post_id ) {
    if ( !isset( $_POST['aft_meta_box_nonce'] ) ) {
        return;
    }

    if ( !wp_verify_nonce( $_POST['aft_meta_box_nonce'], 'aft_meta_box' ) ) {
        return;
    }
    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
        return;
    }
    if ( !current_user_can( 'edit_post', $post_id ) ) {
        return;
    }
   
    $country_bg_color = ( isset( $_POST['country_bg_color'] ) ? sanitize_html_class( $_POST['country_bg_color'] ) : '' );
    update_post_meta( $post_id, 'country_bg_color', $country_bg_color );
}
add_action( 'save_post', 'aft_save_meta_box_data' );

Thursday, February 18, 2016

wordpress-Change upload directory in worpress

let's say you upload a picture. After you upload it, you can view the file at something like:
example.org/wp-content/uploads/2014/12/picture.png
And let's say you now change the uploads folder location via:
Now you need to change in wp-config.php
define('UPLOADS', 'wp-content/media');
This will give you a URL like this:
example.org/wp-content/media/2014/12/picture.png
Hope this will help!

Wordpress-What is the limitation to the depth of your categories?

There is no limitation level to the depth.

Wordpress-How many tables default WordPress have? Can you name those default WordPress table?

The default version of WordPress is incorporated with 11 tables. They are-
  • wp_options
  • wp_users
  • wp_links
  • wp_commentmeta
  • wp_term_relationships
  • wp_postmeta
  • wp_posts
  • wp_term_taxonomy
  • wp_usermeta
  • wp_terms
  • wp_comments

Wednesday, February 10, 2016

PHP-Simplest way to detect a mobile device

<?php

$useragent=$_SERVER['HTTP_USER_AGENT'];

if(preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene

|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a

|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt

|kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)

|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)

|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4)))

header('Location: http://detectmobilebrowser.com/mobile');

?>

Tuesday, February 9, 2016

PHP - simple download script

   #setting headers
    header('Content-Description: File Transfer');
    header('Cache-Control: public');
    header('Content-Type: '.$type);
    header("Content-Transfer-Encoding: binary");
    header('Content-Disposition: attachment; filename='. basename($file));
    header('Content-Length: '.filesize($file));
    ob_clean(); #THIS!
    flush();
    readfile($file);

Saturday, February 6, 2016

Wordprss- Add Scroll To Top Button in Wordprss

 Add Scroll To Top Button in Wordprss

 

Step-1 Add this Div in footer.php


<div id="back_top" style="display: block;"></div>

Step-2 Add this Java script in footer.php


<script type="text/javascript">
    jQuery(function() {
        jQuery(window).scroll(function() {
        if(jQuery(this).scrollTop() > 300) {
            jQuery('#back_top').fadeIn();   
        } else {
            jQuery('#back_top').fadeOut();
        }
    });
       jQuery('#back_top').click(function() {
        jQuery('body,html').animate({scrollTop:0},500);
    });   
    });
 </script>

Step-3 Add this CSS in styles.css


<style type="text/css">
    #back_top {
    background-color: red;
    bottom: 22px;
    cursor: pointer;
    display: none;
    height: 44px;
    position: fixed;
    right: 200px;
    width: 54px;
}
</style>

Magento- Add Scroll To Top Button in Magento

Add Scroll To Top Button in Magento

Step-1 Add this Div in Footer.phtml


<div id="back_top" style="display: block;"></div>

Step-2 Add this Java script in footer.phtml


<script type="text/javascript">
    jQuery(function() {
        jQuery(window).scroll(function() {
        if(jQuery(this).scrollTop() > 300) {
            jQuery('#back_top').fadeIn();   
        } else {
            jQuery('#back_top').fadeOut();
        }
    });
       jQuery('#back_top').click(function() {
        jQuery('body,html').animate({scrollTop:0},500);
    });   
    });
 </script>

Step-3 Add this CSS in styles.css


<style type="text/css">
    #back_top {
    background-color: red;
    bottom: 22px;
    cursor: pointer;
    display: none;
    height: 44px;
    position: fixed;
    right: 200px;
    width: 54px;
}
</style>

Friday, February 5, 2016

PHP- Get distance between to Zipcodes using google map api

<?php
$zips= array();
$zips[]= 20899;
$zips[]= 20877;

$geocoded = array();
//$serviceUrl = "http://maps.googleapis.com/maps/api/geocode/json?components=postal_code:%s&sensor=false";
$serviceUrl = "http://maps.googleapis.com/maps/api/geocode/json?components=country:US|postal_code:%s&sensor=false";

$curl = curl_init();
foreach ($zips as $zip) {
    curl_setopt($curl, CURLOPT_URL, sprintf($serviceUrl, urlencode($zip)));
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
    $data = json_decode(curl_exec($curl));
    $info = curl_getinfo($curl);
    if ($info['http_code'] != 200) {
        // Request failed
    } else if ($data->status !== 'OK') {
        // Something happened, or there are no results
    } else {
        $geocoded[$zip] =$data->results[0]->geometry->location;
    }
}

$latitudeFrom = $geocoded[$zips[0]]->lat;
$longitudeFrom=  $geocoded[$zips[0]]->lng;
$latitudeTo= $geocoded[$zips[1]]->lat;
$longitudeTo= $geocoded[$zips[1]]->lng;

//echo $latitudeFrom.'<br>';
//echo $longitudeFrom.'<br>';
//echo $latitudeTo.'<br>';
//echo $longitudeTo.'<br>';

function distance($lat1, $lon1, $lat2, $lon2, $unit) {

  $theta = $lon1 - $lon2;
  $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +  cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
  $dist = acos($dist);
  $dist = rad2deg($dist);
  $miles = $dist * 60 * 1.1515;
  $unit = strtoupper($unit);

  if ($unit == "K") {
    return ($miles * 1.609344);
  } else if ($unit == "N") {
      return ($miles * 0.8684);
    } else {
        return $miles;
      }
}

echo distance($latitudeFrom, $longitudeFrom, $latitudeTo, $longitudeTo, "M") . " Miles<br>";
echo distance1($latitudeFrom, $longitudeFrom, $latitudeTo, $longitudeTo, "M") . " Miles<br>";
echo distance($latitudeFrom, $longitudeFrom, $latitudeTo, $longitudeTo, "K") . " Kilometers<br>";
echo distance($latitudeFrom, $longitudeFrom, $latitudeTo, $longitudeTo, "N") . " Nautical Miles<br>";



?>

PHP- Get Address Using Co-ordinates(lat Long)

PHP- Get Address Using Co-ordinates(lat Long)



$geolocation = $latitudeFrom.','.$longitudeFrom;
$request = 'http://maps.googleapis.com/maps/api/geocode/json?latlng='.$geolocation.'&sensor=false';
$file_contents = file_get_contents($request);
$json_decode = json_decode($file_contents);
if(isset($json_decode->results[0])) {
    $response = array();
    foreach($json_decode->results[0]->address_components as $addressComponet) {
        if(in_array('political', $addressComponet->types)) {
                $response[] = $addressComponet->long_name;
        }
    }

    if(isset($response[0])){ $first  =  $response[0];  } else { $first  = 'null'; }
    if(isset($response[1])){ $second =  $response[1];  } else { $second = 'null'; }
    if(isset($response[2])){ $third  =  $response[2];  } else { $third  = 'null'; }
    if(isset($response[3])){ $fourth =  $response[3];  } else { $fourth = 'null'; }
    if(isset($response[4])){ $fifth  =  $response[4];  } else { $fifth  = 'null'; }

    if( $first != 'null' && $second != 'null' && $third != 'null' && $fourth != 'null' && $fifth != 'null' ) {
        echo "<br/>Address:: ".$first;
        echo "<br/>City:: ".$second;
        echo "<br/>State:: ".$fourth;
        echo "<br/>Country:: ".$fifth;
    }
    else if ( $first != 'null' && $second != 'null' && $third != 'null' && $fourth != 'null' && $fifth == 'null'  ) {
        echo "<br/>Address:: ".$first;
        echo "<br/>City:: ".$second;
        echo "<br/>State:: ".$third;
        echo "<br/>Country:: ".$fourth;
    }
    else if ( $first != 'null' && $second != 'null' && $third != 'null' && $fourth == 'null' && $fifth == 'null' ) {
        echo "<br/>City:: ".$first;
        echo "<br/>State:: ".$second;
        echo "<br/>Country:: ".$third;
    }
    else if ( $first != 'null' && $second != 'null' && $third == 'null' && $fourth == 'null' && $fifth == 'null'  ) {
        echo "<br/>State:: ".$first;
        echo "<br/>Country:: ".$second;
    }
    else if ( $first != 'null' && $second == 'null' && $third == 'null' && $fourth == 'null' && $fifth == 'null'  ) {
        echo "<br/>Country:: ".$first;
    }
  }