<?
function get_increment($type,$bids=0)
{
 
 $res=mysql_query("select price_increment,time_increment from auction_type where auction_type='".$type."' and 
 range_min <= $bids and range_max > $bids and status='1' limit 1");
 
 if(mysql_num_rows($res)>0)
  {
   $rec=mysql_fetch_array($res);
  
   $arr[0]=$rec[0]/100;  
   $arr[1]=$rec[1];  
  }
  else
  {
  		/////   Default value  for price and time increment  ///////
   $arr[0]=.01;    //  1p ( price  increment )
   $arr[1]=20;     //  20 sec ( time increment )
    	/////   Default value  for price and time increment  ///////
  }
  
   return $arr;
}

function formated_time($date,$time)
{
$dt=explode('-',$date);
$tm=explode(':',$time);
$ts= mktime(0, 0, 0, $dt[1], $dt[2], $dt[0]);
list($time)=mysql_fetch_array(mysql_query("select curtime()"));
$curr=explode(":",$time);

 $hr=$curr[0];
 $day= date('d');
 
$ft= " at ";
if($date==date("Y-m-d"))
{
if(($hr-$tm[0])==0)
$ft.= ($curr[1]-$tm[1])." min ago ";
else if(($hr-$tm[0])==1)
$ft.= "1 hour ago ";
else if(($hr-$tm[0])==2)
$ft.= "2 hour ago ";
else if(($hr-$tm[0])==3)
$ft.= "3 hour ago ";
else
$ft.= $tm[0].":".$tm[1];
}
else
$ft.= $tm[0].":".$tm[1];


if(($day-$dt[2])==0)
$ft.= " Today";
else if(($day-$dt[2])==0)
$ft.= " Yesterday";
else 
$ft.= " on ".date('D',$ts).", ".date('F',$ts)." ".date('d',$ts);

return $ft;
}
function getsent() {
$id = $_SESSION['uid'];
$query="SELECT * FROM mail where sender_id='$id' and s_folder='s' and reciever_id in(select id from  user)";
if (!($res=mysql_query($query))) {error(mysql_error(),__LINE__,__FILE__);}
 $num = mysql_num_rows($res);

return $num;
}
function get_fname($user_id) {
$query="SELECT first_name,last_name FROM user WHERE id='$user_id'";
		$res=mysql_query($query);
		if (mysql_num_rows($res)) 
		{
			list($fname,$lname)=mysql_fetch_row($res);
          }
		  $flname=substr(ucfirst($fname),0,15)." ".substr(ucfirst($lname),0,15);
		  return $flname;
}
function get_profile_name($user_id) {
$query="SELECT uname FROM user WHERE id='$user_id'";
		$res=mysql_query($query);
		if (mysql_num_rows($res)) 
		{
			list($fname)=mysql_fetch_row($res);
          }		  
		 return $fname;
}
function get_profile_nameb($user_id) {
$query="SELECT uname FROM user WHERE id='$user_id'";
		$res=mysql_query($query);
		if (mysql_num_rows($res))
		{
			list($fname)=mysql_fetch_row($res);
        }
		  $fname="<a href='view_profile.php?id=".$user_id."'class='smalla1b'>".substr(ucfirst($fname),0,15)."</a>";
		  return $fname;
}
function mail_to_winner4pay($pid,$uid,$price)
{
     $to=get_fieldval(uid,email,t123go_register,$uid);
	 $fname=get_fieldval(uid,user_name,t123go_register,$uid);
	 $model=get_fieldval(pid,pname,t123go_product,$pid);
	 $email=$to;
	
	$ownerid=get_fieldval(pid,uid,t123go_product,$pid);	
	$owneremail=get_fieldval(uid,email,t123go_register,$ownerid);
	$pid=base64_encode($pid);
	$sub=_YOUWINTHE_;
	
	$body="<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
<html>
<head>
<title>Win the model</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<link rel='shortcut icon' href='http://www.money-auctions.com/auctiontest/favicon.ico' />
</head>
<body bgcolor='#000000' style='background-image:(http://www.money-auctions.com/auctiontest/img/emailback.jpg); background-repeat:repeat'>
<table width='680' border='0' align='center' cellpadding='0' cellspacing='0' bgcolor='#000000' style='background-image:(http://www.money-auctions.com/auctiontest/img/emailback.jpg); background-repeat:repeat'>
     <tr bgcolor='#000000'>
          <td valign='top' colspan='2' bgcolor='#000000'>
          <img src='http://www.money-auctions.com/auctiontest/img/emailgirl_01.jpg' alt='paradis adultes registeration email'></td>
     </tr>
       <tr bgcolor='#000000'>
       <td width='132' valign='top' bgcolor='#000000'><img src='http://www.money-auctions.com/auctiontest/img/emailgirl_02.jpg' alt='paradis adultes registeration email'></td>
              <td width='428' valign='top' style='color:#FFFFFF; font-size:13px'>";
	$body.="<br><br><br><br>"._DEARRR_."$fname!<br><br><br><br>	
    <a href='http://www.money-auctions.com/pay_winner.php?pid=$pid'>Product Details Click Here</a>    
    <br>
	<br>"._MODELPRI_."	 $price €<br><br>"._KND_REGRDS_."<br>"._FRM_EVRONE_TELEBDTM_."<br></td><td width='120' valign='top' style='color:#FFFFFF; font-size:13px' align=center><img src='http://www.money-auctions.com/auctiontest/img/escortwon.png' alt='escort won by' /></td></tr></table></body></html>";
	$hdr= "From:info@paradisadultes.com\nContent-Type: text/html; charset=utf-8" ;
	//echo $body; exit;
	$x=mail($to,$sub,$body,$hdr);
	
}
function mail_to_winner($pid,$uid,$price)
{
     $to=get_fieldval(uid,email,t123go_register,$uid);
	 $fname=get_fieldval(uid,user_name,t123go_register,$uid);
	 $model=get_fieldval(pid,pname,t123go_product,$pid);
	 $email=$to;
	
	$ownerid=get_fieldval(pid,uid,t123go_product,$pid);	
	$owneremail=get_fieldval(uid,email,t123go_register,$ownerid);
	$sub=_YOUWINTHE_;
	$body="<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
<html>
<head>
<title>Win the model</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<link rel='shortcut icon' href='http://www.money-auctions.com/auctiontest/favicon.ico' />
</head>
<body bgcolor='#000000' style='background-image:(http://www.money-auctions.com/auctiontest/img/emailback.jpg); background-repeat:repeat'>
<table width='680' border='0' align='center' cellpadding='0' cellspacing='0' bgcolor='#000000' style='background-image:(http://www.money-auctions.com/auctiontest/img/emailback.jpg); background-repeat:repeat'>
     <tr bgcolor='#000000'>
          <td valign='top' colspan='2' bgcolor='#000000'>
          <img src='http://www.money-auctions.com/auctiontest/img/emailgirl_01.jpg' alt='paradis adultes registeration email'></td>
     </tr>
       <tr bgcolor='#000000'>
       <td width='132' valign='top' bgcolor='#000000'><img src='http://www.money-auctions.com/auctiontest/img/emailgirl_02.jpg' alt='paradis adultes registeration email'></td>
              <td width='428' valign='top' style='color:#FFFFFF; font-size:13px'>";
	$body.="<br><br><br><br>"._DEARRR_."$fname!<br><br><b><u>"._MODELDET_."</u></b><br><br>"._MODELNAME_."<br>$model<br> $owneremail <br><br>"._MODELPRI_."	 $price €<br><br>"._KND_REGRDS_."<br>"._FRM_EVRONE_TELEBDTM_."<br></td><td width='120' valign='top' style='color:#FFFFFF; font-size:13px' align=center><img src='http://www.money-auctions.com/auctiontest/img/escortwon.png' alt='escort won by' /></td></tr></table></body></html>";
	$hdr= "From:"._ADMIN_MAIL_."\nContent-Type: text/html; charset=utf-8" ;
	//echo $body; exit;
	$x=mail($to,$sub,$body,$hdr);
	


}

function mail_to_owner($pid,$uid,$price)
{
    
	$fname=get_fieldval(uid,user_name,t123go_register,$uid);
	$email=get_fieldval(uid,email,t123go_register,$uid);
	$model=get_fieldval(pid,pname,t123go_product,$pid);
	$ownerid=get_fieldval(pid,uid,t123go_product,$pid);
	$ownername=get_fieldval(uid,user_name,t123go_register,$ownerid);
	$owneremail=get_fieldval(uid,email,t123go_register,$ownerid);
	$to=$owneremail;
	
	$sub=_ONEOFRUY_;
	$body="<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
<html>
<head>
<title>your model is booked</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<link rel='shortcut icon' href='http://www.money-auctions.com/auctiontest/favicon.ico' />
</head>
<body bgcolor='#000000' style='background-image:(http://www.money-auctions.com/auctiontest/img/emailback.jpg); background-repeat:repeat'>
<table width='680' border='0' align='center' cellpadding='0' cellspacing='0' bgcolor='#000000' style='background-image:(http://www.money-auctions.com/auctiontest/img/emailback.jpg); background-repeat:repeat'>
     <tr bgcolor='#000000'>
          <td valign='top' colspan='2' bgcolor='#000000'>
          <img src='http://www.money-auctions.com/auctiontest/img/emailgirl_01.jpg' alt='paradis adultes registeration email'></td>
     </tr>
       <tr bgcolor='#000000'>
       <td width='132' valign='top' bgcolor='#000000'><img src='http://www.money-auctions.com/auctiontest/img/emailgirl_02.jpg' alt='paradis adultes registeration email'></td>
              <td width='428' valign='top' style='color:#FFFFFF; font-size:13px'>";
	$body.="<br><br><br><br>"._DEARRR_."$ownername!<br><br>"._ONEOFYORMODE_."<br>"._MODELDET_."<br><br>"._MODELNAME_." $model <br>$owneremail<br>"._MODELPRI_." $price €<br><br><br><b><u>"._VISTORDETA_."</u></b><br><br>"._VISTORDETA1_." $fname <br>$email<br><br>"._KND_REGRDS_."<br>"._FRM_EVRONE_TELEBDTM_."<br></td><td width='120' valign='top' style='color:#FFFFFF; font-size:13px' align=center><img src='http://www.money-auctions.com/auctiontest/img/escortwon.png' alt='escort won by' /></td></tr></table></body></html>";
	$hdr= "From:info@paradisadultes.com\nContent-Type: text/html; charset=utf-8" ;
	//echo $body; exit;
	$x=mail($to,$sub,$body,$hdr);
	

}

function mail_to_owner_test($pid,$uid,$price)
{
    
	$fname=get_fieldval(uid,user_name,t123go_register,$uid);
	$email=get_fieldval(uid,email,t123go_register,$uid);
	$model=get_fieldval(pid,pname,t123go_product,$pid);
	$ownerid=get_fieldval(pid,uid,t123go_product,$pid);
	$ownername=get_fieldval(uid,user_name,t123go_register,$ownerid);
	$owneremail=get_fieldval(uid,email,t123go_register,$ownerid);
	$to="rajat2810@gmail.com";
	
	$sub=_ONEOFRUY_;
	$body="<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
<html>
<head>
<title>your model is booked</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<link rel='shortcut icon' href='http://www.money-auctions.com/auctiontest/favicon.ico' />
</head>
<body bgcolor='#000000' style='background-image:(http://www.money-auctions.com/auctiontest/img/emailback.jpg); background-repeat:repeat'>
<table width='680' border='0' align='center' cellpadding='0' cellspacing='0' bgcolor='#000000' style='background-image:(http://www.money-auctions.com/auctiontest/img/emailback.jpg); background-repeat:repeat'>
     <tr bgcolor='#000000'>
          <td valign='top' colspan='2' bgcolor='#000000'>
          <img src='http://www.money-auctions.com/auctiontest/img/emailgirl_01.jpg' alt='paradis adultes registeration email'></td>
     </tr>
       <tr bgcolor='#000000'>
       <td width='132' valign='top' bgcolor='#000000'><img src='http://www.money-auctions.com/auctiontest/img/emailgirl_02.jpg' alt='paradis adultes registeration email'></td>
              <td width='428' valign='top' style='color:#FFFFFF; font-size:13px'>";
	$body.="<br><br><br><br>"._DEARRR_."$ownername!<br><br>"._ONEOFYORMODE_."<br>"._MODELDET_."<br><br>"._MODELNAME_." $model <br>$owneremail<br>"._MODELPRI_." $price €<br><br><br><b><u>"._VISTORDETA_."</u></b><br><br>"._VISTORDETA1_." $fname <br>$email<br><br>"._KND_REGRDS_."<br>"._FRM_EVRONE_TELEBDTM_."<br></td><td width='120' valign='top' style='color:#FFFFFF; font-size:13px' align=center><img src='http://www.money-auctions.com/auctiontest/img/escortwon.png' alt='escort won by' /></td></tr></table></body></html>";
	$hdr= "From:info@paradisadultes.com\nContent-Type: text/html; charset=utf-8" ;
	//echo $body; exit;
	$x=mail($to,$sub,$body,$hdr);
	

}



function get_dilid_uname($did){
$sql="select * from t123go_useradd where id='$did'";
$myrwd=mysql_query($sql);
$myuname=mysql_fetch_array($myrwd);
$name=$myuname['name'];
return $name;
}

function remainbid1()
{
     $res1=mysql_query("select no_bids  from user where id='".$_SESSION['uid']."'");
	$mysp=mysql_fetch_array($res1);	
	return $mysp[0];
}
function remainbid()
{

    $res1=mysql_query("select sum(total_price) as total_price from t123go_memberpack p,t123go_bidpackage  b 
	where p.package_id=b.pkgid and p.uid='".$_SESSION['uid']."'");
	$mysp=mysql_fetch_array($res1);
	$res2=mysql_query("select sum(sold_price) as sold from t123go_product_sold where uid='".$_SESSION['uid']."'");
	$myrat=mysql_fetch_array($res2);
	$myres=$mysp['total_price']-$myrat['sold'];
	return $myres;
}
function my_inbox($id)
{
$query_inbox = "select * from mail where reciever_id='".$_SESSION['uid']."'";
$exe_inbox = mysql_query($query_inbox) or die ("Error" . mysql_error());
$total_inbox=mysql_num_rows($exe_inbox);
return $total_inbox;
}
function my_read($id)
{
 $query_inbox = "select * from mail where reciever_id='".$_SESSION['uid']."' and status='1'";
$exe_inbox = mysql_query($query_inbox) or die ("Error" . mysql_error());
$total_inbox=mysql_num_rows($exe_inbox);

return $total_read;
}

?>