/** * 增加 */ public function add() { $m_class = D('GoodsClass'); if (chkSubmit()) { if (!$_POST['brand_name'] || !$_POST['class_id']) { $this->error('非法访问'); } $insert = array(); $insert['brand_name'] = $_POST['brand_name']; $insert['class_id'] = intval($_POST['class_id']); $class_info = D('GoodsClass')->getClassInfo(array('class_id' => intval($_POST['class_id']))); $insert['class_name'] = $class_info['class_name']; $insert['is_recommend'] = intval($_POST['brand_recommend']); $insert['sort'] = intval($_POST['brand_sort']); //$insert['brand_pic'] = trim($_POST['brand_pic']); $path = $this->uploadImg('brand_pic'); if ($path) { $insert['brand_pic'] = $path; } $res = D('Brand')->add($insert); if (!$res) { $this->error('添加失败'); } $this->success('添加成功'); } $class_list = $m_class->getList(array()); $class_list = $m_class->getClassTree($class_list); $this->assign('class_list', $class_list); $this->display('html/brand.add'); }
public function index() { $m_setting = D('Setting'); if (chkSubmit()) { dumps($_FILES); $update = array(); $update['site_name'] = $this->getString('post.site_name'); //$update['site_logo'] = $this->getString('post.site_logo'); //$update['member_face'] = $this->getString('post.member_face'); $update['site_seo'] = $this->getString('post.site_seo'); $update['site_email'] = $this->getString('post.site_email'); $update['upload_size_limit'] = $this->getInt('post.upload_size_limit') * 1024; $update['site_phone'] = $this->getString('post.site_phone'); $update['site_status'] = $this->getString('post.site_status'); $update['closed_reason'] = $this->getString('post.closed_reasons'); //logo if ($_FILES) { $upload = new \Think\Upload(); // 实例化上传类 $upload->rootPath = C('UPIMG_PATH') . '/'; // 设置附件上传根目录 $upload->savePath = ''; // 设置附件上传(子)目录 if ($_FILES['site_logo']['name']) { //logo $result = $upload->uploadOne($_FILES['site_logo']); if ($result) { $path = $result['savepath'] . $result['savename']; $update['site_logo'] = $path; } else { $this->error($upload->getError()); } } if ($_FILES['member_face']['name']) { //member_face $result = $upload->uploadOne($_FILES['member_face']); if ($result) { $path = $result['savepath'] . $result['savename']; $update['member_face'] = $path; } else { $this->error($upload->getError()); } } } $res = $m_setting->updateAll($update); if ($res) { $this->success('更新成功'); } else { $this->error('更新失败'); } } $setting_list = $m_setting->getSettingList(array()); $this->assign('setting', $setting_list); $this->display('html/setting'); }
/** * 修改密码 */ public function modify() { if (chkSubmit()) { if (!$_POST['old_password'] || !$_POST['password'] || !$_POST['re_password']) { $this->error('非法访问'); } if ($_SESSION['admin_info']['password'] != md5($_POST['old_password'])) { $this->error('密码错误'); } if (md5($_POST['password']) != md5($_POST['re_password'])) { $this->error('两次密码不一样'); } $condition['admin_id'] = $_SESSION['admin_info']['admin_id']; $update['password'] = md5($_POST['password']); $res = D('Admin')->update($condition, $update); if (!$res) { $this->error('更新失败'); } unset($_SESSION['is_logined'], $_SESSION['admin_info']); $this->success('更新密码成功'); } $this->display('Index/password'); }
public function setting() { $m_setting = D('Setting'); if (chkSubmit()) { $update = array(); $update['can_edit_per_goods_price'] = $this->getInt('post.can_edit_per_goods_price'); $update['goods_per_price'] = $this->getString('post.goods_per_price'); $res = $m_setting->updateAll($update); if ($res) { $this->success('更新成功'); } else { $this->error('更新失败'); } } $setting = $m_setting->getSettingList(array('name' => array('in', array('can_edit_per_goods_price', 'goods_per_price')))); $this->assign('setting', $setting); $this->display('html/goods.setting'); }