<%
guidedisplay=1
copyrightend=1
%>
<!--#include file="admin_start.asp" -->
<style>
td {font:Arial;font-size:10pt}
body {font:Arial;font-size:10pt}

</style>
<body onmousemove="top.changew(2,event.x)" onmouseup="top.changew(1,event.x)">
<%
function check_sql(sql)
	dim rs_check
	on error resume next
	check_sql = false
	set rs_check=conn.execute(sql)
	set rs_check=nothing
	If Err.number=0 then		'感谢网友5757的宝贵建议
		check_sql = True
		'response.write sql
	end if	

end function

function check_f(s1,sss)

	dim i
	dim ss
	
	if sss="" or s1="" then 
		check_f=true
		exit function
	end if
	
	ss=sss
	ss=split(replace(ss," ",""),",")
	
	for i=0 to ubound(ss)
		
		if ss(i)=s1 then 
			check_f=true
			exit function
		end if
	
	next
	
check_f=false

end function

function getfield(t,fs)

	
	dim rsSchema
	dim n_ex
	't=table
	
	if t="" then exit function
	set rsSchema=Conn.openSchema(4)
	rsSchema.Filter =  "TABLE_NAME='" & t & "' "
	do while not rsSchema.eof 
	
		n_ex=0
		if fs<>"" then 
			if not check_f(rsSchema("COLUMN_NAME"),fs) then n_ex=1
		end if
		if n_ex<>1 then
		%>
		<tr onmouseover="this.style.background='#ebebeb';" onmouseout="this.style.background='#ffffff';">
				
			<td height=20  width='100%' align=left style='border-bottom:1px dotted #d0d0d0'><nobr>
			<img src="images/class6_a.gif" align=absmiddle><img src="images/class3_a.gif" align=absmiddle><img align=absmiddle src="images/label_title_l_0.gif" > 
			<%
			s_i=rsSchema("COLUMN_NAME")
			if rsSchema("DESCRIPTION")<>"" then 
				if request("order")="y" then s_i=rsSchema("DESCRIPTION")&"$"&s_i
				response.write "<a title='点击插入此字段标签' href=javascript:InsertLabel('"&s_i&"')><font color=green>"&rsSchema("COLUMN_NAME")&" ["&rsSchema("DESCRIPTION")&"]</font></a>"
			else
				if request("order")="y" then s_i="排序字段说明$"&s_i
				response.write "<a title='点击插入此字段标签' href=javascript:InsertLabel('"&s_i&"')><font color=green>"&rsSchema("COLUMN_NAME")&"</font></a>"
			end if
			%>
				
			</nobr>
			</td>
				
		</tr>
		<%
		end if
		rsSchema.movenext
	loop
	set rsSchema=nothing

end function
'//////////////////////////////////////////////////////////////////////////////
if Session("FB_EM_1_ACC_c_sql")="" then 
	response.write "<center><br>sql语句不合法，请先生成合法的sql查询语句！！</center>"
	response.end
end if
'////检查sql语句的合法性
c_sql=trim(Session("FB_EM_1_ACC_c_sql"))
if instr(1,c_sql,"select",1)>0 then
	
	if not check_sql(split(Ucase(c_sql),"WHERE")(0)) then 
		response.write "<center><br>sql语句不合法，请先生成合法的sql查询语句！！</center>"
		response.end
	end if
	'////取得字段列表
	c_sql=replace(c_sql,vbcrlf," ")
	'c_sql=replace(c_sql," ","|$|")
	l_s=instr(1,c_sql,"select",1)+6
	l_e=instr(l_s,c_sql,"from",1)
	f_sql=mid(c_sql,l_s,l_e-l_s)
	
	if instr(1,f_sql,"*")>0 then 
		f_sql=""
	else
		f_sql=trim(replace(f_sql,"top",""))
		l_s=instr(1,f_sql," ")+1
		f_sql=replace(mid(f_sql,l_s)," ","")
	end if
	'////取得表名
	c_sql=trim(mid(c_sql,l_e+4))
	
	l_s=instr(1,c_sql," ")
	if l_s=0 then
		t_sql=c_sql
	else
		t_sql=trim(mid(c_sql,1,l_s))
	end if
else
	l_s=instr(1,c_sql,"MySys.temp.search.search(""",1)
	if l_s>0 then 
		l_s=l_s+25
		l_e=instr(l_s,c_sql,"""",1)
		if l_e>0 then 
			t_sql=trim(mid(c_sql,l_s,l_e-l_s))
			t_sql="jins_"&t_sql&"_list"
			f_sql=""
		else
			response.write "<center><br>sql语句不合法，请先生成合法的sql查询语句！！</center>"
			response.end
		end if
	else
		response.write "<center><br>sql语句不合法，请先生成合法的sql查询语句！！</center>"
		response.end
	end if
end if

'//////////////////////////////////////////////////////////////////////////////
%>
	<table cellpadding="0" cellspacing="0"  border="0" id=label_list width="300%"   valign=top >
		<tr> 
		  <td align=left height=20 style='padding:0' colspan="10" bgcolor="#ffffff" valign=top style='border-bottom:1px dotted #d0d0d0'>
		  <img src="images/class4_a.gif" align=absmiddle ><img style='CURSOR: hand' title='点击展开或合上下级标签列表' onclick='opencat(st,this);'  src="images/class7_a.gif" align=absmiddle> 可用字段标签
		  </td>
		</tr>
		<tr id=st> 
		  <td align=center style='padding:0' colspan="10" bgcolor="#ffffff" valign=top>
			<table cellspacing=0 cellpadding=0 width=100% align=left  >
			<%
			'response.write t_sql&"|"&f_sql
			getfield t_sql,f_sql 
			%>
			</table>
		  </td>
		</tr>
	</table>
	<SCRIPT language=javascript>
	
		function opencat(cat,img)
		{
			if(cat.style.display=="none"){
			cat.style.display="";
			img.src="Images/class7_a.gif"
			} else {
			cat.style.display="none"; 
			img.src="Images/class1_a.gif"
			}
		}

	</SCRIPT>
<script language="javascript" defer>
function InsertLabel(s){
var string=""
<%if request("order")<>"y" then %>
string='<font color=green>{$rs_loop(rs_loop_num)("'
string+=s
string+='")$}</font>'
top.InsertLabel(string);
<%else%>
string+=','+'<font color=green>'+s+'</font>'+','
top.InsertLabel(string);
top.FarmatLabel(",");
<%end if%>
top.focus
}
</script>

<!--#include file="admin_end.asp" -->
