📄 post_product.php
字号:
$cat_query=mysql_query("Select * from sbbleads_categories where sb_id in ($cid_list)");
$temp_cid_list=-1;
while ($rs=mysql_fetch_array($cat_query))
{
$temp_cid_list .=",".$rs["sb_id"];
$cid=$rs["sb_id"];
$cat_query1=mysql_query("Select * from sbbleads_categories where sb_id=" . $cid );
while ($rs1=mysql_fetch_array($cat_query1))
{
$temp_cid_list.="," .$rs1["sb_id"];
$cat_query1=mysql_query("Select * from sbbleads_categories where sb_id=" . $rs1["sb_pid"] );
}
}
$cid_list=$temp_cid_list;
//echo "<br>cats----".$temp_cid_list."----<br>";
//die();
//////-----------------------------------------
$rs_con=mysql_fetch_array(mysql_query("select * from sbbleads_config where sb_id=1"));
$sb_null_char=$rs_con["sb_null_char"];
$login_url=$rs_con["sb_site_root"]."/signin.php";
$sb_offer_url=$rs_con["sb_site_root"]."/view_product?id=$sb_offer_id";
// foreach($cat as $sb_value)
// {
$sbq3_cat="select * from sbbleads_categories where sb_id=$sb_value";
$sbrow3_cat=mysql_fetch_array(mysql_query($sbq3_cat));
$sb_cat_name=$sbrow3_cat["sb_cat_name"];
$sbuser_id_list="-1";
$sbq_fav_cat="select * from sbbleads_fav_cats where sb_type='product' and cid in ($cid_list)";
//echo $sbq_off_cat;
$sbrs_fav_cat=mysql_query($sbq_fav_cat);
while($sbrow_fav_cat=mysql_fetch_array($sbrs_fav_cat))
{
$sbuser_id_list.=",".$sbrow_fav_cat["mid"];
}
$sbq3_mem="select * from sbbleads_members where sb_id in ($sbuser_id_list)";
$sbrs3_mem=mysql_query($sbq3_mem);
while($sbrow3_mem=mysql_fetch_array($sbrs3_mem))
{ //send mail
//////---getting category name only first matching cat for a user
$sbq1_fav_cat="select * from sbbleads_fav_cats where cid in ($cid_list) and mid=".$sbrow3_mem["sb_id"];
//echo $sbq_off_cat;
$sbrs1_fav_cat=mysql_query($sbq1_fav_cat);
$sbrow_fav_cat=mysql_fetch_array($sbrs1_fav_cat);
$sbq4_cat="select * from sbbleads_categories where sb_id=".$sbrow_fav_cat["cid"];
//echo $sbq_off_cat;
$sbrow4_cat=mysql_fetch_array(mysql_query($sbq4_cat));
$sb_cat_name=$sbrow4_cat["sb_cat_name"];
///////----------------------
$from =$sbrow_mail["sb_fromid"];
$to = $sbrow3_mem["sb_email"];
$subject =$sbrow_mail["sb_subject"];
$header="From:" . $from . "\r\n" ."Reply-To:". $from ;
$body=str_replace("%email%", $sb_null_char,str_replace("%password%",$sb_null_char,str_replace("%lname%", $sbrow3_mem["sb_lastname"],str_replace("%fname%",$sbrow3_mem["sb_firstname"],str_replace("%username%",$sbrow3_mem["sb_username"], $sbrow_mail["sb_mail"]) ))));
$body=str_replace("%signup_url%",$sb_null_char,str_replace("%login_url%",$login_url,$body));
$body=str_replace("%message_text%",$sb_null_char,str_replace("%message_title%",$sb_null_char,str_replace("%sender_username%",$sb_null_char,str_replace("%message_date%",$sb_null_char,$body))));
$body=str_replace("%visitor_name%",$sb_null_char,$body);
$body=str_replace("%offer_title%",$sb_title,str_replace("%offer_url%",$sb_offer_url,str_replace("%offer_id%",$sb_offer_id,$body)));
$body=str_replace("%category%",$sb_cat_name,$body);
if(isset($sbrow_mail["sb_html_format"])&&($sbrow_mail["sb_html_format"]=="yes"))
{
$header .= "\r\nMIME-Version: 1.0";
$header .= "\r\nContent-type: text/html; charset=iso-8859-1\r\n";
// $body=str_replace("\n","<br>",$body);
}
// echo "--from:-$from----to:-$to---sub:-$subject----head:-$header----";
// echo "<pre>$body</pre>";
// die();
if( $sbrow_mail["sb_status"]=='yes')
mail($to,$subject,$body,$header);
} //end while sbrow3_mem
//////////////////////////////////////////////////////////
} // end if
//die();
*/
} //end if approval == auto
///////////-----------------
////////////////////////////////////////////////------------------------------------
//////////////////////////////////////////////////----------------------------------
if($sb_approved=="yes")
{
header ("Location: gen_confirm_mem.php?sb_type=3&id=$sb_offer_id&errmsg=".urlencode($sb_msg));
}
else
{
header ("Location: gen_confirm_mem.php?errmsg=".urlencode($sb_msg));
}
die();
}// if inserted
else
{
header("Location: gen_confirm_mem.php?err=post_product&errmsg=".urlencode("Sorry, some error occurred and unable to post product catalog."));
die();
}
}// if no errors
}// if form posted
else
{
/////////---getting config---------
$sbq_con='select * from sbbleads_config where sb_id=1';
$sbrow_con=mysql_fetch_array(mysql_query($sbq_con));
$sbq_gro='select * from sbbleads_groups where sb_memtype='.$_SESSION["sbbleads_memtype"];
$sbrow_gro=mysql_fetch_array(mysql_query($sbq_gro));
/////////--------------getting information bout user's privious postings
$sbq_off="select * from sbbleads_products where sb_uid=".$_SESSION["sbbleads_userid"];
$sbsell_count=mysql_num_rows(mysql_query($sbq_off));
//////////////////////////////////---------------------------
if( $sbsell_count >= $sbrow_gro["sb_product_cnt"] )
{
header("Location: gen_confirm_mem.php?errmsg=".urlencode("You have already posted maximum allowed product catalogs."));
die();
}
$cid_list='';
$sb_cat_list='';
$sb_title='';
$sb_description='';
$sb_quantity='';
$sb_keywords='';
$sb_location='';
$sb_min_order='';
$sb_price_cur_id='';
$sb_price='';
$sb_samples_available='no';
$sb_product_status='New';
$sb_delivery_time='';
$sb_payment_mode='';
$sb_other_mode='';
$sb_shipping_cost='';
}
function main ()
{
global $sbsell_count, $sbrow_con, $sbrow_gro, $errs, $errcnt, $cid_list, $sb_cat_list, $sb_title, $sb_description, $sb_quantity, $sb_keywords, $sb_location, $sb_min_order, $sb_price_cur_id, $sb_price, $sb_samples_available, $sb_product_status, $sb_delivery_time, $sb_payment_mode, $sb_other_mode, $sb_shipping_cost;
$showform="";
if (count($_POST)>0)
{
$cid_list=$_POST["cid"];
$sb_cat_list=$_POST["category"];
if ( $errcnt <> 0 )
{
?>
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="errorstyle">
<tr>
<td colspan="2"><strong> Your Request cannot be processed due to following
reasons</strong></td>
</tr>
<tr height="10">
<td colspan="2"></td>
</tr>
<?
for ($i=0;$i<$errcnt;$i++)
{
?>
<tr valign="top">
<td width="6%"> <?php echo $i+1;?></td>
<td width="94%"><?php echo $errs[$i]; ?></td>
</tr>
<?
}
?>
</table>
<?
}
}
if ($showform<>"No")
{
?>
<script language="JavaScript" type="text/javascript" src="richtext.js"></script>
<script language="JavaScript">
/* function add_category()
{
if(document.form123.cats.value!=0)
{
var id=document.form123.cats.selectedIndex;
if(document.form123.category.value=="")
{
document.form123.cid.value=document.form123.cats.value;
document.form123.category.value=document.form123.cats.options[id].text;
document.form123.category.focus();
document.form123.cats.selectedIndex=0;
}
else
{
document.form123.cid.value=document.form123.cid.value+";"+document.form123.cats.value;
document.form123.category.value=document.form123.category.value+";"+document.form123.cats.options[id].text;
document.form123.category.focus();
document.form123.cats.selectedIndex=0;
}
}
else
{
alert('Choose a Category to add!');
}
}
*/
function add_category()
{
if(document.form123.cats.value!=0)
{
var id=document.form123.cats.selectedIndex;
//////-------checking duplicate category
var cid_list=form123.cid.value.split(";");
var cnt=0;
var posted="no";
while(cnt<cid_list.length)
{
if(cid_list[cnt]==document.form123.cats.value)
{ posted="yes";}
cnt++;
}
if(posted=="yes")
{
alert('This category is already in the list');
return false;
}
//////-------end checking duplicate category
//////-------checking max no. of categories
var sblength;
if(document.form123.category.value == "")
sblength=0;
else
sblength=cid_list.length
if( sblength >= <?php echo $sbrow_gro["sb_cat_cnt"]; ?> )
{
alert("You can't choose more than <?php echo ($sbrow_gro["sb_cat_cnt"]==1)?$sbrow_gro["sb_cat_cnt"].' category':$sbrow_gro["sb_cat_cnt"].' categories'; ?>");
return false;
}
//////-------checking max no. of categories
if(document.form123.category.value=="")
{
document.form123.cid.value=document.form123.cats.value;
document.form123.category.value=document.form123.cats.options[id].text;
document.form123.category.focus();
document.form123.cats.selectedIndex=0;
}
else
{
document.form123.cid.value=document.form123.cid.value+";"+document.form123.cats.value;
document.form123.category.value=document.form123.category.value+";"+document.form123.cats.options[id].text;
document.form123.category.focus();
document.form123.cats.selectedIndex=0;
}
}
else
{
alert('Choose a Category to add');
}
}
function remove_category()
{
var s1=window.document.form123.category.value;
var s2=s1.split(";");
var i=0;
var id=document.form123.cats.selectedIndex;
var s3=document.form123.cats.options[id].text;
var id_list=document.form123.cid.value;
var id_split=id_list.split(";");
var rem_id=document.form123.cats.value;
window.document.form123.category.value="";
window.document.form123.cid.value="";
while(i<s2.length)
{
//alert('Checking '+s2[i]+' nnn with'+s3+' mm');
if(s3==s2[i])
{
//continue;
// alert('Removing'+s3);
}
else
{
if(document.form123.category.value=="")
{
document.form123.category.value=s2[i];
}
else
{
document.form123.category.value=document.form123.category.value+";"+s2[i];
}
}
if(rem_id==id_split[i])
{
//continue;
// alert('Removing'+s3);
}
else
{
if(document.form123.cid.value=="")
{
document.form123.cid.value=id_split[i];
}
else
{
document.form123.cid.value=document.form123.cid.value+";"+id_split[i];
}
}
i++;
}
//window.document.form123.related.value="";
//window.document.form123.rel_id.value="";
}
function validate_form(frm)
{
updateRTEs();
if(frm.cid.value=='')
{
alert('Please choose atleast one category');
frm.cats.focus();
return(false);
}
if(frm.sb_title.value=='')
{
alert('Please specify Title');
frm.sb_title.focus();
return(false);
}
else if(frm.sb_title.value.match(/[&<>]+/))
{
alert("Please remove special characters from Title i.e. & < >");
frm.sb_title.focus();
frm.sb_title.select();
return(false);
}
if(frm.sb_description.value=='')
{
alert('Please specify Description');
return(false);
}
if( isNaN(frm.sb_quantity.value) || frm.sb_quantity.value<=0)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -