⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 edit_product.php

📁 通达OA部分源代码
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?php
include_once'logincheck.php';
include_once("myconnect.php");
include_once("check_msg_function.php");

function RTESafe($strText) {
	//returns safe code for preloading in the RTE
	$tmpString = trim($strText);
	
	//convert all types of single quotes
	$tmpString = str_replace(chr(145), chr(39), $tmpString);
	$tmpString = str_replace(chr(146), chr(39), $tmpString);
	$tmpString = str_replace("'", "&#39;", $tmpString);
	
	//convert all types of double quotes
	$tmpString = str_replace(chr(147), chr(34), $tmpString);
	$tmpString = str_replace(chr(148), chr(34), $tmpString);
//	$tmpString = str_replace("\"", "\"", $tmpString);
	
	//replace carriage returns & line feeds
	$tmpString = str_replace(chr(10), " ", $tmpString);
	$tmpString = str_replace(chr(13), " ", $tmpString);
	
	return $tmpString;
}


/////////---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));

$errcnt=0;
if(count($_POST)<>0)		//IF SOME FORM WAS POSTED DO VALIDATION
{
	$sb_id=$_REQUEST["sb_id"];

	$cat_list=str_replace(";",",",$_REQUEST["category"]);
	$cid_list=str_replace(";",",",$_REQUEST["cid"]);
	
	$cat=explode(",",$cid_list);
//	$cat_name=explode(",",$_REQUEST["category"]);
	
	$sb_title=$_REQUEST["sb_title"];
	$sb_description=$_REQUEST["sb_description"];
	$sb_quantity=$_REQUEST["sb_quantity"];
	$sb_keywords=$_REQUEST["sb_keywords"];
	$key=explode(",",$sb_keywords);


	$sb_location=$_REQUEST["sb_location"];
	$sb_min_order=$_REQUEST["sb_min_order"];
	$sb_price_cur_id=$_REQUEST["sb_price_cur_id"];
	$sb_price=$_REQUEST["sb_price"];
	$sb_samples_available=$_REQUEST["sb_samples_available"];
	$sb_product_status=$_REQUEST["sb_product_status"];
	$sb_delivery_time=$_REQUEST["sb_delivery_time"];
	$sb_payment_mode='-1';
	if(isset($_REQUEST["sb_cash"]) && ($_REQUEST["sb_cash"]=='yes') )
		$sb_payment_mode.=',cash';
	if(isset($_REQUEST["sb_cheque"]) && ($_REQUEST["sb_cheque"]=='yes') )
		$sb_payment_mode.=',cheque';
	if(isset($_REQUEST["sb_credit"]) && ($_REQUEST["sb_credit"]=='yes') )
		$sb_payment_mode.=',credit';
	if(isset($_REQUEST["sb_bank"]) && ($_REQUEST["sb_bank"]=='yes') )
		$sb_payment_mode.=',bank';
	if(isset($_REQUEST["sb_loc"]) && ($_REQUEST["sb_loc"]=='yes') )
		$sb_payment_mode.=',loc';
	if(isset($_REQUEST["sb_escrow"]) && ($_REQUEST["sb_escrow"]=='yes') )
		$sb_payment_mode.=',escrow';
//echo $sb_payment_mode;
	$sb_other_mode=$_REQUEST["sb_other_mode"];
	$sb_shipping_cost=$_REQUEST["sb_shipping_cost"];	
// echo $cid_list."---hello";
		if( $cid_list == '' )
		{
			$errs[$errcnt]="Atleast one Category must be provided";
			$errcnt++;
		}
		elseif(count($cat) > $sbrow_gro["sb_cat_cnt"])
		{
			$errs[$errcnt]="Too many Categories provided";
			$errcnt++;
		}
		
		
		if ( strlen(trim($sb_title)) == 0 )
		{
			$errs[$errcnt]="Title must be provided";
			$errcnt++;
		}
		elseif(preg_match ("/[<>&]/", $sb_title))
		{
			$errs[$errcnt]="Title can not have any special character i.e. & < >";
			$errcnt++;
		}

		if ( strlen(trim($sb_description)) == 0 )
		{
			$errs[$errcnt]="Description must be provided";
			$errcnt++;
		}
		elseif ( strlen(strip_tags($sb_description)) > $sbrow_con['sb_description_length'] )
		{
			$errs[$errcnt]="Description length must not exceed ".$sbrow_con['sb_description_length']." characters";
			$errcnt++;
		}
		elseif( $sbrow_con["sb_approval_type_offer"] == 'auto')
		{
			if ( check_msg($sb_description,0) == 'yes' )
			{
				$errs[$errcnt]="Description must not contain bad words";
				$errcnt++;
			}
		}
		
		if ( !is_numeric($sb_quantity) || ($sb_quantity <= 0) )
		{
			$errs[$errcnt]="Quantity must be non-zero positive integer";
			$errcnt++;
		}
		
		if ( strlen(trim($sb_keywords)) == 0 )
		{
			$errs[$errcnt]="Keywords must be provided";
			$errcnt++;
		}
		elseif(preg_match ("/[<>&]/", $sb_keywords))
		{
			$errs[$errcnt]="Keywords can not have any special character i.e. & < >";
			$errcnt++;
		}
		elseif(count($key) > $sbrow_gro["sb_keyword_cnt"])
		{
			$errs[$errcnt]="Too many keywords provided";
			$errcnt++;
		}
		
		if ( strlen(trim($sb_location)) == 0 )
		{
			$errs[$errcnt]="Location must be provided";
			$errcnt++;
		}
		elseif(preg_match ("/[<>&]/", $sb_location))
		{
			$errs[$errcnt]="Location can not have any special character i.e. & < >";
			$errcnt++;
		}
		
		if ( !is_numeric($sb_min_order) || ($sb_min_order <= 0) )
		{
			$errs[$errcnt]="Minimum Order must be non-zero positive integer";
			$errcnt++;
		}
		
		if ( !is_numeric($sb_price_cur_id) || ($sb_price_cur_id == 0) )
		{
			$errs[$errcnt]="Price currency must be selected";
			$errcnt++;
		}

		if ( !is_numeric($sb_price) || ($sb_price <= 0) )
		{
			$errs[$errcnt]="Price must be non-zero positive number";
			$errcnt++;
		}
		
		if ( !is_numeric($sb_delivery_time) || ($sb_delivery_time < 0) )
		{
			$errs[$errcnt]="Delivery Time must be positive integer";
			$errcnt++;
		}

		if ( !isset($_REQUEST["sb_cash"]) && !isset($_REQUEST["sb_cheque"]) && !isset($_REQUEST["sb_credit"]) && !isset($_REQUEST["sb_bank"]) && !isset($_REQUEST["sb_loc"]) && !isset($_REQUEST["sb_escrow"]) && (strlen(trim($sb_other_mode))==0) )
		{
			$errs[$errcnt]="Atleast one Payment Mode must be provided";
			$errcnt++;
		}

		if ( !is_numeric($sb_shipping_cost) || ($sb_shipping_cost < 0) )
		{
			$errs[$errcnt]="Shipping Cost must be positive number";
			$errcnt++;
		}
		
			
		if($errcnt==0)
		{
			if(!get_magic_quotes_gpc())
			{
				$sb_title=str_replace("$","\$",addslashes($sb_title));
				$sb_description=str_replace("$","\$",addslashes($sb_description));
				$sb_quantity=str_replace("$","\$",addslashes($sb_quantity));
				$sb_keywords=str_replace("$","\$",addslashes($sb_keywords));
				$sb_location=str_replace("$","\$",addslashes($sb_location));
				$sb_samples_available=str_replace("$","\$",addslashes($sb_samples_available));
				$sb_product_status=str_replace("$","\$",addslashes($sb_product_status));
				$sb_other_mode=str_replace("$","\$",addslashes($sb_other_mode));
			}
			else
			{
				$sb_title=str_replace("$","\$",$sb_title);
				$sb_description=str_replace("$","\$",$sb_description);
				$sb_quantity=str_replace("$","\$",$sb_quantity);
				$sb_keywords=str_replace("$","\$",$sb_keywords);
				$sb_location=str_replace("$","\$",$sb_location);
				$sb_samples_available=str_replace("$","\$",$sb_samples_available);
				$sb_product_status=str_replace("$","\$",$sb_product_status);
				$sb_other_mode=str_replace("$","\$",$sb_other_mode);
			}
			$sb_min_order=(int)$sb_min_order;
			$sb_price_cur_id=(int)$sb_price_cur_id;
			$sb_price=$sb_price;
			$sb_delivery_time=(int)$sb_delivery_time;
			$sb_shipping_cost=$sb_shipping_cost;	
			
			$sb_uid=$_SESSION["sbbleads_userid"];

		if($sbrow_con['sb_approval_type_offer']=='auto')
		{
			$sb_approved='yes';
			$sb_msg='Your product catalog has been updated';
		}
		else
		{
			$sb_approved='no';
			$sb_msg='Your update request has been sent for admin approval, it will be visible after approval';
		}
		$sbqu_off="update `sbbleads_products` set sb_title='$sb_title', sb_description='$sb_description', sb_quantity=$sb_quantity, sb_keywords='$sb_keywords', sb_location='$sb_location', sb_min_order=$sb_min_order, sb_price_cur_id=$sb_price_cur_id, sb_price=$sb_price, sb_samples_available='$sb_samples_available', sb_product_status='$sb_product_status', sb_delivery_time=$sb_delivery_time, sb_payment_mode='$sb_payment_mode', sb_other_mode='$sb_other_mode', sb_shipping_cost=$sb_shipping_cost, sb_approved='$sb_approved' where sb_id=$sb_id and sb_uid=$sb_uid";
	//	die($sbqu_off);
		mysql_query($sbqu_off);
		if(mysql_affected_rows()>0)
		{
	///-----deleteing previous cats
			$sbq1_off_cat="delete from sbbleads_product_cats where sb_offer_id=$sb_id";
			mysql_query($sbq1_off_cat);
			foreach($cat as $sb_value)
			{
				$sbq_off_cat="select * from sbbleads_product_cats where sb_offer_id=$sb_id and sb_cid=$sb_value";
				//echo $sbq_off_cat;
//				$sbrs_off_cat=
				if( mysql_num_rows(mysql_query($sbq_off_cat)) > 0 )
					continue;		//skips if record already exists
				$sbqi_off_cat="insert into sbbleads_product_cats (sb_offer_id, sb_cid) values ($sb_id, $sb_value)";
				mysql_query($sbqi_off_cat);
			}
	if($sb_approved=="yes")
	{
	header ("Location: gen_confirm_mem.php?sb_type=3&id=$sb_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=edit_product&id=$sb_id&errmsg=".urlencode("Sorry, no updations carried out."));
			die();
		}
		}// if no errors

}// if form posted
else
{

//////////////////////////////////---------------------------
	if( !isset($_REQUEST["sb_id"]) && !is_numeric($_REQUEST["sb_id"]) )
	{
		header("Location: gen_confirm_mem.php?errmsg=".urlencode("No such offer found."));
		die();
	}
	$sb_id=$_REQUEST["sb_id"];
	$sbq_off="select * from sbbleads_products where sb_id=$sb_id and sb_uid=".$_SESSION["sbbleads_userid"];
//	die($sbq_off);
	$sbrow_off=mysql_fetch_array(mysql_query($sbq_off));
	if(!$sbrow_off)
	{
		header("Location: gen_confirm_mem.php?errmsg=".urlencode("Invalid access, denied."));
		die();
	}
	
//	$cid_list='';
//	$sb_cat_list='';
	$sb_title=$sbrow_off['sb_title'];
	$sb_description=$sbrow_off['sb_description'];
	$sb_quantity=$sbrow_off['sb_quantity'];
	$sb_keywords=$sbrow_off['sb_keywords'];
	$sb_location=$sbrow_off['sb_location'];
	$sb_min_order=$sbrow_off['sb_min_order'];
	$sb_price_cur_id=$sbrow_off['sb_price_cur_id'];
	$sb_price=$sbrow_off['sb_price'];
	$sb_samples_available=$sbrow_off['sb_samples_available'];
	$sb_product_status=$sbrow_off['sb_product_status'];
	$sb_delivery_time=$sbrow_off['sb_delivery_time'];
	$sb_payment_mode=$sbrow_off['sb_payment_mode'];
	$sb_other_mode=$sbrow_off['sb_other_mode'];
	$sb_shipping_cost=$sbrow_off['sb_shipping_cost'];

	$sbq_off_cat="select * from sbbleads_product_cats where sb_offer_id=$sb_id";
	$sbrs_off_cat=mysql_query($sbq_off_cat);

$cat_list="";
$cid_list="";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -