//PHP发送短信 Monxin专用(PHP代码函数)//本代码基于Monxin 运行//代码来源:Monxin ./config/functions.php function sms($config,$language,$pdo,$sender,$phone_number,$content){ //demo var_dump(sms(self::$config,self::$la
//PHP发送短信 Monxin专用(PHP代码函数) //本代码基于Monxin 运行 //代码来源:Monxin ./config/functions.php function sms($config,$language,$pdo,$sender,$phone_number,$content){ //demo var_dump(sms(self::$config,self::$language,$pdo,"system","18074507509,15507455992","测试内容,时间".date("H:i:s",time()))); $sender=safe_str($sender); $content=safe_str($content); $arr=explode(',',$config['sms']['disable_phrase']); $disable=false; foreach($arr as $v){ if(strpos($content,$v)!==false){$phrase=$v;$disable=true;continue;} } if($disable){return $language['exist_disable_phrase']." ".$phrase;} $phone_number=explode(',',$phone_number); $phone_number=array_unique($phone_number); $addressee=''; $count=0; foreach($phone_number as $v){ if(preg_match($config['other']['reg_phone'],$v)){$addressee.=$v.',';} } $addressee=trim($addressee,','); $addressee=explode(",",$addressee); //var_dump($addressee); $section=ceil(count($addressee)/$config['sms']['max']); for($i=0;$i<$section;$i++){ $phone[$i]=''; for($j=$i*$config['sms']['max'];$j<($i+1)*$config['sms']['max'];$j++){ //echo $j.','; if(isset($addressee[$j])){$phone[$i].=$addressee[$j].$config['sms']['delimiter'];} } $phone[$i]=trim($phone[$i],$config['sms']['delimiter']); $temp=explode($config['sms']['delimiter'],$phone[$i]); $count=count($temp); $length=ceil(strlen(preg_replace('/[\\x80-\\xff]{3}/','x',$content))/($config['sms']['length']/2)); $count=$length*$count; if(!isset($timing)){$timing=0;} if($phone[$i]!=''){ $time=time(); $sql="insert into ".$pdo->index_pre."phone_msg (`sender`,`addressee`,`content`,`state`,`time`,`count`,`timing`) values ('$sender','".$phone[$i]."','".$content."','1','$time','$count','0')"; if($pdo->exec($sql)){ return send_sms($config,$pdo,$pdo->lastInsertId()); }else{ return false; } } } }