public function _before_edit() { $cate = new CategoryModel(); $menu = $cate->getModelCategory('Article'); //加载栏目 $menu1 = arrToMenu($menu, 0); $this->categorylist = $menu1; }
function arrToMenu($data, $pid) { static $menu = array(); foreach ($data as $k => $v) { if ($v['pid'] == $pid) { $menu[] = $v; $v['pid'] = arrToMenu($data, $v['id']); } } return $menu; }
public function _before_edit() { $cate = new CategoryModel(); // $this->list=$cate->getMyCategory();//加载栏目 $menu = $cate->getMyCategory1(); //加载栏目 $menu = arrToMenu($menu, 0); $this->list = $menu; $this->mdldata = $cate->getMyModel(); //加载模型 }
public function add() { if (IS_POST) { //鱼福标识码 $yufumark = I('post.yufumark'); //是否游客提交 if (!C('ISADDACCOUNT')) { if (C('ISAUTOVERIFY') == "1") { if (trim(C('YUFUMARK')) != trim($yufumark)) { $this->error('操作错误'); } } else { $this->error('操作错误'); } } $ip = get_client_ip(); $time = time(); $map['ip'] = array('eq', $ip); //提交间隔 $model = D('Weixin'); $comment = $model->where($map)->order('id desc')->find(); if ($time - $comment['create_time'] < 10) { $this->error('每次提交需间隔10秒钟!'); } $_POST['pubaccount'] = I('post.pubaccount'); $_POST['wxaccount'] = I('post.wxaccount'); $_POST['ghweixin'] = I('post.ghweixin'); $_POST['website'] = I('post.website'); $_POST['sinaweibo'] = I('post.sinaweibo'); $_POST['tencentweibo'] = I('post.tencentweibo'); $_POST['title'] = I('post.title'); $_POST['keywords'] = I('post.keywords'); $_POST['description'] = I('post.description'); $_POST['weblogo'] = I('post.weblogo'); $_POST['webqrcode'] = I('post.webqrcode'); $_POST['tbshopurl'] = I('post.tbshopurl'); $_POST['ppshopurl'] = I('post.ppshopurl'); $_POST['content'] = I('post.content'); $_POST['realname'] = I('post.realname'); $_POST['phone'] = I('post.phone'); $_POST['qq'] = I('post.qq', '', 'int'); //如果标题为空,默认填写公众帐号 if (empty($_POST['title'])) { $_POST['title'] = I('post.pubaccount'); } //敏感词过滤 $Badword = D('Badword'); $Badwordlist = $Badword->select(); foreach ($Badwordlist as $key => $value) { if ($value['level'] == 1) { $_POST['pubaccount'] = preg_replace('/' . $value['badword'] . '/i', $value['replaceword'], $_POST['pubaccount']); $_POST['wxaccount'] = preg_replace('/' . $value['badword'] . '/i', $value['replaceword'], $_POST['wxaccount']); $_POST['ghweixin'] = preg_replace('/' . $value['badword'] . '/i', $value['replaceword'], $_POST['ghweixin']); $_POST['website'] = preg_replace('/' . $value['badword'] . '/i', $value['replaceword'], $_POST['website']); $_POST['sinaweibo'] = preg_replace('/' . $value['badword'] . '/i', $value['replaceword'], $_POST['sinaweibo']); $_POST['tencentweibo'] = preg_replace('/' . $value['badword'] . '/i', $value['replaceword'], $_POST['tencentweibo']); $_POST['title'] = preg_replace('/' . $value['badword'] . '/i', $value['replaceword'], $_POST['title']); $_POST['keywords'] = preg_replace('/' . $value['badword'] . '/i', $value['replaceword'], $_POST['keywords']); $_POST['description'] = preg_replace('/' . $value['badword'] . '/i', $value['replaceword'], $_POST['description']); $_POST['weblogo'] = preg_replace('/' . $value['badword'] . '/i', $value['weblogo'], $_POST['weblogo']); $_POST['webqrcode'] = preg_replace('/' . $value['badword'] . '/i', $value['webqrcode'], $_POST['webqrcode']); $_POST['tbshopurl'] = preg_replace('/' . $value['badword'] . '/i', $value['tbshopurl'], $_POST['tbshopurl']); $_POST['ppshopurl'] = preg_replace('/' . $value['badword'] . '/i', $value['ppshopurl'], $_POST['ppshopurl']); $_POST['content'] = preg_replace('/' . $value['badword'] . '/i', $value['replaceword'], $_POST['content']); $_POST['realname'] = preg_replace('/' . $value['badword'] . '/i', $value['replaceword'], $_POST['realname']); $_POST['phone'] = preg_replace('/' . $value['badword'] . '/i', $value['replaceword'], $_POST['phone']); $_POST['qq'] = preg_replace('/' . $value['badword'] . '/i', $value['replaceword'], $_POST['qq']); } else { $_POST['pubaccount'] = preg_replace('/' . $value['badword'] . '/i', '', $_POST['pubaccount']); $_POST['wxaccount'] = preg_replace('/' . $value['badword'] . '/i', '', $_POST['wxaccount']); $_POST['website'] = preg_replace('/' . $value['badword'] . '/i', '', $_POST['website']); $_POST['sinaweibo'] = preg_replace('/' . $value['badword'] . '/i', '', $_POST['sinaweibo']); $_POST['tencentweibo'] = preg_replace('/' . $value['badword'] . '/i', '', $_POST['tencentweibo']); $_POST['title'] = preg_replace('/' . $value['badword'] . '/i', '', $_POST['title']); $_POST['keywords'] = preg_replace('/' . $value['badword'] . '/i', '', $_POST['keywords']); $_POST['description'] = preg_replace('/' . $value['badword'] . '/i', '', $_POST['description']); $_POST['weblogo'] = preg_replace('/' . $value['badword'] . '/i', '', $_POST['weblogo']); $_POST['webqrcode'] = preg_replace('/' . $value['badword'] . '/i', '', $_POST['webqrcode']); $_POST['tbshopurl'] = preg_replace('/' . $value['badword'] . '/i', '', $_POST['tbshopurl']); $_POST['ppshopurl'] = preg_replace('/' . $value['badword'] . '/i', '', $_POST['ppshopurl']); $_POST['content'] = preg_replace('/' . $value['badword'] . '/i', '', $_POST['content']); $_POST['realname'] = preg_replace('/' . $value['badword'] . '/i', '', $_POST['realname']); $_POST['phone'] = preg_replace('/' . $value['badword'] . '/i', '', $_POST['phone']); $_POST['qq'] = preg_replace('/' . $value['badword'] . '/i', '', $_POST['qq']); } } //上传附件 $this->_upload(); if (false === $model->create()) { $this->error($model->getError()); } if (C('ISAUTOVERIFY') == "1") { if (trim(C('YUFUMARK')) == trim($yufumark)) { $model->status = 1; } else { $model->status = 2; } } else { $model->status = 2; } $model->typeid = 1; $model->iscomment = 1; //保存当前数据对象 $list = $model->add(); if ($list !== false) { //保存成功 $this->success('提交成功!'); } else { //失败提示 $this->error('提交失败!'); } } else { if (!C('ISADDACCOUNT')) { $this->error('操作错误', '__APP__'); } $id = I('get.id', '', 'int'); if (empty($id)) { $this->error('操作错误'); } $catdata = D('Category')->where('status=1')->find($id); $cate = new WeixinModel(); $menu = $cate->getModelCategory('Weixin'); //加载栏目 $this->categorylist = arrToMenu($menu, 0); //获取省级地区 $province = D('areas')->where(array('parent_id' => 1))->select(); $this->assign('province', $province); //seo $position = D('Common')->getPosition($id); foreach ($position as $value) { $title = $value['catname'] . "_" . $title; } $title = substr($title, 0, strlen($title) - 1); $this->seo($catdata['title'] ? $catdata['title'] : $title, $catdata['keywords'] ? $catdata['keywords'] : C(SITE_KEYWORDS), $catdata['description'] ? $catdata['description'] : C(SITE_DESCRIPTION), $position); $this->assign("data", $catdata); $this->display(); } }