<?php
/*
**U2自动链 后台管理系统
**admin.php
**By 冬筠 qq 42 6420
*/
ob_start();
require_once "./inc/common.inc.php";
require_once "./inc/links.inc.php";
require_once "./inc/splitword.func.php";
$adminkey = $_COOKIE['chenglinks'] ? 1 : 0;
if($upzt){
	if(is_array($delete) && count($delete)){
		$ids = idarray($delete);
		$db -> query("UPDATE {$tablepre}link SET classid='$ztid' WHERE id IN($ids)");
		}
}
if($shgest){
	if(is_array($delete)) {
		$ids = idarray($delete);
		$query = $db -> query("SELECT * FROM {$tablepre}link WHERE id IN($ids)");
		while($ssdb = $db-> fetch_array($query)) {	
			$dig=$ssdb['result'] ? 0 : 2;
			$db -> query("UPDATE {$tablepre}link SET result='$dig' WHERE id='$ssdb[id]'");
		}		
	}
}
if($heigest){
	if(is_array($delete)) {
		$ids = idarray($delete);
		$query = $db -> query("SELECT * FROM {$tablepre}link WHERE id IN($ids)");
		while($ssdb = $db-> fetch_array($query)) {	
			$dig=$ssdb['result'] ? 1 : 2;
			$db -> query("UPDATE {$tablepre}link SET result='$dig' WHERE id='$ssdb[id]'");
		}		
	}
}
if($digest){
	if(is_array($delete)) {
		$ids = idarray($delete);
		$query = $db -> query("SELECT * FROM {$tablepre}link WHERE id IN($ids)");
		while($ssdb = $db-> fetch_array($query)) {	
			$dig=$ssdb['result'] ? 2 : 5;
			$db -> query("UPDATE {$tablepre}link SET result='$dig' WHERE id='$ssdb[id]'");
		}		
	}
}

if($delgest){
	if(is_array($delete)) {
		$ids = idarray($delete);
		$db -> query("DELETE FROM {$tablepre}link WHERE id IN($ids)");
	}
}

function mainusertou($message,$url){
	$a="&nbsp;<a href=admin.php>管理首页</a> &raquo; <samp>".$message."</samp>";
	return $a;
	}
	function Getstr($str){
	$str=str_replace("<","",$str);
	$str=str_replace(">","",$str);
	$str=str_replace("=","",$str);
	$str=str_replace("'","",$str);
	$str=trim($str);
	return $str;
	}
	
	function show($message,$url){
	$a="<div class=altbg2 align=center><br><br><br><strong><samp>".$message."</samp></strong><br><br><a href=".$url.">请点击此处返回!</a><br><br></div>";
	return $a;
	}

function slist($lists = array(),$id = 0,$step=0){
	$data = '';
	if(count($lists)){	
		foreach($lists[$id] AS $key => $sort){		
					$trcolor=!$sort['upid'] ? "#F1FAFE" : "#FFFFFF";
					$data.='<tr bgcolor="'.$trcolor.'" align="center" ><td class="smalltxt" width="8%" style="border-bottom:1px solid #DAEEFA;">'.$sort['id'].'</td><td style="border-bottom:1px solid #DAEEFA;" width="15%"><select name="upidnew['.$sort['id'].']"><option value="0">------</option>'.sortselect($lists,$sort['upid']).'</select></td><td style="border-bottom:1px solid #DAEEFA;" align="left">'.($sort['upid']>0?'├':'').str_repeat('----',$step).'<input type="text" name="sortnamenew['.$sort['id'].']" value="'.$sort['sortname'].'"size="15"></td><td style="border-bottom:1px solid #DAEEFA;" width="10%"><input stype="text" name="foldersnew['.$sort['id'].']" value="'.$sort['folders'].'" size="5"></td><td style="border-bottom:1px solid #DAEEFA;" width="10%"><input type="text" name="ordermodenew['.$sort['id'].']" Value="'.$sort['ordermode'].'" size="5"></td style="border-bottom:1px solid #DAEEFA;" width="10%"><td style="border-bottom:1px solid #DAEEFA;" width="10%"><a href="?glcz=delsort&delsort='.$sort['id'].'" onclick="return check(\'该操作不可恢复，你确认要删除？\', \'?glcz=delsort&delsort='.$sort['id'].'\');">删除</a></td></tr>'."\n";
			
			if(count($lists[$sort['id']])){
				$data.=slist($lists,$sort['id'],$step+1);				
			}
		}
	}
	return $data;
}

$sorts=$fsorts=$uploads=array();
$query = $db -> query("SELECT * FROM {$tablepre}sclass ORDER BY ordermode ");
while($sort = $db -> fetch_array($query)){
	$sorts[$sort['id']]=$sort;
	$fsorts[$sort['upid']][$sort['id']]=$sort;
}
$glcz=Getstr($_GET["glcz"]);

if ($loginsubmit) {
		$managekey = md5(trim($managekey));
		if ($managekey == $sitepass) {
			setcookie('chenglinks','1');
		}
		echo '<html><body><script type="text/javascript" language="javascript">parent.reloader()</script></body></html>';
		exit;
	}
if ($nologin) {
		setcookie('chenglinks','');
		echo '<html><body><script type="text/javascript" language="javascript">parent.reloader()</script></body></html>';
		exit;
	}
if($glcz=='daourl') {
$outstr="";
$query = $db -> query("SELECT * FROM {$tablepre}link  WHERE imgok='0' and result<>'1' ORDER BY id DESC");
while($link = $db -> fetch_array($query)){
$outstr .= $link['url']."\n";
}
if($outstr){
$type = "txt";
$id= "url";
    $fp = fopen( "js/url.".$type, "w" );
    $outstr = trim( $outstr );
    fwrite( $fp, $outstr, strlen( $outstr ) );
    fclose( $fp );
    $fp = fopen( "js/".$id.".".$type, "r" );
    header( "Content-type:".$type );
    header( "Accept-Ranges: bytes" );
    header( "Accept-Length: ".filesize( "js/".$id.".".$type ) );
    header( "Content-Disposition: attachment; filename=".$id.".".$type );
    echo fread( $fp, filesize( "js/".$id.".".$type ) );
    fclose( $fp );
    unlink( "js/".$id.".".$type );
    $db -> query("Update {$tablepre}link set imgok=1; ");
}
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?=$charset;?>" />
<title>管理后台</title>
<style type="text/css">
<!--
body,td {font-family: Geneva, Arial, Helvetica, sans-serif, Tahoma;font-size: 12px;color:#1876b7;}
.login {font-family: Geneva, Arial, Helvetica, sans-serif, Tahoma;font-size: 12px;height: 16px;border-top-width: 1px;border-right-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-top-color: #FFFFFF;border-right-color: #EEEEEE;border-bottom-color: #EEEEEE;border-left-color: #FFFFFF;background-color: #f2f2f2;}
input,textarea {font-family: Geneva, Arial, Helvetica, sans-serif, Tahoma;font-size: 12px;border-top-width: 1px;border-right-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-top-color: #FFFFFF;border-right-color: #EEEEEE;border-bottom-color: #EEEEEE;border-left-color: #FFFFFF;background-color: #f2f2f2;}
a {color: #1876b7;text-decoration: none;}
a:hover {color: #000000;text-decoration: underline;}
.smalltxt{ font: 11px Arial, Tahoma; }
Input,select,textarea{ font: 11px Tahoma, Verdana; color: #000000; font-weight: normal; background-color: #F8F8F8; }
form{ margin: 0; padding: 0;}
select{ font: 11px Arial, Tahoma; color: #000000; font-weight: normal; background-color: #F8F8F8; }
.nav{ font: 12px Tahoma, Verdana; color: #000000; font-weight: bold; }
.nav a{ color: #000000;}
.header{ font: 12px Tahoma, Verdana; color: #1876B7; font-weight: bold;background-color: #DAEEFA;background-image:url(images/header.gif);}
.header a{ color: #1876b7; }
.category{ font: 11px Arial, Tahoma; color: #000000; background-color: #EEF6F9; }
.tableborder{ background: #DCEEF6; border: 1px solid #98D5EC }
 .smalltxt{ font: 11px Arial, Tahoma; }
.bold{ font-weight: bold; }
.altbg1{ background: #F8F8F8; width: 320px;}
.altbg2{ background: #FFFFFF; text-align:left;}
.maintable{ width: 98%; background-color: #FFFFFF; }
.menu {color:#FFFFFF;}
.menu a{color:#FFFFFF;font-weight:bold;}
.menu a:hover{color:#CCFFFF;}
.lian_a{border:1px #333333 solid; padding:2px;background-color:#F9F9F9;font-size:12px}
.text_axing{ border:#999999 1px solid; width:140px}
-->
</style>
<script type="text/javascript" language="javascript">
function reloader(){
	window.location = 'admin.php';
}
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table cellspacing="0" cellpadding="3" border="0" width="100%" align="center" style="table-layout: fixed"> 
<tr class="header" ><td width="90%" align="left" nowrap>
</td>    
</tr></table>
<br>
<?php if (!$adminkey){?>
<table cellspacing="1" cellpadding="3" width="720" align="center" class="tableborder">
<tr class="header"><td>
管理系统
</td></tr>
<tr><td align="left">
<form action="admin.php" name="wane_login" method="post" target="ajaxform">
			<table border="0" width="720" cellspacing="1" cellpadding="3" class="text_axing">
				<tr>
					<th colspan="2">[请输入管理密钥]</th>
				</tr>
				<tr>
					<td>密钥</td>
					<td><input type="password" name="managekey" size="20" value="" /></td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td><input type="submit" name="Submit" value="验证密钥" /></td>
				</tr>
			</table>
			<input type="hidden" name="loginsubmit" value="1" />
</form>
</td></tr></table>
<iframe name="ajaxform" id="ajaxform" src="" width="0" height="0"></iframe>
</body>
</html>
<?php } else {?>
<table cellspacing="1" cellpadding="3" width="720" align="center" class="tableborder">
<tr class="header"><td>
管理系统
</td></tr>
<tr><td align="left">
<table border="0" width="720" cellspacing="1" cellpadding="3">
<tr>
<td class="altbg2">
<input type="text" name="url" value="http://" class="text_axing"><input value="手动添加" type="button" onClick="location.href='?glcz=addnew&url='+url.value" class="put">
<input type="text" name="soso" class="text_axing"><input value="网址搜索" type="button" onClick="location.href='?url='+soso.value" class="put">
例如<span style="color: #FF0000">http://www.71116.com</span><a href="?glcz=config" class="lian_a">系统设置</a> <a href="?glcz=daourl" class="lian_a">导出网址</a><br>
<div style="margin-top:5px">
<a href="?gsm=6" class="lian_a">未分类</a>
<a href="?gsm=1" class="lian_a">黑名单</a>
<a href="?glcz=del&qk=ok" onClick="javascript:if(prompt('请输入<?php
$yzddd=random(4, 1); echo $yzddd;?>确认清除！','')!='<?php echo $yzddd;?>'){return(false);};" class="lian_a">清除黑名单</a>
<a href="?gsm=ws" class="lian_a">未审核</a>
<a href="?gsm=2" class="lian_a">已审核</a>
<a href="?gsm=a1" class="lian_a">置顶网址</a>
<a href="?gsm=a2" class="lian_a">加粗网址</a>
<a href="?gsm=a3" class="lian_a">加红网址</a>
<a href="?glcz=keys" class="lian_a">栏目设置</a>
<a href="?glcz=tags" class="lian_a">标签管理</a> 
<a href="?nologin=ok" class="lian_a" target="ajaxform">退出管理</a></div>
</td></tr></table>

<?php 
if($glcz=='addlist'){
			$sorts=$seletedsort=array();
			$query = $db -> query("SELECT * FROM {$tablepre}sclass ORDER BY ordermode");
			while($sort = $db -> fetch_array($query)){
				$sorts[$sort['id']] = $sort;
				$seletedsort[$sort['upid']][$sort['id']] = $sort;
			}			
			$newfolders = trim($newfolders);
			if($newsortname){
			$db -> query("INSERT INTO {$tablepre}sclass  (upid,sortname,folders, folderdir) VALUES ('$newupid', '$newsortname','$newfolders','$path') ");
				echo show('恭喜：分类添加成功!','admin.php?glcz=list');
			}else{
				echo show('对不起，分类名称不允许为空，请返回!','admin.php?glcz=list');
			}

		}elseif($glcz=='addkeys'){
writetofile('./www/1.txt',trim($key1));
writetofile('./www/2.txt',trim($key2));
writetofile('./www/3.txt',trim($key3));
				echo show('恭喜：栏目设置成功!','admin.php?glcz=keys');
		}elseif($glcz=='updatelist'){
			$sorts=$seletedsort=array();
			$query = $db -> query("SELECT * FROM {$tablepre}sclass ORDER BY ordermode");
			while($sort = $db -> fetch_array($query)){
				$sorts[$sort['id']] = $sort;
				$seletedsort[$sort['upid']][$sort['id']] = $sort;
			}
			if(is_array($sortnamenew)){
				foreach($sortnamenew AS $key => $thesort){	
					$path='';
					$foldersnew[$key] = trim($foldersnew[$key]);
					$db -> query("UPDATE {$tablepre}sclass SET upid='$upidnew[$key]', sortname='$sortnamenew[$key]', folders='$foldersnew[$key]', folderdir='$path', ordermode='$ordermodenew[$key]' WHERE id='$key'");
				}
				echo show('恭喜：分类修改成功!','admin.php?glcz=list');
			}	
		}elseif($glcz=='delsort'){
			$sorts=$seletedsort=array();
			$query = $db -> query("SELECT * FROM {$tablepre}sclass ORDER BY ordermode");
			while($sort = $db -> fetch_array($query)){
				$sorts[$sort['id']] = $sort;
				$seletedsort[$sort['upid']][$sort['id']] = $sort;
			}
			$db -> query("DELETE FROM {$tablepre}sclass WHERE id='$delsort'");
				echo show('恭喜：分类删除成功!','admin.php?glcz=list');
		}else{
			$sorts=$seletedsort=array();
			$query = $db -> query("SELECT * FROM {$tablepre}sclass ORDER BY ordermode");
			while($sort = $db -> fetch_array($query)){
				$sorts[$sort['id']] = $sort;
				$seletedsort[$sort['upid']][$sort['id']] = $sort;
			}			
			$select = sortselect($seletedsort);
			$listsort= slist($seletedsort);
}

if($glcz=='addconfig') {
$name=Getstr($name);
$url=Getstr($url);
$key=Getstr($key);
$js=Getstr($js);
$tagss=ceil($tagss);
$delwd=Getstr($delwd);
$shhe=ceil($shhe);
$cjjg=ceil($cjjg);
$configs = readfromfile('./config.inc.php');
$configs = preg_replace("/[$]sitename\s*\=\s*[\"'].*?[\"'];/is", "\$sitename = '$name';", $configs);
$configs = preg_replace("/[$]webname\s*\=\s*[\"'].*?[\"'];/is", "\$webname = '$url';", $configs);
$configs = preg_replace("/[$]sitekey\s*\=\s*[\"'].*?[\"'];/is", "\$sitekey = '$key';", $configs);
$configs = preg_replace("/[$]sitejs\s*\=\s*[\"'].*?[\"'];/is", "\$sitejs = '$js';", $configs);
$configs = preg_replace("/[$]shenhe\s*\=\s*[\"'].*?[\"'];/is", "\$shenhe = '$shhe';", $configs);
if($pass){
$pass=md5($pass);
$configs = preg_replace("/[$]sitepass\s*\=\s*[\"'].*?[\"'];/is", "\$sitepass = '$pass';", $configs);
}
$configs = preg_replace("/[$]tagsnum\s*\=\s*[\"'].*?[\"'];/is", "\$tagsnum = '$tagss';", $configs);
$configs = preg_replace("/[$]cjsjsz\s*\=\s*[\"'].*?[\"'];/is", "\$cjsjsz = '$cjjg';", $configs);
$configs = preg_replace("/[$]delkey\s*\=\s*[\"'].*?[\"'];/is", "\$delkey = '$delwd';", $configs);
writetofile('./config.inc.php',$configs);
echo show('恭喜：系统设置成功！','admin.php');
}

if($glcz=='upct') {
//日统计
if($upct==1){
$db -> query("Update {$tablepre}link set dayctbak=dayct,dayct=0; ");
}
//周统计
if($upct==2){
$db -> query("Update {$tablepre}link set weekctbak=weekct,weekct=0; ");
}
//月统计
if($upct==3){
$db -> query("Update {$tablepre}link set monthctbak=monthct,monthct=0; ");
}
//总统计
if($upct==4){
$db -> query("Update {$tablepre}link set count=0; ");
}
echo show('恭喜：系统清空统计成功！','admin.php');
}


if($glcz=='config'){
echo mainusertou("系统设置","");
 ?>
<script language="JavaScript">
<!--
function check(msg, url){
if(confirm(msg)){
return true;
}else{return false;
}
}
//-->
</script>
<table cellspacing="1" cellpadding="3" width="720" align="center" class="tableborder">
<tr><td align="center">
<table border="0" width="720" cellspacing="1" cellpadding="3">
<form id="form1" name="form1" method="post" action="?glcz=addconfig">
<tr>
<td class="altbg2">
<input type="name" name="name" value="<?php echo $sitename;?>" style="width:500px;"> <b>网站标题</b><br>
<input type="url" name="url" value="<?php echo $webname;?>" style="width:500px;"> <b>网站名称</b><br>
<input type="key" name="key" value="<?php echo $sitekey;?>" style="width:500px;"> <b>网站关键字</b><br>
<input type="js" name="js" value="<?php echo $sitejs;?>" style="width:500px;"> <b>网站介绍</b><br>
<input type="pass" name="pass" value="" style="width:500px;"> <b>网站管理密码</b>* 不修改为空<br>
<input type="shhe" name="shhe" value="<?php echo $shenhe;?>" style="width:500px;"> <b>审核开关,0不需要审核 1需要审核</b><br>
<input type="tagss" name="tagss" value="<?php echo $tagsnum;?>" style="width:500px;"> <b>分页显示几个。</b><br>
<input type="cjjg" name="cjjg"" value="<?php echo $cjsjsz;?>" style="width:500px;"> <b>采集时间间隔设置。</b><br>
<textarea name="delwd" rows="4" class="text_axing" style="width:500px"><?php echo $delkey;?></textarea> <b>过滤关键字</b>* 以 |  进行分割。<br>
<input type="submit" name="addnew" Value="提交"  ></td>
</tr>
</form>
</table>
</td></tr></table><br>
<?php }
if($glcz=='tags'){
echo mainusertou("标签管理","");
echo '<br><script language="javaScript" type="text/javascript" SRC="js/js.js"></script><form id="form1" name="form1" method="post" action="?glcz=tags">';
if($id){
$db -> query("delete from {$tablepre}key where id='$id'");
}
if($deltags){
	if(is_array($delete)) {
		$ids = idarray($delete);
		$db -> query("DELETE FROM {$tablepre}key WHERE id IN($ids)");
	}
}
$query = $db -> query("SELECT * FROM {$tablepre}key WHERE result=1 ORDER BY count DESC LIMIT 0, 100");
	while($tags = $db -> fetch_array($query)){
?>
<input type="checkbox" name="delete[<?php echo $tags["id"];?>]" Value="<?php echo $tags["id"];?>"> <?php echo $tags['tags'];?> (<?php echo $tags['count'];?>) <a href="?id=<?php echo $tags['id'];?>&glcz=tags">删除</a> <br>  
<?php }
?>
<input type="checkbox" name="chkall" class="category" onclick="checkall(this.form)"> <input type="button" value="全选" onclick="return checkall(this.form);"> <input type="button" value="反选" onclick="return checkothers(this.form);"> <input type="submit" name="deltags" Value="批量删除"> </form>
<?php
}
if($glcz=='list'){
echo mainusertou("网址分类","");
 ?>
<script language="JavaScript">
<!--
function check(msg, url){
if(confirm(msg)){
return true;
}else{return false;
}
}
//-->
</script>
<table cellspacing="1" cellpadding="3" width="720" align="center" class="tableborder">
<tr><td align="center">
<table border="0" width="720" cellspacing="1" cellpadding="3">
<form id="form1" name="form1" method="post" action="?glcz=addlist">
<tr align="center">
<td class="altbg2">
<b>新增分类</b>
</td>
<td class="altbg2">
上级分类<select name="newupid"><option value="0">--------</option><?php echo $select;?></select>分类名称:<input type="text" name="newsortname" Value="" size="30" class="put">
存放目录:<input type="text" name="newfolders" Value="" size="30" class="put">
</td>
<td class="altbg2">
<input type="submit" name="addnew" Value="提交"  >
</td>
</tr>
</form>
</table>
</td></tr></table>
<br>
<table cellspacing="1" cellpadding="3" width="720" align="center" class="tableborder">
<tr class="header"><td>
网址分类列表
</td></tr>
<tr><td align="center">
<table border="0" width="100%" cellspacing="1" cellpadding="0">
<tr bgcolor="#FFFFFF" align="center" style="font-weight:bold;padding:3px;" ><td width="8%">ID</td>
<td width="15%">上级分类</td>
<td>名称</td><td width="10%">存放目录</td><td width="10%">排列顺序</td>
<td width="10%">操作</td>
</tr>
<tr align="center" style="font-weight:bold">
<td colspan="6">
<table border="0" width="100%" cellspacing="0" cellpadding="3">
<form id="form1" name="form1" method="post" action="?glcz=updatelist">
<?php echo $listsort;?>
<tr><td colspan="6" align="center">
<input type="submit" name="updatelist" value="提交">
</td></tr>
</form>
</table>
</tr>
</table>
</table></td></tr></table><br>
<?php }
if($glcz=='keys'){
echo mainusertou("栏目设置","");
if(is_file('./www/1.txt')) $key1= readfromfile('./www/1.txt');
if(is_file('./www/2.txt')) $key2= readfromfile('./www/2.txt');
if(is_file('./www/3.txt')) $key3= readfromfile('./www/3.txt');
 ?>
<script language="JavaScript">
<!--
function check(msg, url){
if(confirm(msg)){
return true;
}else{return false;
}
}
//-->
</script>
<table cellspacing="1" cellpadding="3" width="720" align="center" class="tableborder">
<tr><td align="center">
<table border="0" width="720" cellspacing="1" cellpadding="3">
<form id="form1" name="form1" method="post" action="?glcz=addkeys">
<tr align="center">
<td class="altbg2">
<b>推荐内容</b>
</td>
<td class="altbg2">
<b>热门点击</b>
</td>
<td class="altbg2">
<b>最新加入</b>
</td>
</tr>
<tr align="center">
<td class="altbg2">
<textarea name="key1" rows="20" class="text_axing" style="width:220px"><?=$key1;?></textarea>
</td>
<td class="altbg2">
<textarea name="key2" rows="20" class="text_axing" style="width:220px"><?=$key2;?></textarea>
</td>
<td class="altbg2">
<textarea name="key3" rows="20" class="text_axing" style="width:220px"><?=$key3;?></textarea>
</td>
</tr>
<tr align="center">
<td class="altbg2">一个栏目一个换行。</td>
<td class="altbg2">
<input type="submit" name="addnew" Value="提交"  >
</td>
<td class="altbg2">
</td>
</tr>
</form>
</table>
</td></tr></table>
<?php }?>
<?php if($glcz=='addnew'){
$time=time()+8*3600;
$uurl=$url;
if($uurl){
if($uurl<>$siteurl){
$query = $db -> query("SELECT id FROM {$tablepre}link WHERE url='$uurl'");
if($db -> num_rows($query)){
echo show('对不起该网址已存在！','admin.php');
} else {
$urlhtml=get_url_content($uurl);
if($urlhtml){
$urlhtml=get_encoding($urlhtml,$charset);
$title=get_title($urlhtml);
$keywords=get_keywords($urlhtml);
$description=get_description($urlhtml);
if($description=="无") $description=get_goolejs($uurl);
//$wzhtml=get_enhtml($urlhtml);
if($title==""){
echo show('对不起该网址内容获取失败！','admin.php');
} else {
$db -> query("INSERT INTO {$tablepre}link (title, url, keywords, description, about, lurl, result, addtime, uptime) VALUES ('$title', '$uurl', '$keywords', '$description', '$wzhtml', '$lurl', '2', '$time', '$time') ");
//$keywords=GetKeywords($keywords);
Gettags();
echo show('恭喜：网址添加成功！','admin.php');
}
}
}
}
}
}

if($glcz=='editok'){
$db -> query("update {$tablepre}link set title='$title',keywords='$keywords',description='$description',classid='$class',uptime='$time' where id='$id'");
echo show('恭喜：修改编辑内容成功','admin.php?glcz=edit&id='.$id.'');
}
?>
<?php if($glcz=='edit'){
echo mainusertou("编辑内容","");
$query = $db -> query("select * from {$tablepre}link where id='$id'");
 while($row = $db->fetch_array($query)){
 $select = sortselect($fsorts,$row["classid"]);
 ?>
<table border="0" width="720" cellspacing="1" cellpadding="3">
<tr>
<td class="altbg2">
<form action="?glcz=editok" method="post">
标&nbsp;&nbsp;&nbsp;题： 
<input name="title" type="text" class="text_axing" style="width:600px" value="<?php echo $row["title"];?>">
<input name="id" type="hidden" value="<?php echo $id;?>" />
<br>
标&nbsp;&nbsp;&nbsp;签：
<textarea name="keywords" rows="4" class="text_axing" style="width:600px"><?php echo $row["keywords"];?></textarea> <a href="#标签采集">标签采集</a>
<br>
介&nbsp;&nbsp;&nbsp;绍：
<textarea name="description" rows="4" class="text_axing" style="width:600px"><?php echo $row["description"];?></textarea> <a href="#介绍采集">介绍采集</a>
<br>
分&nbsp;&nbsp;&nbsp;类：
<select name="class" class="input1">
<option value="0">----清选择----</option>
<?=$select?>
</select><input type="submit" value="修改">
</form>
</td></tr></table>
<?php
}
}

if($glcz=='del'){
if($id<>''){
$db -> query("delete from {$tablepre}link where id='$id'");
echo show('删除成功','admin.php');
}
if($qk=='ok'){
$db -> query("delete from {$tablepre}link where result='1'");
echo show('删除成功','admin.php');
}
}

if($glcz=='gxsz'){
if($id){
if($result=='1'){
$db -> query("update {$tablepre}link set result='".$result."' where id='$id'");
$szname="黑名单";
}elseif($result=='2'){
$shresult = $db -> queryarray("SELECT result from {$tablepre}link where id='$id'");
if($shresult['result']==1) {
$szname="审核，因该网址已被列入黑名单，所以设置不";
}elseif($shresult['result']==2){
$db -> query("update {$tablepre}link set result='0' where id='$id'");
$szname="取消审核";
}else{
$db -> query("update {$tablepre}link set result='2' where id='$id'");
$szname="审核";
}
}elseif($result=='3'){
$db -> query("update {$tablepre}link set style='2' where id='$id'");
$szname="加粗";
}elseif($result=='4'){
$db -> query("update {$tablepre}link set style='3' where id='$id'");
$szname="加红";
}elseif($result=='5'){
$db -> query("update {$tablepre}link set style='1' where id='$id'");
$szname="置顶";
}elseif($result=='6'){
$db -> query("update {$tablepre}link set style='0' where id='$id'");
$szname="取消";
}else{
$szname="审核";
}
echo show('设置'.$szname.'成功','admin.php');
}
}

if($glcz=='youout'){
if($id){
$db -> query("update {$tablepre}link set youout=youout+10,dayct=dayct+15,weekct=weekct+20,monthct=monthct+70,count=count+100 where id='$id'");
echo show('恭喜：ID:'.$ID.'添加100积分成功','admin.php');
}
}


if($glcz=='update'){
$urlhtml=get_url_content($url);
if($urlhtml){
//$urlhtml=get_encoding($urlhtml,$charset);
$title=get_title($urlhtml);
$keywords=get_keywords($urlhtml);
$description=get_description($urlhtml);
if($description=="无") $description=get_goolejs($url);
$wzhtml="";
if($title==""){
echo show('对不起该网址内容获取失败！','admin.php');
} else {
$db -> query("update {$tablepre}link set title='$title',keywords='$keywords',description='$description',about='$wzhtml',uptime='$time' where id='$id'");
//$keywords=GetKeywords($keywords);
Gettags();
echo show('恭喜：网址更新成功！','admin.php');
}
}
}

if($glcz==''){
echo mainusertou("网址列表","");
 ?>
<script language="javaScript" type="text/javascript" SRC="js/js.js"></script>
<form id="form1" name="form1" method="post" action="">
<table border="0" width="720" cellspacing="1" cellpadding="3">
 <?php 
$sql="WHERE classid='0' and result<>'1'";
if($url) {
	  $url = ereg_replace("[\"\r\n\t\*\?\(\)\$%']"," ",trim($url));
		$urladd = '&url='.$url;
		$sql =  "WHERE url LIKE '%$url%'" ;
}
if($gsm) {
		$urladd = '&gsm='.$gsm;
		if($gsm=='6'){
		$sql =  "WHERE classid='0' and result<>'1'" ;
		}elseif($gsm=='a1'){
		$sql =  "WHERE style='1'" ;
		}elseif($gsm=='a2'){
		$sql =  "WHERE style='2'" ;
		}elseif($gsm=='a3'){
		$sql =  "WHERE style='3'" ;
		}elseif($gsm=='ws'){
		$sql =  "WHERE result='0'" ;
		} else {
		$sql =  "WHERE result='".$gsm."'" ;
		}
}
	$page = ispage($page) ? $page : 1;
	$pagenum = 100;
	$start_limit = ($page-1) * $pagenum;	
	$links = array();
	$query = $db -> query("SELECT COUNT(*) FROM {$tablepre}link $sql");
	$lines = $db -> result($query, 0);
		$paging = paginga($lines, $pagenum, $page, 'admin.php?glcz='.$urladd.'&page=');
$query = $db -> query("SELECT * FROM {$tablepre}link $sql  ORDER BY id desc LIMIT $start_limit, $pagenum");
 while($row = $db->fetch_array($query)){
$furl = str_replace("http://","",$row['url']);
$row['title'] =textcut($row['title'],45);
 ?>
<tr>
<td class="altbg1"><input type="checkbox" name="delete[<?php echo $row["id"];?>]" Value="<?php echo $row["id"];?>"><?php echo Getsclass($row["classid"]);?> <a href="html/<?php echo $row["id"];?>.html" target="_blank"><?php echo $row["title"];?></a>
<br><span style="color: #FF0000"><a href="?glcz=upct&upct=1">日：</a><?php echo $row["dayct"];?> <a href="?glcz=upct&upct=2">周：</a><?php echo $row["weekct"];?> <a href="?glcz=upct&upct=3">月：</a><?php echo $row["monthct"];?>  <a href="?glcz=upct&upct=4">总点：</a><?php echo $row["count"];?>  出点：<?php echo $row["myout"];?>  <a href="?glcz=youout&id=<?php echo $row["id"];?>">+积分</a>：<?php echo $row["youout"];?></span></td><td class="altbg2"><a href="?glcz=del&id=<?php echo $row["id"];?>" class="lian_a">删除</a> <a href="?glcz=update&url=<?php echo $row["url"];?>&id=<?php echo $row["id"];?>" class="lian_a">更新</a> <a href="?glcz=gxsz&id=<?php echo $row["id"];?>&result=2" class="lian_a"><?php if($row["result"]=='0'){?>审核<?php } else {?>已审<?php }?></a> <a href="?glcz=gxsz&id=<?php echo $row["id"];?>&result=1" class="lian_a">加入黑名单</a> <a href="?glcz=gxsz&id=<?php echo $row["id"];?>&result=3" class="lian_a">加粗</a> <a href="?glcz=gxsz&id=<?php echo $row["id"];?>&result=4" class="lian_a">加红</a> <a href="?glcz=gxsz&id=<?php echo $row["id"];?>&result=5" class="lian_a">置顶</a> <a href="?glcz=gxsz&id=<?php echo $row["id"];?>&result=6" class="lian_a">取消</a> <a href="?glcz=edit&id=<?php echo $row["id"];?>" class="lian_a">编辑</a></td></tr>
 <?php }?>
<tr>
<td class="altbg1"><input type="checkbox" name="chkall" class="category" onclick="checkall(this.form)"> <input type="button" value="全选" onclick="return checkall(this.form);"> <input type="button" value="反选" onclick="return checkothers(this.form);">  <input type="submit" name="shgest" Value="审核/取消"> <input type="submit" name="digest" Value="置顶/取消"> <input type="submit" name="heigest" Value="黑名单"></td><td class="altbg2"> <input type="submit" name="delgest" Value="批量删除"> 把所选内容移动到分类<select name="ztid">
<option value="0">--请选择--</option>
<?=$select?>
</select>
<input type="submit" name="upzt" Value="提交"></form></td>
  </tr>
  <?php
}
?>
 </table>
 <table width="100%" class="bg">
<tr><td align="left"><?php echo $paging;?></td>
  </tr>
</table>
</td></tr></table>
<div align=center><a href="http://u2.71116.com/" target="_blank">&copy;2008 - 2010 u2.71116.com &nbsp;&nbsp; 程序设计QQ：426420</a></div>
<iframe name="ajaxform" id="ajaxform" src="" width="0" height="0"></iframe>
</body>
</html>
<?php 
}
?>