public function submit() { $result = array('error' => 1, 'content' => ''); $info['name'] = isset($_POST['name']) ? hy_check($_POST['name'], 'ur') : ''; $info['email'] = isset($_POST['email']) ? hy_check($_POST['email'], 'e') : ''; $info['phone'] = isset($_POST['phone']) ? hy_check($_POST['phone'], 'n') : ''; $info['content'] = isset($_POST['content']) ? hy_substr($_POST['content'], '255') : ''; $info['ip'] = hy_getIP(); $info['created'] = $_SERVER['REQUEST_TIME']; if ($info['name'] == '#@_error') { $result['content'] = '名字格式错误'; print_r(json_encode($result)); exit; } if ($info['email'] == '#@_error') { $result['content'] = '邮件格式错误'; print_r(json_encode($result)); exit; } if ($info['phone'] == '#@_error') { $result['content'] = '电话格式错误'; print_r(json_encode($result)); exit; } $check = Model('forms')->check_ip(array('ip' => $info['ip'], 'table' => 'forms_log_1')); if (!$check) { $result['content'] = '你提交得太频繁了'; print_r(json_encode($result)); exit; } $res = Model('forms')->insert($info, 'forms_log_1'); if ($res) { $result['error'] = 0; $result['content'] = '添加成功'; } else { $result['content'] = '系统繁忙'; } print_r(json_encode($result)); exit; }
public function index() { $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1; $cache_id = $page . '-' . $_GET['code'] . '-' . $_GET['k'] . '-' . DEFAULT_LANG . '-' . session('user_id'); $cfg[k] = hy_substr($_GET['k'], 20); $cache_id = sprintf('%X', crc32($cache_id)); if (!$this->is_cached('list.html', $cache_id)) { $app = Model('app'); if (!($id = $app->code_to_id($_GET['code']))) { //hy_404(); } $cat = $app->getTopClass($id); $this->assign('top', $cat); $art = Model('article'); $cat = $app->getCurClass($id); $this->assign('cat', $cat); $config[c] = array('site_name' => $cat['name'] . '-' . $app->get_cfg('site_name')); $this->assign_global($config); $art_list = $art->get_art_list($page, $id, 4, $cfg); $this->assign('art_list', $art_list['data']); $this->assign('art_page', $art_list['pagelink']); } $this->display('list.html', $cache_id); }
/** * 作品详情展示 */ public function detail() { $workid = I('get.workid'); if (empty($workid)) { $this->error('您访问的页面不存在'); } //增加点击数 M('Works')->where(array('workid' => $workid))->setInc('clicknum'); $detail = D('Works')->relation(true)->find($workid); if (!$detail) { $this->error('您访问的作品不存在'); } //start yf $yf_thumb = array(); $yf_pic = array(); if (!empty($detail['all_pic'])) { $yf_arr = json_decode($detail['all_pic'], true); $yf_temp = array(); foreach ($yf_arr as $k => $v) { $yf_thumb[] = $v; $yf_ex = explode("/", $v); $yf_ex[count($yf_ex) - 1] = str_replace("yf_", "", $yf_ex[count($yf_ex) - 1]); $yf_pic[] = implode("/", $yf_ex); } } else { $yf_arr = array(); $yf_thumb[] = $yf_pic[] = $detail['image']; } $detail['pic_num'] = count($yf_thumb); $detail['thumb'] = implode(",", $yf_thumb); $detail['pic'] = implode(",", $yf_pic); $detail['WorksMaterials_count'] = count($detail['WorksMaterials']); //end $this->assign('data', $detail); //点赞总数 $this->digallnum = $detail['goodnum'] + $detail['badnum']; //综合评价 if ($detail['goodnum'] == 0 && $detail['badnum'] == 0) { $dig['digavg'] = 0; $dig['goodprecent'] = 50; $dig['badprecent'] = 50; } else { $digavg = round($detail['goodnum'] / ($detail['goodnum'] + $detail['badnum']), 2); $dig['digavg'] = $digavg * 10; $dig['goodprecent'] = $digavg * 100; $dig['badprecent'] = (1 - $digavg) * 100; } $this->dig = $dig; //点赞判断 $this->digtype = M('Dig')->field('digtype,id')->where(array('userid' => $this->userid, 'status' => true, 'infoid' => $workid))->find(); //收藏判断 $this->favoritenum = getCount('UserFavorite', array('userid' => $this->userid, 'status' => true, 'infoid' => $workid)); //右侧广告 $this->rightad = parent::getAdvert(8, 3, 0, 2); //点赞人员列表 $diguser = new Model(); $diguerlist = $diguser->table(array(C('DB_PREFIX') . 'dig' => 'D', C('DB_PREFIX') . 'user' => 'U'))->where('D.userid=U.userid and D.status=true and D.digtype=1 and D.infoid=' . $workid . '')->field('U.uavatar,U.openuid')->select(); $this->assign('diglist', $diguerlist); //评论 $where['infoid'] = $workid; $where['type'] = 1; $where['parent_id'] = 0; $count = M('UserMessage')->where($where)->count(); // $limitRows = 5; // 设置每页记录数 $limitRows = C('YF_PAGE'); $page = $this->ajaxpage($count, $limitRows, '#msg', 'ajax_div', 'ajax_page_div'); $Model = new Model(); $message = $Model->table(array(C('DB_PREFIX') . 'user_message' => 'M', C('DB_PREFIX') . 'user' => 'U'))->where('M.userid=U.userid and M.status=true and M.infoid=' . $workid . ' and M.type=1 and M.parent_id=0')->field('M.create_time,M.content,U.nickname,U.uavatar,U.openuid,U.uprovince,U.ucity,U.userid,M.id,M.touserid,U.ifrz')->order('M.create_time DESC')->limit($page->firstRow . ',' . $page->listRows)->select(); foreach ($message as $k => $v) { $child_temp = array(); $child_temp = $Model->table(C('DB_PREFIX') . 'user_message')->field('*')->where(array('parent_id' => $v['id']))->order('create_time ASC')->select(); $message[$k]['childlist'] = array(); if ($child_temp) { foreach ($child_temp as $yk => $yv) { if ($yv['userid'] == 0) { $child_temp[$yk]['nickname'] = "烘焙圈"; $child_temp[$yk]['openuid'] = 0; } else { $yf_user = array(); $yf_user = M('User')->field('openuid, nickname, uprovince, ucity, uavatar, ifrz')->where(array('userid' => $yv['userid']))->find(); $child_temp[$yk]['nickname'] = $yf_user['nickname']; $child_temp[$yk]['openuid'] = $yf_user['openuid']; $child_temp[$yk]['uprovince'] = $yf_user['uprovince']; $child_temp[$yk]['ucity'] = $yf_user['ucity']; $child_temp[$yk]['uavatar'] = $yf_user['uavatar']; $child_temp[$yk]['ifrz'] = $yf_user['ifrz']; } if ($yv['touserid'] != 0) { $child_temp[$yk]['touser'] = M('User')->field('openuid,nickname')->where(array('userid' => $yv['touserid']))->find(); } else { $child_temp[$yk]['touser']['nickname'] = "烘焙圈"; $child_temp[$yk]['touser']['openuid'] = 0; } } $message[$k]['childlist'] = $child_temp; } $message[$k]['tempname'] = hy_substr($v['nickname'], 4, true); //$message[$k]['tempname'] = $v['nickname']; $message[$k]['touser'] = array(); if (!empty($v['touserid'])) { $message[$k]['touser'] = M('User')->field('openuid,nickname')->where(array('userid' => $v['touserid']))->find(); } } unset($where['parent_id']); $this->msgcount = M('UserMessage')->where($where)->count(); $this->msgtype = 1; $this->assign('msglist', $message); $this->assign('page', $page->show()); if (IS_AJAX) { exit($this->fetch('msglist')); } //参照做出的作品 $copylist = $Model->table(array(C('DB_PREFIX') . 'works' => 'W', C('DB_PREFIX') . 'user' => 'U'))->where('W.userid=U.userid and W.status=true and W.type=2 and W.copyid=' . $workid)->field('U.openuid,U.nickname,U.uavatar,W.title,W.image,W.workid,W.create_time,W.title')->order('W.workid DESC')->limit(2)->select(); $this->copylist = $copylist; $this->display(); }
public function reportdetail() { $aid = I('get.id'); if (empty($aid)) { $this->error('您访问的页面不存在!'); } $data = M('TryReport')->where(array('status' => true, 'id' => $aid))->find(); $model = new Model(); $data = $model->table(array(C('DB_PREFIX') . 'try_report' => 'R', C('DB_PREFIX') . 'try_items' => 'I', C('DB_PREFIX') . 'user' => 'U'))->where('I.tryid=R.tryid and U.userid=R.userid and R.status=true and R.id=' . $aid)->field('R.id,R.msgnum,I.title,I.price,I.buylink,U.openuid,U.uavatar,U.nickname,U.ifrz,R.create_time,R.content,R.image,R.otherpic')->find(); $data['otherpic'] = explode('|', $data['otherpic']); if ($data) { $this->assign('data', $data); } else { $this->_empty(); } //评论 $where['infoid'] = $aid; $where['type'] = 3; $where['parent_id'] = 0; $count = M('UserMessage')->where($where)->count(); // $limitRows = 5; // 设置每页记录数 $limitRows = C('YF_PAGE'); $page = $this->ajaxpage($count, $limitRows, '#msg', 'ajax_div', 'ajax_page_div'); $msgModel = new Model(); $message = $msgModel->table(array(C('DB_PREFIX') . 'user_message' => 'M', C('DB_PREFIX') . 'user' => 'U'))->where('M.userid=U.userid and M.status=true and M.infoid=' . $aid . ' and M.type=3 and M.parent_id=0')->field('M.create_time,M.content,U.nickname,U.uavatar,U.openuid,U.uprovince,U.ucity,U.userid,M.id,M.touserid')->order('M.create_time DESC')->limit($page->firstRow . ',' . $page->listRows)->select(); // foreach($message as $k=>$v){ // $message[$k]['touser']=M('User')->field('openuid,nickname')->where(array('userid'=>$v['touserid']))->find(); // } foreach ($message as $k => $v) { $child_temp = array(); $child_temp = $msgModel->table(C('DB_PREFIX') . 'user_message')->field('*')->where(array('parent_id' => $v['id']))->order('create_time ASC')->select(); $message[$k]['childlist'] = array(); if ($child_temp) { foreach ($child_temp as $yk => $yv) { if ($yv['userid'] == 0) { $child_temp[$yk]['nickname'] = "烘焙圈"; $child_temp[$yk]['openuid'] = 0; } else { $yf_user = array(); $yf_user = M('User')->field('openuid, nickname, uprovince, ucity, uavatar, ifrz')->where(array('userid' => $yv['userid']))->find(); $child_temp[$yk]['nickname'] = $yf_user['nickname']; $child_temp[$yk]['openuid'] = $yf_user['openuid']; $child_temp[$yk]['uprovince'] = $yf_user['uprovince']; $child_temp[$yk]['ucity'] = $yf_user['ucity']; $child_temp[$yk]['uavatar'] = $yf_user['uavatar']; $child_temp[$yk]['ifrz'] = $yf_user['ifrz']; } if ($yv['touserid'] != 0) { $child_temp[$yk]['touser'] = M('User')->field('openuid,nickname')->where(array('userid' => $yv['touserid']))->find(); } else { $child_temp[$yk]['touser']['nickname'] = "烘焙圈"; $child_temp[$yk]['touser']['openuid'] = 0; } } $message[$k]['childlist'] = $child_temp; } $message[$k]['tempname'] = hy_substr($v['nickname'], 4, true); //$message[$k]['tempname'] = $v['nickname']; $message[$k]['touser'] = array(); if (!empty($v['touserid'])) { $message[$k]['touser'] = M('User')->field('openuid,nickname')->where(array('userid' => $v['touserid']))->find(); } } unset($where['parent_id']); $this->msgcount = M('UserMessage')->where($where)->count(); $this->msgtype = 3; $this->assign('msglist', $message); $this->assign('page', $page->show()); if (IS_AJAX) { exit($this->fetch('msglist')); } $this->display(); }
/** * 随拍作品详情 */ public function detail() { $workid = I('get.workid'); if (empty($workid)) { $this->error('您访问的页面不存在'); } //增加点击数 M('Works')->where(array('workid' => $workid))->setInc('clicknum'); $detail = D('Works')->relation(true)->find($workid); if (!$detail) { $this->error('您访问的作品不存在'); } $img_temp = explode("/", $detail['image']); $img_temp[count($img_temp) - 1] = str_replace("yf_", "", $img_temp[count($img_temp) - 1]); $detail['image'] = implode("/", $img_temp); $this->assign('data', $detail); $user = M('User')->where(array('userid' => $detail['userid']))->field("openuid, nickname, uavatar")->find(); //print_r($user); $this->assign("user", $user); $copyinfo = M('Works')->where(array('workid' => $detail['copyid']))->field("title, image, userid")->find(); $mname = M('WorksMaterials')->where(array('workid' => $detail['copyid']))->field("mname")->select(); //print_r($mname); //print_r($copyinfo); $copyinfo['materials'] = array(); if ($mname) { $temp_mater = array(); foreach ($mname as $mk => $mv) { $temp_mater[] = $mv['mname']; } $copyinfo['materials'] = implode("、", $temp_mater); //$copyinfo['materials'] = "高筋粉(金像,焙食尚各一半)、细砂糖、可可粉、盐、干酵母、水(我们"; $copyinfo['materials'] = hy_substr($copyinfo['materials'], 32, true); } $copyinfo['donum'] = M('Works')->where(array('copyid' => $detail['copyid']))->count(); $seven = time() - 7 * 24 * 60 * 60; $copyinfo['nownum'] = M('Works')->where("copyid=%d and create_time > %s", array($detail['copyid'], $seven))->count(); $this->assign("copyinfo", $copyinfo); $copyuser = M('User')->where(array('userid' => $copyinfo['userid']))->field("nickname, openuid")->find(); $this->assign("copyuser", $copyuser); //点赞总数 $this->digallnum = $detail['goodnum'] + $detail['badnum']; //点赞判断 $this->dignum = M('Dig')->where(array('userid' => $this->userid, 'status' => true, 'infoid' => $workid))->count(); //收藏判断 $this->favoritenum = getCount('UserFavorite', array('userid' => $this->userid, 'status' => true, 'infoid' => $workid)); //右侧广告 $this->rightad = parent::getAdvert(8, 3, 0, 2); //点赞人员列表 $diguser = new Model(); $diguerlist = $diguser->table(array(C('DB_PREFIX') . 'dig' => 'D', C('DB_PREFIX') . 'user' => 'U'))->where('D.userid=U.userid and D.status=true and D.digtype=1 and D.infoid=' . $workid . '')->field('U.uavatar,U.openuid')->select(); $this->assign('diglist', $diguerlist); //评论 // $where['infoid']=$workid; // $where['type']=1; // $count = M('UserMessage')->where($where)->count(); // $limitRows = 10; // 设置每页记录数 // $page = $this->ajaxpage($count,$limitRows,'type=msg','ajax_div','ajax_page_div'); // $msgModel=new Model(); // $message=$msgModel // ->table(array( // C('DB_PREFIX').'user_message'=>'M', // C('DB_PREFIX').'user'=>'U', // ) // ) // ->where('M.userid=U.userid and M.status=true and M.infoid='.$workid.' and M.type=1') // ->field('M.create_time,M.content,U.nickname,U.uavatar,U.openuid,U.uprovince,U.ucity,U.userid,M.id,M.touserid') // ->order('M.create_time DESC') // ->limit($page->firstRow . ',' . $page->listRows) // ->select(); // foreach($message as $k=>$v){ // $message[$k]['touser']=M('User')->field('openuid,nickname')->where(array('userid'=>$v['touserid']))->find(); // } $where['infoid'] = $workid; $where['type'] = 1; $where['parent_id'] = 0; $count = M('UserMessage')->where($where)->count(); // $limitRows = 5; // 设置每页记录数 $limitRows = C('YF_PAGE'); $page = $this->ajaxpage($count, $limitRows, '#msg', 'ajax_div', 'ajax_page_div'); $Model = new Model(); $message = $Model->table(array(C('DB_PREFIX') . 'user_message' => 'M', C('DB_PREFIX') . 'user' => 'U'))->where('M.userid=U.userid and M.status=true and M.infoid=' . $workid . ' and M.type=1 and M.parent_id=0')->field('M.create_time,M.content,U.nickname,U.uavatar,U.openuid,U.uprovince,U.ucity,U.userid,M.id,M.touserid,U.ifrz')->order('M.create_time DESC')->limit($page->firstRow . ',' . $page->listRows)->select(); foreach ($message as $k => $v) { $child_temp = array(); $child_temp = $Model->table(C('DB_PREFIX') . 'user_message')->field('*')->where(array('parent_id' => $v['id']))->order('create_time ASC')->select(); $message[$k]['childlist'] = array(); if ($child_temp) { foreach ($child_temp as $yk => $yv) { if ($yv['userid'] == 0) { $child_temp[$yk]['nickname'] = "烘焙圈"; $child_temp[$yk]['openuid'] = 0; } else { $yf_user = array(); $yf_user = M('User')->field('openuid, nickname, uprovince, ucity, uavatar, ifrz')->where(array('userid' => $yv['userid']))->find(); $child_temp[$yk]['nickname'] = $yf_user['nickname']; $child_temp[$yk]['openuid'] = $yf_user['openuid']; $child_temp[$yk]['uprovince'] = $yf_user['uprovince']; $child_temp[$yk]['ucity'] = $yf_user['ucity']; $child_temp[$yk]['uavatar'] = $yf_user['uavatar']; $child_temp[$yk]['ifrz'] = $yf_user['ifrz']; } if ($yv['touserid'] != 0) { $child_temp[$yk]['touser'] = M('User')->field('openuid,nickname')->where(array('userid' => $yv['touserid']))->find(); } else { $child_temp[$yk]['touser']['nickname'] = "烘焙圈"; $child_temp[$yk]['touser']['openuid'] = 0; } } $message[$k]['childlist'] = $child_temp; } $message[$k]['tempname'] = hy_substr($v['nickname'], 4, true); //$message[$k]['tempname'] = $v['nickname']; $message[$k]['touser'] = array(); if (!empty($v['touserid'])) { $message[$k]['touser'] = M('User')->field('openuid,nickname')->where(array('userid' => $v['touserid']))->find(); } } unset($where['parent_id']); $this->msgcount = M('UserMessage')->where($where)->count(); $this->msgtype = 1; // $this->msgcount=$count; $this->assign('msglist', $message); $this->assign('page', $page->show()); if (IS_AJAX) { exit($this->fetch('msglist')); //list为list.html模版 } //获取会员烘焙作品数 $this->hbworksnum = getCount('Works', array('status' => true, 'type' => 1, 'userid' => $detail['userid'])); //获取会员随拍作品数 $this->spworksnum = getCount('Works', array('status' => true, 'type' => 2, 'userid' => $detail['userid'])); //是否关注 $this->isfans = getCount('UserFans', array('myid' => $this->userid, 'userid' => $detail['userid'], 'status' => true)); //更多随拍作品 $map['status'] = array('EQ', true); $map['userid'] = array('EQ', $detail['userid']); $map['workid'] = array('NEQ', $workid); $this->moresp = M('Works')->field('image,workid,type,title')->where($map)->limit(9)->select(); $this->display(); }
/** * 随拍作品详情 */ public function detail() { $workid = I('get.workid'); if (empty($workid)) { $this->error('您访问的页面不存在'); } //增加点击数 $model = M('Suipai'); $model->where(array('id' => $workid))->setInc('clicknum'); $detail = $model->find($workid); $unionModel = new Model(); $detail = $unionModel->table(array(C('DB_PREFIX') . 'user' => 'U', C('DB_PREFIX') . 'suipai' => 'S'))->where('U.userid=S.userid and S.id=' . $workid)->field('U.nickname,U.uavatar,U.openuid,U.userid,U.ifrz,S.id,S.title,S.image,S.all_pic,S.content,S.clicknum,S.msgnum')->find(); if (!$detail) { $this->error('您访问的作品不存在'); } //start yf $yf_thumb = array(); $yf_pic = array(); if (!empty($detail['all_pic'])) { $yf_arr = json_decode($detail['all_pic'], true); $yf_temp = array(); foreach ($yf_arr as $k => $v) { $yf_thumb[] = $v; $yf_ex = explode("/", $v); $yf_ex[count($yf_ex) - 1] = str_replace("yf_", "", $yf_ex[count($yf_ex) - 1]); $yf_pic[] = implode("/", $yf_ex); } } else { $yf_arr = array(); $yf_thumb[] = $yf_pic[] = $detail['image']; } $detail['pic_num'] = count($yf_thumb); $detail['thumb'] = implode(",", $yf_thumb); $detail['pic'] = implode(",", $yf_pic); //end $this->assign('data', $detail); //关注数 $this->fansnum = getCount('UserFans', array('userid' => $detail['userid'], 'status' => true)); //右侧广告 $this->rightad = parent::getAdvert(4, 3, 0, 1); //评论 $where['infoid'] = $workid; $where['type'] = 4; $where['parent_id'] = 0; //yf 0915 $count = M('UserMessage')->where($where)->count(); // $limitRows = 5; // 设置每页记录数 $limitRows = C('YF_PAGE'); $page = $this->ajaxpage($count, $limitRows, '#msg', 'ajax_div', 'ajax_page_div'); $message = $unionModel->table(array(C('DB_PREFIX') . 'user_message' => 'M', C('DB_PREFIX') . 'user' => 'U'))->where('M.userid=U.userid and M.status=true and M.infoid=' . $workid . ' and M.type=4 and M.parent_id=0')->field('M.create_time,M.content,U.nickname,U.uavatar,U.openuid,U.uprovince,U.ucity,U.userid,M.id,M.touserid')->order('M.create_time DESC')->limit($page->firstRow . ',' . $page->listRows)->select(); // foreach($message as $k=>$v){ // $message[$k]['touser']=M('User')->field('openuid,nickname')->where(array('userid'=>$v['touserid']))->find(); // } foreach ($message as $k => $v) { $child_temp = array(); $child_temp = $unionModel->table(C('DB_PREFIX') . 'user_message')->field('*')->where(array('parent_id' => $v['id']))->order('create_time ASC')->select(); $message[$k]['childlist'] = array(); if ($child_temp) { foreach ($child_temp as $yk => $yv) { if ($yv['userid'] == 0) { $child_temp[$yk]['nickname'] = "烘焙圈"; $child_temp[$yk]['openuid'] = 0; } else { $yf_user = array(); $yf_user = M('User')->field('openuid, nickname, uprovince, ucity, uavatar, ifrz')->where(array('userid' => $yv['userid']))->find(); $child_temp[$yk]['nickname'] = $yf_user['nickname']; $child_temp[$yk]['openuid'] = $yf_user['openuid']; $child_temp[$yk]['uprovince'] = $yf_user['uprovince']; $child_temp[$yk]['ucity'] = $yf_user['ucity']; $child_temp[$yk]['uavatar'] = $yf_user['uavatar']; $child_temp[$yk]['ifrz'] = $yf_user['ifrz']; } if ($yv['touserid'] != 0) { $child_temp[$yk]['touser'] = M('User')->field('openuid,nickname')->where(array('userid' => $yv['touserid']))->find(); } else { $child_temp[$yk]['touser']['nickname'] = "烘焙圈"; $child_temp[$yk]['touser']['openuid'] = 0; } } $message[$k]['childlist'] = $child_temp; } $message[$k]['tempname'] = hy_substr($v['nickname'], 4, true); //$message[$k]['tempname'] = $v['nickname']; $message[$k]['touser'] = array(); if (!empty($v['touserid'])) { $message[$k]['touser'] = M('User')->field('openuid,nickname')->where(array('userid' => $v['touserid']))->find(); } } unset($where['parent_id']); $this->msgcount = M('UserMessage')->where($where)->count(); $this->msgtype = 4; $this->assign('msglist', $message); $this->assign('page', $page->show()); if (IS_AJAX) { exit($this->fetch('msglist')); //list为list.html模版 } //获取会员烘焙作品数 $this->hbworksnum = getCount('Works', array('status' => true, 'type' => 1, 'userid' => $detail['userid'])); //获取会员随拍作品数 $this->spworksnum = getCount('Suipai', array('status' => true, 'userid' => $detail['userid'])); //是否关注 $this->isfans = getCount('UserFans', array('myid' => $this->userid, 'userid' => $detail['userid'], 'status' => true)); //更多随拍作品 $map['status'] = array('EQ', true); $map['userid'] = array('EQ', $detail['userid']); $map['id'] = array('NEQ', $workid); $this->moresp = M('Suipai')->field('image,id')->where($map)->limit(6)->select(); $this->display(); }
/** * 添加文章数据 */ public function new_art() { $this->admin_priv('add_news'); $data = array('error' => 1, 'content' => ''); $info['cat_id'] = yf_empty(intval($_POST['cat_id']), '', true); //自动截取summary if ($_POST['summary'] === '' && $_POST['content'] != '') { $_POST['summary'] = hy_substr(str_replace(PHP_EOL, '', strip_tags($_POST['content'])), 200); } if ($_POST['en_summary'] === '' && $_POST['en_content'] != '') { $_POST['en_summary'] = hy_substr(str_replace(PHP_EOL, '', strip_tags($_POST['en_content'])), 200); } $en_summary = yf_empty($_POST['en_summary'], "", true); $info['summary'] = isset($_POST['summary']) ? CH_SC . $_POST['summary'] . DIG_EC . EN_SC . $en_summary . DIG_EC : ''; $en_title = yf_empty($_POST['en_title'], '', true); $en_author = yf_empty($_POST['en_author'], '', true); $en_content = yf_empty($_POST['en_content'], '', true); $title = yf_empty($_POST['title'], Lang('KEY_EMPTY')); $info['title'] = isset($_POST['title']) ? CH_SC . $title . DIG_EC . EN_SC . $en_title . DIG_EC : ''; $info['abstract'] = yf_empty($_POST['abstract'], '', true); $info['flags'] = is_array($_POST['flags']) ? implode(',', $_POST['flags']) : $_POST['flags']; $info['keywords'] = yf_empty($_POST['keywords'], '', true); $info['author'] = isset($_POST['author']) ? CH_SC . $_POST['author'] . DIG_EC . EN_SC . $en_author . DIG_EC : ''; $info['source'] = yf_empty($_POST['source'], '', true); $info['content'] = isset($_POST['content']) ? CH_SC . $_POST['content'] . DIG_EC . EN_SC . $en_content . DIG_EC : ''; $info['ordering'] = yf_empty($_POST['ordering'], 0, true); $info['hits'] = yf_empty($_POST['hits'], 0, true); $info['source_url'] = yf_empty($_POST['source_url'], '', true); $info['page_title'] = yf_empty($_POST['page_title'], '', true); $info['created'] = empty($_POST['created']) ? yf_time() : strtotime($_POST['created']); $info['thumb'] = yf_empty($_POST['thumb'], '', true); $info['is_show'] = yf_empty($_POST['is_show'], 1, true); if (!empty($_POST['photo'])) { $photo = is_array($_POST['photo']) ? $_POST['photo'] : array($_POST['photo']); } else { $photo = array(); } $info['form_id'] = yf_empty($_POST['form_id'], 0, true); $pattern = "/<[img|IMG].*?src=[\\'|\"](.*?(?:[\\.gif|\\.jpg|\\.png]))[\\'|\"].*?[\\/]?>/"; preg_match_all($pattern, stripslashes($info['content']), $match); if ($match) { $file = array('name' => '', 'type' => 'image/png', 'tmp_name' => '', 'size' => '', 'error' => 0); //上传word图片-start foreach ($match[1] as $k => $v) { $pattern2 = '/^(file:\\/\\/).*$/'; if (preg_match($pattern2, $v)) { $file['name'] = basename($v); $ex = explode(".", $file['name']); $ext = end($ex); switch ($ext) { case "png": $file['type'] = 'image/png'; break; case "jpeg": $file['type'] = 'image/jpeg'; break; case "jpg": $file['type'] = 'image/jpeg'; break; case "gif": $file['type'] = 'image/gif'; break; } $file['tmp_name'] = $v; $thumb_url = Model('image')->upload_image($file, 'article/' . date('Ym')); if ($thumb_url) { $info['content'] = str_replace(addslashes($v), addslashes($thumb_url), $info['content']); } } else { //对于已经上传的图片,自动截取文章第一个图片为缩略图 if (empty($info['thumb'])) { $info['thumb'] = $match[1][0]; } } } //上传word图片-end } if (Model('article')->create_art($info, $photo)) { $data['content'] = Lang('SUCCESS_ADD'); $data['error'] = 0; } else { $data['content'] = Lang('INVALID_OPERATION'); } $this->showMsg($data); }
public function read() { $infoid = I('get.id'); if (empty($infoid)) { $this->_empty(); } M('News')->where(array('status' => true, 'id' => $infoid))->setInc('clicknum', 1); $data = M('News')->where(array('status' => true, 'id' => $infoid))->find(); $this->assign('data', $data); //评论 $where['infoid'] = $infoid; $where['type'] = 5; $where['parent_id'] = 0; $count = M('UserMessage')->where($where)->count(); // $limitRows = 10; // 设置每页记录数 $limitRows = C('YF_PAGE'); $page = $this->ajaxpage($count, $limitRows, 'type=msg', 'ajax_div', 'ajax_page_div'); $msgModel = new Model(); $message = $msgModel->table(array(C('DB_PREFIX') . 'user_message' => 'M', C('DB_PREFIX') . 'user' => 'U'))->where('M.userid=U.userid and M.status=true and M.infoid=' . $infoid . ' and M.type=5 and M.parent_id=0')->field('M.create_time,M.content,U.nickname,U.uavatar,U.openuid,U.uprovince,U.ucity,U.userid,M.id,M.touserid')->order('M.create_time DESC')->limit($page->firstRow . ',' . $page->listRows)->select(); // foreach($message as $k=>$v){ // $message[$k]['touser']=M('User')->field('openuid,nickname')->where(array('userid'=>$v['touserid']))->find(); // } foreach ($message as $k => $v) { $child_temp = array(); $child_temp = $msgModel->table(C('DB_PREFIX') . 'user_message')->field('*')->where(array('parent_id' => $v['id']))->order('create_time ASC')->select(); $message[$k]['childlist'] = array(); if ($child_temp) { foreach ($child_temp as $yk => $yv) { if ($yv['userid'] == 0) { $child_temp[$yk]['nickname'] = "烘焙圈"; $child_temp[$yk]['openuid'] = 0; } else { $yf_user = array(); $yf_user = M('User')->field('openuid, nickname, uprovince, ucity, uavatar, ifrz')->where(array('userid' => $yv['userid']))->find(); $child_temp[$yk]['nickname'] = $yf_user['nickname']; $child_temp[$yk]['openuid'] = $yf_user['openuid']; $child_temp[$yk]['uprovince'] = $yf_user['uprovince']; $child_temp[$yk]['ucity'] = $yf_user['ucity']; $child_temp[$yk]['uavatar'] = $yf_user['uavatar']; $child_temp[$yk]['ifrz'] = $yf_user['ifrz']; } if ($yv['touserid'] != 0) { $child_temp[$yk]['touser'] = M('User')->field('openuid,nickname')->where(array('userid' => $yv['touserid']))->find(); } else { $child_temp[$yk]['touser']['nickname'] = "烘焙圈"; $child_temp[$yk]['touser']['openuid'] = 0; } } $message[$k]['childlist'] = $child_temp; } $message[$k]['tempname'] = hy_substr($v['nickname'], 4, true); //$message[$k]['tempname'] = $v['nickname']; $message[$k]['touser'] = array(); if (!empty($v['touserid'])) { $message[$k]['touser'] = M('User')->field('openuid,nickname')->where(array('userid' => $v['touserid']))->find(); } } unset($where['parent_id']); $this->msgcount = M('UserMessage')->where($where)->count(); $this->msgtype = 5; $this->assign('msglist', $message); $this->assign('page', $page->show()); if (IS_AJAX) { exit($this->fetch('msglist')); } $this->display(); }
public function submit() { $result = array('error' => 1, 'content' => ''); $info['name'] = isset($_POST['name']) ? hy_check($_POST['name'], 'ur') : ''; $info['email'] = isset($_POST['email']) ? hy_check($_POST['email'], 'e') : ''; $info['phone'] = isset($_POST['phone']) ? hy_check($_POST['phone'], 'n') : ''; $info['content'] = isset($_POST['content']) ? hy_substr($_POST['content'], '255') : ''; $info['ip'] = hy_getIP(); $info['created'] = $_SERVER['REQUEST_TIME']; $this->assign_global(); if ($_POST['name'] == '' || $_POST['email'] == '' || $_POST['phone'] == '' || $_POST['content'] == '') { $result['content'] = '请填写完整'; print_r(json_encode($result)); exit; } if ($info['name'] == '#@_error') { $result['content'] = '名字格式错误'; print_r(json_encode($result)); exit; } if ($info['email'] == '#@_error') { $result['content'] = '邮件格式错误'; print_r(json_encode($result)); exit; } if ($info['phone'] == '#@_error') { $result['content'] = '电话格式错误'; print_r(json_encode($result)); exit; } $check = Model('forms')->check_ip(array('ip' => $info['ip'], 'table' => 'forms_log_1')); if (!$check) { $result['content'] = '你提交得太频繁了'; print_r(json_encode($result)); exit; } $res = Model('forms')->insert($info, 'forms_log_1'); $mail = new PHPMailer(); $mail->IsSMTP(); // Set mailer to use SMTP $mail->Host = C('smtp'); // Specify main and backup server $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = C('smtp_username'); // SMTP username $mail->Password = C('smtp_password'); // SMTP password $mail->From = C('smtp_email'); //$mail->FromName = 'Vancca'; $mail->AddAddress('*****@*****.**', 'Josh Adams'); // Add a recipient $mail->WordWrap = 50; // Set word wrap to 50 characters $mail->Subject = '留言'; $mail->Body = '<p>名称:' . $info['name'] . '</p><p>邮箱:' . $info['email'] . '</p><p>电话:' . $info['phone'] . '</p><p>留言:' . $info['content'] . '</p>'; $mail->AltBody = '<p>名称:' . $info['name'] . '</p><p>邮箱:' . $info['email'] . '</p><p>电话:' . $info['phone'] . '</p><p>留言:' . $info['content'] . '</p>'; $mail->Send(); if ($res) { $result['error'] = 0; $result['content'] = '添加成功'; } else { $result['content'] = '系统繁忙'; } print_r(json_encode($result)); exit; }
public function update_type() { $this->admin_priv('edit_type', 2); $result = array('error' => 1, 'content' => ''); $id = intval($_POST['type_id']); $type_name = isset($_POST['type_name']) ? hy_substr($_POST['type_name'], 7) : ''; $insert_arr = array(); $update_arr = array(); //print_r($_POST); if (is_array($_POST['name'])) { $attr_name = $_POST['name']; } else { $attr_name[] = $_POST['name']; } foreach ($attr_name as $k => $v) { if ($v != '') { $en_name = isset($_POST['en_name']) ? $_POST['en_name'][$k] : ''; $en_field = isset($_POST['en_field']) ? $_POST['en_field'][$k] : ''; if ($_POST['attr_id'][$k] < 0) { $insert_arr[$k]['type_id'] = $id; $insert_arr[$k]['name'] = isset($_POST['name']) ? CH_SC . $v . DIG_EC . EN_SC . $en_name . DIG_EC : ''; $insert_arr[$k]['type'] = isset($_POST['type']) ? $_POST['type'][$k] : 1; $insert_arr[$k]['field'] = isset($_POST['field'][$k]) ? CH_SC . $_POST['field'][$k] . DIG_EC . EN_SC . $en_field . DIG_EC : ''; } else { $update_arr[$k]['id'] = $_POST['attr_id'][$k]; $update_arr[$k]['name'] = isset($_POST['name']) ? CH_SC . $v . DIG_EC . EN_SC . $en_name . DIG_EC : ''; $update_arr[$k]['type'] = isset($_POST['type']) ? $_POST['type'][$k] : 1; $update_arr[$k]['field'] = isset($_POST['field'][$k]) ? CH_SC . $_POST['field'][$k] . DIG_EC . EN_SC . $en_field . DIG_EC : ''; } } } $good = Model('goods'); if (!$type_name) { $result['content'] = '标签不能为空'; $this->showMsg($result); } $tags = $good->update(array('type_name' => $type_name), array('table' => 'goods_type', 'id' => $id)); if ($tags) { $res = true; if (!empty($insert_arr)) { $res = $good->insert($insert_arr, 'goods_spec'); } if (!empty($update_arr)) { $update_arr = array_values($update_arr); //初始化键值 $id_arr = array(); foreach ($update_arr as $k => $v) { $id_arr[] = $v['id']; unset($update_arr[$k]['id']); } $res = $good->update($update_arr, array('table' => 'goods_spec', 'id' => $id_arr)); } if ($res) { $result['error'] = 0; $result['content'] = Lang('SUCCESS_EDIT'); } else { $result['content'] = Lang('INVALID_OPERATION'); } $this->showMsg($result); } else { $result['content'] = '标签更新失败'; $this->showMsg($result); } // $res=Model('goods')->update($info,array('table'=>'goods_attr','id'=>$id)); if ($res) { $result['error'] = 0; $result['content'] = Lang('SUCCESS_EDIT'); } else { $result['content'] = Lang('INVALID_OPERATION'); } $this->showMsg($result); }
/** * yf 0921 * 评论信息 */ public function message() { $model = M('UserMessage'); $list1 = array(); $list2 = array(); $list3 = array(); //$count1 = $model->where("ifread=0 and (touserid=".$this->userid." or (type=2 and infoid=".$this->userid."))")->count(); $field1 = array('infoid', 'content', 'create_time', 'status', 'id', 'ifread', 'type', 'userid', 'touserid'); $list1 = $model->field($field1)->where("ifread=0 and (touserid=" . $this->userid . " or (type=2 and infoid=" . $this->userid . "))")->select(); //$count2 = $model->alias('A')->join(C('DB_PREFIX').'works B on A.infoid=B.workid', 'LEFT')->where("A.ifread=0 and A.type=1 and (A.touserid is NULL OR A.touserid<>".$this->userid.") and B.userid=".$this->userid)->count(); $field2 = array('A.infoid', 'A.content', 'A.create_time', 'A.status', 'A.id', 'A.ifread', 'A.type', 'A.userid', 'A.touserid'); $list2 = $model->alias('A')->join(C('DB_PREFIX') . 'works B on A.infoid=B.workid', 'LEFT')->field($field2)->where("A.ifread=0 and A.type=1 and (A.touserid is NULL OR A.touserid<>" . $this->userid . ") and B.userid=" . $this->userid)->select(); //$count3 = $model->alias('A')->join(C('DB_PREFIX').'suipai B on A.infoid=B.id', 'LEFT')->where("A.ifread=0 and A.type=4 and (A.touserid is NULL OR A.touserid<>".$this->userid.") and B.userid=".$this->userid)->count(); $field3 = array('D.infoid', 'D.content', 'D.create_time', 'D.status', 'D.id', 'D.ifread', 'D.type', 'D.userid', 'D.touserid'); $list3 = $model->alias('D')->join(C('DB_PREFIX') . 'suipai B on D.infoid=B.id', 'LEFT')->field($field3)->where("D.ifread=0 and D.type=4 and (D.touserid is NULL OR D.touserid<>" . $this->userid . ") and B.userid=" . $this->userid)->select(); $ypage = empty($_GET['page']) ? 1 : intval($_GET['page']); $all_count = $this->get_msg_num(); $count = $all_count['message']; $page = $this->Pages($count, 10); $pageurl = '?page=' . urlencode('[PAGE]'); $page->url = __APP__ . '/user/index/message' . $pageurl; $arr = array(); if ($list1) { $arr = array_merge_recursive($list1); } if ($list2) { if ($arr) { $arr = array_merge_recursive($arr, $list2); } else { $arr = array_merge_recursive($list2); } } if ($list3) { if ($arr) { $arr = array_merge_recursive($arr, $list3); } else { $arr = array_merge_recursive($list3); } } // $arr = array_merge_recursive($list1, $list2, $list3); usort($arr, function ($a, $b) { $al = $a['id']; $bl = $b['id']; if ($al == $bl) { return 0; } return $al > $bl ? -1 : 1; }); $list = array(); if ($arr) { $start = ($ypage - 1) * $page->listRows; for ($i = $start; $i < $start + $page->listRows; $i++) { if (!empty($arr[$i])) { $list[] = $arr[$i]; } } foreach ($list as $k => $v) { if ($v['type'] == 1) { $list[$k]['msg'] = "在你的烘焙作品"; if (!empty($v['touserid'])) { $list[$k]['msg'] = "回复了你在烘焙作品"; } } if ($v['type'] == 2) { $list[$k]['msg'] = "在"; $list[$k]['openuid'] = M('User')->where(array('userid' => $v['infoid']))->getField('openuid'); if (!empty($v['touserid'])) { $list[$k]['msg'] = "回复了你在"; } } if ($v['type'] == 3) { $list[$k]['msg'] = "在你的试用报告"; if (!empty($v['touserid'])) { $list[$k]['msg'] = "回复了你在试用报告"; } } if ($v['type'] == 4) { $list[$k]['msg'] = "在你的随拍作品"; if (!empty($v['touserid'])) { $list[$k]['msg'] = "回复了你在随拍作品"; } } if ($v['type'] == 5) { $list[$k]['msg'] = "在你的新闻评论"; if (!empty($v['touserid'])) { $list[$k]['msg'] = "回复了你在新闻评论"; } } if ($v['type'] == 6) { $list[$k]['msg'] = "在你的活动评论"; if (!empty($v['touserid'])) { $list[$k]['msg'] = "回复了你在活动评论"; } } $list[$k]['content'] = hy_substr($v['content'], 25, true); if ($v['userid'] == 0) { $user['nickname'] = "烘焙圈"; } else { $user = M('User')->where(array('userid' => $v['userid']))->field("nickname, uavatar, openuid")->find(); } $list[$k]['user'] = $user; } } $this->assign("all_count", $all_count); $this->assign("list", $list); $this->assign('url', 'message'); $this->assign("act", "message"); $this->assign("Page", $page->show()); $this->display(); }