protected function isInt($value , $rule = '' , $date = '' , $field = '')
{
if(is_numeric($value) && is_int($value + 0) && ($value + 0) > 0)
{
return true;
}else{
return $field . '必须是正整数';
}
}
public function checkIDs($value)
{
$value = explode(',',$value);
foreach($value as $v)
{
if(empty($v))
{
return false;
}
if(!$this->isInt($v))
{
return false;
}
}
return true;
}
protected function isMobile($value, $rule = '' , $date = '' , $field = '')
{
$rule = '^1(3|4|5|6|7|8)[0-9]\d{8}$^';
$result = preg_match($rule, $value);
if ($result) {
return true;
} else {
return $field.'手机号格式错误';
}
}
protected function isPassword($value , $rule = '' , $date = '' , $field = '')
{
$rule='/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/';
if(!preg_match($rule,$value))
{
return false;
}
return true;
}
function checkIdentfy($idcard){
if(strlen($idcard)!=18){
return false;
}
$idcard_base = substr($idcard, 0, 17);
$verify_code = substr($idcard, 17, 1);
$factor = array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
$verify_code_list = array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
$total = 0;
for($i=0; $i<17; $i++){
$total += substr($idcard_base, $i, 1)*$factor[$i];
}
$mod = $total % 11;
if($verify_code == $verify_code_list[$mod]){
return true;
}else{
return false;
}
}