<!--<?php
include_once PrintEot('left');
print <<<EOT
-->
<script type="text/javascript" src="js/color_picker.js" ></script>
<script type="text/javascript">
function getObj(id){
	return document.getElementById(id);
}

function showSelHtml(d,s) {
	if(s) getObj(d).innerHTML = getObj(s).innerHTML;
	else getObj(d).innerHTML = '';
}
</script>
<!--
EOT;
if (empty($action)) {
print <<<EOT
-->
	<div class="nav3 mb10">
	<ul class="cc">
		<li class="current"><a href="$basename">搜索設置</a></li>
		<li><a href="$basename&action=forum">版塊推薦</a></li>
		<li><a href="$basename&action=cp">關鍵字推送</a></li>
		<li><a href="$basename&action=statistic">搜索統計</a></li>
	</ul>
</div>
<div id="stypestate" style="display:$display;">
	<h2 class="h1">搜索設置</h2>
	<form method="post" name="FORM" action="$basename&" id="FORM">
	<input type="hidden" name="step" value="2">
	<div class="admin_table mb10">
	<table width="100%" cellspacing="0" cellpadding="0">
		<tr class="tr1 vt">
			<td class="td1">定時搜索</td>
			<td class="td2" width="415">
				<ul class="list_A list_80 cc fl mar20">
					<li><input type="radio" value="1" name="schctl[opensch]" $opensch_Y>開啟</li>
					<li><input type="radio" value="0" name="schctl[opensch]" $opensch_N>關閉</li>
				</ul>
				<div class="cc"></div>
				<ul class="list_B list_120 cc">
					<li>開啟于[時]:&nbsp;<input name="schctl[schstart]" value="$db_schstart" class="input input_wd"></li>
					<li>關閉于[時]:&nbsp;<input name="schctl[schend]" value="$db_schend" class="input input_wd"></li>
				</ul>
			</td>
			<td class="td2"><div class="help_a">設置用戶可以使用搜索功能的時間段(24小時制)，支持跨越零點搜索，例如:用戶在 每晚22:00 到 次日10:00 這段時間內可以使用搜索，搜索開啟于(點)設為:<b>22</b>；搜索關閉于(點)設為:<b>10</b>。<br />管理員與總版主不受此限制</div></td>
		</tr>
		<tr class="tr1 vt">
			<td class="td1">搜索返回結果數</td>
			<td class="td2"><input name="config[maxresult]" value="$db_maxresult" class="input input_wa" /></td>
			<td class="td2"><div class="help_a">搜索一次得到的最大數量</div></td>
		</tr>
		<tr class="tr1 vt" style="display:none">
			<td class="td1">搜索間隔時間[秒]</td>
			<td class="td2"><input name="config[schwait]" value="$db_schwait" class="input input_wa" /></td>
			<td class="td2"><div class="help_a">當搜索佔用很大資源時可以設置此項，用于控制全站搜索頻次。表示一個用戶搜索一次後，自己或其他用戶再次進行搜索所需要等待的時間。0或留空表示不限制</div></td>
		</tr>
		<!--tr class="tr1 vt">
			<td class="td1">熱門搜索關鍵詞</td>
			<td class="td2"><textarea class="textarea" name="config[hotwords]">$db_hotwords</textarea></td>
			<td class="td2"><div class="help_a">詞語之間用英文逗號","分隔, 建議參考<a href="admin.php?adminjob=searcher&action=statistic">搜索統計</a>後填寫</div></td>
		</tr-->
		<tr class="tr1 vt">
			<td class="td1">搜索過濾版塊ID</td>
			<td class="td2"><input name="config[filterids]" value="$db_filterids" class="input input_wa" /></td>
			<td class="td2"><div class="help_a">輸入版塊ID,用英文逗號","分隔.設置後,這些版塊中的帖子將不顯示到搜索結果中</div></td>
		</tr>
		
		<tr class="tr1 vt">
			<td class="td1">搜索類型擴展</td>
			<td class="td2">
				<ul class="list_A list_120">
					<li><input type="checkbox" value="diary" name="config[search_type_expand][]" {$search_type_expand['diary']}/> 日志</li>
					<li><input type="checkbox" value="group" name="config[search_type_expand][]" {$search_type_expand['group']}/> 群組</li>
					<li><input type="checkbox" value="cms" name="config[search_type_expand][]" {$search_type_expand['cms']} /> 文章</li>
				</ul>
			</td>
			<td class="td2"><div class="help_a">開啟的搜索類型可以讓用戶像搜索帖子一樣搜索此類型（開啟前請確認是否已開啟對應應用或模式）
</div></td>
		</tr>			
		<tr class="tr1 vt" style="display:none">
			<td class="td1">操作行為記錄</td>
			<td class="td2">
				<ul class="list_A list_120">
					<li><input type="checkbox" value="log_forums" name="config[operate_log][]" {$operate_log['log_forums']} /> 版塊</li>
					<li><input type="checkbox" value="log_threads" name="config[operate_log][]" {$operate_log['log_threads']} /> 帖子</li>
					<li><input type="checkbox" value="log_posts" name="config[operate_log][]" {$operate_log['log_posts']} /> 回復</li>
					<li><input type="checkbox" value="log_diarys" name="config[operate_log][]" {$operate_log['log_diarys']} /> 日志</li>
					<li><input type="checkbox" value="log_members" name="config[operate_log][]" {$operate_log['log_members']} /> 用戶</li>
					<li><input type="checkbox" value="log_colonys" name="config[operate_log][]" {$operate_log['log_colonys']} /> 群組</li>
				</ul>
			</td>
			<td class="td2"><div class="help_a">如果開啟操作行為記錄,如帖子,將對帖子的新增,刪除,更新行為進行記錄,用于實現其它功能的擴展</div></td>
		</tr>
        <tr class="tr1 vt">
            <td class="td1">圖文並茂</td>
            <td class="td2">
                <ul class="list_A list_80 cc fl mar20">
                    <li><input type="radio" value="1" name="config[openbuildattachs]" $openbuildattachs_Y>開啟</li>
                    <li><input type="radio" value="0" name="config[openbuildattachs]" $openbuildattachs_N>關閉</li>
                </ul>
                <div class="cc"></div>
            </td>
            <td class="td2"><div class="help_a">開啟後搜索帖子和顯示帖子中的圖片</div></td>
        </tr>
	</table>
    <div class="cc mb10"></div>
    <h2 class="h1">熱門關鍵字搜索設置</h2>
    <table width="100%" cellspacing="0" cellpadding="0">
        <tr class="tr1 vt">
            <td class="td1">顯示個數</td>
            <td class="td2" width="415"><input name="hotwordsconfig[shownum]" value="$db_hotwordsconfig[shownum]" class="input input_wa" id="shownum"/></td>
            <td class="td2"><div class="help_a">含自動調用和自定義關鍵字，0或者留空表示不顯示熱門關鍵字</div></td>
        </tr>
        <tr class="tr1 vt">
            <td class="td1">自動調用</td>
            <td class="td2">
                <ul class="list_A list_80 cc fl mar20">
                    <li><input type="radio" value="1" name="hotwordsconfig[openautoinvoke]" $openautoinvoke_Y  onclick="checkOpenInvoke();">開啟</li>
                    <li><input type="radio" value="0" name="hotwordsconfig[openautoinvoke]" $openautoinvoke_N onclick="checkOpenInvoke();">關閉</li>
                </ul>
                <div class="cc"></div>
            </td>
            <td class="td2"><div class="help_a"></div></td>
        </tr>
<!--
EOT;
$invokeperiodDisplay = $db_hotwordsconfig['openautoinvoke'] == 1 ? '' :'style = "display:none"';
print <<<EOT
-->
        <tr class="tr1 vt" id="invokeperiod" {$invokeperiodDisplay}>
            <td class="td1">自動調用周期</td>
            <td class="td2"><input name="hotwordsconfig[invokeperiod]" value="{$db_hotwordsconfig[invokeperiod]}" class="input input_wa" /> 天</td>
            <td class="td2"><div class="help_a">熱門關鍵字將根據此周期篩選相應關鍵字，如輸入“7”則代表調用7天內搜索最多的關鍵字，0或者留空表示不自動調用關鍵字</div></td>
        </tr>
        <tr class="tr1 vt">
            <td class="td1">熱門搜索關鍵字</td>
            <td class="td2">
						<div class="admin_tableB">
             <table id="keywordhottable"><tr>
                <td width="40">順序</td>
                <td width="180">關鍵字</td>
                <td width="60">數據類型</td>
                <td width="50"><!--
EOT;
if ($db_hotwordsconfig[shownum] > count($searchHotwords)) {
print <<<EOT
--><a href="javascript:;" class="s3" onclick="addtbody('cdiymode','cdiybody');">[添加]</a><!--
EOT;
}
print <<<EOT
-->
                </td>
            </tr>
            <tbody id="cdiymode" style="display:none"><tr><td style="padding-bottom:5px;"><input name="new_view[vieworder][]" class="input input_wd" style="width:30px;"/></td><td><input name="new_view[keyword][]" class="input input_wa" /></td><td>自定義</td><td><a class="cp s4" onclick="deltbody(this);">[刪除]</a></td></tr></tbody>
<!--
EOT;
foreach ($searchHotwords as $key => $value) {
$value[fromtype] = $value[fromtype] == 'custom' ? '自定義' : '自動調用';
print <<<EOT
--><tr><td style="padding-bottom:5px;"><input name="view[$value[id]][vieworder]" value="{$value[vieworder]}" class="input input_wd" style="width:30px;"/></td><td><input name="view[$value[id]][keyword]" value="{$value[keyword]}" class="input input_wa" /></td><td>{$value['fromtype']}</td><td><!--
EOT;
if ($value[fromtype] == "自定義") {
print <<<EOT
--><a class="cp s4" onclick="deltbody(this);getObj('FORM').submit();">[刪除]</a><!--
EOT;
}print <<<EOT
-->
</td></tr><!--
EOT;
}print <<<EOT
-->
            <tbody id="cdiybody"></tbody>
        </table>   
            </div>
            </td>
            <td class="td2"><div class="help_a">此處顯示的數量將根據熱門“關鍵字搜索設置”中“顯示個數”顯示。<br />
數據類型中“自動調用”指系統根據“自動調用周期”產生的關鍵字自動顯示。<br />關鍵字建議參考<a href="$db_adminfile?adminjob=searcher&action=statistic">搜索統計</a>後填寫</div></td>
        </tr>  
		</table>
	<div class="cc mb10"></div>
	<div class="tac mb10">
	<span class="btn"><span><button type="submit">提 交</button></span></span>
	</div>
	</div>
	</form>
</div>		
<script type="text/javascript">
function addtbody(mode,tbody){

	var num = getObj("keywordhottable").rows.length - 2;
	var shownum = getObj("shownum").value;
	if (num >= shownum) {
		alert("你已經添加了"+shownum+'個關鍵字。如需添加更多請修改“熱門關鍵字搜索設置”中“顯示個數”。');
		return false;
	}
	
    if (getObj(mode)) {
        var s = getObj(mode).firstChild.cloneNode(true);
        getObj(tbody).appendChild(s);
    }
}
function deltbody(obj){
    var o = obj.parentNode.parentNode;
    o.parentNode.removeChild(o);
	return false;
}

function checkOpenInvoke()
{
	var obj = document.getElementsByName('hotwordsconfig[openautoinvoke]');
     for(var i=0;i<obj.length;i++) {
        if(obj[i].checked == true){
           var commend = obj[i].value;
           break;
        }
     }
     getObj('invokeperiod').style.display = commend == 1 ? "" : 'none';
     return true;
}


</script>

<!--
EOT;
}elseif($action == "cp") {
if(!$job){print <<<EOT
-->
<div class="nav3 mb10">
	<ul class="cc">
		<li><a href="$basename">搜索設置</a></li>
		<li><a href="$basename&action=forum">版塊推薦</a></li>
		<li class="current"><a href="$basename&action=cp">關鍵字推送</a></li>
		<li><a href="$basename&action=statistic">搜索統計</a></li>
	</ul>
</div>
<div style="display: block;" class="admin_info mb10">
<h3 class="h1"><b>提示信息</b></h3>
<div class="legend"><ol><li>通過關鍵字的推送可以在帖子、文章、日志搜索結果上部根據關鍵字顯示推送內容。</li></ol></div>
</div>
<form action="$basename" method="post">
<input type="hidden" name="action" value="cp">
<h2 class="h1">搜索</h2>
<div class="admin_table mb10">
<table width="100%" cellspacing="0" cellpadding="0">
	<tr class="tr1 vt">
		<td class="td2">
            <span class="mr5">關鍵字:<input type="text" class="input input_wa" name="keyword" value="$keyword"/></span>
            <span class="bt2"><span><button type="submit" value="搜 索">搜 索</button></span></span>
        </td>
	</tr>
</table>
</div>
</form>
<form method="post" name="FORM" action="$basename&">
<input type="hidden" name="action" value="cp">
<h2 class="h1"><span class="fl mr10">關鍵字推送</span><a class="btn_add fl" href="$basename&action=$action&job=add" hidefocus="true"><i>添加推送</i></a></h2>
<div class="admin_table mb10">
<table width="100%" cellspacing="0" cellpadding="0" style="table-layout:auto;">
	<tr class="tr2">
		<td width="28" class="tac"><span onclick="CheckAll(document.FORM)" class="cp">全選</span></td>
		<td width="200">順序</td>
		<td width="300">關鍵字</td>
		<td>結束時間</td>
		<td>狀態</td>
		<td>操作</td>
	</tr>
<!--
EOT;
if (empty($adverts)) {print <<<EOT
-->
<tr><td class="p10" colspan="8"><div class="admin_tips">啊哦，沒有你要的信息！</div></td></tr>
<!--
EOT;
}else{
foreach ($adverts as $value){
$value[ifshow] = $value[ifshow] ? '<span class="s3">開啟</span>' : '<span class="gray">關閉</span>';
print <<<EOT
-->
	<tr class="tr1 vt">
		<td class="td2">&nbsp;<input type="checkbox" name="selid[]" value="$value[id]" /></td>
		<td class="td2"><input type="text" class="input input_wc" name="orderby[{$value['id']}]" value="$value[orderby]"></td>
		<td class="td2">{$value['keyword']}</td>
		<td class="td2">{$value['endtime']}</td>
		<td class="td2">{$value['ifshow']}</td>
		<td class="td2">
			<a class="mr20" href="$basename&action=$action&job=edit&id=$value[id]" title="編輯">[編輯]</a><a href="$basename&action=$action&job=del&selid[]=$value[id]" onclick="if(!confirm('您確認要刪除該廣告嗎?'))return false;" title="刪除">[刪除]</a>
		</td>
	</tr>
<!--
EOT;
}}print <<<EOT
-->
</table>
</div>
<input type="hidden" name="job" value="del" id="job"/>
<div class="mg_pw">
<span class="fr">$pages</span>
      <ul>
           <li><span class="bt2"><span><button type="button" onclick="CheckAll(document.FORM)">全 選</button></span></span></li>
           <li><span class="bt2"><span><button type="submit" onclick="getObj('job').value='del';return confirm('您確認要進行此操作嗎?');">刪 除</button></span></span></li>
           <li><span class="bt2"><span><button type="submit" onclick="getObj('job').value='commit';">排 序</button></span></span></li>
      </ul>
</div>

</form>

<!--
EOT;
}elseif($job=='add' || $job=='edit'){print <<<EOT
-->
<div class="nav3 mb10">
	<ul class="cc">
		<li><a href="$basename">搜索設置</a></li>
		<li><a href="$basename&action=forum">版塊推薦</a></li>
		<li><a href="$basename&action=cp">關鍵字推送</a></li>
		<li><a href="$basename&action=statistic">搜索統計</a></li>
<!--
EOT;
if($job=='edit'){print <<<EOT
-->
		<li class="current"><a href="$basename&action=$action&job=edit&id=$id">編輯推送</a></li>
<!--
EOT;
}else{print <<<EOT
-->
		<li class="current"><a href="$basename&action=$action&job=add">添加推送</a></li>
<!--
EOT;
}print <<<EOT
-->
	</ul>
</div>
<script type="text/javascript" src="js/date.js"></script>
<form method="post" name="FORM" action="$basename&job=save&" onsubmit="checkData();return false;">
<input type="hidden" name="action" value="cp">
<input type="hidden" name="id" value="$id">
<h2 class="h1">添加推送</h2>
<div class="admin_table mb10">
<table width="100%" cellspacing="0" cellpadding="0">
	<tr class="tr1 vt">
		<td class="td1">關鍵字<span class="s1">*</span></td>
		<td class="td2">
			<input type="text" class="input input_wb" name="advert[skey]" value="$advert[skey]" id="skey"> 當用戶使用關鍵字中的任意字搜索帖子或文章或日志時，將顯示此條推送內容
		</td>
		<td class="td2"><div class="help_a"></div> </td>
	</tr>
	<tr class="tr1 vt">
		<td class="td1">順序<span class="s1"></span></td>
		<td class="td2">
			<input type="text" class="input input_wb" name="advert[orderby]" value="$advert[orderby]" id="orderby"> 搜索結果此推送顯示順序，值大的將排在後面
		</td>
		<td class="td2"><div class="help_a"></div> </td>
	</tr>
	<tr class="tr1 vt">
		<td class="td1">有效時間</td>
        <td class="td2">
			<p class="mb10 cc">
            <div class="input_img fl"><i onclick="this.nextSibling.onclick()" class="input_time" title="選擇時間">選擇時間</i><input name="advert[starttime]" id="starttime" value="$advert[starttime]" onClick="setAdvert.initDate(this.id);" type="text" /></div><span class="p_lr_10 fl">-</span>
			<div class="input_img fl mr20"><i onclick="this.nextSibling.onclick()" class="input_time" title="選擇時間">選擇時間</i><input name="advert[endtime]" id="endtime" value="$advert[endtime]" onClick="setAdvert.initDate(this.id);" type="text" /></div>
            <p class="gray mb10">格式︰yyyy-mm-dd</p>
            有效時間段設置
<!--
EOT;
if ($showddate) {print <<<EOT
-->
			</p><div id='showddate'></div>
<!--
EOT;
}else{print <<<EOT
-->
			<span class="bt2"><span><button type="button" value="設置詳細展示時間" onclick="getObj('showddate').style.display='';this.style.display='none';">設置詳細展示時間</button></span></span></p>
			<div id='showddate' style="display:none;">
<!--
EOT;
}print <<<EOT
-->
				<div class="admin_table_c" style="width:auto;">
				<table width="100%" cellspacing="0" cellpadding="0">
					<tr>
						<td class="s4" width="60">按日期</td>
						<td title="有效時間段內的按日期展示"><ul id="ddate_id" class="list_A list_80 cc" style="width:480px;"></ul></td>
					</tr>
					<tr>
						<td class="s4">按星期</td>
						<td title="有效時間段內的按星期展示"><ul id="dweek_id" class="list_A list_80 cc" style="width:480px;"></ul><p>設置有效時間段內的具體展示日期。兩種方式，任選其一，均可生效</p></td>
					</tr>
					<tr title="可以設置有效時間段內每天的哪幾個時間段顯示">
						<td class="s4">展示時間</td>
						<td><span id="dtime_id"></span><p>設置每日展示小時段，按Ctrl或Shift進行多選)</p></td>
					</tr>
				</table>
                </div>
			</div>
		</td>
		<td class="td2"><div class="help_a"></div> </td>
	</tr>
	<tr class="tr1 vt">
		<td class="td1">顯示內容<span class="s1">*</span></td>
		<td class="td2">
			<textarea name="advert[code]" class="textarea fl mr10" id="code" style="height:155px;width:300px;">$advert[code]</textarea>
			<div class="fl" style="width:500px">
			搜索結果中顯示的內容，支持html代碼。如︰&lt;dl&gt;  &lt;dt&gt;  &lt;a href=&quot;標題連接地址&quot; target=&quot;_blank&quot; class=&quot;tlink&quot;&gt;這里是標題&lt;/a&gt;  &lt;/dt&gt;  &lt;dd&gt;  &lt;div class=&quot;text&quot;&gt;這里是文字簡介&lt;/div&gt;  &lt;div class=&quot;author&quot;&gt;&lt;cite&gt;這里是鏈接地址&lt;/cite&gt;&lt;/div&gt;  &lt;/dd&gt;&lt;/dl&gt;<br />
			<span class="s1">將顯示為如下效果:</span> <div class="cc"><img src="images/admin/tuisongcode.gif">
</div>
			
			</div>
			

		</td>
		<td class="td2"><div class="help_a"></div> </td>
	</tr>
		<tr class="tr1 vt">
		<td class="td1">狀態<span class="s1"></span></td>
		<td class="td2">
			<ul class="list_A list_80 cc fl mar20">
				<li><input type="radio" name="advert[ifshow]" value="1" $ifshow_Y >開啟</li>
				<li><input type="radio" name="advert[ifshow]" value="0" $ifshow_N >關閉</li>
			</ul>
		</td>
		<td class="td2"><div class="help_a"></div> </td>
	</tr>
</table>
</div>
<div class="tac mb10">
	<span class="btn"><span><button type="submit">提 交</button></span></span>
</div>
</form>
<script type="text/javascript">
function checkData(){
    if(getObj("skey").value == ""){
        alert("推送關鍵字不能為空");
        return false;
    }
	if(getObj("code").value == ""){
        alert("推送顯示內容不能為空");
        return false;
    }
    submit();
}
</script>

<script type="text/javascript">
var setAdvert = {
    handler : '',
    initDate : function(id){
        ShowCalendar(id);
        setAdvert.handler = setInterval(function(){
            setAdvert.checkDate(setAdvert.handler);
        },1000);
    },

    checkDate : function(){
        var starttime = getObj("starttime").value;
        var endtime = getObj("endtime").value;
        if(endtime == "" || starttime == ""){
            return false;
        }
        var startD  = new Date(Date.parse(starttime.replace(/-/g,"/")));
        var endD = new Date(Date.parse(endtime.replace(/-/g,"/")));
        if(startD-endD>0){
            getObj("endtime").value = "";
            alert("抱歉，結束時間不能小于開始時間");
            return false;
        }
        var startArray = starttime.split("-");
        var endArray = endtime.split("-");
        if(startArray[0]<endArray[0]){
            return false;
        }
        //two month
        if(endArray[1]-startArray[1] <=2){
            var dateRange = setAdvert.getDateRange(starttime,endtime);
        }
        if(endArray[1]==startArray[1] && endArray[2]==startArray[2]){
            //
        }
        showddate(starttime,endtime);
        clearInterval(setAdvert.handler);
    },

    getDateRange : function(starttime,endtime){
        var unit_day = 86400*1000;
        var startT = Date.parse(starttime.replace(/-/g,"/"));
        var endT = Date.parse(endtime.replace(/-/g,"/"));
        var startN = startT+unit_day;
        var dateArray = [];
        var weekArray = [];
        for(i=startT;i<=endT;i+=unit_day){
            var startND = new Date(i);
            var td = startND.getDate();
            var wd = startND.getDay();
            dateArray.push(td);
            weekArray.push(wd);
        }
        return {days:dateArray,weeks:weekArray};
    },

    disableDate : function(valids){
        var ddate = getObj("ddate_id").getElementsByTagName("input");
        for(i=0;i<ddate.length;i++){
            var value = ddate[i].value;
            if(valids.indexOf(value) == -1){
                ddate[i].disabled = "disabled";
            }
        }
    },

    disableWeek : function(valids){
        var dweek = getObj("dweek_id").getElementsByTagName("input");
        for(i=0;i<dweek.length;i++){
            var value = dweek[i].value;
            if(valids.indexOf(value) != -1){
                dweek[i].disabled = "disabled";
            }
        }
    },

    disableTime : function(valids){
        var dtime = getObj("dtime_id").getElementsByTagName("option");
        for(i=0;i<dtime.length;i++){
             var value = dtime[i].value;
             if(valids.indexOf(value) != -1){
                dtime[i].disabled = "disabled";
             }
        }
    }

}
~function()
{
   CheckDate=
	{
	   getMaxs:function(begin,end,selected)
		{
			selected=selected||{days:{},weeks:{},hours:{}};
			selected.days=selected.days||{};
			selected.weeks=selected.weeks||{};
			selected.hours=selected.hours||{};

			var s=new Date(begin.replace(/\-/g,'/')).getTime();
			var e=new Date(end.replace(/\-/g,'/')+" 23:59:59").getTime();
			if(e<s)
			{
				return !!alert("結束日期不能比開始日期早！");
			}
			var c=24*3600*1000;
			var maxDays=[];
			var maxWeekDays=[];
			var dt;
			for (var i=s,len=e; i<len; i=i+c)
			{
				dt=new Date(i).getDate();
				(","+maxDays.join(",")+",").indexOf(","+(dt<10?"0"+dt:dt)+",")>=0?0:maxDays.push(dt<10?"0"+dt:""+dt);
				dt=new Date(i).getDay();
				(","+maxWeekDays.join(",")+",").indexOf(","+dt+",")>=0?0:maxWeekDays.push(dt);
				if(maxDays.length>=31&&maxWeekDays.length>=7)
				{
					break;
				}
			}
			var d=[];
			var g=[];
			maxDays.sort();
			maxWeekDays.sort();
			for (var i=0,len=maxDays.length; i<len; i++)
			{
				maxDays[i]=maxDays[i].replace(/^0/,'');
				d[i]="<li><input name='ddate[]' type=checkbox value='"+maxDays[i]+"' "+(selected.days[maxDays[i]]?" checked":"")+">"+maxDays[i]+"</li>";
			}
			var w="日一二三四五六".split("");
			for (var i=0,len=maxWeekDays.length; i<len; i++)
			{
				g[i]=[maxWeekDays[i]==0?7:maxWeekDays[i],"<li><input name='dweek[]' type=checkbox value='"+i+"'  "+(selected.weeks[maxWeekDays[i]]?" checked":"")+">星期"+w[maxWeekDays[i]] + "</li>"];
			}
			g.sort();
			for (var i=0,len=g.length; i<len; i++)
			{
				g[i]=g[i][1];
			}

			var h=[];
			for (var i=1,len=24; i<=len; i++)
			{
				h[i]=(i-1<10?"0"+(i-1):i-1)+":00 - "+(i<10?"0"+i:i)+":00";
				h[i]="<option value='"+i+"' "+(selected.hours[i]?"selected":"")+"> "+h[i]+" </option>";
			}
			return {days:d,weeks:g,hours:h};
		}
	};
}
();
function showddate(stime,etime,data) {
	var a=CheckDate.getMaxs(stime,etime,data);
	getObj('ddate_id').innerHTML = a.days.join("");
	getObj('dweek_id').innerHTML = a.weeks.join("");
	getObj('dtime_id').innerHTML = "<select name='dtime[]' class='select_wa mb5' style='height:180px;' multiple><option value=''>&nbsp;</option>"+a.hours.join("")+"</select>";
}


<!--
EOT;
if ($showddate) {print <<<EOT
-->
showddate('$advert[starttime]','$advert[endtime]',$showddate);
<!--
EOT;
}else{print <<<EOT
-->
showddate('$advert[starttime]','$advert[endtime]');
<!--
EOT;
}print <<<EOT
-->
</script>


<!--
EOT;
}
print <<<EOT
-->
<!--
EOT;
} elseif ($action == 'forum') {print <<<EOT
-->

	<div class="nav3 mb10">
	<ul class="cc">
		<li><a href="$basename">搜索設置</a></li>
		<li class="current"><a href="$basename&action=forum">版塊推薦</a></li>
		<li><a href="$basename&action=cp">關鍵字推送</a></li>
		<li><a href="$basename&action=statistic">搜索統計</a></li>
	</ul>
	</div>
	<div class="admin_info mb10" style="display: block;">
	<h3 class="h1"><b>提示信息</b></h3>
	<div class="legend"><ol><li>推薦的版塊將在用戶搜索時展示在帖子搜索的左側上方，未推薦的版塊當用戶點擊“更多”時才會顯示。</li><li>建議不要推薦過多板塊以確保推薦效果。</li></ol></div>
	</div>
	<h2 class="h1">搜索</h2>
	<div class="admin_table mb10">
	<table width="100%" cellspacing="0" cellpadding="0">
		<tbody><tr class="tr1 vt">
			<td class="td2">
				<span class="mr5">版塊搜索:<input class="input input_wa" name="forumname" id="forumname"></span>
				<span class="bt2"><span><button type="button" value="搜索" onclick="searchForum();">搜索</button></span></span>
			</td>
		</tr>
	</tbody></table>
	</div>
<h2 class="h1"><span  class="mr10">推薦版塊</span> <span class="linka"><a onclick="setall('open');" href="javascript:;">全部展開</a> | <a onclick="setall('close');" href="javascript:;">全部關閉</a></span></h2>
<form action="$basename&" method="post">
<input type="hidden" name="action" value="editforum" />
<div class="admin_table mb10">
<table id="ftable" cellspacing="0" cellpadding="0" width="100%">
    <tr class="tr2">
        <td>[推薦順序]版塊名稱</td>
        <td width="160">是否推薦</td>
        <td></td>
    </tr>
<!--
EOT;
foreach ($catedb as $cate) {
$tmpStyle = $threaddb[$cate['fid']] ? 'expand expand_b' : 'expand expand_d';
print <<<EOT
-->
	<tr class="vt tr1" onmouseover="showAdd('$cate[fid]')" onmouseout="hiddenAdd('$cate[fid]')">
		<td class="td3 tdcur">
			<i id="bt_$cate[fid]" class="$tmpStyle" onclick="cateopen('$cate[fid]')"></i>
			<span class="fourm_name">$cate[name]</span>
			<span class="fourm_name" id="fourm_edit_box_$cate[fid]"></span>
			<font class="gray mr20">FID:$cate[fid]</font>&nbsp;&nbsp;
		</td>
		<td class="td2">
		</td>
        <td class="td2">
           
        </td>
	</tr>
<!--
EOT;
if ($threaddb[$cate['fid']]) {print <<<EOT
-->
	<tbody id="cate_$cate[fid]">
<!--
EOT;
foreach ($threaddb[$cate['fid']] as $thread) {
$isspace = str_repeat($space,$thread['type'] == 'forum' ? 0 : ($thread['type'] == 'sub' ? 1 : 2));
$disabledByType = $thread['f_type'] != 'forum' ? 'disabled="disabled"' : '';
print <<<EOT
-->
	<tr class="vt tr1" onmouseover="showAdd('$thread[fid]')" onmouseout="hiddenAdd('$thread[fid]')">
		<td class="td3">
			{$isspace}
                <i class="lower"></i>
                <input class="input input_wd mr5" name="order[$thread[fid]]" value="$thread[vieworder]" type="text">
                <span class="fourm_name">$thread[name]</span>
                <span id="fourm_edit_box_$thread[fid]" class="fourm_name"></span>
                <font class="gray">FID:$thread[fid]</font>
		</td>
		<td class="td2">
			<input type="checkbox" name="fidcommend[$thread[fid]]" {$thread[isrecommend]} {$disabledByType}>
		</td>
		<td class="td2">
            
        </td>
	</tr>
<!--
EOT;
}print <<<EOT
-->
	</tbody>
<!--
EOT;
}}if ($forum_L) {print <<<EOT
-->
	<tr class="tr1 vt">
		<td class="td2" colspan="6">
        	<i id="bt_error" class="expand expand_a" onclick="cateopen('error')" ></i><span class="s1 mr10">異常版塊</span>(重新設置上級版塊可以恢復正常)
        </td>
	</tr>
	<tbody id="cate_error">
<!--
EOT;
foreach ($forum_L as $key => $thread) {
$isspace = str_repeat($space,$thread['type'] == 'forum' ? 0 : ($thread['type'] == 'sub' ? 1 : 2));
print <<<EOT
-->
	<tr class="tr1 vt">
		<td class="td3">
			<div class="fourm"><i class="lower"></i>
				<input class="input input_wd" name="order[$thread[fid]]" value="$thread[vieworder]" type="text">
				$thread[name]
				<font class="gray">FID:$thread[fid]</font>
			</div>
		</td>
		<td class="td2"><input class="input input_wa" name="forumadmin[$thread[fid]]" value="$thread[forumadmin]" type="text"></td>
		<td class="td2">
            <a href="$basename&action=edit&fid=$thread[fid]" class="mr10">[編輯]</a>
            <a href="$basename&action=delete&fid=$thread[fid]">[刪除]</a>
        </td>
	</tr>
<!--
EOT;
}print <<<EOT
-->
	</tbody>
<!--
EOT;
}print <<<EOT
-->
</table>
</div>
<div class="mb10 tac"><span class="btn"><span><button type="submit">提 交</button></span></span></div>
</form>

<script type="text/javascript" src="js/pw_ajax.js"></script>
<script type="text/javascript">
function cateopen(id) {
	var o = getObj('cate_' + id);
	if (o == null) return;
	if (o.style.display == 'none') {
		o.style.display = '';
		getObj('bt_' + id).className = 'expand expand_b';
	} else {
		o.style.display = 'none';
		getObj('bt_' + id).className = 'expand expand_a';
	}
}
function setall(t) {
	var tbs = getObj('ftable').getElementsByTagName('tbody');
	for (var i = 0; i < tbs.length; i++) {
		if (!tbs[i].id.match(/^cate/)) {
			continue;
		}
		var id = tbs[i].id.substr(5);
		if (t == 'open') {
			tbs[i].style.display = '';
			getObj('bt_' + id).className = 'expand expand_a';
		} else {
			tbs[i].style.display = 'none';
			getObj('bt_' + id).className = 'expand expand_b';
		}
	}
}
function IsElement(id){
	return document.getElementById(id)!=null ? true : false;
}
function showAdd(id){
	if (IsElement('addbt_' + id)) {
		getObj('addbt_' + id).style.display = '';
	}
}
function hiddenAdd(id){
	if (IsElement('addbt_' + id)) {
		getObj('addbt_' + id).style.display = 'none';
	}
}
function adminCFname(){

}

function searchForum(){
	var is_ie = ((agt.indexOf('msie')!=-1) && (agt.indexOf('opera')==-1)),
		is_ns = (document.layers);
		is_w3 = (document.getElementById && !is_ie),
		searchname = getObj('forumname').value,
		forumtable = getObj('ftable'),
		span = forumtable.getElementsByTagName('span'),
		first = null;
	for (var i=0;i<span.length;i++) {
		var ocateid = span[i].parentNode.parentNode.parentNode;
		var cateid = ocateid.id;
		if(span[i].innerHTML.indexOf('font')){
			span[i].innerHTML = span[i].innerText || span[i].textContent;
		}
		if (span[i].innerHTML != '' && span[i].innerHTML.indexOf(searchname) != -1 && cateid != 'ftable') {
			span[i].innerHTML = span[i].innerHTML.replace(searchname,'<font style="color:red; background-color:yellow;">'+searchname+'</font>');
			if(!first){
				first = span[i];	
			}
			var cid = cateid.substr(5);
			if (ocateid.style.display == 'none') {
				ocateid.style.display = '';
				getObj('bt_' + cid).className = 'close fl';
			}
			if (is_w3 || is_ns) {
				var m = 0;
				while(m<2){
					m++;
					parent.find(searchname);
				}
			} else if (is_ie) {
				var txt = parent.document.body.createTextRange();
				if (txt.findText(searchname)){
					txt.select();
				}
			}
		}
		
	}
	if(first){
		first.scrollIntoView();
	}else{
		alert('找不到到您搜索的版塊！');
	}
}

</script>
	
<!--
EOT;
} elseif ($action == 'statistic') {print <<<EOT
-->
<div class="nav3 mb10">
<ul class="cc">
	<li><a href="$basename">搜索設置</a></li>
	<li><a href="$basename&action=forum">版塊推薦</a></li>
	<li><a href="$basename&action=cp">關鍵字推送</a></li>
	<li class="current"><a href="$basename&action=statistic">搜索統計</a></li>
</ul>
</div>
<script type="text/javascript" src="js/date.js"></script>
<form method="post" action="{$basename}&action=$action">
<h2 class="h1">搜索統計</h2>
<div class="admin_table mb10">
<table width="100%" cellspacing="0" cellpadding="0">
	<tr class="tr1 vt">
		<td class="td1">關鍵字</td>
		<td class="td2"><input type="text" name="keyword" value="$keyword" class="input input_wa" /> 可使用通配符 "*"，多個作者用英文半角逗號","分隔       </td>
	</tr>
	<tr class="tr1 vt">
		<td class="td1">日期</td>
		<td class="td2">
		<div class="input_img fl"><i onclick="this.nextSibling.onclick()" class="input_time" title="選擇時間">選擇時間</i><input type="text" name="createtime_s" value="$createtime_s" id="createtime_s" onclick="javascript:ShowCalendar(this.id)"></div><span class="p_lr_10 fl">至</span><div class="input_img fl"><i class="input_time" title="選擇時間">選擇時間</i> <input type="text" name="createtime_e" id="createtime_e" value="$createtime_e" onclick="javascript:ShowCalendar(this.id)"></div>
		</td>
	</tr>
</table>
</div>
<br />
<div class="mb10 tac">
	<span class="btn"><span><button type="submit">提 交</button></span></span>
</div>
</form>

<form action="$basename&action=$action&" method="post" name="FORM">
<h2 class='h1'>統計列表   <span class="linka">僅顯示搜索次數最多的前500條！</span></h2>
<div class="admin_table mb10">
<table width="100%" cellspacing="0" cellpadding="0">
	<tr class="tr2 vt td_bgB">
		<td width="210">關鍵字</td>
		<td>搜索次數</td>
	</tr>
<!--
EOT;
if (empty($statisticDb)) {print <<<EOT
-->
<tr><td class="p10" colspan="7"><div class="admin_tips">啊哦，沒有你要的信息！</div></td></tr>
<!--
EOT;
}else{
foreach ($statisticDb as $key => $value) {print <<<EOT
-->
	<tr class="tr1 vt">
		<td class="td2">{$value['keyword']}</td>
		<td class="td2">{$value['times']}</td>
	</tr>
<!--
EOT;
}}print <<<EOT
-->
</table>
<div>$pages</div>

</div>
</form>
<!--
EOT;
}
include_once PrintEot('adminbottom');
?>-->