| Current Path : /home/zqegovsj/public_html/us3.supplierlist.com/member/master/ |
| Current File : /home/zqegovsj/public_html/us3.supplierlist.com/member/master/freemember3.php |
<?php
$inc_path = "../../haibo/en/";$ua_sm_compile_dir = "newmember/";
require($inc_path."global.php");
require($inc_path .APP_NAME. 'lang/'.$app_lang.'/room.inc.php');
require($inc_path .APP_NAME. 'include/inc.discuz.php');
require($inc_path .APP_NAME. 'configs/db_session.php');
$sql="select username from members where id=".$session_id;
$rest = $g_db->GetArray($sql);
setvar("logoutname",$rest[0][0]);
setvar("imgpath", "../../".$rest[0][0]."/en/".$rest[0][0]."/");
uses("trade","member","producttype","product","industry","setting","company");
$setting = new Settings();
$company = new Companies();
$industry = new Industries();
$member = new Members();
$product = new Products();
$producttype = new Producttypes();
$trade = new Trades();
$tpl_file = "freemember4";
$conditions = " member_id=".$session_id;
$company_id = $company->field("id", "member_id=".$session_id);
$conditions.=" and level=0";
$ts = $producttype->findAll($producttype->common_cols,$conditions," id DESC",0,30);
$count1=$producttype->findAll('count(*)',"1=1"," id DESC",0,50);
$count2=$producttype->findAll('count(*)',$conditions," id DESC",0,50);
for($i=0;$i<$count2[0][0];$i++)
{
$a[$i]= $producttype->findAll($producttype->common_cols,"level='".$ts[$i][0]."'"," id DESC",0,50);
$ct=$producttype->findAll('count(*)',"level='".$ts[$i][0]."'"," id DESC",0,50);
if($i==0){$typeres[0]=$ts[0];
for($j=0;$j<$ct[0][0];$j++){
$typeres[$j+1]=$a[$i][$j];
}if($ts[1]!=''){$typeres[$ct[0][0]+1]=$ts[1];$x=$ct[0][0]+1;}
}else{
for($j=0;$j<$ct[0][0];$j++){
$typeres[$x+1+$j]=$a[$i][$j];
}
$x+=$ct[0][0]+1;
if($x==$count1[0][0])break;
if($ts[$i+1]!='')$typeres[$x]=$ts[$i+1];
}
}
$list = $typeres;
if(count($typeres)==0){flash("./tip.php","./producttype.php","Please add a category");
}
$conditions = " and member_id=".$session_id;
if (($_GET['action']=="mod") && (!empty($_GET['id']))) {
$sql="select * from ".$_SESSION['Version']."_keywords where member_id=".$session_id." and product_id=".$_GET['id'];
$res = $g_db->GetAll($sql);
setvar("keywords",$res);
$productinfo = $product->read(null,$_GET['id'],null,$conditions);
if (empty($productinfo)) {
gotoUrl("./tip.php?id=1005");
}else {
$current_industry = $industry->searchParentIndustry($productinfo['ProductIndustryId']);
if (is_array($current_industry)) {
$search_industry_ids = implode(",",$current_industry);
setvar("CurrentIndustry",$g_db->GetArray("select name AS IndustryName from ".$industry->getTable(true)." where id in (".$search_industry_ids.")"));
}
$sql="select id,name,level from ".$_SESSION['Version']."_producttypes where id = '".$productinfo['ProductProducttypeId']."'";
$res=$g_db->GetAll($sql);
setvar("b","product.php?action=list&sid=".$res[0][0]);
setvar("bb",$res[0][1]);
$sql="select id,name from ".$_SESSION['Version']."_producttypes where id = '".$res[0][2]."'";
$res=$g_db->GetAll($sql);
if($res!=''){
setvar("c","product.php?action=list&sid=".$res[0][0]);
setvar("cc",$res[0][1]);}
$productinfo['ProductContent']=stripslashes($productinfo['ProductContent']);
$productinfo['ProductContent']=html_entity_decode($productinfo['ProductContent']);
setvar("ProductInfo",$productinfo);
}
}else{
}
if (isset($_POST['action'])) {
if($_POST['action']=="product_edit"){
uses("access");
$access = new Accesses();
$vals = array();
$now_product_amount = $product->findCount("member_id=".$session_id);
$max_product_amount = intval($access->field("max_product","membertype_id=".$ua_user['user_type']));
$check_product_update = intval($access->field("check_product_update","membertype_id=".$ua_user['user_type']));
if ($check_product_update=="0") {
$vals['status'] = 1;
}else {
$vals['status'] = 0;
$message_info = $cfg['room']['msg_wait_check'];
}
$pid = intval($_POST['id']);
if ($max_product_amount!=0 && $now_product_amount>=$max_product_amount && (empty($pid))) {
$msg = $cfg['room']['mx_prod_day'];
flash("./tip.php","./product.php",$msg,0);
}
if (!empty($_FILES['pic']['name'])) {
require(LIB_PATH.'controllers/upload.inc.php');
$f = $_FILES['pic'];
require(LIB_PATH.'controllers/GDImage.inc.php');
ini_set("memory_limit", "32M");
$check_path = uaCheckMediaPath('..'.DS.'..'.DS.$rest[0][0].DS.'en'.DS.$rest[0][0].DS."products".DS);
$file_ext = fileext($f['name']);
$this_product_pic = $session_id."_".$pid."_".$time_stamp.$file_ext;
$u = new upload($f['name']);
if($u->checkImage()){
$uploade_file = move_uploaded_file($f['tmp_name'],$check_path.$this_product_pic);
}else{
flash("./tip.php","./product.php", $cfg['room']['pic_upload_error'],0);
}
if(!$uploade_file){
flash("./tip.php","./product.php",$cfg['room']['pic_upload_false'],0);
}else {
$oldfile = substr($check_path,0,-7).$_POST['oldimgname'];
$oldfile = str_replace("\\","/",$oldfile);
@unlink($oldfile);
$oldsmallfile = substr($check_path,0,-11)."small".DS.$_POST['oldimgname'];
@unlink(str_replace("\\","/",$oldsmallfile));
}
$image = new GDImage2($check_path,uaCheckMediaPath('..'.DS.'..'.DS.$rest[0][0].DS.'en'.DS.$rest[0][0].DS."products".DS,"small".DS));
$image->makeThumb($this_product_pic);
$set_watermark = $setting->field("ab","aa='watermark'");
if($set_watermark && empty($pid)){
$water_text = $setting->field("ab","aa='watertext'");
$water_color = $setting->field("ab","aa='watercolor'");
if (empty($water_text)) {
$water_text = URL;
}
require($inc_path .APP_NAME. 'include/inc.imageWaterMark.php');
imageWaterMark($check_path.$this_product_pic,8,"",$water_text,5,$water_color);
}
}
if(!empty($this_product_pic)) {
$vals['picture'] = $this_product_pic;
}
$industryid = 0;
if ($_POST['cindustry']) {
$industryid = $_POST['cindustry'];
}else if($_POST['bindustry']){
$industryid = $_POST['bindustry'];
}else if($_POST['aindustry']){
$industryid = $_POST['aindustry'];
}
if($industryid)
$vals['industry_id'] = $industryid;
$vals['name'] = $_POST['prod_name'];
$vals['sort_id'] = $_POST['sort_id'];
$vals['sn'] = $_POST['prod_sn'];
$vals['spec'] = $_POST['scale'];
$vals['packing_content'] = $_POST['package'];
$vals['price'] = $_POST['price'];
$vals['produce_area'] = $_POST['fromwhere'];
$vals['content'] = htmlspecialchars($_POST['content']);
$vals['producttype_id'] = $_POST['product_type'];
$sort_arr = implode(",", $_POST['kid']);
$sql="DELETE FROM `en_keywords` WHERE `id` in (".$sort_arr.")";
$res = $g_db->Query($sql);
$a=array(); $a=$_POST['prodKeyword'];
}
array_walk($vals,"uatrim");
if(!empty($vals['keywords'])){
$keyword->importKeys($vals['keywords'], $pid, 4);
}
if (empty($company_id)) {
flash("./tip.php","./company.php", $cfg['room']['re_complete_corp'],0);
}
if (!empty($pid)) {
$result = $product->save($vals, "update", $pid, null, $conditions);
for($i=1;$i<=count($a);$i++)
{
if($a[$i]!='')
{
$sql="INSERT INTO `en_keywords` (
`id` ,
`member_id` ,
`company_id` ,
`product_id` ,
`name` ,
`created`
)
VALUES (
NULL , '".$session_id."', '".$company_id."', '".$pid."', '".$a[$i]."', now()
)";
$res = $g_db->Query($sql);}}
}else {
$vals['member_id'] = $session_id;
$vals['company_id'] = $company_id;
$vals['created'] = $time_stamp;
$result = $product->save($vals);
$sql="select id from ".$_SESSION['Version']."_products where name = ".$_POST['prod_name']." and producttype_id =".$_POST['product_type']." and member_id='".$session_id."' order by id ASC limit 0,1";
echo $sql;
$r = $g_db->GetAll($sql);
for($i=1;$i<=count($a);$i++)
{
if($a[$i]!='')
{
$sql="INSERT INTO `en_keywords` (
`id` ,
`member_id` ,
`company_id` ,
`product_id` ,
`name` ,
`created`
)
VALUES (
NULL , '".$session_id."', '".$company_id."', '".$r[0][0]."', '".$a[$i]."', now()
)";
$res = $g_db->Query($sql);
}
}
}
if ($result) {
$message_info = $cfg['room']['action_complete'];
flash("./tip.php","./product.php",$message_info);
}else {
flash("./tip.php","./product.php",$message_info,0);
}
}
setvar("ProductSorts",$product->product_sorts);
setvar("ProductTypes",$list);
$conditions = "member_id = ".$session_id;
if($secid!=''){
$sql = "select * from ".$_SESSION['Version']."_img where section_id = ".$secid." and member_id = ".$session_id." order by img_range DESC
";
}else{
$sql = "select * from ".$_SESSION['Version']."_img where product_id = ".$_GET['id']." and member_id = ".$session_id." order by img_range DESC
";}
setvar("s",$secid);
setvar("p",$_GET['id']);
$res = $g_db->GetArray($sql);
setvar("imglist",$res);
if($secid!=''){
$sql = "select * from ".$_SESSION['Version']."_newsection where id = ".$secid." and member_id = ".$session_id."
";
$res = $g_db->GetArray($sql);
setvar("sn",$res[0]);
}else{
$sql = "select * from ".$_SESSION['Version']."_products where id = ".$_GET['id']." and member_id = ".$session_id."
";
$res = $g_db->GetArray($sql);
setvar("pd",$res[0]);
}
setvar("i",4);
include("head.php");template("newmember/".$tpl_file);
?>