<?php 


/** 
***************************************************
*欢迎使用免费版SiteTeam企业建站软件！
*这是一个专业为搜索引擎营销而设计的，极稳定、极易维护的建站软件！
*官方客服：help@php.net.cn
*官方下载网址：http://www.SiteTeam.cn 
***************************************************
**/



 if(!defined('IN_SITETEAM')) {exit('Access Denied');}?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SiteTeam Administrator's Control Panel</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<link rel="stylesheet" href="admin/images/admincp.css" type="text/css" media="all" />
<link rel="stylesheet" href="admin/images/form.css" type="text/css" media="all" />
<script src="admin/js/common.js" type="text/javascript"></script>
<script src="skin/common.js" type="text/javascript"></script>
</head>
<body>
<script type="text/JavaScript">if(parent.$('admincpnav')) parent.$('admincpnav').innerHTML='开始&nbsp;&raquo;&nbsp;外链关键词';</script>
<div class="container" id="cpcontainer">
  <div class="itemtitle">
    <h3>关键词工具导航</h3>
    <ul class="tab1">
      <li><a><span>共有<?=count($words_external_data)?>个关键词</span></a></li>
	  <li><a href="javascript:start_task(0)"><span>启动全部更新</span></a></li>
	  <li><a href="javascript:start_task(1)"><span>启动局部更新</span></a></li>
	  <li><a href="javascript:stop_task()"><span>停止本次任务</span></a></li>
    </ul>
  </div>
  
  <div class="tb tb2 nobdb">
    <ul id="postform">
    <?php if (is_array($words_external_data) && count($words_external_data) > 0) foreach ($words_external_data as $k => $v) {?>
    <li style="width:180px; float:left">&nbsp; <a <?php if(count($v) == 1){?>href="<?=@$v[0]?>" target="_blank"<?php }?>  title="<?php if (is_array($v) && count($v) > 0) foreach ($v as $url) {?> <?=$url."\n"?> <?php  }?>"><?=$k?></a> (<span id='msg_<?=substr(md5($k), 0, 8)?>'><?=count($v)?></span>)&nbsp;</li>
    <?php  }?>
	</ul>
  </div>
</div>

<script language="javascript" type="text/javascript">
<?php $i = 0;$words_external_data=array_reverse($words_external_data);?>
var task = new Array();
<?php if (is_array($words_external_data) && count($words_external_data) > 0) foreach ($words_external_data as $k => $v) {?>
task['<?=++$i?>'] = 'words=<?=rawurlencode($k)?>&id=<?=substr(md5($k), 0, 8)?>&num=<?=count($v)?>';
<?php  }?>

//任务状态
var task_status = 1;
//任务启劝状态
var start_status = 0;

function run_task() {
	var arr = task.pop();
	if (typeof(arr) == 'undefined') {
		return false;
	}
	
	var str = arr.split("&");
	for (var i in str) {
		var temp = str[i];
		var tmp = temp.split("=");
		if (tmp[0] == 'words') var words = tmp[1];
		if (tmp[0] == 'id') var id = tmp[1];
		if (tmp[0] == 'num') var num = tmp[1];
	}
	
	if (start_status == 0) {
		showContent('msg_' + id, "admin.php?action=keywords&operation=external_list&words=" + words);
	} else if(start_status == 1) {
		if (num < 1) {
			showContent('msg_' + id, "admin.php?action=keywords&operation=external_list&words=" + words);
		} else {
			run_task();
		}
	}
	
	//如果遇到作务退出
	if (task_status == 4) return false;
	
	//再次执行
	window.setTimeout("run_task()",1000);
	
}
//开始任务
function start_task(status) {
	if (confirm('此操作需要几分钟或更长时间，启动之后，本次任务未完成之前，最好不要刷页面，确定要进行吗？')){
		start_status = status;
		task_status = 1;
		window.setTimeout("run_task()",1000);
	}
}
//结束任务
function stop_task() {
	task_status = 4;
}
</script>
</body>
</html>
