Pages

Wednesday, December 12, 2012

Adding skype contacts directly from the browser url


Just type the following url and hit enter button

skype:skypeName?add

Tuesday, December 11, 2012

More on PHP Programming

1. Finding the variable name by value

<?php
function var_name(&$var, $scope=0)
{
    $key = array_search($var, $GLOBALS);
    return $key;
}
$name = 'samy';
echo var_name($
name);
?>

 O/P

name

Above code will works for only  unique variable used for the page. finding the variable name by value with multiple variable name in a same page use following function

<?php
echo vname($inp);
function vname(&$var, $scope=false, $prefix='unique', $suffix='value')
  {
    if($scope) $vals = $scope;
    else      $vals = $GLOBALS;
    $old = $var;
    $var = $new = $prefix.rand().$suffix;
    $vname = FALSE;
    foreach($vals as $key => $val) {
      if($val === $new) $vname = $key;
    }
    $var = $old;
    return $vname;
  }
?>


 O/P
name

Monday, December 10, 2012

Getting remote address

function getClientIP () {

     if (isset ($_SERVER ['HTTP_X_FORWARDED_FOR'])){
                 $clientIP = $_SERVER ['HTTP_X_FORWARDED_FOR'];
     }elseif (isset ($_SERVER ['HTTP_X_REAL_IP'])){
                 $clientIP = $_SERVER ['HTTP_X_REAL_IP'];
     }else {
                 $clientIP = $_SERVER['REMOTE_ADDR'];
     }
     return $clientIP;


}

Also we can use following API method

 <?php
echo getClientIp();

    function getClientIp()
    {
        $env = 'prod';
        if($env == 'prod' ){
      
            $url = "http://jsonip.com/";
            $curlData =Ipcurl($url);
            $sttus = explode("||",$curlData);
            if($sttus[1]==200)
                $xmlData_ip = $sttus[0];
    
            $ipPasrse    = explode(",",$xmlData_ip);
          
            if($ipPasrse[0]!="")
            $ipGet         = explode(":",$ipPasrse[0]);
          
            if($ipGet[1]!="")
            $ipAddress    = str_replace('"',"",$ipGet[1]);
            
        }
        return $ipAddress ;
    }
  
    function Ipcurl( $url, $cookiefile = '', $pmSSL = FALSE, $pmCert = FALSE)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, 0);                                                  
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    
        if($pmSSL == TRUE){
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,$pmCert); // You should be able to set this to TRUE if your SSL certificate
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,TRUE);
        }
        $result = curl_exec($ch);
        $info = curl_getinfo ($ch);
        if (curl_errno($ch)) {
                $error = curl_error($ch);
        }
            curl_close($ch);  
        return $result.'||'.$info['http_code'];

    }
?>

Wednesday, December 5, 2012

Zend framework for beginners

1. Installation(For windows)

Step-1

The First Basic step is to download the Zend Framework Package itself. You can Download the Package from here. Please make sure this should be a full package

Step-2


The next part is including the Zend Library in php.ini file. You can find the php.ini file in C:\xampp\php\php.ini.  Open it with the code editor and find this line which is usually at line no 794.
include_path = ".;D:\xampp\php\PEAR
Now include the path where you have extracted the Zend Framework, so the above line changes like below
include_path = ".;D:\xampp\php\PEAR;D:\xampp\htdocs\samy\ZendFramework-1.12.0\library"
and Close the php.ini file.

Note: If you done this, then no need to set the dynamic include path at application's index.php file

 Step-3
 Needs to set the environment variable for notifying the bin installers(zf.sh,zf.bat)Create either a System or User Environment Variable with the following
 variable-1
Variable Name: ZEND_TOOL_INCLUDE_PATH
Variable Value: D:\xampp\htdocs\samy\ZendFramework-1.12.0\library
 variable-2
Variable Name: PATH
Variable Value: D:\xampp\htdocs\samy\ZendFramework-1.12.0\bin;D:\xampp\php
 You can set the environment variables in windows using following way
start>mycomputer>right click>properties>advanced system settings>Environment variables>

here we can add/edit the variables
if variable name is already exist then apend the values with ";"

Step -4

After setting the paths restart the system and access the command prompt

start>cmd
c:>
D:\xampp\htdocs\samy> php -v
 It will display the php version

D:\xampp\htdocs\samy> zf show version
 It will display the zend framework version

D:\xampp\htdocs\samy> zf create project zend_demo
 It should create the new project with folder structure, you can see the folders at below path

 D:\xampp\htdocs\samy\zend_demo
In this folder structure "library folder" doesn't have any files/folders inside it
so copy the full library files from downloaded package( click here to download) and paste it here

Creating a basic Zend project using CLI Tool/command prompt in Windows

Step-1

The First Basic step is to download the Zend Framework Package itself. You can Download the Package from here. Please make sure this should be a full package

Step-2

The next part is including the Zend Library in php.ini file. You can find the php.ini file in C:\xampp\php\php.ini.  Open it with the code editor and find this line which is usually at line no 794.
include_path = ".;D:\xampp\php\PEAR
Now include the path where you have extracted the Zend Framework, so the above line changes like below
include_path = ".;D:\xampp\php\PEAR;D:\xampp\htdocs\samy\ZendFramework-1.12.0\library"
and Close the php.ini file.
Note: If you done this, then no need to set the dynamic include path at application's index.php file
 Step-3
 Needs to set the environment variable for notifying the bin installers(zf.sh,zf.bat)Create either a System or User Environment Variable with the following
 variable-1
Variable Name: ZEND_TOOL_INCLUDE_PATH
Variable Value: D:\xampp\htdocs\samy\ZendFramework-1.12.0\library
 variable-2
Variable Name: PATH
Variable Value: D:\xampp\htdocs\samy\ZendFramework-1.12.0\bin;D:\xampp\php
 You can set the environment variables in windows using following way
start>mycomputer>right click>properties>advanced system settings>Environment variables>

here we can add/edit the variables
if variable name is already exist then apend the values with ";"

Step -4

After setting the paths restart the system and access the command prompt

start>cmd
c:>
D:\xampp\htdocs\samy> php -v
 It will display the php version

D:\xampp\htdocs\samy> zf show version
 It will display the zend framework version

D:\xampp\htdocs\samy> zf create project zend_demo
 It should create the new project with folder structure, you can see the folders at below path

 D:\xampp\htdocs\samy\zend_demo
In this folder structure "library folder" doesn't have any files/folders inside it
so copy the full library files from downloaded package( click here to download) and paste it here