|
楼主 |
发表于 2015-1-8 13:11:35
|
显示全部楼层
<?php
class Homes extends CI_Controller{
public function __construct()
{
parent::__construct();
$this->load->library('session');
$this->load->library('upload');
$this->load->helper('url');//引入地址辅助函数
$this->load->helper('html');//引入html辅助函数
$this->load->helper("form");
//引入表情辅助函数
$this->load->helper("smiley");
$this->load->model("note_model");//引入note_model数据模型
$this->load->model("show_member");
$this->load->model("show_question");
$this->load->model("show_book");
$this->load->model("show_tab");
$this->load->model("count_visit");
$this->load->model("check_model");
}
public function view($pages="content",$page_num=0,$tab=1)
{
$this->load->model("show_plugin");
//检测ip
$current_ip=$this->session->userdata("current_ip");
$your_ip=$this->input->ip_address();//获取当前ip
if(!$current_ip || $current_ip!==$your_ip)
{
$this->session->set_userdata("current_ip",$your_ip);
$this->count_visit->count_visit_num();
}
//检测ip end
$data['newnotes']=$this->note_model->view_newnotes();//新笔记
$data['hotnotes']=$this->note_model->view_hotnotes();//热门笔记
$data['newmember']=$this->note_model->view_new_member();//新成员
$data['question']=$this->show_question->show_new_question();//新问题
$data['book']=$this->show_book->show_hot_book();//热门书籍
$data['randnote']=$this->note_model->show_rand_note();//获取随机文章
$data['replymost']=$this->note_model->show_reply_most();//获取评论最多的文章
$data['tool']=$this->note_model->show_one_type(2);
$data['countnum']=$this->count_visit->count_all_num();//网站总统计
$data['tab']=$this->show_tab->show_tab_list();
$data["plugin"]=$this->show_plugin->show_all_plugin();
switch($pages)
{
case "about" :
$page_num=9;
break;
case "question" :
$page_num=9;
break;
case "tab" :
$tab_num=$page_num;
$page_num=9;
//分页start
$this->load->library("pagination");
$config['base_url']="http://www.webmasterfight.com/index.php/homes/view/tab/".$tab_num."/";
$config['total_rows']=200;
$config['per_page']=10;
$config['uri_segment']=5;//设置第几个参数为分页码
$config['use_page_numbers']=TRUE;
//包裹所有分页数字
$config['full_tag_open'] = '<div class="tab_full_box">';
$config['full_tag_close'] = '</div>';
//当前页
$config['cur_tag_open'] = '<strong class="tab_cur_tag">';
$config['cur_tag_close'] = '</strong>';
//数字链接
//$config['num_tag_open'] = '<li>';
//$config['num_tag_close'] = '<li>';
$config['first_link'] = '首页'; // 第一页显示
$config['last_link'] = '末页'; // 最后一页显示
$config['next_link'] = '下一页'; // 下一页显示
$config['prev_link'] = '上一页'; // 上一页显示
$this->pagination->initialize($config); //传递参数
//分页结束
$data["one_tab"]=$this->show_tab->show_one_tab($tab_num,$tab);
break;
case "notes" : $data["plugin"]=$this->show_plugin->show_all_plugin();break;
case "member" : $data["allmember"]=$this->show_member->show_all_member();break;
case "feedback" :
$data["new_feedback"]=$this->check_model->show_new_feedback();
break;
}
$data['num']=$page_num;
$id=$this->session->userdata('user_id');
//判断用户是否存在
if($id!=false)
{
$data['member']=$this->show_member->show_detail($id);
}
$this->load->view("templates/header",$data);
$this->load->view("home/".$pages,$data);
$this->load->view("templates/footer");
}
//问问页面
public function show_page($pages="ask",$num=1)
{
$data['num']=3;
date_default_timezone_set("Asia/ShangHai");
$date=date('Y-m-d');
$id=$this->session->userdata('user_id');
//判断用户是否登录
if($id!=false)
{
$data['member']=$this->show_member->show_detail($id);
}
else
{
$id=0;
}
$data['que_id']=$id;
//判断end
//导入分页的css样式
$css=array(
'href'=>base_url('css/page.css'),
'rel'=>'stylesheet'
);
echo link_tag($css);//导入css结束
//分页类
$per=20;
$this->load->library('pagination');
$config['base_url'] = 'http://www.webmasterfight.com/index.php/homes/show_page/ask/';
$config['uri_segment'] = 4;//从哪里获取你的分页数
$config['total_rows'] = $this->count_visit->count_question();//分页的数据总行数
$config['per_page'] = $per; //每页项目数量
$config['num_links']=2;
//包裹所有分页数字
$config['full_tag_open'] = '<div class="full_box">';
$config['full_tag_close'] = '</div>';
//当前页
$config['cur_tag_open'] = '<strong class="cur-tag">';
$config['cur_tag_close'] = '</strong>';
//数字链接
//$config['num_tag_open'] = '<li>';
//$config['num_tag_close'] = '<li>';
$config['first_link'] = '首页'; // 第一页显示
$config['last_link'] = '末页'; // 最后一页显示
$config['next_link'] = '下一页'; // 下一页显示
$config['prev_link'] = '上一页'; // 上一页显示
$config['use_page_numbers'] = TRUE;
$this->pagination->initialize($config); //传递参数
//分页结束
//获取当前页的问题
$data['questions']=$this->show_question->show_all_question($num,$per);
//获取今日问题数
$data['count_today']=$this->show_question->count_today_question($date);
//获取总数量
$this->load->view("templates/header",$data);
$this->load->view("home/".$pages,$data);
$this->load->view("templates/footer");
}
}
|
|