<?php
header("Expires: Mon, 26 Jul 2097 05:00:00 GMT\n");
header("Last-Modified: Mon, 26 Jul 1997 05:00:00 GMT\n");
header("Cache-Control: must-revalidate", false);
	$trans["  "]=" ";
###############################
error_reporting( E_ALL | E_STRICT );
ini_set("display_errors", 1);
#####################################
header("Content-type: text/javascript; charset=utf-8");
function to_farsi($num) {


		return str_replace(
			array(",",".","0", "1", "2", "3", "4", "5", "6", "7", "8", "9"),
			array("/","/","۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"),
			$num
		);

	 

}
include_once('ip_location.class.php');
include_once('translater.php');
//require_once ('class.datetimecalc.php');
require_once ('class.time.php');
require_once ('oghatsharee.php');
 include_once('ez_sql.class.php');
define("EZSQL_DB_HOST3", "localhost");	// <-- mysql server host
define("EZSQL_DB_USER3", "ipfinder");			// <-- mysql db user
define("EZSQL_DB_PASSWORD3", "ippass123");		// <-- mysql db password
define("EZSQL_DB_NAME3", "sheybani_ip");		// <-- mysql db pname
$ip = $_SERVER['REMOTE_ADDR'];
$current_date = $day.' '.$monthDays[$month].' '.$year;
$dbs = new db(EZSQL_DB_USER3, EZSQL_DB_PASSWORD3, EZSQL_DB_NAME3, EZSQL_DB_HOST3);
$id = $dbs->get_var("SELECT id FROM ips where ip='{$ip}'");

if(!is_numeric($id) ) {

$IPAddress = new IPLocation;
$IPAddress->AddressErrorMessage = '<h3>Your IP is '.$ip.'</h3><p>Sorry, for some reasons the details of your IP address location can\'t be displayed</p>';
$IPAddress->AddressLocalErrorMessage = '<h3>Your IP is '.$ip.'</h3><p>Sorry, the details of your IP address location can\'t be displayed<br />Make sure that your internet connection is not turn off or contact your server administrator for this error</p>';
$IPAddress->Address($ip);


if($IPAddress->Error==1) {
	echo $IPAddress->ErrorMessage;
} else {
	

	$IPAddress->City = strtr($IPAddress->City, $Citytrans);
	$IPAddress->RegionName = strtr($IPAddress->RegionName, $Regiontrans);
	if($IPAddress->City=='تهران' )
	$IPAddress->RegionName='تهران';
		if($IPAddress->City=='قزوین')
	$IPAddress->RegionName='قزوین';
		if($IPAddress->City=='بیرجند' )
	$IPAddress->RegionName='خراسان جنوبی';
	
 $IPAddress->CountryName = strtr($IPAddress->CountryName, $trans);
 
/*if($IPAddress->Timezone!=$date->TimeZone['offset']){
$orig_date = $date->Time;
$orig_mask = "h:i:s";
$action = "remove timezone";

$obj = new Date_Time_Calc($orig_date, $orig_mask);
$obj->calculate("TimeZone", $date->TimeZone['offset'], "subtract");

$user_time = $obj->date_time;}
else */
$user_time = $date->Time;
 	if($IPAddress->is_LocalIP($ip)==1) {
		$out_mess =  '<h3>شما از یک سرویس عموی استفاده می نمایید '.$_SERVER['REMOTE_ADDR'].'<br />
		آی پی  مشترک شما عبارت است از '.$IPAddress->Ip.'</h3>';
	} else {
		$out_mess = '<h3 dir=ltr>آی پی شما عبارت است از '.$IPAddress->Ip.'</h3>';
	}
	$country = "<img border='0' src='http://www.google-analysts.com/ip/flags/".strtolower($IPAddress->CountryCode).".png'>".strtr($IPAddress->CountryName, $translate);
	$regionname  =$IPAddress->RegionName;
$city = 	$IPAddress->City;
$Latitude =	to_farsi($IPAddress->Latitude);
$Longitude =to_farsi($IPAddress->Longitude);
$user_time;
$parrams = oghatsharee_main($IPAddress->Longitude,$IPAddress->Latitude);

$sobh = $parrams['t1'];
$toloo = $parrams['t2'];
$ghoroob = $parrams['t3'];
$zohr = $parrams['zr'];
$maghreb =  $parrams['t4'];
$user_ip = $IPAddress->Ip;
$dbs->query("INSERT IGNORE INTO `ips`  (`ip`,`CountryCode`,`CountryName`,`City`,`Latitude`,`Longitude`,`RegionName`,`Timezone`) VALUES ('{$IPAddress->Ip}','{$IPAddress->CountryCode}','{$IPAddress->CountryName}','{$city}','{$IPAddress->Latitude}','{$IPAddress->Longitude}','{$IPAddress->RegionName}','{$IPAddress->Timezone}') ON DUPLICATE KEY UPDATE `count`=`count`+1");
?>
    document.getElementById('googleUserState').innerHTML="<?include('templet2.php');?>";
  <?
}}
else{
	$user_ip = $dbs->get_row("SELECT * FROM ips WHERE id = '{$id}'");
$country = "<img border='0' src='http://www.google-analysts.com/ip/flags/".strtolower($user_ip->CountryCode).".png'>".strtr($user_ip->CountryName, $translate);
$dbs->query("UPDATE ips SET `count` = `count`+1 WHERE id = '{$id}'");

/*if($user_ip->Timezone!=$date->TimeZone['offset']){
$orig_date = $user_ip->Timezone;
$orig_mask = "h:i:s";
$action = "remove timezone";

//$obj = new Date_Time_Calc($orig_date, $orig_mask);
//$obj->calculate("TimeZone", $date->TimeZone['offset'], "subtract");

$user_time = $obj->date_time;

}*/
//else 
$user_time = $date->Time;


$user_ip->City = strtr($user_ip->City, $Citytrans);
	$user_ip->RegionName = strtr($user_ip->RegionName, $Regiontrans);
 $user_ip->CountryName = strtr($user_ip->CountryName, $trans);
	$regionname  =$user_ip->RegionName;
$city = 	$user_ip->City;
$user_ip = $user_ip->ip;
//$Latitude =	to_farsi($user_ip->Latitude);
//$Longitude =to_farsi($user_ip->Longitude);
//$user_time;
//$parrams = oghatsharee_main($user_ip->Longitude,$user_ip->Latitude);
$current_date = $day.' '.$monthDays[$month].' '.$year;
//$sobh = $parrams['t1'];
//$toloo = $parrams['t2'];
//$ghoroob = $parrams['t3'];
//$zohr = $parrams['zr'];
//$maghreb =  $parrams['t4'];



?>
    document.getElementById('googleUserState').innerHTML="<?include('templet2.php');?>";
  <?	
	
}



