Example #1
0
 /**
  * Initialize Application
  * @param Configuration $configuration
  */
 public function __construct($configuration = null)
 {
     if ($configuration) {
         if (isset($configuration->database)) {
             Database::$configuration = new Object($configuration->database);
         }
         // initialize session if configured
         if (isset($configuration->session)) {
             $this->session = new Session($configuration->session);
         }
         // initialize language if configured
         if (isset($configuration->language)) {
             $this->language = new Language($configuration->language);
         }
         // initialize template if configured
         if (isset($configuration->template)) {
             $this->template = new Template($configuration->template);
         }
         // save pages json
         if (isset($configuration->pages)) {
             Page::$pages = (array) json_decode(file_get_contents($configuration->pages));
         }
         // save configuration
         Application::$configuration = $this->configuration = $configuration;
     }
 }
	public function index($page = 1)
	{
		$this->_adminTab = 'ManagePagesAdminTab';
		$this->pager = Page::pages(CoOrg::getLanguage());
		$this->pages = $this->pager->execute($page, 20);
		$this->render('admin/index');
	}
Example #3
0
 /**
  * @param array $pages
  * @param string $default
  */
 public static function init(array $pages = array(), $default = false)
 {
     self::$pages = $pages;
     if ($default !== false) {
         self::$default = $default;
     } elseif ($default === false && !empty(self::$pages)) {
         self::$default = self::$pages[0];
     } else {
         self::$default = false;
     }
 }
Example #4
0
	public static function listData($action, $language)
	{
		if ($action == 'show')
		{
			$pages = Page::pages($language);
			$menu = array();
			foreach ($pages->execute(0, 0) as $page)
			{
				$menu[$page->ID] = $page->title;
			}
			return $menu;
		}
		else
		{
			return null;
		}
	}
Example #5
0
 public function init()
 {
     $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
     $dirs = $application = $dirs_arr = $directory = array();
     $dirs = glob(APPS_PATH . '*');
     foreach ($dirs as $d) {
         if (is_dir($d)) {
             $d = basename($d);
             $dirs_arr[] = $d;
         }
     }
     //应用总数
     $total = count($dirs_arr);
     $dirs_arr = array_chunk($dirs_arr, 15, true);
     define('INSTALL', true);
     $applications = $this->db->key('application')->select();
     $pages = Page::pages($total, $page, 15);
     $directory = $dirs_arr[intval($page - 1)];
     include $this->view('application_list');
 }
Example #6
0
 public function lists()
 {
     $show_header = true;
     $commentid = isset($_GET['commentid']) && trim($_GET['commentid']) ? trim($_GET['commentid']) : showmessage(L('illegal_parameters'), HTTP_REFERER);
     $hot = isset($_GET['hot']) && intval($_GET['hot']) ? intval($_GET['hot']) : 0;
     $comment = $this->comment_db->getby_commentid($commentid);
     if (empty($comment)) {
         $forward = isset($_GET['show_center_id']) ? 'blank' : HTTP_REFERER;
         showmessage(L('no_comment'), $forward);
     }
     Loader::helper('comment:global');
     $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1;
     $pagesize = 20;
     $offset = ($page - 1) * $pagesize;
     $this->comment_data_db->table_name($comment['tableid']);
     $desc = 'id desc';
     if (!empty($hot)) {
         $desc = 'support desc, id desc';
     }
     $list = $this->comment_data_db->where(array('commentid' => $commentid, 'status' => 1))->order($desc)->limit($offset . ',' . $pagesize)->select();
     $pages = Page::pages($comment['total'], $page, $pagesize);
     include $this->view('comment_data_list');
 }
Example #7
0
 /**
  * 按照模型搜索
  */
 public function init()
 {
     $grouplist = S('member/grouplist');
     $_groupid = cookie('_groupid');
     if (empty($_groupid)) {
         $_groupid = 1;
     }
     if (!isset($grouplist[$_groupid]['allowsearch'])) {
         if ($_groupid == 1) {
             showmessage(L('guest_not_allowsearch'));
         } else {
             showmessage('');
         }
     }
     if (!isset($_GET['catid'])) {
         showmessage(L('missing_part_parameters'));
     }
     $catid = intval($_GET['catid']);
     $this->categorys = S('common/category_content');
     if (!isset($this->categorys[$catid])) {
         showmessage(L('missing_part_parameters'));
     }
     if (isset($_GET['info']['catid']) && $_GET['info']['catid']) {
         $catid = intval($_GET['info']['catid']);
     } else {
         $_GET['info']['catid'] = 0;
     }
     $modelid = $this->categorys[$catid]['modelid'];
     $modelid = intval($modelid);
     if (!$modelid) {
         showmessage(L('illegal_parameters'));
     }
     // 搜索间隔
     $minrefreshtime = S('common/common');
     $minrefreshtime = intval($minrefreshtime['minrefreshtime']);
     $minrefreshtime = $minrefreshtime ? $minrefreshtime : 5;
     if (cookie('search_cookie') && cookie('search_cookie') > TIME - 2) {
         showmessage(L('search_minrefreshtime', array('min' => $minrefreshtime)), 'index.php?app=content&controller=search&catid=' . $catid, $minrefreshtime * 1280);
     } else {
         cookie('search_cookie', TIME + 2);
     }
     // 搜索间隔
     $CATEGORYS = $this->categorys;
     // 产生表单
     $fields = S('model/model_field_' . $modelid);
     $forminfos = array();
     foreach ($fields as $field => $r) {
         if ($r['issearch']) {
             if ($r['formtype'] == 'catid') {
                 $r['form'] = Form::select_category('', $_GET['info']['catid'], 'name="info[catid]"', L('please_select_category'), $modelid, 0, 1);
             } elseif ($r['formtype'] == 'number') {
                 $r['form'] = "<input type='text' name='{$field}_start' id='{$field}_start' value='' size=5 class='input-text'/> - <input type='text' name='{$field}_end' id='{$field}_start' value='' size=5 class='input-text'/>";
             } elseif ($r['formtype'] == 'datetime') {
                 $r['form'] = Form::date("info[{$field}]");
             } elseif ($r['formtype'] == 'box') {
                 $options = explode("\n", $r['options']);
                 foreach ($options as $_k) {
                     $v = explode("|", $_k);
                     $option[$v[1]] = $v[0];
                 }
                 switch ($r['boxtype']) {
                     case 'radio':
                         $string = Form::radio($option, $value, "name='info[{$field}]' id='{$field}'");
                         break;
                     case 'checkbox':
                         $string = Form::radio($option, $value, "name='info[{$field}]' id='{$field}'");
                         break;
                     case 'select':
                         $string = Form::select($option, $value, "name='info[{$field}]' id='{$field}'");
                         break;
                     case 'multiple':
                         $string = Form::select($option, $value, "name='info[{$field}]' id='{$field}'");
                         break;
                 }
                 $r['form'] = $string;
             } elseif ($r['formtype'] == 'typeid') {
                 $types = S('common/type_content');
                 $types_array = array(L('no_limit'));
                 foreach ($types as $_k => $_v) {
                     if ($modelid == $_v['modelid']) {
                         $types_array[$_k] = $_v['name'];
                     }
                 }
                 $r['form'] = Form::select($types_array, 0, "name='info[{$field}]' id='{$field}'");
             } elseif ($r['formtype'] == 'linkage') {
                 $setting = string2array($r['setting']);
                 $value = $_GET['info'][$field];
                 $r['form'] = menu_linkage($setting['linkageid'], $field, $value);
             } elseif (in_array($r['formtype'], array('text', 'keyword', 'textarea', 'editor', 'title', 'author', 'omnipotent'))) {
                 $value = safe_replace($_GET['info'][$field]);
                 $r['form'] = "<input type='text' name='info[{$field}]' id='{$field}' value='" . $value . "' class='input-text search-text'/>";
             } else {
                 continue;
             }
             $forminfos[$field] = $r;
         }
     }
     // -----------
     if (isset($_GET['dosubmit'])) {
         $this->db->set_model($modelid);
         $tablename = $this->db->table_name;
         $page = max(intval($_GET['page']), 1);
         $sql = "SELECT * FROM `{$tablename}` a,`{$tablename}_data` b WHERE a.id=b.id AND a.status=99";
         $sql_count = "SELECT COUNT(*) AS num FROM `{$tablename}` a,`{$tablename}_data` b WHERE a.id=b.id AND a.status=99";
         // 构造搜索SQL
         $where = '';
         foreach ($fields as $field => $r) {
             if ($r['issearch']) {
                 $table_nickname = $r['issystem'] ? 'a' : 'b';
                 if ($r['formtype'] == 'catid') {
                     if ($_GET['info']['catid']) {
                         $where .= " AND {$table_nickname}.catid='{$catid}'";
                     }
                 } elseif ($r['formtype'] == 'number') {
                     $start = "{$field}_start";
                     $end = "{$field}_end";
                     if ($_GET[$start]) {
                         $start = intval($_GET[$start]);
                         $where .= " AND {$table_nickname}.{$field}>'{$start}'";
                     }
                     if ($_GET[$end]) {
                         $end = intval($_GET[$end]);
                         $where .= " AND {$table_nickname}.{$field}<'{$end}'";
                     }
                 } elseif ($r['formtype'] == 'datetime') {
                     if ($_GET['info'][$field]) {
                         $start = strtotime($_GET['info'][$field]);
                         if ($start) {
                             $where .= " AND {$table_nickname}.{$field}>'{$start}'";
                         }
                     }
                 } elseif ($r['formtype'] == 'box') {
                     if ($_GET['info'][$field]) {
                         $field_value = safe_replace($_GET['info'][$field]);
                         switch ($r['boxtype']) {
                             case 'radio':
                                 $where .= " AND {$table_nickname}.`{$field}`='{$field_value}'";
                                 break;
                             case 'checkbox':
                                 $where .= " AND {$table_nickname}.`{$field}` LIKE '%,{$field_value},%'";
                                 break;
                             case 'select':
                                 $where .= " AND {$table_nickname}.`{$field}`='{$field_value}'";
                                 break;
                             case 'multiple':
                                 $where .= " AND {$table_nickname}.`{$field}` LIKE '%,{$field_value},%'";
                                 break;
                         }
                     }
                 } elseif ($r['formtype'] == 'typeid') {
                     if ($_GET['info'][$field]) {
                         $typeid = intval($_GET['info'][$field]);
                         $where .= " AND {$table_nickname}.`{$field}`='{$typeid}'";
                     }
                 } elseif ($r['formtype'] == 'linkage') {
                     if ($_GET['info'][$field]) {
                         $linkage = intval($_GET['info'][$field]);
                         $where .= " AND {$table_nickname}.`{$field}`='{$linkage}'";
                     }
                 } elseif (in_array($r['formtype'], array('text', 'keyword', 'textarea', 'editor', 'title', 'author', 'omnipotent'))) {
                     if ($_GET['info'][$field]) {
                         $keywords = safe_replace($_GET['info'][$field]);
                         $where .= " AND {$table_nickname}.`{$field}` LIKE '%{$keywords}%'";
                     }
                 } else {
                     continue;
                 }
             }
         }
         // -----------
         if ($where == '') {
             showmessage(L('please_enter_content_to_search'));
         }
         $pagesize = 20;
         $offset = intval($pagesize * ($page - 1));
         $sql_count .= $where;
         $this->db->query($sql_count);
         $total = $this->db->fetch_array();
         $total = $total[0]['num'];
         if ($total != 0) {
             $sql .= $where;
             $order = '';
             $order = $_GET['orderby'] == 'a.id DESC' ? 'a.id DESC' : 'a.id ASC';
             $sql .= ' ORDER BY ' . $order;
             $sql .= " LIMIT {$offset},{$pagesize}";
             $this->db->query($sql);
             $datas = $this->db->fetch_array();
             $pages = Page::pages($total, $page, $pagesize);
         } else {
             $datas = array();
             $pages = '';
         }
     }
     $SEO = seo($catid, $keywords);
     include template('content', 'search');
 }
Example #8
0
 /**
  * 关键词搜索
  */
 public function init()
 {
     G('begin_time');
     // 搜索配置
     $setting = S('search/search');
     $search_model = S('search/search_model');
     $type_application = S('search/type_application');
     if (isset($_GET['q'])) {
         if (trim($_GET['q']) == '') {
             header('Location: ' . SITE_URL . 'index.php?app=search');
             exit;
         }
         $typeid = isset($_GET['typeid']) && $_GET['typeid'] > 0 ? intval($_GET['typeid']) : 1;
         $time = empty($_GET['time']) ? 'all' : trim($_GET['time']);
         $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
         $pagesize = 10;
         $q = safe_replace(trim($_GET['q']));
         $q = htmlspecialchars(strip_tags($q));
         $q = str_replace('%', '', $q);
         // 过滤'%',用户全文搜索
         $search_q = $q;
         // 搜索原内容
         // 按时间搜索
         $where = array();
         if ($time == 'day') {
             $search_time = TIME - 86400;
             $where['adddate'] = array('gt', $search_time);
         } elseif ($time == 'week') {
             $search_time = TIME - 604800;
             $where['adddate'] = array('gt', $search_time);
         } elseif ($time == 'month') {
             $search_time = TIME - 2592000;
             $where['adddate'] = array('gt', $search_time);
         } elseif ($time == 'year') {
             $search_time = TIME - 31536000;
             $where['adddate'] = array('gt', $search_time);
         } else {
             $search_time = 0;
         }
         if ($page == 1 && !$setting['sphinxenable']) {
             // 精确搜索
             if ($typeid != 0) {
                 $where['typeid'] = $typeid;
             }
             $where['data'] = array('like', "%{$q}%");
             $commend = $this->db->where($where)->find();
         } else {
             $commend = '';
         }
         // 如果开启sphinx
         if ($setting['sphinxenable']) {
             $sphinx = Loader::lib('search:search_interface', '', 0);
             $sphinx = new search_interface();
             $offset = $pagesize * ($page - 1);
             $res = $sphinx->search($q, array($typeid), array($search_time, TIME), $offset, $pagesize, '@weight desc');
             $totalnums = $res['total'];
             // 如果结果不为空
             if (!empty($res['matches'])) {
                 $result = $res['matches'];
             }
         } else {
             $segment = Loader::lib('Segment');
             // 分词结果
             $segment_q = $segment->get_keyword($segment->split_result($q));
             // 如果分词结果为空
             if (!empty($segment_q)) {
                 $sql = array();
                 $sql['typeid'] = $typeid;
                 $sql = array_merge($where, $sql);
                 $sql = $this->db->where($sql)->to_sql();
                 $sql = "{$sql} AND MATCH (`data`) AGAINST ('{$segment_q}' IN BOOLEAN MODE)";
             } else {
                 $sql = array();
                 $sql['typeid'] = $typeid;
                 $sql = array_merge($where, $sql);
                 $sql['data'] = array('like', "%{$q}%");
             }
             $result = $this->db->where($where)->order('searchid DESC')->listinfo($page, 10);
         }
         // 如果开启相关搜索功能
         if ($setting['relationenble']) {
             // 如果关键词长度在8-16之间,保存关键词作为relation search
             $this->keyword_db = loader::model('search_keyword_model');
             if (strlen($q) < 17 && strlen($q) > 5 && !empty($segment_q)) {
                 $res = $this->keyword_db->where(array('keyword' => $q))->find();
                 if ($res) {
                     // 关键词搜索数+1
                     $this->keyword_db->where(array('keyword' => $q))->update(array('searchnums' => '+=1'));
                 } else {
                     // 关键词转换为拼音
                     $pinyin = string_to_pinyin($q);
                     $this->keyword_db->insert(array('keyword' => $q, 'searchnums' => 1, 'data' => $segment_q, 'pinyin' => $pinyin));
                 }
             }
             // 相关搜索
             if (!empty($segment_q)) {
                 $relation_q = str_replace(' ', '%', $segment_q);
             } else {
                 $relation_q = $q;
             }
             $relation = $this->keyword_db->where("MATCH (`data`) AGAINST ('%{$relation_q}%' IN BOOLEAN MODE)")->order('searchnums DESC')->limit(10)->select();
         }
         // 如果结果不为空
         if (!empty($result) || !empty($commend['id'])) {
             // 开启sphinx后文章id取法不同
             if ($setting['sphinxenable']) {
                 foreach ($result as $_v) {
                     $sids[] = $_v['attrs']['id'];
                 }
             } else {
                 foreach ($result as $_v) {
                     $sids[] = $_v['id'];
                 }
             }
             if (!empty($commend['id'])) {
                 $sids[] = $commend['id'];
             }
             $sids = array_unique($sids);
             $ids = implode(',', $sids);
             $where = array('id' => array('in', $ids));
             // 获取模型id
             $model_type_cache = S('search/type_model');
             $model_type_cache = array_flip($model_type_cache);
             $modelid = $model_type_cache[$typeid];
             // 是否读取其他模块接口
             if ($modelid) {
                 $this->content_db->set_model($modelid);
                 if ($setting['sphinxenable']) {
                     $data = $this->content_db->where($where)->order('id DESC')->listinfo(1, $pagesize);
                     $pages = Page::pages($totalnums, $page, $pagesize);
                 } else {
                     $data = $this->content_db->where($where)->select();
                     $pages = $this->db->pages;
                     $totalnums = $this->db->number;
                 }
                 // 如果分词结果为空
                 if (!empty($segment_q)) {
                     $replace = explode(' ', $segment_q);
                     foreach ($replace as $replace_arr_v) {
                         $replace_arr[] = '<font color=red>' . $replace_arr_v . '</font>';
                     }
                     foreach ($data as $_k => $_v) {
                         $data[$_k]['title'] = str_replace($replace, $replace_arr, $_v['title']);
                         $data[$_k]['description'] = str_replace($replace, $replace_arr, $_v['description']);
                     }
                 } else {
                     foreach ($data as $_k => $_v) {
                         $data[$_k]['title'] = str_replace($q, '<font color=red>' . $q . '</font>', $_v['title']);
                         $data[$_k]['description'] = str_replace($q, '<font color=red>' . $q . '</font>', $_v['description']);
                     }
                 }
             } else {
                 // 读取专辑搜索接口
                 $special_api = Loader::lib('special:search_api');
                 $data = $special_api->get_search_data($sids);
             }
         }
         G('search_time');
         $pages = isset($pages) ? $pages : '';
         $totalnums = isset($totalnums) ? $totalnums : 0;
         $data = isset($data) ? $data : '';
         $execute_time = G('begin_time', 'search_time');
         include template('search', 'list');
     } else {
         include template('search', 'index');
     }
 }
Example #9
0
	public function testPages()
	{
		$pager = Page::pages('en');
		$pages = $pager->execute(1, 10);
		$this->assertEquals(3, count($pages));
		
		$this->assertEquals('aabbcc', $pages[0]->ID);
		$this->assertEquals('some-page', $pages[1]->ID);
		$this->assertEquals('tidelodoo', $pages[2]->ID);
		
		$pager = Page::pages('nl');
		$pages = $pager->execute(1, 10);
		$this->assertEquals(2, count($pages));
		
		$this->assertEquals('aabbcc', $pages[0]->ID);
		$this->assertEquals('tidelodoe', $pages[1]->ID);
	}
Example #10
0
 public function ajax()
 {
     $commentid =& $this->commentid;
     $num = isset($_GET['num']) && intval($_GET['num']) ? intval($_GET['num']) : 20;
     $yun_tag = Loader::lib('comment:comment_tag');
     $comment = array();
     if ($comment = $yun_tag->get_comment(array('commentid' => $commentid))) {
         $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1;
         $offset = ($page - 1) * $num;
         $data = array('commentid' => $commentid, 'limit' => $offset . ',' . $num, 'direction' => $direction);
         $comment['data'] = $yun_tag->lists($data);
         foreach ($comment['data'] as $k => $v) {
             $comment['data'][$k]['format_time'] = Format::date($v['creat_at'], 1);
         }
         $comment['pages'] = Page::pages($total, $page, $num, 'javascript:comment_next_page({$page})');
         if (CHARSET == 'gbk') {
             $comment = array_iconv($comment, 'gbk', 'utf-8');
         }
         echo json_encode($comment);
     } else {
         exit('0');
     }
 }
Example #11
0
 public static function init($items, $per_page = 25, $key = 'pg')
 {
     // load the class properties
     self::$key = $key;
     self::$perpage = $per_page;
     self::$items = $items;
     self::$query = $_GET;
     self::$script_url = self::current_url();
     // determine what page we are on
     foreach (explode('/', self::$script_url) as $segment) {
         list($pg, $num) = explode(':', $segment);
         if ($pg == $key && (int) $num > 0) {
             self::$current = (int) $num;
             break;
         }
     }
     if (self::$current <= 0) {
         self::$current = 1;
     }
     // run the page calculations
     self::$pages = self::$items > 0 ? (int) ceil(self::$items / $per_page) : 1;
     self::$offset = (self::$current - 1) * $per_page;
     // redirect to the first page if the page no. is out of range
     if (self::$current > self::$pages || self::$current < 1) {
         die(self::get_url(1));
         self::redirect(self::get_url(1));
     }
     // load the config file if present
     if (file_exists(APPPATH . 'config/pagination' . EXT)) {
         include APPPATH . 'config/pagination' . EXT;
         # enclosing markup
         if (isset($config['full_tag_open'])) {
             self::$full_tag_open = $config['full_tag_open'];
         }
         if (isset($config['full_tag_close'])) {
             self::$full_tag_close = $config['full_tag_close'];
         }
         # first link
         if (isset($config['first_link'])) {
             self::$first_link = $config['first_link'];
         }
         if (isset($config['first_tag_open'])) {
             self::$first_tag_open = $config['first_tag_open'];
         }
         if (isset($config['first_tag_close'])) {
             self::$first_tag_close = $config['first_tag_close'];
         }
         # last link
         if (isset($config['last_link'])) {
             self::$last_link = $config['last_link'];
         }
         if (isset($config['last_tag_open'])) {
             self::$last_tag_open = $config['last_tag_open'];
         }
         if (isset($config['last_tag_close'])) {
             self::$last_tag_close = $config['last_tag_close'];
         }
         # next link
         if (isset($config['next_link'])) {
             self::$next_link = $config['next_link'];
         }
         if (isset($config['next_tag_open'])) {
             self::$next_tag_open = $config['next_tag_open'];
         }
         if (isset($config['next_tag_close'])) {
             self::$next_tag_close = $config['next_tag_close'];
         }
         # previous link
         if (isset($config['prev_link'])) {
             self::$prev_link = $config['prev_link'];
         }
         if (isset($config['prev_tag_open'])) {
             self::$prev_tag_open = $config['prev_tag_open'];
         }
         if (isset($config['prev_tag_close'])) {
             self::$prev_tag_close = $config['prev_tag_close'];
         }
         # current page
         if (isset($config['cur_tag_open'])) {
             self::$cur_tag_open = $config['cur_tag_open'];
         }
         if (isset($config['cur_tag_close'])) {
             self::$cur_tag_close = $config['cur_tag_close'];
         }
         # digit link
         if (isset($config['num_tag_open'])) {
             self::$num_tag_open = $config['num_tag_open'];
         }
         if (isset($config['num_tag_close'])) {
             self::$num_tag_close = $config['num_tag_close'];
         }
     }
 }
Example #12
0
 /**
  * 广告统计
  */
 public function stat()
 {
     $_GET['id'] = intval($_GET['id']);
     $info = $this->db->field('spaceid')->where(array('id' => $_GET['id']))->find();
     if (!$_GET['id']) {
         showmessage(L('illegal_operation'));
     }
     /**
      * 如果设置了日期查询,设置查询的开始时间和结束时间
      */
     $sdb = Loader::model('poster_stat_model');
     // 调用广告统计的数据模型
     //$year =  $_GET ['year'] ;
     $year = date('Y', TIME);
     $month = date('m', TIME);
     $day = date('d', TIME);
     $group = $order = '';
     $fields = '*';
     $where = array('pid' => $_GET['id']);
     if (isset($_GET['range']) && $_GET['range'] == 2) {
         // 昨天的统计
         $fromtime = mktime(0, 0, 0, $month, $day - 2, $year);
         $totime = mktime(0, 0, 0, $month, $day - 1, $year);
         $where['clicktime'] = array('between', "{$fromtime},{$totime}");
     } elseif (isset($_GET['range']) && is_numeric($_GET['range'])) {
         // 如果设置了查询的天数
         $fromtime = mktime(0, 0, 0, $month, $day - $_GET['range'], $year);
         $where['clicktime'] = array('egt', $fromtime);
     }
     $order = 'clicktime DESC';
     // 如果设置了按点击、展示统计
     $_GET['click'] = isset($_GET['click']) ? intval($_GET['click']) : 0;
     if (is_numeric($_GET['click'])) {
         $_GET['click'] = intval($_GET['click']);
         $where['type'] = $_GET['click'];
         // 如果设置了按地区或者按ip分类
         if (isset($_GET['group'])) {
             $group = " `" . $_GET['group'] . "`";
             $fields = "*, COUNT(" . $_GET['group'] . ") AS num";
             $order = " `num` DESC";
         }
         $r = $sdb->field('COUNT(*) AS num')->where($where)->group($group)->find();
         // 取得总数
     } else {
         $r = $sdb->where($where)->find();
     }
     $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
     $curr_page = 20;
     $limit = ($page - 1) * $curr_page . ',' . $curr_page;
     $pages = Page::pages($r['num'], $page, 20);
     // 生成分页
     $data = $sdb->field($fields)->where($where)->order($order)->group($group)->limit($limit)->select();
     $selectstr = $sdb->get_list($year);
     // 取得历史查询下拉框,有历史数据查询时,会自动换表
     $show_header = true;
     unset($r);
     include $this->view('poster_stat');
 }
Example #13
0
 /**
  * 查询多条数据并分页
  *
  * @param $where 条件
  * @param $order 排序
  * @param $page 页码
  * @param $pagesize 每页数量
  * @param $key 返回数组按键名排序
  * @return array
  */
 public final function listinfo($page = 1, $pagesize = 20, $key = '', $setpages = 10, $urlrule = '', $array = array())
 {
     // ps:复制下数组 统计完总数后options会被清空,此处复制下放下面分页用
     $options = $this->options;
     // 获取总数
     $this->number = $this->count();
     $page = max(intval($page), 1);
     $offset = $pagesize * ($page - 1);
     $this->pages = Page::pages($this->number, $page, $pagesize, $urlrule, $array, $setpages);
     $array = array();
     if ($this->number > 0) {
         return $this->limit($offset, $pagesize)->select($options);
     } else {
         return array();
     }
 }
Example #14
0
        		<h5>最新下载</h5>
            <ul class="content news-photo col4 picbig">
            <?php 
if (defined('IN_ADMIN') && !defined('HTML')) {
    echo "<div class=\"admin_piao\" yun_action=\"content\" data=\"op=content&tag_md5=83d80f1bb2ed5822082f5424b8a9bded&do=lists&catid=%24catid&num=8&thumb=1&order=id+DESC&page=%24page\"><a href=\"javascript:void(0);\" class=\"admin_piao_edit\">编辑</a>";
}
$content_tag = Loader::lib("content:content_tag");
if (method_exists($content_tag, 'lists')) {
    $pagesize = 8;
    $page = isset($page) ? intval($page) : 1;
    if ($page <= 0) {
        $page = 1;
    }
    $offset = ($page - 1) * $pagesize;
    $content_total = $content_tag->count(array('catid' => $catid, 'thumb' => '1', 'order' => 'id DESC', 'limit' => $offset . "," . $pagesize, 'do' => 'lists'));
    $pages = Page::pages($content_total, $page, $pagesize, isset($urlrule) ? $urlrule : '');
    $data = $content_tag->lists(array('catid' => $catid, 'thumb' => '1', 'order' => 'id DESC', 'limit' => $offset . "," . $pagesize, 'do' => 'lists'));
}
?>
			<?php 
$n = 1;
if (is_array($data)) {
    foreach ($data as $r) {
        ?>
            	<li>
                    <div class="img-wrap"><a href="<?php 
        echo $r['url'];
        ?>
#"><img src="<?php 
        echo $r['thumb'];
        ?>
Example #15
0
<?php

if (Url::base(true) === 'https://local.jacmoe.dk') {
    $posts = Page::pages('datetime DESC', array('blogpost', '==', true));
} else {
    $posts = Page::pages('datetime DESC', array('published', '==', true));
}