<!--#include file="conn.asp"-->
<!--#include file="../../conn.asp"-->


<%Call head()
Call saycarda("身份证真伪识别工具")

if request("ct")="" Then
If saytk<>1 then
%>
  <form id="form1" name="form1" method="post" action="?ct=do&amp;saytk=<%=saytk%>&amp;sid=<%=sid%>">
  <%End if%>
身份证真伪识别工具<br/>

身份证号码：

<input name="sfz" type="text" maxlength="18" />

<%If saytk<>1 then
%>

<input type="submit" name="Submit" value="立即查询" /></form>
<%else%>
<br/> <anchor>[立即查询]
 <go href="?ct=do&amp;saytk=<%=saytk%>&amp;sid=<%=sid%>" method="post">
  <postfield name="sfz" value="$(sfz)"/> 
 </go>
 </anchor>



<%End if%>

<%
elseif request("ct")="do" then
dim sfz
sfz=trim(request("sfz"))
if len(sfz)<>18 then Alert "目前只能识别第二代身份证！你填写的位数不正确。","?"
	if IsNumeric(left(sfz,17)) then
		dim numarr(16)
		for i=0 to 16
		numarr(i)=mid(sfz,i+1,1)
		'response.write numarr(i)&"<br>"
		next
		yu=(numarr(0)*7+numarr(1)*9+numarr(2)*10+numarr(3)*5+numarr(4)*8+numarr(5)*4+numarr(6)*2+numarr(7)*1+numarr(8)*6+numarr(9)*3+numarr(10)*7+numarr(11)*9+numarr(12)*10+numarr(13)*5+numarr(14)*8+numarr(15)*4+numarr(16)*2) mod 11
		select case yu
		case 0
		last="1"
		case 1
		last="0"
		case 2
		last="x"
		case 3
		last="9"
		case 4
		last="8"
		case 5
		last="7"
		case 6
		last="6"
		case 7
		last="5"
		case 8
		last="4"
		case 9
		last="3"
		case 10
		last="2"
		end select
		ylast=lcase(right(sfz,1))
	
		if cstr(last)=cstr(ylast) then
			Alert "恭喜你!\n你的身份证是合格的。","?"
		else
			Alert "Sorry!\n你的身份证的尾数不正确。很有可能是伪造的。","?"
		end if
	else
		Alert "请不要拿本工具开玩笑,你输入的不是数字！","?"
	end if

end if

' 提示信息
function Alert(byval Msgstr,byval  Url)
	if len(Url) > 0 then
	on error resume next
	if len(Msgstr) > 0 then response.write "" & Msgstr & "" ' 提示
	response.write "" & Url & "" ' 跳转

	else
	if len(Msgstr) > 0 then response.write "" & Msgstr & "" ' 提示
	end If

end Function
response.write "<br/><br/><a href=""sfzw.asp?sid="&sid&"&amp;saytk="&saytk&""">返回上级</a>"
response.write "<br/><a href=""../index.asp?sid="&sid&"&amp;saytk="&saytk&""">便民中心</a><br/>"
response.write "<a href=""/index.asp?sid="&sid&"&amp;saytk="&saytk&""">网站首页</a><br/>"
Call headsay()

%>

