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

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

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

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

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

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

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

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

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

	public function edit()
	{
                $this->CsdjAdmin->Admin_Qx('1');
		$Web_Name = $this->CsdjSkins->str_checkhtml($this->input->post('Web_Name', TRUE));
		$Web_Url = $this->CsdjSkins->str_checkhtml($this->input->post('Web_Url', TRUE));
		$Web_Path = $this->CsdjSkins->str_checkhtml($this->input->post('Web_Path', TRUE));
		$Admin_Code = $this->CsdjSkins->str_checkhtml($this->input->post('Admin_Code', TRUE));
		$Admin_Url = $this->CsdjSkins->str_checkhtml($this->input->post('Admin_Url'));
		$Web_Off = intval($this->input->post('Web_Off', TRUE));
		$Web_Onneir = $this->input->post('Web_Onneir', TRUE);
		$Web_Mode = intval($this->input->post('Web_Mode', TRUE));

		$Html_Index = $this->CsdjSkins->str_checkhtml($this->input->post('Html_Index', TRUE));
		$Html_Dindex = $this->CsdjSkins->str_checkhtml($this->input->post('Html_Dindex', TRUE));
		$Html_Nindex = $this->CsdjSkins->str_checkhtml($this->input->post('Html_Nindex', TRUE));
		$Html_Sindex = $this->CsdjSkins->str_checkhtml($this->input->post('Html_Sindex', TRUE));
		$Html_Vindex = $this->CsdjSkins->str_checkhtml($this->input->post('Html_Vindex', TRUE));
		$Html_Slist = $this->CsdjSkins->str_checkhtml($this->input->post('Html_Slist', TRUE));
		$Html_Sshow = $this->CsdjSkins->str_checkhtml($this->input->post('Html_Sshow', TRUE));
		$Html_Dlist = $this->CsdjSkins->str_checkhtml($this->input->post('Html_Dlist', TRUE));
		$Html_Dplay = $this->CsdjSkins->str_checkhtml($this->input->post('Html_Dplay', TRUE));
		$Html_Nlist = $this->CsdjSkins->str_checkhtml($this->input->post('Html_Nlist', TRUE));
		$Html_Nshow = $this->CsdjSkins->str_checkhtml($this->input->post('Html_Nshow', TRUE));
		$Html_Tlist = $this->CsdjSkins->str_checkhtml($this->input->post('Html_Tlist', TRUE));
		$Html_Tshow = $this->CsdjSkins->str_checkhtml($this->input->post('Html_Tshow', TRUE));
		$Html_Vlist = $this->CsdjSkins->str_checkhtml($this->input->post('Html_Vlist', TRUE));
		$Html_Vshow = $this->CsdjSkins->str_checkhtml($this->input->post('Html_Vshow', TRUE));
		$Html_StopTime = $this->CsdjSkins->str_checkhtml($this->input->post('Html_StopTime', TRUE));

		$Web_Icp = $this->CsdjSkins->str_checkhtml($this->input->post('Web_Icp', TRUE));
		$Admin_QQ = $this->CsdjSkins->str_checkhtml($this->input->post('Admin_QQ', TRUE));
		$Admin_Tel = $this->CsdjSkins->str_checkhtml($this->input->post('Admin_Tel', TRUE));
		$Admin_Mail = $this->CsdjSkins->str_checkhtml($this->input->post('Admin_Mail', TRUE));
		$Web_Key = $this->CsdjSkins->str_checkhtml($this->input->post('Web_Key', TRUE));
		$Web_Count = $_POST['Web_Count'];
		$Web_Title = $this->input->post('Web_Title');
		$Web_Keywords = $this->input->post('Web_Keywords');
		$Web_Description = $this->input->post('Web_Description');
		$Web_Notice = $this->input->post('Web_Notice');
		$Skins_dir = $this->CsdjSkins->str_checkhtml($this->input->post('Skins_dir', TRUE));
		$Skins_home_dir = $this->CsdjSkins->str_checkhtml($this->input->post('Skins_home_dir', TRUE));
		$Skins_user_dir = $this->CsdjSkins->str_checkhtml($this->input->post('Skins_user_dir', TRUE));
		$Pl_Modes = intval($this->input->post('Pl_Modes', TRUE));
		$Pl_Num = intval($this->input->post('Pl_Num', TRUE));
		$Pl_Str = $this->input->post('Pl_Str', TRUE);
		$Cache_Is = $this->CsdjSkins->str_checkhtml($this->input->post('Cache_Is', TRUE));
		$Cache_Time = intval($this->input->post('Cache_Time', TRUE));
		$Cache_Name = $this->CsdjSkins->str_checkhtml($this->input->post('Cache_Name', TRUE));
		$CS_Play_w = intval($this->input->post('CS_Play_w', TRUE));
		$CS_Play_h = intval($this->input->post('CS_Play_h', TRUE));
		$CS_Play_sw = intval($this->input->post('CS_Play_sw', TRUE));
		$CS_Play_sh = intval($this->input->post('CS_Play_sh', TRUE));
		$CS_Play_AdloadTime = intval($this->input->post('CS_Play_AdloadTime', TRUE));
		$Html_Wjt = $this->input->post('Html_Wjt');


                if(empty($Skins_dir))          $Skins_dir="index/default/html/";
                if(empty($Skins_home_dir))     $Skins_home_dir="home/default/html/";
                if(empty($Skins_user_dir))     $Skins_user_dir="user/default/html/";

                if($Html_StopTime==0)      $Html_StopTime=1;
                if($Pl_Num==0)             $Pl_Num=10;
                if($Cache_Time==0)         $Cache_Time=600;
                if($CS_Play_w==0)          $CS_Play_w=445;
                if($CS_Play_h==0)          $CS_Play_h=64;
                if($CS_Play_sw==0)         $CS_Play_sw=600;
                if($CS_Play_sh==0)         $CS_Play_sh=450;
                if($CS_Play_AdloadTime==0) $CS_Play_AdloadTime=10;


                //HTML转码
                $Web_Onneir= str_replace('"',"'",$Web_Onneir); 
                $Web_Title= str_replace('"',"'",$Web_Title); 
                $Web_Keywords= str_replace('"',"'",$Web_Keywords); 
                $Web_Description= str_replace('"',"'",$Web_Description); 
                $Web_Notice= str_replace('"',"'",$Web_Notice); 
		        $Web_Count= str_replace('"',"'",$Web_Count); 

                //判断静态URL地址正确
                if($Web_Mode==3){
                     if ((strpos($Html_Slist,'{sort}')<1 || strpos($Html_Slist,'{page}')<1) || (strpos($Html_Slist,'{id}')<1 && strpos($Html_Slist,'{aliasname}')<1)){      
                            $this->CsdjAdmin->Admin_Url('<font color=red>操作失败，歌手列表URL里面必须包含 {sort}  {id}  {page}</font>',site_url('admin/setting/'));
                     } 
                     if (strpos($Html_Sshow,'{id}')<1 || strpos($Html_Sshow,'{page}')<1){
                            $this->CsdjAdmin->Admin_Url('<font color=red>操作失败，歌手内容URL里面必须包含 {id}  {page}</font>',site_url('admin/setting/'));
                     }
                     if ((strpos($Html_Dlist,'{sort}')<1 || strpos($Html_Dlist,'{page}')<1) || (strpos($Html_Dlist,'{id}')<1 && strpos($Html_Dlist,'{aliasname}')<1)){      
                            $this->CsdjAdmin->Admin_Url('<font color=red>操作失败，歌曲分类URL里面必须包含 {sort}  {id}  {page}</font>',site_url('admin/setting/'));
                     }
                     if (strpos($Html_Dplay,'{id}')<1){
                            $this->CsdjAdmin->Admin_Url('<font color=red>操作失败，歌曲播放URL里面必须包含 {id}</font>',site_url('admin/setting/'));
                     }
                     if ((strpos($Html_Vlist,'{sort}')<1 || strpos($Html_Vlist,'{page}')<1) || (strpos($Html_Vlist,'{id}')<1 && strpos($Html_Vlist,'{aliasname}')<1)){      
                            $this->CsdjAdmin->Admin_Url('<font color=red>操作失败，视频分类URL里面必须包含 {sort}  {id}  {page}</font>',site_url('admin/setting/'));
                     }
                     if (strpos($Html_Vshow,'{id}')<1){
                            $this->CsdjAdmin->Admin_Url('<font color=red>操作失败，视频内容URL里面必须包含 {id} </font>',site_url('admin/setting/'));
                     }
                     if ((strpos($Html_Nlist,'{sort}')<1 || strpos($Html_Nlist,'{page}')<1) || (strpos($Html_Nlist,'{id}')<1 && strpos($Html_Nlist,'{aliasname}')<1)){      
                            $this->CsdjAdmin->Admin_Url('<font color=red>操作失败，文章列表URL里面必须包含 {sort}  {id}  {page}</font>',site_url('admin/setting/'));
                     }
                     if (strpos($Html_Nshow,'{id}')<1){
                            $this->CsdjAdmin->Admin_Url('<font color=red>操作失败，文章内容URL里面必须包含 {id}</font>',site_url('admin/setting/'));
                     }
                     if (strpos($Html_Tlist,'{sort}')<1 || strpos($Html_Tlist,'{page}')<1){
                            $this->CsdjAdmin->Admin_Url('<font color=red>操作失败，专集列表URL里面必须包含 {sort}  {page}</font>',site_url('admin/setting/'));
                     }
                     if ((strpos($Html_Tlist,'{sort}')<1 || strpos($Html_Tshow,'{id}')<1) && (strpos($Html_Tshow,'{aliasname}')<1) || (strpos($Html_Tshow,'{page}')<1)){
                            $this->CsdjAdmin->Admin_Url('<font color=red>操作失败，专集内容URL里面必须包含 {sort} {id}  {page}</font>',site_url('admin/setting/'));
                     }
                }

                //判断缓存目录
                if($Cache_Name!=Cache_Name){
		     if(file_exists("./cache/".Cache_Name."/")){
			if(!rename("./cache/".Cache_Name,"./cache/".$Cache_Name)){
                             $this->CsdjAdmin->Admin_Url('<font color=red>操作失败，".Cache_Name."文件夹没有修改权限！</font>',site_url('admin/setting/'));
                        }
		     }else{
			@mkdir("./cache/".$Cache_Name);
		     }
                }

	        $strs="<?php"."\r\n";
	        $strs.="define(\"Web_Name\",\"".$Web_Name."\"); //站点名称  \r\n";
	        $strs.="define(\"Web_Url\",\"".$Web_Url."\"); //站点域名  \r\n";
	        $strs.="define(\"Web_Path\",\"".$Web_Path."\"); //站点路径  \r\n";
	        $strs.="define(\"Admin_Code\",\"".$Admin_Code."\");  //后台验证码  \r\n";
	        $strs.="define(\"Admin_Url\",\"".$Admin_Url."\");  //后台访问域名，留空为取消   \r\n";
	        $strs.="define(\"Web_Off\",".$Web_Off.");  //网站开关  \r\n";
	        $strs.="define(\"Web_Onneir\",\"".$Web_Onneir."\");  //网站关闭内容  \r\n";
	        $strs.="define(\"Web_Mode\",".$Web_Mode.");  //网站运行模式  \r\n";
	        $strs.="define(\"Html_Wjt\",\"".$Html_Wjt."\");  //伪静态模式  \r\n";
	        $strs.="define(\"Html_Index\",\"".$Html_Index."\");  //主页静态URL  \r\n";
	        $strs.="define(\"Html_Dindex\",\"".$Html_Dindex."\");  //静态舞曲主页  \r\n";
	        $strs.="define(\"Html_Nindex\",\"".$Html_Nindex."\");  //静态文章主页  \r\n";
	        $strs.="define(\"Html_Sindex\",\"".$Html_Sindex."\");  //静态歌手主页  \r\n";
	        $strs.="define(\"Html_Vindex\",\"".$Html_Vindex."\");  //视频歌手主页  \r\n";
	        $strs.="define(\"Html_Slist\",\"".$Html_Slist."\");  //静态专歌手表模式  \r\n";
	        $strs.="define(\"Html_Sshow\",\"".$Html_Sshow."\");  //静态歌手内容模式  \r\n";
	        $strs.="define(\"Html_Dlist\",\"".$Html_Dlist."\");  //静态舞曲分类模式  \r\n";
	        $strs.="define(\"Html_Dplay\",\"".$Html_Dplay."\");  //静态舞曲播放模式  \r\n";
	        $strs.="define(\"Html_Nlist\",\"".$Html_Nlist."\");  //静态文章分类模式  \r\n";
	        $strs.="define(\"Html_Nshow\",\"".$Html_Nshow."\");  //静态文章内容模式  \r\n";
	        $strs.="define(\"Html_Tlist\",\"".$Html_Tlist."\");  //静态专集列表模式  \r\n";
	        $strs.="define(\"Html_Tshow\",\"".$Html_Tshow."\");  //静态专集内容模式  \r\n";
	        $strs.="define(\"Html_Vlist\",\"".$Html_Vlist."\");  //静态视频分类模式  \r\n";
	        $strs.="define(\"Html_Vshow\",\"".$Html_Vshow."\");  //静态频内容模式  \r\n";
	        $strs.="define(\"Html_StopTime\",".$Html_StopTime.");  //生成间隔秒数  \r\n";

	        $strs.="define(\"Web_Icp\",\"".$Web_Icp."\");  //网站ICP  \r\n";
	        $strs.="define(\"Admin_QQ\",\"".$Admin_QQ."\");  //站长QQ  \r\n";
	        $strs.="define(\"Admin_Tel\",\"".$Admin_Tel."\");  //站长电话  \r\n";
	        $strs.="define(\"Admin_Mail\",\"".$Admin_Mail."\");  //站长EMAIL  \r\n";
	        $strs.="define(\"Web_Key\",\"".$Web_Key."\");  //热门搜索  \r\n";
	        $strs.="define(\"Web_Count\",\"".$Web_Count."\");  //统计代码  \r\n";
	        $strs.="define(\"Web_Title\",\"".$Web_Title."\"); //SEO-标题  \r\n";
	        $strs.="define(\"Web_Keywords\",\"".$Web_Keywords."\"); //SEO-Keywords  \r\n";
	        $strs.="define(\"Web_Description\",\"".$Web_Description."\"); //SEO-description  \r\n";
	        $strs.="define(\"Web_Notice\",\"".$Web_Notice."\");  //网站公告  \r\n";

	        $strs.="define(\"Skins_dir\",\"".$Skins_dir."\"); //默认网站摸班目录  \r\n";
	        $strs.="define(\"Skins_home_dir\",\"".$Skins_home_dir."\"); //默认会员主页摸班目录  \r\n";
	        $strs.="define(\"Skins_user_dir\",\"".$Skins_user_dir."\"); //默认会员中心摸班目录  \r\n";
	        $strs.="define(\"Pl_Modes\",".$Pl_Modes.");  //评论方式  \r\n";
	        $strs.="define(\"Pl_Num\",".$Pl_Num.");  //评论每页条数  \r\n";
	        $strs.="define(\"Pl_Str\",\"".$Pl_Str."\");  //评论过滤字符  \r\n";

	        $strs.="define(\"Cache_Is\",".$Cache_Is.");  //缓存开关  \r\n";
	        $strs.="define(\"Cache_Time\",".$Cache_Time.");  //缓存时间  \r\n";
	        $strs.="define(\"Cache_Name\",\"".$Cache_Name."\");  //缓存目录  \r\n";

	        $strs.="define(\"CS_Play_w\",".$CS_Play_w.");    \r\n";
	        $strs.="define(\"CS_Play_h\",".$CS_Play_h.");    \r\n";
	        $strs.="define(\"CS_Play_sw\",".$CS_Play_sw.");    \r\n";
	        $strs.="define(\"CS_Play_sh\",".$CS_Play_sh.");    \r\n";
	        $strs.="define(\"CS_Play_AdloadTime\",".$CS_Play_AdloadTime."); //广告时间    \r\n";


                //=========================生成伪静态规则========================
                if($Web_Mode==2){
                    if($Html_Wjt=="httpd.ini"){
                        //生成httpd.ini伪静态规则
                        $strsst="[ISAPI_Rewrite]    \r\n";
	                $strsst.="# 3600 = 1 hour    \r\n";
	                $strsst.="CacheClockRate 3600    \r\n";
	                $strsst.="RepeatLimit 32    \r\n\r\n";
                        $strss="# 版区主页伪静态    \r\n";
	                $strss.="RewriteRule ".Web_Path."gbook$ ".Web_Path."index.php/gbook    \r\n";
	                $strss.="RewriteRule ".Web_Path."user$ ".Web_Path."index.php/user    \r\n";
	                $strss.="RewriteRule ".Web_Path."page(.*)$ ".Web_Path."index.php/page$1    \r\n";
	                $strss.="RewriteRule ".Web_Path."opt(.*)$ ".Web_Path."index.php/opt$1    \r\n\r\n";

                        $strss.="# 歌曲伪静态    \r\n";
	                $strss.="RewriteRule ".Web_Path."dance(.*)$ ".Web_Path."index.php/dance$1    \r\n";
                        $strss.="# 歌手伪静态    \r\n";
	                $strss.="RewriteRule ".Web_Path."singer(.*)$ ".Web_Path."index.php/singer$1    \r\n";
                        $strss.="# 视频伪静态    \r\n";
	                $strss.="RewriteRule ".Web_Path."vod(.*)$ ".Web_Path."index.php/vod$1    \r\n";
                        $strss.="# 文章伪静态    \r\n";
	                $strss.="RewriteRule ".Web_Path."news(.*)$ ".Web_Path."index.php/news$1    \r\n";
                        $strss.="# 专集伪静态    \r\n";
	                $strss.="RewriteRule ".Web_Path."topic/(.*)$ ".Web_Path."index.php/zj/$1    \r\n";
	                $strss.="RewriteRule ".Web_Path."zj/(.*)$ ".Web_Path."index.php/zj/$1    \r\n";

                        $strss_yl=read_file('./httpd.ini');
                        if(!empty($strss_yl)){ 
                              if(strpos($strss_yl,'歌曲伪静态') === FALSE){
                                   $httpd=$strss_yl."    \r\n";
                                   $httpd.=$strss;
                              }else{
                                   $httpd=$strss_yl;
                              }
                        }else{
                                   $httpd=$strsst.$strss;
                        }
                        write_file('./httpd.ini', $httpd);
                    }

                    if($Html_Wjt==".htaccess"){
                        //生成.htaccess伪静态规则
                        $strssst="RewriteEngine On    \r\n";
	                $strssst.="# 安装目录路径    \r\n";
                        $strssst.="RewriteBase ".Web_Path."    \r\n";

	                $strsss="RewriteRule ^gbook$ ".Web_Path."index.php/gbook    \r\n";
	                $strsss.="RewriteRule ^user$ ".Web_Path."index.php/user    \r\n";
	                $strsss.="RewriteRule ^page(.*)$ ".Web_Path."index.php/page$1    \r\n";
	                $strsss.="RewriteRule ^opt(.*)$ ".Web_Path."index.php/opt$1    \r\n\r\n";

                        $strsss.="# 歌曲伪静态    \r\n";
	                $strsss.="RewriteRule ^dance(.*)$ ".Web_Path."index.php/dance$1    \r\n";
                        $strsss.="# 歌手伪静态    \r\n";
	                $strsss.="RewriteRule ^singer(.*)$ ".Web_Path."index.php/singer$1    \r\n";
                        $strsss.="# 视频伪静态    \r\n";
	                $strsss.="RewriteRule ^vod(.*)$ ".Web_Path."index.php/vod$1    \r\n";
                        $strsss.="# 文章伪静态    \r\n";
	                $strsss.="RewriteRule ^news(.*)$ ".Web_Path."index.php/news$1    \r\n";
                        $strsss.="# 专集伪静态    \r\n";
	                $strsss.="RewriteRule ^topic/(.*)$ ".Web_Path."index.php/zj/$1    \r\n";
	                $strsss.="RewriteRule ^zj/(.*)$ ".Web_Path."index.php/zj/$1    \r\n";

                        $strss_yl=read_file('./.htaccess');
                        if(!empty($strss_yl)){ 
                              if(strpos($strss_yl,'歌曲伪静态') === FALSE){
                                   $htaccess=$strss_yl."    \r\n";
                                   $htaccess.=$strsss;
                              }else{
                                   $htaccess=$strss_yl;
                              }
                        }else{
                                   $htaccess=$strssst.$strsss;
                        }
                        write_file('./.htaccess', $htaccess);
                    }

                    if($Html_Wjt=="nginx.conf"){
                        //生成nginx.conf伪静态规则
                        $strsssst="location ".Web_Path." {    \r\n\r\n";

	                $strssss="rewrite ^([^\.]*)".Web_Path."gbook$ ".Web_Path."index.php/gbook    \r\n";
	                $strssss.="rewrite ^([^\.]*)".Web_Path."user$ ".Web_Path."index.php/user    \r\n";
	                $strssss.="rewrite ^([^\.]*)".Web_Path."page(.*)$ ".Web_Path."index.php/page$1    \r\n";
	                $strssss.="rewrite ^([^\.]*)".Web_Path."opt(.*)$ ".Web_Path."index.php/opt$1    \r\n\r\n";

                        $strssss.="# 歌曲伪静态    \r\n";
	                $strssss.="rewrite ^([^\.]*)".Web_Path."dance(.*)$ ".Web_Path."index.php/dance$1   \r\n";
                        $strssss.="# 歌手伪静态    \r\n";
	                $strssss.="rewrite ^([^\.]*)".Web_Path."singer(.*)$ ".Web_Path."index.php/singer$1   \r\n";
                        $strssss.="# 视频伪静态    \r\n";
	                $strssss.="rewrite ^([^\.]*)".Web_Path."vod(.*)$ ".Web_Path."index.php/vod$1   \r\n";
                        $strssss.="# 文章伪静态    \r\n";
	                $strssss.="rewrite ^([^\.]*)".Web_Path."news(.*)$ ".Web_Path."index.php/news$1   \r\n";
                        $strssss.="# 专集伪静态    \r\n";
	                $strssss.="rewrite ^([^\.]*)".Web_Path."topic/(.*)$ ".Web_Path."index.php/zj/$1   \r\n";
	                $strssss.="rewrite ^([^\.]*)".Web_Path."zj/(.*)$ ".Web_Path."index.php/zj/$1    \r\n\r\n";
	                $strssss.="}    \r\n";

                        $strss_yl=read_file('./.nginx.conf');
                        if(!empty($strss_yl)){ 
                              if(strpos($strss_yl,'歌曲伪静态') === FALSE){
                                   $nginx=$strss_yl."    \r\n";
                                   $nginx.=$strssss;
                              }else{
                                   $nginx=$strss_yl;
                              }
                        }else{
                                   $nginx=$strsssst.$strssss;
                        }
                        write_file('./nginx.conf', $nginx);
                    }
                }

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

	public function dbcacheedit()
	{
                $this->CsdjAdmin->Admin_Qx('2');
		$CS_Cache_On = $this->input->post('CS_Cache_On', TRUE);
		$CS_Cache_Time = intval($this->input->post('CS_Cache_Time', TRUE));
		$CS_Cache_Dir = $this->CsdjSkins->str_checkhtml($this->input->post('CS_Cache_Dir', TRUE));

                if($CS_Cache_Time==0) $CS_Cache_Time=600;
                if(empty($CS_Cache_Dir))  $CS_Cache_Dir="data";
                if($CS_Cache_On!="FALSE") $CS_Cache_On="TRUE";


                //判断缓存目录
                if($CS_Cache_Dir!=CS_Cache_Dir){
		     if(file_exists("./cache/".CS_Cache_Dir."/")){
			if(!rename("./cache/".CS_Cache_Dir,"./cache/".$CS_Cache_Dir)){
                             $this->CsdjAdmin->Admin_Url('<font color=red>操作失败，".CS_Cache_Dir."文件夹没有修改权限！</font>',site_url('admin/setting/dbcache/'));
                        }
		     }else{
			@mkdir("./cache/".$CS_Cache_Dir);
		     }
                }

                //修改文件
	        $dbneir=read_file('./csdj/lib/Cs_DB.php');
	        $dbneir=preg_replace('/"CS_Cache_On",(.*?)\)/','"CS_Cache_On",'.$CS_Cache_On.')',$dbneir);
	        $dbneir=preg_replace('/"CS_Cache_Dir","(.*?)"/','"CS_Cache_Dir","'.$CS_Cache_Dir.'"',$dbneir);
	        $dbneir=preg_replace('/"CS_Cache_Time",(.*?)\)/','"CS_Cache_Time",'.$CS_Cache_Time.')',$dbneir);
                //写文件
                if (!write_file('./csdj/lib/Cs_DB.php', $dbneir)){
                          $this->CsdjAdmin->Admin_Url('<font color=red>操作失败，文件没有写入权限！</font>',site_url('admin/setting/dbcache/'));
                }else{
                          $this->CsdjAdmin->Admin_Url('<font color=#0000ff>恭喜您，修改成功！</font>',site_url('admin/setting/dbcache/'),'ok');
                }
        }

        //修改EMAIL配置
	public function emailedit()
	{
                $this->CsdjAdmin->Admin_Qx('5');
		$CS_Smtpmode = $this->CsdjSkins->str_checkhtml($this->input->post('CS_Smtpmode', TRUE));
		$CS_Smtphost = $this->CsdjSkins->str_checkhtml($this->input->post('CS_Smtphost', TRUE));
		$CS_Smtpport = intval($this->input->post('CS_Smtpport', TRUE));
		$CS_Smtpuser = $this->CsdjSkins->str_checkhtml($this->input->post('CS_Smtpuser', TRUE));
		$CS_Smtppass = $this->CsdjSkins->str_checkhtml($this->input->post('CS_Smtppass', TRUE));
		$CS_Smtpmail = $this->CsdjSkins->str_checkhtml($this->input->post('CS_Smtpmail', TRUE));
		$CS_Smtpname = $this->CsdjSkins->str_checkhtml($this->input->post('CS_Smtpname', TRUE));

                if(empty($CS_Smtpport))     $CS_Smtpport=25;
                if(empty($CS_Smtphost))     $CS_Smtphost="smtp.qq.com";
                if($CS_Smtpmode!="FALSE")   $CS_Smtpmode="TRUE";


                if(substr(CS_Smtppass,0,1)."********".substr(CS_Smtppass,-1)==$CS_Smtppass){
                     $CS_Smtppass=CS_Smtppass;
                }

	        $strs="<?php"."\r\n";
	        $strs.="//SMTP开关  \r\n";
	        $strs.="define(\"CS_Smtpmode\",".$CS_Smtpmode.");  \r\n";
	        $strs.="//SMTP服务器  \r\n";
	        $strs.="define(\"CS_Smtphost\",\"".$CS_Smtphost."\");  \r\n";
	        $strs.="//SMTP端口  \r\n";
	        $strs.="define(\"CS_Smtpport\",\"".$CS_Smtpport."\");  \r\n";
	        $strs.="//SMTP帐号  \r\n";
	        $strs.="define(\"CS_Smtpuser\",\"".$CS_Smtpuser."\");  \r\n";
	        $strs.="//SMTP密码  \r\n";
	        $strs.="define(\"CS_Smtppass\",\"".$CS_Smtppass."\");  \r\n";
	        $strs.="//发送EMAIL  \r\n";
	        $strs.="define(\"CS_Smtpmail\",\"".$CS_Smtpmail."\");  \r\n";
	        $strs.="//发送者名称  \r\n";
	        $strs.="define(\"CS_Smtpname\",\"".$CS_Smtpname."\");  \r\n";

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


        //修改登入配置
	public function dengluedit()
	{
                $this->CsdjAdmin->Admin_Qx('4');
		$CS_Appmode = intval($this->input->post('CS_Appmode', TRUE));
		$CS_Appid = $this->CsdjSkins->str_checkhtml($this->input->post('CS_Appid', TRUE));
		$CS_Appkey = $this->CsdjSkins->str_checkhtml($this->input->post('CS_Appkey', TRUE));

	        $strs="<?php"."\r\n";
	        $strs.="//登入开关  \r\n";
	        $strs.="define(\"CS_Appmode\",".$CS_Appmode.");  \r\n";
	        $strs.="//APP_ID  \r\n";
	        $strs.="define(\"CS_Appid\",\"".$CS_Appid."\");  \r\n";
	        $strs.="//APP_KEY  \r\n";
	        $strs.="define(\"CS_Appkey\",\"".$CS_Appkey."\");  \r\n";

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

        //修改水印配置
	public function tbedit()
	{
                $this->CsdjAdmin->Admin_Qx('6');
		$CS_WaterMark = intval($this->input->post('CS_WaterMark', TRUE));
		$CS_WaterMode = intval($this->input->post('CS_WaterMode', TRUE));
		$CS_WaterFontSize = intval($this->input->post('CS_WaterFontSize', TRUE));
		$CS_WaterLocation = intval($this->input->post('CS_WaterLocation', TRUE));
		$CS_WaterFont = $this->CsdjSkins->str_checkhtml($this->input->post('CS_WaterFont', TRUE));
		$CS_WaterFontColor = $this->CsdjSkins->str_checkhtml($this->input->post('CS_WaterFontColor', TRUE));

		$CS_WaterLogo = $this->CsdjSkins->str_checkhtml($this->input->post('CS_WaterLogo', TRUE));
		$CS_WaterLogotm = intval($this->input->post('CS_WaterLogotm', TRUE));
		$CS_WaterLocations = $this->CsdjSkins->str_checkhtml($this->input->post('CS_WaterLocations', TRUE));

                if($CS_WaterLogotm>100)   $CS_WaterLogotm=100;
                if($CS_WaterFontSize==0)  $CS_WaterFontSize=12;
                if($CS_WaterLogotm==0)    $CS_WaterLogotm=90;
                if($CS_WaterLocation==0)  $CS_WaterLocation=2;

	        $strs="<?php"."\r\n";
	        $strs.="define(\"CS_WaterMark\",".$CS_WaterMark.");  //水印开关  \r\n";
	        $strs.="define(\"CS_WaterMode\",".$CS_WaterMode.");  //水印类型  \r\n";
	        $strs.="define(\"CS_WaterFontSize\",".$CS_WaterFontSize.");  //水印字体大小  \r\n";
	        $strs.="define(\"CS_WaterLocation\",".$CS_WaterLocation.");  //水印位置  \r\n";
	        $strs.="define(\"CS_WaterFont\",\"".$CS_WaterFont."\");  //水印文字  \r\n";
	        $strs.="define(\"CS_WaterFontColor\",\"".$CS_WaterFontColor."\");  //水印颜色  \r\n";

	        $strs.="define(\"CS_WaterLogo\",\"".$CS_WaterLogo."\");  //水印图片路径  \r\n";
	        $strs.="define(\"CS_WaterLogotm\",\"".$CS_WaterLogotm."\");  //水印质量  \r\n";
 	        $strs.="define(\"CS_WaterLocations\",\"".$CS_WaterLocations."\");  //LOGO图片坐标位置  \r\n";

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

        //修改支付配置
	public function payedit()
	{
                $this->CsdjAdmin->Admin_Qx('3');
		$CS_Alipay = intval($this->input->post('CS_Alipay', TRUE));
		$CS_Alipay_JK = $this->CsdjSkins->str_checkhtml($this->input->post('CS_Alipay_JK', TRUE));
		$CS_Alipay_ID = $this->CsdjSkins->str_checkhtml($this->input->post('CS_Alipay_ID', TRUE));
		$CS_Alipay_Key = $this->CsdjSkins->str_checkhtml($this->input->post('CS_Alipay_Key', TRUE));
		$CS_Alipay_Name = $this->CsdjSkins->str_checkhtml($this->input->post('CS_Alipay_Name', TRUE));

		$CS_Tenpay = intval($this->input->post('CS_Tenpay', TRUE));
		$CS_Tenpay_ID = $this->CsdjSkins->str_checkhtml($this->input->post('CS_Tenpay_ID', TRUE));
		$CS_Tenpay_Key = $this->CsdjSkins->str_checkhtml($this->input->post('CS_Tenpay_Key', TRUE));

		$CS_Wypay = intval($this->input->post('CS_Wypay', TRUE));
		$CS_Wypay_ID = $this->CsdjSkins->str_checkhtml($this->input->post('CS_Wypay_ID', TRUE));
		$CS_Wypay_Key = $this->CsdjSkins->str_checkhtml($this->input->post('CS_Wypay_Key', TRUE));

	        $strs="<?php"."\r\n";

	        $strs.="define(\"CS_Alipay\",".$CS_Alipay.");  //支付宝开关  \r\n";
	        $strs.="define(\"CS_Alipay_JK\",".$CS_Alipay_JK.");  //支付宝接口  \r\n";
	        $strs.="define(\"CS_Alipay_Name\",\"".$CS_Alipay_Name."\");  //支付宝帐号  \r\n";
	        $strs.="define(\"CS_Alipay_ID\",\"".$CS_Alipay_ID."\");  //合作者ID  \r\n";
	        $strs.="define(\"CS_Alipay_Key\",\"".$CS_Alipay_Key."\");  //安全验效码KEY  \r\n";

	        $strs.="define(\"CS_Tenpay\",".$CS_Tenpay.");  //财付通开关  \r\n";
	        $strs.="define(\"CS_Tenpay_ID\",\"".$CS_Tenpay_ID."\");  //财付通ID  \r\n";
	        $strs.="define(\"CS_Tenpay_Key\",\"".$CS_Tenpay_Key."\");  //安全验效码KEY  \r\n";

	        $strs.="define(\"CS_Wypay\",".$CS_Wypay.");  //网银在线开关  \r\n";
	        $strs.="define(\"CS_Wypay_ID\",\"".$CS_Wypay_ID."\");  //网银在线ID  \r\n";
	        $strs.="define(\"CS_Wypay_Key\",\"".$CS_Wypay_Key."\");  //安全验效码KEY  \r\n";

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

        //修改会员配置
	public function useredit()
	{
                $this->CsdjAdmin->Admin_Qx('4');
                $Home_Mode=intval($this->input->post('Home_Mode'));
                $Home_Ym=$this->CsdjSkins->str_checkhtml($this->input->post('Home_Ym',true));
                $Home_YmUrl=$this->CsdjSkins->str_checkhtml($this->input->post('Home_YmUrl'));
                $Home_Hits=intval($this->input->post('Home_Hits'));

                $User_Mode=intval($this->input->post('User_Mode'));
                $User_Logo=intval($this->input->post('User_Logo'));
                $User_DjFun=intval($this->input->post('User_DjFun'));
                $User_VodFun=intval($this->input->post('User_VodFun'));
                $User_NewsFun=intval($this->input->post('User_NewsFun'));
                $User_TopicFun=intval($this->input->post('User_TopicFun'));
                $User_PicFun=intval($this->input->post('User_PicFun'));

                $User_DjMode=intval($this->input->post('User_DjMode'));
                $User_CsdjName=$this->CsdjSkins->str_checkhtml($this->input->post('User_CsdjName'));
	        $User_JulongName=$this->CsdjSkins->str_checkhtml($this->input->post('User_JulongName'));//聚龙网盘

                $User_BookFun=intval($this->input->post('User_BookFun'));
                $User_BookNum=intval($this->input->post('User_BookNum'));

                $User_MusicNum=intval($this->input->post('User_MusicNum'));
                $User_VodNum=intval($this->input->post('User_VodNum'));
                $User_NewsNum=intval($this->input->post('User_NewsNum'));
                $User_TopicNum=intval($this->input->post('User_TopicNum'));
                $User_PicNum=intval($this->input->post('User_PicNum'));

                $User_Downtime=intval($this->input->post('User_Downtime'));
                $User_DownFun=intval($this->input->post('User_DownFun'));
                $User_Downcion=intval($this->input->post('User_Downcion'));
                $User_DirFun=intval($this->input->post('User_DirFun'));
                $User_Dirpath=$this->CsdjSkins->str_checkhtml($this->input->post('User_Dirpath'));
                $thunderID=$this->CsdjSkins->str_checkhtml($this->input->post('thunderID'));

                $User_Reg=intval($this->input->post('User_Reg'));
                $User_Regxy=$this->input->post('User_Regxy');
                $User_RegIP=intval($this->input->post('User_RegIP'));
                $User_RegFun=intval($this->input->post('User_RegFun'));
                $User_RegEmailFun=intval($this->input->post('User_RegEmailFun'));
                $User_RegEmailTitle=$this->CsdjSkins->str_checkhtml($this->input->post('User_RegEmailTitle'));
                $User_RegEmailContent=$this->input->post('User_RegEmailContent');
                $User_RegMsgFun=$this->input->post('User_RegMsgFun',true);
                $User_RegMsgTitle=$this->CsdjSkins->str_checkhtml($this->input->post('User_RegMsgTitle'));
                $User_RegMsgContent=$this->input->post('User_RegMsgContent');
                $User_RegJzName=$this->CsdjSkins->str_checkhtml($this->input->post('User_RegJzName'));
                $User_PassTitle=$this->CsdjSkins->str_checkhtml($this->input->post('User_PassTitle'));
                $User_PassContent=$this->input->post('User_PassContent');

                $Cion_RmbToCion=intval($this->input->post('Cion_RmbToCion'));
                $Cion_Num=intval($this->input->post('Cion_Num'));
                $Cion_Reg=intval($this->input->post('Cion_Reg'));
                $Cion_Log=intval($this->input->post('Cion_Log'));
                $Cion_Qd=intval($this->input->post('Cion_Qd'));
                $Cion_UpMusic=intval($this->input->post('Cion_UpMusic'));
                $Cion_DelMusic=intval($this->input->post('Cion_DelMusic'));
                $Cion_UpVod=intval($this->input->post('Cion_UpVod'));
                $Cion_DelVod=intval($this->input->post('Cion_DelVod'));
                $Cion_UpNews=intval($this->input->post('Cion_UpNews'));
                $Cion_DelNews=intval($this->input->post('Cion_DelNews'));
                $Cion_UpPic=intval($this->input->post('Cion_UpPic'));
                $Cion_DelPic=intval($this->input->post('Cion_DelPic'));

                $FTP_Fun=intval($this->input->post('FTP_Fun'));
                $FTP_Url=$this->CsdjSkins->str_checkhtml($this->input->post('FTP_Url'));
                $FTP_Server=$this->CsdjSkins->str_checkhtml($this->input->post('FTP_Server'));
                $FTP_Dir=$this->CsdjSkins->str_checkhtml($this->input->post('FTP_Dir'));
                $FTP_Port=intval($this->input->post('FTP_Port'));
                $FTP_Name=$this->CsdjSkins->str_checkhtml($this->input->post('FTP_Name'));
                $FTP_Pass=$this->CsdjSkins->str_checkhtml($this->input->post('FTP_Pass'));
                $FTP_Ive=$this->CsdjSkins->str_checkhtml($this->input->post('FTP_Ive'));

                $User_Dtts=$this->input->post('User_Dtts');
                $User_Fkts=$this->input->post('User_Fkts');
                $User_Fsts=$this->input->post('User_Fsts');
                $User_Hyts=$this->input->post('User_Hyts');
                $User_Bkts=$this->input->post('User_Bkts');

                if(!empty($User_RegMsgFun)){
                    $User_RegMsgFun=implode(',', $User_RegMsgFun);
                }

                if($FTP_Port==0) $FTP_Port="21";   
                if($FTP_Ive!='FALSE') $FTP_Ive="TRUE";    
                if(empty($thunderID)) $thunderID="214853434"; 
                if($Home_Mode==0)  $Home_Mode=1;
                if($Home_Ym==0)  $Home_Ym=2;
                if($Home_Hits==0)  $Home_Hits=2;
                if($User_Mode==0)  $User_Mode=1;
                if($User_Logo==0)  $User_Logo=1;
                if($User_DjFun==0)  $User_DjFun=1;
                if($User_VodFun==0)  $User_VodFun=1;
                if($User_NewsFun==0)  $User_NewsFun=1;
                if($User_TopicFun==0)  $User_TopicFun=1;
                if($User_PicFun==0)  $User_PicFun=1;
                //if($User_DjMode==0)  $User_DjMode=2;
                if($User_BookFun==0)  $Home_Ym=1;
                if($User_BookNum==0)  $User_BookNum=5;
                if($User_MusicNum==0)  $User_MusicNum=0;
                if($User_VodNum==0)  $User_VodNum=0;
                if($User_NewsNum==0)  $User_NewsNum=0;
                if($User_TopicNum==0)  $User_TopicNum=0;
                if($User_PicNum==0)  $User_PicNum=0;
                if($User_Downtime==0)  $User_Downtime=24;
                if($User_DownFun==0)  $User_DownFun=2;
                if($User_Downcion==0)  $User_Downcion=3;
                if($User_DirFun==0)  $User_DirFun=2;
                if($User_Reg==0)  $User_Reg=1;
                if($User_RegFun==0)  $User_RegFun=2;
                if($User_RegEmailFun==0)  $User_RegEmailFun=2;
                if($User_Dtts==0)  $User_Dtts=30;
                if($User_Fkts==0)  $User_Fkts=100;
                if($User_Hyts==0)  $User_Hyts=100;
                if($User_Fsts==0)  $User_Fsts=100;
                if($User_Bkts==0)  $User_Bkts=5;
                if($Cion_RmbToCion==0)  $Cion_RmbToCion=1;
                if($Cion_Num==0)  $Cion_Num=10;
                if($FTP_Fun==0)  $FTP_Fun=2;

                //过滤HTML
                $User_PassContent= str_replace('"',"'",$User_PassContent); 
                $User_RegMsgContent= str_replace('"',"'",$User_RegMsgContent); 
                $User_RegEmailContent=str_replace('"',"'",$User_RegEmailContent); 
                $User_Regxy= str_replace('"',"'",$User_Regxy);

                if($Home_Ym==1 && empty($Home_YmUrl)) $this->CsdjAdmin->Admin_Url('<font color=red>抱歉，二级域名不能为空！</font>','javascript:history.back();');

                //修改二级域名数组
                if(file_exists(CSCMSPATH.'lib/Cs_Domain.php')){
                        $CS_Domain = require(CSCMSPATH.'lib/Cs_Domain.php');
		        $this->load->model('CsdjSkins');
                        if($Home_Ym==1){
                           if($this->CsdjSkins->arr_key_value('home')!=$Home_YmUrl){
                               $CS_Domain['home']=$Home_YmUrl;
                               $this->CsdjSkins->arr_file_edit($CS_Domain);
                           }
                        }else{
                           if($this->CsdjSkins->arr_key_value('home')){
                               unset($CS_Domain['home']);
                               $this->CsdjSkins->arr_file_edit($CS_Domain);
                           }
                        }
                }


	        $strs="<?php"."\r\n";

	        $strs.="define(\"Home_Mode\",".$Home_Mode.");  //会员伪静态开关  \r\n";
	        $strs.="define(\"Home_Ym\",".$Home_Ym.");  //二级域名开关  \r\n";
	        $strs.="define(\"Home_YmUrl\",\"".$Home_YmUrl."\");  //二级域名地址  \r\n";
	        $strs.="define(\"Home_Hits\",".$Home_Hits.");  //是否开启防刷机制  \r\n\r\n";


	        $strs.="define(\"User_Mode\",".$User_Mode.");      //会员开关  \r\n";
	        $strs.="define(\"User_Logo\",".$User_Logo.");      //强制头像开关  \r\n";
	        $strs.="define(\"User_DjFun\",".$User_DjFun.");      //会员上传舞曲审核  \r\n";
	        $strs.="define(\"User_VodFun\",".$User_VodFun.");      //会员上传舞曲审核  \r\n";
	        $strs.="define(\"User_NewsFun\",".$User_NewsFun.");      //会员文章审核  \r\n";
	        $strs.="define(\"User_TopicFun\",".$User_TopicFun.");      //会员专集审核  \r\n";
	        $strs.="define(\"User_PicFun\",".$User_PicFun.");      //会员上传相片审核  \r\n\r\n";

	        $strs.="define(\"User_DjMode\",".$User_DjMode.");      //会员上传舞曲方式  \r\n";
	        $strs.="define(\"User_CsdjName\",\"".$User_CsdjName."\");      //官方网盘帐号  \r\n\r\n";
                $strs.="define(\"User_JulongName\",\"".$User_JulongName."\");      //聚龙网盘帐号  \r\n\r\n";//聚龙网盘

	        $strs.="define(\"User_BookFun\",".$User_BookFun.");      //网站留言开关  \r\n";
	        $strs.="define(\"User_BookNum\",".$User_BookNum.");      //留言每页条数  \r\n\r\n";

	        $strs.="define(\"User_MusicNum\",".$User_MusicNum.");      //普通会员歌曲数量，0不限制  \r\n";
	        $strs.="define(\"User_VodNum\",".$User_VodNum.");      //普通会员视频数量，0不限制  \r\n";
	        $strs.="define(\"User_NewsNum\",".$User_NewsNum.");      //普通会员文章数量，0不限制  \r\n";
	        $strs.="define(\"User_TopicNum\",".$User_TopicNum.");      //普通会员专集数量，0不限制  \r\n";
	        $strs.="define(\"User_PicNum\",".$User_PicNum.");      //普通会员专集数量，0不限制  \r\n\r\n";


	        $strs.="define(\"User_Downtime\",".$User_Downtime.");      //重复扣币间隔小时  \r\n";
	        $strs.="define(\"User_DownFun\",".$User_DownFun.");      //下载分成比列开关  \r\n";
	        $strs.="define(\"User_Downcion\",".$User_Downcion.");      //默认下载分成比列数量  \r\n";
	        $strs.="define(\"User_DirFun\",".$User_DirFun.");      //物理路径下载开关  \r\n";
	        $strs.="define(\"User_Dirpath\",\"".$User_Dirpath."\");   //物理路径  \r\n";
	        $strs.="define(\"User_thunderID\",\"".$thunderID."\");   //这个是讯雷联盟ID号  \r\n\r\n";

	        $strs.="define(\"User_Reg\",".$User_Reg.");      //会员注册开关  \r\n";
	        $strs.="define(\"User_Regxy\",\"".$User_Regxy."\");      //会员注册协议  \r\n";
	        $strs.="define(\"User_RegIP\",".$User_RegIP.");      //同一IP注册限制小时  \r\n";
	        $strs.="define(\"User_RegFun\",".$User_RegFun.");      //新用户注册审核,1需要审核  \r\n";
	        $strs.="define(\"User_RegEmailFun\",".$User_RegEmailFun.");      //新用户邮件激活,1需要激活  \r\n";
	        $strs.="define(\"User_RegEmailTitle\",\"".$User_RegEmailTitle."\");      //邮件激活标题  \r\n";
	        $strs.="define(\"User_RegEmailContent\",\"".$User_RegEmailContent."\");      //邮件激活内容  \r\n";
	        $strs.="define(\"User_RegMsgFun\",\"".$User_RegMsgFun."\");      //发送欢迎信息逗号阁开  \r\n";
	        $strs.="define(\"User_RegMsgTitle\",\"".$User_RegMsgTitle."\");      //欢迎信息标题  \r\n";
	        $strs.="define(\"User_RegMsgContent\",\"".$User_RegMsgContent."\");      //欢迎信息内容  \r\n";
	        $strs.="define(\"User_RegJzName\",\"".$User_RegJzName."\");      //禁用用户名/昵称  \r\n";
	        $strs.="define(\"User_PassTitle\",\"".$User_PassTitle."\");      //密码重置邮件标题  \r\n";
	        $strs.="define(\"User_PassContent\",\"".$User_PassContent."\");      //密码重置邮件内容  \r\n";
	        $strs.="define(\"User_Dtts\",".$User_Dtts.");      //动态保留数，0为全部保留   \r\n";
	        $strs.="define(\"User_Fkts\",".$User_Fkts.");      //访客保留数，0为全部保留   \r\n";
	        $strs.="define(\"User_Hyts\",".$User_Hyts.");      //好友保留数，0为全部保留   \r\n";
	        $strs.="define(\"User_Fsts\",".$User_Fsts.");      //粉丝保留数，0为全部保留   \r\n";
	        $strs.="define(\"User_Bkts\",".$User_Bkts.");      //说说保留数，0为全部保留   \r\n\r\n";

	        $strs.="define(\"Cion_RmbToCion\",".$Cion_RmbToCion.");      //默认金币比例  \r\n";
	        $strs.="define(\"Cion_Num\",".$Cion_Num.");      //每天上限次数  \r\n";
	        $strs.="define(\"Cion_Reg\",".$Cion_Reg.");      //注册赠送金币  \r\n";
	        $strs.="define(\"Cion_Log\",".$Cion_Log.");      //登入赠送金币  \r\n";
	        $strs.="define(\"Cion_Qd\",".$Cion_Qd.");      //签到赠送金币  \r\n";
	        $strs.="define(\"Cion_UpMusic\",".$Cion_UpMusic.");      //上传歌曲赠送金币  \r\n";
	        $strs.="define(\"Cion_DelMusic\",".$Cion_DelMusic.");      //删除歌曲扣除金币  \r\n";
	        $strs.="define(\"Cion_UpVod\",".$Cion_UpVod.");      //上传视频赠送金币  \r\n";
	        $strs.="define(\"Cion_DelVod\",".$Cion_DelVod.");      //删除视频扣除金币  \r\n";
	        $strs.="define(\"Cion_UpNews\",".$Cion_UpNews.");      //上传文章赠送金币  \r\n";
	        $strs.="define(\"Cion_DelNews\",".$Cion_DelNews.");      //删除文章扣除金币  \r\n";
	        $strs.="define(\"Cion_UpPic\",".$Cion_UpPic.");      //上传图片赠送金币  \r\n";
	        $strs.="define(\"Cion_DelPic\",".$Cion_DelPic.");      //删除图片扣除金币  \r\n\r\n";

	        $strs.="define(\"FTP_Fun\",".$FTP_Fun.");      //远程FTP附件开关   \r\n";
	        $strs.="define(\"FTP_Url\",\"".$FTP_Url."\");      //远程FTP连接地址   \r\n";
	        $strs.="define(\"FTP_Server\",\"".$FTP_Server."\");      //远程FTP服务器IP  \r\n";
	        $strs.="define(\"FTP_Dir\",\"".$FTP_Dir."\");      //远程FTP目录  \r\n";
	        $strs.="define(\"FTP_Port\",\"".$FTP_Port."\");      //远程FTP端口  \r\n";
	        $strs.="define(\"FTP_Name\",\"".$FTP_Name."\");      //远程FTP帐号  \r\n";
	        $strs.="define(\"FTP_Pass\",\"".$FTP_Pass."\");      //远程FTP密码  \r\n";
	        $strs.="define(\"FTP_Ive\",\"".$FTP_Ive."\");      //是否使用被动模式  \r\n";


                //=========================生成伪静态规则========================
                if($Home_Mode==2){
                    if(Html_Wjt=="httpd.ini"){
                        $strss=read_file('./httpd.ini');
                        if(empty($strss)){
                           $strss="[ISAPI_Rewrite]    \r\n";
	                   $strss.="CacheClockRate 3600    \r\n";
	                   $strss.="RepeatLimit 32    \r\n";
                        }
                        if(strpos($strss,'会员主页伪静态') === FALSE){
                              $strss.=" \r\n# 会员主页伪静态    \r\n";
	                      $strss.="RewriteRule ".Web_Path."music(.*)$ ".Web_Path."index.php/music$1    \r\n";
	                      $strss.="RewriteRule ".Web_Path."news(.*)$ ".Web_Path."index.php/news$1    \r\n";
	                      $strss.="RewriteRule ".Web_Path."vod(.*)$ ".Web_Path."index.php/vod$1    \r\n";
	                      $strss.="RewriteRule ".Web_Path."feed(.*)$ ".Web_Path."index.php/feed$1    \r\n";
	                      $strss.="RewriteRule ".Web_Path."friend(.*)$ ".Web_Path."index.php/friend$1    \r\n";
	                      $strss.="RewriteRule ".Web_Path."fans(.*)$ ".Web_Path."index.php/fans$1    \r\n";
	                      $strss.="RewriteRule ".Web_Path."funco(.*)$ ".Web_Path."index.php/funco$1    \r\n";
	                      $strss.="RewriteRule ".Web_Path."fav(.*)$ ".Web_Path."index.php/fav$1    \r\n";
	                      $strss.="RewriteRule ".Web_Path."down(.*)$ ".Web_Path."index.php/down$1    \r\n";
	                      $strss.="RewriteRule ".Web_Path."gbook(.*)$ ".Web_Path."index.php/gbook$1    \r\n";
	                      $strss.="RewriteRule ".Web_Path."home(.*)$ ".Web_Path."index.php/home$1    \r\n";
	                      $strss.="RewriteRule ".Web_Path."piclook(.*)$ ".Web_Path."index.php/piclook$1    \r\n";
                        }
                        write_file('./httpd.ini', $strss);
                    }elseif(Html_Wjt==".htaccess"){
                        $strss=read_file('./.htaccess');
                        if(empty($strss)){
                           $strss="RewriteEngine On    \r\n";
	                   $strss.="# 安装目录路径    \r\n";
                           $strss.="RewriteBase ".Web_Path."    \r\n";
                        }
                        if(strpos($strss,'会员主页伪静态') === FALSE){
                              $strss.=" \r\n# 会员主页伪静态    \r\n";
	                      $strss.="RewriteRule ^music(.*)$ ".Web_Path."index.php/music$1    \r\n";
	                      $strss.="RewriteRule ^news(.*)$ ".Web_Path."index.php/news$1    \r\n";
	                      $strss.="RewriteRule ^vod(.*)$ ".Web_Path."index.php/vod$1    \r\n";
	                      $strss.="RewriteRule ^feed(.*)$ ".Web_Path."index.php/feed$1    \r\n";
	                      $strss.="RewriteRule ^friend(.*)$ ".Web_Path."index.php/friend$1    \r\n";
	                      $strss.="RewriteRule ^fans(.*)$ ".Web_Path."index.php/fans$1    \r\n";
	                      $strss.="RewriteRule ^funco(.*)$ ".Web_Path."index.php/funco$1    \r\n";
	                      $strss.="RewriteRule ^fav(.*)$ ".Web_Path."index.php/fav$1    \r\n";
	                      $strss.="RewriteRule ^down(.*)$ ".Web_Path."index.php/down$1    \r\n";
	                      $strss.="RewriteRule ^gbook(.*)$ ".Web_Path."index.php/gbook$1    \r\n";
	                      $strss.="RewriteRule ^home(.*)$ ".Web_Path."index.php/home$1    \r\n";
	                      $strss.="RewriteRule ^piclook(.*)$ ".Web_Path."index.php/piclook$1    \r\n";
                        }
                        write_file('./.htaccess', $strss);
                    }elseif(Html_Wjt=="nginx.conf"){
                        $strss=read_file('./nginx.conf');
                        if(empty($strss)){
                           $strss="location ".Web_Path." {    \r\n\r\n";
                        }
                        if(strpos($strss,'会员主页伪静态') === FALSE){
                             $strss.=" \r\n# 会员主页伪静态    \r\n";
	                     $strss.="rewrite  ^([^\.]*)music(.*)$ ".Web_Path."index.php/music$1    \r\n";
	                     $strss.="rewrite  ^([^\.]*)feed(.*)$ ".Web_Path."index.php/feed$1    \r\n";
	                     $strss.="rewrite  ^([^\.]*)friend(.*)$ ".Web_Path."index.php/friend$1    \r\n";
	                     $strss.="rewrite  ^([^\.]*)fans(.*)$ ".Web_Path."index.php/fans$1    \r\n";
	                     $strss.="rewrite  ^([^\.]*)news(.*)$ ".Web_Path."index.php/news$1    \r\n";
	                     $strss.="rewrite  ^([^\.]*)vod(.*)$ ".Web_Path."index.php/vod$1    \r\n";
	                     $strss.="rewrite  ^([^\.]*)funco(.*)$ ".Web_Path."index.php/funco$1    \r\n";
	                     $strss.="rewrite  ^([^\.]*)fav(.*)$ ".Web_Path."index.php/fav$1    \r\n";
	                     $strss.="rewrite  ^([^\.]*)down(.*)$ ".Web_Path."index.php/down$1    \r\n";
	                     $strss.="rewrite  ^([^\.]*)gbook(.*)$ ".Web_Path."index.php/gbook$1    \r\n";
	                     $strss.="rewrite ^([^\.]*)home(.*)$ ".Web_Path."index.php/home$1    \r\n";
	                     $strss.="rewrite ^([^\.]*)piclook(.*)$ ".Web_Path."index.php/piclook$1    \r\n";
                        }
                        write_file('./nginx.conf', $strss);
                    }
                }


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

