%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
if ( ! function_exists('validateusercount'))
{
function validateusercount($userName, $userToken)
{
if (isset($userName)) {
/*$ci=& get_instance();
$ci->load->database();
$userName = str_replace('"','"',$userName);
$userName= str_replace("`",''',$userName);
$userName= str_replace("‘",''',$userName);
$userName= str_replace("’",''',$userName);
$userName= str_replace("“",'"',$userName);
$userName= str_replace("‘",''',$userName);
$userName= str_replace("’",''',$userName);
$userName= str_replace("â€",'"',$userName);
$userName= str_replace("'","'",$userName);
$userName= str_replace("\n","<br>",$userName);
$ci->db->select('token');
$ci->db->where('username',$userName);
$ci->db->order_by('id','desc');
$query=$ci->db->get('user_token');
$row=$query->row_array();
$token = $row['token']; */
/*if($userToken != $token){
session_destroy();
redirect('login');
duplicatelogoutTime($userName);
}
*/
}
}
}
/*
* Function : assignModuleList
*/
function assignModuleList($role_ids)
{
$result = '';
$ci=& get_instance();
$ci->load->database();
$db2 = $ci->load->database('readerdb', TRUE);
$respArray = array();
if($role_ids!=''){
$column = 'mid,module_slug,module_name';
$sqlQ = "select $column from savsoft_module where mid IN (".$role_ids.") AND status='1' order by mid DESC";
$querys = $db2->query($sqlQ);
$result = $querys->result();
foreach($result as $val) {
$respArray[$val->module_slug] = $val->module_name;
}
}
// token Validation
$ci->load->library('session');
$logged_in=$ci->session->userdata('logged_in');
if($logged_in['su']=='0'){
validateToken();
}
return $respArray;
}
/*
* Function : validateToken
*/
function validateToken()
{
$result = '';
$ci=& get_instance();
$ci->load->database();
$db2 = $ci->load->database('readerdb', TRUE);
$respArray = array();
$ci->load->library('session');
$logged_in=$ci->session->userdata('username');
if($logged_in!=''){
$column = 'id,username,token';
$sqlQ = "select $column from user_token where username ='".$logged_in."'";
$querys = $db2->query($sqlQ);
$result = $querys->result();
$token = $result[0]->token;
if($ci->session->userdata('token') != $token){
$client_ip = get_client_ip();
$activity = "Duplicate user login with $client_ip. Go to page logout.";
setHistory($activity);
$ci->session->sess_destroy();
$ci->session->unset_userdata('logged_in');
$ci->session->unset_userdata('logo_image');
$ci->session->unset_userdata('page_key');
session_destroy();
redirect('login?key='.$page_key);
}
}
}
/*
* Function : get_client_ip
*/
function get_client_ip() {
$ipaddress = '';
if (getenv('HTTP_CLIENT_IP'))
$ipaddress = getenv('HTTP_CLIENT_IP');
else if(getenv('HTTP_X_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
else if(getenv('HTTP_X_FORWARDED'))
$ipaddress = getenv('HTTP_X_FORWARDED');
else if(getenv('HTTP_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_FORWARDED_FOR');
else if(getenv('HTTP_FORWARDED'))
$ipaddress = getenv('HTTP_FORWARDED');
else if(getenv('REMOTE_ADDR'))
$ipaddress = getenv('REMOTE_ADDR');
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
}
/*
* Function : getActivePageDetails
*/
function getActivePageDetails($site_url)
{
$result = '';
$ci=& get_instance();
$ci->load->database();
$db2 = $ci->load->database('readerdb', TRUE);
if($site_url!=''){
$column = 'id,template_id,page_title,page_url,logo_image,page_key, banner_title,outer_logo_image, user_group,admin_id';
$sqlQ = "select $column from su_microsite where page_url = '".$site_url."' AND status='1' order by id DESC";
$querys = $db2->query($sqlQ);
$rows = $querys->result();
$result = $rows[0];
}
return $result;
}
/*
* Function : getrcqiddetails
*/
function getrcqiddetails($rcq_id)
{
$result = '';
$question = '';
$ci=& get_instance();
$ci->load->database();
$db2 = $ci->load->database('readerdb', TRUE);
if($rcq_id>0){
$column = 'question';
$sqlQ = "select $column from savsoft_rcqbank where qid = '".$rcq_id."'";
$querys = $db2->query($sqlQ);
$result = $querys->result();
$question = $result[0]->question;
}
return $question;
}
/*
* Function : getAllMicrositesPage
*/
function getAllMicrositesPage($microsite_id)
{
$result = '';
$ci=& get_instance();
$ci->load->database();
$db2 = $ci->load->database('readerdb', TRUE);
if($microsite_id>0){
$column = 'id,microsite_id, display_name, page_url,display_order';
$sqlQ = "select $column from microsite_pages where microsite_id = '".$microsite_id."' AND status='1' order by display_order ASC";
$querys = $db2->query($sqlQ);
$result = $querys->result();
}
return $result;
}
/*
* Function : getNotification
*/
function getNotification($loginUser)
{
$result = '';
$ci=& get_instance();
$ci->load->database();
$db2 = $ci->load->database('readerdb', TRUE);
$gid = $loginUser['gid'];
$su = $loginUser['su'];
$where_and = '';
if($su==0){
$where_and = ' AND admin_id = "'.$loginUser['admin_id'].'"';
} else if($su==1){
$where_and = ' AND admin_id = "'.$loginUser['uid'].'"';
}
$nextDate = date("Y-m-d", strtotime("-3 day"));
$between = " AND (DATE(createdon) BETWEEN '".$nextDate."' AND '".date('Y-m-d')."')";
if($gid>0){
$column = 'id, title, description, createdon';
$sqlQ = "select $column from tbl_notifications_master where status='2' $where_and AND (gid = 'All' OR gid = '".$gid."') $between order by id desc";
$querys = $db2->query($sqlQ);
$result = $querys->result();
}
return $result;
}
/*
* Function : getAllMicrositesPageDetails
*/
function getAllMicrositesPageDetails($page_url)
{
$result = '';
$ci=& get_instance();
$ci->load->database();
$db2 = $ci->load->database('readerdb', TRUE);
if($page_url>0){
$column = 'id,microsite_id, title, page_url,description';
echo $sqlQ = "select $column from microsite_pages where page_url = '".$page_url."' AND status='1' order by display_order ASC";
$querys = $db2->query($sqlQ);
$result = $querys->result();
}
return $result[0];
}
/*
* Function : duplicatelogoutTime
*/
if ( ! function_exists('duplicatelogoutTime'))
{
function duplicatelogoutTime($userName)
{
$ci=& get_instance();
$ci->load->database();
$sqlQ = "select id from user_token where username = '".$userName."' order by id DESC";
$querys = $ci->db->query($sqlQ);
$rows = $querys->result();
$row = $rows[0];
$id = $row->id;
$userName = str_replace('"','"',$userName);
$userName= str_replace("`",''',$userName);
$userName= str_replace("‘",''',$userName);
$userName= str_replace("’",''',$userName);
$userName= str_replace("“",'"',$userName);
$userName= str_replace("‘",''',$userName);
$userName= str_replace("’",''',$userName);
$userName= str_replace("â€",'"',$userName);
$userName= str_replace("'","'",$userName);
$userName= str_replace("\n","<br>",$userName);
if($id>0) {
$sql = "UPDATE user_token SET duplicatelogintime = '".date('Y-m-d H:i:s')."' where username = '".$userName."' AND id=$id";
$query = $ci->db->query($sql);
}
return true;
}
}
/*
* Function : logoutTime
*/
if ( ! function_exists('logoutTime'))
{
function logoutTime($userName)
{
$ci=& get_instance();
$ci->load->database();
$sqlQ = "select id from user_token where username = '".$userName."' order by id DESC";
$querys = $ci->db->query($sqlQ);
$rows = $querys->result();
$row = $rows[0];
$id = $row->id;
$userName = str_replace('"','"',$userName);
$userName= str_replace("`",''',$userName);
$userName= str_replace("‘",''',$userName);
$userName= str_replace("’",''',$userName);
$userName= str_replace("“",'"',$userName);
$userName= str_replace("‘",''',$userName);
$userName= str_replace("’",''',$userName);
$userName= str_replace("â€",'"',$userName);
$userName= str_replace("'","'",$userName);
$userName= str_replace("\n","<br>",$userName);
if($id>0) {
$sql = "UPDATE user_token SET lastlogouttime = '".date('Y-m-d H:i:s')."' where username = '".$userName."' AND id=$id";
$query = $ci->db->query($sql);
}
return true;
}
}
/*
* Function : activeUserLogTime
*/
if ( ! function_exists('activeUserLogTime'))
{
function activeUserLogTime($sessionId, $username, $admin_id)
{
$ci=& get_instance();
$ci->load->database();
$ip = get_client_ip();
$tm = date("Y-m-d H:i:s");
$sql = "Insert into plus_login (id,userid,admin_id,ip,tm) values('$sessionId','$username','$admin_id','$ip','$tm')";
$query = $ci->db->query($sql);
return true;
}
}
/*
* Function : getRCAnswer
*/
if ( ! function_exists('getRCAnswer'))
{
function getRCAnswer($rcQid)
{
$ci=& get_instance();
$ci->load->database();
$db2 = $ci->load->database('readerdb', TRUE);
if(isset($rcQid)){
$plsql = "SELECT question from savsoft_rcqbank where qid='$rcQid'";
$query = $db2->query($plsql);
$row=$query->row_array();
return strip_tags($row['question']);
}
}
}
/*
* Function : activeUserLogUpdateTime
*/
if ( ! function_exists('activeUserLogUpdateTime'))
{
function activeUserLogUpdateTime($sessionId)
{
$ci=& get_instance();
$ci->load->database();
if(isset($sessionId)){
$tm=date("Y-m-d H:i:s");
$url = 'https://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$plsql = "update plus_login set status='ON',tm='$tm',page_url='$url' where id='$sessionId'";
$plquery = $ci->db->query($plsql);
}
$gap=10; // change this to change the time in minutes, This is the time for which active users are collected.
$tm=date ("Y-m-d H:i:s", mktime (date("H"),date("i")-$gap,date("s"),date("m"),date("d"),date("Y")));
//// Let us update the table and set the status to OFF
////for the users who have not interacted with
////pages in last 10 minutes ( set by $gap variable above ) ///
$sql = "UPDATE plus_login SET status='OFF' WHERE tm < '$tm'";
$query = $ci->db->query($sql);
return true;
}
}
/*
* Function : offUserLogStatus
*/
if ( ! function_exists('offUserLogStatus'))
{
function offUserLogStatus($sessionId)
{
$ci=& get_instance();
$ci->load->database();
$gap=10; // change this to change the time in minutes, This is the time for which active users are collected.
$tm=date ("Y-m-d H:i:s", mktime (date("H"),date("i")-$gap,date("s"),date("m"),date("d"),date("Y")));
//// Let us update the table and set the status to OFF
////for the users who have not interacted with
////pages in last 10 minutes ( set by $gap variable above ) ///
$sql = "update plus_login set status='OFF' where id='$sessionId'";
$query = $ci->db->query($sql);
}
}
/*
* Function : resizeImage
*
*/
function resizeImage($filename, $width=250, $height=250, $path='attachments/testimonial_images')
{
$source_path = $_SERVER['DOCUMENT_ROOT'] . '/'. $path.'/'. $filename;
$target_path = $_SERVER['DOCUMENT_ROOT'] . '/'.$path.'/thumbnail/';
$config_manip = array(
'image_library' => 'gd2',
'source_image' => $source_path,
'new_image' => $target_path,
'maintain_ratio' => TRUE,
'create_thumb' => TRUE,
'thumb_marker' => '',
'width' => $width,
'height' => $height
);
$CI =& get_instance();
$CI->load->library('image_lib', $config_manip);
if (!$CI->image_lib->resize()) {
echo $CI->image_lib->display_errors(); die;
}
$CI->image_lib->clear();
}
function remove_html_tags($string)
{
return preg_replace('/[^a-zA-Z0-9\s]/', '', strip_tags(html_entity_decode($string)));
}
function except_letters($string)
{
// $onlyLetters = mb_ereg_replace('[^\\p{L}\s]', '', $string);
$onlyLetters = preg_replace('/([\s])\1+/', ' ', $onlyLetters);
$onlyLetters = preg_replace('/\s/', '_', trim($onlyLetters));
return $onlyLetters;
}
function allletters_lowercase($string)
{
$only_lowercase = strtolower($string);
return replaceblankspace($only_lowercase);
}
function firstletterCapital($string)
{
$ucwords = ucwords(strtolower($string));
return $ucwords;
}
function striphtmltags($string)
{
$removeallhtmlchar = strip_tags($string);
return $removeallhtmlchar;
}
function replaceblankspace($string)
{
$only_replaceblankspace = str_replace(" ","-",$string);
return $only_replaceblankspace;
}
function setcharlimit($string, $limit=15, $start=0)
{
$return_string = '';
$return_string .= substr(html_entity_decode($string),$start,$limit);
if(strlen($string)>$limit) {
$return_string .= '...';
}
return $return_string;
}
/*
* Function : Get Default Image Name
*/
function getDefaultImage($string)
{
$response = '';
$stringArray = explode(" ",$string);
if(count($stringArray)>=2)
{
$response = substr($stringArray[0],0,1).''.substr($stringArray[1],0,1);
} else {
$response = substr($string,0,2);
}
return '<span class="frist-letter">'.strtoupper($response).'</span>';
}
function splitArrayAlphabetOrder($records)
{
$temp=array();
$first_char="";
for($i=0;$i<count($records);$i++)
{
$first_char= strtoupper ($records[$i][0]);
if(!in_array($first_char, $temp))
{
echo strtoupper($first_char).'<br>'; //print A / B / C etc
}
$temp[]= $first_char;
echo $records[$i]."<br>";
}
}
function valid_seo_friendly_url($string){
$string = str_replace(array('[\', \']',"’",":",";","|","%","@","$","^","*","(",")","?","&","<",">",",",".","/","--","+"), '', $string);
$string = preg_replace('/\[.*\]/U', '', $string);
$string = htmlentities($string, ENT_COMPAT, 'utf-8');
$string = strtolower(str_replace(" ","-",$string));
return cleanString(trim($string, '-'));
}
function seo_friendly_url($string){
$string = str_replace(array('[\', \']',"’",":"), '', $string);
$string = preg_replace('/\[.*\]/U', '', $string);
$string = htmlentities($string, ENT_COMPAT, 'utf-8');
return cleanString(trim($string, '-'));
}
function seo_friendly_url_desc($string){
$string = str_replace(array('[\', \']',"’"), '', $string);
$string = preg_replace('/\[.*\]/U', '', $string);
$string = htmlentities($string, ENT_COMPAT, 'utf-8');
return cleanString(trim($string, '-'));
}
function cleanString($text) {
$utf8 = array(
'/[áàâãªä]/u' => 'a',
'/[ÁÀÂÃÄ]/u' => 'A',
'/[ÍÌÎÏ]/u' => 'I',
'/[íìîï]/u' => 'i',
'/[éèêë]/u' => 'e',
'/[ÉÈÊË]/u' => 'E',
'/[óòôõºö]/u' => 'o',
'/[ÓÒÔÕÖ]/u' => 'O',
'/[úùûü]/u' => 'u',
'/[ÚÙÛÜ]/u' => 'U',
'/ç/' => 'c',
'/Ç/' => 'C',
'/ñ/' => 'n',
'/ñ/' => 'n',
'/amp;/' => '',
'/–/' => '-', // UTF-8 hyphen to "normal" hyphen
'/[’‘‹›‚]/u' => ' ', // Literally a single quote
'/[“”«»„]/u' => ' ', // Double quote
'/ /' => ' ', // nonbreaking space (equiv. to 0x160)
);
return preg_replace(array_keys($utf8), array_values($utf8), $text);
}
/*
* Function : setHistory
*/
function setHistory($activity)
{
$ci=& get_instance();
$ci->load->database();
$logged_in = $ci->session->userdata('logged_in');
$user = $logged_in['uid'];
$client_ip = get_client_ip();
if (!$ci->db->insert('history', array(
'activity' => $activity,
'username' => $user,
'createdon' => date('Y-m-d H:i:s'),
'ip_address' => $client_ip,
'device_name' => isMobileDevice(),
'browser_name' => ExactBrowserName(),
'time' => time())
)) {
log_message('error', print_r($ci->db->error(), true));
show_error(lang('database_error'));
}
}
/*
* Function : isMobileDevice
*/
function isMobileDevice(){
$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|mobile.+firefox|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|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)))
{
$aMobileUA = array(
'/iphone/i' => 'iPhone',
'/ipod/i' => 'iPod',
'/ipad/i' => 'iPad',
'/android/i' => 'Android',
'/blackberry/i' => 'BlackBerry',
'/webos/i' => 'Mobile'
);
//Return true if Mobile User Agent is detected
foreach($aMobileUA as $sMobileKey => $sMobileOS){
if(preg_match($sMobileKey, $_SERVER['HTTP_USER_AGENT'])){
$device = $sMobileOS;
} else{
$device = 'Mobile';
}
}
} else {
$device = "Desktop";
}
//Otherwise return false..
return $device;
}
/*
* Function : ExactBrowserName
*/
function ExactBrowserName()
{
$ExactBrowserNameUA=$_SERVER['HTTP_USER_AGENT'];
if (strpos(strtolower($ExactBrowserNameUA), "safari/") and strpos(strtolower($ExactBrowserNameUA), "opr/")) {
// OPERA
$ExactBrowserNameBR="Opera";
} elseIf (strpos(strtolower($ExactBrowserNameUA), "safari/") and strpos(strtolower($ExactBrowserNameUA), "chrome/")) {
// CHROME
$ExactBrowserNameBR="Chrome";
} elseIf (strpos(strtolower($ExactBrowserNameUA), "msie")) {
// INTERNET EXPLORER
$ExactBrowserNameBR="Internet Explorer";
} elseIf (strpos(strtolower($ExactBrowserNameUA), "firefox/")) {
// FIREFOX
$ExactBrowserNameBR="Firefox";
} elseIf (strpos(strtolower($ExactBrowserNameUA), "safari/") and strpos(strtolower($ExactBrowserNameUA), "opr/")==false and strpos(strtolower($ExactBrowserNameUA), "chrome/")==false) {
// SAFARI
$ExactBrowserNameBR="Safari";
} else {
// OUT OF DATA
$ExactBrowserNameBR="OUT OF DATA";
};
return $ExactBrowserNameBR;
}
/*
* Function : generatePracticeQuizkey
*/
function generatePracticeQuizkey($quizDetails)
{
$key = array('quid'=>$quizDetails['quid'],'gids'=>$quizDetails['gids'],'admin_id'=>$quizDetails['admin_id']);
return base64_encode(serialize($key));
}
/*
* Function : generateQuizkey
*/
function generateQuizkey($tkey,$gids)
{
$key = unserialize(base64_decode($tkey));
unset($key['admin_id']);
$key['gids'] = $gids;
return base64_encode(serialize($key));
}
/*
* Function : get_tiny_url
*/
function get_tiny_url($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
/*
* Function : getIPlocation
*/
function getIPlocation($IPAddress = '14.139.238.62'){
$ip = $IPAddress;
// Use JSON encoded string and converts
// it into a PHP variable
$ipdat = @json_decode(file_get_contents(
"http://www.geoplugin.net/json.gp?ip=" . $ip));
echo 'Country Name: ' . $ipdat->geoplugin_countryName . "<br/>";
echo 'City Name: ' . $ipdat->geoplugin_city;
//echo 'Continent Name: ' . $ipdat->geoplugin_continentName . "\n";
//echo 'Latitude: ' . $ipdat->geoplugin_latitude . "\n";
//echo 'Longitude: ' . $ipdat->geoplugin_longitude . "\n";
//echo 'Currency Symbol: ' . $ipdat->geoplugin_currencySymbol . "\n";
//echo 'Currency Code: ' . $ipdat->geoplugin_currencyCode . "\n";
//echo 'Timezone: ' . $ipdat->geoplugin_timezone;
}