public function attachment_del() { if (IS_POST && !empty($_POST['pigcms_id'])) { $database_attachment = D('Attachment'); $condition_attachment['store_id'] = $this->store_session['store_id']; $condition_attachment['pigcms_id'] = $_POST['pigcms_id']; $now_attachment = $database_attachment->field('`pigcms_id`,`file`')->where($condition_attachment)->find(); if (!empty($now_attachment)) { @unlink('./upload/' . $now_attachment['file']); $database_attachment->where($condition_attachment)->delete(); // 删除又拍云服务器 $attachment_upload_type = option('config.attachment_upload_type'); if ($attachment_upload_type == '1') { import('source.class.upload.upyunUser'); upyunUser::delete('/' . $now_attachment['file']); } json_return(0, '删除成功'); } else { json_return(1, '文件不存在'); } } else { json_return(1, '非法访问'); } }
public function brand_del() { $StoreBrand = M('StoreBrand'); $brand_id = $this->_get('id', 'trim,intval'); $now_brand = $StoreBrand->find($brand_id); if ($StoreBrand->delete($brand_id)) { //删除图片 if ($now_brand['pic']) { unlink('./upload/' . $now_brand['pic']); // 上传到又拍云服务器 $attachment_upload_type = C('config.attachment_upload_type'); if ($attachment_upload_type == '1') { import('upyunUser', './source/class/upload/'); upyunUser::delete('/' . $now_brand['pic']); } } $this->success('删除成功!'); } else { $this->error('删除失败!请重试~'); } }
public function adver_del() { $database_adver = D('Adver'); $condition_adver['id'] = $_POST['id']; $now_adver = $database_adver->field(true)->where($condition_adver)->find(); if ($database_adver->where($condition_adver)->delete()) { unlink('./upload/' . $now_adver['pic']); $attachment_upload_type = C('config.attachment_upload_type'); // 删除又拍云服务器 if ($attachment_upload_type == '1') { import('upyunUser', './source/class/upload/'); upyunUser::delete('/' . $now_adver['pic']); } S('adver_list_' . $now_adver['cat_id'], NULL); // 清空缓存 import('ORG.Util.Dir'); Dir::delDirnotself('./cache'); $this->success('删除成功'); } else { $this->error('删除失败!请重试~'); } }
public function category_edit() { $category = M('ProductCategory'); if (IS_POST) { $cat_id = $this->_post('cat_id', 'trim,intval'); $now_cat = $category->find($cat_id); if ($this->_post('property', 'trim') == '') { $this->frame_submit_tips(0, '分类属性不能为空!'); } if ($_FILES['pic']['error'] != 4 || $_FILES['pcpic']['error'] != 4) { //上传图片 $rand_num = date('Y/m', $_SERVER['REQUEST_TIME']); $upload_dir = './upload/category/' . $rand_num . '/'; if (!is_dir($upload_dir)) { mkdir($upload_dir, 0777, true); } import('ORG.Net.UploadFile'); $upload = new UploadFile(); $upload->maxSize = 10 * 1024 * 1024; $upload->allowExts = array('jpg', 'jpeg', 'png', 'gif'); $upload->allowTypes = array('image/png', 'image/jpg', 'image/jpeg', 'image/gif'); $upload->savePath = $upload_dir; $upload->saveRule = 'uniqid'; if ($upload->upload()) { $uploadList = $upload->getUploadFileInfo(); // 上传到又拍云服务器 $attachment_upload_type = C('config.attachment_upload_type'); if ($attachment_upload_type == '1') { import('upyunUser', './source/class/upload/'); upyunUser::upload('./upload/category/' . $rand_num . '/' . $uploadList[0]['savename'], '/category/' . $rand_num . '/' . $uploadList[0]['savename']); } $j = 0; if ($_FILES['pic']['error'] != 4) { $_POST['cat_pic'] = 'category/' . $rand_num . '/' . $uploadList[$j]['savename']; $j = 1; } if ($_FILES['pcpic']['error'] != 4) { $_POST['cat_pc_pic'] = 'category/' . $rand_num . '/' . $uploadList[$j]['savename']; } } else { $this->frame_submit_tips(0, $upload->getErrorMsg()); } } $data = array(); $data['cat_fid'] = $this->_post('parent_id', 'trim,intval'); $data['cat_name'] = $this->_post('name', 'trim'); $data['cat_sort'] = $this->_post('order_by', 'trim,intval'); $data['cat_status'] = $this->_post('status', 'trim,intval'); $data['cat_desc'] = $this->_post('desc', 'trim'); //商品属性类别 // $property_arr = $this->_post('property', 'trim'); // $property_arr = array_unique($property_arr); // if (is_array($property_arr)) { // $data['filter_attr'] = implode(',', $property_arr); // } else { // if (is_int($property_arr)) // $data['filter_attr'] = $property_arr; // } $data['filter_attr'] = $this->_post('property', 'trim'); $data['tag_str'] = join(',', $this->_post('tag', 'trim')); if (empty($data['tag_str'])) { $data['tag_str'] = ''; } if ($_POST['cat_pic']) { $data['cat_pic'] = $_POST['cat_pic']; } if ($_POST['cat_pc_pic']) { $data['cat_pc_pic'] = $_POST['cat_pc_pic']; } if (!empty($data['cat_fid'])) { $data['cat_level'] = 2; $path = $category->where(array('cat_id' => $data['cat_fid']))->getField('cat_path'); $data['cat_path'] = $path; } else { $data['cat_level'] = 1; $data['cat_path'] = 0; } if ($category->where(array('cat_id' => $cat_id))->save($data)) { if ($cat_id <= 9) { $str_cat_id = '0' . $cat_id; } else { $str_cat_id = $cat_id; } $path = $data['cat_path'] . ',' . $str_cat_id; $category->where(array('cat_id' => $cat_id))->save(array('cat_path' => $path)); if ($_POST['cat_pic'] && $now_cat['cat_pic']) { unlink('./upload/' . $now_cat['cat_pic']); $attachment_upload_type = C('config.attachment_upload_type'); // 删除又拍云服务器 if ($attachment_upload_type == '1') { import('upyunUser', './source/class/upload/'); upyunUser::delete('/' . $now_cat['cat_pic']); } } if ($_POST['cat_pc_pic'] && $now_cat['cat_pc_pic']) { unlink('./upload/' . $now_cat['cat_pc_pic']); $attachment_upload_type = C('config.attachment_upload_type'); // 删除又拍云服务器 if ($attachment_upload_type == '1') { import('upyunUser', './source/class/upload/'); upyunUser::delete('/' . $now_cat['cat_pc_pic']); } } $this->frame_submit_tips(1, '修改成功!'); } else { $this->frame_submit_tips(0, '修改失败!请重试~'); } } $this->assign('bg_color', '#F3F3F3'); $id = $this->_get('id', 'trim,intval'); $categories = $category->where(array('cat_level' => 1, 'cat_status' => 1))->order('cat_sort ASC, cat_id ASC')->select(); $category = $category->find($id); $category['cat_pic'] = getAttachmentUrl($category['cat_pic']); $category['cat_pc_pic'] = getAttachmentUrl($category['cat_pc_pic']); $this->assign('categories', $categories); $this->assign('category', $category); //获取属性类别的 所有属性 $attr_list = D('SystemProductProperty')->get_property_list(); $property_type = array(); if ($category['filter_attr']) { $filter_attr = explode(",", $category['filter_attr']); //把多个筛选属性放到数组中 foreach ($filter_attr as $k => $v) { if ($k != 0) { break; } $property_type_id = M('SystemProductProperty')->where(array('pid' => $v))->find($v); $property_type[$k]['goods_type_list'] = D('SystemPropertyType')->get_PropertyType_list($property_type_id['property_type_id']); //取得每个属性的商品类型 $property_type[$k]['filter_attr'] = $v; $attr_option = array(); foreach ($attr_list[$property_type_id['property_type_id']] as $val) { $attr_option[key($val)] = current($val); } $property_type[$k]['option'] = $attr_option; $property_type[$k]['option_selected_id'] = $v; $edit_type = 1; } $this->assign('filter_attr', $filter_attr); } else { //获取属性类别 $property_type = M('SystemPropertyType')->where(array('type_status' => 1))->select(); $edit_type = 2; } $system_property_type_list = D('system_property_type')->where(array('type_status' => 1))->select(); $system_tag_list = D('system_tag')->select(); $tag_arr = explode(',', $category['tag_str']); $tag_list = array(); $system_tag_list_group = array(); foreach ($system_tag_list as $tmp) { $system_tag_list_group[$tmp['tid']][] = $tmp; if (in_array($tmp['id'], $tag_arr)) { $tag_list[] = $tmp; } } $tag_str = '{'; foreach ($system_tag_list_group as $key => $system_tag) { $tag_str .= $key . ':{'; foreach ($system_tag as $i => $tmp) { if ($i != 0) { $tag_str .= ','; } $name = str_replace('"', "'", $tmp['name']); $tag_str .= $tmp['id'] . ':"' . $name . '"'; } $tag_str .= '},'; } $tag_str .= '}'; $this->assign('edit_type', $edit_type); //1:有属性 修改 2:无属性修改 $this->assign('property_type', $property_type); $this->assign('system_property_type_list', $system_property_type_list); $this->assign('system_tag_list', $system_tag_list); $this->assign('system_tag_list_group', $system_tag_list_group); $this->assign('tag_str', $tag_str); $this->assign('tag_list', $tag_list); $this->display(); }