📄 index.php
字号:
<?php
/*
[身份证查询]
[文件] index.php --- 主文件
info.txt --- 数据文件
[注意] info.txt和index.php要在一个文件架下
[版本]: 1.0.0
[版权]Copyright: PhpUp Studio (www.phpup.com)
[时间]Last Modified: 2005/05/20 01:20
*/
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>身份证所在地查询</title>
</head>
<body>
<form method="post">
<input name="idc" size="40" type="text">
<input name="submit" type="submit">
<input name="action" type="hidden" value="do">
</form>
<?php
if('do' == $_POST['action']){
if(false == IDCheck($_POST['idc'])){
echo "请输入正确的15或18位身份证";
exit;
}
$idc = $_POST['idc'];
$idc = substr($idc, 0, 6);
$idc = substr(md5($idc), 8, 16);
$lines = file ('info.txt');
foreach ($lines as $line_num => $line) {
list($bm,$dq) = explode('|',$line);
if($bm == $idc){
echo "地址:".$dq."<br>";
echo "性别:".chksex($_POST['idc'])."<br>";
echo "生日:".chkbirthday($_POST['idc']);
$get_it = 1;
break;
}
}
if(1 <> $get_it){
echo "地址:找不到相关信息,这个号码可能有些老<br>";
echo "性别:".chksex($_POST['idc'])."<br>";
echo "生日:".chkbirthday($_POST['idc']);
}
}
?>
</body>
</html>
<?php
//定义函数
function chksex($idc){
$idclen=strlen($idc);
if(15 == $idclen){
if(0 <> $idc[$idclen-1]%2){
return "男";
}else{
return "女";
}
}elseif(18 == $idclen){
if(0 <> $idc[$idclen-2]%2){
return "男";
}else{
return "女";
}
}
}
function chkbirthday($idc){
$idclen=strlen($idc);
if(15 == $idclen){
$byear = substr($idc,6,2);
$bmonth = substr($idc,8,2);
$bday = substr($idc,10,2);
return "19".$byear."年".$bmonth."月".$bday."日";
}elseif(18 == $idclen){
$byear = substr($idc,6,4);
$bmonth = substr($idc,10,2);
$bday = substr($idc,12,2);
return $byear."年".$bmonth."月".$bday."日";
}
}
function IDCheck($e){
$arrVerifyCode = explode(",","1,0,x,9,8,7,6,5,4,3,2");
$Wi = explode(",","7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2");
$Checker = explode(",","1,9,8,7,6,5,4,3,2,1,1");
If(strlen($e) < 15 || strlen($e) == 16 || strlen($e) == 17 || strlen($e) > 18)return false;
if(strlen($e) == 18){
$ai = substr($e, 0, 17);
}elseIf(strlen($e) == 15){
$ai = $e;
$ai = substr($ai, 0,6) & "19" & substr($ai, 6, 9);
}
//If(Not IsNumeric($ai))return false;
$strYear = substr($ai, 7, 4);
$strMonth = substr($ai, 11, 2);
$strDay = substr($ai, 13, 2);
if(checkdate($strMonth,$strDay,$strYear ))return false;
for($i = 0;$i<17;$i++){
$TotalmulAiWi += substr($ai, $i, 1)*$Wi[$i];
}
$modValue = $TotalmulAiWi % 11;
$strVerifyCode = $arrVerifyCode[$modValue];
$ai .= $strVerifyCode;
If(strlen($e) == 18 && $e <> $ai)return false;
return $ai;
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -