<?php
require_once('session.php');
require_once('../fun/funsql.php'); 
require_once('../fun/funlogic.php');
require_once('../fun/funlink.php');
if (isset($_GET["rel"])){$rel=$_GET["rel"];}else{$rel="";}
$linkstr = new linkstr($dbz);
?>
<!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=utf-8" />
<title> Home</title>
<link href="css_body.css" rel="stylesheet" type="text/css" />
</head>
<script type="text/javascript" src="../fun/adminjs.js"></script>
<body>
<?php if ($rel==''){
$num=20;//列表显示条数
$page=@funstr($_GET["page"]);

if($page==''){$page=0;}
if($page<0){$page=0;}
//获取信息总数
$linknum=$linkstr->linknum();
?>
<div class='bodytitle'><div class='bodytitleleft'></div><div class='bodytitletxt'>友情连接管理</div></div>
<form id="form3" name="form3" method="post" action="query.php?rel=link_all">
<table width="96%" border="0" cellpadding="0" cellspacing="0" align="center" style="margin-bottom:8px;display:block" id="td1" >
<tr> 
<td>
<table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#E2F5BC" class="sysinfo">
<tr align="center" height="24">
<td height="30" colspan="9" align="left" bgcolor="#EDF9D5"><b>&nbsp;[<a href="link.php?rel=link_add">添加连接</a>]</b>    &nbsp;&nbsp;</td>
</tr>
<tr align="center"> 
<td  height="25" bgcolor="#FFFFFF" align="left">ID</td>
<td bgcolor="#FFFFFF" align="left">名称</td>
<td bgcolor="#FFFFFF" align="left">地址</td>
<td bgcolor="#FFFFFF" align="left">图片</td>
<td bgcolor="#FFFFFF" align="left">状态</td>
<td bgcolor="#FFFFFF" align="left">QQ</td>
<td bgcolor="#FFFFFF" align="left">描述</td>
<td bgcolor="#FFFFFF" align="left">排序</td>
<td bgcolor="#FFFFFF" align="left">管理</td>
</tr>

<?php 
$list=0;
if ($linknum==0){
  echo "<tr><td colspan=\"9\"><strong>暂时没有连接.</strong></td></tr>";
}
else{
  //总页数
  
  $list=ceil($linknum/$num);
  echo $linkstr->linklist($num*$page,$num,$page);
}
?>

<tr align="center" height="24">
  <td height="30" align="left" bgcolor="#FFFFFF" colspan="9"><a href="#" onclick="checkbox('checkbox',<?php echo $num; ?>)">全选/取消</a> <input type="hidden" name="i" value="<?php echo $num; ?>" />
  <input type="submit" name="Submit3" value="批量修改排序" /> 分页: <?php echo $page+1;?>/<?php echo $list;?> <a href="link.php?page=0">首页</a> <?php if ($page==0){echo "上一页"; }else{ echo "<a href=\"link.php?page=".($page-1)."\">上一页</a>"; }?> <?php if (($page+1)<$list){echo "<a href=\"link.php?page=".($page+1)."\">下一页</a>"; }else{ echo "下一页"; }?> <?php if (($page+1)<>$list){echo "<a href=\"link.php?page=".($list-1)."\">尾页</a>"; }else{ echo "尾页"; }?></form></td>
  </tr>
</table>
</td>
</tr>
</table>
<?php }?>
<?php if($rel=='link_add'){?>
<div class='bodytitle'><div class='bodytitleleft'></div><div class='bodytitletxt'>连接添加</div></div>
<table width="96%" border="0" cellpadding="0" cellspacing="0" 
	align="center" style="margin-bottom:8px;display:block" id="td1" >
<tr> 
<td>
<form id="form1" name="form1" method="post" action="query.php?rel=link_add">
<table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#E2F5BC" class="sysinfo">
<tr align="center" height="24">
<td height="30" colspan="3" align="left" bgcolor="#EDF9D5"><b>&nbsp;[<a href="link.php">连接管理</a>]</b>    &nbsp;&nbsp;</td>
</tr>
<tr align="center"> 
<td width="20%" height="25" bgcolor="#FFFFFF">变量说明</td>
<td bgcolor="#FFFFFF">变量值</td>
<td width="30%" bgcolor="#FFFFFF">介绍</td>
</tr>  
<tr align="center" height="24" bgcolor="#FFFFFF"> 
<td height="30" align="left" bgcolor="#FFFFFF"> 连接名称:</td>
<td align="left" bgcolor="#FFFFFF">
<input type='text' name='names' value='' style='width:60%' maxlength="20"></td>
<td align="left" bgcolor="#FFFFFF">获取前20字符</td>
</tr>
<tr align="center" height="24" bgcolor="#FFFFFF"> 
<td height="30" align="left" bgcolor="#FFFFFF"> 连接地址:</td>
<td align="left" bgcolor="#FFFFFF">
<input type='text' name='urls' value='http://' style='width:60%' maxlength="100"></td>
<td align="left" bgcolor="#FFFFFF">获取前100字符</td>
</tr>
<tr align="center" height="24" bgcolor="#FFFFFF"> 
<td height="30" align="left" bgcolor="#FFFFFF"> 图片地址:</td>
<td align="left" bgcolor="#FFFFFF">
<input type='text' name='imgs' value='' style='width:60%' maxlength="100"></td>
<td align="left" bgcolor="#FFFFFF">获取前100字符,为空则按照文字连接显示</td>
</tr>
<tr align="center" height="24" bgcolor="#FFFFFF"> 
<td height="30" align="left" bgcolor="#FFFFFF"> 联系QQ:</td>
<td align="left" bgcolor="#FFFFFF">
<input type='text' name='qqs' value='0' style='width:60%' maxlength="20"></td>
<td align="left" bgcolor="#FFFFFF">获取前20字符,必须为数字</td>
</tr>
<tr align="center" height="24" bgcolor="#FFFFFF"> 
<td height="30" align="left" bgcolor="#FFFFFF"> 连接排序:</td>
<td align="left" bgcolor="#FFFFFF">
<input type='text' name='orders' value='50' style='width:60%' maxlength="3"></td>
<td align="left" bgcolor="#FFFFFF">获取前3字符,最大数字为999</td>
</tr>
<tr align="center" height="24" bgcolor="#FFFFFF"> 
<td height="30" align="left" bgcolor="#FFFFFF"> 连接备注:</td>
<td align="left" bgcolor="#FFFFFF">
<textarea name="dis" id="id" rows="4" cols="50"></textarea></td>
<td align="left" bgcolor="#FFFFFF">获取前200字符</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#E2F5BC" class="sysinfo">
<tr align="center" height="24">
  <td height="30" colspan="3" align="left" bgcolor="#EDF9D5"><b>&nbsp;请按照说明设置.</b></td>
  </tr>
<tr align="center" height="24">
  <td height="30" colspan="3" align="center" bgcolor="#FFFFFF"><input type="submit" name="Submit" value="确定" /> 
    <input type="reset" name="Submit2" value="重置" /></td>
  </tr>
</table>
</form>
</td>
</tr>
</table>
<?php }?>
<?php if($rel=='link_info'){
$id=funstr($_GET["id"]);
$page=funstr($_GET["page"]);
$sql=query("select * from ".$dbz."link where id=$id");
if($row=fetch($sql)){
?>
<div class='bodytitle'><div class='bodytitleleft'></div><div class='bodytitletxt'>连接修改</div></div>
<table width="96%" border="0" cellpadding="0" cellspacing="0" 
	align="center" style="margin-bottom:8px;display:block" id="td1" >
<tr> 
<td>
<form id="form1" name="form1" method="post" action="query.php?rel=link_info">
<table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#E2F5BC" class="sysinfo">
<tr align="center" height="24">
<td height="30" colspan="3" align="left" bgcolor="#EDF9D5"><b>&nbsp;[<a href="link.php">连接管理</a>]</b>    &nbsp;&nbsp;</td>
</tr>
<tr align="center"> 
<td width="20%" height="25" bgcolor="#FFFFFF">变量说明</td>
<td bgcolor="#FFFFFF">变量值</td>
<td width="30%" bgcolor="#FFFFFF">介绍</td>
</tr>  
<tr align="center" height="24" bgcolor="#FFFFFF"> 
<td height="30" align="left" bgcolor="#FFFFFF"> 连接名称:</td>
<td align="left" bgcolor="#FFFFFF">
<input type='text' name='names' value='<?php echo $row["names"]; ?>' style='width:60%' maxlength="20"></td>
<td align="left" bgcolor="#FFFFFF">获取前20字符</td>
</tr>
<tr align="center" height="24" bgcolor="#FFFFFF"> 
<td height="30" align="left" bgcolor="#FFFFFF"> 连接地址:</td>
<td align="left" bgcolor="#FFFFFF">
<input type='text' name='urls' value='<?php echo $row["urls"]; ?>' style='width:60%' maxlength="100"></td>
<td align="left" bgcolor="#FFFFFF">获取前100字符</td>
</tr>
<tr align="center" height="24" bgcolor="#FFFFFF"> 
<td height="30" align="left" bgcolor="#FFFFFF"> 图片地址:</td>
<td align="left" bgcolor="#FFFFFF">
<input type='text' name='imgs' value='<?php echo $row["imgs"]; ?>' style='width:60%' maxlength="100"></td>
<td align="left" bgcolor="#FFFFFF">获取前100字符,为空则按照文字连接显示</td>
</tr>
<tr align="center" height="24" bgcolor="#FFFFFF"> 
<td height="30" align="left" bgcolor="#FFFFFF"> 联系QQ:</td>
<td align="left" bgcolor="#FFFFFF">
<input type='text' name='qqs' value='<?php echo $row["qqs"]; ?>' style='width:60%' maxlength="20"></td>
<td align="left" bgcolor="#FFFFFF">获取前20字符,必须为数字</td>
</tr>
<tr align="center" height="24" bgcolor="#FFFFFF"> 
<td height="30" align="left" bgcolor="#FFFFFF"> 连接排序:</td>
<td align="left" bgcolor="#FFFFFF">
<input type='text' name='orders' value='<?php echo $row["orders"]; ?>' style='width:60%' maxlength="3"></td>
<td align="left" bgcolor="#FFFFFF">获取前3字符,最大数字为999</td>
</tr>
<tr align="center" height="24" bgcolor="#FFFFFF"> 
<td height="30" align="left" bgcolor="#FFFFFF"> 连接备注:</td>
<td align="left" bgcolor="#FFFFFF">
<textarea name="dis" id="id" rows="4" cols="50"><?php echo $row["dis"]; ?></textarea></td>
<td align="left" bgcolor="#FFFFFF">获取前200字符</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#E2F5BC" class="sysinfo">
<tr align="center" height="24">
  <td height="30" colspan="3" align="left" bgcolor="#EDF9D5"><b>&nbsp;请按照说明设置.</b></td>
  </tr>
<tr align="center" height="24">
  <td height="30" colspan="3" align="center" bgcolor="#FFFFFF">
  <input type="hidden" name="id" value="<?php echo $id; ?>" />
    <input type="hidden" name="page" value="<?php echo $page; ?>" />
  <input type="submit" name="Submit" value="确定" /> 
    <input type="reset" name="Submit2" value="重置" /></td>
  </tr>
</table>
</form>
</td>
</tr>
</table>
<?php }}?>
<?php mysql_close();?>
</body>
</html>