| Current Path : /home/zqegovsj/public_html/us3.supplierlist.com/member/master/ |
| Current File : /home/zqegovsj/public_html/us3.supplierlist.com/member/master/freemember.php |
<?php
$inc_path = "../../haibo/en/";$ua_sm_compile_dir = "newmember/";
require($inc_path."global.php");
require("./session2.php");
uaCheckPermission(2);
$sql="select username,user_reg from members where id=".$id;
$rest = $g_db->GetArray($sql);
$sql="select user_reg from members where id=".$_SESSION['MemberID'];
$res = $g_db->GetArray($sql);
uses("member","industry","company","access","setting");
if($_SESSION['Version']=="en")setvar("imgpath", "../../");else setvar("imgpath", "../../".$_SESSION['Version']."/");
$keyword=new Keywords();
$setting= new Settings();
$access = new Accesses();
$industry = new Industries();
$member = new Members();
$company = new Companies();
$tpl_file = "freemember1";
$company_id = $company->field("id","member_id=".$_SESSION['MemberID']);
$sql = "select id,name from ".$_SESSION['Version']."_countries ";
$res = $g_db->GetAll($sql);
setvar("country", $res);
if (isset($_POST['CompanyEdit'])) {
$vals = array();
$vals =$_POST['k'];
$vals['name'] = strip_tags($_POST['name']);
$vals['english_name'] = strip_tags($_POST['english_name']);
if (isset($_POST['cindustry'])) {
$industryid = $_POST['cindustry'];
}else if(isset($_POST['bindustry'])){
$industryid = $_POST['bindustry'];
}else if(isset($_POST['aindustry'])){
$industryid = $_POST['aindustry'];
}
if(!empty($industryid))
$vals['industry_id'] = uaAddSlashes($industryid);
$vals['employee_amount'] = $_POST['EmployeeAmount'];
if($_POST['FoundDate']!="None") $vals['found_date'] = uaDateConvert($_POST['FoundDate']);
$vals['year_annual'] = $_POST['AnnualRevenue'];
if(isset($_POST['manage_type']))
{
$managetype = implode(",",$_POST['manage_type']);
$vals['manage_type'] = $managetype;
}
$vals['property'] = $_POST['company_property'];
$vals['main_prod'] = strip_tags($_POST['main_prod']);
$vals['address'] = strip_tags($_POST['address']);
$vals['description'] = htmlspecialchars($_POST['company_des']);
require(LIB_PATH.'controllers/upload.inc.php');
require(LIB_PATH.'controllers/GDImage.inc.php');
require($inc_path .APP_NAME. 'include/inc.imageWaterMark.php');
if (!empty($_FILES['brand_img']['name'])) {
$f = $_FILES['brand_img'];
ini_set("memory_limit", "32M");
$check_path = uaCheckMediaPath('..'.DS.'..'.DS.$_SESSION['MemberName'].DS.$_SESSION['Version'].DS.$_SESSION['MemberName'].DS."company".DS);
$file_ext = fileext($f['name']);
$this_product_pic = "b".$_SESSION['MemberID']."_".$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","./company.php", $cfg['room']['pic_upload_error'],0);
}
if(!$uploade_file){
flash("./tip.php","./company.php",$cfg['room']['pic_upload_false'],0);
}else {
$oldfile = substr($check_path,0,-7).$_POST['oldbrand_img'];
$oldfile = str_replace("\\","/",$oldfile);
@unlink($oldfile);
$oldsmallfile = substr($check_path,0,-11)."small".DS.$_POST['oldbrand_img'];
@unlink(str_replace("\\","/",$oldsmallfile));
$oldfile = substr($check_path,0,-7).$_POST['oldpicture'];
$oldfile = str_replace("\\","/",$oldfile);
@unlink($oldfile);
$oldsmallfile = substr($check_path,0,-11)."small".DS.$_POST['oldpicture'];
@unlink(str_replace("\\","/",$oldsmallfile));
}
$image = new GDImage2($check_path,uaCheckMediaPath('..'.DS.'..'.DS.$_SESSION['MemberName'].DS.$_SESSION['Version'].DS.$_SESSION['MemberName'].DS."company".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;
}
imageWaterMark($check_path.$this_product_pic,8,"",$water_text,5,$water_color);
}
if(!empty($this_product_pic)) {
$vals['brand_img'] = $this_product_pic;
}
}
if(!empty($_FILES['picture']['name'])) {
$f = $_FILES['picture'];
ini_set("memory_limit", "32M");
$check_path = uaCheckMediaPath('..'.DS.'..'.DS.$_SESSION['MemberName'].DS.$_SESSION['Version'].DS.$_SESSION['MemberName'].DS."company".DS);
$file_ext = fileext($f['name']);
$this_product_pic = "p".$_SESSION['MemberID']."_".$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","./company.php", $cfg['room']['pic_upload_error'],0);
}
if(!$uploade_file){
flash("./tip.php","./company.php",$cfg['room']['pic_upload_false'],0);
}else {
$oldfile = substr($check_path,0,-7).$_POST['oldpicture'];
$oldfile = str_replace("\\","/",$oldfile);
@unlink($oldfile);
$oldsmallfile = substr($check_path,0,-11)."small".DS.$_POST['oldpicture'];
@unlink(str_replace("\\","/",$oldsmallfile));
}
$image = new GDImage2($check_path,uaCheckMediaPath('..'.DS.'..'.DS.$_SESSION['MemberName'].DS.$_SESSION['Version'].DS.$_SESSION['MemberName'].DS."company".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;
}
imageWaterMark($check_path.$this_product_pic,8,"",$water_text,5,$water_color);
}
if(!empty($this_product_pic)) {
$vals['picture'] = $this_product_pic;
}
}
$vals['boss_name'] = $_POST['bossname'];
$vals['reg_address'] = $_POST['reg_address'];
$vals['reg_fund'] = $_POST['reg_fund'];
$vals['bank_from'] = $_POST['bank_from'];
$vals['bank_account'] = $_POST['bank_account'];
$vals['main_brand'] = $_POST['main_brand'];
$vals['year_annual'] = $_POST['AnnualRevenue'];
$vals['main_customer'] = $_POST['main_customer'];
$vals['main_biz_place'] = $_POST['main_biz_place'];
$vals['link_man'] = $_POST['linkman'];
$vals['position'] = $_POST['position'];
$vals['telcode'] = $_POST['telcode'];
$vals['zipcode'] = $_POST['zipcode'];
$vals['telzone'] = $_POST['telzone'];
$vals['tel'] = $_POST['tel'];
$vals['faxcode'] = $_POST['faxcode'];
$vals['faxzone'] = $_POST['faxzone'];
$vals['fax'] = $_POST['fax'];
$vals['mobile'] = $_POST['mobile'];
$vals['site_url'] = $_POST['site_url'];
$vals['link_man_gender'] = $_POST['link_man_gender'];
$vals['email'] = $_POST['email'];
if($_POST['countryid']!='') $vals['country_id'] = $_POST['countryid'];
if($_POST['provinceid']!='') $vals['province_code_id'] = $_POST['provinceid'];
if(isset($_POST['cityid'])) $vals['city_code_id'] = $_POST['cityid'];
if(isset($_POST['main_market'])) {
$mainmarket = implode(",",$_POST['main_market']);
$vals['main_market'] = $mainmarket;
}
$check_company_update = $access->field("check_company_update","membertype_id=".$ua_user['user_type']);
if ($check_company_update==0) {
$vals['status'] = 1;
$message_info = $cfg['room']['action_complete'];
}else {
$vals['status'] = 0;
$message_info = $cfg['room']['msg_wait_check'];
}
array_walk($vals,"uatrim");
if(!empty($company_id)){
$vals['modified'] = $time_stamp;
$company->save($vals, "update", $company_id, null, " and member_id=".$_SESSION['MemberID']);
} else {
$vals['member_id'] = $_SESSION['MemberID'];
$vals['created'] = $time_stamp;
$company->save($vals);
$last_company_id = $g_db->Insert_ID();
}
flash("./tip.php","./company.php",$message_info);
}
if(!empty($company_id)){
$company->primaryKey = "id";
$fields = $company->getFieldAliasNames();
$fields.= ",".$company->alias_cols.",AreaProvince.name AS CompanyProvince";
$res = $company->read2($fields,$company_id,null," and Company.member_id=".$_SESSION['MemberID']);
if(!empty($res['CompanyIndustryId']))
$current_industry = $industry->searchParentIndustry($res['CompanyIndustryId']);
if (is_array($current_industry)) {
$search_industry_ids = implode(",",$current_industry);
$industry=$g_db->GetArray("SELECT id ,name AS IndustryName FROM ".$industry->getTable()." WHERE id in (".$search_industry_ids.")");
setvar("Industry1",$industry[0]);
setvar("Industry2",$industry[1]);
}
}
$res['CompanyDescription']= stripslashes($res['CompanyDescription']);
$res['CompanyDescription']=html_entity_decode($res['CompanyDescription']);
setvar("CompanyInfo",$res);
setvar("company_des",$res['CompanyDescription']);
editor("company_des", $res['CompanyDescription'], "FCK_NEWSCONTENT");
setvar("CompanyProperty",$company->economic_type);
$selected['property'] = $res['CompanyProperty'];
setvar("SelectedType",$selected['property']);
setvar("ManageTypes",$company->manage_type);
$selected['properties'] = explode(",",$res['CompanyManageType']);
setvar("SelectedProperty",$selected['properties']);
setvar("MainMarkets",$company->main_market);
$selected['markets'] = explode(",",$res['CompanyMainMarket']);
setvar("SelectedMarket",$selected['markets']);
setvar("CompanyFunds",$company->company_funds);
$selected['fund'] = $res['CompanyRegFund'];
setvar("SelectedFund",$selected['fund']);
setvar("CompanyAnual",$company->year_annuals);
$selected['annual'] = $res['CompanyYearAnnual'];
setvar("SelectedAnual",$selected['annual']);
setvar("LinkmanPositions",$member->ua_positions);
setvar("Genders",$member->genders);
setvar("SelectedPosition",$res['CompanyPosition']);
setvar("EmployeeAmounts",$company->employee_amount);
setvar("SelectedEmployeeAmount",$res['CompanyEmployeeAmount']);
unset($selected,$res);
function get_Product(){
$sql = "select id,name,parentid from ".$_SESSION['Version']."_industries where parentid = 0 order by id asc";
$rs = mysql_query($sql);
$arr = array();
while ($row = mysql_fetch_array($rs)){
$arr[$row['id']] ['id'] = $row['id'];
$arr[$row['id']] ['name'] = $row['name'];
$arr[$row['id']] ['parentid'] = $row['parentid'];
}
return $arr;
}
/*** 从lian.html中ajax传过来的值,并获取传到where条件中 ***/
if($_GET['pid'] != ""){
function get_Product_tow(){ //二级产品查询
$pid = $_GET['pid'];
$sql="select id,parentid,name from ".$_SESSION['Version']."_industries where parentid='$pid'";
$rs = mysql_query($sql);
$arr = array();
while ($row = mysql_fetch_array($rs)){
$arr[$row['id']] ['id'] = $row['id'];
$arr[$row['id']] ['name'] = $row['name'];
$arr[$row['id']] ['parentid'] = $row['parentid'];
}
return $arr;
}
}else {
function get_Product_tow($industry){ // 如果为空的话, 直接查询pid = 1的所有内容, 这里也比较好理解
$sql="select name,id,parentid from ".$_SESSION['Version']."_industries where parentid='".$industry."'";
$rs = mysql_query($sql);
$arr = array();
while ($row = mysql_fetch_array($rs)){
$arr[$row['id']] ['id'] = $row['id'];
$arr[$row['id']] ['name'] = $row['name'];
$arr[$row['id']] ['pid'] = $row['pid'];
}
return $arr;
}
}
setvar('get_Product_tow',get_Product_tow($industry[0]['id'])); //二级产品
setvar('get_Product',get_Product());
if($freeedit==1)$tpl_file = "freemember2";
include("head.php");template("./newmember/".$tpl_file);
?>