<?php
	session_start(); 
	require_once('inc/conn.php');
	require_once('inc/constant.php');
	require_once('inc/ls_syscode.php');
	require_once('inc/check.php');
	$opendb=new mydb();
	require_once('inc/char_set.php');
	$ls_b2b_type=array("","",);

	//$tableResult   =   mysql_list_tables($dbname); 

	$ls=$_GET['ls'];
	$id=$_GET['id'];

	$nownum=$_GET['Num'];
	$modiid=$_POST['modiid'];
	$siteName=$_POST['siteName'];
	$url=$_POST['url'];
	$b2btype=$_POST['b2btype'];
	$ls_msg="";
	$searchproductName=$_POST['searchproductName'];
	if($searchproductName==''){$searchproductName=$_GET['searchproductName'];}// 分页传过来的变量
	$b2btype=$_POST['b2btype'];
	$siteName=$_POST['siteName'];
	$message=$_POST['message'];
	$AD=$_POST['AD'];

	$url=$_POST['url'];
	$profile=$_POST['profile'];
	$products=$_POST['products'];							
	$offers=$_POST['offers'];
	$alert=$_POST['alert'];
	$pages=$_POST['pages'];  // 推广字段， 页号 是page
	$username=$_POST['username'];
	$password=$_POST['password'];
	$error=$_POST['error'];
	$publicaccount=$_POST['publicaccount'];
	$count_sql="SELECT b2btype,error,COUNT(*),url FROM ls_promote_en GROUP BY b2btype, error";//count the error by searchtype
	$count_query=$opendb->query($count_sql);
	$count_sql2="SELECT b2btype,error,COUNT(*),url FROM ls_promote_en GROUP BY  error";//count the error by searchtype
	$count_query2=$opendb->query($count_sql2);
	$lsc=$_GET['lsc'];
	$lsctype=$_GET['lsctype'];
	
	
	switch ($ls)
	{
		case "up":
			$up=$nownum+1;
			$up_sql="update ls_promote_en set Num=".$nownum." where Num=".$up." ";
			$up_sql2="update ls_promote_en set Num=Num+1 where id=".$id." ";
			//echo $up_sql;
			$up_query=$opendb->query($up_sql);
			$up_query=$opendb->query($up_sql2);


			$ls_msg="上移操作成功！";
			break;
		case "down":
			$down=$nownum-1;
			$down_sql="update ls_promote_en set Num=".$nownum." where Num=".$down." ";
			$down_sql2="update ls_promote_en set Num=Num-1 where id=".$id." ";
			//echo $down_sql;
			$down_query=$opendb->query($down_sql);
			$down_query=$opendb->query($down_sql2);


			$ls_msg="下移操作成功！";
			break;
	 	case "unenable":
			$unenable_sql="update ls_promote_en set enable=0 where id=".$id." ";
			//echo $unenable_sql;
			$unenable_query=$opendb->query($unenable_sql);


			$ls_msg="不显示操作成功！";
			break;
		case "enable":
			$enable_sql="update ls_promote_en set enable=1 where id=".$id." ";
			//echo $enable_sql;
			$enable_query=$opendb->query($enable_sql);


			$ls_msg="显示操作成功！";
			break;
			
		case "insert":
			$clearurl=trim($url);
			$urlflag=str_replace("http://","",$clearurl);
			$urlflag=str_replace("https://","",$urlflag);
			$urlflag2=$urlflag;
			$urlflag=substr($urlflag,0,strpos($urlflag,"/"));  // 截取网址 去掉 / 以后的
			if($urlflag==""){$urlflag=$urlflag2;} // 没有 / 恢复原来的

			//if(substr_count($urlflag,".")==2)
			//{$urlflag=substr($urlflag,(strpos($urlflag,".")+1));}
			if($siteName==""){$siteName=$urlflag;}
			$select_sql2="select * from ls_promote_en where url like '%".$urlflag."%'";
			//echo "---  ".$select_sql2." ---  ".$clearurl;
			$select_query2=$opendb->query($select_sql2);
			$select_rows2_num=mysql_num_rows($select_query2); //总数
			if($select_rows2_num==0)
			{
				$select_sql2="select * from ls_promote_en ";
				$select_query2=$opendb->query($select_sql2);
				$select_rows2=mysql_num_rows($select_query2); //总数
			
				if($message!='') //如果已经填好信息，则输入日期
				{$date1=date("Y-m-d"); }
				else
				{$date1='';}	
			
				$ls_msg="【".$select_rows2['siteName']."】 ";
				$ls_msg.="添加操作成功！";

		}
		else
		{$ls_msg="B2b网站已经存在！";}
		
		break;
			
		case "modi":
			$select_sql2="select * from ls_promote_en  where id=".$modiid." ";
			
			$select_query2=$opendb->query($select_sql2);
			$select_rows2=mysql_fetch_assoc($select_query2); 
			
			
			$modi_sql="update ls_promote_en set username='".$username."',password='".$password."',b2btype='".$b2btype."',message='".$message."',AD='".$AD."',profile='".$profile."',products='".$products."',offers='".$offers."',alert='".$alert."',pages='".$pages."',error='".$error."',date='".date('Y-m-d')."',siteName='".$siteName."' where id=".$modiid." ";
			
			$modi_query=$opendb->query($modi_sql);
			

			$ls_msg.="修改操作成功！";
			writelog($b2btype." - ".str_replace("http://","",$config_rows2['website'])."  :  ".$_SERVER['PHP_SELF'],"modify ".$_SESSION['currentsuffix']." ".$username." ".$password." URL: <a href=\'".$url."\' target=\'_blank\'>".$url."</a>","user: ".$_SESSION['userid']." ID: ".$modiid);
			break;
			
	  	case "del":
			$select_sql2="select * from ls_promote_en where id=".$id." ";
			//echo $select_sql2;
			$select_query2=$opendb->query($select_sql2);
			$select_rows2=mysql_fetch_assoc($select_query2); 
			$num_sql2="update ls_promote_en set Num=Num-1 where Num>".$select_rows2['Num']." ";//all order number-1
			$down_query=$opendb->query($num_sql2);

			$del_sql="delete from ls_promote_en where id=".$id." ";
		   	$del_query=$opendb->query($del_sql);
			$ls_msg="【".$select_rows2['siteName']."】 ";
			writelog($_SERVER['PHP_SELF'],"Delete ".$_SESSION['currentsuffix']." URL: <a href=\'".$select_rows2['url']."\' target=\'_blank\'>".$select_rows2['url']."</a>","user: ".$_SESSION['userid']." ID: ".$modiid);

		   	$ls_msg.="删除操作成功！";
						
		 	break;
			

	}
	
switch ($lsc)
	{
		case "noreg":			
			$addsearchstr=" where profile=0 and products=0 and offers=0 and  alert=0 and  pages=0 and  (error is NULL or error='')   and  message='' ";
			$ls_msg="没有登记的网址";

		 	break;
		case "all":			
			$addsearchstr=" where 1 ";
			$ls_msg="全部网址";
		 	break;
		case "allfinish":			
			$addsearchstr=" where message='ok' or message='成功'  ";
			$ls_msg="已推广的";
		 	break;
		case "alldown":			
			$addsearchstr=" where 1 order by ID desc";
			$ls_msg="添加网站后先顺序";
		 	break;

		case "date":			
			$addsearchstr=" where 1 order by date desc";
			$ls_msg="推广时间后先顺序";
		 	break;
			
		case "type":			
			$addsearchstr=" where b2btype='".$lsctype."' ";
			$ls_msg="筛选条件： ".$lsctype." 的网址";
		 	break;
			
		case "newadd":	
			$addsearchstr=" where memo='newadd' order by date desc";
			$ls_msg="新加网站审核，时间后先顺序";
		 	break;
			
		case "getnew":
		
			$ls_msg="   --   ".$b2b_update_num." 个网址更新成功！";

			
	}
	
	$config_sql="select * from ls_config ";
	$config_query=$opendb->query($config_sql);
	$config_rows=mysql_fetch_assoc($config_query);
	

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="css/admin.css" rel="stylesheet" type="text/css">
<script language="JavaScript"  >

function secBoard(n)
{
	document.getElementById("Z_"+n).style.display="block";
	document.getElementById("ZH_"+n).style.display="none";

}
function secBoard2(n)
{
	document.getElementById("Z_"+n).style.display="none";
	document.getElementById("ZH_"+n).style.display="block";

}
</script>
<script type="text/javascript" src="js/ls.js"></script>

<title>无标题文档</title>
<style type="text/css">
<!--
.STYLE1 {
	color: #FF9900;
	font-weight: bold;
}
.STYLE2 {color: #CC6600}
-->
</style>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#6396d6">
  <tr>
    <td height="29" background="images/admin_bg.gif"><div align="center"><font color="#ffffff"><strong>推广发布管理</strong></font></div></td>
  </tr>
  <tr>
    <td height="213" valign="top" bgcolor="#dee7ff"><form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" name="searchfm" id="searchfm">
      <table width="99%" border="0" align="center" cellpadding="3" cellspacing="0" bgcolor="">
        <tr bgcolor="#DBEEF0" >
          <td width="24%" style="padding-left:6px;"><input name="Action" type="hidden" id="Action" value="proDel" />
            <a href="?lsc=noreg">没有登录的网址</a></td>
          <td width="25%" colspan="-1" align="center" style="padding-left:6px;"><a href="?lsc=all">全部</a>  <a href="?lsc=allfinish">已推</a> <a href="?lsc=alldown">后先</a>   <a href="?lsc=newadd">【新加】</a> </td>
          <td width="21%" align="right" style="padding-left:6px;"><strong>查找：</strong>
	        <input type="text" name="searchproductName" size="12" maxlength="50" />
	        <input type="submit"  value="查询" /></td>
          <td width="6%" align="right" style="padding-left:6px;"><a href="?lsc=getnew" class="STYLE2">更新</a></td>
          <td width="24%" align="right" style="padding-left:6px;"><select name="selecttype2" id="selecttype"  onchange="window.open('?lsc=type&amp;lsctype='+this.value,'right','');">
            <option value="0">请选择一个网址类别：</option>
            <?
         	$select_sql="select distinct b2btype from ls_promote_en where enable=1";
			$select_query=$opendb->query($select_sql);
			while($select_rows2=mysql_fetch_assoc($select_query))
		  	{
            	echo "<option value=".$select_rows2['b2btype'].">".$select_rows2['b2btype']."</option>";
            }
			?>
          </select></td>
        </tr>
      </table>
	  </form>
<?php 
if( isset($_GET['page']) ){
	   $page = intval( $_GET['page'] );
	}
	else{
		if($_POST['gopage']!="")
		{$page =$_POST['gopage'];}
		else{$page = 1;}
	}
	// 每页数量
	$PageSize = $PageNum;
	
	// 获取总数据量
	/********************************************************************************/
	$b2b_sql="select * from ls_promote_en ";
	if($searchproductName!="")
		{
			$b2b_sql.="where siteName like '%".$searchproductName."%'";
		}
	else
	{
		if($lsc=="noreg"||$lsc=="type"||$lsc=="all"||$lsc=="allfinish"||$lsc=="alldown" || $lsc=="date" || $lsc=="newadd")
		{
			$b2b_sql.=$addsearchstr;
		}
	}

	//大类
	$result=$opendb->query($b2b_sql);
	
	/********************************************************************************/
	// 获取总数据量
	
	$row = mysql_num_rows($result);
	$amount = $row;
	
	// 记算总共有多少页
	if( $amount ){
	   if( $amount < $PageSize ){ $page_count = 1; }               //如果总数据量小于$PageSize，那么只有一页
	   if( $amount % $PageSize ){                                  //取总数据量除以每页数的余数
	       $page_count = (int)($amount / $PageSize) + 1;           //如果有余数，则页数等于总数据量除以每页数的结果取整再加一
	   }else{
	       $page_count = $amount / $PageSize;                      //如果没有余数，则页数等于总数据量除以每页数的结果
	   }
	}
	else{
	   $page_count = 0;
	}
	
	// 翻页链接
	$page_string = '';
	if($lsc=="noreg"){	$pagecatestr="&lsc=".$lsc;}
	if( $page == 1 ){
	   $page_string .= '首页 | 上一页 |';
	}
	else{
	   $page_string .= '<a href=?&page=1&'.$pagecatestr."&".'lsc='.$lsc."&".'lsctype='.$lsctype."&".'searchproductName='.$searchproductName.'><u><font color=\"#0000FF\">首页</font></u></a> | <a href=?&page='.($page-1)."&".$pagecatestr."&".'lsc='.$lsc."&".'lsctype='.$lsctype."&".'searchproductName='.$searchproductName.'><u><font color=\"#0000FF\">上一页</font></u></a> | ';
	}
	if( ($page == $page_count) || ($page_count == 0) ){
	   $page_string .= ' 下一页 | 尾页';
	}
	else{
	   $page_string .= ' <a href=?&page='.($page+1).'&'.$pagecatestr."&".'lsc='.$lsc."&".'lsctype='.$lsctype."&".'searchproductName='.$searchproductName.'><u><font color=\"#0000FF\">下一页</font></u></a> | <a href=?&page='.$page_count.'&'.$pagecatestr."&".'lsc='.$lsc."&".'lsctype='.$lsctype."&".'searchproductName='.$searchproductName.'><u><font color=\"#0000FF\">尾页</font></u></a>';
	}
		 $page_string .= " &nbsp;&nbsp;页次：<font color='#FF0000'><b>".$page."</b></font>/<b>".$page_count."</b>页";
		 $page_string .= " (".$PageSize."个/页)";
	echo "
<table border=\"0\" width=\"98%\" align=\"center\">
	<tr>
		<td>提示： <font color=\"#FF0000\">".$_SESSION['currentsuffix']." ".$ls_msg."</font></td>
		<td align=\"right\">共 <b>".$row."</b> 个网站</td>
	</tr>
</table>
";	 
		 
		/*\***************************************************************************\*/
		/*\查询数据库	\*/
		/*\***************************************************************************\*/ 

		
	//查询数据
		if($lsc=="noreg"||$lsc=="type"||$lsc=="all"||$lsc=="allfinish"||$lsc=="alldown" || $lsc=="date" || $lsc=="newadd" )
		{
			$b2b_sql.=" limit ". ($page-1)*$PageSize .",".$PageSize." ";	
			//echo  $b2b_sql."dd";
		}else
		{
			$b2b_sql.=" order by  Num ASC limit ". ($page-1)*$PageSize .",".$PageSize." ";	
		}
	//echo $b2b_sql."<br>";
	$b2b_query=$opendb->query($b2b_sql);
		/*\***************************************************************************\*/
		/*\查询数据库	\*/
		/*\***************************************************************************\*/ 			
?><table width="99%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
        		<tr bgcolor="#B9DAFF">
			<td align="center" height="25" width="30"></td>
			<td align="center" height="25" width="30">类型</td>
			<td align="center" width="70">信息</td>
			<td align="center" width="80">URL</td> 
			<td align="center" width="46">用户名</td> 
			<td align="center" width="46">密码</td> 
			<td align="center" width="70">概况</td> 
			<td align="center" width="70">产品</td> 
			<td align="center" width="70">供求</td>
			<td align="center" width="70">提醒</td> 
			<td align="center" width="70">网页</td>
			<td align="center" width="62">操作日期</td>
			<td align="center" width="54">错误</td>
			<td align="center" colspan="2">排序</td>
		 	<td align="center" colspan="2">操作</td>
			<td align="center" width="12">允许</td>
		</tr>
		
		<?
	
	$i=1;
	$openurlstr="";
	while($b2b_rows=mysql_fetch_assoc($b2b_query))
	 {
	 	$openurlstr.="window.open('".$b2b_rows['url']."');";
		echo "<tbody id='ZH_".$b2b_rows['ID']."' >\r\n";	
 	  	echo "<tr bgcolor='#f4f4f4' ";
		echo " onMouseOver=";
		echo " 	this.style.backgroundColor='#CCFFCC' ";
		echo "onMouseOut=";
		echo " 	this.style.backgroundColor='#f4f4f4' ";
		echo ">\r\n";
		echo "	<td align='center'  height='25'>\r\n";
		//echo "		<input name='selectid".$i."' type='checkbox' onclick=\"unselectall();\" id=\"select_id\" value='".$b2b_rows['ID']."'>\r\n";
		echo "	</td>\r\n";
	  	echo "	<td style='padding-left:2px;' >\r\n";
		echo 		$b2b_rows['b2btype'];
		echo "	</td>\r\n";
	  	echo "	<td style='padding-left:2px;'>\r\n";
		echo 		$b2b_rows['message'];
		echo "	</td>\r\n";
		echo "	<td style='padding-left:2px;'>\r\n";
		echo 		"<a href='".$b2b_rows['url']."' target='_blank'>".$b2b_rows['url']."</a>";
		echo "	</td>\r\n";
		echo "	<td style='padding-left:2px;'>\r\n";
		echo 		substr($b2b_rows['username'],0,8)."\n".substr($b2b_rows['username'],8,8)."\n".substr($b2b_rows['username'],16,8);
		echo "	</td>\r\n";
		echo "	<td style='padding-left:2px;'>\r\n";
		echo 		substr($b2b_rows['password'],0,8)."\n".substr($b2b_rows['password'],8,8);
		echo "	</td>\r\n";
		echo "	<td >\r\n";
		echo 		$b2b_rows['profile'];
		echo "	</td>\r\n";
		echo "	<td >\r\n";
		echo 		$b2b_rows['products'];
		echo "	</td>\r\n";
		echo "	<td >\r\n";
		echo 		$b2b_rows['offers'];
		echo "	</td>\r\n";
		echo "	<td >\r\n";
		echo 		$b2b_rows['alert'];
		echo "	</td>\r\n";
		echo "	<td >\r\n";
		echo 		$b2b_rows['pages'];
		echo "	</td>\r\n";
		echo "	<td >\r\n";
		echo 		date('y-m-d',strtotime($b2b_rows['date']));
		echo "	</td>\r\n";
		echo "	<td >\r\n";
		echo 		$b2b_rows['error'];
		echo "	</td>\r\n";
		echo "	<td align='center'>\r\n";
		if($i!=1)
		{
		echo "		<a href='?id=".$b2b_rows['ID']."&Num=".$b2b_rows['Num']."&ls=up&page=".$page." ' title='向上移动'><img src='images/up.gif' border='0'></a>\r\n";
		}
		echo "  </td>\r\n"; 
		echo "	<td align='center'>\r\n";
		if($i!=$amount)
		{
		echo "	 <a href='?id=".$b2b_rows['ID']."&Num=".$b2b_rows['Num']."&ls=down&page=".$page." ' title='向下移动'><img src='images/down.gif' border='0'></a>\r\n";
		}
		echo "  </td>\r\n";
		echo "	<td align='center'>\r\n";
		echo "		<a href='javascript:secBoard(".$b2b_rows['ID'].");' title='编辑'><img src='images/b_edit.png' border='0'></a>\r\n";
		
		if( $lsc=="newadd" && $_SESSION['userid']=='admin')
		{    
			echo "		<a href='?id=".$b2b_rows['ID']."&ls=OK&page=".$page."&lsctype=".$lsctype."' onclick='return ConfirmOK();' title='审核通过'>OK</a>\r\n";
		
		}
		echo "  </td>\r\n";
		echo "	<td align='center'>\r\n    ";
		if(  $_SESSION['userid']=='admin' && strpos($_SERVER['HTTP_REFERER'],"ls_4fixsn")!==false)
		{   
			echo "		<a href='?id=".$b2b_rows['ID']."&ls=del&page=".$page."&lsc=".$lsc."&lsctype=".$lsctype."' onclick='return ConfirmDel();' title='删除'><img src='images/b_drop.png' border='0'></a>\r\n";
		}
		echo "   </td>  \r\n";
		echo "	<td align='center'>\r\n";
		  
	  if($b2b_rows['enable']==1)
		{
		echo "<a href='?id=".$b2b_rows['ID']."&ls=unenable&page=".$page." ' title='显示'><img src='images/enable.gif' border='0'></a>\r\n";
		}
	  if($b2b_rows['enable']==0)
  		{
		echo "<a href='?id=".$b2b_rows['ID']."&ls=enable&page=".$page." ' title='不显示'><img src='images/unenable.gif' border='0'></a>\r\n";
		}
	
		echo "	</td>\r\n";
		echo "</tr>\r\n";
		echo "</tbody>\r\n";
		
		echo "<tbody id='Z_".$b2b_rows['ID']."' style='display:none;'>\r\n";
		echo " <form name='fm_menu' action='?ls=modi&page=".$page."&lsc=".$lsc."&lsctype=".$lsctype."' method='post'> ";
		echo "	<tr bgcolor='#CCCCCC'>\r\n";
		echo "	<td align='center'>&nbsp;\r\n";
		echo "	</td>\r\n";
		echo "		<td style='padding-left:5px;'>\r\n";
		echo "			<input type='text' value='".$b2b_rows['b2btype']."' name='b2btype' size='1' class='inp'>\r\n";
		echo " 		</td>\r\n";
		echo "		<td style='padding-left:5px;'>\r\n";
		echo "			<input type='text' value='".$b2b_rows['message']."' name='message' size='6' class='inp'>\r\n";
		echo "			<input type='hidden' value='".$b2b_rows['siteName']."' name='siteName' size='6' class='inp'>\r\n";
		echo " 		</td>\r\n";
		echo "		<td style='padding-left:5px;'>\r\n";
		echo 		"<a href='".$b2b_rows['url']."' target='_blank'>".$b2b_rows['url']."</a>";
//		echo "			<input type='text' value='".$b2b_rows['url']."' name='url' size='45' class='inp'>\r\n";
		echo " 		</td>\r\n";
		echo "		<td style='padding-left:5px;'>\r\n";
		echo "			<input type='text' value='".($b2b_rows['username']?$b2b_rows['username']:$username)."' name='username' size='4' class='inp'>\r\n";
		echo " 		</td>\r\n";
		echo "		<td style='padding-left:5px;'>\r\n";
		echo "			<input type='text' value='".($b2b_rows['password']?$b2b_rows['password']:$password)."' name='password' size='4' class='inp' >\r\n";
		echo " 		</td>\r\n";
		echo "		<td style='padding-left:5px;'>\r\n";
		echo "			<input type='text' value='".$b2b_rows['profile']."' name='profile' size='1' class='inp' ondblclick='this.value=1'>\r\n";
		echo " 		</td>\r\n";
		echo "		<td align='left' style='padding-left:10px;' height='25'>\r\n";
	  	echo "			<input type='text' value='".$b2b_rows['products']."' name='products' size='1' class='inp' ondblclick='this.value=1'>\r\n";
		echo "		</td>\r\n";
		echo "		<td align='left' style='padding-left:5px;' height='25'>\r\n";
	  	echo "			<input type='text' value='".trim($b2b_rows['offers'])."' name='offers' size='1' class='inp' ondblclick='this.value=1'>\r\n";
		echo "		</td>\r\n";
		echo "		<td align='left' style='padding-left:5px;' height='25'>\r\n";
	  	echo  "			<input type='text' value='".$b2b_rows['alert']."' name='alert' size='1' class='inp' ondblclick='this.value=1'>\r\n";
		echo "		</td>\r\n";
		echo "		<td align='left' style='padding-left:5px;' height='25'>\r\n";
	  	echo  "			<input type='text' value='".$b2b_rows['pages']."' name='pages' size='1' class='inp' ondblclick='this.value=1'>\r\n";
		echo "		</td>\r\n";
		echo "		<td align='left' style='padding-left:5px;' height='25'>\r\n";
	  	echo  "			<input type='text' value='".date('y-m-d')."' name='date' size='16' class='inp' >\r\n";
		echo "		</td>\r\n";
		echo "		<td align='left' style='padding-left:5px;' height='25'>\r\n";
	  	echo  "			<input type='text' value='".$b2b_rows['error']."' name='error' size='1' class='inp' ondblclick='this.value=1'>\r\n";
		echo "		</td>\r\n";
		echo "		<td colspan='5' align='left'>\r\n";
		echo "			<input value='".$b2b_rows['ID']."' name='modiid' type='hidden'>\r\n";
		echo "			<input type='submit' value='确定修改'> &nbsp; ";
		echo "			<input type='button' onclick='javascript:secBoard2(".$b2b_rows['ID'].");' value='放弃修改'>\r\n";
		echo " 		</td>\r\n";
		echo "	</tr>\r\n";
		echo " </form>\r\n";
		echo "</tbody>\r\n";

	$i++;
	
	}
	?>
	<tr bgcolor="#B9DAFF">";
	
	<td colspan='18' align='center' height='44'><form action="".$_SERVER['PHP_SELF']."" method="post" name="searchfm2" id="searchfm2">
	  <span style="padding-right:150px;padding-left:70px">  <a href="javascript:" onclick="javascript:<?=$openurlstr?>" >打开上面网址</a> </span>
	<?=$page_string?> 到	  
	<input name="gopage" type="text" size="3" /> 页
	  <input type="submit" name="Submit" value="GO" /> 以上概况、产品、供求、提醒等双击改变当前值
	  
</form> 
	</td> 
	</tr> 
	</table>

	  <br />
	  <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
	    <tr>
	      <td height="48" colspan="4" align="center" bgcolor="#EBEFF5"><strong>推广信息</strong></td>
        </tr>
	    <tr>
	      <td width="15%" align="right" bgcolor="#EBEFF5">网站标题：</td>
	      <td width="35%" align="center" bgcolor="#EBEFF5"><textarea name="companyName" cols="64" class="inputareashort"  ><?php echo $config_rows['companyName'];?></textarea></td>
	      <td width="14%" align="right" bgcolor="#EBEFF5">关键字：</td>
	      <td width="36%" align="center" bgcolor="#EBEFF5"><textarea name="siteKeywords" cols="64" class="inputareashort"  ><?php echo $config_rows['siteKeywords'];?></textarea></td>
        </tr>
	    <tr>
	      <td align="right" bgcolor="#EBEFF5">网站描述：</td>
	      <td align="center" bgcolor="#EBEFF5"><textarea name="siteDescription" cols="64" rows="6" class="inputareashort" ><?php echo $config_rows['siteDescription'];?></textarea></td>
	      <td align="right" bgcolor="#EBEFF5">求售机会：</td>
 	      <td align="center" bgcolor="#EBEFF5"><textarea name="saleslead" cols="64" rows="6" class="inputareashort"  ><?php echo $config_rows['saleslead'];?></textarea></td>
      </tr>
	    <tr>
	      <td height="32" align="right" bgcolor="#EBEFF5">Tel（电话）： </td>
	      <td align="center" bgcolor="#EBEFF5"><input name="tel" type="text" class="ifinfoinputshort" value="<?php echo $config_rows['tel'];?>" size="60" /></td>
	      <td align="right" bgcolor="#EBEFF5">Fax（传真）：</td>
	      <td align="center" bgcolor="#EBEFF5"><input name="fax" type="text" class="ifinfoinputshort" value="<?php echo $config_rows['fax'];?>" size="60" /></td>
        </tr>
	    <tr>
	      <td height="32" align="right" bgcolor="#EBEFF5">E-Mail（反馈表邮箱）：</td>
	      <td align="center" bgcolor="#EBEFF5"><input name="feedbackEmail" type="text" class="ifinfoinputshort" value="<?php echo $config_rows['feedbackEmail'];?>" size="60"    /></td>
	      <td align="right" bgcolor="#EBEFF5">MSN：</td>
	      <td align="center" bgcolor="#EBEFF5"><input name="MSN" type="text" class="ifinfoinputshort" value="<?php echo $config_rows['MSN'];?>" size="60"    /></td>
        </tr>
	    <tr>
	      <td height="32" align="right" bgcolor="#EBEFF5">Website（网址）：</td>
	      <td align="center" bgcolor="#EBEFF5"><input name="website" type="text" class="ifinfoinputshort" value="<?php echo $config_rows['website'];?>" size="60"    /></td>
	      <td align="right" bgcolor="#EBEFF5">Skype：</td>
	      <td align="center" bgcolor="#EBEFF5"><input name="skype" type="text" class="ifinfoinputshort" value="<?php echo $config_rows['skype'];?>" size="60" /></td>
        </tr>
	    <tr>
	      <td height="32" align="right" bgcolor="#EBEFF5">Address（经营地点）： </td>
	      <td align="center" bgcolor="#EBEFF5"><input name="address" type="text" class="ifinfoinputlong"  value="<?php echo $config_rows['address'];?>" size="60"   /></td>
	      <td align="left" bgcolor="#EBEFF5">&nbsp;</td>
	      <td align="left" bgcolor="#EBEFF5">&nbsp;</td>
        </tr>
      </table>
	  <br />
      
	  <form action="?ls=insert" method="post" name="fmaddmenu" id="fmaddmenu">
   	    <table width="99%" border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#FFFFFF">
   	      <tr bgcolor="#B9DAFF">
   	        <td width="25%" height="38" style='padding-left:20px;'><input name="b2btype" type="text" size="6" value="normal"/>
   	          <select name="selecttype" id="select3"  onchange="document.fmaddmenu.b2btype.value=document.fmaddmenu.selecttype.value">
   	            <option value="0">请选择推广类型：</option>
   	            <?
         	$select_sql="select * from ls_b2b_type where enable=1";
			$select_query=$opendb->query($select_sql);
			while($select_rows2=mysql_fetch_assoc($select_query))
		  	{
            	echo "<option value=".$select_rows2['name'].">".$select_rows2['name']."</option>";
            }
			?>
              </select></td>
   	        <td width="19%" style='padding-left:20px;'>名称:
              <input type="text" name="siteName" /></td>
   	        <td width="38%" style='padding-left:20px;'>链接:
   	          <input name="url" type="text" size="65" /></td>
   	        <td width="18%" align="center"><p><span style="padding-left:20px;">
   	          <input type="submit" value="添加推广网站" />
   	        </span></p></td>
          </tr>
   	      <tr bgcolor="#B9DAFF">
   	        <td height="38" style='padding-left:20px;'>用户名:
   	          <input name="username" type="text" id="username" size="24" /></td>
   	        <td style='padding-left:20px;'>密码:
   	          <input type="text" name="password" id="password" /></td>
   	        <td colspan="2" style='padding-left:20px;'>信息:
   	          <input name="message" type="text" id="message" size="12" ondblclick="this.value='ok'"/>
   	          概况
   	          <input name="products" type="text" size="3" id="products" ondblclick='this.value=1'/>
   	          产品
   	          <input name="products" type="text" size="3" id="products" ondblclick='this.value=1'/>
   	          供求
   	          <input name="offers" type="text" size="3" id="offers" ondblclick='this.value=1'/>
   	          提醒
   	          <input name="alert" type="text" size="3" id="pages" ondblclick='this.value=1' />
   	          网页
   	          <input name="alert2" type="text" size="3" id="alert2" ondblclick='this.value=1' /></td>
          </tr>
        </table>
   	  </form>
	<br />
<table width="99%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
        <tr> 
          <td colspan="4" align="center" bgcolor="#DDEEFF"><span class="STYLE1"> 统 计</span></td>
        </tr>
        <tr> 
          <td width="10%" bgcolor="#B9DAFF">分类网站</td>
          <td width="35%" bgcolor="#B9DAFF">error</td>
          <td width="35%" bgcolor="#B9DAFF">代表URL</td>
          <td width="10%" bgcolor="#B9DAFF">数量</td>
        </tr>
        <? while($count_rows=mysql_fetch_assoc($count_query)){?>
        <tr> 
          <td bgcolor="#DDEEFF">
            <? echo $count_rows['b2btype'] ?>
          </td>
          <td bgcolor="#DDEEFF">
            <? echo $count_rows['error'] ?>
          </td>
          <td bgcolor="#DDEEFF">
            <? echo $count_rows['url'] ?>
          </td>
          <td bgcolor="#DDEEFF">
            <? echo $count_rows['COUNT(*)'] ?>
          </td>
        </tr>
        <?  } ?>
        <tr background="#B9DAFF"> 
          <td bgcolor="#B9DAFF">全部网站</td>
          <td bgcolor="#B9DAFF"> error</td>
          <td bgcolor="#B9DAFF">代表URL</td>
          <td bgcolor="#B9DAFF">数量</td>
        </tr>
        <?  while($count_rows2=mysql_fetch_assoc($count_query2)){?>
        <tr> 
          <td bgcolor="#DDEEF0">&nbsp;</td>
          <td bgcolor="#DDEEF0">
            <? echo $count_rows2['error'] ?>
          </td>
          <td bgcolor="#DDEEF0">
            <? echo $count_rows2['url'] ?>
          </td>
          <td bgcolor="#DDEEF0">
            <? echo $count_rows2['COUNT(*)'] ?>
          </td>
        </tr>
        <?  } 
	  $opendb->close();
	 ?>
      </table></td>
  </tr>
</table>

</body>
</html>