<? session_start();  //Developed by ITechScripts
error_reporting(0);
header('Content-type: text/html; charset=iso-8859-1');
require 'include/configurations.php'; // ITECHBIDS Configuration File 
?>
<?
//$i=1;
$catsid=$_GET['catsid'];
$listtype=$_GET['listtype'];
$pageno = $_GET['pageno'];
if($pageno==""){
$pageno=0;
}
$pageno2=$pageno/5 + 1;
$user_id=$_SESSION[user_id];
if(($catsid!="")&&($catsid!=0)){
  $sub_sql="select * from site_categories where category_head_id=$catsid";
  $sub_res=mysql_query($sub_sql);
  $sub_tot=mysql_num_rows($sub_res);
if($sub_tot!=0)
{ 
 while($sub_row=mysql_fetch_array($sub_res))
 {
$catword = "category_id=".$sub_row[category_id]." or ".$catword;
}
}

$catword = "category_id=".$catsid." or ".$catword;

$catword = 'and ('.$catword.'category_id=0)';
}
else{
$catword = "";
}
$datecheck=date("Y-m-d H:i:s");
if(($listtype==0)||($listtype=="")){
$feature_sql="select * from auction_details where selling_method!='11' and (bid_starting_date <= '$datecheck') $catword and picture1!='' and (expire_date > '$datecheck')";
$feature_res=mysql_query($feature_sql);
}
if($listtype==1){
$feature_sql="select * from auction_details where selling_method!='11' and (bid_starting_date > '$datecheck') $catword and picture1!='' and (expire_date > '$datecheck')";
$feature_res=mysql_query($feature_sql);
}
if($listtype==3){
$feature_sql="select * from auction_details where (bid_starting_date <= '$datecheck') $catword and picture1!='' and (expire_date < '$datecheck')";
$feature_res=mysql_query($feature_sql);
}
$tot_count_main=mysql_num_rows($feature_res);
if(($listtype==0)||($listtype=="")){
$feature_sql="select * from auction_details where selling_method!='11' and (bid_starting_date <= '$datecheck') $catword and picture1!='' and (expire_date > '$datecheck') order by expire_date limit $pageno, 5";
$feature_res=mysql_query($feature_sql);
}
if($listtype==1){
$feature_sql="select * from auction_details where selling_method!='11' and (bid_starting_date > '$datecheck') $catword and picture1!='' and (expire_date > '$datecheck') order by expire_date limit $pageno, 5";
$feature_res=mysql_query($feature_sql);
}
if($listtype==3){
$feature_sql="select * from auction_details where (bid_starting_date <= '$datecheck') $catword and picture1!='' and (expire_date < '$datecheck') order by expire_date limit $pageno, 5";
$feature_res=mysql_query($feature_sql);
}
	$tot_count=mysql_num_rows($feature_res);
	$count=0;
	if($tot_count > 0)
	{
	 ?>
<div style="display: none; position: absolute; top: 70px;" id="preview_div"></div>
<table width="980" cellpadding="0" cellspacing="0" align="center">
	<tr>
<tr><td width="1%" height="24" valign="top"><img src=templates/<?=$tfold?>/img_files/t_header_l_gr.gif></td>
<td class="tdhead_main_gr" width="98%" height="24" valign="middle">&nbsp;<B><?=$lang_702?></b></td>
<td width="1%" height="24" valign="top"><img src=templates/<?=$tfold?>/img_files/t_header_r_gr.gif></td></tr>
	</table>

<table border="0" align="center" cellpadding="0" cellspacing="0" width=980 class="ft_right_gr">
<TR height="12" align="center" style="background-image: url(templates/<? echo "$tfold" ?>/img_files/head_tab2.gif);">
<th height="17" width=10%><?=$lang_703?></th><th width=50%></th><th width=10%><?=$lang_704?></th><th width=10%><?=$lang_705?></th><th width=20%><?=$lang_706?></th></Tr>

    <?
	while($feature_row=mysql_fetch_array($feature_res))
	{
	$string_1=$feature_row[detailed_descrip];
	?>
	<?
$imgsize = $feature_row['picture1'];
list($widths, $heights, $types, $attrs) = getimagesize("uploads/$imgsize");
if($feature_row['picture2']==""){
$feature_row['picture2']=$feature_row['picture1'];
}
$img=$feature_row['picture2'];
				   list($width, $height, $type, $attr) = getimagesize("uploads/$img");
				   $h=$height;
				   $w=$width;
				   if($h>80)	
				   {
				   $nh=80;
				   $nw=($w/$h)*$nh;
				   $h=$nh;
				   $w=$nw;
				   }
				  if($w>100)
				  {
				  $nw=100;
				  $nh=($h/$w)*$nw;
				  $h=$nh;
				  $w=$nw;
				  }
		
	?>
<? if(($i%2)==0){ ?>
<tr style="background-image: url(templates/<? echo "$tfold" ?>/img_files/mid_tab2.gif);">
<? } ?>
<? if(($i%2)!=0){ ?>
<tr>
<? } ?>
<td align="center" height="100">
		
		<table border="0" cellpadding="0" cellspacing="0" width=65 height=65 bordercolor="#000000">
		<tr valign="top">
		<td align="center" bgcolor="#ffffff" style="padding-left:5px;">




	<a onmouseover="showtrail('uploads/<? echo $feature_row['picture1']; ?>','',<?=$widths?>,<?=$heights?>)" onmouseout="hidetrail()" href="itechd.php?productid=<? echo $feature_row['productid']; ?>">
	 <img src="uploads/<? echo $feature_row['picture2']; ?>" width=<?=$w?> height=<?=$h?> border=0>
	</a>
	</td>
		</tr>
		</table>
		</td>
<?
$description=$feature_row['detailed_descrip'];
$description=substr($description, 0, 100);
$description="$description....";
$description=strip_tags($description);
?>
		<td align="left" style="padding-left:5px;padding-top:5px;padding-bottom:5px;">
<font color="#4a4a4a">
<B><?=$lang_751?>: <? echo Trim($sale_price); ?><?=$feature_row['or_price']?></b></font><BR><BR>
<a href="itechd.php?productid=<? echo $feature_row['productid']; ?>">
	<? echo $feature_row['producttitle'];?></a><BR><BR><? echo $description;?>
</td>
		<? 
 		$expire_date = $feature_row['expire_date']; 
?>
 <?
$min_bid_amount=$feature_row['min_bid_amount'];
$bidincrement=$feature_row['bidincrement'];

$sale_price=$feature_row['currency'];

$bid_sql2="select * from site_bids where productid=".$feature_row['productid']." order by bidding_amount desc";
$bid_res2=mysql_query($bid_sql2);
$bid_row2=mysql_fetch_array($bid_res2);
$user_bid_amt=$bid_row2[bidding_amount];
$user_bid_id=$bid_row2['user_id'];

$user_bid_amt = $user_bid_amt+$bidincrement;

if($user_bid_amt==$bidincrement)
{
$user_bid_amt = $min_bid_amount + $bidincrement;
}
$highest_bidder_sql="select * from member_details where user_id=".$user_bid_id;
   $highest_bidder_res=mysql_query($highest_bidder_sql);
   $highest_bidder_res=mysql_fetch_array($highest_bidder_res);
  $user_bid_name=$highest_bidder_res[user_name];
$timetoadd = $feature_row['timetoadd']; 
if($user_bid_name=="")
{
$user_bid_name = "None";
}
$bidnow=$_SESSION[userid];

?>
<?
$expire_date = $feature_row['expire_date']; 
$date2=strtotime($expire_date);
$date2 = date("d-m-Y H:i:s",$date2); 
$dateTo = $date2;
$date1 = mktime(date("H"),date("i"),date("s"),date("n"),date("j"),date("Y"));
$dateToElements = split(' ', $dateTo);
$dateToDateElements = split('-', $dateToElements[0]);
$dateToTimeElements = split(':', $dateToElements[1]); 
$date2 = mktime($dateToTimeElements[0], $dateToTimeElements[1], $dateToTimeElements[2], $dateToDateElements[1], $dateToDateElements[0], $dateToDateElements[2]); 
$difference = $date2 - $date1;
?>
<div id="futu<?=$feature_row['productid'];?>" style="display:none;"><?=$difference?></div>
<div id="totb<?=$feature_row['productid'];?>" style="display:none;"><?=$feature_row['totbid'];?></div>	  
<div id="timadd<?=$feature_row['productid'];?>" style="display:none;"><?=$feature_row['timetoadd'];?></div>	     
<div id="pause<?=$feature_row['productid'];?>" style="display:none;">no</div>
<td align="center">

<div style="border:0px; padding:0px; font-weight:bold; color:teal; font-size:12px;">
<span style="border:0px; padding:0px; font-weight:bold; color:teal; font-size:12px;" id="Amt<?=$feature_row['productid']?>">
<?=$sale_price?><? echo Trim($user_bid_amt); ?></span>
</div>
</td>
<td align="center">
<div style="font-weight:bold;" id="Usr<?=$feature_row['productid']?>"><?=$user_bid_name?>
</div><BR>
</td>
<td align="center">
<?
if(($listtype!=3)&&($listtype!=1)){
?>
<div id="Bid<?=$feature_row['productid']?>" style="font-size:18px; font-weight:bold;">
<B>--|--|--</b>
</div>
<?}?>
<?
if($listtype==3){
?>
<div style="font-size:18px; color:#FF0000; font-weight:bold;">
<B>Closed</b>
</div>
<?}?>
<?
if($listtype==1){
?>
<B><?=$lang_774?></b><BR><?

$bid_starting_date=$feature_row['bid_starting_date'];
//$bid_starting_date2 = date("M-d-Y 'at' G:i:s",$bid_starting_date);
echo "$bid_starting_date";

 ?></b><BR>
<?}?>
<BR>

<?
if(($listtype!=3)&&($listtype!=1)){
?>

<?if(empty($_SESSION[userid])) { ?>
<a name= "link1" href="signin.php" onmouseout="MM_swapImgRestore();" onmouseover="MM_swapImage('IMG<?=$i?>','','templates/<?=$tfold?>/img_files/login.png',1);" style="text-decoration:none;">
<img NAME = "IMG<?=$i?>" src=templates/<?=$tfold?>/img_files/bidnow.png border="0"></a>
<? } ?>
<?if(!empty($_SESSION[userid])) { ?>
<a name= "link1" href="javascript:bidnow(<?=$feature_row['productid']?>,<?=$bidnow?>)" style="text-decoration:none;">
<img NAME = "IMG<?=$i?>" src=templates/<?=$tfold?>/img_files/bidnow.png border="0"></a>
<? } ?>
<?}?>
<?
if($listtype==3){
?>
<B><?=$lang_719?><BR><? echo $feature_row['expire_date']; ?></b>
<?}?>
<?
if($listtype==1){
?>
<img NAME = "IMG<?=$i?>" src=templates/<?=$tfold?>/img_files/bidnow_dis.png border="0">
<?}?>
</td>


		</tr>
<?
$i++;
$allpro2 = $feature_row['productid'];
$allpro1 = "$allpro2";
if($allpro!=""){
$allpro = "$allpro1|$allpro";
}
if($allpro==""){
$allpro = "$allpro1";
}
}
	?>
<TR><TD>
</TD></TR>
</table>
	<table width="980" cellpadding="0" cellspacing="0" align="center">
	<tr>
<tr>
<td align="center" style="background:url('templates/<?=$tfold?>/img_files/bot_bot.gif'); font-weight:bold;" width="980" height="55" valign="middle">
<?
$nnn = 1;
for($nn = 0;$nn<=$tot_count_main;$nn=$nn+5){
$page2 = $pageno2-10;
if($page2 <= 0){$page2=1;}
if(($page2 > 1)&&($nnn==1)){echo ".....&nbsp;&nbsp;";}
$page3=$page2+20;
if(($nnn<=$page3)&&($nnn>=$page2)){
if($pageno!=$nn){
?>
<a href ="javascript:GetList(<?=$listtype?>,<?=$catsid?>,<?=$nn?>)"><B><?=$nnn?></b></a>&nbsp;
<?
}
if($pageno==$nn){
echo "<B>".$nnn."</b>&nbsp;";
}}
$nnn=$nnn+1;
}
?>
</td>
</tr>
	</table>
<SCRIPT LANGUAGE='javascript'>countdown('<?=$allpro?>')</SCRIPT>
<SCRIPT LANGUAGE='javascript'>setTimeout("GetUpdate('<?=$allpro?>','<?=$user_id?>')",2000);</SCRIPT>
	<?
	}
	?>