<?php
/**
 * @version        Somao_Search X1.0 9:23 2012-1-1 Somao $
 * @package        Somao_Search.Site
 * @copyright      Copyright (c) 2009 - 2012, Somao, Inc.
 * @license        http://www.somao123.com/
 * @link           http://www.somao.cc/
 */
require_once("global.php");
is_login();
$action=trim(HtmlReplace($_POST["action"]));
if($action=="add"){
	 $mid=$user["user_id"];
	 $webname=trim(HtmlReplace($_POST["webname"]));
	 $weburl=trim(HtmlReplace($_POST["weburl"]));
	 $webbody=trim(HtmlReplace($_POST["webbody"]));
	 $webtype=trim(HtmlReplace($_POST["webtype"]));
	 if($webname=="") {
		jsalert ("请填写网站名称!");
		exit(); 
	 }
	 if($weburl=="") {
		jsalert ("请填写网址!");
		exit();
	 }
	 $fp=fopen("http://".$weburl."/webunion.txt","r"); 
	 if($fp){
		$fp2=file_get_contents("http://".$weburl."/webunion.txt");
		echo $fp2;
		if(trim(HtmlReplace($fp2)!=$mid)){
	      jsalert ("验证失败，请检查贵网站根目录中是否存在验证文件!");
     	  exit();
        } 
	 }else{
		jsalert ("验证失败，请检查贵网站根目录中是否存在验证文件!");
		exit();
	 }
	 $row = $db->get_one("select * from ve123_webunion where weburl like '%".$weburl."%'");
	 if(is_array($row))
	 {
	   jsalert ("该网站已审核验证过，请不要重复验证!");
       exit();
	 }
	 $arcrank=0;
     $array=array('mid'=>$mid,'arcrank'=>$arcrank,'webname'=>$webname,'weburl'=>$weburl,'webbody'=>$webbody,'webtype'=>$webtype,'dtime'=>time());
	 $db->insert("ve123_webunion",$array);
	 header("location:union.php");
}
    

?>
<!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=gb2312" />
<title>添加站点</title>
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<link href="/css/union.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/union.js"></script>
</head>
<body>
<div id="body">
<form name="ctl00" method="post" action="" id="ctl00">
<input type="hidden" name="action" value="add" />
<table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#39867B">
  <tr>
    <td class="title">添加站点信息</td>
  </tr>
  <tr>
    <td valign="top" bgcolor="#EFEFEF"><table width="80%" border="0" align="center" cellpadding="0" cellspacing="0" class="table">
      <tr>
        <td width="11%">&nbsp;</td>
        <td width="89%">&nbsp;</td>
      </tr>
      <tr>
        <td height="30"><div align="right">站点地址：</div></td>
        <td>http://
          <input name="weburl" type="text" id="weburl" class="input" style="width:220px;" />
		  </td>
      </tr>
	
      <tr>
        <td height="60"><div align="right">验证网站：</div></td>
        <td style="border:1px solid #ccc;">
          <p>1、请点击"<span id="down"><a href="union_download.php?t=<?php echo $user["user_id"];?>"><u>下载验证文件</u></a></span>"获取验证文件</p>
          <p>2、将验证文件放置于您所填写的网站(如zxyt.cn)的根目录下 注意：只能填写顶级域名</p>
          </td>
      </tr>
	  
      <tr>
        <td height="30"><div align="right">站点名称：</div></td>
        <td>
            <input name="webname" type="text" id="webname" class="input" style="width:280px;" /> 
            * (如 泽许官网) </td>
      </tr>
      <tr>
        <td height="30"><div align="right">站点介绍：</div></td>
        <td>
            <textarea name="webbody" rows="5" cols="20" id="webbody" class="input" style="width:280px;"></textarea> 
            * </td>
      </tr>
      <tr>
        <td height="30"><div align="right">站点类型：</div></td>
        <td><select name="webtype" id="webtype">
			<option value="未分类">选择类型</option>
			<option value="综合网站">综合网站</option>
			<option value="论坛博客">论坛博客</option>
			<option value="网址大全">网址大全</option>
			<option value="游戏资讯">游戏资讯</option>
			<option value="视频电影">视频电影</option>
            <option value="其他类型">其他类型</option>
           </select></td>
      </tr>
      <tr>
        <td height="30">&nbsp;</td>
        <td>
            <input type="submit" name="Button1" value=" 确 定 " id="Button1" class="button"/></td>
      </tr>

    </table></td>
  </tr>
</table>
</form>
<br />
<table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#39867B">
  <tr>
    <td class="title">我的站点列表</td>
  </tr>
  <tr>
    <td valign="top" bgcolor="#EFEFEF"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#dddddd" class="table">
      <tr>
        <td width="6%" height="30" bgcolor="#efefef"><h4 align="center">ID</h4></td>
        <td width="12%" bgcolor="#efefef"><h4>站点名称</h4></td>
        <td width="12%" bgcolor="#efefef"><h4>域名</h4></td>
        <td width="8%" bgcolor="#efefef"><h4 align="center">站点类型</h4></td>
        <td width="8%" bgcolor="#efefef"><h4 align="center">贡献流量</h4></td>
        <td width="8%" bgcolor="#efefef"><h4 align="center">得到流量</h4></td>
        <td width="8%" bgcolor="#efefef"><h4 align="center">收录深度</h4></td>
        <td width="10%" bgcolor="#efefef"><h4 align="center">状态</h4></td>
        <td width="15%" bgcolor="#efefef"><h4 align="center">审核时间</h4></td>
        <td width="10%" bgcolor="#efefef"><h4 align="center">获取代码</h4></td>
        </tr>
  <?php
  $query=$db->query("select * from ve123_webunion where mid='".$user["user_id"]."' order by id desc ");
  while($link=$db->fetch_array($query)){
  ?>
  <tr>
    <td height="30" align="center"><?php echo $link["id"];?></td>
    <td><a href="http://<?php echo $link["weburl"];?>" target="_blank"><?php echo $link["webname"];?></a></td>
    <td><a href="http://<?php echo $link["weburl"];?>" target="_blank"><?php echo $link["weburl"];?></a></td>
    <td align="center"><?php echo $link["webtype"];?></td>
    <td align="left">今日：<?php echo countunion($link["id"],'day',1);?><br />总量：<?php echo countunion($link["id"],'',1);?></td>
    <td align="left">今日：<?php echo countunion($link["id"],'day',2);?><br />总量：<?php echo countunion($link["id"],'',2);?></td>
    <td align="center"><?php echo countwebs($link["weburl"]);?></td>
    <td align="center"><?php if($link["arcrank"]>0){echo "已审核";}elseif($link["arcrank"]<0){echo "审核失败";}else{echo "未审核";};?></td>
    <td align="center"><?php echo MyDate('Y-m-d  H:i:s',$link["dtime"])?></td>
    <td align="center"><a href="union_code.php?urlid=<?php echo $link["id"];?>">代码</a></td>
  </tr>
  <?php
  }
  ?>
    </table></td>
  </tr>
</table>