Thursday 14 May 2015

How to get real ip address of a client in case client using proxy server ?

function getRealIPAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))   //to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}

How to view Docuement via Google ?


function google_docview($file_path,$file_name)
{
$file_location=$file_path.$file_name;
echo '<iframe  src="https://docs.google.com/gview?url='.$file_location.'&amp;embedded=true" style="width:100%; height:800px; text-align:center;" frameborder="0"></iframe>';
}

Example
/*
$file_path="sscet.comli.com/L_NOTES/";
$file_name="_1378281542_notes.docx";
google_docview($file_path,$file_name);
*/