<%@ page language="C#" autoeventwireup="true" inherits="admin_search_sekeyslist, localhost_deploy" %>
<%@ Register Src="../../common/pageContent.ascx" TagName="pageContent" TagPrefix="uc1" %>
<!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>
<title>网站入口页</title>
<link href="/admin/common/client.css" rel="stylesheet" type="text/css" />
<style>
.show1{
display:none;
}
</style>
<script language="javascript">
function AddKeyInFast(s_key)
{
	top.o_parentFrame=window;
	window.open("userkeyslist.aspx?do=add&key="+escape(s_key)+"&rnd="+Math.random(),"fredo");
}

function GetKeyTop(obj,s_key)
{
		obj.style.display="none";
		$P('txtcol').value+=s_key+"\r\n";
}

function ShowKeyAdd(s_key)
{
	
	if(("\r\n"+$P('txtcol').value+"\r\n").search("\r\n"+s_key+"\r\n")<0)
	{
		document.write("<input type='button' class='button' value='采集' onclick=\"GetKeyTop(this,'"+s_key+"')\" />");
	}
	 
}
</script>
</head>
<body class="mg3">
<%
	//详细列表
	string s_url= "";
	
	PageContent.ImagePageBar=true;
  PageContent.Table="Sys_VisitedReport";
	PageContent.Url = "sekeyslist.aspx?"+GetParameter()+"&ord="+Para("ord") +"&pn=@pagenumber@";
	
	s_url = "sekeyslist.aspx?"+ GetParameter()+"&ord=";
	
	PageContent.AddList("<td>编号</td>","<td>@ItemNumber@</td>");
	
	if(Para("type")=="1")
	{
		//组记录
		PageContent.PageBody("@@Const.PageTable()@@","@@Const.PageBar(\"\")@@","<tr id='trhead'>@content@</tr>","<tr id='tr_@K_ID@'>@content@</tr>");
		PageContent.Order=" V_Name ";
		PageContent.SQL=" select sum(V_Conversion) as ccnt,V_Name,count(V_Name) as vcnt,(select count(*) from Sys_FastResult where F_Key=V_name) as fcnt from Sys_VisitedReport where " +GetWhere().Replace("'","#") + " group by V_Name  ";
	  PageContent.SQLCount="select count(*) as cnt from (select count(*) from Sys_VisitedReport where " +GetWhere().Replace("'","#") + " group by V_Name )";
		PageContent.AddList("@@Const.PageOrderField('"+s_url+"','V_Name','" + Para("ord") + "','关键词')@@", "<td>@V_Name@</td>");
		PageContent.AddList("@@Const.PageOrderField('"+s_url+"','count(v_name)','" + Para("ord") + "','搜索量')@@", "<td>@vcnt@</td>");
		PageContent.AddList("@@Const.PageOrderField('"+s_url+"','sum(V_Conversion)','" + Para("ord") + "','转化数量')@@", "<td>@ccnt@</td>");
		
		PageContent.AddList("<td width='10%'>快速提示</td>", "<td>&nbsp;<input type='button' class='button show@fcnt@' value='加入提示' onclick=\"AddKeyInFast('@v_name@')\" /></td>");
		PageContent.AddList("<td width='10%'>采集</td>", "<td>&nbsp;<script language='javascript'>ShowKeyAdd('@V_Name@')</script></td>");
		
		 
	}
	else
	{	
		int i_free=WebCode.function.GetNumber( ds.GetDataString("select count(*) as cnt from  Sys_VisitedReport where V_Buy=0 and "+GetWhere().Replace("'","#"),"@cnt@"));
		int i_ad=WebCode.function.GetNumber(ds.GetDataString("select count(*) as cnt from  Sys_VisitedReport where V_Buy=1 and "+GetWhere().Replace("'","#"),"@cnt@"));
		int i_dir=WebCode.function.GetNumber(ds.GetDataString("select count(*) as cnt from  Sys_VisitedReport where V_Buy=2 and "+GetWhere().Replace("'","#"),"@cnt@"));
		int i_otr=WebCode.function.GetNumber(ds.GetDataString("select count(*) as cnt from  Sys_VisitedReport where V_Buy=3 and "+GetWhere().Replace("'","#"),"@cnt@"));
		
		int i_total=i_free+i_ad+i_dir+i_otr;
		
		if(i_total==0)
			i_total=1;
		
		
		PageContent.PageBody("@@Const.PageTable()@@","<div class='pagebar'><span class='tright fright'>@pageNumber@&nbsp;&nbsp; 共 @pageCount@ 页 共 @itemCount@ 项&nbsp;</span><span class=\"blue\">直接访问："+i_dir+" ("+(i_dir*100/i_total).ToString("0")+"%)</span> <span class=\"deeppink\">其他网站："+i_otr+" ("+(i_otr*100/i_total).ToString("0")+"%)</span> <span class=\"green\">自然排名："+i_free+" ("+(i_free*100/i_total).ToString("0")+"%)</span> <span class=\"red\">竞价推广："+i_ad+" ("+(i_ad*100/i_total).ToString("0")+"%) </span></div>","<tr id='trhead'>@content@</tr>","<tr id='tr_@K_ID@'>@content@</tr>");
		
		//0 详细记录
		string s_where="  ";
		if(Para("type")=="2")
		{
			s_where=" V_Enter=1 and "; //仅入口 本页
		}
		else if(Para("type")=="10")
		{
			//该用户访问的所有页面 sekeysitem.aspx
			s_where=" V_SID='"+ Para("sid") +"'  and V_ID>="+ Para("id") +" and "; //仅入口
		}
		else if(Para("idlst")!="")
		{
			//防恶意点击
			s_where+=" V_Id in ("+Para("idlst")+") and ";
		}
		else if(Para("session")!="")
		{
			//客户记录
			s_where+=" V_SessionID='"+Para("session")+"' and  ";
		}
		else if(Para("vid")!="")
		{
			//客户记录
			s_where+=" V_ID="+Para("vid")+" and  ";
		}
		
		PageContent.SQL=" select V_Conversion,V_Enter,V_StayTime,V_Stop,V_ID,V_Memo,V_Title,V_Name,V_SE,V_IP,V_Area,V_REFERER,V_Url,V_Date,V_Buy,V_Visited,V_Memo from Sys_VisitedReport  where "+ s_where +GetWhere().Replace("'","#");
	  PageContent.AddList("@@Const.PageOrderField('"+s_url+"','V_Name','" + Para("ord") + "','关键词')@@", "<td><a target='_blank' href='@V_REFERER@'>@V_Name@</a></td>");
	  
		PageContent.AddList("@@Const.PageOrderField('"+s_url+"','V_SE','"+Para("ord")+"','搜索引擎')@@","<td>@@Csharp.GetSelectValue('@V_SE@','0,"+ds.GetDataString("select S_ID,S_Description from Sys_Spider ","|@S_ID@,@S_Description@")+"')@@</td>");
		PageContent.AddList("@@Const.PageOrderField('"+s_url+"','V_Buy','"+Para("ord")+"','类型')@@","<td>@@Csharp.GetSelectValue('@V_Buy@','0,<span class=\"green\">自然排名</span>|1,<span class=\"red\">竞价</span>|2,<span class=\"blue\">直接访问</span>|3,<span style=\"color:deeppink;\">其他网站</span>')@@</td>");
	  PageContent.AddList("@@Const.PageOrderField('"+s_url+"','V_Url','"+Para("ord")+"','访问页面')@@","<td><a target='_blank' href='@V_Url@'>@V_Title@</a></td>");
		
		PageContent.AddList("@@Const.PageOrderField('"+s_url+"','V_IP','"+Para("ord")+"','用户地址')@@","<td>@V_IP@</td>");
		
		PageContent.AddList("@@Const.PageOrderField('"+s_url+"','V_Area','"+Para("ord")+"','地区')@@","<td>@V_Area@</td>");
		
		
		PageContent.AddList("@@Const.PageOrderField('"+s_url+"','V_Date','"+Para("ord")+"','日期')@@","<td>@V_Date@</td>");
		
		PageContent.AddList("@@Const.PageOrderField('"+s_url+"','V_Visited','"+Para("ord")+"','访问次数')@@","<td>@V_Visited@</td>");
		PageContent.AddList("@@Const.PageOrderField('"+s_url+"','V_StayTime','"+Para("ord")+"','访问时间')@@","<td>@@Csharp.ShowVisitedTime('@V_StayTime@')@@</td>");
		
		PageContent.AddList("@@Const.PageOrderField('"+s_url+"','V_Memo','"+Para("ord")+"','备注')@@","<td>@V_Memo@</td>");
		
		PageContent.AddList("@@Const.PageOrderField('"+s_url+"','V_Enter','"+Para("ord")+"','页面类型')@@","<td>@@Csharp.GetSelectValue('@V_Enter@','1,入口|0,')@@</td>");
		
		PageContent.AddList("@@Const.PageOrderField('"+s_url+"','V_Stop','"+Para("ord")+"','防护')@@","<td>@@Csharp.ShowVisitedStop('@V_Stop@')@@</td>");
		PageContent.AddList("@@Const.PageOrderField('"+s_url+"','V_Conversion','"+Para("ord")+"','转换')@@","<td>@@Csharp.GetSelectValue('@V_Conversion@','1,转化|0,')@@</td>");
		
		
		if(Para("type")!="10")
		{
			PageContent.AddList("<td></td>","<td><a onclick='ShowSearchBar(0)'  href='sekeysitem.aspx?id=@V_ID@'>详细</a></td>");
		}
	}
%>
<%//=PageContent.SQL%>
<uc1:pageContent ID="PageContent" runat="server" />
<%if(Para("type")!="10"){%>
	<script type="text/javascript" >
	ShowSearchBar(1);
	</script>
<%}%>

</body>
</html>   
