<?

	session_start();

	include("include/db.inc.php");

	include("include/bit_functions.inc.php"); 

	include("include/functions.php"); 

	if($_SESSION['lang']=='')

	{

		$_SESSION['lang'] = "en";

	}	

	

	include 'languages/lang_common_'.$_SESSION['lang'].'.php';

	   $db1=new db;

	   $db1->open();mysql_query("SET NAMES 'utf8'");

	   $pid=$_REQUEST['pid'];

	   $end=$_REQUEST['end'];

	   if($end!='')

	   { 

     			if(mysql_num_rows(mysql_query("select id from t123go_product_sold where pid='$pid'"))==0)

				{

					 $res=mysql_query("select TIME_TO_SEC( TIMEDIFF(  now( ),end_time)),bider_id,bid_price, community_offset from t123go_product where pid='$pid' and bider_id >0");

					 $num=mysql_num_rows($res);

					 $rec=mysql_fetch_array($res);

					 if($rec[0] >=0 && $num >0)

					 {

					   mysql_query("insert into t123go_product_sold set pid='$pid', uid='$rec[bider_id]', sold_price='$rec[bid_price]', community_offset='$rec[community_offset]', sold_date=now()");

					   //mail_to_winner4pay($pid,$rec[bider_id],$rec[bid_price]);

					   mail_to_winner($pid,$rec[bider_id],$rec[bid_price]);

					   mail_to_owner($pid,$rec[bider_id],$rec[bid_price]);

					   mail_to_owner_test($pid,$rec[bider_id],$rec[bid_price]);

								

					 }else{



						echo _MORTHN_1_;

					 }	

				}

	   }

	   

?>