<?php
if ( ! defined('CSCMSPATH')) exit('No direct script access allowed');
class Sft_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->CsdjAdmin->Admin_Login(); //判断是否登入
			require_once PLUGINDIR.'sft/conxiu.php'; 
	        $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()

	{
	        $this->load->view('admin.tpl');
        }

public function xiu()

	{
		$this->CsdjAdmin->Admin_Login();
		   
		   $jinbi = $this->input->get_post('jinbi');


                $this->load->helper('file');
                //修改配置文件
	        $config=read_file(PLUGINDIR."/sft/conxiu.php");
			$config=preg_replace('/"jinbi","(.*?)"/','"jinbi","'.$jinbi.'"',$config);
			

	        if(!write_file(PLUGINDIR.'/sft/conxiu.php', $config)){
                      $this->CsdjAdmin->Admin_Url('<font color=red>文件'.PLUGINDIR.'/sft/conxiu.php，没有写入权限！</font>','javascript:history.back();');
                }else{
                      $this->CsdjAdmin->Admin_Url('<font color=#0000ff>恭喜您，修改成功！</font>',site_url('m/sft/admin'),'ok');
                }

               }


}
