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

	function __construct(){
		    parent::__construct();
        	$this->load->helper('url');
	        $this->load->database();
            $this->load->library('session'); //加载session
	        $this->load->model('CsdjDB'); //加载数据操作模型
            $this->load->model('CsdjSkins'); //加载全局标签模型 
	        $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()
	{
	     
                $edit['cs_sflogo']=$this->input->post('cs_bgpic', TRUE);
				$sfzh=$this->input->post('cs_sfzh', TRUE);
				$edit['cs_sfdz']=$this->input->post('cs_sfdz', TRUE);
				$edit['cs_rzs']=1;
				
				$row=$this->db->query("SELECT CS_Logo,CS_Qianm,CS_Nichen,CS_Name,CS_RZID,CS_Sfzh FROM ".CS_SqlPrefix."user where cs_id='".$this->session->userdata('cs_id')."'")->row();
				if($row->CS_Sfzh!=$sfzh){
			
			
				$sql="SELECT CS_ID FROM ".CS_SqlPrefix."user where cs_sfzh='".$sfzh."'";
	        $rows=$this->CsdjDB->get_all($sql);
			if($rows){
			
			 $this->CsdjSkins->Msg_url('手机号已经认证，请更换手机号!',@$_SERVER['HTTP_REFERER']);
			 
			}else{
			$edit['cs_sfzh']=$sfzh;
			}
			
			}else{
			$edit['cs_sfzh']=$sfzh;
			}
			
				if($edit['cs_sfzh']==''){
                $this->CsdjSkins->Msg_url('手机/座机，不能为空!',@$_SERVER['HTTP_REFERER']); 
				}
				if($edit['cs_sfdz']==''){
                $this->CsdjSkins->Msg_url('居住地址不能为空!',@$_SERVER['HTTP_REFERER']); 
				}
				if($edit['cs_sflogo']==''){
                $this->CsdjSkins->Msg_url('身份证照片不能为空!',@$_SERVER['HTTP_REFERER']); 
				}
				
		if($row->CS_Rzid=1){
                $this->CsdjDB->get_update('user',$this->session->userdata('cs_id'),$edit);
                $this->CsdjSkins->Msg_url('恭喜您，修改成功!',@$_SERVER['HTTP_REFERER']); 
				}else{
				$this->CsdjSkins->Msg_url('已经认证，如修改请联系站长!',@$_SERVER['HTTP_REFERER']);
				} 
        }
		

	public function admin()
	{
              header("Location: ".site_url('m/sfpt/admin').""); 
        }
}
