예제 #1
0
 public function save()
 {
     $Pro = D('Pro');
     if (!($data = $Pro->create())) {
         $this->error($Pro->getError());
     }
     if ($Pro->id) {
         //修改
         if (!$Pro->image) {
             unset($Pro->image);
         }
         if ($Pro->save()) {
             updateApi($data['webid'], 'editProduct', $data['id']);
             $this->success('修改成功');
         } else {
             $this->error('修改失败');
         }
     } else {
         //添加
         if ($Pro->add()) {
             if (!$Pro->image) {
                 $this->error('请上传图片');
             }
             updateApi($data['webid'], 'getProducts', $Pro->getLastSql());
             $this->success('添加成功');
         } else {
             $this->error('添加失败');
         }
     }
 }
 public function save()
 {
     $Link = D('link');
     $data = $Link->create();
     if ($Link->type == 'file' && $_FILES['android']['error'] != 4) {
         C('DB_PREFIX', 'rou_');
         $savePath = M('website')->getFieldByid($Link->webid, 'filename');
         $config = array('exts' => 'apk', 'rootPath' => '.' . $savePath . '/resources/');
         $Upload = new \Think\Upload($config);
         $info = $Upload->uploadOne($_FILES['android']);
         if ($Upload->getError()) {
             $this->error($Upload->getError());
         }
         $Link->android = $savePath . '/resources/' . $info['savepath'] . $info['savename'];
     }
     if ($Link->id) {
         //修改
         if ($Link->save()) {
             updateApi($data['webid'], 'getLink', $data['id']);
             $this->success('链接修改成功');
         } else {
             $this->error('链接修改失败');
         }
     } else {
         //添加
         if ($Link->add()) {
             updateApi($data['webid'], 'getLink', $Link->getLastInsId());
             $this->success('链接修改成功');
         } else {
             $this->error('链接修改失败');
         }
     }
 }
 public function save()
 {
     $News = D('news');
     $data = $News->create();
     if (!$data) {
         $this->error($News->getError());
     }
     if ($News->id) {
         //修改
         if ($News->save()) {
             updateApi($data['webid'], 'updNews', $data['id']);
             $this->success('修改成功');
         } else {
             $this->error('修改失败');
         }
     } else {
         //新增
         if ($News->add()) {
             updateApi($data['webid'], 'getNews', $News->getLastInsId());
             $this->success('添加成功');
         } else {
             $this->error('添加失败');
         }
     }
 }
 public function save()
 {
     $Web = D('website');
     if (!$Web->create()) {
         $this->error('数据错误');
     }
     $id = $Web->id;
     if ($Web->save()) {
         updateApi($id, 'getBaseConf', '');
         $this->success('资料修改成功');
     } else {
         $this->error('资料修改失败');
     }
 }
예제 #5
0
 public function getCategory()
 {
     $Cate = D('category');
     $Article = D('article');
     $map['pid'] = 1;
     $type = C('TYPE1');
     $cates = $Cate->where($map)->select();
     foreach ($cates as $v) {
         $dir = './MediaTpl/Train/train/';
         $dir .= $type[$v['name']] ? $type[$v['name']] : $v['name'];
         //$dir = iconv('utf-8','gbk',$dir);
         if (!is_dir($dir)) {
             mkdir($dir, 0777, true);
         }
         $map['pid'] = $v['id'];
         $data = $Cate->field('name,id')->where($map)->select();
         $map = array();
         $map['category'] = $v['id'];
         $map['show'] = '1';
         $article = $Article->field('id,title,about,image,media,show,attachment,update_time,content')->where($map)->order('id desc')->select();
         if ($article) {
             $hd = fopen($dir . '/list', 'w+');
             fwrite($hd, $this->decodeUnicode(json_encode($article)));
             fclose($hd);
         }
         foreach ($data as $item) {
             //$item['name'] = iconv('utf-8','gbk',$item['name']);
             $dir1 = $dir . '/' . $item['name'];
             if (!is_dir($dir1)) {
                 mkdir($dir1, 0777, true);
             }
             $map = array();
             $map['category'] = $item['id'];
             $map['show'] = '1';
             $article = $Article->field('id,title,about,image,media,show,attachment,update_time,content')->where($map)->select();
             $article = $this->decodeUnicode(json_encode($article));
             if ($article) {
                 $hd = fopen($dir1 . '/list', 'w+');
                 fwrite($hd, $article);
                 fclose($hd);
             }
             updateApi(1, 'downData', '');
         }
     }
 }
 public function save()
 {
     $Cate = D('category');
     if (!($data = $Cate->create())) {
         $this->error($Cate->getError());
     }
     if ($_FILES) {
         $upload = true;
         $config = array('exts' => 'jpg,png', 'rootPath' => './', 'savePath' => $_SESSION['web']['filename'] . '/resource/');
         $Upload = new \Think\Upload($config);
         $info = $Upload->uploadOne($_FILES['cover_img']);
     }
     if ($Cate->id) {
         //修改
         if ($info) {
             $Cate->image = $info['savepath'] . $info['savename'];
         }
         if ($Cate->save()) {
             updateApi($data['webid'], 'getAds', $Cate->id);
             $this->success('修改成功');
         } else {
             $this->error('修改失败');
         }
     } else {
         //添加
         if ($upload) {
             if (!$info) {
                 $this->error($Upload->getError());
             }
             $Cate->image = $info['savepath'] . $info['savename'];
         }
         if ($Cate->add()) {
             updateApi($data['webid'], 'getAds', $Cate->getLastInsId());
             $this->success('添加成功');
         } else {
             $this->error('添加失败');
         }
     }
 }
예제 #7
0
 public function save()
 {
     $Art = D('art');
     $data = $Art->create();
     if ($Art->id) {
         //编辑
         if ($Art->save()) {
             updateApi($data['webid'], 'getContent', $data['id']);
             $this->success('内容编辑成功');
         } else {
             $this->error('内容编辑失败');
         }
     } else {
         //添加
         if ($Art->add()) {
             updateApi($data['webid'], 'getContent', $Art->getLastInsId());
             $this->success('内容编辑成功');
         } else {
             $this->error('内容编辑失败');
         }
     }
 }
예제 #8
0
 public function save()
 {
     $Ads = D('ads');
     $_validate = array(array('image', 'require', '请上传图片'));
     $data = $Ads->validate($_validate)->create();
     if (!$data) {
         $this->error($Ads->getError());
     }
     if (!$Ads->id) {
         if ($Ads->add()) {
             updateApi($data['webid'], 'getAds', $Ads->getLastInsId());
             $this->success('添加成功');
         } else {
             $this->error('添加失败');
         }
     } else {
         if ($Ads->save()) {
             updateApi($data['webid'], 'getAds', $data['id']);
             $this->success('修改成功');
         } else {
             $this->error('修改失败');
         }
     }
 }