<?php
if ( ! defined('CSCMSPATH')) exit('No direct script access allowed');
class Sfpt_Admin_module extends CI_Module {

	function __construct(){
		parent::__construct();
        	$this->load->helper('url');
	        $this->load->database();
	        $this->load->model('CsdjDB'); //加载数据操作模型
		$this->load->model('CsdjAdmin');
		$this->load->model('CsdjSkins');
	        $this->CsdjAdmin->Admin_Login(); //判断是否登入
	        $dir = $this->uri->segment(2);
                $sql="SELECT CS_SID FROM ".CS_SqlPrefix."plugins where cs_dir='".$dir."'";
	        $row=$this->CsdjDB->get_all($sql);
	        if($row){
                      if($row[0]->CS_SID==1){
                             $this->CsdjAdmin->Admin_Url('<font color=red>该插件尚未开启！</font>','javascript:history.back();');
                      }
                }else{
                      $this->CsdjAdmin->Admin_Url('<font color=red>该插件尚未安装！</font>','javascript:history.back();');
                }
	}

	public function index()
	{
 	    $sid = $this->input->get('sid');
 	    $page = $this->input->get('page');
            if(empty($page)) $page=1;

            
	          $sql_string = "SELECT * FROM ".CS_SqlPrefix."user where cs_rzid=0 and cs_rzs=1 order by CS_AddTime desc";
           
	    $query = $this->db->query($sql_string); 
	    $total = $query->num_rows();

            $base_url = site_url('m/sfpt/admin/')."?sid=".$sid;
	    $per_page = 20; 
            $totalPages = ceil($total / $per_page); // 总页数
	    $data['nums'] = $total;
            if($total<$per_page){
               $per_page=$total;
            }
            $sql_string.=' limit '. $per_page*($page-1) .','. $per_page;
	    $query = $this->db->query($sql_string);

	    $data['user'] = $query->result();
	    $data['pages'] = $this->CsdjAdmin->get_page($base_url,$totalPages,$page,10); //获取分页类
		
           $this->load->view('admin.php',$data);
			
        }
		public function userrz()
	{
            $this->CsdjAdmin->Admin_Qx('41');
	    $id = intval($this->input->get('id'));
	    $rzid = intval($this->input->get('rzid'));
            if($rzid==1){
                 $updata['CS_RZID']=0;
				 $updata['CS_RZS']=1;  
            }else{
 	         $updata['CS_RZID']=1;
			 $updata['CS_RZS']=0;
            }
            $this->CsdjDB->get_update ('user',$id,$updata);

               if($updata['CS_RZID']==0){
	               echo '<a href="javascript:;" title="点击取消认证" onClick="userrz(\''.site_url('m/sfpt/admin/userrz/').'\',0,'.$id.');return false"><font color=#ff0033>×</font></a>';
               }else{
	               echo '<a href="javascript:;" title="点击认证" onClick="userrz(\''.site_url('m/sfpt/admin/userrz/').'\',1,'.$id.');return false">√</a>';
               }
        }
}
