<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Zan extends CI_Controller {

	function __construct(){
			    parent::__construct();
        	    $this->load->helper('url');
        	    $this->load->helper('form');
                $this->load->library('session'); //加载session
			    $this->load->model('CsdjDB');
			    $this->load->model('CsdjSkins');
			    $this->load->model('CsdjUser');
			    $this->CsdjUser->User_Login();
	}

	public function index()
	{
                $data='';
                $op = $this->input->get('op', TRUE); 
                $page = intval($this->input->get('page', TRUE));   //page
                if($page==0) $page=1;
				$data['op']=$op;
                        
                if($op=='my'){
                      $sqlstr="select * from ".CS_SqlPrefix."zan where CS_Userb='".$this->session->userdata('cs_name')."'";
                }else{
                      $sqlstr="select * from ".CS_SqlPrefix."zan where CS_Usera='".$this->session->userdata('cs_name')."'";
                }
                $sqlstr.=" order by CS_AddTime desc";
			    $Arr=$this->CsdjSkins->SpanUsersPage($sqlstr,10,10,'user/zan?op='.$op,$page);//sql,每页显示条数
			    $result=$this->CsdjDB->db->query($Arr[2]);
			    $data['zan']=$result->result();


                $this->load->get_user_templates();
			    $template=$this->load->view('zan-list.html',$data,true);
			    $template=$this->CsdjSkins->TopandBottom($template,'user');

			    $Mark_Text=str_replace("{cscms:title}","赞与被赞 - 会员管理中心",$template);
			    $Mark_Text=str_replace("{cscms:keywords}",stripslashes(html_entity_decode(Web_Keywords)),$Mark_Text);
			    $Mark_Text=str_replace("{cscms:description}",stripslashes(html_entity_decode(Web_Description)),$Mark_Text);
			    $Mark_Text=str_replace("[zan:op]",$op,$Mark_Text); //CID
		        $Mark_Text=str_replace("[user:op]","fansm",$Mark_Text);
			    $Mark_Text=$this->CsdjSkins->Page_Mark($Mark_Text,$Arr);	
	            $row=$this->CsdjDB->get_select ('user','CS_ID','*',''.$this->session->userdata('cs_id').'');
		        $Mark_Text=$this->CsdjUser->getuser($Mark_Text,$row);
		        $Mark_Text=$this->CsdjSkins->Common_Mark($Mark_Text,$this->session->userdata('cs_name'));
                $this->CsdjSkins->skins($Mark_Text,$data);
        }
}
