public function index()
 {
     if (IS_POST) {
         $this->redirect('index', $_POST);
     }
     //查询条件
     $where = array();
     //搜索
     $search = I('get.search');
     if (!empty($search)) {
         $this->assign("search", $search);
         //添加开始时间
         $start_time = I('get.start_time');
         if (!empty($start_time)) {
             $start_time = strtotime($start_time);
             $where['create_time'] = array("EGT", $start_time);
             $this->assign('start_time', $start_time);
         }
         //添加结束时间
         $end_time = I('get.end_time');
         if (!empty($end_time)) {
             $end_time = strtotime($end_time);
             $where['create_time'] = array("ELT", $end_time);
             $this->assign('end_time', $end_time);
         }
         if ($end_time > 0 && $start_time > 0) {
             $where['create_time'] = array(array('EGT', $start_time), array('ELT', $end_time));
         }
         //搜索字段
         $searchtype = I('get.searchtype', null, 'intval');
         //搜索关键字
         $keyword = \Input::getVar(I('get.keyword'));
         if (!empty($keyword)) {
             $this->assign("searchtype", $searchtype);
             $this->assign("keyword", $keyword);
             if ($searchtype == 1) {
                 $where['mname'] = array("LIKE", "%{$keyword}%");
             } elseif ($searchtype == 2) {
                 $where['mtel'] = array("LIKE", "%{$keyword}%");
             } elseif ($searchtype == 3) {
                 $where['mprovince'] = array("LIKE", "%{$keyword}%");
             }
         }
         //状态
         $status = I('get.status', 0, 'intval');
         if ($status == 1) {
             $where['status'] = array("EQ", true);
         } elseif ($status == 2) {
             $where['status'] = array('EQ', false);
         }
         $this->assign('status', $status);
     }
     $model = M('TryMember');
     //信息总数
     $count = $model->where($where)->count();
     $page = $this->page($count, 30);
     $data = $model->where($where)->limit($page->firstRow . ',' . $page->listRows)->order(array("id" => "DESC"))->select();
     $this->assign('Page', $page->show())->assign('count', $count)->assign('data', $data);
     $this->display();
 }
 public function index()
 {
     if (IS_POST) {
         $this->redirect('index', $_POST);
     }
     //搜索
     $search = I('get.search');
     if (!empty($search)) {
         $this->assign("search", $search);
         //添加开始时间
         $start_time = I('get.start_time');
         if (!empty($start_time)) {
             $this->assign('start_times', $start_time);
             $start_time = strtotime($start_time);
             $where['create_time'] = array("EGT", $start_time);
             $this->assign('start_time', $start_time);
         }
         //添加结束时间
         $end_time = I('get.end_time');
         if (!empty($end_time)) {
             $this->assign('end_times', $end_time);
             $end_time = strtotime($end_time);
             $where['create_time'] = array("ELT", $end_time);
             $this->assign('end_time', $end_time);
         }
         //时间搜索条件
         if ($end_time > 0 && $start_time > 0) {
             $where['create_time'] = array(array('EGT', $start_time), array('ELT', $end_time));
         }
         //是否审核
         $status = I('get.status', 2, 'intval');
         if ($status != 2) {
             $where["status"] = array("EQ", $status);
         }
         $this->assign("status", $status);
         //全部栏目
         $menu = I('get.menu');
         if (!empty($menu)) {
             $where["menu"] = array("EQ", $menu);
             $this->assign("menu", $menu);
         }
         //搜索关键字
         $keyword = \Input::getVar(I('get.keyword'));
         if (!empty($keyword)) {
             $this->assign("keyword", $keyword);
             $where['title'] = array("LIKE", "%{$keyword}%");
         }
     } else {
         $this->assign("status", 2);
     }
     $count = M('Advert')->where($where)->count();
     $page = $this->page($count, 20);
     $list = M('Advert')->where($where)->limit($page->firstRow . ',' . $page->listRows)->order(array('id' => 'DESC'))->select();
     $this->assign("list", $list);
     $this->assign("Page", $page->show());
     session('backurl', get_url());
     //页面跳转SESSION
     $this->display();
 }
 /**
  * 获取模型字段信息
  * @param type $data
  * @return type 
  */
 function get($data = array())
 {
     //信息ID
     if (isset($data['id'])) {
         $this->id = $data['id'];
     }
     $this->data = $data;
     $info = array();
     foreach ($this->fields as $field => $v) {
         //判断是否后台
         if (defined('IN_ADMIN') && IN_ADMIN) {
             //判断是否内部字段,如果是,跳过
             if ($v['iscore']) {
                 continue;
             }
         } else {
             //判断是否内部字段或者,是否禁止前台投稿字段
             if ($v['iscore']) {
                 continue;
             }
             if (!$v['isadd']) {
                 continue;
             }
         }
         $func = $v['formtype'];
         $value = isset($data[$field]) ? Input::getVar($data[$field]) : '';
         if ($func == 'pages' && isset($data['maxcharperpage'])) {
             $value = $data['paginationtype'] . '|' . $data['maxcharperpage'];
         }
         //判断对应方法是否存在,不存在跳出本次循环
         if (!method_exists($this, $func)) {
             continue;
         }
         //传入参数 字段名 字段值 字段信息
         $form = $this->{$func}($field, $value, $v);
         if ($form !== false) {
             //作为基本信息
             if ($v['isbase']) {
                 $star = $v['minlength'] || $v['pattern'] ? 1 : 0;
                 $info['base'][$field] = array('name' => $v['name'], 'tips' => $v['tips'], 'form' => $form, 'star' => $star, 'isomnipotent' => $v['isomnipotent'], 'formtype' => $v['formtype']);
             } else {
                 $star = $v['minlength'] || $v['pattern'] ? 1 : 0;
                 $info['senior'][$field] = array('name' => $v['name'], 'tips' => $v['tips'], 'form' => $form, 'star' => $star, 'isomnipotent' => $v['isomnipotent'], 'formtype' => $v['formtype']);
             }
         }
     }
     //配合 validate 插件,生成对应的js验证规则
     $this->formValidateRules = $this->ValidateRulesJson($this->formValidateRules);
     $this->formValidateMessages = $this->ValidateRulesJson($this->formValidateMessages, true);
     return $info;
 }
 public function index()
 {
     $get = I('get.');
     $type = I('get.t');
     $keyword = \Input::getVar(I('get.keyword'));
     if (empty($type)) {
         $this->_empty();
     }
     if (empty($keyword)) {
         $this->error('亲爱的,你似乎没有输入需要搜索的关键词...');
     }
     $url = '&keyword=' . $keyword . '&t=' . $type;
     if ($type == 1) {
         //中间广告位
         $this->assign('midad', parent::getAdvert(2, 1, 0, 1));
         $worksModel = M('Works');
         $where['status'] = array('EQ', true);
         $where['title'] = array("LIKE", "%{$keyword}%");
         $count = $worksModel->where($where)->count();
         $page = $this->Pages($count, 30);
         $pageurl = '?page=' . urlencode('[PAGE]');
         $page->url = __APP__ . '/search/' . $pageurl . $url;
         $Model = new Model();
         $list = $Model->table(array(C('DB_PREFIX') . 'works' => 'W', C('DB_PREFIX') . 'user' => 'U'))->where("W.userid=U.userid and W.status=true and W.title like '%" . $keyword . "%'")->field('W.title,W.type,W.content,W.goodnum,W.msgnum,W.workid,W.create_time,W.image,U.nickname,U.uavatar,U.openuid,U.uprovince,U.ucity,U.userid,U.ifrz')->order('msgnum DESC')->limit($page->firstRow . ',' . $page->listRows)->select();
         foreach ($list as $key => $value) {
             $list[$key]['dignum'] = M('Dig')->where(array('status' => true, 'infoid' => $value['workid'], 'userid' => $this->userid))->count();
         }
         $this->assign('keywords', $keyword);
         $this->assign("list", $list);
         $this->assign("Page", $page->show());
         $this->display('works');
     } else {
         $userModel = M('User');
         $where['status'] = array('EQ', true);
         $where['nickname'] = array("LIKE", "%{$keyword}%");
         $count = $userModel->where($where)->count();
         $page = $this->Pages($count, 40);
         $pageurl = '?page=' . urlencode('[PAGE]');
         $page->url = __APP__ . '/search/' . $pageurl . $url;
         $list = $userModel->where($where)->field('userid,uavatar,openuid,nickname,worksnum,spnum,fansnum')->order('worksnum DESC')->limit($page->firstRow . ',' . $page->listRows)->select();
         foreach ($list as $key => $value) {
             $list[$key]['worknums'] = $value['worksnum'] + $value['spnum'];
             if (M('UserFans')->where(array('userid' => $value['userid'], 'myid' => $this->userid, 'status' => true))->count() > 0) {
                 $list[$key]['isfans'] = true;
             }
         }
         $this->assign("list", $list);
         $this->assign("Page", $page->show());
         $this->display('user');
     }
 }
 /**
  *检查城市选项
  *@date 2010-6-23
  *@time 上午10:17:39
  */
 protected function chk_cid()
 {
     //检查城市选项
     $cid = Input::getVar($_GET['cid']);
     if ($cid) {
         if ($_SESSION['cid']) {
             $this->pcid = $cid;
         } else {
             $_SESSION['cid'] = $cid;
             $this->pcid = $cid;
             cookie('cid', null);
             if ($_REQUEST['remember']) {
                 cookie('cid', $cid, array('expire' => 60 * 60 * 60 * 24 * 30));
             }
         }
     } else {
         //$this->_set_cid();
         $this->pcid = empty($this->cid) ? 0 : $this->cid;
     }
 }
 /**
  *发送短消息
  *@date 2010-9-29
  *@time 下午05:41:19
  */
 function pm()
 {
     //发送短消息
     if (!$this->_is_login()) {
         $this->error("Login please.", $_REQUEST['is_ajax']);
     }
     if (Input::getVar($_REQUEST['fromusername']) && empty($_REQUEST['fromuid'])) {
         $member = D("Members");
         $condition = array('username' => Input::getVar($_REQUEST['fromusername']));
         $info = $member->where($condition)->find();
         if ($info['id']) {
             $fromuid = $info['id'];
         } else {
             $this->error("Wrong user name!", $_REQUEST['is_ajax']);
         }
     } else {
         $fromuid = Input::getVar($_REQUEST['fromuid']);
     }
     $content = Input::getVar($_REQUEST['content']);
     $title = Input::getVar($_REQUEST['title']);
     if (!empty($fromuid)) {
         if (empty($content)) {
             $this->error('You must fill in the field of "Content".', $_REQUEST['is_ajax']);
         }
         if (empty($title)) {
             $this->error('You must fill in the field of "Title".', $_REQUEST['is_ajax']);
         }
         $data = array();
         $data['fromuid'] = $fromuid;
         $data['content'] = nl2br(remove_xss($content));
         $data['title'] = $title;
         $data['itype'] = Input::getVar($_REQUEST['itype']);
         $data['xid'] = Input::getVar($_REQUEST['xid']);
         $dao = D("Pm");
         $vo = $dao->create($data);
         if ($vo) {
             $id = $dao->add($vo);
             if ($id) {
                 $this->success('sucess.', $_REQUEST['is_ajax']);
             } else {
                 $this->error('failure.', $_REQUEST['is_ajax']);
             }
         } else {
             $this->error($dao->getError(), $_REQUEST['is_ajax']);
         }
     } else {
         $this->error("Wrong parameter!");
     }
 }
 /**
  *修改用户资料
  *@date 2010-7-20
  *@time 上午11:23:52
  */
 function edit()
 {
     //修改用户资料
     $dao = D("Members");
     if ($_POST['act'] == 'edit') {
         $data = array();
         $data = $dao->create();
         if (empty($_FILES['avatar']['name'])) {
             $data['avatar'] = $_POST['old_avatar'];
         } else {
             $finfo = $this->_avatar();
             $data['avatar'] = '/Public/avatar/s_' . $finfo[0]['savename'];
         }
         $data['bday'] = Input::getVar($_POST['bdayyear']) . '-' . Input::getVar($_POST['birthmonth']) . '-' . Input::getVar($_POST['birthday']);
         $address = Input::getVar($_POST['address']);
         $data['address'] = empty($address) ? Input::getVar($_POST['address2']) : $address;
         $data['id'] = $this->user['uid'];
         $re = $dao->save($data);
         if ($re) {
             $info = $dao->where(array('id' => $this->user['uid']))->find();
             $info['avatar'] = avatar($info['avatar']);
             unset($_SESSION["info"]);
             $_SESSION["info"] = $info;
             redirect("/Cp/edit");
         } else {
             //$this->redirect("/Cp/edit",array(),5,'','Failed to update the Profile.');
             $this->assign('jumpUrl', __APP__ . "/Cp/edit");
             $this->error('Failed to update the Profile.');
         }
     } else {
         $info = $dao->where(array('id' => $this->user['uid']))->find();
         $bday = explode('-', $info['bday']);
         $info['bdayyear'] = $bday['0'];
         $info['birthmonth'] = $bday['1'];
         $info['birthday'] = $bday['2'];
         $this->assign('info', $info);
     }
     $page = array();
     $page['title'] = 'Edit Profile -  My Control Panel -  BeingfunChina';
     $page['keywords'] = 'Edit Profile';
     $page['description'] = 'Edit Profile';
     $this->assign('page', $page);
     $this->assign('content', 'Cp:edit');
     $this->display("Cp:layout");
 }
 /**
  *展会信息
  *@date 2010-6-2
  *@time 上午10:38:22
  */
 function show()
 {
     //展会信息
     $aid = intval($_REQUEST['aid']);
     $this->assign('industries', $this->_get_fair());
     $this->assign("city", $this->_get_city('fair'));
     $this->assign('date', $this->_get_time());
     $year = array();
     $nowyear = date('Y');
     $year['sy']['name'] = $nowyear;
     $year['sy']['ms'] = mktime(0, 0, 0, 1, 1, $nowyear);
     $year['sy']['me'] = mktime(0, 0, 0, 1, 1, $nowyear + 1) - 1;
     $year['ny']['name'] = $nowyear + 1;
     $year['ny']['ms'] = mktime(0, 0, 0, 1, 1, $nowyear + 1);
     $year['ny']['me'] = mktime(0, 0, 0, 1, 1, $nowyear + 2) - 1;
     $this->assign('year', $year);
     $flang = Input::getVar($_REQUEST['flang']);
     $dao = D("Archives");
     $condition = array();
     if ($flang) {
         $lan = explode('_', $flang);
         if ($lan['1'] == 'CN') {
             $flang = $lan['0'] . '_CN';
         } else {
             $flang = $lan['0'] . '_EN';
         }
         $condition['writer'] = $flang;
         $condition['channel'] = 11;
         $_SESSION['flang'] = $lan['1'];
     } else {
         $condition['id'] = $aid;
     }
     $info = $dao->where($condition)->find();
     if ($info['ismake'] == '0') {
         $this->error("error: the information has been deleted!");
     }
     if (empty($info)) {
         $this->error("sorry,the information is not available now.<br/>\n您查看的信息暂时空缺。");
     }
     $lan = explode('_', $info['writer']);
     $lang['cn'] = $lan['0'] . '_CN';
     $lang['en'] = $lan['0'] . '_EN';
     $this->assign('lang', $lang);
     $info['_fair'] = $dao->relationGet("fair");
     $album = $this->get_album($info['id'], $info['channel']);
     if ($info['picurl']) {
         $info['picurl'] = str_replace('../Public/Uploads', '/Public/Uploads', $info['picurl']);
     } else {
         $info['picurl'] = out_images($album['0'], 's');
     }
     $info['albumnum'] = count($album);
     $this->assign("album", $album);
     $this->assign('info', $info);
     $page = array();
     $page['title'] = $info['title'] . ' - BeingfunChina 缤纷中国';
     $page['keywords'] = $info['keywords'] . ',fair,china,biz';
     $page['description'] = $info['description'];
     $this->assign('page', $page);
     $this->assign('dh', $this->_get_dh($info['typeid']));
     $this->display();
 }
 public function checktel()
 {
     //搜索关键字
     $keyword = \Input::getVar(I('get.shtxt'));
     if (empty($keyword)) {
         exit(json_encode(array('status' => false)));
     }
     $where['mtel'] = array("LIKE", "%{$keyword}%");
     $list = M('TryMember')->field('mname,mtel,id')->where($where)->select();
     if ($list) {
         exit(json_encode(array('status' => true, 'datas' => $list)));
     } else {
         exit(json_encode(array('status' => false)));
     }
 }
Exemple #10
0
 public function trylist($where)
 {
     $worksModel = M('TryItems');
     $gets = I('get.');
     $where['status'] = array('EQ', true);
     $cat = $gets['cat'];
     $order = $gets['order'];
     $postfee = $gets['postfee'];
     $sort = $gets['sort'];
     $keywords = \Input::getVar($gets['keyword']);
     if (!empty($keywords)) {
         $where['title'] = array('LIKE', "%{$keywords}%");
         $this->keyword = $keywords;
         $keywordurl = "&keyword=" . $keywords;
     }
     if (!empty($cat)) {
         $caturl = "cat=" . $cat;
         $where['cateid'] = $cat;
         $this->cat = $cat;
         $linkarrow = "&";
         $this->catename = getTryCateName($cat);
     } else {
         $this->catename = '全部商品';
         $this->cat = 0;
     }
     if (!empty($postfee)) {
         $postfeeurl = "&postfee=" . $postfee;
         $where['postfee'] = $postfee;
         $this->postfee = $postfee;
     } else {
         $postfeeurl = "&postfee=0";
         $this->postfee = 0;
     }
     if (empty($order)) {
         $orders = 'tryid';
         $orderurl = "&order=1";
     } else {
         $orders = $this->getorder($order);
         $orderurl = "&order=" . $order;
     }
     $this->order = !empty($order) ? $order : '0';
     if (empty($sort)) {
         $sort = 'desc';
     }
     if ($order == 1 && $sort == 'desc') {
         $this->cls1 = 'b-fenlei_up_on';
         $sort = 'asc';
     } elseif ($order == 1 && $sort == 'asc') {
         $this->cls1 = 'b-fenlei_down_on';
         $sort = 'desc';
     } else {
         $this->cls1 = 'b-fenlei_down';
     }
     if ($order == 2 && $sort == 'desc') {
         $this->cls2 = 'b-fenlei_up_on';
         $sort = 'asc';
     } elseif ($order == 2 && $sort == 'asc') {
         $this->cls2 = 'b-fenlei_down_on';
         $sort = 'desc';
     } else {
         $this->cls2 = 'b-fenlei_down';
     }
     if ($order == 3 && $sort == 'desc') {
         $this->cls3 = 'b-fenlei_up_on';
         $sort = 'asc';
     } elseif ($order == 3 && $sort == 'asc') {
         $this->cls3 = 'b-fenlei_down_on';
         $sort = 'desc';
     } else {
         $this->cls3 = 'b-fenlei_down';
     }
     if ($order == 4 && $sort == 'desc') {
         $this->cls4 = 'b-fenlei_up_on';
         $sort = 'asc';
     } elseif ($order == 4 && $sort == 'asc') {
         $this->cls4 = 'b-fenlei_down_on';
         $sort = 'desc';
     } else {
         $this->cls4 = 'b-fenlei_down';
     }
     if ($order == 5 && $sort == 'desc') {
         $this->cls5 = 'b-fenlei_up_on';
         $sort = 'asc';
     } elseif ($order == 5 && $sort == 'asc') {
         $this->cls5 = 'b-fenlei_down_on';
         $sort = 'desc';
     } else {
         $this->cls5 = 'b-fenlei_down';
     }
     $sorturl = "&sort=" . $sort;
     $this->sort = $sort;
     $count = $worksModel->where($where)->count();
     $page = $this->Pages($count, 18);
     $pageurl = '?page=' . urlencode('[PAGE]');
     $page->url = __APP__ . '/try/' . ACTION_NAME . $pageurl . $linkarrow . $caturl . $postfeeurl . $orderurl . $sorturl . $keywordurl;
     $list = $worksModel->where($where)->field('title,tryid,image,requestnum,trynum,price,end_time')->order('' . $orders . ' ' . $sort . '')->limit($page->firstRow . ',' . $page->listRows)->select();
     $this->assign("list", $list);
     $this->assign("Page", $page->show());
     $this->assign("arrowpage", $page->arrowshow());
     $this->assign('caturl', $caturl);
     $this->assign('postfeeurl', $postfeeurl);
     $this->assign('orderurl', $orderurl);
     $this->assign('sorturl', $sorturl);
     $this->assign('keywordurl', $keywordurl);
 }
 /**
  * 显示对应栏目信息列表 
  */
 public function classlist()
 {
     $catid = $this->_get("catid");
     $Categorys = $this->categorys[$catid];
     $this->assign("Categorys", $Categorys);
     //是否搜索
     $search = $this->_get("search");
     $where = array();
     $where["catid"] = array("EQ", $catid);
     $Model = F("Model");
     if (!empty($Categorys)) {
         //取得主表名
         $tablename = $Model[$Categorys['modelid']]['tablename'];
         if (empty($tablename)) {
             $this->error("模型不存在!");
         }
         //检查模型是否被禁用
         if ($Model[$Categorys['modelid']]['disabled'] == 1) {
             $this->error("模型被禁用!");
         }
         $this->Content = new ContentModel(ucwords($tablename));
         //检查表是否存在
         if (!$this->Content->table_exists($tablename)) {
             $this->error("数据表不存在!");
         }
         //搜索相关开始
         if (!empty($search)) {
             //添加开始时间
             $start_time = $this->_get("start_time");
             if (!empty($start_time)) {
                 $start_time = strtotime($start_time);
                 $where["inputtime"] = array("EGT", $start_time);
             }
             //添加结束时间
             $end_time = $this->_get("end_time");
             if (!empty($end_time)) {
                 $end_time = strtotime($end_time);
                 $where["inputtime"] = array("ELT", $end_time);
             }
             if ($end_time > 0 && $start_time > 0) {
                 $where['inputtime'] = array(array('EGT', $start_time), array('ELT', $end_time));
             }
             //推荐
             $posids = $this->_get("posids");
             if (!empty($posids)) {
                 $where["posids"] = array("EQ", $posids);
             }
             //搜索字段
             $searchtype = (int) $this->_get("searchtype");
             //搜索关键字
             $keyword = Input::getVar($this->_get("keyword"));
             if (!empty($keyword)) {
                 $type_array = array('title', 'description', 'username');
                 if ($searchtype < 3) {
                     $searchtype = $type_array[$searchtype];
                     $where[$searchtype] = array("LIKE", "%" . $keyword . "%");
                 } elseif ($searchtype == 3) {
                     $where["id"] = array("EQ", (int) $keyword);
                 }
             }
             //状态
             $status = (int) $this->_get('status');
             if ($status > 0) {
                 $where['status'] = array("EQ", $status);
             }
         }
         //信息总数
         $count = $this->Content->where($where)->count();
         $page = $this->page($count, 20);
         $Content = $this->Content->where($where)->limit($page->firstRow . ',' . $page->listRows)->order(array("id" => "DESC"))->select();
     } else {
         $this->error("该栏目不存在!");
     }
     $this->assign("search", $search);
     $this->assign("start_time", $start_time);
     $this->assign("end_time", $end_time);
     $this->assign("posids", $posids);
     $this->assign("searchtype", $searchtype);
     $this->assign("keyword", $keyword);
     $this->assign($Categorys);
     $this->assign("count", $count);
     $this->assign("catid", $catid);
     $this->assign("Content", $Content);
     $this->assign("Page", $page->show('Admin'));
     $this->display();
 }
 /**
 +----------------------------------------------------------
 * 处理城市指南用户发的文章
 * @date 2011-2-28 - @time 下午02:47:19
 +----------------------------------------------------------
 * @static
 * @access public
 +----------------------------------------------------------
 * @param string 
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 function ctg_article_do()
 {
     //处理城市指南用户发的文章
     //增加新闻
     $dao = D("Archives");
     $_POST['my_content'] = Input::getVar($_POST['my_content']);
     $vo = $dao->create();
     if ($vo) {
         if (empty($_POST['my_content'])) {
             $this->error("You must fill in the field of 'Summary'");
         }
         $vo['description'] = String::msubstr($vo['my_content'], 0, 200);
         $vo['my_content'] = nl2br($vo['my_content']);
         $vo['my_content'] = trim($vo['my_content'], '<br>');
         if ($vo['showstart']) {
             $t = explode('/', $vo['showstart']);
             $vo['showstart'] = mktime('0', 0, 0, $t['1'], $t['0'], $t['2']);
         } else {
             $vo['showstart'] = time();
         }
         if ($vo['showend']) {
             $t = explode('/', $vo['showend']);
             $vo['showend'] = mktime('0', 0, 0, $t['1'], $t['0'], $t['2']);
         } else {
             $vo['showend'] = $vo['showstart'] + 60 * 60 * 60 * 24;
         }
         $vo['typeid'] = "2002";
         $vo['channel'] = "12";
         $kw = str_word_count($vo['description'], 1);
         $keywords = "";
         foreach ($kw as $vkw) {
             $keywords .= $vkw . ',';
         }
         $vo['keywords'] = empty($_POST['keywords']) ? trim($keywords, ',') : $_POST['keywords'];
         $eid = '';
         $xid = Input::getVar($_REQUEST['id']);
         if ($xid) {
             $aid = $xid;
             $eid = $xid;
             $dao->where("id={$aid}")->save($vo);
         } else {
             $aid = $dao->add($vo);
         }
         $actlog = $dao->getLastSql();
         if ($aid) {
             $data = array();
             $_POST['content'] = Input::getVar($_POST['content']);
             if (empty($_POST['content'])) {
                 $this->error("You must fill in the field of 'Content'");
             }
             //$data['content']=nl2br($_REQUEST['content']);
             $data['content'] = $_POST['content'];
             if (!empty($xid)) {
                 $id = $dao->Table("iic_addon_arc")->where("aid={$aid}")->save($data);
             } else {
                 $data['aid'] = $aid;
                 $id = $dao->Table("iic_addon_arc")->add($data);
             }
             //dump($dao->getLastSql());
             if ($id || $id == '0') {
                 $actlog .= '<br>' . $dao->getLastSql();
                 if (empty($xid)) {
                     $this->_act_log($aid, $vo['channel'], 'add', $actlog);
                 } else {
                     $this->_act_log($aid, $vo['channel'], 'edit', $actlog);
                 }
                 //echo "发布成功!";
                 $txt = '<h4>Successful release. </h4><br><a href="' . __APP__ . '/article/' . $aid . '.html">View articles </a>   /   ';
                 $txt .= '<a href="' . __APP__ . '/Usercenter/ctg_article/act/add/ctgid/' . $_POST['typeid2'] . '">Post articles</a><br>';
                 $txt .= '<a href="' . __APP__ . '/Usercenter/ctg_article/">Back to the list </a>';
                 $txt .= 'You will be directed to the list page in three seconds! ';
                 $this->assign('jumpUrl', __APP__ . '/Usercenter/ctg_article/ctgid/' . $_POST['typeid2']);
                 $this->success($txt);
             } else {
                 if (empty($xid)) {
                     $dao->Table("iic_archives")->where("id={$aid}")->limit('1')->delete();
                 }
                 $this->error("Failed to write in subsidiary table. ");
             }
         } else {
             if ($this->user['username'] == 'iicc') {
                 dump($dao->getLastSql());
             }
             $this->error('Failed to update the main profile table. ');
         }
         //dump($vo);
     } else {
         $this->error($dao->getError());
     }
 }
 /**
  *读取数据库的首页
  *@date 2011-1-10 / @time 下午06:05:52
  */
 function detail()
 {
     //读取数据库的首页
     $vol = Input::getVar($_GET['vol']);
     $dao = D("Magazines");
     $index = '';
     if (empty($vol)) {
         $condition = array("showtime" => array('lt', time()));
         $top = $dao->where($condition)->order("id DESC")->find();
         $index = $top['vol'];
         $vol = empty($vol) ? $index : $vol;
     } else {
         $condition = array("vol" => array('eq', $vol));
         $top = $dao->where($condition)->find();
     }
     $top['mid'] = explode(",", trim($top['middleimg'], ','));
     $top['small'] = explode(",", trim($top['smallimg'], ','));
     self::pre_and_next($vol, $dao);
     $this->assign("top", $top);
     self::all_zine($dao);
     $y = array();
     $y = F('dnum_' . $vol, '', APP_PATH . '/file/');
     if (empty($y)) {
         $num = rand(200, 1800);
         $y = array('num' => $num, 'time' => time());
     }
     if ($y['time'] + 180 < time()) {
         if (date('H') > 22 || date('H') < 8) {
             if ($vol == $index) {
                 $rand = rand(10, 100);
             } else {
                 $rand = rand(8, 80);
             }
         } else {
             if ($vol == $index) {
                 $rand = rand(100, 500);
             } else {
                 $rand = rand(80, 300);
             }
         }
         $time = time();
     } else {
         $rand = 0;
         $time = $y['time'];
     }
     $x = array('num' => $y['num'] + $rand, 'time' => $time);
     F('dnum_' . $vol, $x, APP_PATH . '/file/');
     $this->assign('dnum', $x);
     $this->assign("group", $this->member_group($this->member_comments($vol, 14), "0,6"));
     $page = array('title' => $top['seotitle'], 'keywords' => $top['keywords'], 'description' => $top['description']);
     $this->assign('page', $page);
     $this->assign("otherarc", $this->otherarc(3001, 'vol' . $vol));
     $this->display("index_2");
 }
Exemple #14
0
 /**
  * 站内信
  */
 public function sysmsg()
 {
     if (IS_POST) {
         $this->redirect('sysmsg', $_POST);
     }
     //搜索
     $search = I('get.search');
     if (!empty($search)) {
         $this->assign("search", $search);
         //添加开始时间
         $start_time = I('get.start_time');
         if (!empty($start_time)) {
             $start_time = strtotime($start_time);
             $where['create_time'] = array("EGT", $start_time);
             $this->assign('start_time', $start_time);
         }
         //添加结束时间
         $end_time = I('get.end_time');
         if (!empty($end_time)) {
             $end_time = strtotime($end_time);
             $where['create_time'] = array("ELT", $end_time);
             $this->assign('end_time', $end_time);
         }
         //时间搜索条件
         if ($end_time > 0 && $start_time > 0) {
             $where['create_time'] = array(array('EGT', $start_time), array('ELT', $end_time));
         }
         //类别
         $types = I('get.types', null, 'intval');
         if (!empty($types)) {
             $this->assign("types", $types);
             $where['type'] = array("EQ", $types);
         }
         //搜索字段
         $searchtype = I('get.searchtype', null, 'intval');
         //搜索关键字
         $keyword = \Input::getVar(I('get.keyword'));
         if (!empty($keyword)) {
             $this->assign("searchtype", $searchtype);
             $this->assign("keyword", $keyword);
             if ($searchtype == 2) {
                 $where['title'] = array("LIKE", "%{$keyword}%");
             } elseif ($searchtype == 1) {
                 $userid = M('User')->where(array('nickname' => $keyword))->getField('userid');
                 $where['userid'] = array('EQ', (int) $userid);
             }
         }
     }
     $where['sendtype'] = array('EQ', I('get.sendtype'));
     $this->assign('sendtype', I('get.sendtype'));
     $model = M('Sysmsg');
     $count = $model->where($where)->count();
     $page = $this->page($count, 20);
     $data = $model->where($where)->limit($page->firstRow . ',' . $page->listRows)->order(array("id" => "DESC"))->select();
     $this->assign('Page', $page->show());
     $this->assign('count', $count);
     $this->assign('data', $data);
     $this->display();
 }
 public function classlist()
 {
     if (IS_POST) {
         $this->redirect('classlist', $_POST);
     }
     //当前栏目信息
     $catInfo = getCategory($this->catid);
     if (empty($catInfo)) {
         $this->error('该栏目不存在!', U('Admin/Main/index'));
     }
     //查询条件
     $where = array();
     $where['catid'] = array('EQ', $this->catid);
     $where['status'] = array('EQ', 99);
     //栏目所属模型
     $modelid = $catInfo['modelid'];
     //栏目扩展配置
     $setting = $catInfo['setting'];
     //检查模型是否被禁用
     if (getModel($modelid, 'disabled')) {
         $this->error('模型被禁用!');
     }
     //搜索
     $search = I('get.search');
     if (!empty($search)) {
         $this->assign("search", $search);
         //添加开始时间
         $start_time = I('get.start_time');
         if (!empty($start_time)) {
             $start_time = strtotime($start_time);
             $where['inputtime'] = array("EGT", $start_time);
             $this->assign('start_time', $start_time);
         }
         //添加结束时间
         $end_time = I('get.end_time');
         if (!empty($end_time)) {
             $end_time = strtotime($end_time);
             $where['inputtime'] = array("ELT", $end_time);
             $this->assign('end_time', $end_time);
         }
         if ($end_time > 0 && $start_time > 0) {
             $where['inputtime'] = array(array('EGT', $start_time), array('ELT', $end_time));
         }
         //推荐
         $posids = I('get.posids', 0, 'intval');
         if (!empty($posids)) {
             $where["posid"] = array("EQ", $posids);
             $this->assign("posids", $posids);
         }
         //搜索字段
         $searchtype = I('get.searchtype', null, 'intval');
         //搜索关键字
         $keyword = \Input::getVar(I('get.keyword'));
         if (!empty($keyword)) {
             $this->assign("searchtype", $searchtype);
             $this->assign("keyword", $keyword);
             $type_array = array('title', 'description', 'username');
             if ($searchtype < 3) {
                 $searchtype = $type_array[$searchtype];
                 $where[$searchtype] = array("LIKE", "%{$keyword}%");
             } elseif ($searchtype == 3) {
                 $where["id"] = array("EQ", (int) $keyword);
             }
         }
         //状态
         $status = I('get.status', 0, 'intval');
         if ($status) {
             $where['status'] = array("EQ", $status);
         }
     }
     //实例化模型
     $model = ContentModel::getInstance($modelid);
     //信息总数
     $count = $model->where($where)->count();
     $page = $this->page($count, 20);
     $data = $model->where($where)->limit($page->firstRow . ',' . $page->listRows)->order(array("id" => "DESC"))->select();
     //模板处理
     $template = '';
     //自定义列表
     if (!empty($setting['list_customtemplate'])) {
         $template = "Listtemplate:{$setting['list_customtemplate']}";
     }
     $this->assign($catInfo)->assign('Page', $page->show())->assign('catid', $this->catid)->assign('count', $count)->assign('data', $data);
     $this->display($template);
 }
 /**
  *编辑信息
  *@date 2010-6-18
  *@time 下午06:29:13
  */
 function my_edit_art()
 {
     //编辑信息
     $info = Input::getVar($_REQUEST['info']);
     $info = explode('_', $info);
     $dao = D("Archives");
     $condition = array();
     $condition['channel'] = $info['0'];
     $condition['id'] = $info['1'];
     $data = $dao->where($condition)->find();
     if ($data['uid'] == $this->user['uid']) {
         $data['content'] = $dao->relationGet("arc");
         $this->assign('data', $data);
     } else {
         $this->error("Insufficient privilege.");
     }
     $this->assign('flag', $this->_get_flag());
     $class_tree = $this->_get_tree(2000);
     $this->assign("class_tree", $class_tree);
     $this->assign('citylist', $this->_get_city('city'));
     $page = array();
     $page['title'] = 'Edit Articles -  My Control Panel -  BeingfunChina';
     $page['keywords'] = 'Edit Articles';
     $page['description'] = 'Edit Articles';
     $this->assign('page', $page);
     $this->assign('content', 'Cp:post_art');
     $this->display("Cp:layout");
 }
 public function suipai()
 {
     //显示
     if ($this->doAction == 'index') {
         if (IS_POST) {
             $this->redirect('suipai?doAction=index', $_POST);
         }
         //查询条件
         $where = '';
         //搜索
         $search = I('get.search');
         if (!empty($search)) {
             $this->assign("search", $search);
             //添加开始时间
             $start_time = I('get.start_time');
             if (!empty($start_time)) {
                 $start_time = strtotime($start_time);
                 $where .= ' and S.create_time>' . $start_time;
                 $this->assign('start_time', $start_time);
             }
             //添加结束时间
             $end_time = I('get.end_time');
             if (!empty($end_time)) {
                 $end_time = strtotime($end_time);
                 $where .= ' and S.create_time<' . $end_time;
                 $this->assign('end_time', $end_time);
             }
             /*if ($end_time > 0 && $start_time > 0) {
                   $where.=' and S.create_time>'.$start_time.' and S.create_time<'.$end_time;
               }*/
             //搜索关键字
             $keyword = \Input::getVar(I('get.keyword'));
             if (!empty($keyword)) {
                 $this->assign("keyword", $keyword);
                 $where .= ' and S.title like "%' . $keyword . '"';
             }
             //状态
             $status = I('get.status');
             $this->assign('status', $status);
             if (isset($_GET['status'])) {
                 $where .= ' and S.status=' . $status;
             }
             //获奖
             $ifwin = I('get.ifwin');
             $this->assign('ifwin', $ifwin);
             if (isset($_GET['ifwin']) && $ifwin < 3) {
                 $where .= ' and TS.ifwin=' . $ifwin;
             }
         } else {
             $where .= ' and S.status=true';
             $this->assign('ifwin', 3);
         }
         $Model = new Model();
         $arr = $Model->table(array(C('DB_PREFIX') . 'toppic_suipai' => 'TS', C('DB_PREFIX') . 'suipai' => 'S', C('DB_PREFIX') . 'user' => 'U'))->where('TS.userid=U.userid and S.id=TS.workid' . $where)->field('TS.id')->select();
         $count = count($arr);
         $page = $this->Pages($count, 30);
         $list = $Model->table(array(C('DB_PREFIX') . 'toppic_suipai' => 'TS', C('DB_PREFIX') . 'suipai' => 'S', C('DB_PREFIX') . 'user' => 'U'))->where('TS.userid=U.userid and S.id=TS.workid' . $where)->field('TS.ifwin,S.title,S.msgnum,S.clicknum,S.id,TS.create_time,S.image,U.uavatar,U.openuid,TS.userid,S.status')->order('TS.id DESC')->limit($page->firstRow . ',' . $page->listRows)->select();
         $this->assign('Page', $page->show())->assign('count', $count)->assign('data', $list);
         $this->display('Toppic:Suipai:index');
     }
     //批量处理信息
     if ($this->doAction == 'suipaibatch') {
         $ids = $_POST['ids'];
         if (!$ids) {
             $this->error('没有信息被选中!');
         }
         $doAct = I('get.do');
         switch ($doAct) {
             case 'win':
                 $data = array('ifwin' => true);
                 $msg = '获奖';
                 break;
             case 'nowin':
                 $data = array('ifwin' => false);
                 $msg = '取消获奖';
                 break;
         }
         foreach ($ids as $id) {
             M('ToppicSuipai')->where(array('workid' => $id))->save($data);
         }
         $this->success($msg . '成功!');
     }
 }
Exemple #18
0
 protected function _add($post)
 {
     if ($_POST['title'] == '' || $_POST['text'] == '') {
         $this->error('标题或内容不能为空!');
     }
     $data = array('title' => Input::getVar($_POST['title']), 'date' => date('Y-m-d H:i:s'));
     //存入日志基本信息
     $db = new ArticlesModel();
     //dump($data);exit;
     $id = $db->add($data);
     if ($id === false || $id === null) {
         $this->error('保存文章基本信息时出现错误' . $db->getError());
     }
     //存入日志内容信息
     $db = new ArticlesContentModel();
     unset($data);
     $data = array('id' => $id, 'text' => str_replace('\\', '', str_replace("&quot;", '', $_POST['text'])));
     $rs = $db->add($data);
     if ($rs === false || $rs === null) {
         $this->error('保存文章内容时出现错误' . $db->getError());
     }
     $c = $this->getConfig();
     $msg = '发表文章《' . Input::getVar($_POST['title']) . '》 详细:' . $c['domain'] . '/index.php/Note/view/id/' . $data['id'];
     //同步到本站微博
     $db = new WorldsModel();
     $data = array('text' => Input::makeLink($msg), 'time' => date('Y-m-d H:i:s'));
     $db->add($data);
     //同步到新浪微博
     $this->sina_update($msg);
     $this->redirect('Note/view/id/' . $id);
 }
 /**
  * 获取临时未处理的图片
  * @return type
  */
 protected function att_not_used()
 {
     //获取临时未处理文件列表
     // 水平凡 修复如果cookie里面有加反斜杠,去除
     $att_json = \Input::getVar(cookie('att_json'));
     if ($att_json) {
         if ($att_json) {
             $att_cookie_arr = explode('||', $att_json);
         }
         foreach ($att_cookie_arr as $_att_c) {
             $att[] = json_decode($_att_c, true);
         }
         if (is_array($att) && !empty($att)) {
             foreach ($att as $n => $v) {
                 $ext = fileext($v['src']);
                 if (in_array($ext, array('jpg', 'gif', 'png', 'bmp', 'jpeg'))) {
                     $att[$n]['fileimg'] = $v['src'];
                     $att[$n]['width'] = '80';
                     $att[$n]['filename'] = urldecode($v['filename']);
                 } else {
                     $att[$n]['fileimg'] = file_icon($v['src']);
                     $att[$n]['width'] = '64';
                     $att[$n]['filename'] = urldecode($v['filename']);
                 }
                 $this->cookie_att .= '|' . $v['src'];
             }
         }
     }
     return $att;
 }
 /**
  * 编辑文件 
  */
 public function edit_file()
 {
     if (IS_POST) {
         $dir = $this->_post("dir");
         $file = $this->_post("file");
         $path = $this->filepath . $dir . "/" . $file;
         $path = str_replace(array("//"), array("/"), $path);
         $content = Input::getVar($this->_post("content"));
         $status = file_put_contents($path, htmlspecialchars_decode(stripslashes($content)));
         if ($status) {
             $this->success("保存成功!");
         } else {
             $this->error("保存失败,请检查模板文件权限是否设置为可写!");
         }
         exit;
     } else {
         $dir = isset($_GET['dir']) && trim($_GET['dir']) ? str_replace(array('..\\', '../', './', '.\\'), '', urldecode(trim($_GET['dir']))) : '';
         $dir = str_replace("-", "/", $dir);
         $file = isset($_GET['file']) && trim($_GET['file']) ? trim($_GET['file']) : '';
         $path = $this->filepath . $dir . "/" . $file;
         if ($file) {
             if (file_exists($path)) {
                 $content = file_get_contents($path);
                 $content = Input::forTarea($content);
             } else {
                 $this->error("文件不存在!");
             }
         }
         $this->assign("content", $content);
         $this->assign("dir", $dir);
         $this->assign("file", $file);
     }
     $this->display();
 }
 public function tpllists()
 {
     if (IS_POST) {
         $info = I('post.');
         if ($info['createtype'] == 'dir') {
             $file_ext = explode('.', $info['createname']);
             if (!empty($file_ext[1]) || preg_match('/[^\\x00-\\x80]/', $info['createname'])) {
                 $this->error('文件夹名称应为英文字符和数字');
             }
             $filepath = $this->setFullpath($info['createpath'], $info['createname'], '');
             if (is_dir($filepath)) {
                 $this->error('该文件(文件夹)已经存在,请换个标识');
             } else {
                 create_dir_or_files(array(0 => $filepath));
                 $this->success($info['createname'] . '文件夹创建成功!路径为:' . $filepath, U('edit'));
             }
         } else {
             import('Common.ORG.Input');
             $content = \Input::getVar($info['content']);
             $file_ext = explode('.', $info['createname']);
             if (count($file_ext) > 0) {
                 $ext = end($file_ext);
                 $filename = str_replace('.' . $ext, '', $info['createname']);
                 //创建路径 file_put_contents("{$addon_dir}Model/{$data['info']['name']}Model.class.php", $addonModel);
                 $filepath = $this->setFullpath($info['createpath'], $filename, $ext);
                 //判断文件是否存在 否则创建
                 if (!file_exists($filepath)) {
                     create_dir_or_files(array(0 => $filepath));
                     //是否存在
                     if (!file_exists($filepath)) {
                         $this->error('模板文件新建失败,后缀标识为.,请确保文件名请使用非中文和标点,当前路径为合法路径');
                     }
                 }
                 if (!is_writable($filepath)) {
                     $this->error("文件 {$info['createname']} 不可写!");
                 }
                 file_put_contents($filepath, $content);
                 $this->success('创建【' . $info['createname'] . '】文件成功!', U('edit'));
             } else {
                 $this->error('请输入有效的文件后缀名!');
             }
         }
     } else {
         $this->assign('meta_title', '模板编辑');
         $info = I('get.');
         if (empty($info['type'])) {
             $filename = $info['filename'];
             $showpath = str_replace('-', '/', $info['dir']) . '/' . $info['filename'];
             $this->assign('editpath', $showpath);
             $this->assign('title', '新增');
             $this->assign('nowpath', $showpath);
         } else {
             $filename = $info['filename'] . '.' . $info['type'];
             $showpath = str_replace('-', '/', $info['dir']);
             $filepath = $this->setFullpath($info['dir'], $info['filename'], $info['type']);
             //标签合法
             $content = file_get_contents($filepath);
             import('Common.ORG.Input');
             $content = \Input::forTarea($content);
             $this->assign('content', $content);
             $this->assign('title', '编辑');
             $this->assign('editpath', $showpath);
             $this->assign('nowpath', $showpath . '/' . $filename);
             $this->assign('fileinfo', $filename);
             $this->assign('filetype', 'file');
         }
         $this->display();
     }
 }
 public function tell_a_friend()
 {
     if (isset($_POST['id'])) {
         $list = D('Products')->find($id);
         import("ORG.Util.Input");
         $to_email_address = Input::getVar($_POST['to_email_address']);
         $to_name = Input::getVar($_POST['to_name']);
         $from_email_address = Input::getVar($_POST['from_email_address']);
         $from_name = Input::getVar($_POST['from_name']);
         $message = Input::safeHtml($_POST['message']);
         $sitename = GetSettValue('siteurl');
         sendmail(array($to_email_address), "Your friend {$from_name} has recommended this great product from {$sitename}", "Hi {$to_name}!<br/><br/>Your friend, {$from_name}({$from_email_address}), thought that you would be interested in {$list['name']} from {$sitename}.<br/>{$message}");
         $this->jumpUrl = build_url($list, 'pro_url');
         $this->success("Your message has been successfully sent!");
     }
     if (isset($_GET['id'])) {
         $id = intval($_GET['id']);
         $list = D('Products')->find($id);
         if ($list) {
             if ($this->memberID <= 0 && GetSettValue('quickbuy') == 0) {
                 Session::set('back', U('Pro/tell_a_friend', array('id' => $list['id'])));
                 $this->redirect('Member-Public/Login');
             }
             $this->list = $list;
             $this->display('tell_a_friend');
         }
     } else {
         $this->redirect("Index/index");
     }
 }
 public function classlist()
 {
     $catInfo = getCategory($this->catid);
     //是否搜索
     $search = I('get.search');
     $where = array();
     $where["catid"] = array("EQ", $this->catid);
     if (!empty($catInfo)) {
         //栏目扩展配置
         $setting = $catInfo['setting'];
         //检查模型是否被禁用
         if ($this->model[$catInfo['modelid']]['disabled'] == 1) {
             $this->error("模型被禁用!");
         }
         $this->contentModel = ContentModel::getInstance($catInfo['modelid']);
         //搜索相关开始
         if (!empty($search)) {
             //添加开始时间
             $start_time = I('get.start_time');
             if (!empty($start_time)) {
                 $start_time = strtotime($start_time);
                 $where["inputtime"] = array("EGT", $start_time);
             }
             //添加结束时间
             $end_time = I('get.end_time');
             if (!empty($end_time)) {
                 $end_time = strtotime($end_time);
                 $where["inputtime"] = array("ELT", $end_time);
             }
             if ($end_time > 0 && $start_time > 0) {
                 $where['inputtime'] = array(array('EGT', $start_time), array('ELT', $end_time));
             }
             //推荐
             $posids = I('get.posids', 0, 'intval');
             if (!empty($posids)) {
                 $where["posid"] = array("EQ", $posids);
             }
             //搜索字段
             $searchtype = I('get.searchtype', null, 'intval');
             //搜索关键字
             $keyword = Input::getVar(I('get.keyword'));
             if (!empty($keyword)) {
                 $type_array = array('title', 'description', 'username');
                 if ($searchtype < 3) {
                     $searchtype = $type_array[$searchtype];
                     $where[$searchtype] = array("LIKE", "%{$keyword}%");
                 } elseif ($searchtype == 3) {
                     $where["id"] = array("EQ", (int) $keyword);
                 }
             }
             //状态
             $status = I('get.status', 0, 'intval');
             if ($status > 0) {
                 $where['status'] = array("EQ", $status);
             }
         }
         //信息总数
         $count = $this->contentModel->where($where)->count();
         $page = $this->page($count, 20);
         $data = $this->contentModel->where($where)->limit($page->firstRow . ',' . $page->listRows)->order(array("id" => "DESC"))->select();
         //模板处理
         $template = "";
         if (!empty($setting['list_customtemplate'])) {
             $template = "Listtemplate:" . $setting['list_customtemplate'];
         }
     } else {
         $this->error("该栏目不存在!");
     }
     $this->assign("search", $search);
     $this->assign("start_time", $start_time);
     $this->assign("end_time", $end_time);
     $this->assign("posids", $posids);
     $this->assign("searchtype", $searchtype);
     $this->assign("keyword", $keyword);
     $this->assign($catInfo);
     $this->assign("count", $count);
     $this->assign("catid", $this->catid);
     $this->assign("Content", $data);
     $this->assign("Page", $page->show('Admin'));
     $this->display($template);
 }
 function reg_add()
 {
     //注册写入
     if ($_POST['policy'] != '1') {
         $this->error("You should agree with the Terms of Service to finish registration.");
     }
     $dao = D("Members");
     $data = array();
     if (!$dao->create()) {
         $this->error($dao->getError());
     }
     $data['username'] = Input::getVar($_POST['username']);
     $data['password'] = Input::getVar($_POST['password']);
     $data['email'] = Input::getVar($_POST['email']);
     $data['groupid'] = 10;
     if ($data['password'] != $_POST['repassword'] || empty($data['password']) || empty($data['email']) || empty($data['username'])) {
         $this->error("Wrong parameter!");
     }
     $data['password'] = md5($data['password']);
     $data['bday'] = Input::getVar($_POST['bdayyear']) . '-' . Input::getVar($_POST['birthmonth']) . '-' . Input::getVar($_POST['birthday']);
     $data['nationality'] = Input::getVar($_POST['nationality']);
     $address = Input::getVar($_POST['address']);
     $data['address'] = empty($address) ? Input::getVar($_POST['address2']) : $address;
     $data['nationality'] = Input::getVar($_POST['nationality']);
     $data['gender'] = Input::getVar($_POST['gender']);
     $data['fname'] = Input::getVar($_POST['first_name']);
     $data['lname'] = Input::getVar($_POST['last_name']);
     $uid = $dao->add($data);
     //dump($dao->getLastSql());
     if ($uid) {
         $info = $dao->where("id='{$uid}'")->find();
         $_SESSION['uid'] = $info['id'];
         $_SESSION['username'] = $info['username'];
         $info['avatar'] = avatar($info['avatar']);
         $_SESSION["info"] = $info;
         if (empty($_REQUEST['to'])) {
             redirect("/Cp/index");
         } else {
             $url = mydecode($_REQUEST['to']);
             $this->redirect($url);
         }
     } else {
         $this->error("Wrong parameter!!");
     }
 }
Exemple #25
0
 /**
  * 显示默认列表页
  */
 public function allworks()
 {
     if (IS_POST) {
         $this->redirect('allworks', $_POST);
     }
     $order = I('get.order', 'workid');
     //查询条件
     $where = array();
     if (isset($_GET['status']) && $_GET['status'] == 0) {
         $status = 0;
     } else {
         $status = I('get.status', 1, 'intval');
     }
     $where['status'] = array('EQ', $status);
     $this->assign('statuss', $status);
     //搜索
     $search = I('get.search');
     if (!empty($search)) {
         $this->assign("search", $search);
         //添加开始时间
         $start_time = I('get.start_time');
         if (!empty($start_time)) {
             $start_time = strtotime($start_time);
             $where['create_time'] = array("EGT", $start_time);
             $this->assign('start_time', $start_time);
         }
         //添加结束时间
         $end_time = I('get.end_time');
         if (!empty($end_time)) {
             $end_time = strtotime($end_time);
             $where['create_time'] = array("ELT", $end_time);
             $this->assign('end_time', $end_time);
         }
         if ($end_time > 0 && $start_time > 0) {
             $where['create_time'] = array(array('EGT', $start_time), array('ELT', $end_time));
         }
         //类别
         $type = I('get.type', 0, 'intval');
         if (!empty($type)) {
             $this->assign("type", $type);
             $where["type"] = array("EQ", (int) $type);
         }
         //搜索字段
         $searchtype = I('get.searchtype', null, 'intval');
         //搜索关键字
         $keyword = \Input::getVar(I('get.keyword'));
         if (!empty($keyword)) {
             $this->assign("searchtype", $searchtype);
             $this->assign("keyword", $keyword);
             if ($searchtype == 1) {
                 $where['title'] = array("LIKE", "%{$keyword}%");
             } elseif ($searchtype == 2) {
                 $userid = M('User')->where(array('nickname' => $keyword))->getField('userid');
                 $where['userid'] = array('EQ', (int) $userid);
             } elseif ($searchtype == 3) {
                 $where["workid"] = array("EQ", (int) $keyword);
             }
         }
     }
     $model = M('Works');
     //信息总数
     $count = $model->where($where)->count();
     $page = $this->page($count, 30);
     $data = $model->where($where)->limit($page->firstRow . ',' . $page->listRows)->order('' . $order . ' DESC')->select();
     $this->assign('Page', $page->show())->assign('cateid', $this->cateid)->assign('count', $count)->assign('data', $data);
     $this->display();
 }
 public function edit()
 {
     if (IS_POST) {
         //文件
         $file = I('post.file', '', '');
         //目录
         $dir = I('post.dir', '', '');
         $dir = str_replace(array("//"), array("/"), $dir);
         //完整路径
         $path = TEMPLATE_PATH . $dir . "/" . $file;
         $path = str_replace(array("//"), array("/"), $path);
         if (!file_exists($path)) {
             $this->error("文件 {$path} 不存在!");
         }
         //检查文件是否可写
         if (!is_writable($path)) {
             $this->error("文件 {$path} 不可写!");
         }
         //模板内容
         $content = \Input::getVar(I('post.content', '', ''));
         $status = file_put_contents($path, htmlspecialchars_decode(stripslashes($content)));
         if ($status) {
             $this->success("保存成功!");
         } else {
             $this->error("保存失败,请检查模板文件权限是否设置为可写!");
         }
         exit;
     } else {
         //取得目录路径
         $dir = isset($_GET['dir']) && trim($_GET['dir']) ? str_replace(array('..\\', '../', './', '.\\'), '', urldecode(trim($_GET['dir']))) : '';
         $dir = str_replace("-", "/", $dir);
         //文件名
         $file = isset($_GET['file']) && trim($_GET['file']) ? trim($_GET['file']) : '';
         //完整路径
         $path = TEMPLATE_PATH . $dir . "/" . $file;
         //检查文件是否存在
         if (!file_exists($path)) {
             $this->error("文件 {$path} 不存在!");
         }
         //检查文件是否可写
         if (!is_writable($path)) {
             $this->error("文件 {$path} 不可写!");
         }
         //读取内容
         $content = file_get_contents($path);
         $content = \Input::forTarea($content);
         $this->assign("content", $content);
         $this->assign("dir", $dir);
         $this->assign("file", $file);
     }
     $this->display();
 }
 /**
  *群内成员列表
  *@date 2010-6-4
  *@time 下午04:02:01
  */
 function members()
 {
     //群内成员
     $gid = Input::getVar($_GET['gid']);
     $dao = D("Tagspace");
     $count = $dao->where("tagid={$gid}")->count();
     import("ORG.Util.Page");
     $page = new Page($count, 50);
     $page->config = array('header' => 'Rows', 'prev' => 'Previous', 'next' => 'Next', 'first' => '«', 'last' => '»', 'theme' => ' %nowPage%/%totalPage% %upPage% %downPage% %first%  %prePage%  %linkPage%  %nextPage% %end%');
     $this->assign('showpage', $page->show());
     $page->config = array('header' => '', 'prev' => '<', 'next' => '>', 'first' => '«', 'last' => '»', 'theme' => '%first% %upPage%  %prePage%  %linkPage%  %nextPage% %downPage% %end%');
     $this->assign('showpage_bot', $page->show_img());
     $limit = $page->firstRow . ',' . $page->listRows;
     $member = $this->get_gmember($gid, '', $limit);
     $this->assign('member', $member);
     $this->display();
 }
 /**
  * 修改内容 
  * @param array $data 数据
  * @param type $id 信息ID
  * @return boolean 
  */
 public function edit($data, $id)
 {
     require_array(array(RUNTIME_PATH . 'content_input.class.php', RUNTIME_PATH . 'content_update.class.php'));
     $this->catid = (int) $data['catid'];
     $this->modelid = $this->categorys[$this->catid]['modelid'];
     //主表操作开始
     $this->table_name = ucwords($this->Model[$this->modelid]['tablename']);
     $this->fbtable_name = $this->table_name . "_data";
     $this->Content = new ContentModel($this->table_name);
     $content_input = new content_input($this->modelid, $this);
     $inputinfo = $content_input->get($data);
     if (is_bool($inputinfo) && $inputinfo == false) {
         //显示错误
         $this->error($content_input->getError());
         return false;
     }
     //主表字段内容
     $systeminfo = $inputinfo['system'];
     //副表字段内容
     $modelinfo = $inputinfo['model'];
     //栏目数据
     $catidinfo = $this->categorys[$systeminfo['catid']];
     //setting配置
     $catidsetting = unserialize($catidinfo['setting']);
     //前台投稿状态判断
     if (defined('IN_ADMIN') && IN_ADMIN == false) {
         //前台投稿编辑是否需要审核
         if ($catidsetting['member_editcheck']) {
             $systeminfo['status'] = 1;
         }
     }
     //取得inputtime的真实发布时间
     //inputtime为真实发表时间,不允许修改
     $data['inputtime'] = $systeminfo['inputtime'] = $inputtime = $this->Content->where(array("id" => $id))->getField("inputtime");
     //更新时间处理
     if ($data['updatetime'] && !is_numeric($data['updatetime'])) {
         $systeminfo['updatetime'] = strtotime($data['updatetime']);
     } elseif (!$data['updatetime']) {
         $systeminfo['updatetime'] = time();
     } else {
         $systeminfo['updatetime'] = $data['updatetime'];
     }
     //自动提取摘要,如果有设置自动提取,且description为空,且有内容字段才执行
     if (isset($_POST['add_introduce']) && $systeminfo['description'] == '' && isset($modelinfo['content'])) {
         $content = stripslashes($modelinfo['content']);
         $introcude_length = intval($_POST['introcude_length']);
         $systeminfo['description'] = str_cut(str_replace(array("\r\n", "\t", '[page]', '[/page]', '&ldquo;', '&rdquo;', '&nbsp;'), '', strip_tags($content)), $introcude_length);
         $inputinfo['system']['description'] = $systeminfo['description'] = Input::getVar($systeminfo['description']);
     }
     //自动提取缩略图,从content 中提取
     if (isset($_POST['auto_thumb']) && $systeminfo['thumb'] == '' && isset($modelinfo['content'])) {
         $content = $content ? $content : stripslashes($modelinfo['content']);
         $auto_thumb_no = intval($_POST['auto_thumb_no']) - 1;
         if (preg_match_all("/(src)=([\"|']?)([^ \"'>]+\\.(gif|jpg|jpeg|bmp|png))\\2/i", $content, $matches)) {
             $systeminfo['thumb'] = $matches[3][$auto_thumb_no];
         }
     }
     //转向地址
     if ($data['islink'] == 1) {
         $systeminfo['url'] = $_POST['linkurl'];
     } else {
         //生成该篇地址
         $urls = $this->url->show($id, 0, $systeminfo['catid'], $inputtime, $data['prefix'], $inputinfo, 'edit');
         $systeminfo['url'] = $urls[0];
     }
     //使用TP的自动验证,所以要把令牌合并
     $systeminfo = array_merge($systeminfo, array(C("TOKEN_NAME") => $_POST[C("TOKEN_NAME")]));
     $status = $this->Content->create($systeminfo);
     if (!$status) {
         $this->error($this->Content->getError());
     }
     //把副表的数据合并,按关联模型的需求合并
     $status['id'] = $id;
     $fdata = array($this->fbtable_name => $modelinfo);
     $status = array_merge($status, $fdata);
     //删除真实时间的信息,避免被更新
     unset($status['inputtime']);
     //数据修改,这里使用关联操作
     $this->Content->relation(true)->where(array('id' => $id))->save($status);
     //调用 update
     $content_update = new content_update($this->modelid, $id, $this);
     $data['url'] = $systeminfo['url'];
     $content_update->update($data);
     //更新附件状态,把相关附件和文章进行管理
     $this->attachment_db = service("Attachment");
     $this->attachment_db->api_update('', 'c-' . $systeminfo['catid'] . '-' . $id, 2);
     //更新到全站搜索
     if ($systeminfo['status'] == 99) {
         $this->search_api($id, $inputinfo, "updata");
     } else {
         $this->search_api($id, $inputinfo, "delete");
     }
     //生成相关
     $generatelish = 0;
     import('Html');
     $html = new Html();
     if (defined('IN_ADMIN') && IN_ADMIN) {
         //是否生成内容页
         if ($catidsetting['generatehtml']) {
             //生成静态
             if ($urls['content_ishtml'] && $status['status'] == 99) {
                 $html->show($urls[1], $urls['data']);
             }
         }
         //如果是未审核,删除已经生成
         if ($urls['content_ishtml'] && !$data['islink'] && $status['status'] == 1) {
             $this->deleteHtml($data['catid'], $id, $systeminfo['inputtime'], $systeminfo['prefix']);
         }
         //生成列表
         if ((int) $catidsetting['generatelish'] > 0) {
             $generatelish = (int) $catidsetting['generatelish'];
         }
     } else {
         //投稿内容页生成,直接审核通过的直接生成内容页
         if ($status['status'] == 99) {
             //生成静态
             if ($urls['content_ishtml']) {
                 $html->show($urls[1], $urls['data']);
             }
         } else {
             if ($urls['content_ishtml'] && !$data['islink']) {
                 $this->deleteHtml($data['catid'], $id, $systeminfo['inputtime'], $systeminfo['prefix']);
             }
         }
         //列表生成
         if ((int) $catidsetting['member_generatelish'] > 0) {
             $generatelish = (int) $catidsetting['member_generatelish'];
         }
     }
     //列表生成
     switch ($generatelish) {
         //生成当前栏目
         case 1:
             $html->create_relation_html($status['catid']);
             break;
             //生成首页
         //生成首页
         case 2:
             $html->index();
             break;
             //生成父栏目
         //生成父栏目
         case 3:
             if ($catidinfo['parentid']) {
                 $html->create_relation_html($catidinfo['parentid']);
             }
             break;
             //生成当前栏目与父栏目
         //生成当前栏目与父栏目
         case 4:
             $html->create_relation_html($status['catid']);
             if ($catidinfo['parentid']) {
                 $html->create_relation_html($catidinfo['parentid']);
             }
             break;
             //生成父栏目与首页
         //生成父栏目与首页
         case 5:
             if ($catidinfo['parentid']) {
                 $html->create_relation_html($catidinfo['parentid']);
             }
             $html->index();
             break;
             //生成当前栏目、父栏目与首页
         //生成当前栏目、父栏目与首页
         case 6:
             $html->create_relation_html($status['catid']);
             if ($catidinfo['parentid']) {
                 $html->create_relation_html($catidinfo['parentid']);
             }
             $html->index();
             break;
     }
     //生成上一篇下一篇
     $this->related_content($status['catid'], $id, "edit");
     return true;
 }