Thursday, September 2, 2010

How to get the distance between to location using the google map?

When we calculate the distance between two lat & long the distance would the air to air so distance is wrong,so you have to send both  lat & long to google to get the driving distance.
Given  below the code for it.
//intiat curl
$ch = curl_init();
//pass the  both start and end lat & long
//check google map doc for option
//mode=driving is for driving distance
//sensor=false for site ,for mobile then it is true
//reponse is json
curl_setopt($ch, CURLOPT_URL,
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $contents = curl_exec ($ch);

Working with php & ffmpeg

This the code for convert video using the ffmpeg.The php use the ffmpeg insstall in Linux system.
for the option please out the web site of ffmpeg

$uploadfile = "t1.3gp";
$uploadfile_flv = "video.flv";

//shell_exec('ffmpeg -i  '.$uploadfile.' -acodec libmp3lame -map_meta_data '.$uploadfile_flv.':'.$uploadfile.' -ar 22050 -ab 64000 -deinterlace -nr 500 -s 320x240 -aspect 4:3 -r 20 -g 500 -me_range 20 -b 200k -f flv -y '.$uploadfile_flv);

shell_exec('ffmpeg -i  '.$uploadfile.' -ar 22050 -ab 64000 -deinterlace -nr 500 -s 320x240 -aspect 4:3 -r 20 -g 500 -me_range 20 -b 200k -f flv -y '.$uploadfile_flv);

echo ('ffmpeg -i  '.$uploadfile.' -ar 22050 -ab 64000 -deinterlace -nr 500 -s 320x240 -aspect 4:3 -r 20 -g 500 -me_range 20 -b 200k -f flv -y '.$uploadfile_flv);

//$flvMetaUpdateCmd = "flvtool2 -U ".$uploadfile_flv;

$uploaddir = "./";
$png_file_name = "preview";

shell_exec("ffmpeg -i ".$uploadfile." -vcodec png -ss 00:00:05 -vframes 1 -an -f rawvideo -s 320x240 -y ".$uploaddir.$png_file_name.".png");

echo "

File Converted...";


How to create the application.ini in zend

 The code explain every thing
//this for all error  reporting
// Define path to application directory
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),


/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_PATH . '/configs/application.ini'
//to store the object/array/var in system use the register
 require_once 'Zend/Registry.php';
//this for mysql connection
 require_once 'Zend/Db/Adapter/Pdo/Mysql.php';

 Zend_Registry::set('varname',"value of var");
//there are two way of setting the database connection
//first by setting the using the Zend_Db_Adapter_Pdo_Mysql
//second using the Zend_Db:factory
/*$params = array('host' =>'localhost',
                'username' =>'root',
'password'  =>'password',
'dbname' =>'zend'
 $db=new Zend_Db_Adapter_Pdo_Mysql($params);
//this for load the application varibles,first parametes is application ini path & second is
//blok in application ini
 $config=new Zend_Config_Ini(APPLICATION_PATH.'/configs/application.ini','general');
 $db= Zend_Db::factory($config->db->adapter,$config->db->params->toArray());