<?php
/**
 *	Generated by miceCMS
 *	http://www.miceCMS.com/
 */
class installsqlAction extends security_normal {
	
	function action(){	
		if(!$_POST['username'] or !$_POST['userpwd'] or !$_POST['useremail']){
			$jsstring='Dialog.alert(\'系统设置错误\',function(){window.location.href="'.MICE_URL.'install.php";window.event.returnValue = false;},300,100,"返回文档列表");';
			MessageBox($jsstring);
			die();
		}		

		set_time_limit(0);

		include_once MICE_DIR.'/includes/restore.php';
		if($_POST['install_example'])
		{
			$restoreDB = new restoreDB(MICE_DIR.'/install/install.example.sql');
		}else{
			$restoreDB = new restoreDB(MICE_DIR.'/install/install.sql');
		}

		$salt = md5(rand(100000, 999999).$loginname);
		$pwd=sha1($salt.$_POST['userpwd']);

		if(MICE_DB=='txt'){
			$db_type='gladius';
		}else{
			$db_type=MICE_DB;
		}
		$conn2 = new DBBase($db_type);

		$conn2->RawExecute("INSERT INTO #__user (loginname,salt,password,postnums,realname,explam,url,email,regdate,stopdate,usergroup_id,pointnum,status,nicename,address,headimg,brothday,sex,im,telno,lastlogindate,lastloginip,forgetpwd,memo) VALUES ('".strtolower($_POST['username'])."','".$salt."','".$pwd."',0,'','超级管理员','','admin@micecms.com',1255255375,0,1,0,0,'','','',0,1,'','',1255255375,'127.0.0.1','','在进行数据操作时，红色的选项内容不能为空请注意定期做好数据备份，数据的定期备份可最大限度的保障您网站数据的安全');");
		
		$url="http://".$_SERVER['HTTP_HOST'].$_SERVER["SCRIPT_NAME"];
		$url=substr($url,0,strlen($url)-11);
		
		$smarty = new Smarty();
		$smarty->load_filter('pre','micePreCompileInstall');
		$smarty->assign("title","第5步:完成安装—miceCMS5.0 安装向导");
		$smarty->assign("url",$url);
		$smarty->assign("results",$restoreDB->results);
		$smarty->assign("ExeResults",$restoreDB->ExeResults);
		$filename = new getTPLFileName(__CLASS__);
		$smarty->display($filename->TPLFileName);
	}	
}
?>