日期:2014-05-17  浏览次数:20717 次

dede在线安装InitDede.php
<?php
if(empty($_POST['dopost'])) $dopost = '';
else $dopost = $_POST['dopost'];
$rmurl = "http://www.dedecms.com/newver.txt";
//修改密码,并下载DedeCms进行安装
if($dopost=='mdpwd')
{
	$oldpwd = $_POST['oldpwd'];
	$newpwd = $_POST['dbpwd'];
	$conn = mysql_connect('localhost','root',stripslashes($oldpwd));
	if(!$conn) {
		ShowMsg("数据库初始密码错误,请输入正确的初始密码!","initDede.php");
		exit();
	}
	
	if($newpwd!='')
	{
		 if(!mysql_query(" update mysql.user set Password=password('$newpwd') where User='root' ",$conn))
		 {
			  ShowMsg("修改密码失败!" & mysql_error(),"initDede.php");
		    exit();
		 }
		 mysql_query("flush privileges ",$conn);
		 $conn = mysql_connect('localhost','root',stripslashes($newpwd));
		 if(!$conn) {
		    ShowMsg("重新连接数据库失败,请返回前页,用新密码作为初始密码尝试连接!","-1");
		    exit();
		 }
		 $oldpwd = $newpwd;
	}
	$oldpwd = stripslashes($oldpwd);
	echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\" />";
	echo "修改密码成功,现在获取最新版DedeCms信息...<br />";
	$infoString = file_get_contents($rmurl) or die("连接远程网址失败!");
	$infos = split(',',$infoString);
  $rmurl = trim($infos[0]);
  echo "修改密码成功,现在开始下载DEDE安装包...<br />";
  $zipbin = file_get_contents($rmurl);
	$fp = fopen(dirname(__FILE__).'/tmp.zip','w');
	fwrite($fp,$zipbin);
	unset($zipbin);
	fclose($fp);
	echo "成功下载DEDE安装包,现在进行解压及初处理...<br />";
	$z = new zip();
  $z->ExtractAll ( dirname(__FILE__).'/tmp.zip', dirname(__FILE__));
  echo "成功解压DEDE安装包,现在对解压后的文件进行初处理...<br />";
  $mdfile = trim($infos[1]);
  $mdvalue = trim($infos[2]);
  $fp = fopen('./'.$mdfile,'r');
  $str = fread($fp,filesize('./'.$mdfile));
  fclose($fp);
  $str = str_replace($mdvalue,$mdvalue." value=\"$oldpwd\" ",$str);
  $fp = fopen('./'.$mdfile,'w');
  $str = fwrite($fp,$str);
  fclose($fp);
  unlink("./tmp.zip");
  unlink("./initDede.php");
  unlink("./phpinfo.php");
  unlink("./loading1.gif");
  ShowMsg("成功下载程序并处理,现转向安装页&gt;&gt;","install/index.php");
  exit();
}


function MoveDir()
{
	
}

function ShowMsg($msg,$gourl,$onlymsg=0,$limittime=0)
{
	if(empty($GLOBALS['cfg_phpurl'])) $GLOBALS['cfg_phpurl'] = '..';
	$htmlhead  = "<html>\r\n<head>\r\n<title>DEDECMS提示信息</title>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\" />\r\n";
	$htmlhead .= "<base target='_self'/>\r\n<style>div{line-height:160%;}</style></head>\r\n<body leftmargin='0' topmargin='0'>\r\n<center>\r\n<script>\r\n";
	$htmlfoot  = "</script>\r\n</center>\r\n</body>\r\n</html>\r\n";

	if($limittime==0) $litime = 1000;
	else $litime = $limittime;

	if($gourl=="-1"){
		if($limittime==0) $litime = 5000;
		$gourl = "javascript:history.go(-1);";
	}

	if($gourl==''||$onlymsg==1){
		$msg = "<script>alert(\"".str_replace("\"","“",$msg)."\");</script>";
	}else{
		$func = "      var pgo=0;
      function JumpUrl(){
        if(pgo==0){ location='$gourl'; pgo=1; }
      }\r\n";
		$rmsg = $func;
		$rmsg .= "document.write(\"<br /><div style='width:450px;padding:0px;border:1px solid #D1DDAA;'>";
		$rmsg .= "<div style='padding:6px;font-size:12px;border-bottom:1px solid #D1DDAA;background:#DBEEBD';'><b>DEDECMS 提示信息!</b></div>\");\r\n";
		$rmsg .= "document.write(\"<div style='height:130px;font-size:10pt;background:#ffffff'><br />\");\r\n";
		$rmsg .= "document.write(\"".str_replace("\"","“",$msg)."\");\r\n";
		$rmsg .= "document.write(\"";
		if($onlymsg==0){
			if($gourl!="javascript:;" && $gourl!=""){ $rmsg .= "<br /><a href='{$gourl}'>如果你的浏览器没反应,请点击这里...</a>"; }
			$rmsg .= "<br/></div>\");\r\n";
			if($gourl!="javascript:;" && $gourl!=''){ $rmsg .= "setTimeout('JumpUrl()',$litime);"; }
		}else{ $rmsg .= "<br/><br/></div>\");\r\n"; }
		$msg  = $htmlhead.$rmsg.$htmlfoot;
	}
	echo $msg;
}

/*
$z = new zip();
2、解压缩整个ZIP文件