<?php
include ("txt/header.php");
?> 
<table width="560" border="0" cellspacing="0" cellpadding="0">
<tr> 
<td height="22" class="menu">
<div align="center">
Пользовательская панель управления 
</div>
</td>
</tr>
<tr> 
<td align="center" valign="top" class="menu"><table width="560" border="0" cellspacing="1" cellpadding="0">
<tr>
<td align="center" valign="top" bgcolor="#FFFFFF"><table width="550" border="0" cellspacing="5" cellpadding="0">
<tr> 
<td>
<?php
include ("auth_user.php");
if (isset($_POST['lot'])) {
$lot=$_POST['lot'];
}
if (!isset($lot) || $lot==" ") {
die('Не выбран лот!');
} 
$query="select * from goods where (first='$lot')";
$res=mysql_query($query);
$row=mysql_fetch_assoc($res);
$name=$row["name"];
$name=stripslashes($name);
$cat=$row["parent"];
$query="select name from subcategories where (first='$cat')";
$cats=mysql_query($query);
$rowcats=mysql_fetch_assoc($cats);
$name_of_category=$rowcats["name"];
$type=$row["type"];
$typeshow=str_replace ("one","Уникальный",$type);
$typeshow=str_replace ("mult","Несколько одинаковых",$typeshow);
$typeshow=str_replace ("unlim","Неограниченное количество",$typeshow);
$price=$row["price"];
$mprice=$row["mprice"];
$quantity=$row["quantity"];
$descr=$row["descr"];
$descr=stripslashes($descr);
$photo=$row["photo"];
$bid_of_good=$row["bid"];
$end=$row["srok"];
$nowtime=time();
$stay=$end-$nowtime;
if ($bid_of_good==0) {
$bid_of_good="нет";
}
$buyer=$row["buyer"];
$buyer=stripslashes($buyer);
$buyerc=$buyer;
if ($buyer=="no") {
$buyer_show="нет предложений";
$buyer="нет покупателей";
}
else {
$query="select name,email from users where (crcname='$buyer')";
$user_res=mysql_query($query);
$row_user=mysql_fetch_assoc($user_res);
$buyer_show=$row_user["name"];
$email_of_buyer=$row_user["email"];
$email_of_buyer=stripslashes($email_of_buyer);
$buyer_show="<a href=\"profile.php?user=$buyer\"><u>$buyer_show</u></a>";
}
$id=$row["first"];
?>
<center>
<?php include ("txt/menu_cp.php"); ?>
<br>
<table class="t">
<tr bgcolor=white>
<td><b>Название:</b></td><td><center><?php echo $name; ?></td>
</tr>
<tr bgcolor=white>
<td><b>Категория:</b></td><td><center><?php echo "<a href='goods.php?subcat=$cat'><u>$name_of_category</a></u>"; ?></td>
</tr>
<tr bgcolor=white>
<td><b>Тип аукциона:</b></td><td><center><?php echo $typeshow; ?></td>
</tr>
<tr bgcolor=white>
<td><b>Начальная цена:</b></td><td><center><?php echo $price; ?></td>
</tr>
<tr bgcolor=white>
<td><b>Цена моментальной продажи:</b></td><td><center><?php echo $mprice; ?></td>
</tr>
<?php
if ($type=="one") {
echo "<tr bgcolor=white>";
echo "<td><b>Текущая ставка: </b></td><td><center>$bid_of_good</td>";
echo "</tr>";
}
echo "<tr bgcolor=white>";
echo "<td><b>";
if ($type=="one") {
echo "Наивысшую цену предложил: ";
}
else {
echo "Покупатели: ";
}
echo "</b></td><td><center>";
if ($type=="one") {
echo "$buyer_show";
}
else {
echo "$buyer";
}
echo "</td>";
echo "</tr>";
if ($type=="mult") {
if ($quantity<1) {
$quantity="<font color=red>Товар закончился</font>";
}
echo "<tr bgcolor=white><td><b>Количество:</b></td><td><center>$quantity</td></tr>";
}
?>
<tr bgcolor=white>
<td><b>Описание:</b></td><td><?php echo $descr; ?></td>
</tr>
</table>
<br>
<form action="del_lot.php" method="post">
<input type=hidden name=lot value="<?php echo "$id" ?>">
<input type=submit value="Снять с продажи">
</form>
<center>
<?php
if ($stay<=0 && $type=="one" && $buyerc!="no") {
echo "Время данного аукциона истекло. Победителем стал $buyer_show. Вам надо связаться с ним для обсуждения дальнейших деталей сделки по email <a href='mailto:$email_of_buyer'><u>$email_of_buyer</u></a.";
}
if (file_exists("photos/$photo") && $photo!="") {
echo "<img src='photos/$photo'>";
}
?>
</td>
</tr>
</table></td>
</tr>
</table></td></tr></table>
<br>
</td>
</tr>
</table></td>
</tr>
<?php
include ("txt/footer.php");
?> 

