<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Yun extends CI_Controller {

	function __construct(){
		    parent::__construct();
        	$this->load->helper('url');
            $this->load->library('session'); //加载session
		    $this->load->model('CsdjDB');
		    $this->load->model('CsdjAdmin');
		    $this->load->model('CsdjSkins');
	        $this->CsdjAdmin->Admin_Login();
            $this->load->helper('file');
			require_once CSCMSPATH.'lib/Cs_Sfyun.php';
	}


	public function index()
	{
            $this->load->view('admin/sfyun');
	}

	public function save()
	{

             $CS_Sf_Mode = intval($this->input->post('CS_Sf_Mode', TRUE));
		    $CS_Sf_Ak = $this->input->post('CS_Sf_Ak', TRUE);
		    $CS_Sf_Sk = $this->input->post('CS_Sf_Sk', TRUE);


           

            //修改文件
	        $strs="<?php"."\r\n";
			$strs.="define(\"CS_Sf_Mode\",".$CS_Sf_Mode.");  //开关  \r\n";
	        $strs.="define(\"CS_Sf_Ak\",\"".$CS_Sf_Ak."\"); //账户  \r\n";
	        $strs.="define(\"CS_Sf_Sk\",\"".$CS_Sf_Sk."\"); //密码  \r\n";

            //写文件
            if (!write_file('./csdj/lib/Cs_Sfyun.php', $strs)){
                $this->CsdjAdmin->Admin_Url('<font color=red>操作失败，文件没有写入权限！</font>',site_url('admin/yun'));
            }else{
                $this->CsdjAdmin->Admin_Url('<font color=#0000ff>恭喜您，修改成功！</font>',site_url('admin/yun'),'ok');
            }
	}
}
