$sql = "INSERT INTO `dede_sms`(`phone`,`code`,`created_at`,`expire_at`) VALUES ('$phone','$code','$created_at','$expire_at')";
return $dsql->ExecuteNoneQuery($sql);
}
//检查手机号,验证码
function validateCode($phone,$code)
{
global $dsql;
$code = strtolower($code);
$current = time();
$sql = "SELECT `id` FROM `dede_sms` WHERE `phone` LIKE '$phone' AND `code` LIKE '$code' AND `expire_at` > '$current' ";
$row = $dsql->GetOne($sql);
if(is_array($row)){
return true;
}else{
return false;
}
}
//检查是否发送:防止恶意刷短信
//$phone 手机号 织梦模板下载
//$time 有效时间 (分钟)
function validatePremise($phone,$time = '1')
{
global $dsql;
$row = $dsql->GetOne("SELECT `id`,`expire_at` FROM `dede_sms` WHERE `phone` LIKE '$phone' ");
if(is_array($row)){
if( time() < $row['expire_at'] ){
return false;
}else{
$dsql->ExecuteNoneQuery("DELETE FROM `dede_sms` WHERE id=".$row['id']);
}
}
return true;
}
提示:表的前缀改为你的表前缀,这样就完成了织梦短信接口。