public function img_add()
 {
     $bp = M('Img_link_page');
     $banner_page = $bp->select();
     $data = array('banner_page' => $banner_page);
     if (IS_POST) {
         $img_link = M('Img_link');
         // print_r($_FILES);die;
         $thumb = imgFile();
         $info = $thumb['info'];
         if (!$info) {
             // 上传错误提示错误信息
             echo "<script>alert('上传失败');window.history.go(-1);</script>";
         } else {
             // 上传成功
             $path = $info['ban_url']['savepath'];
             $p = ltrim($path, '.');
             $img = $info['ban_url']['savename'];
             $src = $p . $img;
             $root = rtrim($thumb['rootPath'], '\\ThinkPHP/');
             $roo = str_replace("\\", "/", $root);
             $url = ltrim($info['ban_url']['savepath'], '.');
             $uploadedfile = $roo . $url . $info['ban_url']['savename'];
             $tmp = imagecreatefromjpeg($uploadedfile);
             // list($width,$height)=getimagesize($uploadedfile);
             // $newwidth= 1000;
             // $newheight=($height/$width)*$newwidth;
             // img_create_small($uploadedfile,$newwidth,$newheight,$uploadedfile);
             $arr = array('img_name' => I('post.img_name'), 'img_order' => I('post.img_order'), 'img_gourl' => I('post.img_gourl'), 'img_url' => $src, 'img_pageid' => I('post.check_page'));
             $res = $img_link->add($arr);
             if ($res) {
                 echo "<script>window.location.href='/index.php/Admin/Link/img_link';</script>";
             } else {
                 echo "<script>alert('添加失败');window.history.go(-1);</script>";
             }
         }
     }
     $this->assign($data);
     $this->display();
 }
 function edit()
 {
     $id = $_GET['id'];
     $member = M('Member');
     $mcate = M('Mcate');
     $Mdata = $mcate->select();
     //所有父类名称
     $res = $member->where(array('p_id' => $id))->select();
     if (IS_POST) {
         $memb = M('Member');
         $time = date('Y.m.d', time());
         $arr = array('p_title' => I('post.title'), 'p_content' => I('post.content1'), 'p_cate' => I('post.cate'), 'p_addtime' => $time, 'p_author' => I('post.author'), 'p_source' => I('post.source'));
         $memb = M('Member');
         $num = $memb->where(array('p_id' => $id))->save($arr);
         if ($_FILES['thumb']['name']) {
             $thumb = imgFile();
             $path = $thumb['info']['thumb']['savepath'];
             $p = ltrim($path, '.');
             $img = $thumb['info']['thumb']['savename'];
             $src = $p . $img;
             $rnum = $memb->where(array('p_id' => $id))->save(array('p_thumb' => $src));
         }
         if ($id || $rnum) {
             echo "<script>alert('修改成功');window.location.href = '/index.php/Admin/Member/index';</script>";
         } else {
             echo "<script>alert('修改失败');window.history.go(-1);</script>";
         }
     }
     $cate = $res[0]['p_cate'];
     $Mname = $mcate->where(array('m_id' => $cate))->select();
     //当前id的父类名称
     $this->assign('data', $res[0]);
     //当前id数据
     $this->assign('Mdata', $Mdata);
     $this->assign('Mname', $Mname[0]);
     $this->display();
 }
 function add()
 {
     $artcate = M('artcate');
     $article = M('article');
     $cate = $artcate->where(array('cate_pid' => 0))->order('cate_id ASC')->select();
     $maxorder = $article->field('art_order')->order('art_order DESC')->limit(1)->find();
     //文章列表的最大排序
     // dump($maxorder);die;
     if (!$maxorder) {
         $order = 1;
     } else {
         $order = $maxorder['art_order'] + 1;
     }
     $time = time();
     $nowtime = date('Y-m-d', $time);
     $arr = array();
     if (IS_POST) {
         $arr = array('art_title' => I('post.title'), 'art_author' => I('post.author'), 'art_from' => I('post.source'), 'art_isshow' => I('post.isshow'), 'art_summary' => I('post.summary'), 'art_content' => I('post.content1'), 'art_addtime' => $nowtime, 'art_order' => $order);
         //			print_r($arr);die;
         $scate = I('post.scate');
         $acate = I('post.cate');
         if (!$scate) {
             $arr['art_cateid'] = $acate;
         } else {
             $arr['art_cateid'] = $scate;
         }
         // dump($arr);die;
         $res = $article->add($arr);
         // dump($res);die;
         if (FALSE) {
             $this->error('更新失败!');
         } else {
             if ($_FILES['thumb']['name']) {
                 import('ORG.Net.UploadFile');
                 $thumb = imgFile();
                 //					$thumb->thumbMaxWidth='100';
                 $info = $thumb['info'];
                 if (!$info) {
                     // 上传错误提示错误信息
                     $error;
                 } else {
                     // 上传成功
                     $path = $info['thumb']['savepath'];
                     $p = ltrim($path, '.');
                     $img = $info['thumb']['savename'];
                     $src = $p . $img;
                     $root = rtrim($thumb['rootPath'], '\\ThinkPHP/');
                     $roo = str_replace("\\", "/", $root);
                     $url = ltrim($info['thumb']['savepath'], '.');
                     $uploadedfile = $roo . $url . $info['thumb']['savename'];
                     $oldFile = $roo . $art['art_thumb'];
                     unlink($oldFile);
                     //删除原来的缩略图
                     $tmp = imagecreatefromjpeg($uploadedfile);
                     list($width, $height) = getimagesize($uploadedfile);
                     $newwidth = 100;
                     $newheight = $height / $width * $newwidth;
                     img_create_small($uploadedfile, $newwidth, $newheight, $uploadedfile);
                     $article->where(array('art_id' => $res))->save(array('art_thumb' => $src));
                     echo "<script>window.location.href='/index.php/Admin/Article/index';</script>";
                 }
             } else {
                 echo "<script>window.location.href='/index.php/Admin/Article/index';</script>";
             }
         }
     }
     $data = array('cate' => $cate, 'time' => $time);
     $this->assign($data);
     $this->display();
 }
 public function add()
 {
     $procate = M('procate');
     $product = M('product');
     $cate = $procate->where(array('cate_pid' => 0))->order('cate_id ASC')->select();
     $maxorder = $product->field('pro_order')->order('pro_order DESC')->limit(1)->find();
     //文章列表的最大排序
     // dump($maxorder);die;
     if (!$maxorder) {
         $order = 1;
     } else {
         $order = $maxorder['pro_order'] + 1;
     }
     $time = time();
     $arr = array();
     if (IS_POST) {
         $arr = array('pro_name' => I('post.title'), 'pro_cate_id' => I('post.cate'), 'pro_author' => I('post.author'), 'pro_isshow' => 1, 'pro_member_price' => I('post.member_price'), 'pro_general_price' => I('post.general_price'), 'pro_from' => I('post.source'), 'pro_summary' => I('post.summary'), 'pro_order' => I('post.order'), 'pro_introduction' => I('post.content1'), 'pro_addtime' => time());
         $scate = I('post.scate');
         $acate = I('post.cate');
         if (!$scate) {
             $arr['pro_cate_id'] = $acate;
         } else {
             $arr['pro_cate_id'] = $scate;
         }
         // dump($arr);die;
         $res = $product->add($arr);
         // dump($res);die;
         if (!$res) {
             $this->error('更新失败!');
         } else {
             if ($_FILES['thumb']['name']) {
                 $thumb = imgFile();
                 $info = $thumb['info'];
                 if (!$info) {
                     // 上传错误提示错误信息
                     $error;
                 } else {
                     // 上传成功
                     $path = $info['thumb']['savepath'];
                     $p = ltrim($path, '.');
                     $img = $info['thumb']['savename'];
                     $src = $p . $img;
                     $root = rtrim($upload->rootPath, '\\ThinkPHP/');
                     $roo = str_replace("\\", "/", $root);
                     $url = ltrim($info['thumb']['savepath'], '.');
                     $uploadedfile = $roo . $url . $info['thumb']['savename'];
                     $oldFile = $roo . $pro['pro_thumb'];
                     unlink($oldFile);
                     //删除原来的缩略图
                     $tmp = imagecreatefromjpeg($uploadedfile);
                     list($width, $height) = getimagesize($uploadedfile);
                     $newwidth = 100;
                     $newheight = $height / $width * $newwidth;
                     img_create_small($uploadedfile, $newwidth, $newheight, $uploadedfile);
                     $product->where(array('pro_id' => $res))->save(array('pro_thumb' => $src));
                     echo "<script>window.location.href='/Admin/Product/index';</script>";
                 }
             } else {
                 echo "<script>window.location.href='/Admin/Product/index';</script>";
             }
         }
     }
     $data = array('cate' => $cate, 'time' => $time);
     $this->assign($data);
     $this->display();
 }
 public function add()
 {
     $procate = M('procate');
     $product = M('product');
     $cate = $procate->where(array('cate_pid' => 0))->order('cate_id ASC')->select();
     $maxorder = $product->field('pro_order')->order('pro_order DESC')->limit(1)->find();
     //文章列表的最大排序
     // dump($maxorder);die;
     if (!$maxorder) {
         $order = 1;
     } else {
         $order = $maxorder['pro_order'] + 1;
     }
     $arr = array();
     if (IS_POST) {
         $arr = array('pro_name' => I('post.title'), 'pro_cate_id' => I('post.cate'), 'pro_author' => I('post.author'), 'pro_isshow' => 1, 'pro_member_price' => I('post.member_price'), 'pro_general_price' => I('post.general_price'), 'pro_from' => I('post.source'), 'pro_summary' => I('post.summary'), 'pro_order' => I('post.order'), 'pro_introduction' => I('post.content1'));
         $scate = I('post.scate');
         $acate = I('post.cate');
         if (!$scate) {
             $arr['pro_cate_id'] = $acate;
         } else {
             $arr['pro_cate_id'] = $scate;
         }
         $res = $product->add($arr);
         if ($_FILES['ban_url']) {
             $thumb = imgFile();
             $info = $thumb['info'];
             if (!$info) {
                 // 上传错误提示错误信息
                 $error;
             } else {
                 // 上传成功
                 $path = $info['ban_url']['savepath'];
                 $p = ltrim($path, '.');
                 $img = $info['ban_url']['savename'];
                 $src = $p . $img;
                 $product = M('product');
                 $product->where(array('pro_id' => $res))->save(array('pro_thumb' => $src));
                 echo "<script>alert('添加成功');window.location.href='/Admin/Product/index';</script>";
             }
         } else {
             echo "<script>window.location.href='/index.php/Admin/Product/index';</script>";
         }
     }
     $data = array('cate' => $cate, 'time' => $time);
     $this->assign($data);
     $this->display();
 }