Beispiel #1
0
 /**
  * 首页
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2013-04-28 17:14:18
  *
  * @return void 无返回值
  */
 public function indexAction()
 {
     $page_size = 60;
     $total = $this->_model->table(TB_TAG)->count('DISTINCT tag');
     $page_info = Filter::page($total, 'page', $page_size);
     $page = $page_info['page'];
     $page_one = $page < 2;
     $tag_arr = $this->_model->table(TB_TAG)->order('searches DESC')->field('DISTINCT `tag`')->limit($page_info['limit'])->select();
     $paging = new Paging(array('_url_tpl' => BASE_SITE_URL . 'tag/page/\\1.shtml', '_total_page' => $page_info['total_page'], '_now_page' => $page, '_page_size' => $page_size));
     $o = $this->getViewTemplate()->assign(array('web_title' => L('TAG'), 'tag_arr' => $tag_arr, 'paging' => $paging->getHtml(), 'page' => $page_one ? '' : $page));
     $this->_display(null, null, $page);
 }
Beispiel #2
0
 /**
  * 渲染博客列表
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2013-04-28 16:55:45
  *
  * @param string|array $cate_info 数组为分类,否则为标签
  *
  * @return void 无返回值
  */
 private function _fetchBlog($cate_info = null)
 {
     if (is_array($cate_info)) {
         //分类
         $is_tag = false;
         $cate_id = $cate_info['cate_id'];
         $table = TB_BLOG;
         $where = array('b.is_delete' => 0, 'b.is_issue' => 1);
         if ($cate_id) {
             //category.shtml
             $where['b.cate_id'] = array('IN', $this->_getChildrenIds($cate_id));
         }
         $url_tpl = str_replace('.shtml', '/page/\\1.shtml', $cate_info['link_url']);
         $cache_flag = $cate_id;
         $total = $this->_model->table(TB_BLOG)->alias('b')->where($where)->count();
         $this->_model->alias('b');
         //b.title
     } else {
         //标签
         $this->_model->table(TB_TAG)->where(array('tag' => $cate_info))->setInc('searches');
         //搜索次数+1
         $is_tag = true;
         $table = TB_BLOG . ' AS b JOIN ' . TB_TAG . ' AS t ON t.blog_id=b.blog_id';
         $where = array('t.tag' => array('IN', $cate_info), 'b.is_delete' => 0, 'b.is_issue' => 1);
         $url_tpl = BASE_SITE_URL . 'tag/' . urlencode($cate_info) . '/page/\\1.shtml';
         $cache_flag = md5(strtolower($cate_info));
         $total = $this->_model->table(TB_BLOG)->alias('b')->join(' JOIN ' . TB_TAG . ' AS t ON b.blog_id=t.blog_id')->where($where)->count('DISTINCT b.blog_id');
     }
     $page_info = Filter::page($total, 'page', PAGE_SIZE);
     $page = $page_info['page'];
     $page_one = $page < 2;
     $blog_arr = $this->_model->table($table)->where($where)->order('b.blog_id DESC')->limit($page_info['limit'])->field('b.blog_id,b.title,b.link_url,b.cate_id,b.add_time,b.summary,b.seo_keyword,b.seo_description')->select();
     $paging = new Paging(array('_url_tpl' => $url_tpl, '_total_page' => $page_info['total_page'], '_now_page' => $page, '_page_size' => PAGE_SIZE));
     $o = $this->getViewTemplate($page_one && !$is_tag ? 'build_html' : null)->assign(array('blog_arr' => $blog_arr, 'paging' => $paging->getHtml(), 'page' => $page_one ? '' : $page));
     if ($is_tag) {
         //标签
         $o->assign(array('web_title' => $cate_info . TITLE_SEPARATOR . L('TAG'), 'tag' => $cate_info, 'seo_keywords' => $cate_info));
     } else {
         //分类
         $o->assign(array('web_title' => $cate_id ? $this->nav($cate_id, 'cate_name', null, TITLE_SEPARATOR) : $cate_info['cate_name'], 'cate_info' => $cate_info, 'tag' => ''));
     }
     $content = $o->fetch(CONTROLLER_NAME, ACTION_NAME, $cache_flag . '-' . $page);
     if ($page_one && !$is_tag) {
         $filename = str_replace(BASE_SITE_URL, WWWROOT, $cate_info['link_url']);
         new_mkdir(dirname($filename));
         //file_put_contents($filename, $content);
     }
     echo $content;
 }
 /**
  * 首页
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2013-02-21 13:30:55
  *
  * @return void 无返回值
  */
 public function indexAction()
 {
     $total = $this->_model->count();
     $page_info = Filter::page($total, 'page', PAGE_SIZE);
     $page = $page_info['page'];
     $page_one = $page < 2;
     $blog_arr = $this->_model->order('blog_id DESC')->limit($page_info['limit'])->select();
     $paging = new Paging(array('_url_tpl' => BASE_SITE_URL . 'miniblog/page/\\1.shtml', '_total_page' => $page_info['total_page'], '_now_page' => $page, '_page_size' => PAGE_SIZE));
     $o = $this->getViewTemplate($page_one ? 'build_html' : null)->assign(array('web_title' => L('MINIBLOG'), 'blog_arr' => $blog_arr, 'paging' => $paging->getHtml(), 'page' => $page_one ? '' : $page));
     $content = $o->fetch(CONTROLLER_NAME, ACTION_NAME, $page);
     if ($page_one) {
         $filename = WWWROOT . 'miniblog.shtml';
         //file_put_contents($filename, $content);
     }
     echo $content;
 }
Beispiel #4
0
 /**
  * 首页
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2013-02-21 13:44:11
  *
  * @return void 无返回值
  */
 public function indexAction()
 {
     $total = $this->_model->table(TB_COMMENTS)->where($where = 'type=' . COMMENT_TYPE_GUESTBOOK . ' AND status=' . COMMENT_STATUS_PASS . ' AND parent_id=0')->count();
     $page_info = Filter::page($total, 'page', PAGE_SIZE);
     $page = $page_info['page'];
     $page_one = $page < 2;
     $guestbook_arr = $this->_model->table(TB_COMMENTS)->where($where)->order('last_reply_time DESC')->limit($page_info['limit'])->select();
     $paging = new Paging(array('_url_tpl' => BASE_SITE_URL . 'guestbook/page/\\1.shtml', '_total_page' => $page_info['total_page'], '_now_page' => $page, '_page_size' => PAGE_SIZE));
     $o = $this->getViewTemplate($page_one ? 'build_html' : null)->assign(array('web_title' => L('GUESTBOOK'), 'guestbook_html' => $this->_getRecurrsiveComments($guestbook_arr), 'paging' => $paging->getHtml(), 'page' => $page_one ? '' : $page));
     $content = $o->fetch(CONTROLLER_NAME, ACTION_NAME, $page);
     if ($page_one) {
         $filename = WWWROOT . 'guestbook.shtml';
         //file_put_contents($filename, $content);
     }
     echo $content;
 }
 /**
  * 列表
  *
  * @author          mrmsl <*****@*****.**>
  * @lastmodify      2013-01-22 10:40:26 by mrmsl
  *
  * @return void 无返回值
  */
 public function listAction()
 {
     $sort = Filter::string('sort', 'get', $this->_pk_field);
     //排序字段
     $sort = 'a.' . $sort;
     $order = !empty($_GET['dir']) ? Filter::string('dir', 'get') : Filter::string('order', 'get');
     //排序
     $order = toggle_order($order);
     $keyword = Filter::string('keyword', 'get');
     //关键字
     $date_start = Filter::string('date_start', 'get');
     //开始时间
     $date_end = Filter::string('date_end', 'get');
     //结束时间
     $column = Filter::string('column', 'get');
     //搜索字段
     $where = array();
     if ($keyword !== '' && in_array($column, array('username', 'realname', 'admin_id'))) {
         $where['b.' . $column] = $this->_buildMatchQuery('b.' . $column, $keyword, Filter::string('match_mode', 'get'), 'admin_id');
     }
     if ($date_start && ($date_start = strtotime($date_start))) {
         $where['a.login_time'][] = array('EGT', $date_start);
     }
     if ($date_end && ($date_end = strtotime($date_end))) {
         $where['a.login_time'][] = array('ELT', $date_end);
     }
     if (isset($where['a.login_time']) && count($where['a.login_time']) == 1) {
         $where['a.login_time'] = $where['a.login_time'][0];
     }
     $where && $this->_model->join('JOIN ' . TB_ADMIN . ' AS b ON a.admin_id=b.admin_id');
     $total = $this->_model->alias('a')->where($where)->count();
     if ($total === false) {
         //查询出错
         $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('TOTAL_NUM,ERROR'));
     } elseif ($total == 0) {
         //无记录
         $this->_ajaxReturn(true, '', null, $total);
     }
     $page_info = Filter::page($total);
     $data = $this->_model->alias('a')->join('JOIN ' . TB_ADMIN . ' AS b ON a.admin_id=b.admin_id')->where($where)->field('a.*,b.username,b.realname,INET_NTOA(a.login_ip) AS login_ip')->limit($page_info['limit'])->order('' . $sort . ' ' . $order)->select();
     $data === false && $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('LIST,ERROR'));
     //出错
     $this->_ajaxReturn(true, '', $data, $total);
 }
Beispiel #6
0
 /**
  * 列表
  *
  * @author          mrmsl <*****@*****.**>
  * @lastmodify      2013-01-22 10:40:26 by mrmsl
  *
  * @return void 无返回值
  */
 public function listAction()
 {
     $sort = Filter::string('sort', 'get', $this->_pk_field);
     //排序字段
     $sort = in_array($sort, $this->_getDbFields()) ? $sort : $this->_pk_field;
     $order = !empty($_GET['dir']) ? Filter::string('dir', 'get') : Filter::string('order', 'get');
     //排序
     $order = toggle_order($order);
     $keyword = Filter::string('keyword', 'get');
     //关键字
     $date_start = Filter::string('date_start', 'get');
     //注册开始时间
     $date_end = Filter::string('date_end', 'get');
     //注册结束时间
     $log_type = Filter::int('log_type', 'get');
     //日志类型
     $where = $log_type != LOG_TYPE_ALL ? array('log_type' => $log_type) : array();
     if ($keyword !== '') {
         $where['content'] = $this->_buildMatchQuery('content', $keyword, Filter::string('match_mode', 'get'));
     }
     if ($date_start && ($date_start = strtotime($date_start))) {
         $where['log_time'][] = array('EGT', $date_start);
     }
     if ($date_end && ($date_end = strtotime($date_end))) {
         $where['log_time'][] = array('ELT', $date_end);
     }
     if (isset($where['log_time']) && count($where['log_time']) == 1) {
         $where['log_time'] = $where['log_time'][0];
     }
     $total = $this->_model->where($where)->count();
     if ($total === false) {
         //查询出错
         $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME_LOG') . L('TOTAL_NUM,ERROR'));
     } elseif ($total == 0) {
         //无记录
         $this->_ajaxReturn(true, '', null, $total);
     }
     $page_info = Filter::page($total);
     $data = $this->_model->where($where)->field('*,INET_NTOA(user_ip) AS user_ip')->limit($page_info['limit'])->order('' . $sort . ' ' . $order)->select();
     $data === false && $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME_LOG') . L('LIST,ERROR'));
     //出错
     $this->_ajaxReturn(true, '', $data, $total);
 }
Beispiel #7
0
 /**
  * 管理员列表
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2012-12-26 14:22:09
  * @lastmodify      2013-03-31 19:03:13 by mrmsl
  *
  * @return void 无返回值
  */
 public function listAction()
 {
     $db_fields = $this->_getDbFields();
     //表字段
     $sort = Filter::string('sort', 'get', $this->_pk_field);
     //排序字段
     $sort = in_array($sort, $db_fields) ? $sort : $this->_pk_field;
     $order = empty($_GET['dir']) ? Filter::string('order', 'get') : Filter::string('dir', 'get');
     //排序
     $order = toggle_order($order);
     $keyword = Filter::string('keyword', 'get');
     //关键字
     $date_start = Filter::string('date_start', 'get');
     //注册开始时间
     $date_end = Filter::string('date_end', 'get');
     //注册结束时间
     $cate_id = Filter::int('cate_id', 'get');
     //所属管理组
     $column = Filter::string('column', 'get');
     //搜索字段
     $is_delete = Filter::int('is_delete', 'get');
     //删除
     $is_issue = Filter::int('is_issue', 'get');
     //状态
     $where = array();
     if ($keyword !== '' && in_array($column, array('title', 'seo_keyword', 'seo_description', 'content', 'from_name', 'from_url'))) {
         $where['' . $column] = $this->_buildMatchQuery('' . $column, $keyword, Filter::string('match_mode', 'get'));
     }
     if ($date_start && ($date_start = strtotime($date_start))) {
         $where['add_time'][] = array('EGT', $date_start);
     }
     if ($date_end && ($date_end = strtotime($date_end))) {
         $where['add_time'][] = array('ELT', $date_end);
     }
     if (isset($where['add_time']) && count($where['add_time']) == 1) {
         $where['add_time'] = $where['add_time'][0];
     }
     if (-1 != $is_delete) {
         //删除
         $where['is_delete'] = $is_delete;
     }
     if (-1 != $is_issue) {
         //状态
         $where['is_issue'] = $is_issue;
     }
     if ($cate_id) {
         $cate_arr = $this->_getCache($cate_id, 'Category');
         if (!$cate_arr) {
             $this->_model->addLog(L("INVALID_PARAM,%:,BELONG_TO_CATEGORY,%cate_id({$cate_id}),NOT_EXIST"), LOG_TYPE_INVALID_PARAM);
             $this->_ajaxReturn(true);
         }
         $where['cate_id'] = array('IN', $this->_getChildrenIds($cate_id, true, true, 'Category'));
     }
     $total = $this->_model->where($where)->count();
     if ($total === false) {
         //查询出错
         $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME_BLOG') . L('TOTAL_NUM,ERROR'));
     } elseif ($total == 0) {
         //无记录
         $this->_ajaxReturn(true, '', null, $total);
     }
     $page_info = Filter::page($total);
     $data = $this->_model->where($where)->field('content', true)->limit($page_info['limit'])->order('' . $sort . ' ' . $order)->select();
     $data === false && $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME_BLOG') . L('LIST,ERROR'));
     //出错
     $cate_arr = $this->_getCache(false, 'Category');
     foreach ($data as &$v) {
         $v['cate_name'] = $cate_arr[$v['cate_id']]['cate_name'];
     }
     $this->_ajaxReturn(true, '', $data, $total);
 }
Beispiel #8
0
 /**
  * 列表
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2013-06-07 11:09:51
  *
  * @return void 无返回值
  */
 public function listAction()
 {
     $sort = Filter::string('sort', 'get', $this->_pk_field);
     //排序字段
     if (!in_array($sort, $this->_getDbFields())) {
         $log = __METHOD__ . ': ' . __LINE__ . ',' . L('QUERY,CONTROLLER_NAME,%。,ORDER,COLUMN') . $sort . L('NOT_EXIST');
         C('TRIGGER_ERROR', array($log));
         $this->_model->addLog($log, LOG_TYPE_INVALID_PARAM);
         $this->_ajaxReturn(false, L('SERVER_ERROR'));
     }
     $order = !empty($_GET['dir']) ? Filter::string('dir', 'get') : Filter::string('order', 'get');
     //排序
     $order = toggle_order($order);
     $keyword = Filter::string('keyword', 'get');
     //关键字
     $date_start = Filter::string('date_start', 'get');
     //开始时间
     $date_end = Filter::string('date_end', 'get');
     //结束时间
     $template_id = Filter::int('template_id', 'get');
     //
     $column = Filter::string('column', 'get');
     //搜索字段
     $where = array();
     if ('' !== $keyword && in_array($column, array('subject', 'content', 'email'))) {
         $where[$column] = $this->_buildMatchQuery($column, $keyword, Filter::string('match_mode', 'get'));
     }
     if ($date_start && ($date_start = strtotime($date_start))) {
         $where['add_time'][] = array('EGT', $date_start);
     }
     if ($date_end && ($date_end = strtotime($date_end))) {
         $where['add_time'][] = array('ELT', $date_end);
     }
     if (isset($where['add_time']) && count($where['add_time']) == 1) {
         $where['add_time'] = $where['add_time'][0];
     }
     if ($template_id) {
         $where['template_id'] = $template_id;
     }
     $total = $this->_model->where($where)->count();
     if ($total === false) {
         //查询出错
         $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('TOTAL_NUM,ERROR'));
     } elseif ($total == 0) {
         //无记录
         $this->_ajaxReturn(true, '', null, $total);
     }
     $page_info = Filter::page($total);
     $data = $this->_model->where($where)->limit($page_info['limit'])->order('' . $sort . ' ' . $order)->select();
     $data === false && $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('LIST,ERROR'));
     //出错
     $templates = $this->_getCache(false, 'Mail');
     foreach ($data as &$v) {
         $v['template_name'] = isset($templates[$id = $v['template_id']]) ? $templates[$id]['template_name'] : '';
     }
     $this->_ajaxReturn(true, '', $data, $total);
 }
 /**
  * 列表管理
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2012-12-28 16:45:42
  * @lastmodify      2013-01-22 10:48:23 by mrmsl
  *
  * @return void 无返回值
  */
 public function listAction()
 {
     $sort = Filter::string('sort', 'get', 'sort_order');
     //排序字段
     $order = empty($_GET['dir']) ? Filter::string('order', 'get') : Filter::string('dir', 'get');
     //排序
     $order = toggle_order($order);
     $keyword = Filter::string('keyword', 'get');
     //关键字
     $module_id = Filter::int('module_id', 'get');
     //所属模块
     $column = Filter::string('column', 'get');
     //搜索字段
     $where = array();
     if ($keyword !== '' && in_array($column, array('var_name', 'var_value_zh_cn', 'var_value_en'))) {
         $where['a.' . $column] = $this->_buildMatchQuery('a.' . $column, $keyword, Filter::string('match_mode', 'get'));
     }
     if ($module_id) {
         !$this->cache($module_id, 'LanguageModules') && $this->_ajaxReturn(true, '', array(), 0);
         $where['a.module_id'] = $module_id;
     }
     $total = $this->_model->alias('a')->where($where)->count();
     if ($total === false) {
         //查询出错
         $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('TOTAL_NUM,ERROR'));
     } elseif ($total == 0) {
         //无记录
         $this->_ajaxReturn(true, '', null, $total);
     }
     $page_info = Filter::page($total);
     $data = $this->_model->alias('a')->join('JOIN ' . TB_LANGUAGE_MODULES . ' AS m ON a.module_id=m.module_id')->where($where)->field('a.*,m.module_name')->limit($page_info['limit'])->order('a.' . $sort . ' ' . $order)->select();
     $data === false && $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('LIST,ERROR'));
     //出错
     $this->_ajaxReturn(true, '', $data, $total);
 }
Beispiel #10
0
 /**
  * 列表管理
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2012-08-01 16:53:52
  * @lastmodify      2013-01-22 10:29:43 by mrmsl
  *
  * @return void 无返回值
  */
 public function listAction()
 {
     $sort = Filter::string('sort', 'get', $this->_pk_field);
     //排序字段
     $sort = in_array($sort, $this->_getDbFields()) ? $sort : $this->_pk_field;
     $order = !empty($_GET['dir']) ? Filter::string('dir', 'get') : Filter::string('order', 'get');
     //排序
     $order = toggle_order($order);
     $column = Filter::string('column', 'get');
     //搜索字段
     $keyword = Filter::string('keyword', 'get');
     //搜索关键字
     $menu_id = Filter::int('menu_id', 'get');
     //所属菜单
     $is_enable = Filter::int('is_enable', 'get');
     //是否启用 by mrmsl on 2012-09-15 02:18:18
     $where = array();
     if ($menu_id) {
         //getChildrenIds($item_id, $include_self = true, $return_array = false, $filename = null, $level_field = 'level', $node_field = 'node') {
         $menu_id = $this->_getChildrenIds($menu_id, true, false, 'Menu');
         $menu_id ? $where['a.menu_id'] = array('IN', $menu_id) : '';
     }
     if ($keyword !== '' && in_array($column, array($this->_name_column, 'field_code', 'validate_rule', 'input_name'))) {
         $where['a.' . $column] = $this->_buildMatchQuery('a.' . $column, $keyword, Filter::string('match_mode', 'get'));
     }
     if ($is_enable != -1) {
         //启用状态 by mrmsl on 2012-09-15 02:20:43
         $where['a.is_enable'] = array('EQ', $is_enable);
     }
     $total = $this->_model->alias('a')->where($where)->count();
     if ($total === false) {
         //查询出错
         $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME_ADMIN') . L('TOTAL_NUM,ERROR'));
     } elseif ($total == 0) {
         //无记录
         $this->_ajaxReturn(true, '', null, $total);
     }
     $page_info = Filter::page($total);
     $data = $this->_model->alias('a')->join('JOIN ' . TB_MENU . ' AS m ON a.menu_id=m.menu_id')->where($where)->field('a.*,m.menu_name')->limit($page_info['limit'])->order('a.' . $sort . ' ' . $order)->select();
     $data === false && $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME_FIELD') . L('LIST,ERROR'));
     //出错
     $this->_ajaxReturn(true, '', $data, $total);
     //搜索
     if (!$field_id && $column && $keyword && in_array($column, array($this->_name_column, 'field_code', 'field_value'))) {
         $this->_queryTree($column, $keyword);
     } elseif ($field_id) {
         $this->_ajaxReturn(true, '', $this->_getTreeData($field_id, false));
     }
     $data = $this->_getCache(0, CONTROLLER_NAME . '_tree');
     $this->_ajaxReturn(true, '', $data, count($this->_getCache()));
 }
 /**
  * 管理员列表
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2012-12-26 14:22:09
  * @lastmodify      2013-03-31 19:03:13 by mrmsl
  *
  * @return void 无返回值
  */
 public function listAction()
 {
     $db_fields = $this->_getDbFields();
     //表字段
     $sort = Filter::string('sort', 'get', $this->_pk_field);
     //排序字段
     $sort = in_array($sort, $db_fields) ? $sort : $this->_pk_field;
     $sort = 'c.' . $sort;
     $order = empty($_GET['dir']) ? Filter::string('order', 'get') : Filter::string('dir', 'get');
     //排序
     $order = toggle_order($order);
     $keyword = Filter::string('keyword', 'get');
     //关键字
     $date_start = Filter::string('date_start', 'get');
     //添加开始时间
     $date_end = Filter::string('date_end', 'get');
     //添加结束时间
     $column = Filter::string('column', 'get');
     //搜索字段
     $type = Filter::int('type', 'get');
     //类型
     $status = Filter::int('auditing', 'get');
     //状态
     $reply_type = Filter::int('admin_reply_type', 'get');
     //回复状态
     $where = array();
     $column_arr = array('username' => 'c.username', 'email' => 'c.email', 'content' => 'c.content', 'blog_id' => 'c.blog_id', 'miniblog_id' => 'c.blog_id', 'blog_content' => 'b.content', 'blog_title' => 'b.title');
     if ($keyword !== '' && isset($column_arr[$column])) {
         $where[$column_arr[$column]] = $this->_buildMatchQuery($column_arr[$column], $keyword, Filter::string('match_mode', 'get'));
         if ('blog_content' == $column || 'blog_title' == $column) {
             $table = ' JOIN ' . TB_BLOG . ' AS b ON b.blog_id=c.blog_id';
         }
     }
     if ($date_start && ($date_start = strtotime($date_start))) {
         $where['c.add_time'][] = array('EGT', $date_start);
     }
     if ($date_end && ($date_end = strtotime($date_end))) {
         $where['c.add_time'][] = array('ELT', $date_end);
     }
     if (isset($where['c.add_time']) && count($where['c.add_time']) == 1) {
         $where['c.add_time'] = $where['c.add_time'][0];
     }
     if (-1 != $type) {
         //类型
         $where['c.type'] = $type;
     }
     if (-1 != $status) {
         //状态
         $where['c.status'] = $status;
     }
     if (-1 != $reply_type) {
         //回复状态
         $where['c.admin_reply_type'] = $reply_type;
     }
     isset($table) && $this->_model->join($table);
     $total = $this->_model->alias('c')->where($where)->count('c.blog_id');
     if ($total === false) {
         //查询出错
         $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('TOTAL_NUM,ERROR'));
     } elseif ($total == 0) {
         //无记录
         $this->_ajaxReturn(true, '', null, $total);
     }
     $page_info = Filter::page($total);
     isset($table) && $this->_model->join($table);
     $data = $this->_model->alias('c')->field('c.*,INET_NTOA(user_ip) AS user_ip')->where($where)->limit($page_info['limit'])->order('' . $sort . ' ' . $order)->select();
     $data === false && $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('LIST,ERROR'));
     //出错
     $selected = array(COMMENT_TYPE_BLOG => array(), COMMENT_TYPE_MINIBLOG => array());
     foreach ($data as $k => $v) {
         $type = $v['type'];
         $blog_id = $v['blog_id'];
         if (COMMENT_TYPE_BLOG == $type) {
             if (isset($selected[COMMENT_TYPE_BLOG][$blog_id])) {
                 $info = $selected[COMMENT_TYPE_BLOG][$blog_id];
             } else {
                 $info = $this->_model->table(TB_BLOG)->where('blog_id=' . $blog_id)->field('title,link_url')->find();
                 $selected[COMMENT_TYPE_BLOG][$blog_id] = $info;
             }
             $data[$k]['title'] = $info['title'];
             $data[$k]['link_url'] = $info['link_url'];
         } elseif (COMMENT_TYPE_MINIBLOG == $type) {
             if (isset($selected[COMMENT_TYPE_MINIBLOG][$blog_id])) {
                 $info = $selected[COMMENT_TYPE_MINIBLOG][$blog_id];
             } else {
                 $info = $this->_model->table(TB_MINIBLOG)->where('blog_id=' . $v['blog_id'])->field('add_time,link_url')->find();
                 $selected[COMMENT_TYPE_MINIBLOG][$blog_id] = $info;
             }
             $data[$k]['title'] = new_date('Y-m-d', $info['add_time']) . ' ' . L('MINIBLOG');
             $data[$k]['link_url'] = $info['link_url'];
         }
     }
     //end foreach
     $this->_ajaxReturn(true, '', $data, $total);
 }
Beispiel #12
0
 /**
  * 管理员列表
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2012-12-26 14:22:09
  * @lastmodify      2013-01-21 15:46:28 by mrmsl
  *
  * @return void 无返回值
  */
 public function listAction()
 {
     $db_fields = $this->_getDbFields();
     //表字段
     $db_fields = array_filter($db_fields, create_function('$v', 'return strpos($v, "_") !== 0;'));
     //过滤_开头
     $sort = Filter::string('sort', 'get', $this->_pk_field);
     //排序字段
     $sort = in_array($sort, $db_fields) || $sort == 'is_lock' ? $sort : $this->_pk_field;
     $order = empty($_GET['dir']) ? Filter::string('order', 'get') : Filter::string('dir', 'get');
     //排序
     $order = toggle_order($order);
     $keyword = Filter::string('keyword', 'get');
     //关键字
     $date_start = Filter::string('date_start', 'get');
     //注册开始时间
     $date_end = Filter::string('date_end', 'get');
     //注册结束时间
     $role_id = Filter::int('role_id', 'get');
     //所属管理组
     $column = Filter::string('column', 'get');
     //搜索字段
     $is_lock = Filter::int('is_lock', 'get');
     //锁定
     $is_restrict = Filter::int('is_restrict', 'get');
     //绑定登陆 by mrmsl on 2012-09-15 11:53:58
     $where = array();
     if ($keyword !== '' && in_array($column, array('username', 'realname'))) {
         $where['a.' . $column] = $this->_buildMatchQuery('a.' . $column, $keyword, Filter::string('match_mode', 'get'));
     }
     if ($date_start && ($date_start = strtotime($date_start))) {
         $where['a.add_time'][] = array('EGT', $date_start);
     }
     if ($date_end && ($date_end = strtotime($date_end))) {
         $where['a.add_time'][] = array('ELT', $date_end);
     }
     if (isset($where['a.add_time']) && count($where['a.add_time']) == 1) {
         $where['a.add_time'] = $where['a.add_time'][0];
     }
     if ($is_lock == 0) {
         //未锁定 by mrmsl on 2012-09-15 11:26:36
         $where['a.lock_end_time'] = array('ELT', APP_NOW_TIME);
     } elseif ($is_lock == 1) {
         //未锁定 by mrmsl on 2012-09-15 11:26:44
         $where['a.lock_start_time'] = array('ELT', APP_NOW_TIME);
         $where['a.lock_end_time'] = array('EGT', APP_NOW_TIME);
     }
     if ($role_id) {
         $where['a.role_id'] = $role_id;
     }
     if ($is_restrict == 0) {
         $where['a.is_restrict'] = $is_restrict;
     } elseif ($is_restrict == 1) {
         $where['a.is_restrict'] = $is_restrict;
     }
     $total = $this->_model->alias('a')->where($where)->count();
     if ($total === false) {
         //查询出错
         $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME_ADMIN') . L('TOTAL_NUM,ERROR'));
     } elseif ($total == 0) {
         //无记录
         $this->_ajaxReturn(true, '', null, $total);
     }
     $now = APP_NOW_TIME;
     $fields = str_replace(array(',a.password', ',a.mac_address', ',a.lock_start_time', ',a.lock_end_time', ',a.lock_memo'), '', join(',a.', $db_fields));
     $page_info = Filter::page($total);
     $data = $this->_model->alias('a')->join('JOIN ' . TB_ADMIN_ROLE . ' AS r ON a.role_id=r.role_id')->where($where)->field($fields . ',r.role_name,' . "(a.lock_start_time AND a.lock_start_time<{$now} AND a.lock_end_time AND a.lock_end_time>{$now}) AS is_lock")->limit($page_info['limit'])->order(($sort == 'is_lock' ? 'is_lock' : 'a.' . $sort) . ' ' . $order)->select();
     $data === false && $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME_ADMIN') . L('LIST,ERROR'));
     //出错
     $this->_ajaxReturn(true, '', $data, $total);
 }