示例#1
0
 public function editcate()
 {
     $cateid = $this->segment(4);
     if (!intval($cateid)) {
         _message("参数错误");
         exit;
     }
     $cateinfo = $this->db->GetOne("SELECT * FROM `@#_category` WHERE `cateid` = '{$cateid}' LIMIT 1");
     if (!$cateinfo) {
         _message("没有这个栏目");
     }
     $cateinfo['info'] = unserialize($cateinfo['info']);
     $categorys = $this->db->GetList("SELECT * FROM `@#_category` WHERE 1 order by `parentid` ASC,`cateid` ASC", array('key' => 'cateid'));
     $models = $this->db->GetList("SELECT * FROM `@#_model` WHERE 1", array('key' => 'modelid'));
     $tree = System::load_sys_class('tree');
     $tree->icon = array('│ ', '├─ ', '└─ ');
     $tree->nbsp = ' ';
     $categoryshtml = "<option value='\$cateid'>\$spacer\$name</option>";
     $tree->init($categorys);
     $categoryshtml = $tree->get_tree(0, $categoryshtml);
     $catetype = 'def';
     //类型
     if ($cateinfo['model'] > 0) {
         $catetype = 'def';
     }
     if ($cateinfo['model'] == -1) {
         $catetype = 'danweb';
     }
     if ($cateinfo['model'] == -2) {
         $catetype = 'link';
     }
     $topinfo = $this->db->GetOne("SELECT * FROM `@#_category` WHERE `cateid` = '{$cateinfo['parentid']}' LIMIT 1");
     if ($topinfo) {
         $categoryshtml .= "<option value='{$topinfo['cateid']}' selected>≡ {$topinfo['name']} ≡</option>";
     } else {
         $categoryshtml .= "<option value='0' selected>≡ 作为一级栏目 ≡</option>";
     }
     $info = array();
     if (isset($_POST['info'])) {
         switch ($catetype) {
             case 'def':
                 $info['parentid'] = intval($_POST['info']['parentid']);
                 $info['name'] = htmlspecialchars($_POST['info']['name']);
                 $info['catdir'] = htmlspecialchars($_POST['info']['catdir']);
                 if (empty($info['name'])) {
                     _message('栏目名不能为空');
                 }
                 if (empty($info['catdir'])) {
                     _message("地址不能为空");
                 }
                 $setting = array('thumb' => htmlspecialchars($_POST['thumb']), 'des' => htmlspecialchars($_POST['info']['description']), 'template' => '', 'content' => '', 'meta_title' => htmlspecialchars($_POST['setting']['meta_title']), 'meta_keywords' => htmlspecialchars($_POST['setting']['meta_keywords']), 'meta_description' => htmlspecialchars($_POST['setting']['meta_description']));
                 $setting['template_list'] = $_POST['info']['template_list'];
                 $setting['template_show'] = $_POST['info']['template_show'];
                 $setting = serialize($setting);
                 $sql = "UPDATE `@#_category` SET `parentid`='{$info['parentid']}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t   `name`='{$info['name']}', \n\t\t\t\t\t\t\t\t\t\t\t\t\t   `catdir`='{$info['catdir']}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t   `info`='{$setting}' \n\t\t\t\t\t\t\t\t\t\t\t\t\t   WHERE (`cateid`='{$cateid}')\n\t\t\t\t\t\t ";
                 $this->db->Query($sql);
                 if ($this->db->affected_rows()) {
                     _message("操作成功!", WEB_PATH . '/' . ROUTE_M . '/category/lists/');
                 } else {
                     _message("操作失败!");
                 }
                 break;
             case 'danweb':
                 $info['parentid'] = intval($_POST['info']['parentid']);
                 $info['name'] = $_POST['info']['name'];
                 $info['catdir'] = $_POST['info']['catdir'];
                 if (empty($info['name'])) {
                     _message('栏目名不能为空');
                 }
                 if (empty($info['catdir'])) {
                     _message("地址不能为空");
                 }
                 $setting = array('thumb' => htmlspecialchars($_POST['thumb']), 'des' => htmlspecialchars($_POST['info']['description']), 'template' => $_POST['info']['template'], 'content' => base64_encode(editor_safe_replace(stripslashes($_POST['setting']['content']))), 'meta_title' => htmlspecialchars($_POST['setting']['meta_title']), 'meta_keywords' => htmlspecialchars($_POST['setting']['meta_keywords']), 'meta_description' => htmlspecialchars($_POST['setting']['meta_description']));
                 $setting = serialize($setting);
                 $sql = "UPDATE `@#_category` SET `parentid`='{$info['parentid']}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t   `name`='{$info['name']}', \n\t\t\t\t\t\t\t\t\t\t\t\t\t   `catdir`='{$info['catdir']}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t   `info`='{$setting}' \n\t\t\t\t\t\t\t\t\t\t\t\t\t   WHERE (`cateid`='{$cateid}')\n\t\t\t\t\t\t ";
                 $this->db->Query($sql);
                 if ($this->db->affected_rows()) {
                     _message("操作成功!", WEB_PATH . '/' . ROUTE_M . '/category/lists/');
                 } else {
                     _message("操作失败!");
                 }
                 break;
             case 'link':
                 $info['parentid'] = intval($_POST['info']['parentid']);
                 $info['name'] = htmlspecialchars($_POST['info']['name']);
                 $info['url'] = htmlspecialchars($_POST['info']['url']);
                 if (empty($info['name'])) {
                     _message('栏目名不能为空');
                 }
                 if (empty($info['url'])) {
                     _message("地址不能为空");
                 }
                 $sql = "UPDATE `@#_category` SET `parentid`='{$info['parentid']}',`name`='{$info['name']}', `url`='{$info['url']}' WHERE (`cateid`='{$cateid}')";
                 $this->db->Query($sql);
                 if ($this->db->affected_rows()) {
                     _message("操作成功!", WEB_PATH . '/' . ROUTE_M . '/category/lists/');
                 } else {
                     _message("操作失败!");
                 }
                 break;
         }
         //SWITCH END
     }
     //IF POST END
     include $this->tpl(ROUTE_M, 'category.edit');
 }
示例#2
0
 public function goods_add()
 {
     if (isset($_POST['dosubmit'])) {
         $cateid = intval($_POST['cateid']);
         $brandid = intval($_POST['brand']);
         $title = _htmtocode($_POST['title']);
         $title_color = htmlspecialchars($_POST['title_style_color']);
         $title_bold = htmlspecialchars($_POST['title_style_bold']);
         $title2 = _htmtocode($_POST['title2']);
         $keywords = htmlspecialchars($_POST['keywords']);
         $description = htmlspecialchars($_POST['description']);
         $content = editor_safe_replace(stripslashes($_POST['content']));
         $money = intval($_POST['money']);
         $yunjiage = intval($_POST['yunjiage']);
         $xiangou = intval($_POST['xiangou']);
         $thumb = htmlspecialchars($_POST['thumb']);
         $maxqishu = intval($_POST['maxqishu']);
         $canyurenshu = 0;
         $goods_key_pos = isset($_POST['goods_key']['pos']) ? 1 : 0;
         $goods_key_renqi = isset($_POST['goods_key']['renqi']) ? 1 : 0;
         $goods_key_bannershop = isset($_POST['goods_key']['bannershop']) ? 1 : 0;
         $renqipos = isset($_POST['goods_key']['renqipos']) ? 1 : 0;
         $newpos = isset($_POST['goods_key']['newpos']) ? 1 : 0;
         $posthumb = trim(htmlspecialchars($_POST['posthumb']));
         if (!$cateid) {
             _message("请选择栏目");
         }
         if (!$brandid) {
             _message("请选择品牌");
         }
         if (!$title) {
             _message("标题不能为空");
         }
         if (!$thumb) {
             _message("缩略图不能为空");
         }
         $title_style = '';
         if ($title_color) {
             $title_style .= 'color:' . $title_color . ';';
         }
         if ($title_bold) {
             $title_style .= 'font-weight:' . $title_bold . ';';
         }
         if (isset($_POST['uppicarr'])) {
             $picarr = serialize($_POST['uppicarr']);
         } else {
             $picarr = serialize(array());
         }
         if ($_POST['xsjx_time'] != '') {
             $xsjx_time = strtotime($_POST['xsjx_time']) ? strtotime($_POST['xsjx_time']) : time();
             $xsjx_time_h = intval($_POST['xsjx_time_h']) ? $_POST['xsjx_time_h'] : 36000;
             $xsjx_time += $xsjx_time_h;
         } else {
             $xsjx_time = '0';
         }
         if ($maxqishu > 65535) {
             _message("最大雨数不能超过65535雨");
         }
         if ($money < $yunjiage) {
             _message("商品价格不能小于购买价格");
         }
         $zongrenshu = ceil($money / $yunjiage);
         $codes_len = ceil($zongrenshu / 3000);
         $shenyurenshu = $zongrenshu - $canyurenshu;
         if ($zongrenshu == 0 || $zongrenshu - $canyurenshu == 0) {
             _message("云购价格不正确");
         }
         $time = time();
         //商品添加时间
         $this->db->Autocommit_start();
         $query_1 = $this->db->Query("INSERT INTO `@#_shoplist` (`quyu`,`cateid`, `brandid`, `title`, `title_style`, `title2`, `keywords`, `description`, `money`, `yunjiage`, `xiangou`, `zongrenshu`, `canyurenshu`,`shenyurenshu`, `qishu`,`maxqishu`,`thumb`, `picarr`, `content`,`xsjx_time`,`renqi`,`pos`,`bannershop`,`renqipos`,`newpos`,`posthumb`, `time`) VALUES ('" . htmlspecialchars($_POST['quyu']) . "','{$cateid}', '{$brandid}', '{$title}', '{$title_style}', '{$title2}', '{$keywords}', '{$description}', '{$money}', '{$yunjiage}','{$xiangou}' ,'{$zongrenshu}', '{$canyurenshu}','{$shenyurenshu}', '1','{$maxqishu}', '{$thumb}', '{$picarr}', '{$content}','{$xsjx_time}','{$goods_key_renqi}', '{$goods_key_pos}','{$goods_key_bannershop}','{$renqipos}','{$newpos}','{$posthumb}','{$time}')");
         $shopid = $this->db->insert_id();
         System::load_app_fun("content");
         $query_table = content_get_codes_table();
         if (!$query_table) {
             $this->db->Autocommit_rollback();
             _message("雨购码仓库不正确!");
         }
         $query_2 = content_get_go_codes($zongrenshu, 3000, $shopid);
         $query_3 = $this->db->Query("UPDATE `@#_shoplist` SET `codes_table` = '{$query_table}',`sid` = '{$shopid}',`def_renshu` = '{$canyurenshu}' where `id` = '{$shopid}'");
         if ($query_1 && $query_2 && $query_3) {
             $this->db->Autocommit_commit();
             _message("商品添加成功!", WEB_PATH . '/' . ROUTE_M . '/content/goods_list/');
         } else {
             $this->db->Autocommit_rollback();
             _message("商品添加失败!");
         }
         header("Cache-control: private");
     }
     $cateid = intval($this->segment(4));
     $categorys = $this->db->GetList("SELECT * FROM `@#_category` WHERE `model` = '1' order by `parentid` ASC,`cateid` ASC", array('key' => 'cateid'));
     $tree = System::load_sys_class('tree');
     $tree->icon = array('│ ', '├─ ', '└─ ');
     $tree->nbsp = '&nbsp;';
     $categoryshtml = "<option value='\$cateid'>\$spacer\$name</option>";
     $tree->init($categorys);
     $categoryshtml = $tree->get_tree(0, $categoryshtml);
     $categoryshtml = '<option value="0">≡ 请选择栏目 ≡</option>' . $categoryshtml;
     if ($cateid) {
         $cateinfo = $this->db->GetOne("SELECT * FROM `@#_category` WHERE `cateid` = '{$cateid}' LIMIT 1");
         if (!$cateinfo) {
             _message("参数不正确,没有这个栏目", G_ADMIN_PATH . '/' . ROUTE_C . '/addarticle');
         }
         $categoryshtml .= '<option value="' . $cateinfo['cateid'] . '" selected="true">' . $cateinfo['name'] . '</option>';
         $BrandList = $this->db->GetList("SELECT * FROM `@#_brand` where `cateid`='{$cateid}'", array("key" => "id"));
     } else {
         $BrandList = $this->db->GetList("SELECT * FROM `@#_brand` where 1", array("key" => "id"));
     }
     $this->ment = array(array("lists", "商品管理", ROUTE_M . '/' . ROUTE_C . "/goods_list"), array("insert", "添加商品", ROUTE_M . '/' . ROUTE_C . "/goods_add"));
     include $this->tpl(ROUTE_M, 'shop.insert');
 }
示例#3
0
 public function singleinsert()
 {
     $member = $this->userinfo;
     $uid = _getcookie('uid');
     $ushell = _getcookie('ushell');
     $title = "添加晒单";
     $recordid = intval($this->segment(4));
     $shopid = $recordid;
     $shaidan = $this->db->GetOne("select * from `@#_member_go_record` where `id`='{$recordid}' and `uid` = '{$member['uid']}'");
     if (!$shaidan) {
         _message("该商品您不可晒单!");
     }
     $shaidanyn = $this->db->GetOne("select sd_id from `@#_shaidan` where `sd_shopid`='{$recordid}' and `sd_userid` = '{$member['uid']}'");
     if ($shaidanyn) {
         _message("不可重复晒单!");
     }
     $ginfo = $this->db->GetOne("select id,sid,qishu from `@#_shoplist` where `id`='{$shaidan['shopid']}' LIMIT 1");
     if (!$ginfo) {
         _message("该商品已不存在!");
     }
     if (isset($_POST['submit'])) {
         if ($_POST['title'] == null) {
             _message("标题不能为空");
         }
         if ($_POST['content'] == null) {
             _message("内容不能为空");
         }
         if (!isset($_POST['fileurl_tmp'])) {
             _message("图片不能为空");
         }
         System::load_sys_class('upload', 'sys', 'no');
         $img = $_POST['fileurl_tmp'];
         $num = count($img);
         $pic = "";
         for ($i = 0; $i < $num; $i++) {
             $pic .= trim($img[$i]) . ";";
         }
         $src = trim($img[0]);
         if (!file_exists(G_UPLOAD . $src)) {
             _message("晒单图片不正确");
         }
         $size = getimagesize(G_UPLOAD . $src);
         $width = 220;
         $height = $size[1] * ($width / $size[0]);
         $src_houzhui = upload::thumbs($width, $height, false, G_UPLOAD . '/' . $src);
         $thumbs = $src . "_" . intval($width) . intval($height) . "." . $src_houzhui;
         $sd_userid = $this->userinfo['uid'];
         $sd_shopid = $ginfo['id'];
         $sd_shopsid = $ginfo['sid'];
         $sd_qishu = $ginfo['qishu'];
         $sd_title = _htmtocode($_POST['title']);
         $sd_thumbs = $thumbs;
         $sd_content = editor_safe_replace(stripslashes($_POST['content']));
         $sd_photolist = $pic;
         $sd_time = time();
         $sd_ip = _get_ip_dizhi();
         $this->db->Query("INSERT INTO `@#_shaidan`(`sd_userid`,`sd_shopid`,`sd_shopsid`,`sd_qishu`,`sd_ip`,`sd_title`,`sd_thumbs`,`sd_content`,`sd_photolist`,`sd_time`)VALUES\n\t\t\t('{$sd_userid}','{$sd_shopid}','{$sd_shopsid}','{$sd_qishu}','{$sd_ip}','{$sd_title}','{$sd_thumbs}','{$sd_content}','{$sd_photolist}','{$sd_time}')");
         _message("晒单分享成功", WEB_PATH . "/member/home/singlelist");
     }
     include templates("member", "singleinsert");
 }