Exemplo n.º 1
0
 /**
  * ajax上传图片
  */
 public function image_uploadOp()
 {
     // 判断图片数量是否超限
     $model_album = Model('album');
     $album_limit = $this->store_grade['sg_album_limit'];
     if ($album_limit > 0) {
         $album_count = $model_album->getCount(array('store_id' => 0));
         if ($album_count >= $album_limit) {
             $error = L('store_goods_album_climit');
             if (strtoupper(CHARSET) == 'GBK') {
                 $error = Language::getUTF8($error);
             }
             exit(json_encode(array('error' => $error)));
         }
     }
     // $class_info = $model_album->getOne(array('store_id' => 0, 'is_default' => 1), 'album_class');
     // 上传图片
     $upload = new UploadFile();
     $upload->set('default_dir', ATTACH_GOODS . DS . '0' . DS . $upload->getSysSetPath());
     $upload->set('max_size', C('image_max_filesize'));
     $upload->set('thumb_width', GOODS_IMAGES_WIDTH);
     $upload->set('thumb_height', GOODS_IMAGES_HEIGHT);
     $upload->set('thumb_ext', GOODS_IMAGES_EXT);
     $upload->set('fprefix', '0');
     $upload->set('allow_type', array('gif', 'jpg', 'jpeg', 'png'));
     $result = $upload->upfile($_POST['id']);
     if (!$result) {
         if (strtoupper(CHARSET) == 'GBK') {
             $upload->error = Language::getUTF8($upload->error);
         }
         $output = array();
         $output['error'] = $upload->error;
         $output = json_encode($output);
         exit($output);
     }
     $img_path = $upload->getSysSetPath() . $upload->file_name;
     $thumb_page = $upload->getSysSetPath() . $upload->thumb_image;
     // 取得图像大小
     list($width, $height, $type, $attr) = getimagesize(UPLOAD_SITE_URL . '/' . ATTACH_GOODS . '/' . '0' . DS . $img_path);
     // 存入相册
     $image = explode('.', $_FILES[$_POST['id']]["name"]);
     $insert_array = array();
     $insert_array['apic_name'] = $image['0'];
     $insert_array['apic_tag'] = '';
     $insert_array['aclass_id'] = 0;
     $insert_array['apic_cover'] = $img_path;
     $insert_array['apic_size'] = intval($_FILES[$_POST['id']]['size']);
     $insert_array['apic_spec'] = $width . 'x' . $height;
     $insert_array['upload_time'] = TIMESTAMP;
     $insert_array['store_id'] = '0';
     $model_album->addPic($insert_array);
     $data = array();
     $data['image'] = cthumb($img_path, 240, '0');
     $data['filename'] = $img_path;
     // 整理为json格式
     $output = json_encode($data);
     echo $output;
     exit;
 }
Exemplo n.º 2
0
 /**
  * 文章管理
  */
 public function article_classOp()
 {
     $lang = Language::getLangContent();
     $model_class = Model('article_class');
     /**
      * 删除
      */
     if ($_POST['form_submit'] == 'ok') {
         if (!empty($_POST['check_ac_id'])) {
             if (is_array($_POST['check_ac_id'])) {
                 $del_array = $model_class->getChildClass($_POST['check_ac_id']);
                 if (is_array($del_array)) {
                     foreach ($del_array as $k => $v) {
                         $model_class->del($v['ac_id']);
                     }
                 }
             }
             showMessage($lang['article_class_index_del_succ']);
         } else {
             showMessage($lang['article_class_index_choose']);
         }
     }
     /**
      * 父ID
      */
     $parent_id = $_GET['ac_parent_id'] ? intval($_GET['ac_parent_id']) : 0;
     /**
      * 列表
      */
     $tmp_list = $model_class->getTreeClassList(2);
     if (is_array($tmp_list)) {
         foreach ($tmp_list as $k => $v) {
             if ($v['ac_parent_id'] == $parent_id) {
                 /**
                  * 判断是否有子类
                  */
                 if ($tmp_list[$k + 1]['deep'] > $v['deep']) {
                     $v['have_child'] = 1;
                 }
                 $class_list[] = $v;
             }
         }
     }
     if ($_GET['ajax'] == '1') {
         /**
          * 转码
          */
         if (strtoupper(CHARSET) == 'GBK') {
             $class_list = Language::getUTF8($class_list);
         }
         $output = json_encode($class_list);
         print_r($output);
         exit;
     } else {
         Tpl::output('class_list', $class_list);
         Tpl::showpage('article_class.index');
     }
 }
Exemplo n.º 3
0
 /**
  * 分类管理
  */
 public function goods_classOp()
 {
     $lang = Language::getLangContent();
     $model_class = Model('goods_class');
     if (chksubmit()) {
         //删除
         if ($_POST['submit_type'] == 'del') {
             $gcids = implode(',', $_POST['check_gc_id']);
             if (!empty($_POST['check_gc_id'])) {
                 if (!is_array($_POST['check_gc_id'])) {
                     $this->log(L('nc_delete,goods_class_index_class') . '[ID:' . $gcids . ']', 0);
                     showMessage($lang['nc_common_del_fail']);
                 }
                 $del_array = $model_class->delGoodsClassByGcIdString($gcids);
                 $this->log(L('nc_delete,goods_class_index_class') . '[ID:' . $gcids . ']', 1);
                 showMessage($lang['nc_common_del_succ']);
             } else {
                 $this->log(L('nc_delete,goods_class_index_class') . '[ID:' . $gcids . ']', 0);
                 showMessage($lang['nc_common_del_fail']);
             }
         }
     }
     //父ID
     $parent_id = $_GET['gc_parent_id'] ? intval($_GET['gc_parent_id']) : 0;
     //列表
     $tmp_list = $model_class->getTreeClassList(3);
     if (is_array($tmp_list)) {
         foreach ($tmp_list as $k => $v) {
             if ($v['gc_parent_id'] == $parent_id) {
                 //判断是否有子类
                 if ($tmp_list[$k + 1]['deep'] > $v['deep']) {
                     $v['have_child'] = 1;
                 }
                 $class_list[] = $v;
             }
         }
     }
     if ($_GET['ajax'] == '1') {
         //转码
         if (strtoupper(CHARSET) == 'GBK') {
             $class_list = Language::getUTF8($class_list);
         }
         $output = json_encode($class_list);
         print_r($output);
         exit;
     } else {
         Tpl::output('class_list', $class_list);
         Tpl::output('top_link', $this->sublink($this->links, 'goods_class'));
         Tpl::showpage('goods_class.index');
     }
 }
Exemplo n.º 4
0
 /**
  * 店铺分类
  */
 public function store_classOp()
 {
     $lang = Language::getLangContent();
     $model_class = Model('store_class');
     //删除
     if (chksubmit()) {
         if (!empty($_POST['check_sc_id'])) {
             if (is_array($_POST['check_sc_id'])) {
                 $del_array = $model_class->getChildClass($_POST['check_sc_id']);
                 if (is_array($del_array)) {
                     foreach ($del_array as $k => $v) {
                         $model_class->del($v['sc_id']);
                     }
                 }
             }
             $this->log(L('nc_del,store_class') . '[ID:' . implode(',', $_POST['check_sc_id']) . ']', 1);
             showMessage($lang['nc_common_del_succ']);
         } else {
             showMessage($lang['nc_common_del_fail']);
         }
     }
     $parent_id = $_GET['sc_parent_id'] ? intval($_GET['sc_parent_id']) : 0;
     $tmp_list = $model_class->getTreeClassList(2);
     if (is_array($tmp_list)) {
         foreach ($tmp_list as $k => $v) {
             if ($v['sc_parent_id'] == $parent_id) {
                 //判断是否有子类
                 if ($tmp_list[$k + 1]['deep'] > $v['deep']) {
                     $v['have_child'] = 1;
                 }
                 $class_list[] = $v;
             }
         }
     }
     if ($_GET['ajax'] == '1') {
         //转码
         if (strtoupper(CHARSET) == 'GBK') {
             $class_list = Language::getUTF8($class_list);
         }
         $output = json_encode($class_list);
         print_r($output);
         exit;
     } else {
         Tpl::output('class_list', $class_list);
         Tpl::showpage('store_class.index');
     }
 }
Exemplo n.º 5
0
 public function updateAddressOp()
 {
     $address_model = Model('address');
     // 验证提交数据
     $obj_validate = new Validate();
     $obj_validate->validateparam = array(array("input" => $_POST["true_name"], "require" => "true", "message" => "真实姓名必填"), array("input" => $_POST["area_id"], "require" => "true", "validator" => "Number", "message" => "地址信息错误"), array("input" => $_POST["city_id"], "require" => "true", "validator" => "Number", "message" => "地址信息错误"), array("input" => $_POST["area_info"], "require" => "true", "message" => "地址信息错误"), array("input" => $_POST["address"], "require" => "true", "message" => "地址信息错误"), array("input" => $_POST['mob_phone'], 'require' => 'true', "validator" => "mobile", 'message' => "手机号码有误"));
     $error = $obj_validate->validate();
     if ($error != '') {
         $error = strtoupper(CHARSET) == 'GBK' ? Language::getUTF8($error) : $error;
         output_error($error);
     }
     $data = array();
     $data['member_id'] = $this->member_info['member_id'];
     $data['true_name'] = $_POST['true_name'];
     $data['area_id'] = intval($_POST['area_id']);
     $data['city_id'] = intval($_POST['city_id']);
     $data['area_info'] = $_POST['area_info'];
     $data['address'] = $_POST['address'];
     $data['mob_phone'] = $_POST['mob_phone'];
     $data['is_default'] = $_POST['is_default'] ? 1 : 0;
     // 判断用户地址数量,如果为0,设置当前添加地址为默认地址
     $address_num = $address_model->getAddressCount(array('member_id' => $this->member_info['member_id'], 'is_default' => 1));
     if ($address_num == 0) {
         $data['is_default'] = 1;
     }
     if ($data['is_default'] == 1) {
         $address_model->editAddress(array('is_default' => 0), array('member_id' => $this->member_info['member_id'], 'is_default' => 1));
     }
     if (intval($_POST['id']) > 0) {
         $rs = $address_model->editAddress($data, array('address_id' => intval($_POST['id']), 'member_id' => $this->member_info['member_id']));
         if (!$rs) {
             output_error("地址信息修改失败");
         }
     } else {
         $count = $address_model->getAddressCount(array('member_id' => $this->member_info['member_id']));
         if ($count >= 20) {
             output_error("最多允许添加20个有效地址");
         }
         $rs = $address_model->addAddress($data);
         if (!$rs) {
             output_error("地址添加失败");
         }
     }
     output_data("设置成功");
 }
Exemplo n.º 6
0
 public function arealistOp()
 {
     $area_model = Model("area");
     $condition = array();
     $condition['parent_area_id'] = $_GET['area_parent_id'] ? intval($_GET['area_parent_id']) : 0;
     if (isset($_POST) && !empty($_POST)) {
         if (isset($_POST['area_name']) && !empty($_POST['area_name'])) {
             $condition['area_name'] = array(array('like', '%' . trim($_POST['area_name']) . '%'));
             Tpl::output('area_name', trim($_POST['area_name']));
         }
         if (isset($_POST['first_letter']) && !empty($_POST['first_letter'])) {
             $condition['first_letter'] = $_POST['first_letter'];
             Tpl::output('first_letter', $_POST['first_letter']);
         }
     }
     $list = $area_model->getList($condition, 15);
     if (!empty($list)) {
         foreach ($list as $key => $val) {
             $child_area = $area_model->table('area')->where(array('parent_area_id' => $val['area_id']))->select();
             if (!empty($child_area)) {
                 $list[$key]['have_child'] = 1;
             }
             unset($child_area);
         }
     }
     Tpl::output('show_page', $area_model->showpage(2));
     Tpl::output('list', $list);
     //城市首字母
     $letterArr = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
     Tpl::output('letter', $letterArr);
     if ($_GET['ajax'] == '1') {
         //转码
         if (strtoupper(CHARSET) == 'GBK') {
             $list = Language::getUTF8($list);
         }
         $output = json_encode($list);
         print_r($output);
         exit;
     } else {
         Tpl::showpage("area.list");
     }
 }
Exemplo n.º 7
0
	/**
	 * 积分礼品购物车更新礼品数量
	 */
	public function updateOp() {
		$pcart_id	= intval($_GET['pc_id']);
		$quantity	= intval($_GET['quantity']);
		//兑换失败提示
		$msg = L('pointcart_cart_modcart_fail');
		//转码
		if (strtoupper(CHARSET) == 'GBK'){
			$msg = Language::getUTF8($msg);//网站GBK使用编码时,转换为UTF-8,防止json输出汉字问题
		}
		if($pcart_id <= 0 || $quantity <= 0) {
			echo json_encode(array('msg'=>$msg));
			die;
		}
		//验证礼品购物车信息是否存在
		$model_pointcart	= Model('pointcart');
		$cart_info	= $model_pointcart->getPointCartInfo(array('pcart_id'=>$pcart_id,'pmember_id'=>$_SESSION['member_id']));
		if (!$cart_info){
			echo json_encode(array('msg'=>$msg)); die;
		}
		
		//验证是否能兑换
		$data = $model_pointcart->checkExchange($cart_info['pgoods_id'], $quantity, $_SESSION['member_id']);
		if (!$data['state']){
		    echo json_encode(array('msg'=>$data['msg'])); die;
		}
		$prod_info = $data['data']['prod_info'];
		$quantity = $prod_info['quantity'];
		
		$cart_state = true;
		//如果数量发生变化则更新礼品购物车内单个礼品数量
		if ($cart_info['pgoods_choosenum'] != $quantity){
		    $cart_state = $model_pointcart->editPointCart(array('pcart_id'=>$pcart_id,'pmember_id'=>$_SESSION['member_id']),array('pgoods_choosenum'=>$quantity));
		}
		if ($cart_state) {
			//计算总金额
			$amount= $model_pointcart->getPointCartAmount($_SESSION['member_id']);
			echo json_encode(array('done'=>'true','subtotal'=>$prod_info['pointsamount'],'amount'=>$amount,'quantity'=>$quantity));
			die;
		}
	}
Exemplo n.º 8
0
 /**
  * AJAX获取商品分类
  */
 public function ajax_classOp()
 {
     $id = intval($_GET['id']);
     $deep = intval($_GET['deep']);
     if ($id <= 0 || $deep <= 0 || $deep >= 4) {
         echo 'false';
         exit;
     }
     $deep += 1;
     $model_goodsclass = Model('goods_class');
     // 验证分类是否存在
     $gc_info = $model_goodsclass->getGoodsClassInfo(array('gc_id' => $id), 'type_id');
     if (empty($gc_info)) {
         echo 'false';
         exit;
     }
     // 读取商品分类
     if ($deep != 4) {
         $gc_list = $model_goodsclass->getGoodsClass($_SESSION['store_id'], $id, $deep);
     }
     // 分类不为空输出分类信息
     if (!empty($gc_list)) {
         $data = array('type' => 'class', 'data' => $gc_list, 'deep' => $deep);
     } else {
         // 查询类型
         $model_type = Model('type');
         $spec_list = $model_type->getSpecByType(array('type_id' => $gc_info['type_id']), 'type_id, spec.*');
         $data = array('type' => 'spec', 'data' => $spec_list, 'gcid' => $id, 'deep' => $deep);
     }
     // 转码
     if (strtoupper(CHARSET) == 'GBK') {
         $data = Language::getUTF8($data);
     }
     echo json_encode($data);
     exit;
 }
Exemplo n.º 9
0
 public function get_complain_talkOp()
 {
     $complain_id = intval($_POST['complain_id']);
     $complain_info = $this->get_complain_info($complain_id);
     $model_complain_talk = Model('complain_talk');
     $param = array();
     $param['complain_id'] = $complain_id;
     $complain_talk_list = $model_complain_talk->getComplainTalk($param);
     $talk_list = array();
     $i = 0;
     foreach ($complain_talk_list as $talk) {
         $talk_list[$i]['css'] = $talk['talk_member_type'];
         $talk_list[$i]['talk'] = date("Y-m-d H:i:s", $talk['talk_datetime']);
         switch ($talk['talk_member_type']) {
             case 'accuser':
                 $talk_list[$i]['talk'] .= Language::get('complain_accuser');
                 break;
             case 'accused':
                 $talk_list[$i]['talk'] .= Language::get('complain_accused');
                 break;
             case 'admin':
                 $talk_list[$i]['talk'] .= Language::get('complain_admin');
                 break;
             default:
                 $talk_list[$i]['talk'] .= Language::get('complain_unknow');
         }
         if (intval($talk['talk_state']) === 2) {
             $talk['talk_content'] = Language::get('talk_forbit_message');
         }
         $talk_list[$i]['talk'] .= '(' . $talk['talk_member_name'] . ')' . Language::get('complain_text_say') . ':' . $talk['talk_content'];
         $i++;
     }
     if (strtoupper(CHARSET) == 'GBK') {
         $talk_list = Language::getUTF8($talk_list);
     }
     echo json_encode($talk_list);
 }
Exemplo n.º 10
0
 protected function echo_json($data)
 {
     if (strtoupper(CHARSET) == 'GBK') {
         $data = Language::getUTF8($data);
         //网站GBK使用编码时,转换为UTF-8,防止json输出汉字问题
     }
     echo json_encode($data);
 }
Exemplo n.º 11
0
 /**
  * 短消息回复保存
  *
  * @param 
  * @return 
  */
 public function savereplyOp()
 {
     Language::read('member_home_message');
     //查询会员是否允许发送站内信
     $isallowsend = $this->allowSendMessage($_SESSION['member_id']);
     if (!$isallowsend) {
         if ($_GET['inajax'] == 1) {
             showDialog(Language::get('home_message_noallowsend'));
         } else {
             showMessage(Language::get('home_message_noallowsend'), 'index.php?act=home&op=message', 'html', 'error');
         }
     }
     if ($_POST['form_submit'] == 'ok') {
         $message_id = intval($_POST["message_id"]);
         if ($message_id <= 0) {
             showMessage(Language::get('wrong_argument'), 'index.php?act=home&op=message', 'html', 'error');
         }
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["msg_content"], "require" => "true", "message" => Language::get('home_message_reply_content_null')));
         $error = $obj_validate->validate();
         if ($error != '') {
             if ($_GET['inajax'] == 1) {
                 showDialog(Language::get('error'));
             } else {
                 showMessage(Language::get('error') . $error, '', 'html', 'error');
             }
         }
         $model_message = Model('message');
         //查询站内信
         $param = array();
         $param['message_id'] = "{$message_id}";
         $param['no_message_state'] = "2";
         //未删除
         $message_info = $model_message->getRowMessage($param);
         if (empty($message_info)) {
             if ($_GET['inajax'] == 1) {
                 showDialog(Language::get('home_message_no_record'));
             } else {
                 showMessage(Language::get('home_message_no_record') . $error, '', 'html', 'error');
             }
         }
         //不能回复自己的站内信
         if ($message_info['from_member_id'] == $_SESSION['member_id']) {
             showMessage(Language::get('home_message_no_record'), '', 'html', 'error');
         }
         $insert_arr = array();
         if ($message_info['message_parent_id'] > 0) {
             $insert_arr['message_parent_id'] = $message_info['message_parent_id'];
         } else {
             $insert_arr['message_parent_id'] = $message_info['message_id'];
         }
         $insert_arr['from_member_id'] = $_SESSION['member_id'];
         $insert_arr['from_member_name'] = $_SESSION['member_name'];
         $insert_arr['member_id'] = $message_info['from_member_id'];
         $insert_arr['to_member_name'] = $message_info['from_member_name'];
         $insert_arr['msg_content'] = $_POST['msg_content'];
         $insert_state = $model_message->saveMessage($insert_arr);
         if ($insert_state) {
             //更新父类站内信更新时间
             $update_arr = array();
             $update_arr['message_update_time'] = time();
             $update_arr['message_open'] = 1;
             $model_message->updateCommonMessage($update_arr, array('message_id' => "{$insert_arr['message_parent_id']}"));
         }
         if ($_GET['inajax'] == 1) {
             $insert_arr['msg_id'] = $insert_state;
             if (strtoupper(CHARSET) == 'GBK') {
                 $insert_arr['msg_content'] = Language::getUTF8($insert_arr['msg_content']);
             }
             $insert_arr['msg_content'] = parsesmiles($insert_arr['msg_content']);
             $data = json_encode($insert_arr);
             $js = "replyMsgSuccess(" . $data . ")";
             showDialog(Language::get('home_message_send_success'), '', 'succ', $js);
         } else {
             showMessage(Language::get('home_message_send_success'), 'index.php?act=home&op=privatemsg');
         }
     } else {
         if ($_GET['inajax'] == 1) {
             showDialog(Language::get('home_message_reply_command_wrong'));
         } else {
             showMessage(Language::get('home_message_reply_command_wrong'), '', 'html', 'error');
         }
     }
 }
Exemplo n.º 12
0
 /**
  * 头部最近浏览的商品
  */
 public function viewed_infoOp()
 {
     $info = array();
     if ($_SESSION['is_login'] == '1') {
         $member_id = $_SESSION['member_id'];
         $info['m_id'] = $member_id;
         if (C('voucher_allow') == 1) {
             $time_to = time();
             //当前日期
             $info['voucher'] = Model()->table('voucher')->where(array('voucher_owner_id' => $member_id, 'voucher_state' => 1, 'voucher_start_date' => array('elt', $time_to), 'voucher_end_date' => array('egt', $time_to)))->count();
         }
         $time_to = strtotime(date('Y-m-d'));
         //当前日期
         $time_from = date('Y-m-d', $time_to - 60 * 60 * 24 * 7);
         //7天前
         $info['consult'] = Model()->table('consult')->where(array('member_id' => $member_id, 'consult_reply_time' => array(array('gt', strtotime($time_from)), array('lt', $time_to + 60 * 60 * 24), 'and')))->count();
     }
     $goods_list = Model('goods_browse')->getViewedGoodsList($_SESSION['member_id'], 5);
     if (is_array($goods_list) && !empty($goods_list)) {
         $viewed_goods = array();
         foreach ($goods_list as $key => $val) {
             $goods_id = $val['goods_id'];
             $val['url'] = urlShop('goods', 'index', array('goods_id' => $goods_id));
             $val['goods_image'] = thumb($val, 60);
             $viewed_goods[$goods_id] = $val;
         }
         $info['viewed_goods'] = $viewed_goods;
     }
     if (strtoupper(CHARSET) == 'GBK') {
         $info = Language::getUTF8($info);
     }
     echo json_encode($info);
 }
Exemplo n.º 13
0
    /**
     * 保存动态
     */
    public function store_sns_saveOp()
    {
        /**
         * 验证表单
         */
        $obj_validate = new Validate();
        $obj_validate->validateparam = array(array("input" => $_POST["content"], "require" => "true", "validator" => "Length", "max" => 140, "min" => 1, "message" => Language::get('store_sns_center_error')), array("input" => $_POST["goods_url"], "require" => "false", "validator" => "url", "message" => Language::get('store_goods_index_goods_price_null')));
        $error = $obj_validate->validate();
        if ($error != '') {
            showDialog($error);
        }
        // 实例化模型
        $model = Model();
        $goodsdata = '';
        $content = '';
        $_POST['type'] = intval($_POST['type']);
        switch ($_POST['type']) {
            case '2':
                $sns_image = trim($_POST['sns_image']);
                if ($sns_image != '') {
                    $content = '<div class="fd-media">
									<div class="thumb-image"><a href="javascript:void(0);" nc_type="thumb-image"><img src="' . $sns_image . '" /><i></i></a></div>
									<div class="origin-image"><a href="javascript:void(0);" nc_type="origin-image"></a></div>
								</div>';
                }
                break;
            case '9':
                $data = $this->getGoodsByUrl(html_entity_decode($_POST['goods_url']));
                if (CHARSET == 'GBK') {
                    foreach ((array) $data as $k => $v) {
                        $data[$k] = Language::getUTF8($v);
                    }
                }
                $goodsdata = addslashes(json_encode($data));
                break;
            case '10':
                if (is_array($_POST['goods_id'])) {
                    $goods_id_array = $_POST['goods_id'];
                } else {
                    showDialog(Language::get('store_sns_choose_goods'));
                }
                $field = 'goods_id,store_id,goods_name,goods_image,goods_price,goods_freight';
                $where = array('store_id' => $_SESSION['store_id'], 'goods_id' => array('in', $goods_id_array));
                $goods_array = Model('goods')->getGoodsList($where, $field);
                if (!empty($goods_array) && is_array($goods_array)) {
                    $goodsdata = array();
                    foreach ($goods_array as $val) {
                        if (CHARSET == 'GBK') {
                            foreach ((array) $val as $k => $v) {
                                $val[$k] = Language::getUTF8($v);
                            }
                        }
                        $goodsdata[] = addslashes(json_encode($val));
                    }
                }
                break;
            case '3':
                if (is_array($_POST['goods_id'])) {
                    $goods_id_array = $_POST['goods_id'];
                } else {
                    showDialog(Language::get('store_sns_choose_goods'));
                }
                $field = 'goods_id,store_id,goods_name,goods_image,goods_price,goods_freight';
                $where = array('store_id' => $_SESSION['store_id'], 'goods_id' => array('in', $goods_id_array));
                $goods_array = Model('goods')->getGoodsList($where, $field);
                if (!empty($goods_array) && is_array($goods_array)) {
                    $goodsdata = array();
                    foreach ($goods_array as $val) {
                        if (CHARSET == 'GBK') {
                            foreach ((array) $val as $k => $v) {
                                $val[$k] = Language::getUTF8($v);
                            }
                        }
                        $goodsdata[] = addslashes(json_encode($val));
                    }
                }
                break;
            default:
                showDialog(Language::get('para_error'));
        }
        $model_stracelog = Model('store_sns_tracelog');
        // 插入数据
        $stracelog_array = array();
        $stracelog_array['strace_storeid'] = $this->store_info['store_id'];
        $stracelog_array['strace_storename'] = $this->store_info['store_name'];
        $stracelog_array['strace_storelogo'] = empty($this->store_info['store_label']) ? '' : $this->store_info['store_label'];
        $stracelog_array['strace_title'] = $_POST['content'];
        $stracelog_array['strace_content'] = $content;
        $stracelog_array['strace_time'] = time();
        $stracelog_array['strace_type'] = $_POST['type'];
        if (isset($goodsdata) && is_array($goodsdata)) {
            $stracelog = array();
            foreach ($goodsdata as $val) {
                $stracelog_array['strace_goodsdata'] = $val;
                $stracelog[] = $stracelog_array;
            }
            $rs = $model_stracelog->saveStoreSnsTracelogAll($stracelog);
        } else {
            $stracelog_array['strace_goodsdata'] = $goodsdata;
            $rs = $model_stracelog->saveStoreSnsTracelog($stracelog_array);
        }
        if ($rs) {
            showDialog(Language::get('nc_common_op_succ'), 'index.php?act=store_sns', 'succ');
        } else {
            showDialog(Language::get('nc_common_op_fail'));
        }
    }
Exemplo n.º 14
0
 /**
  * 我加入的圈子
  */
 public function myjoinedcircleOp()
 {
     $model = Model('circle_member');
     $cm_list = $model->getCircleMemberList(array('member_id' => $_SESSION['member_id'], 'circle_id' => array('neq', 0)), 'circle_id,circle_name,is_identity', 0, 'is_identity asc');
     if (empty($cm_list)) {
         echo false;
         die;
     }
     if (strtoupper(CHARSET) == 'GBK') {
         $cm_list = Language::getUTF8($cm_list);
     }
     echo json_encode($cm_list);
 }
Exemplo n.º 15
0
 /**
  * 店铺幻灯片ajax上传
  */
 public function silde_image_uploadOp()
 {
     $upload = new UploadFile();
     $upload->set('default_dir', ATTACH_SLIDE);
     $upload->set('max_size', C('image_max_filesize'));
     $result = $upload->upfile($_POST['id']);
     $output = array();
     if (!$result) {
         /**
          * 转码
          */
         if (strtoupper(CHARSET) == 'GBK') {
             $upload->error = Language::getUTF8($upload->error);
         }
         $output['error'] = $upload->error;
         echo json_encode($output);
         die;
     }
     $img_path = $upload->file_name;
     /**
      * 模型实例化
      */
     $model_upload = Model('upload');
     if (intval($_POST['file_id']) > 0) {
         $file_info = $model_upload->getOneUpload($_POST['file_id']);
         @unlink(BASE_UPLOAD_PATH . DS . ATTACH_SLIDE . DS . $file_info['file_name']);
         $update_array = array();
         $update_array['upload_id'] = intval($_POST['file_id']);
         $update_array['file_name'] = $img_path;
         $update_array['file_size'] = $_FILES[$_POST['id']]['size'];
         $model_upload->update($update_array);
         $output['file_id'] = intval($_POST['file_id']);
         $output['id'] = $_POST['id'];
         $output['file_name'] = $img_path;
         echo json_encode($output);
         die;
     } else {
         /**
          * 图片数据入库
          */
         $insert_array = array();
         $insert_array['file_name'] = $img_path;
         $insert_array['upload_type'] = '3';
         $insert_array['file_size'] = $_FILES[$_POST['id']]['size'];
         $insert_array['item_id'] = $_SESSION['store_id'];
         $insert_array['upload_time'] = time();
         $result = $model_upload->add($insert_array);
         if (!$result) {
             @unlink(BASE_UPLOAD_PATH . DS . ATTACH_SLIDE . DS . $img_path);
             $output['error'] = Language::get('store_slide_upload_fail', 'UTF-8');
             echo json_encode($output);
             die;
         }
         $output['file_id'] = $result;
         $output['id'] = $_POST['id'];
         $output['file_name'] = $img_path;
         echo json_encode($output);
         die;
     }
 }
Exemplo n.º 16
0
 /**
  * ajax选择常用商品分类
  */
 public function ajax_show_commOp()
 {
     $staple_id = intval($_GET['stapleid']);
     /**
      * 查询相应的商品分类id
      */
     $model_staple = Model('goods_class_staple');
     $staple_info = $model_staple->getStapleInfo(array('staple_id' => intval($staple_id), 'gc_id_1,gc_id_2,gc_id_3'));
     if (empty($staple_info) || !is_array($staple_info)) {
         echo json_encode(array('done' => false, 'msg' => ''));
         die;
     }
     $list_array = array();
     $list_array['gc_id'] = 0;
     $list_array['type_id'] = $staple_info['type_id'];
     $list_array['done'] = true;
     $list_array['one'] = '';
     $list_array['two'] = '';
     $list_array['three'] = '';
     $gc_id_1 = intval($staple_info['gc_id_1']);
     $gc_id_2 = intval($staple_info['gc_id_2']);
     $gc_id_3 = intval($staple_info['gc_id_3']);
     /**
      * 查询同级分类列表
      */
     $model_goods_class = Model('goods_class');
     // 1级
     if ($gc_id_1 > 0) {
         $list_array['gc_id'] = $gc_id_1;
         $class_list = $model_goods_class->getGoodsClass($_SESSION['store_id']);
         if (empty($class_list) || !is_array($class_list)) {
             echo json_encode(array('done' => false, 'msg' => ''));
             die;
         }
         foreach ($class_list as $val) {
             if ($val['gc_id'] == $gc_id_1) {
                 $list_array['one'] .= '<li class="" onclick="selClass($(this));" data-param="{gcid:' . $val['gc_id'] . ', deep:1, tid:' . $val['type_id'] . '}" nctype="selClass"> <a class="classDivClick" href="javascript:void(0)"><span class="has_leaf"><i class="icon-double-angle-right"></i>' . $val['gc_name'] . '</span></a> </li>';
             } else {
                 $list_array['one'] .= '<li class="" onclick="selClass($(this));" data-param="{gcid:' . $val['gc_id'] . ', deep:1, tid:' . $val['type_id'] . '}" nctype="selClass"> <a class="" href="javascript:void(0)"><span class="has_leaf"><i class="icon-double-angle-right"></i>' . $val['gc_name'] . '</span></a> </li>';
             }
         }
     }
     // 2级
     if ($gc_id_2 > 0) {
         $list_array['gc_id'] = $gc_id_2;
         $class_list = $model_goods_class->getGoodsClass($_SESSION['store_id'], $gc_id_1, 2);
         if (empty($class_list) || !is_array($class_list)) {
             echo json_encode(array('done' => false, 'msg' => ''));
             die;
         }
         foreach ($class_list as $val) {
             if ($val['gc_id'] == $gc_id_2) {
                 $list_array['two'] .= '<li class="" onclick="selClass($(this));" data-param="{gcid:' . $val['gc_id'] . ', deep:2, tid:' . $val['type_id'] . '}" nctype="selClass"> <a class="classDivClick" href="javascript:void(0)"><span class="has_leaf"><i class="icon-double-angle-right"></i>' . $val['gc_name'] . '</span></a> </li>';
             } else {
                 $list_array['two'] .= '<li class="" onclick="selClass($(this));" data-param="{gcid:' . $val['gc_id'] . ', deep:2, tid:' . $val['type_id'] . '}" nctype="selClass"> <a class="" href="javascript:void(0)"><span class="has_leaf"><i class="icon-double-angle-right"></i>' . $val['gc_name'] . '</span></a> </li>';
             }
         }
     }
     // 3级
     if ($gc_id_3 > 0) {
         $list_array['gc_id'] = $gc_id_3;
         $class_list = $model_goods_class->getGoodsClass($_SESSION['store_id'], $gc_id_2, 3);
         if (empty($class_list) || !is_array($class_list)) {
             echo json_encode(array('done' => false, 'msg' => ''));
             die;
         }
         foreach ($class_list as $val) {
             if ($val['gc_id'] == $gc_id_3) {
                 $list_array['three'] .= '<li class="" onclick="selClass($(this));" data-param="{gcid:' . $val['gc_id'] . ', deep:3, tid:' . $val['type_id'] . '}" nctype="selClass"> <a class="classDivClick" href="javascript:void(0)"><span class="has_leaf"><i class="icon-double-angle-right"></i>' . $val['gc_name'] . '</span></a> </li>';
             } else {
                 $list_array['three'] .= '<li class="" onclick="selClass($(this));" data-param="{gcid:' . $val['gc_id'] . ', deep:3, tid:' . $val['type_id'] . '}" nctype="selClass"> <a class="" href="javascript:void(0)"><span class="has_leaf"><i class="icon-double-angle-right"></i>' . $val['gc_name'] . '</span></a> </li>';
             }
         }
     }
     // 转码
     if (strtoupper(CHARSET) == 'GBK') {
         $list_array = Language::getUTF8($list_array);
     }
     echo json_encode($list_array);
     die;
 }
Exemplo n.º 17
0
	/**
	 * 添加转发
	 */
	public function addforwardOp(){
		// 验证用户是否登录
		$this->checkLoginStatus();

		$obj_validate = new Validate();
		$stid = intval($_POST["stid"]);
		$validate_arr[] = array("input"=>$_POST["forwardcontent"], "validator"=>'Length',"min"=>0,"max"=>140,"message"=>Language::get('sns_content_beyond'));
		//发帖数超过最大次数出现验证码
		if(intval(cookie('forwardnum'))>=self::MAX_RECORDNUM){
			$validate_arr[] = array("input"=>$_POST["captcha"], "require"=>"true","message"=>Language::get('wrong_null'));
		}
		$obj_validate -> validateparam = $validate_arr;
		$error = $obj_validate->validate();
		if ($error != ''){
			showDialog($error,'','error');
		}
		//发帖数超过最大次数出现验证码
		if(intval(cookie('forwardnum'))>=self::MAX_RECORDNUM){
			if (!checkSeccode($_POST['nchash'],$_POST['captcha'])){
				showDialog(Language::get('wrong_checkcode'),'','error');
			}
		}
		//查询会员信息
		$model = Model();
		$member_info = $model->table('member')->where(array('member_state'=>1))->find($_SESSION['member_id']);
		if (empty($member_info)){
			showDialog(Language::get('sns_member_error'),'','error');
		}
		//查询原帖信息
		$model_stracelog = Model('store_sns_tracelog');
		$stracelog_info = $model_stracelog->getStoreSnsTracelogInfo(array('strace_id' => $stid));
		if (empty($stracelog_info)){
			showDialog(Language::get('sns_forward_fail'),'','error');
		}
		if($stracelog_info['strace_content'] == ''){
			$data = json_decode($stracelog_info['strace_goodsdata'],true);
			if( CHARSET == 'GBK') {
				foreach ((array)$data as $k=>$v){
					$data[$k] = Language::getUTF8($v);
				}
			}
			$stracelog_info['strace_content']	= $model_stracelog->spellingStyle($stracelog_info['strace_type'], $data);
		}

		$insert_arr = array();
		$insert_arr['trace_originalid']			= 0;
		$insert_arr['trace_originalmemberid']	= 0;
		$insert_arr['trace_originalstate']		= 0;
		$insert_arr['trace_memberid'] 			= $member_info['member_id'];
		$insert_arr['trace_membername']			= $member_info['member_name'];
		$insert_arr['trace_memberavatar']		= $member_info['member_avatar'];
		$insert_arr['trace_title']				= $_POST['forwardcontent']?$_POST['forwardcontent']:Language::get('sns_forward');
		$insert_arr['trace_content']			= "<dl class=\"fd-wrap\">
														<dt>
															<h3><a href=\"index.php?act=store_snshome&sid=".$stracelog_info['strace_storeid']."\" target=\"_blank\">".$stracelog_info['strace_storename']."</a>".Language::get('nc_colon')."
															".$stracelog_info['strace_title']."</h3>
										      			</dt>
														<dd>".$stracelog_info['strace_content']."</dd>
													<dl>";
		$insert_arr['trace_addtime']			= time();
		$insert_arr['trace_state']				= 0;
		$insert_arr['trace_privacy']			= 0;
		$insert_arr['trace_commentcount']		= 0;
		$insert_arr['trace_copycount']			= 0;
		$insert_arr['trace_orgcommentcount']	= 0;
		$insert_arr['trace_orgcopycount']		= 0;
		$insert_arr['trace_from']				= 2;
		$result = $model->table('sns_tracelog')->insert($insert_arr);
		if ($result){
			//更新动态转发次数
			$where = array('strace_id'=>$stid);
			$update	= array('strace_spread'=>array('exp', 'strace_spread+1'));
			Model('store_sns_tracelog')->editStoreSnsTracelog($update, $where);
			showDialog(Language::get('sns_forward_succ'),'','succ');
		}else {
			showDialog(Language::get('sns_forward_fail'),'','error');
		}
	}
Exemplo n.º 18
0
 /**
  * 首页图片上传
  */
 public function image_uploadOp()
 {
     $data = array();
     $data['status'] = 'success';
     if (!empty($_FILES['image_upload']['name'])) {
         $upload = new UploadFile();
         $upload->set('default_dir', ATTACH_CMS . DS . 'index');
         $result = $upload->upfile('image_upload');
         if (!$result) {
             $data['status'] = 'fail';
             $data['error'] = $upload->error;
         }
         $data['file_name'] = $upload->file_name;
         $data['file_url'] = getCMSIndexImageUrl($upload->file_name);
     }
     if (strtoupper(CHARSET) == 'GBK') {
         $data = Language::getUTF8($data);
         //网站GBK使用编码时,转换为UTF-8,防止json输出汉字问题
     }
     echo json_encode($data);
 }
Exemplo n.º 19
0
 public function get_subject_by_typeidOp()
 {
     $inform_subject_type_id = trim($_POST['typeid']);
     if (empty($inform_subject_type_id)) {
         echo '';
     } else {
         /*
          * 获得举报主题列表
          */
         $model_inform_subject = Model('inform_subject');
         //搜索条件
         $condition = array();
         $condition['order'] = 'inform_subject_id asc';
         $condition['inform_subject_type_id'] = $inform_subject_type_id;
         $condition['inform_subject_state'] = 1;
         $inform_subject_list = $model_inform_subject->getInformSubject($condition, $page, 'inform_subject_id,inform_subject_content');
         if (strtoupper(CHARSET) == 'GBK') {
             $inform_subject_list = Language::getUTF8($inform_subject_list);
         }
         echo json_encode($inform_subject_list);
     }
 }
Exemplo n.º 20
0
 /**
  * 分类管理
  */
 public function flea_classOp()
 {
     $lang = Language::getLangContent();
     $model_class = Model('flea_class');
     /**
      * 删除,编辑
      */
     if ($_POST['form_submit'] == 'ok') {
         /**
          * 删除
          */
         if ($_POST['submit_type'] == 'del') {
             if (!empty($_POST['check_gc_id'])) {
                 if (is_array($_POST['check_gc_id'])) {
                     $del_array = $model_class->getChildClass($_POST['check_gc_id']);
                     if (is_array($del_array)) {
                         foreach ($del_array as $k => $v) {
                             $model_class->del($v['gc_id']);
                         }
                     }
                 }
                 showMessage($lang['goods_class_index_del_succ']);
             } else {
                 showMessage($lang['goods_class_index_choose_del']);
             }
         }
         /**
          * 编辑
          */
         if ($_POST['submit_type'] == 'brach_edit') {
             if (!empty($_POST['check_gc_id'])) {
                 Tpl::output('id', implode(',', $_POST['check_gc_id']));
                 Tpl::showpage('flea_class.brach_edit');
             } else {
                 showMessage($lang['goods_class_index_choose_edit']);
             }
         }
         /**
          * 首页显示
          */
         if ($_POST['submit_type'] == 'index_show' or $_POST['submit_type'] == 'index_hide') {
             if (!empty($_POST['check_gc_id'])) {
                 if (is_array($_POST['check_gc_id'])) {
                     $param = array();
                     $param['gc_index_show'] = $_POST['submit_type'] == 'index_show' ? '1' : '0';
                     foreach ($_POST['check_gc_id'] as $k => $v) {
                         $param['gc_id'] = $v;
                         $model_class->update($param);
                     }
                 }
                 showMessage($lang['goods_class_index_in_homepage'] . ($_POST['submit_type'] == 'index_show' ? $lang['goods_class_index_display'] : $lang['goods_class_index_hide']) . $lang['goods_class_index_succ']);
             } else {
                 showMessage($lang['goods_class_index_choose_in_homepage'] . ($_POST['submit_type'] == 'index_show' ? $lang['goods_class_index_display'] : $lang['goods_class_index_hide']) . $lang['goods_class_index_content']);
             }
         }
     }
     /**
      * 父ID
      */
     $parent_id = $_GET['gc_parent_id'] ? $_GET['gc_parent_id'] : 0;
     /**
      * 列表
      */
     $tmp_list = $model_class->getTreeClassList(4);
     if (is_array($tmp_list)) {
         foreach ($tmp_list as $k => $v) {
             if ($v['gc_parent_id'] == $parent_id) {
                 /**
                  * 判断是否有子类
                  */
                 if ($tmp_list[$k + 1]['deep'] > $v['deep']) {
                     $v['have_child'] = 1;
                 }
                 $class_list[] = $v;
             }
         }
     }
     if ($_GET['ajax'] == '1') {
         /**
          * 转码
          */
         if (strtoupper(CHARSET) == 'GBK') {
             $class_list = Language::getUTF8($class_list);
         }
         $output = json_encode($class_list);
         print_r($output);
         exit;
     } else {
         Tpl::output('class_list', $class_list);
         Tpl::showpage('flea_class.index');
     }
 }
Exemplo n.º 21
0
 /**
  * 我加入的圈子
  */
 public function myjoinedcircleOp()
 {
     $model = Model();
     $cm_list = $model->table('circle_member')->field('circle_id,circle_name,is_identity')->where(array('member_id' => $_SESSION['member_id']))->order('is_identity asc')->select();
     if (empty($cm_list)) {
         echo false;
         die;
     }
     if (strtoupper(CHARSET) == 'GBK') {
         $cm_list = Language::getUTF8($cm_list);
     }
     echo json_encode($cm_list);
 }
Exemplo n.º 22
0
 public function area_show()
 {
     $area_one_level = array();
     $area_two_level = array();
     $condition = array();
     $condition['area_parent_id'] = '1';
     $condition['field'] = 'flea_area_id,flea_area_name,flea_area_parent_id';
     $condition['order'] = 'flea_area_parent_id asc,flea_area_sort asc,flea_area_id asc';
     $area_list = $this->getListArea($condition);
     if (is_array($area_list) && !empty($area_list)) {
         foreach ($area_list as $val) {
             if ($val['flea_area_parent_id'] == 0) {
                 $flea_area_id = $val['flea_area_id'];
                 $area_one_level[] = $val;
                 $area_two_level[$flea_area_id]['id'] = $flea_area_id;
             } else {
                 $flea_area_parent_id = $val['flea_area_parent_id'];
                 if (isset($area_two_level[$flea_area_parent_id])) {
                     $area_two_level[$flea_area_parent_id]['children'][] = $val;
                     $area_children = $area_two_level[$flea_area_parent_id]['children'];
                     if (strtoupper(CHARSET) == 'GBK') {
                         $area_children = Language::getUTF8($area_children);
                     }
                     $area_two_level[$flea_area_parent_id]['content'] = json_encode($area_children);
                 }
             }
         }
     }
     return array('area_one_level' => $area_one_level, 'area_two_level' => $area_two_level);
 }
Exemplo n.º 23
0
 /**
  * 自动发布店铺动态
  *
  * @param array $data 相关数据
  * @param string $type 类型 'new','coupon','xianshi','mansong','bundling','groupbuy'
  *            所需字段
  *            new       goods表'             goods_id,store_id,goods_name,goods_image,goods_price,goods_transfee_charge,goods_freight
  *            xianshi   p_xianshi_goods表'   goods_id,store_id,goods_name,goods_image,goods_price,goods_freight,xianshi_price
  *            mansong   p_mansong表'         mansong_name,start_time,end_time,store_id
  *            bundling  p_bundling表'        bl_id,bl_name,bl_img,bl_discount_price,bl_freight_choose,bl_freight,store_id
  *            groupbuy  goods_group表'       group_id,group_name,goods_id,goods_price,groupbuy_price,group_pic,rebate,start_time,end_time
  *            coupon在后台发布
  */
 public function storeAutoShare($data, $type)
 {
     $param = array(3 => 'new', 4 => 'coupon', 5 => 'xianshi', 6 => 'mansong', 7 => 'bundling', 8 => 'groupbuy');
     $param_flip = array_flip($param);
     if (!in_array($type, $param) || empty($data)) {
         return false;
     }
     $auto_setting = Model('store_sns_setting')->getStoreSnsSettingInfo(array('sauto_storeid' => $_SESSION['store_id']));
     $auto_sign = false;
     // 自动发布开启标志
     if ($auto_setting['sauto_' . $type] == 1) {
         $auto_sign = true;
         if (CHARSET == 'GBK') {
             foreach ((array) $data as $k => $v) {
                 $data[$k] = Language::getUTF8($v);
             }
         }
         $goodsdata = addslashes(json_encode($data));
         if ($auto_setting['sauto_' . $type . 'title'] != '') {
             $title = $auto_setting['sauto_' . $type . 'title'];
         } else {
             $auto_title = 'nc_store_auto_share_' . $type . rand(1, 5);
             $title = Language::get($auto_title);
         }
     }
     if ($auto_sign) {
         // 插入数据
         $stracelog_array = array();
         $stracelog_array['strace_storeid'] = $this->store_info['store_id'];
         $stracelog_array['strace_storename'] = $this->store_info['store_name'];
         $stracelog_array['strace_storelogo'] = empty($this->store_info['store_label']) ? '' : $this->store_info['store_label'];
         $stracelog_array['strace_title'] = $title;
         $stracelog_array['strace_content'] = '';
         $stracelog_array['strace_time'] = TIMESTAMP;
         $stracelog_array['strace_type'] = $param_flip[$type];
         $stracelog_array['strace_goodsdata'] = $goodsdata;
         Model('store_sns_tracelog')->saveStoreSnsTracelog($stracelog_array);
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 24
0
 /**
  * ajax图片上传
  */
 public function image_uploadOp()
 {
     $ap_id = intval($_POST['apid']);
     /**
      * 相册
      */
     $model = Model();
     $default_class = $model->table('sns_albumclass')->where(array('member_id' => $_SESSION['member_id'], 'is_default' => 1))->find();
     if (empty($default_class)) {
         // 验证时候存在买家秀相册,不存在添加。
         $default_class = array();
         $default_class['ac_name'] = Language::get('sns_buyershow');
         $default_class['member_id'] = $this->master_id;
         $default_class['ac_des'] = Language::get('sns_buyershow_album_des');
         $default_class['ac_sort'] = '255';
         $default_class['is_default'] = 1;
         $default_class['upload_time'] = time();
         $default_class['ac_id'] = $model->table('sns_albumclass')->insert($default_class);
     }
     // 验证图片数量
     $count = $model->table('sns_albumpic')->where(array('member_id' => $_SESSION['member_id']))->count();
     if (C('malbum_max_sum') != 0 && $count >= C('malbum_max_sum')) {
         $output = array();
         $output['error'] = Language::get('sns_upload_img_max_num_error');
         $output = json_encode($output);
         echo $output;
         die;
     }
     /**
      * 上传图片
      */
     $upload = new UploadFile();
     if ($ap_id > 0) {
         $pic_info = $model->table('sns_albumpic')->find($ap_id);
         if (!empty($pic_info)) {
             $upload->set('file_name', $pic_info['ap_cover']);
         }
         // 原图存在设置图片名称为原图名称
     }
     $upload_dir = ATTACH_MALBUM . DS . $_SESSION['member_id'] . DS;
     $upload->set('default_dir', $upload_dir . $upload->getSysSetPath());
     $thumb_width = '240,1024';
     $thumb_height = '2048,1024';
     $upload->set('max_size', C('image_max_filesize'));
     $upload->set('thumb_width', $thumb_width);
     $upload->set('thumb_height', $thumb_height);
     $upload->set('fprefix', $_SESSION['member_id']);
     $upload->set('thumb_ext', '_240,_1024');
     $result = $upload->upfile(trim($_POST['id']));
     if (!$result) {
         if (strtoupper(CHARSET) == 'GBK') {
             $upload->error = Language::getUTF8($upload->error);
         }
         $output = array();
         $output['error'] = $upload->error;
         $output = json_encode($output);
         echo $output;
         die;
     }
     if ($ap_id <= 0) {
         // 如果原图存在,则不需要在插入数据库
         $img_path = $upload->getSysSetPath() . $upload->file_name;
         list($width, $height, $type, $attr) = getimagesize(BASE_UPLOAD_PATH . DS . ATTACH_MALBUM . DS . $_SESSION['member_id'] . DS . $img_path);
         $image = explode('.', $_FILES[trim($_POST['id'])]["name"]);
         if (strtoupper(CHARSET) == 'GBK') {
             $image['0'] = Language::getGBK($image['0']);
         }
         $insert = array();
         $insert['ap_name'] = $image['0'];
         $insert['ac_id'] = $default_class['ac_id'];
         $insert['ap_cover'] = $img_path;
         $insert['ap_size'] = intval($_FILES[trim($_POST['id'])]['size']);
         $insert['ap_spec'] = $width . 'x' . $height;
         $insert['upload_time'] = time();
         $insert['member_id'] = $_SESSION['member_id'];
         $insert['ap_type'] = 1;
         $insert['item_id'] = intval($_POST['sid']);
         $result = $model->table('sns_albumpic')->insert($insert);
     }
     $data = array();
     $data['file_name'] = $ap_id > 0 ? $pic_info['ap_cover'] : $upload->getSysSetPath() . $upload->thumb_image;
     $data['file_id'] = $ap_id > 0 ? $pic_info['ap_id'] : $result;
     /**
      * 整理为json格式
      */
     $output = json_encode($data);
     echo $output;
     die;
 }
Exemplo n.º 25
0
 /**
  * 搜索商品
  */
 public function getselectgoodslistOp()
 {
     //得到商品列表
     $goods_class = Model('goods');
     //得到搜索条件
     $stc_id = intval($_GET['stc_id']);
     $goods_name = trim($_GET['stc_goods_name']);
     //获得商品列表
     $condition_array = array();
     //$condition_array['stc_id'] = $stc_id;//本店铺商品类别编号
     $condition_array['keyword'] = $goods_name;
     $condition_array['store_id'] = $_SESSION['store_id'];
     //判断直通车申请类型
     $t = intval($_GET['t']);
     if (!in_array($t, array(0, 1))) {
         $t = 0;
     }
     if ($t == 1) {
         //充值
         $condition_array['goods_isztc'] = 1;
     } else {
         //申请新直通车
         $condition_array['goods_isztc'] = 0;
     }
     //查询分类下的子分类
     if ($stc_id) {
         $model_store_class = Model('my_goods_class');
         $stc_id_arr = $model_store_class->getChildAndSelfClass($stc_id);
         if (is_array($stc_id_arr) && count($stc_id_arr) > 0) {
             $condition_array['stc_id_in'] = implode(',', $stc_id_arr);
         } else {
             $condition_array['stc_id'] = $stc_id_arr;
         }
     }
     $condition_array['limit'] = 50;
     $condition_array['order'] = 'goods.goods_id desc';
     //$condition_array['order'] = 'goods.goods_id';
     $goods_list = $goods_class->getGoods($condition_array, '', '`goods`.goods_id,`goods`.goods_name', 'stc');
     //处理返回字符串
     if (is_array($goods_list)) {
         $data = array('done' => 1, 'length' => count($goods_list), 'retval' => $goods_list);
     } else {
         $data = array('done' => 1, 'length' => 0, 'retval' => array());
     }
     /**
      * 转码
      */
     if (strtoupper(CHARSET) == 'GBK') {
         $data = Language::getUTF8($data);
         //网站GBK使用编码时,转换为UTF-8,防止json输出汉字问题
     }
     echo json_encode($data);
 }
Exemplo n.º 26
0
 /**
  * 从第三方取快递信息
  *
  */
 public function get_expressOp()
 {
     $url = 'http://www.kuaidi100.com/query?type=' . $_GET['e_code'] . '&postid=' . $_GET['shipping_code'] . '&id=1&valicode=&temp=' . random(4) . '&sessionid=&tmp=' . random(4);
     import('function.ftp');
     $content = dfsockopen($url);
     $content = json_decode($content, true);
     if ($content['status'] != 200) {
         exit(json_encode(false));
     }
     $content['data'] = array_reverse($content['data']);
     $output = '';
     if (is_array($content['data'])) {
         foreach ($content['data'] as $k => $v) {
             if ($v['time'] == '') {
                 continue;
             }
             $output .= '<li>' . $v['time'] . '&nbsp;&nbsp;' . $v['context'] . '</li>';
         }
     }
     if ($output == '') {
         exit(json_encode(false));
     }
     if (strtoupper(CHARSET) == 'GBK') {
         $output = Language::getUTF8($output);
         //网站GBK使用编码时,转换为UTF-8,防止json输出汉字问题
     }
     echo json_encode($output);
 }
Exemplo n.º 27
0
 /**
  * ajax获取商品列表
  */
 public function get_goods_list_ajaxOp()
 {
     $common_id = $_GET['commonid'];
     if ($common_id <= 0) {
         echo 'false';
         exit;
     }
     $model_goods = Model('goods');
     $goodscommon_list = $model_goods->getGoodeCommonInfoByID($common_id, 'spec_name,store_id');
     if (empty($goodscommon_list) || $goodscommon_list['store_id'] != $_SESSION['store_id']) {
         echo 'false';
         exit;
     }
     $goods_list = $model_goods->getGoodsList(array('store_id' => $_SESSION['store_id'], 'goods_commonid' => $common_id), 'goods_id,goods_spec,store_id,goods_price,goods_serial,goods_storage_alarm,goods_storage,goods_image');
     if (empty($goods_list)) {
         echo 'false';
         exit;
     }
     $spec_name = array_values((array) unserialize($goodscommon_list['spec_name']));
     foreach ($goods_list as $key => $val) {
         $goods_spec = array_values((array) unserialize($val['goods_spec']));
         $spec_array = array();
         foreach ($goods_spec as $k => $v) {
             $spec_array[] = '<div class="goods_spec">' . $spec_name[$k] . L('nc_colon') . '<em title="' . $v . '">' . $v . '</em>' . '</div>';
         }
         $goods_list[$key]['goods_image'] = thumb($val, '60');
         $goods_list[$key]['goods_spec'] = implode('', $spec_array);
         $goods_list[$key]['alarm'] = $val['goods_storage_alarm'] != 0 && $val['goods_storage'] <= $val['goods_storage_alarm'] ? 'style="color:red;"' : '';
         $goods_list[$key]['url'] = urlShop('goods', 'index', array('goods_id' => $val['goods_id']));
     }
     /**
      * 转码
      */
     if (strtoupper(CHARSET) == 'GBK') {
         Language::getUTF8($goods_list);
     }
     echo json_encode($goods_list);
 }
Exemplo n.º 28
0
 /**
  * 测试邮件发送
  *
  * @param
  * @return
  */
 public function email_testingOp()
 {
     /**
      * 读取语言包
      */
     $lang = Language::getLangContent();
     $email_host = trim($_POST['email_host']);
     $email_port = trim($_POST['email_port']);
     $email_addr = trim($_POST['email_addr']);
     $email_id = trim($_POST['email_id']);
     $email_pass = trim($_POST['email_pass']);
     $email_test = trim($_POST['email_test']);
     $subject = $lang['test_email'];
     $site_url = SHOP_SITE_URL;
     $site_title = C('site_name');
     $message = '<p>' . $lang['this_is_to'] . "<a href='" . $site_url . "' target='_blank'>" . $site_title . '</a>' . $lang['test_email_send_ok'] . '</p>';
     // 		if ($email_type == '1'){
     $obj_email = new Email();
     $obj_email->set('email_server', $email_host);
     $obj_email->set('email_port', $email_port);
     $obj_email->set('email_user', $email_id);
     $obj_email->set('email_password', $email_pass);
     $obj_email->set('email_from', $email_addr);
     $obj_email->set('site_name', $site_title);
     $result = $obj_email->send($email_test, $subject, $message);
     // 		}else {
     // 			$result = @mail($email_test,$subject,$message);
     // 		}
     if ($result === false) {
         $message = $lang['test_email_send_fail'];
         if (strtoupper(CHARSET) == 'GBK') {
             $message = Language::getUTF8($message);
         }
         showMessage($message, '', 'json');
     } else {
         $message = $lang['test_email_send_ok'];
         if (strtoupper(CHARSET) == 'GBK') {
             $message = Language::getUTF8($message);
         }
         showMessage($message, '', 'json');
     }
 }
Exemplo n.º 29
0
 public function ajax_categoryOp()
 {
     $model = Model('goods_class');
     $list = $model->field('gc_title,gc_keywords,gc_description')->find(intval($_GET['id']));
     //转码
     if (strtoupper(CHARSET) == 'GBK') {
         $list = Language::getUTF8($list);
         //网站GBK使用编码时,转换为UTF-8,防止json输出汉字问题
     }
     echo json_encode($list);
     exit;
 }
Exemplo n.º 30
0
 /**
  * 添加新的收货地址
  *
  */
 public function add_addrOp()
 {
     $model_addr = Model('address');
     if (chksubmit()) {
         //验证表单信息
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["true_name"], "require" => "true", "message" => Language::get('cart_step1_input_receiver')), array("input" => $_POST["area_id"], "require" => "true", "validator" => "Number", "message" => Language::get('cart_step1_choose_area')), array("input" => $_POST["address"], "require" => "true", "message" => Language::get('cart_step1_input_address')));
         $error = $obj_validate->validate();
         if ($error != '') {
             $error = strtoupper(CHARSET) == 'GBK' ? Language::getUTF8($error) : $error;
             exit(json_encode(array('state' => false, 'msg' => $error)));
         }
         $data = array();
         $data['member_id'] = $_SESSION['member_id'];
         $data['true_name'] = $_POST['true_name'];
         $data['area_id'] = intval($_POST['area_id']);
         $data['city_id'] = intval($_POST['city_id']);
         $data['area_info'] = $_POST['area_info'];
         $data['address'] = $_POST['address'];
         $data['tel_phone'] = $_POST['tel_phone'];
         $data['mob_phone'] = $_POST['mob_phone'];
         //转码
         $data = strtoupper(CHARSET) == 'GBK' ? Language::getGBK($data) : $data;
         $insert_id = $model_addr->addAddress($data);
         if ($insert_id) {
             exit(json_encode(array('state' => true, 'addr_id' => $insert_id)));
         } else {
             exit(json_encode(array('state' => false, 'msg' => Language::get('cart_step1_addaddress_fail', 'UTF-8'))));
         }
     } else {
         Tpl::showpage('buy_address.add', 'null_layout');
     }
 }