<!--<?php
if(!$step){print <<<EOT
-->
<section class="section">
			<div class="step">
				<ul id="stepTips">
					<li class="current"><em>1</em>升級提醒</li>
					<li><em>2</em>升級數據</li>
					<li><em>3</em>升級完成</li>
				</ul>
			</div>
			<div style="margin-bottom:30px;" class="success_tip error_tip" id="updateDatabase">
				<p class="f14 b s4">phpwind v{$from_version}  升級至 $wind_version</p>
				<p>升級前請確認站點是否關閉。</p>
				<p>升級前請務必備份好論壇文件和數據庫。</p>
				<p>數據庫大小︰<span class="s1">{$databaseSize}{$unit}</span>
<!--
EOT;
if (!$showBackup){print <<<EOT
-->
				，建議做線下備份
<!--
EOT;
}print <<<EOT
-->
				</p>
			</div>
			<div class="install" id="updateMessage" style="display:none"><ul id="updateMessageList"></ul></div>
			<div style="margin-bottom:30px;" class="bottom tac">
<script src="js/pw_ajax.js"></script>
<script>
var getObj = function(id){
	if(!id){
		return false;
	}
	return document.getElementById(id);
};
var updateUrl = "{$_SERVER['SCRIPT_NAME']}?step=1";

window.onload=function(){
	var updateUrlCookie = FetchCookie('last_update_url');
	if (updateUrlCookie && updateUrlCookie != '0'){
		getObj("continueUpdateObj").style.display='';
		getObj("continueUpdateObj").onclick = function(){
			doUpdate(updateUrlCookie,getObj('startUpdateObj'));
		}
	}
}
function doUpdate(url,obj){
	getObj("continueUpdateObj").style.display='none';
	var stepTips = getObj('stepTips').children;
	stepTips[0].className = 'on';
	stepTips[1].className = 'current';
	obj.className = 'btn_old';
	obj.onclick = function (){return false;}
	obj.innerHTML = '<img src="lang/images/loading.gif" align="absmiddle" />&nbsp;正在升級';
	getObj('updateMessage').style.display='';
	getObj('updateDatabase').style.display='none';
	if (getObj('databaseBackup')){
		getObj('databaseBackup').style.display='none';
	}
	ajaxUpdate(url,obj);
}

function ajaxUpdate(url,obj){
	ajax.send(url,'',function(){
		var rText = ajax.request.responseText.split("\t");
		if (rText[2]) {
			var messages = rText[2].split('|');
			if (messages.length > 1) {
				for(var i=1;i<messages.length;i++){
					var li=document.createElement("li");
					li.innerHTML='<span class="correct_span">ˇ</span>' + messages[0] + messages[i];
					getObj('updateMessageList').appendChild(li);
				} 
			} else {
				var li=document.createElement("li");
				li.innerHTML='<span class="correct_span">ˇ</span>' + rText[2];
				getObj('updateMessageList').appendChild(li);
			}
			getObj('updateMessage').scrollTop = 9999999;
		}
		if (rText[0] == 'continue'){
			SetCookie('last_update_url',rText[1]);
			setTimeout(function(){
				ajaxUpdate(rText[1],obj);
			},1000)
			
		} else if(rText[0] == 'success') {
			SetCookie('last_update_url','0');
			document.location = rText[1];
		} else {
			if (ajax.request.responseText){
				var li=document.createElement("li");
				li.innerHTML='<span class="error_span">ˇ</span>' + ajax.request.responseText;
				getObj('updateMessageList').appendChild(li);
				getObj('updateMessage').scrollTop = 9999999;
			}
			obj.innerHTML = '升級失敗';
		}
	});
}
</script>
<!--
EOT;
if ($showBackup){print <<<EOT
-->
<script>

var backupUrl = "{$_SERVER['SCRIPT_NAME']}?step=database";
function databaseBackup(url,obj){
	obj.className = 'btn_old';
	obj.onclick = function(){return false;}
	obj.innerHTML = '備份中...';
	ajax.send(url,'',function(){
		var rText = ajax.request.responseText.split("\t");
		if (rText[0] == 'continue'){
			databaseBackup(rText[1],obj);
		} else if(rText[0] == 'success'){
			obj.innerHTML = '備份完成';
		} else {
			obj.innerHTML = '備份失敗';
			setTimeout(function(){
				obj.className = 'btn';
				obj.innerHTML = '重新備份';
				obj.onclick = function(){databaseBackup(backupUrl,obj);}
			},1500);
		}
	});
}
</script>
		<a class="btn" href="javascript:void(0)" onclick="databaseBackup(backupUrl,this);return false;" id="databaseBackup">數據備份</a>
<!--
EOT;
}print <<<EOT
-->
				<a class="btn" href="javascript:void(0)" onclick="doUpdate(updateUrl,this,1);return false;" id="startUpdateObj">開始升級</a>

				<a href="javascript:void(0)" id="continueUpdateObj" style="display:none">上次升級未完成，繼續安裝?</a>
			</div>
		</section>
<!--
EOT;
}else{
if($step == 'finish'){print <<<EOT
-->
<section class="section">
	<div class="step">
		<ul>
			<li><em>1</em>升級提醒</li>
			<li><em>2</em>升級數據</li>
			<li class="current"><em>3</em>升級完成</li>
		</ul>
	</div>
	<div class="main cc">
		<div class="success_tip">
			<a class="f16 b" href="$bbsurl/index.php">恭喜您，升級完成，點擊進入</a>
			<p>瀏覽器會自動跳轉，無需人工干預<img src="http://nt.phpwind.net/src/upto_stats.php?url=$bbsurl&version=$wind_version&type=bbs&charsets=$lang[db_charset]&c=$ceversion" width="0" height="0"></p>
		</div>
	</div>
</section>
<script type="text/javascript">
setTimeout(function(){window.location.href="$bbsurl/index.php"}, 2000);
</script>
<!--
EOT;
}print <<<EOT
-->
</div>
<!--
EOT;
}?>-->