<?php
/**
 * 生成首页
 *
 * @version        $Id: makehtml_homepage.php 2 9:30 2010-11-11 tianya $
 * @package        DedeCMS.Administrator
 * @copyright      Copyright (c) 2007 - 2010, DesDev, Inc.
 * @license        http://help.dedecms.com/usersguide/license.html
 * @link           http://www.dedecms.com
 */

require_once(dirname(__FILE__)."/config.php");
CheckPurview('sys_MakeHtml');
require_once(DEDEINC."/arc.partview.class.php");
$action = (empty($action) ? '' : $action);

if($action=='')
{
    require_once(DEDEADMIN."/templets/makestaticdynamic.htm");
    exit();
}
else if($action=='make')
{
	if($uptype=='dynamic')
	{
		$row = $dsql->ExecuteNoneQuery("update `#@__arctype` set isdefault=-1");
		$row = $dsql->ExecuteNoneQuery("update `#@__archives` set ismake=-1");
		ShowMsg("完成动态设置！","-1");
		exit();
	}
	else
	{
		$row = $dsql->ExecuteNoneQuery("update `#@__arctype` set isdefault=1");
		$row = $dsql->ExecuteNoneQuery("update `#@__archives` set ismake=1");
		
		$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);
		}

		$str1 = '<input name="ishtml" type="radio" class="np" value="1">';
		$str12 = '<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, $str1))
		{
			$archives_add = str_ireplace($str1, '<input name="ishtml" type="radio" class="np" value="1" checked>', $archives_add);
			$archives_add = str_ireplace($str12, '<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);
		}

		$str2 = '<input name="ishtml" type="radio" class="np" value="1">';
		$str22 = '<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, $str2))
		{
			$album_add = str_ireplace($str2, '<input name="ishtml" type="radio" class="np" value="1" checked>', $album_add);
			$album_add = str_ireplace($str22, '<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);
		}
		
		ShowMsg("完成静态设置！","-1");
		exit();
	}
}