[公告] 今天的程式
<?php
class applicationItemConnectCheckClass {
//*********************************//////
// 檢查出生日期是否輸入正確
//*********************************//////
function Birthday_Is_Accept_OK($strAcceptBirthday) {
if (strlen ($strAcceptBirthday) != 10)
return FALSE ;
if ((substr ($strAcceptBirthday,4,1) != "/") ||
(substr ($strAcceptBirthday,7,1) != "/") )
return FALSE ;
$intYearValues =(int)substr ($strAcceptBirthday,0,4) ;
$intMontValues =(int)substr ($strAcceptBirthday,5,2) ;
$intDaysValues =(int)substr ($strAcceptBirthday,8,2) ;
if (($intYearValues < 1880) || ($intYearValues > 2290))
return FALSE ;
if (($intMontValues < 1) || ($intMontValues > 12))
return FALSE ;
if ($intMontValues = 1) || ($intMontValues = 3)||($intMontValues =
5)||($intMontValues = 7) ||($intMontValues = 8) ||||($intMontValues = 10)
||($intMontValues = 12)
{if (($intDaysValues < 1) || ($intDaysValues > 31))
return FALSE ;
} else
{if (($intDaysValues < 1) || ($intDaysValues > 30)
return FALSE;
}
if ($intMontValues = 2 && $intYearValues % 4 = 0)
{if (($intDaysValues < 1) || ($intDaysValues > 29))
return FALSE ;
}
if ($intMontValues = 2 && $intYearValues % 4 != 0)
{if (($intDaysValues < 1) || ($intDaysValues > 28))
return FALSE ;
}
return TRUE ;
}
//*********************************//////
// 檢查身分證號碼是否輸入正確
//*********************************//////
function IDCheckConnect ($strPassChkIDNO) {
$strFirstArray = array(
"A"=>10,"B"=>11,"C"=>12,"D"=>13,"E"=>14,"F"=>15,
"G"=>16,"H"=>17,"J"=>18,"K"=>19,"L"=>20,"M"=>21,
"N"=>22,"P"=>23,"Q"=>24,"R"=>25,"S"=>26,"T"=>27,
"U"=>28,"V"=>29,"X"=>30,"Y"=>31,"I"=>34,"O"=>35) ;
$strFirstChar = substr ($strPassChkIDNO,0,1) ;
if (strlen ($strPassChkIDNO) != 10)
return FALSE ;
if (($strFirstChar < "A") || ($strFirstChar > "Z"))
return FALSE ;
for ($i=1; $i<=9;$i++)
{
if((int)substr ($strPassChkIDNO,$i,1) < 0) ||((int)substr
($strPassChkIDNO,$i,1) > 9)
return FALSE;
}
$strSecondChar = substr ($strPassChkIDNO,1,1) ;
if (((int)$strSecondChar != 1) && ((int)$strSecondChar != 2))
return FALSE ;
//************************************////////
$intValueGo = 0 ;
$strString = (string)$strFirstArray [$strFirstChar] ;
//************************************////////
$intValueGo = (int)substr ($strString,0,1) * 1 +
(int)substr ($strString,1,1) * 9 +
(int)substr ($strPassChkIDNO,1,1) * 8 +
(int)substr ($strPassChkIDNO,2,1) * 7 +
(int)substr ($strPassChkIDNO,3,1) * 6 +
(int)substr ($strPassChkIDNO,4,1) * 5 +
(int)substr ($strPassChkIDNO,5,1) * 4 +
(int)substr ($strPassChkIDNO,6,1) * 3 +
(int)substr ($strPassChkIDNO,7,1) * 2 +
(int)substr ($strPassChkIDNO,8,1) * 1 ;
$intValueGo = $intValueGo % 10 ;
$intValueGo = 10 - $intValueGo ;
$intChkVal = (int)substr ($strPassChkIDNO,9,1) ;
if ($intValueGo == $intChkVal)
return TRUE ;
else
return FALSE ;
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.128.142.226