📄 cat_buy.php
字号:
<?
include_once "myconnect.php";
include_once "date_time_format.php";
if(isset($_REQUEST["cid"]))
{
$cat_query=mysql_query("Select * from sbbleads_categories where sb_pid=" . $_REQUEST["cid"]);
$rs=mysql_num_rows($cat_query);
if(($rs<=0)||($_REQUEST["cid"]==0))
{
header("Location:"."buyoffers.php?cid=".$_REQUEST["cid"]);
die();
}
}
function main()
{
$keyword="";
if(isset($_REQUEST["keyword"])&&($_REQUEST["keyword"]<>""))
{
$keyword=$_REQUEST["keyword"];
}
$config=mysql_fetch_array(mysql_query("select * from sbbleads_config"));
$cid=0;
if(isset($_REQUEST["cid"])&&($_REQUEST["cid"]<>""))
{
$cid=$_REQUEST["cid"];
$sbqu_off="update sbbleads_categories set sb_visit_buy=sb_visit_buy+1 where sb_id=$cid";
mysql_query($sbqu_off);
}
/*$sell_num=mysql_num_rows(mysql_query("select * from sbbleads_offers where sb_approved='yes'"));
$buy_num=mysql_num_rows(mysql_query("select * from sbbleads_offers_buy where sb_approved='yes'"));
$product_num=mysql_num_rows(mysql_query("select * from sbbleads_products where sb_approved='yes'"));
$profile_num=mysql_num_rows(mysql_query("select * from sbbleads_companyprofiles where sb_approved='yes'"));*/
$catname="";
$category=0;
$cat_query=mysql_query("Select * from sbbleads_categories where sb_id=" . $cid );
if ($cat=mysql_fetch_array($cat_query))
{
$catname=$cat["sb_cat_name"];
$category=$cat["sb_id"];
}
$catpath="";
$cat_query=mysql_query("Select * from sbbleads_categories where sb_id=" . $cid );
while ($rs=mysql_fetch_array($cat_query))
{
$catpath =" > <a href=\"cat_buy.php?cid=" . $rs["sb_id"] . "\">" .$rs["sb_cat_name"]."</a>".$catpath;
$cat_query=mysql_query("Select * from sbbleads_categories where sb_id=" . $rs["sb_pid"] );
}
?>
<table width="100%" border="0" cellspacing="10" cellpadding="2" class="maintablestyle">
<tr>
<td valign="top"><table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="onepxtable">
<tr>
<form name="form1" method="post" action="search.php">
<td align="center" valign="middle" class="innertablestyle"><br> <input name="keyword" type="text" value="<? echo $keyword;?>" size="40">
<select name="type">
<option value="1">Sell Offers</option>
<option value="2" selected>Buy Offers</option>
<option value="3">Products Catalogs</option>
<option value="4">Company Profiles</option>
</select>
<font class='normal'>
<input name="show_save" type="hidden" id="show_save" value="yes">
</font>
<input type="submit" name="Submit" value="Search">
<a href="advance_search.php">Advance Search</a> <br>
</td>
</form>
</tr>
</table></td>
</tr>
<tr>
<td valign="top"><table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" >
<tr>
<td><font class="normal"> <a href="index.php">Home</a><? echo $catpath;?></font></td>
</tr>
<tr>
<td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="titlestyle">
<tr>
<td align="center" valign="middle" class="subtitle" >→
<a href="cat_sell.php<?php if($cid<>0) echo "?cid=".$cid;?>">Sell Offers</a></td>
<td align="center" valign="middle">↓ Buy Offers</td>
<td align="center" valign="middle" class="subtitle" >→
<a href="cat_products.php<?php if($cid<>0) echo "?cid=".$cid;?>">Products</a></td>
<td align="center" valign="middle" class="subtitle" >→
<a href="cat_profiles.php<?php if($cid<>0) echo "?cid=".$cid;?>">Companies</a></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td valign="top"> <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><font class="normal"><b>Browse Buy Offers</b></font></td>
</tr>
<td class="onepxtable"><table width="100%" border="0" cellspacing="1" cellpadding="2" class="innertablestyle">
<?
$cats_sql="select * from sbbleads_categories where sb_pid=$cid ";
if($config["sb_cat_listing"]=="alpha")
{
$cats_sql.=" order by sb_cat_name";
}
else
{
$cats_sql.=" order by sb_order_index";
}
$cats_query=mysql_query($cats_sql);
$cnt=1;
while($cats=mysql_fetch_array($cats_query))
{
$rst_query=mysql_query("Select * from sbbleads_categories where sb_pid=".$cats["sb_id"] );
$clist=$cats["sb_id"];
while ( $rst=mysql_fetch_array($rst_query) )
{
$clist.="," . $rst["sb_id"];
$thislist="-1," . $rst["sb_id"];
while ( $rst=mysql_fetch_array($rst_query) )
{
$clist.="," . $rst["sb_id"];
$thislist.="," . $rst["sb_id"];
//echo $rst["sbcat_id"];
}
$rst_query=mysql_query("Select * from sbbleads_categories where sb_pid in (" . $thislist . ")" );
}
$sbcat_str= " and sb_cid IN (" .$clist . ")" ;
$sbq_off_cat="select * from sbbleads_offer_cats, sbbleads_offers where sb_approved='yes' and sbbleads_offers.sb_id=sbbleads_offer_cats.sb_offer_id and DATE_ADD(sb_postedon,INTERVAL ".$config["sb_expiry_sell"]." MONTH) > NOW() $sbcat_str";
$sboff_count=mysql_num_rows(mysql_query($sbq_off_cat));
$sbq_buy_cat="select * from sbbleads_offer_cats_buy, sbbleads_offers_buy where sb_approved='yes' and sbbleads_offers_buy.sb_id=sbbleads_offer_cats_buy.sb_offer_id and DATE_ADD(sb_postedon,INTERVAL ".$config["sb_expiry_buy"]." MONTH) > NOW() $sbcat_str";
$sbbuy_count=mysql_num_rows(mysql_query($sbq_buy_cat));
$sbq_product_cat="select * from sbbleads_product_cats, sbbleads_products where sb_approved='yes' and sbbleads_products.sb_id=sbbleads_product_cats.sb_offer_id $sbcat_str";
$sbproduct_count=mysql_num_rows(mysql_query($sbq_product_cat));
$sbq_profile_cat="select * from sbbleads_profile_cats, sbbleads_companyprofiles where sb_approved='yes' and sbbleads_companyprofiles.sb_id=sbbleads_profile_cats.sb_profile_id $sbcat_str";
$sbprofile_count=mysql_num_rows(mysql_query($sbq_profile_cat));
$sbtotal=$sbbuy_count;//$sboff_count+$sbbuy_count+$sbproduct_count+$sbprofile_count;
//die();
if($cnt%3==1)
{
?>
<tr>
<td width="20"> </td>
<?
}
?>
<td align="left"><font class='normal'> <a href="index.php?cid=<? echo $cats["sb_id"];?>">
</a><a href="cat_buy.php?cid=<? echo $cats["sb_id"];?>"><? echo $cats["sb_cat_name"]; ?></a>(<? echo $sbtotal; ?>)</font></td>
<?
if($cnt%3==0)
{
?>
</tr>
<?
}
$cnt++;
}
?>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td valign="top"><table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="onepxtable">
<tr class="titlestyle">
<td> Featured Offers </td>
</tr>
<tr>
<td><table width="100%" cellpadding="2" cellspacing="5">
<?php
mt_srand((double)microtime()*1000000);
$rst_query=mysql_query("Select * from sbbleads_categories where sb_pid=".$cid );
$clist=$cid;
while ( $rst=mysql_fetch_array($rst_query) )
{
$clist.="," . $rst["sb_id"];
$thislist="-1," . $rst["sb_id"];
while ( $rst=mysql_fetch_array($rst_query) )
{
$clist.="," . $rst["sb_id"];
$thislist.="," . $rst["sb_id"];
//echo $rst["sbcat_id"];
}
$rst_query=mysql_query("Select * from sbbleads_categories where sb_pid in (" . $thislist . ")" );
}
$id_list=-1;
$cat_query=mysql_query("select * from sbbleads_offer_cats_buy where sb_cid in ($clist)");
while($offer_cat=mysql_fetch_array($cat_query))
{ $id_list.=",".$offer_cat["sb_offer_id"];}
$sbq1_mem="select * from sbbleads_members where sb_memtype=1";
$sbrs1_mem=mysql_query($sbq1_mem);
$sbgold_list="0";
while($sbrow1_mem=mysql_fetch_array($sbrs1_mem))
{
$sbgold_list.=",".$sbrow1_mem["sb_id"];
}
$sbq_off="select *,UNIX_TIMESTAMP(sb_postedon) as ondate from sbbleads_offers_buy
where sb_approved='yes' and sb_uid in ($sbgold_list) and sb_id in ($id_list) and
DATE_ADD(sb_postedon,INTERVAL ".$config["sb_expiry_buy"]." MONTH) > NOW() order by sb_id desc";
$sbrs_off=mysql_query($sbq_off);
$num_rows=mysql_num_rows($sbrs_off);
$max_allowed=$config["sb_cat_featured"];
$number[0]=-1;
if($num_rows>$max_allowed)
{
for($i=0;$i<$max_allowed;$i++)
{
$unique=0;
while($unique==0)
{
$j=rand(0,$num_rows-1);
for($k=0;$k<count($number);$k++)
{
//echo $j;
if($number[$k]==$j)
break;
}
if($k>(count($number)-1))
{
$unique=1;
}
}
$number[$i]=$j;
}
}// end if num > no_allowed
/*for($k=0;$k<count($number);$k++)
{
echo $number[$k]." ";
}*/
$row=0;
$cnt=0;
$offer=mysql_fetch_array($sbrs_off);
while (($offer)&&($cnt<$max_allowed))
{
$display=0;
if($num_rows>$max_allowed)
{
for($k=0;$k<count($number);$k++)
{
if($number[$k]==$row)
{
$display=1;
}
}
}
else
{
$display=1;
}
if($display==1)
{
$images=mysql_fetch_array(mysql_query("select * from sbbleads_offer_images where sb_offer_id=".$offer["sb_id"]." order by sb_id"));
?>
<tr >
<td valign="top" > <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="subtitle"><font class="normal"> <a
href="view_offer_buy.php?id=<?php echo $offer["sb_id"];?>">
</a><a
href="view_offer_buy.php?id=<?php echo $offer["sb_id"];?>">
<?php
if (strlen ($offer["sb_title"])>50)
{
echo substr($offer["sb_title"], 0, strrpos( substr($offer["sb_title"], 0, 50),' ' ));
}
else
{
echo $offer["sb_title"];
}
?>
</a><a
href="view_offer.php?id=<?php echo $offer["sb_id"];?>">
</a><font class="red"> [
<?
$cur=mysql_fetch_array(mysql_query("select * from sbbleads_currencies where sbcur_id=".$offer["sb_price_cur_id"]));
echo $cur["sbcur_symbol"];
?>
<?php echo $offer["sb_price"];?>]</font></font></td>
</tr>
<tr>
<td><font class="smalltext"> Posted by <strong>
<?php
$mem=mysql_fetch_array(mysql_query("select * from sbbleads_members where sb_id=".$offer["sb_uid"]));
$profile=mysql_fetch_array(mysql_query("select * from sbbleads_companyprofiles where sb_uid=".$offer["sb_uid"]));
if ($profile) { echo $profile["sb_companyname"];}
else { echo $mem["sb_username"]; }
?>
</strong><font class="red"><strong>[
<?php
$level_query=mysql_query("select * from sbbleads_levels where sb_levelid=" .$mem["sb_memtype"]);
$level= mysql_fetch_array($level_query);
echo $level["sb_levelname"];
?>
]</strong></font> on <?php echo sb_date($offer["ondate"]);?>
</font></td>
</tr>
<tr>
<td valign="top"><font class="smalltext">
<?php
if (strlen (strip_tags($offer["sb_description"]))>100)
{
echo substr(strip_tags($offer["sb_description"]), 0, strrpos( substr(strip_tags($offer["sb_description"]), 0, 100),' ' )) . "..";
}
else
{
echo strip_tags($offer["sb_description"]);
}
?>
</font></td>
</tr>
</table></td>
</tr>
<?
$cnt++;
}//if display
$offer=mysql_fetch_array($sbrs_off);
/*if(!$offer||($cnt>=$max_allowed))
{
?>
<tr>
<td valign="top" > <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="60"> </td>
<td class="subtitle"><font class="red"><strong>Default Ad
</strong></font><font class="normal"> </font></td>
</tr>
<tr>
<td> </td>
<td><font class="smalltext">Become a Gold member and your
Offer will appear here. </font></td>
</tr>
</table></td>
</tr>
<?
}*/
$row++;
}// end while
?>
<tr>
<td valign="top" > <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="subtitle"><font class="red"><strong>Default Ad
</strong></font><font class="normal"> </font></td>
</tr>
<tr>
<td><font class="smalltext">Become a Gold member and your
Offer will appear here. </font></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<?
}// end main
include "template.php";
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -