<?php
define('DEDEADMIN', str_replace("\\", '/', dirname(__FILE__) ) );
require_once(DEDEADMIN.'/../include/common.inc.php');
require_once (DEDEINC . "/arc.taglist.class.php");

if($_POST)
{
	$choose = $_POST['setup'];
	for($i = 0; $i < count ( $choose ); $i ++)
	{
		switch ($choose[$i])
		{
			case 1:
				$row = $dsql->ExecuteNoneQuery("update `#@__arctype` set isdefault=-1");
			break;
			case 2:
				$row = $dsql->ExecuteNoneQuery("update `#@__archives` set ismake=-1");
			break;
			case 3:
				$str = '<input name="ishtml" type="radio" class="np" value="1" checked="1" />';
				$str2 = '<input type="radio" name="ishtml" class="np" value="0"/>';
				$article_add = file_get_contents(DEDEADMIN.'/templets/article_add.htm');
				if($article_add || substr_count($article_add, $str))
				{
					$article_add = str_ireplace($str, '<input name="ishtml" type="radio" class="np" value="1"/>', $article_add);
					$article_add = str_ireplace($str2, '<input type="radio" name="ishtml" class="np" value="0" checked="1" />', $article_add);
					@$fp = fopen(DEDEADMIN.'/templets/article_add.htm','w'); 
					fwrite($fp,$article_add);
					fclose($fp);
				}
			break;
			case 4:
				$str = '<input name="ishtml" type="radio" class="np" value="1" checked>';
				$str2 = '<input type="radio" name="ishtml" class="np" value="0">';
				$archives_add = file_get_contents(DEDEADMIN.'/templets/archives_add.htm');
				if($archives_add || substr_count($archives_add, $str))
				{
					$archives_add = str_ireplace($str, '<input name="ishtml" type="radio" class="np" value="1">', $archives_add);
					$archives_add = str_ireplace($str2, '<input type="radio" name="ishtml" class="np" value="0" checked>', $archives_add);
					@$fp = fopen(DEDEADMIN.'/templets/archives_add.htm','w'); 
					fwrite($fp,$archives_add);
					fclose($fp);
				}
			break;
			case 5:
				$str = '<input name="ishtml" type="radio" class="np" value="1" checked>';
				$str2 = '<input type="radio" name="ishtml" class="np" value="0">';
				$album_add = file_get_contents(DEDEADMIN.'/templets/album_add.htm');
				if($album_add || substr_count($album_add, $str))
				{
					$album_add = str_ireplace($str, '<input name="ishtml" type="radio" class="np" value="1">', $album_add);
					$album_add = str_ireplace($str2, '<input type="radio" name="ishtml" class="np" value="0" checked>', $album_add);
					@$fp = fopen(DEDEADMIN.'/templets/album_add.htm','w'); 
					fwrite($fp,$album_add);
					fclose($fp);
				}
			break;
			case 6:
$str = '$dsql->SetQuery';
$str_new = <<<HTML
\$path = "../templets/";
\$all_files = scandir(\$path);
\$dir = array();
foreach (\$all_files as \$i=>\$filename)
{
	if (in_array(\$filename, array(".", "..")))
	{
		continue;
	}
	\$full_name = \$path . \$filename;
	if(file_exists(\$full_name."/index.htm"))
	{
		\$dir[\$i]["filename"] = basename(\$filename);
	}
}
\$dsql->SetQuery
HTML;
$str3 = <<<HTML
else
{
HTML;
$str3_new = <<<HTML
else if(\$row['varname'] == 'cfg_df_style')
{
	echo "<select id='edit___cfg_df_style' name='edit___cfg_df_style'>";
	foreach(\$dir as \$t)
	{
		if(\$row['value'] == \$t['filename'])
		{
			echo "<option selected='selected' value='{\$t['filename']}'>{\$t['filename']}</option>";
		}
		else
		{
			echo "<option value='{\$t['filename']}'>{\$t['filename']}</option>";
		}
	}
	echo "</select>";
}else
{
HTML;
				$sys_info_html = file_get_contents(DEDEADMIN.'/templets/sys_info.htm');
				if($sys_info_html || substr_count($sys_info_html, $str))
				{
					$sys_info_html = str_ireplace($str, $str_new, $sys_info_html);
					$sys_info_html = str_ireplace($str3, $str3_new, $sys_info_html);
					@$fp = fopen(DEDEADMIN.'/templets/sys_info.htm','w'); 
					fwrite($fp,$sys_info_html);
					fclose($fp);
				}
$str2 = <<<HTML
    ReWriteConfig();
    ShowMsg("成功更改站点配置！", "sys_info.php");
HTML;
$str2_new = <<<HTML
\$iquery = "UPDATE `#@__homepageset` SET templet='\$_POST[edit___cfg_df_style]/index.htm' ";
\$dsql->ExecuteNoneQuery(\$iquery);
ReWriteConfig();
ShowMsg("成功更改站点配置！", "sys_info.php");
HTML;
				$sys_info_php = file_get_contents(DEDEADMIN.'/sys_info.php');
				if($sys_info_php || substr_count($sys_info_php, $str2))
				{
					$sys_info_php = str_ireplace($str2, $str2_new, $sys_info_php);
					@$fp2 = fopen(DEDEADMIN.'/sys_info.php','w'); 
					fwrite($fp2,$sys_info_php);
					fclose($fp2);
				}
			break;
			case 7:
				$str = '0x63,0x66,0x67,0x5f,0x70,0x6f,0x77,0x65,0x72,0x62,0x79';
				$str2 = '0x20,0x3c,0x61,0x20,0x68,0x72,0x65,0x66,0x3d,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,
0x77,0x77,0x77,0x2e,0x64,0x65,0x64,0x65,0x63,0x6d,0x73,0x2e,0x63,0x6f,0x6d,0x20,0x74,0x61,0x72,
0x67,0x65,0x74,0x3d,0x27,0x5f,0x62,0x6c,0x61,0x6e,0x6b,0x27,0x3e,0x50,0x6f,0x77,0x65,0x72,0x20,
0x62,0x79,0x20,0x44,0x65,0x64,0x65,0x43,0x6d,0x73,0x3c,0x2f,0x61,0x3e';
				$dedesql = file_get_contents(DEDEINC.'/dedesql.class.php');
				if($dedesql || substr_count($dedesql, $str))
				{
					$dedesql = str_ireplace($str, '', $dedesql);
					$dedesql = str_ireplace($str2, '', $dedesql);
					@$fp = fopen(DEDEINC.'/dedesql.class.php','w'); 
					fwrite($fp,$dedesql);
					fclose($fp);
				}
			break;
			case 8:
				$str = '<div class="dede-iframe"><iframe name="loginad" src="login.php?dopost=showad" frameborder="0" id="loginad" scrolling="no" marginwidth="0" marginheight="0" width="100%"></iframe></div>';
				$str2 = '<div class="login-power">Powered by<a href="http://www.dedecms.com" title="DedeCMS官网"><strong>DedeCMS<?php echo $cfg_version; ?></strong></a>&copy; 2004-2011 <a href="http://www.desdev.cn" target="_blank">DesDev</a> Inc.</div>';
				$str3 = '." ".$cfg_version';
				$login = file_get_contents(DEDEADMIN.'/templets/login.htm');
				if($login || substr_count($login, $str))
				{
					$login = str_ireplace($str, '', $login);
					$login = str_ireplace($str2, '', $login);
					$login = str_ireplace($str3, '', $login);
					@$fp = fopen(DEDEADMIN.'/templets/login.htm','w'); 
					fwrite($fp,$login);
					fclose($fp);
				}
				$login_ad = DEDEADMIN.'/templets/login_ad.htm';
				if(file_exists($login_ad)){
					file_put_contents($login_ad, "");
					//$result=unlink ($login_ad);
				}
			break;
			case 9:
				$str = 'DedeCMS';
				$common = file_get_contents(DEDEINC.'/common.func.php');
				if($common || substr_count($common, $str))
				{
					$common = str_replace($str, '', $common);
					@$fp = fopen(DEDEINC.'/common.func.php','w'); 
					fwrite($fp,$common);
					fclose($fp);
				}
			break;
			case 10:
$str = <<<HTML
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>
     <div style='float:left'>
       欢迎使用专业的PHP网站管理系统，轻松建站的首选利器 -- <?php echo \$cfg_softname; ?>
     </div>
     <div id='' style='float:right;padding-right:8px;'>
         <!--  //保留位置（顶右）  -->
     </div>
   </td>
  </tr>
  <tr>
    <td height="1" background="images/sp_bg.gif" style='padding:0px'></td>
  </tr>
</table>
HTML;
$str2 = <<<HTML
        <dl class="dbox" id="item1">
            <dt class='lside'><span class='l'><?php echo \$cfg_soft_enname; ?> 更新消息</span></dt>
            <dd>
                <div id='updatetest'>
                    <div id='updateinfos'>
                        <?php
                            echo "<div class='updatedvt'><b>您系统版本最后更新时间为：{\$oktime} </b><br/>";
                            echo " <a href='javascript:LoadUpdateInfos();' class='np coolbg'>进行在线更新</a> &nbsp; \\r\\n";
HTML;
$str3 = <<<HTML
        <dl class='dbox' id="item5">
            <dt class='lside'><div class='l'>程序团队</div></dt>
            <dd class='intable'>
                <table width="98%" class="dboxtable">
                    <tr>
                        <td width='25%' height='36' class='nline' style="text-align:right"> 主程序研发： </td>
                        <td class='nline' style="text-align:left"><a href="http://www.desdev.cn/team.php" target="_blank" style="color:blue">织梦团队</a></td>
                    </tr>
                    <tr>
                        <td height='36' class='nline' style="text-align:right">鸣谢：</td>
                        <td class='nline' style="text-align:left"><a href="http://www.desdev.cn/dedecms-thanks.html" target="_blank" style="color:blue">热心用户</a>、<a href="http://www.dedecms.com/thanks.html" target="_blank" style="color:blue">赞助商</a></td>
                    </tr>
                </table>
            </dd>
        </dl><!--开发团队结束-->
HTML;
$str4 = <<<HTML
        <dl class='dbox' id="item8">
            <dt class='lside'><div class='l'>赞助商链接(<a href="http://ad.dedecms.com/ad/" target="_blank">说明</a>)</div></dt>
            <dd>
                <iframe name="showad" src="index_body.php?dopost=showad" frameborder="0" width="100%" id="showad" frameborder="0" scrolling="no"  marginheight="5"></iframe>
            </dd>
        </dl><!--赞助商链接结束-->
HTML;
$str5 = <<<HTML
        <dl class='dbox' id="item2">
            <dt class='lside'><span class='l'>商业授权查询</span></dt>
            <dd>               
                <iframe name="showauth" src="index_body.php?dopost=showauth" width="100%" frameborder="0" scrolling="no" marginwidth="10" marginheight="10" id="showauth"></iframe>                
            </dd>
        </dl><!--更新消息结束-->
HTML;
$str6 = <<<HTML
                            echo " <a href='sys_repair.php' class='np coolbg'>系统错误修复</a></div>\\r\\n";
                            echo "<iframe name='stafrm' src='{\$offUrl}&uptime={\$oktime}' frameborder='0' id='stafrm' width='98%' height='50'></iframe>";
                        ?>
                    </div>
                 </div>
            </dd>
        </dl><!--更新消息结束-->
HTML;
$str7 = 'DedeCMS';
$str8 = "<a href='http://www..com' target='_blank'><u></u></a>. 织梦科技";
				$index_body = file_get_contents(DEDEADMIN.'/templets/index_body.htm');
				if($index_body || substr_count($index_body, $str))
				{
					$index_body = str_ireplace($str, '', $index_body);
					$index_body = str_ireplace($str2, '', $index_body);
					$index_body = str_ireplace($str3, '', $index_body);
					$index_body = str_ireplace($str4, '', $index_body);
					$index_body = str_ireplace($str5, '', $index_body);
					$index_body = str_ireplace($str6, '', $index_body);
					$index_body = str_ireplace($str7, '', $index_body);
					$index_body = str_ireplace($str8, '', $index_body);
					@$fp = fopen(DEDEADMIN.'/templets/index_body.htm','w'); 
					fwrite($fp,$index_body);
					fclose($fp);
				}
				$index_body_showad = DEDEADMIN.'/templets/index_body_showad.htm';
				$index_body_showauth = DEDEADMIN.'/templets/index_body_showauth.htm';
				if(file_exists($index_body_showad)){
					file_put_contents($index_body_showad, "");
				}
				if(file_exists($index_body_showauth)){
					file_put_contents($index_body_showauth, "");
				}
			break;
			case 11:
				$str = 'DedeCMS';
				$str3 = '织梦内容管理系统';
				$str4 = "<a href='http://bbs.dedecms.com' target='_blank'>官方论坛</a> <a href='http://help.dedecms.com' target='_blank'>在线帮助</a>";
				$index_top2 = file_get_contents(DEDEADMIN.'/templets/index_top2.htm');
				$index2 = file_get_contents(DEDEADMIN.'/templets/index2.htm');
				$sys_data = file_get_contents(DEDEADMIN.'/templets/sys_data.htm');
				$sys_info_mark = file_get_contents(DEDEADMIN.'/templets/sys_info_mark.htm');
				$sys_info = file_get_contents(DEDEADMIN.'/templets/sys_info.htm');
				
				$common = file_get_contents(DEDEINC.'/common.inc.php');
				
				if($index_top2 || substr_count($index_top2, $str))
				{
					$index_top2 = str_ireplace($str, '', $index_top2);
					@$fp = fopen(DEDEADMIN.'/templets/index_top2.htm','w'); 
					fwrite($fp,$index_top2);
					fclose($fp);
				}
				if($index2 || substr_count($index2, $str))
				{
					$index2 = str_ireplace($str4, '', $index2);
					$index2 = str_ireplace($str, '', $index2);
					@$fp = fopen(DEDEADMIN.'/templets/index2.htm','w'); 
					fwrite($fp,$index2);
					fclose($fp);
				}
				if($sys_data || substr_count($sys_data, $str))
				{
					$sys_data = str_ireplace($str, '', $sys_data);
					@$fp = fopen(DEDEADMIN.'/templets/sys_data.htm','w'); 
					fwrite($fp,$sys_data);
					fclose($fp);
				}
				if($sys_info_mark || substr_count($sys_info_mark, $str))
				{
					$sys_info_mark = str_ireplace($str, '', $sys_info_mark);
					@$fp = fopen(DEDEADMIN.'/templets/sys_info_mark.htm','w'); 
					fwrite($fp,$sys_info_mark);
					fclose($fp);
				}
				if($sys_info || substr_count($sys_info, $str))
				{
					$sys_info = str_ireplace($str, '', $sys_info);
					@$fp = fopen(DEDEADMIN.'/templets/sys_info.htm','w'); 
					fwrite($fp,$sys_info);
					fclose($fp);
				}
				if($common || substr_count($common, $str))
				{
					$common = str_replace($str, 'CMS', $common);
					$common = str_ireplace($str3, '内容管理系统', $common);
					@$fp = fopen(DEDEINC.'/common.inc.php','w'); 
					fwrite($fp,$common);
					fclose($fp);
				}
$str2 = <<<HTML
  <m:item name='参考文档' link='http://help.dedecms.com' rank='' target='_blank' />
  <m:item name='意见建议反馈' link='http://site.desdev.cn/suggest/' rank='' target='_blank' />
  <m:item name='官方交流论坛' link='http://bbs.dedecms.com' rank='' target='_blank' />
HTML;
				$inc_menu = file_get_contents(DEDEADMIN.'/inc/inc_menu.php');
				if($inc_menu || substr_count($inc_menu, $str))
				{
					$inc_menu = str_ireplace($str2, '', $inc_menu);
					@$fp = fopen(DEDEADMIN.'/inc/inc_menu.php','w'); 
					fwrite($fp,$inc_menu);
					fclose($fp);
				}
			break;
			case 12:
				$row = $dsql->ExecuteNoneQuery("update `#@__arctype` set isdefault=1");
			break;
			case 13:
				$row = $dsql->ExecuteNoneQuery("update `#@__archives` set ismake=1");
			break;
			case 14:
				$str = '<input name="ishtml" type="radio" class="np" value="1"/>';
				$str2 = '<input type="radio" name="ishtml" class="np" value="0" checked="1" />';
				$article_add = file_get_contents(DEDEADMIN.'/templets/article_add.htm');
				if($article_add || substr_count($article_add, $str))
				{
					$article_add = str_ireplace($str, '<input name="ishtml" type="radio" class="np" value="1" checked="1" />', $article_add);
					$article_add = str_ireplace($str2, '<input type="radio" name="ishtml" class="np" value="0"/>', $article_add);
					@$fp = fopen(DEDEADMIN.'/templets/article_add.htm','w'); 
					fwrite($fp,$article_add);
					fclose($fp);
				}
			break;
			case 15:
				$str = '<input name="ishtml" type="radio" class="np" value="1">';
				$str2 = '<input type="radio" name="ishtml" class="np" value="0" checked>';
				$archives_add = file_get_contents(DEDEADMIN.'/templets/archives_add.htm');
				if($archives_add || substr_count($archives_add, $str))
				{
					$archives_add = str_ireplace($str, '<input name="ishtml" type="radio" class="np" value="1" checked>', $archives_add);
					$archives_add = str_ireplace($str2, '<input type="radio" name="ishtml" class="np" value="0">', $archives_add);
					@$fp = fopen(DEDEADMIN.'/templets/archives_add.htm','w'); 
					fwrite($fp,$archives_add);
					fclose($fp);
				}
			break;
			case 16:
				$str = '<input name="ishtml" type="radio" class="np" value="1">';
				$str2 = '<input type="radio" name="ishtml" class="np" value="0" checked>';
				$album_add = file_get_contents(DEDEADMIN.'/templets/album_add.htm');
				if($album_add || substr_count($album_add, $str))
				{
					$album_add = str_ireplace($str, '<input name="ishtml" type="radio" class="np" value="1" checked>', $album_add);
					$album_add = str_ireplace($str2, '<input type="radio" name="ishtml" class="np" value="0">', $album_add);
					@$fp = fopen(DEDEADMIN.'/templets/album_add.htm','w'); 
					fwrite($fp,$album_add);
					fclose($fp);
				}
			break;
			
		}
	}
}
?>

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>dedecms 一键工具包 By Neo</title>
	<style>
	*{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline}
	table{border-collapse:collapse;border-spacing:0}
	th,td{vertical-align:middle}
	.Left{float:left}
	.Right{float:right}
	a{text-decoration:none;color:#333}
	a:hover{color:#e53434!important;text-decoration:underline}
	.clearfix:after{content:'.';display:block;height:0;clear:both;overflow:hidden}
	.clearfix{*zoom:1}
	.clear{clear:both}
	body{margin:0 auto;font-family:"宋体",Arial,Helvetica,sans-serif;font-size:12px;background:#ebebeb}
	.uc{width:710px;padding-left:25px;padding-right:25px;background:#fff;margin-top:40px;margin-left:auto;margin-right:auto}
	.uc .body{width:100%;margin-top:30px}
	.uc .body .name{font-size:14px;text-align:right;color:#333}
	.uc .body .value{text-align:left}
	.uc{padding-top:50px;padding-bottom:50px}
	.uc .main{width:700px}
	.uc .main .title{height:22px;line-height:22px;padding-left:32px;font-size:18px;font-family:"微软雅黑";}
	.uc .main .body .check{height:30px;line-height:30px}
	.uc .main .body .checkbox{display:inline-block;vertical-align:top;cursor:pointer;color:#787878}
	.uc .main .body .checkbox{margin-top:8px;margin-left:0;margin-bottom:0}
	.uRegiste .main .body td{padding:6px 0}
	.uc .main .body .submit{display:inline-block;cursor:pointer;width:99px;height:36px;line-height:36px;overflow:hidden;background:#E32D2B;border:0;color:#fff;font-size:14px;font-weight:bold;text-align:center;text-decoration:none}
	.uc .main .body .submit:hover{cursor:pointer;color:#fff!important}
	</style>
	<script>
	window.onload=function()
	{
		var allcheck=document.getElementById('allcheck');
		var cknames=document.getElementsByName("setup[]");
		
		allcheck.onclick=function()
		{
			for(var i=0;i<cknames.length;i++)
			{
				cknames[i].checked=!cknames[i].checked;
			}
		}
		
	}
	</script>
</head>
<body>
<div class="uc clearfix uRegiste">
	<div class="main Left">
		<div class="title">dedecms 一键工具包 By Neo</div>
		<form method="post" action="">
		<table cellpadding="0" cellspacing="0" class="body">
			<tr>
				<td class="name"> dedecms所有栏目设置为“使用动态页”：</td>
				<td class="value"><input type="checkbox" class="checkbox" name="setup[]" value="1" /></td>
			</tr>
			<tr>
				<td class="name"> dedecms所有文档都设置为“仅动态”：</td>
				<td class="value"><input type="checkbox" class="checkbox" name="setup[]" value="2" /></td>
			</tr>
			<tr>
				<td class="name"> dedecms发布文章时发布的自动为动态：</td>
				<td class="value"><input type="checkbox" class="checkbox" name="setup[]" value="3" /></td>
			</tr>
			<tr>
				<td class="name"> dedecms发布通用文档时发布的自动为动态：</td>
				<td class="value"><input type="checkbox" class="checkbox" name="setup[]" value="4" /></td>
			</tr>
			<tr>
				<td class="name"> dedecms发布图集时发布的自动为动态：</td>
				<td class="value"><input type="checkbox" class="checkbox" name="setup[]" value="5" /></td>
			</tr>
			<tr>
				<td class="name"> dedecms后台直接选择模板：</td>
				<td class="value"><input type="checkbox" class="checkbox" name="setup[]" value="6" /></td>
			</tr>
			<tr>
				<td class="name"> dedecms前台去Power by DedeCms：</td>
				<td class="value"><input type="checkbox" class="checkbox" name="setup[]" value="7" /></td>
			</tr>
			<tr>
				<td class="name"> dedecms后台去登陆页广告：</td>
				<td class="value"><input type="checkbox" class="checkbox" name="setup[]" value="8" /></td>
			</tr>
			<tr>
				<td class="name"> dedecms后台去提示跳转页信息“Dede CMS 提示信息！”：</td>
				<td class="value"><input type="checkbox" class="checkbox" name="setup[]" value="9" /></td>
			</tr>
			<tr>
				<td class="name"> dedecms后台去除后台登陆后默认首页广告：</td>
				<td class="value"><input type="checkbox" class="checkbox" name="setup[]" value="10" /></td>
			</tr>
			<tr>
				<td class="name"> dedecms后台去除版权和相关所有链接：</td>
				<td class="value"><input type="checkbox" class="checkbox" name="setup[]" value="11" /></td>
			</tr>
			<tr>
				<td><br /></td>
			</tr>
			<tr>
				<td class="name"> dedecms所有栏目设置为“使用静态页”：</td>
				<td class="value"><input type="checkbox" class="checkbox" name="setup[]" value="12" /></td>
			</tr>
			<tr>
				<td class="name"> dedecms所有文档都设置为“仅静态”：</td>
				<td class="value"><input type="checkbox" class="checkbox" name="setup[]" value="13" /></td>
			</tr>
			<tr>
				<td class="name"> dedecms发布文章时发布的自动为静态：</td>
				<td class="value"><input type="checkbox" class="checkbox" name="setup[]" value="14" /></td>
			</tr>
			<tr>
				<td class="name"> dedecms发布通用文档时发布的自动为静态：</td>
				<td class="value"><input type="checkbox" class="checkbox" name="setup[]" value="15" /></td>
			</tr>
			<tr>
				<td class="name"> dedecms发布图集时发布的自动为静态：</td>
				<td class="value"><input type="checkbox" class="checkbox" name="setup[]" value="16" /></td>
			</tr>
			<tr>
				<td class="name"><label><input type="checkbox" id="allcheck">全选反选</label>&ensp;&ensp;</td>
				<td class="value">
					<input type="submit" class="submit" value="立即提交">
				</td>
			</tr>
		</table>
		</form>
	</div>
</div>	
</body>
</html>