Hi,
I am not a coder and I really appreciate your help. I don't know what to do. If you will visit my site
http://www.flamingwheels.com/ you will get an error
Fatal error: Cannot redeclare get_domain() (previously declared in /home/flamingw/public_html/in.php:2) in
/home/flamingw/public_html/in.php on line
8
Below is the code. Please help
.
<?php
function get_domain($url){
$refdomain = preg_match('@^(?:
http://)?([^/]+)@i',$url, $matches);
$host = $matches[1];
preg_match('/[^.]+\.[^.]+$/', $host, $matches);
$refdomain = $matches[0];
return $refdomain;
}
$ref1 = $_SERVER['HTTP_REFERER'];
$ref2 = get_domain($ref1);
//$base1 = "http://".$_SERVER["HTTP_HOST"];
//$base2 = get_domain($base1);
if(!empty($ref2)){
//if($ref2!=$base2){
$trade_options=get_option(abb_trade_settings);
if($trade_options[geotrading]!=1){
if(!empty($_SERVER['HTTP_CLIENT_IP'])) $ip=$_SERVER['HTTP_CLIENT_IP'];
elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
else $ip=$_SERVER['REMOTE_ADDR'];
}else{
include_once('ip2c/ip2country.php');
$ip2c=new ip2country();
$ip=$ip2c->get_client_ip();
$ipc=$ip2c->get_country_name();
$ipcc=$ip2c->get_country_code();
}
$post_id = $post->ID;
$now=time();
$query1=mysql_query("SELECT ipaddress FROM trade_ipaddress WHERE ipaddress='$ip' && websiteurl='$ref2' LIMIT 1") or die(mysql_error());
if(mysql_num_rows($query1)==0){
if($trade_options[geotrading]!=1){
$insert=mysql_query("INSERT INTO trade_ipaddress (ipaddress,websiteurl,fullurl,post_id,io,time) VALUES ('$ip','$ref2','$ref1','$post_id','1','$now')") or die(mysql_error());
$update=mysql_query("UPDATE trade_sites SET totalin=totalin+1,dayin=dayin+1 WHERE websitename='$ref2' LIMIT 1") or die(mysql_error());
}else{
$insert=mysql_query("INSERT INTO trade_ipaddress (ipaddress,country,country_code,websiteurl,fullurl ,post_id,io,time) VALUES ('$ip','$ipc','$ipcc','$ref2','$ref1','$post_id',' 1','$now')") or die(mysql_error());
$tiercredit=0;
$tier0listexplode=explode(',',$trade_options[tier0]);
for($x=0;$x<count($tier0listexplode);$x++){if($ipc ==$tier0listexplode[$x]){$tiercredit=1;
$update=mysql_query("UPDATE trade_sites SET totalin=totalin+1,dayin=dayin+1,tier0credit=tier0c redit+1 WHERE websitename='$ref2' LIMIT 1") or die(mysql_error());}}
if($tiercredit==0){$tier1listexplode=explode(',',$ trade_options[tier1]);
for($x=0;$x<count($tier1listexplode);$x++){if($ipc ==$tier1listexplode[$x]){$tiercredit=1;
$update=mysql_query("UPDATE trade_sites SET totalin=totalin+1,dayin=dayin+1,tier1credit=tier1c redit+1 WHERE websitename='$ref2' LIMIT 1") or die(mysql_error());}}}
if($tiercredit==0){$tier2listexplode=explode(',',$ trade_options[tier2]);
for($x=0;$x<count($tier2listexplode);$x++){if($ipc ==$tier2listexplode[$x]){$tiercredit=1;
$update=mysql_query("UPDATE trade_sites SET totalin=totalin+1,dayin=dayin+1,tier2credit=tier2c redit+1 WHERE websitename='$ref2' LIMIT 1") or die(mysql_error());}}}
if($tiercredit==0){$tiercredit=1;
$update=mysql_query("UPDATE trade_sites SET totalin=totalin+1,dayin=dayin+1,tier3credit=tier3c redit+1 WHERE websitename='$ref2' LIMIT 1") or die(mysql_error());}
}
}
//}
}
?
>