
<?php include("dh.php"); 
include("../sql/conn.php");
include("yz.php"); 
$llym = $_SERVER["HTTP_REFERER"];
?>

<?php
if ($_GET['id']=="friend")
{
mysql_query("INSERT INTO friend (name, url, title,bz) VALUES ('$_POST[name]','$_POST[url]','$_POST[title]','$_POST[bz]')");

mysql_query("INSERT INTO text (name, time, ip, ing, f, bz) 
VALUES ('".$_SESSION['name']."', '".$noww."', '".$iipp."', '添加友链', '0', '')");

?>
<script language="javascript">setTimeout(function (){location.href='<?php echo $llym; ?>';},2);</script>
<?
}

?>



<?php
if ($_GET['xg']=="xg")
{
mysql_query("UPDATE friend SET url = '".$_POST['url']."' WHERE id='".$_GET['id']."'");
mysql_query("UPDATE friend SET name = '".$_POST['name']."' WHERE id='".$_GET['id']."'");
mysql_query("UPDATE friend SET title = '".$_POST['title']."' WHERE id='".$_GET['id']."'");
mysql_query("UPDATE friend SET bz = '".$_POST['bz']."' WHERE id='".$_GET['id']."'");

mysql_query("INSERT INTO text (name, time, ip, ing, f, bz) 
VALUES ('".$_SESSION['name']."', '".$noww."', '".$iipp."', '改文章信息-".$_GET['id']."', '0', '')");
?>
<script language="javascript">setTimeout(function (){location.href='<?php echo $llym; ?>';},2);</script>
<?
}
?>



<?php
if ($_GET['id']=="text")
{
////////////////////////////////////////////////////////////////////////
$TxtFileName    = "friendtext.txt"; 
if( ($TxtRes=fopen ($TxtFileName,"w+")) === FALSE){ 
///    echo("创建可写文件：".$TxtFileName."失败");    
    exit(); 
} 
///echo ("创建可写文件".$TxtFileName."成功！</br>"); 
    $StrConents = $_POST['content'];//要 写进文件的内容 
if(!fwrite ($TxtRes,$StrConents)){ //将信息写入文件 
///        echo ("尝试向文件".$TxtFileName."写入".$StrConents."失败！"); 
        fclose($TxtRes); 
        exit();        
}  
///echo ("尝试向文件".$TxtFileName."写入".$StrConents."成功！"); 
fclose ($TxtRes); //关闭指针 
////////////////////////////////////////////////////////////////////////
?>
<script language="javascript">setTimeout(function (){location.href='<?php echo $llym; ?>';},2);</script>
<?
}
?>


<?php

if ($_GET['s']=="fok")
{
mysql_query("DELETE FROM  friend  WHERE id='".$_GET['id']."'");

mysql_query("INSERT INTO text (name, time, ip, ing, f, bz) 
VALUES ('".$_SESSION['name']."', '".$noww."', '".$iipp."', '删除友链".$_GET['id']."', '0', '')");
?>
<script language="javascript">setTimeout(function (){location.href='<?php echo $llym; ?>';},2);</script>
<?
}

?>
<table  width="818">
  <tr>
    <td valign="top">友情链接列表 <a href="http://link.chinaz.com/?wd=www.ttpk.net" target="_blank">检查友链</a>
	
	<br /><?php
$result = mysql_query("SELECT * FROM friend");
while($row = mysql_fetch_array($result))
  {
  echo "<div class=bhh >";
  echo "<form action=friend.php?xg=xg&id=".$row['id']." method=post>";
  echo "<a target=_blank href=".$row['url']. " >查</a>";

  echo "<input type=text name=name value=\"";
  echo $row['name'];
  echo "\"  size=8 />";
  
  echo "[<a ";
    ?>onClick="return confirm('删除要小心！？')"<?php
  echo " href=friend.php?id=".$row['id']."&s=fok >删</a>]";
  
  echo "<input type=text name=url value=\"";
  echo $row['url'];
  echo "\"  size=8 />";
  
  echo "<input type=text name=title value=\"";
  echo $row['title'];
  echo "\"  size=8 />";

  echo "<input type=text name=bz value=\"";
  echo $row['bz'];
  echo "\"  size=8 />";

  echo "<input type=submit value=修 />";
if($row['bz']!="")  {
echo "<a target=_blank href=http://wpa.qq.com/msgrd?v=3&uin=".$row['bz']."&site=qq&menu=yes title=".$row['bz']." >聊</a>";  }
  echo "</form>";
  echo "</div>";
  }
?></td>
    <td rowspan="2" valign="top">|</td>
    <td rowspan="2" valign="top"><script type="text/javascript"> 
    function jsCopy(){ 
        var e=document.getElementById("content");//对象是content 
        e.select(); //选择对象 
        document.execCommand("Copy"); //执行浏览器复制命令 
    } 
</script> 

<form action="?id=text" method="post">
<textarea cols="58" name="content" rows="28" id="content"><?php include("friendtext.txt"); ?></textarea> <br>
<input type="submit" value="保存" /> <a onclick="jsCopy()" >点击复制</a>	
</form></td>
</tr>
  <tr>
    <td valign="top"><table height="150" >
      <form action="friend.php?id=friend" method="post">
        <tr>
          <td height="20" colspan="2"><div align="center">填加友情链接</div></td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td height="20">标题:</td>
          <td><input name="name" type="text" value="" size="39"  /></td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td height="23">地址:</td>
          <td><input name="url" type="text" value="http://" size="39" /></td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td height="23">文字:</td>
          <td><input name="title" type="text" value="" size="39"  /></td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td height="23">Q Q:</td>
          <td><input name="bz" type="text" value="" size="39" /></td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td height="25">&nbsp;</td>
          <td><input name="submit" type="submit" value="增加友链" /></td>
          <td></td>
        </tr>
      </form>
    </table></td>
  </tr>
</table>


<hr>

<textarea cols="88" rows="3">友情链接管理
右边的这个文本框是方便广大站长们拉友链时复制粘贴常用语的。
</textarea>


<?php include("../sql/close.php"); ?>