<?php
if( !defined('ISDVBBS') ){
	header('HTTP/1.0 404 Not Found');
	printFooter();
	exit;
}
$opts_disabled = $ftdisabled = ' disabled="disabled" ';
$ft_settings = explode('|', $forum_setting[101]);	//	fulltext 设置
if (!isset($ft_settings[0])) {	//	是否启用全文检索
	$ft_settings[0] = 0;
}
if (!isset($ft_settings[1])) {	//	是否开启相关主题功能
	$ft_settings[1] = 0;
}
if (!isset($ft_settings[2])) {	//	搜索页面是否开启全文检索
	$ft_settings[2] = 0;
}
if (0 == $ft_settings[0]) {
	$ft_settings[1] = $ft_settings[2] = 0;
}
if (0 == $ft_settings[0]) {
	$ft_checked0_1 = ' checked="checked" ';
	$ft_checked0_2 = '';
} else {
	$ft_checked0_1 = '';
	$ft_checked0_2 = ' checked="checked" ';
}
if (0 == $ft_settings[1]) {
	$ft_checked1_1 = ' checked="checked" ';
	$ft_checked1_2 = '';
} else {
	$ft_checked1_1 = '';
	$ft_checked1_2 = ' checked="checked" ';
}
$ftminwordlen = getftminwordlen();
if ($ftminwordlen <= 2) {
	$ftdisabled = '';
	(1 == $ft_settings[0]) AND ($opts_disabled = '');
	$desc = '';
} else {
	$opts_disabled = $ftdisabled = ' disabled="disabled" ';
	$desc = str_replace('{$TPL_ft_min_word_len}', $ftminwordlen, $lang['ft_settings.err0']);
}
$GLOBALS['ft_selected2_'.intval($ft_settings[2])] = ' selected="selected" ';
$ROOT_PATH = ROOT_PATH;

print <<<EOT
	<br />
	<script type="text/JavaScript" src="templates/lang/{$GLOBALS['fsetting']['lang']}/js/guagebar.js"></script>
	<script type="text/JavaScript">
	<!--
	var mustdo = false, __warning_flag = false, __keys_status_flag = false, __keys_enabled_topic_ft = false, __keys_enabled_bbs_ft = false;
	var __intervalid1 = null,__intervalid2 = null, __hidden_frame1 = null, __hidden_frame2 = null;
	var obj_guagebar = null, __tablelist = null, __mixedvar = null, __status_text_id = null;
	var __processed_rows = 0;
	var __status_text_temp = '';
	function SendRequest(destframe, doaction, params)
	{
		var strparam = '';
		if (params) {
			for (var key in params) {
				strparam += '&'+key+'='+params[key];
			}//end for
		}
		destframe.src = window.location.href+'?'+window.location.search+'&doaction='+doaction+''+strparam;
	}//end function SendRequest
	function DoResponse(mixedvar)
	{
		if (!mixedvar) {
			return;
		}
		if (mixedvar.errstr) {
			alert(mixedvar.errstr);
			return;
		}
		
		switch (mixedvar.doaction) {
			case 'rebuild_init':
				if (!mixedvar.TableList) {
					(!__status_text_id) && (__status_text_id = document.getElementById('StatusText'));
					(!__hidden_frame1) && (__hidden_frame1 = document.getElementById('HiddenFrame1'));
					(!__hidden_frame2) && (__hidden_frame2 = document.getElementById('HiddenFrame2'));
					__status_text_id.innerHTML = '{$lang["lang.str1"]}';
					obj_guagebar.setPercent(0);
					SendRequest(__hidden_frame1, 'rebuild_init');
				} else {
					__tablelist = mixedvar;
					obj_guagebar.setPercent(100);
					window.setTimeout("DoResponse({'doaction':'disable_settings'})", 100);
					return;
				}
				break;
			case 'disable_settings':
				if (true !== mixedvar.settings_disabled) {
					obj_guagebar.setPercent(0);
					__status_text_id.innerHTML = '{$lang["lang.str2"]}';
					SendRequest(__hidden_frame1, 'disable_settings');
				} else {
					obj_guagebar.setPercent(100);
					window.setTimeout("DoResponse({'doaction':'disable_keys'})", 100);
					return;
				}
				break;
			case 'disable_keys':
				if (true !== mixedvar.keys_disabled) {
					obj_guagebar.setPercent(0);
					__status_text_id.innerHTML = '{$lang["lang.str3"]}';
					SendRequest(__hidden_frame1, 'disable_keys');
				} else {
					obj_guagebar.setPercent(100);
					window.setTimeout("DoResponse({'doaction':'replace_data'})", 100);
					return;
				}
				break;
			case 'replace_data':
				if ('undefined' == typeof(mixedvar.all_done)) {
					obj_guagebar.setPercent(0);
					__status_text_id.innerHTML = '{$lang["lang.str4"]}';
					var firsttablename = '';
					for (var index in __tablelist['TableList']) {
						if (__tablelist['TableList'][index][1] > 0) {
							firsttablename = __tablelist['TableList'][index][0];
							break;
						}
					}//end for
					SendRequest(__hidden_frame1, 'replace_data', {'dest_tablename':firsttablename, 'begin_id':1});
				} else {
					__tablelist[mixedvar.dest_tablename]['AffectedRows'] += mixedvar.affected_rows;
					__processed_rows += mixedvar.affected_rows;
					if (false === mixedvar.all_done) {
						__status_text_id.innerHTML = '{$lang["lang.str5"]}'+mixedvar.dest_tablename+'{$lang["lang.str6"]}'+__tablelist[mixedvar.dest_tablename]['AffectedRows']+'/'+__tablelist[mixedvar.dest_tablename]['RecordCount']+'{$lang['tpl.str2']})';
						//var ipercent = __processed_rows*100/__tablelist.RecordCount;
						var ipercent = __tablelist[mixedvar.dest_tablename]['AffectedRows']*100/__tablelist[mixedvar.dest_tablename].RecordCount;
						//(ipercent >= 100) && (ipercent = 99);
						obj_guagebar.setPercent(ipercent);
						window.setTimeout("SendRequest(__hidden_frame1, 'replace_data', {'dest_tablename':'"+mixedvar.dest_tablename+"', 'begin_id':"+mixedvar.begin_id+"})", 500);
						return;
					} else {
						window.setTimeout("DoResponse({'doaction':'enable_keys_topic_ft'})", 10);
						return;
					}
				}
				break;
			case 'enable_keys_topic_ft':
				if (false === __keys_enabled_topic_ft) {
					if ('undefined' == typeof(mixedvar.keys_enabled)) {
						obj_guagebar.setPercent(0);
						__status_text_id.innerHTML = '{$lang["lang.str8"]}{$dv}topic_ft{$lang["lang.str9"]}';
						//__intervalid1 = setInterval('CheckKeysStatusTopicFt()', 3000);
						SendRequest(__hidden_frame1, 'enable_keys_topic_ft');
					} else {
						if (true === mixedvar.keys_enabled) {
							__keys_enabled_topic_ft = true;
							obj_guagebar.setPercent(100);
							window.setTimeout("DoResponse({'doaction':'enable_keys_bbs_ft'})", 10);
							return;
						}
					}
				}
				break;
			case 'check_keys_status_topic_ft':
				break;
			case 'enable_keys_bbs_ft':
				if (false === __keys_enabled_bbs_ft) {
					if ('undefined' == typeof(mixedvar.keys_enabled)) {
						obj_guagebar.setPercent(0);
						__status_text_id.innerHTML = '{$lang["lang.str8"]}{$dv}bbs_ft{$lang["lang.str9"]}';
						//__intervalid2 = setInterval('CheckKeysStatusBbsFt()', 3000);
						SendRequest(__hidden_frame1, 'enable_keys_bbs_ft');
					} else {
						if (true === mixedvar.keys_enabled) {
							obj_guagebar.setPercent(100);
							__keys_enabled_bbs_ft = true;
							window.setTimeout("DoResponse({'doaction':'all_done'})", 10);
							return;
						}
					}
				} else {
					window.setTimeout("DoResponse({'doaction':'all_done'})", 10);
					return;
				}
				break;
			case 'check_keys_status_bbs_ft':
				break;
			case 'all_done':
				__status_text_id.innerHTML = '{$lang["lang.str11"]}';
				document.forms['ft_form'].submit();
				break;
			default:
				break;
		}//end switch
	}//end function DoResponse

	function EnableFt(bln, chkbox)
	{
		var settings_1_1 = document.getElementById('ft_settings_1_1');
		var settings_1_2 = document.getElementById('ft_settings_1_2');
		var settings_2 = document.getElementById('ft_settings(2)');
		if (bln !== true && bln !== false) {
			bln = false;
		}
		settings_1_1 && (settings_1_1.disabled = !bln);
		settings_1_2 && (settings_1_2.disabled = !bln);
		settings_2 && (settings_2.disabled = !bln);
	}//end function EnableFt
	function SaveFtSettings(btn)
	{
		var form = btn.form;
		btn.disabled = true;
		if (!document.getElementById('ft_settings0_2').checked) {
			form.submit();
			return true;
		}
		if (!confirm('{$lang["lang.str12"]}')) {
			form.submit();
			return true;
		} else {
			mustdo = true;
			windowOnResize();
			DoResponse({'doaction':'rebuild_init'});
		}
	}//end function SaveFtSettings
	function windowOnResize()
	{
		if (false === mustdo) {
			return true;
		}
		var id1 = document.getElementById('ConvertArea1');
		with(id1.style) {
			position = 'absolute';
			display = '';
			width = parseInt(document.body.clientWidth);
			height = parseInt(window.screen.height);
		}
		var id2 = document.getElementById('ConvertArea2');
		with(id2.style) {
			position = 'absolute';
			display = '';
			width = parseInt(document.body.clientWidth);
			height = parseInt(window.screen.height);
		}
	}//end function windowOnResize
	window.onresize = windowOnResize;
	//-->
	</script>
	<!-- 全文检索设置开始 -->
		<table border="0" cellspacing="1" cellpadding="1"  align="center" class="tableborder">
			<form action="" method="post" name="ft_form">
				<input type="hidden" name="doaction" value='save_settings' />
				<input type="hidden" name="ft_settings_0" value="{$ft_settings[0]}" />
			<tr> 
				<td height="25" colspan="2" align="left" class="tit1"><a name="setting100"></a>{$lang['tpl.str1']} <span class="bfont">{$lang['lang.str13']}</span>&nbsp;[<a href="#top">{$lang['lang.str14']}</a>]</td>
			</tr>
			<tr> 
				<td class="forumrow1" width="50%"><a name="SettingFullText"></a>
					<b>{$lang['lang.str15']}</b>
					<br />{$desc}
				</td>
				<td class="forumrow1">  
				<input type="radio" id="ft_settings0_1" name="ft_settings(0)" value="0" onclick="EnableFt(false, this)" {$ft_checked0_1} {$ftdisabled} />{$lang['lang.str16']}&nbsp;
				<input type="radio" id="ft_settings0_2" name="ft_settings(0)" value="1" onclick="EnableFt(true, this)" {$ft_checked0_2} {$ftdisabled} />{$lang['lang.str17']}&nbsp;
				</td>
			</tr>
			<tr> 
				<td class="forumrow1" width="50%"><a name="SettingFullText"></a>
					<b>{$lang['lang.str18']}</b>
					<br />{$lang['lang.str19']}</td>
					<td class="forumrow1">  
					<input type="radio" id="ft_settings_1_1" name="ft_settings(1)" value="0" {$ft_checked1_1} {$opts_disabled} />{$lang['lang.str16']}&nbsp;
					<input type="radio" id="ft_settings_1_2" name="ft_settings(1)" value="1" {$ft_checked1_2} {$opts_disabled} />{$lang['lang.str17']}&nbsp;
				</td>
			</tr>
			<tr> 
				<td class="forumrow1" width="50%"><a name="SettingFullText"></a>
					<b>{$lang['lang.str20']}</b>
					<br />{$lang['lang.str21']}</td>
				<td class="forumrow1">  
					<select name="ft_settings(2)" id="ft_settings(2)" {$opts_disabled}>
						<option value="0" {$ft_selected2_0}>{$lang['lang.str22']}</option>
						<option value="1" {$ft_selected2_1}>{$lang['lang.str23']}</option>
						<option value="2" {$ft_selected2_2}>{$lang['lang.str24']}</option>
						<option value="3" {$ft_selected2_3}>{$lang['lang.str25']}</option>
					</select>
				</td>
			</tr>
			<tr>
				<td align="center" class="forumrow1" colspan="2" style="text-align:center;"><input class="button" type="button" value="{$lang['lang.str26']}" {$ftdisabled} onclick="SaveFtSettings(this)" /></td>
			</tr>
	</form>
		</table>
	<!-- 全文检索设置结束 -->
	<div id="ConvertArea1" style="position:absolute;margin:0px;width:100%;height:100%;left:0;top:0;display:none;background-color1:#336699;filter1:Alpha(opacity=30);z-index:100;">
	</div>
	<div id="ConvertArea2" style="position:absolute;margin:0px;width:100%;height:100%;left:0;top:0;display:none;z-index:200;">
		<table align="left" border="0" cellspacing="1" cellpadding="1" width="98%" height="100%" style="color:;">
			<tr>
				<td colspan="3" height="25%"></td>
			</tr>
			<tr>
				<td width="15%" rowspan="2"></td>
				<td valign="middle" align="left">
					<div style="width:80%;">
						<table cellspacing="0" cellpadding="0" width="98%" height="100%" border="0" bordercolor="red">
							<tr>
								<td width="100%" align="left"><div id="StatusText" style="width:100%;">{$lang['lang.str27']}</div></td>
								<!--
								<td width="20%" align="left"><div id="StatusText" style="width:100%;">{$lang['lang.str27']}</div></td>
								<td align="right"><div id="WarningText" style="display:none;width:100%;">{$lang['lang.str28']}</div></td>
								<td width="40%"></td>-->
							</tr>
							<tr>
								<td colspan="3" width="100%">
									<script type="text/JavaScript">
										obj_guagebar = new GuageBar(document.body.clientWidth/2, '20px');
										obj_guagebar.showUI();
										//obj_guagebar.setPercent(50);
									</script>
								</td>
							</tr>
						</table>
					</div>
				<td width="12px"></td>
			</tr>
			<tr>
				<td colspan="3" height="60%" rowspan="2"></td>
			</tr>
		</table>
	</div>
	<iframe name="HiddenFrame" id="HiddenFrame1" src="about:blank" style="display:none;" marginwidth="0" marginheight="0" frameborder="0" scrolling1="no"></iframe>
	<iframe name="HiddenFrame2" id="HiddenFrame2" src="about:blank" style="display:none;" marginwidth="0" marginheight="0" frameborder="0" scrolling1="no"></iframe>
EOT;
?>