global.func.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. function sms_status($status = 0,$return_array = 0) {
  3. $array = array(
  4. '0'=>'发送成功',
  5. '1'=>'手机号码非法',
  6. '2'=>'用户存在于黑名单列表',
  7. '3'=>'接入用户名或密码错误',
  8. '4'=>'产品代码不存在',
  9. '5'=>'IP非法',
  10. '6 '=>'源号码错误',
  11. '7'=>'调用网关错误',
  12. '8'=>'消息长度超过60',
  13. '9'=>'发送短信内容参数为空',
  14. '10'=>'用户已主动暂停该业务',
  15. '11'=>'wap链接地址或域名非法',
  16. '12'=>'5分钟内给同一个号码发送短信超过10条',
  17. '13'=>'短信模版ID为空',
  18. '14'=>'禁止发送该消息',
  19. '-1'=>'每分钟发给该手机号的短信数不能超过3条',
  20. '-2'=>'手机号码错误',
  21. '-11'=>'帐号验证失败',
  22. '-10'=>'接口没有返回结果',
  23. );
  24. return $return_array ? $array : $array[$status];
  25. }
  26. function checkmobile($mobilephone) {
  27. $mobilephone = trim($mobilephone);
  28. if(preg_match("/^13[0-9]{1}[0-9]{8}$|15[01236789]{1}[0-9]{8}$|18[01236789]{1}[0-9]{8}$/",$mobilephone)){
  29. return $mobilephone;
  30. } else {
  31. return false;
  32. }
  33. }
  34. function get_smsnotice($type = '') {
  35. $url = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
  36. $urls = base64_decode('aHR0cDovL3Ntcy5waHBpcC5jb20vYXBpLnBocD9vcD1zbXNub3RpY2UmdXJsPQ==').$url."&type=".$type;
  37. $content = pc_file_get_contents($urls,5);
  38. if($content) {
  39. $content = json_decode($content,true);
  40. if($content['status']==1) {
  41. return strtolower(CHARSET)=='gbk' ?iconv('utf-8','gbk',$content['msg']) : $content['msg'];
  42. }
  43. }
  44. $urls = base64_decode('aHR0cDovL3Ntcy5waHBjbXMuY24vYXBpLnBocD9vcD1zbXNub3RpY2UmdXJsPQ==').$url."&type=".$type;
  45. $content = pc_file_get_contents($urls,3);
  46. if($content) {
  47. $content = json_decode($content,true);
  48. if($content['status']==1) {
  49. return strtolower(CHARSET)=='gbk' ?iconv('utf-8','gbk',$content['msg']) : $content['msg'];
  50. }
  51. }
  52. return '<font color="red">短信通服务器无法访问!您将无法使用短信通服务!</font>';
  53. }
  54. function sendsms($mobile, $send_txt, $tplid = 1, $id_code = '', $siteid=1) {
  55. pc_base::load_app_class('smsapi', 'sms', 0); //引入smsapi类
  56. $sms_setting = getcache('sms','sms');
  57. $sms_uid = $sms_setting[$siteid]['userid'];//短信接口用户ID
  58. $sms_pid = $sms_setting[$siteid]['productid'];//产品ID
  59. $sms_passwd = $sms_setting[$siteid]['sms_key'];//32位密码
  60. $smsapi = new smsapi($sms_uid, $sms_pid, $sms_passwd); //初始化接口类
  61. $mobile = explode(',',$mobile);
  62. $code = $smsapi->send_sms($mobile, $send_txt, 0, CHARSET,$id_code,$tplid,1); //发送短信
  63. if($code==0) {
  64. return 0;
  65. } else {
  66. return sms_status($code,1);
  67. }
  68. }