<?
$ip=getRealIP();
$t=time();
$deltime=$t-24*3600;



if($res["kolvo"]<1)
{
	mysql_query("insert into tb_hosts (ip,data) values ('$ip','$t')"); $wel++;
	if($elref!='')
	{
		$res1=mysql_query("select count(id) as kolvo, money, reflinkpaid, rlvisits from tb_users where username='$elref'"); $wel++;
		$res1=mysql_fetch_array($res1);
		if($res1["kolvo"]>0)
		{
			$money=$res1["money"];
			$rlpmoney=$res1["reflinkpaid"];
			$rlv=$res1["rlvisits"];
			$res2=mysql_query("select price from tb_config where item='reflinkprice'"); $wel++;
			$rlp=mysql_result($res2,0,0);
			$money=$money+$rlp;
			$rlpmoney=$rlpmoney+$rlp;
			$rlv=$rlv+1;
			mysql_query("update tb_users set money='$money', reflinkpaid='$rlpmoney', rlvisits='$rlv' where username='$elref'"); $wel++;

			$res=mysql_query("select * from tb_comp where param='5'");$wel++;
			if(mysql_num_rows($res)>0)
			{
				while($row=mysql_fetch_array($res))
				{
					$id=$row["id"];
					$lidertype=$row["lidername"];
					$t=time();
					$sd=strtotime($row["startdate"]);
					$ed=strtotime($row["enddate"]);
					if($t>$sd && $t<$ed)
					{
						if($lidertype=='1')
						{
							$res1=mysql_query("select wmid from tb_users where username='$elref'");$wel++;
							if(mysql_num_rows($res1)>0){$res1=mysql_fetch_array($res1); $lidername=$res1["wmid"];}else{$lidername='';}
						}else{
							$lidername=$elref;
						}
						if($lidername!='')
						{
							$res1=mysql_query("select * from tb_compdata where idk='$id' and user='$lidername'"); $wel++;
							if(mysql_num_rows($res1)>0)
							{
								$res1=mysql_Fetch_array($res1);
								$resvalue=$res1["resvalue"]+1;
								mysql_query("update tb_compdata set resvalue='$resvalue' where id='".$res1["id"]."'");$wel++;
							}else{
								mysql_query("insert into tb_compdata (idk,user,resvalue) values ('$id','$lidername','1')");$wel++;
							}
						}
					}
				}
			}
		}
	}
}


?>