<?php 
require_once 'conn.php';
require_once 'function.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"/>
<title>在线投稿 <?=$site['sitename']?></title>
<link rel="stylesheet" href="css/index.css">
<link rel="stylesheet" href="page.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/jquery.js"></script>
<script src="layer/layer.js"></script>
<script src="js/bootstrap.min.js"></script>
<script charset="utf-8" src="kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="kindeditor/lang/zh_CN.js"></script>
<script>
	var editor;
	KindEditor.ready(function(K) {
		editor = K.create('textarea[name="content"]', {
	})});
</script>
<style>
.navbar { margin-bottom:0px;}
</style>
</head>
 
<body>
<?php 
require_once 'head.php';
?>
<div class="container">
  <div class="box"> 
    <div class="row">
         <div class="panel panel-default">
			<div class="panel-heading">
				<h3 class="panel-title">
					快速发布链接
				</h3>
			</div>
			<div class="panel-body">
				
				<form action="" method="post">
		
			<table width="100%" border="0" cellspacing="0" cellpadding="0" class="biaoge">		 
				  <tr>
					<td width="250">网站名称</td>
					<td><input name="sitename" type="text" style="width:100%"  /></td>
				  </tr>
				 
				 <tr>
					<td width="200">网站URL</td>
					<td><input name="url" type="text" style="width:100%" /></td>
				  </tr>
				  
				  <tr>
					<td width="200">交换QQ <br> <font color="red">(*登录本站时可使用此QQ号登录)</font></td>
					<td><input name="qq" type="text" /></td>
				  </tr>
				 
				  <tr>
					<td width="200">登录密码</td>
					<td><input name="pwd" type="text" value="123456" /></td>
				  </tr>
				
				  
				   <tr>
					<td></td>
					<td><input name="submit" type="submit" value="确认" class="btn btn-primary" /></td>
				  </tr>
				  
				</table>
				 </form>
				 
				
				 
				 
				<?php 
				
				

				
				if($_POST['submit']){
				
				
				 $sitename=trim($_POST['sitename']);		
				 $url=trim($_POST['url']);				
				
				 $qq=trim($_POST['qq']);					 				
				 $pwd=trim($_POST['pwd']);
				 
			
				 if(empty($sitename)){
				 msg('请输入网站名称');
				 }
				 if(empty($url)){
				 msg('请输入域名');
				 }		
				 if(empty($qq)){
				 msg('请输入QQ');
				 }				 
				 if(empty($pwd)){
				 msg('请输入密码');
				 }
				 
				 if(strlen($qq)<=3){
				  msg('QQ号码不正确');
				 }
			
				 $time=date("Y-m-d H:i");
				 
				 $url=str_replace("https://","",$url);
				 $url=str_replace("http://","",$url);
				 
				 $row=query("select * from url_data where url='$url'");
				 if($row){
				 msg('该网址已经存在');
				 }				 
				 $arr=array(	
				'user'=>$qq,			
				'sitename'=>$sitename,				
				'url'=>$url,				
				'qq'=>$qq				
				);
				
				
				$sql="select * from user where user='$qq'";	
				$row=query($sql);				
				if($row){
				 exit("<script>alert('该账号已经存在! 请登录添加网站');window.history.go(-1);</script>");
				 exit();
				}
				
				
				$sql=gzsql($arr);		 
				mysql_query("insert into url_data $sql");				
			    mysql_query("insert into user (user,pwd,time) values ('$qq','$pwd','$time')");
				
				
				echo "<script>alert('发布成功 请记住用户名是：".$qq." 密码是：".$pwd."');window.location.href='index.php';</script>";
				 
				}
				
				?>
				
			</div>
		</div>

    </div>
	
	
	
	
	<?php 
		require_once 'foot.php';

	?>
	
	<!--我的代码结束-->
  </div>
</div>

</body>
 
</html>