<?php include("dh.php"); 
include("../sql/conn.php");
include("yz.php"); 
?>

<?php
$llym = $_SERVER["HTTP_REFERER"];

if ($_GET['s']=="ok")
{
mysql_query("DELETE FROM  url  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['xg']=="xg")
{
mysql_query("UPDATE url SET url = '".$_POST['url']."' WHERE id='".$_GET['id']."'");
mysql_query("UPDATE url SET name = '".$_POST['name']."' WHERE id='".$_GET['id']."'");
mysql_query("UPDATE url 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']=="url")
{
mysql_query("INSERT INTO url (url, name,bz) VALUES ('".$_POST['url']."', '".$_POST['name']."', '".$_POST['bz']."')");

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

<?php
if ($_GET['id']=="text")
{
////////////////////////////////////////////////////////////////////////
$TxtFileName    = "urltext.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['ys'])
{
$ys = $_SESSION['ts']*($_GET['ys']-1);
}	 
else
{
$ys = 0;
}

if($_GET['px'])
{
$px = $_GET['px'];
}	 
else
{
$px = id;
}

?>



<table >
  <tr>
    <td rowspan="2" valign="top">
<?php
echo "<TABLE ><TBODY><TR  bgcolor=#CCCC00 >";
echo "<b><TD >修改</td><TD >ID</td><TD ><a href=?ys=".$_GET['ys']."&px=name >网址</a></td><TD >网站名</td><TD ><a href=?ys=".$_GET['ys']."&px=bz >备注</a></td><TD >删除</td><TD >查看</td></b></TR>";
$result = mysql_query("SELECT * FROM  url  ORDER  BY ".$px." DESC LIMIT ".$ys.",".$_SESSION['ts']);
while($row = mysql_fetch_array($result))
  {
echo "<TR ";
?> onmouseover="this.style.background='#FFF'; " onmouseout ="this.style.background=''; this.style.borderColor=''" <?php 
echo ">";

$url = "http://".$row['url'];
$url = str_replace("http://http://","http://",$url);

echo "<form action=url.php?xg=xg&id=".$row['id']." method=post>";

  echo "<td><a ";
    ?>onClick="return confirm('删除要小心！？')"<?php
  echo " href=?id=".$row['id']."&s=ok >删</a></td>";

echo "<TD ><input  type=text size=3 value=".$row['id'] . " /></a></td>";
echo "<TD ><input name=url type=text size=8 value=".$row['url'] . " /></td>";
echo "<TD ><input name=name type=text size=8 value=".$row['name'] . " /></td>";
echo "<TD ><input name=bz type=text size=8 value=".$row['bz'] . " /></td>";
echo "<TD ><a target=_blank href=".$url. " >查看</a></td>";
echo "<TD ><input type=submit value=修 /></td>";
echo "</form>";
echo "</TR>";
  } 
echo "</TBODY></TABLE>";
?>
<?php 
$result = mysql_query("SELECT * FROM  url ");//查看总留言数并分页
$num = mysql_num_rows($result);
echo "外链数".$num." 个";
$ys = ceil($num/$_SESSION['ts']);

for ($i=1; $i<=$ys; $i++)
{
if ($_GET['ys']!=$i)
echo "〖<a href=?ys=".$i."&px=".$_GET['px'].">".$i."</a>〗";
else
echo "<strong>[".$i."]</strong>";
}
echo "</p>";
?>	</td>
    <td>
<table border="1">
<form action="?id=url" method="post"><tr>
<td>网址: <input type="text" name="url" /></td>

<td>站名: <input type="text" name="name" /></td></tr>
<tr><td>备注: <input type="text" name="bz" /></td>
<td><input type="submit" value="增加网址" /></td>
</tr></form>
</table>	
	</td>
  </tr>
  <tr>
    <td>
<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="20" id="content"><?php include("urltext.txt"); ?></textarea> <br>
<input type="submit" value="保存" /> <a onclick="jsCopy()" >点击复制</a>	
</form>
	</td>
  </tr>
</table>





<hr>

<textarea cols="88" rows="3">网页外链宣传
此项内容是为了方便站长发布外链。许多的网站可以发布一些网文，可以存放在右侧文本框内，复制使用比较方便，左侧可以记录常用网站。
</textarea>



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