<?
	include("config/connect.php");
	include("functions.php");

	$message = "";

	if($_REQUEST["pno"]=="" || $_REQUEST["auccode"]=="")
	{
		echo $lng_wrongparameter;
		exit;
	}
?>
<?
		if(substr($_REQUEST["pno"],0,1)==" ")
		{
			$pno1 = substr($_REQUEST["pno"],1);
		}
		else
		{
			$pno1 = $_REQUEST["pno"];
		}
	$qrysmsdata = "Insert into smsbid_data(messagedata,message_time) values('+".$pno1."|".$_REQUEST["auccode"]."',NOW())";
	mysql_query($qrysmsdata) or die(mysql_error());

	if($_REQUEST["pno"]!="" && $_REQUEST["auccode"]!="")
	{
		if(substr($_REQUEST["pno"],0,1)==" ")
		{
			$pno = substr($_REQUEST["pno"],1);
		}
		else
		{
			$pno = $_REQUEST["pno"];
		}
		$auccodeget = strtoupper($_REQUEST["auccode"]);
		
		$auccodepart = explode(" ",$auccodeget);
		$auccodecount = count($auccodepart);
				
		if($auccodepart[0]=="BID")
		{
			$auccode = $auccodepart[1];
	
			$qrysel = "select * from registration where full_mobileno='+".$pno."'";
			$rssel = mysql_query($qrysel);
			$total = mysql_num_rows($rssel);
			$obj = mysql_fetch_object($rssel);
			if($total==0)
			{
				$message = $lng_userdoesnotex;
			}
			
			$qryauc = "select * from auction where auctionID='".$auccode."'";
			$resauc = mysql_query($qryauc);
			$totalauc = mysql_num_rows($resauc);
			if($totalauc>0)
			{
				$objauc = mysql_fetch_object($resauc);
				if($objauc->auc_status=="3" or $objauc->auc_status=="1")
				{
					$auctionstatus = "1";
					$message = $lng_auctionnotrunn;
				}
				elseif($objauc->pause_status=="1")
				{
					$auctionstatus = "1";
					$message = $lng_auctioncurrpause;
				}
				else
				{
					$auctionstatus = "0";
				}
			}
			else
			{
				$auctionstatus = "1";
				$message = $lng_aucdoesnotex;
			}
	
			if($total>0 && $auctionstatus=="0")
			{
				$qry = "select * from auc_due_table adt left join auction a on adt.auction_id=a.auctionID left join auction_management am on a.time_duration=am.auc_manage where auctionID='".$auccode."'";
				$r = mysql_query($qry);
				$ob = mysql_fetch_object($r);
			
				$oldtime = $ob->auc_due_time;
				$oldprice = $ob->auc_due_price;
				$plusprice = $ob->auc_plus_price;
				$plustime = $ob->auc_plus_time;
				
				if($ob->pennyauction==1)
				{
				$newprice = $oldprice + 0.01;
				}
				else
				{
				$newprice = $oldprice + $plusprice;
				}
	
				$newtime = $oldtime + $plustime;

				$qupd = "update auc_due_table set auc_due_time=$newtime,auc_due_price=$newprice where auction_id='".$ob->auctionID."'";
				mysql_query($qupd) or die(mysql_error());
	
				$qryins = "Insert into bid_account (user_id,bidpack_buy_date,bid_count,auction_id,product_id,bid_flag,bidding_price,bidding_type,bidding_time) values('".$obj->id."',NOW(),'1','".$ob->auctionID."','".$ob->productID."','d',$newprice,'m','".$oldtime."')";
				mysql_query($qryins) or die(mysql_error()); 

				$message = $lng_okmessage1.$newprice.$lng_okmessage2.calc_counter_from_time_php($newtime);
			 }
		}
		else
		{
			$message = $lng_invalidmessage;
		}
		echo $message;
	}
?>
