mymps.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. function Post($curlPost, $url)
  3. {
  4. $curl = curl_init();
  5. curl_setopt($curl, CURLOPT_URL, $url);
  6. curl_setopt($curl, CURLOPT_HEADER, false);
  7. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  8. curl_setopt($curl, CURLOPT_NOBODY, true);
  9. curl_setopt($curl, CURLOPT_POST, true);
  10. curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);
  11. $return_str = curl_exec($curl);
  12. curl_close($curl);
  13. return $return_str;
  14. }
  15. function xml_to_array($xml)
  16. {
  17. $reg = '/<(\\w+)[^>]*>([\\x00-\\xFF]*)<\\/\\1>/';
  18. if (preg_match_all($reg, $xml, $matches)) {
  19. $count = count($matches[0]);
  20. for ($i = 0; $i < $count; $i++) {
  21. $subxml = $matches[2][$i];
  22. $key = $matches[1][$i];
  23. if (preg_match($reg, $subxml)) {
  24. $arr[$key] = xml_to_array($subxml);
  25. }
  26. else {
  27. $arr[$key] = $subxml;
  28. }
  29. }
  30. }
  31. return $arr;
  32. }
  33. function msend_sms($sms_user, $sms_pwd, $mobile, $content)
  34. {
  35. global $charset;
  36. $content = rawurlencode($content);
  37. $target = 'http://120.55.205.5/webservice/sms.php?method=Submit';
  38. $post_data = 'account=' . $sms_user . '&password=' . $sms_pwd . '&mobile=' . $mobile . '&content=' . $content;
  39. $gets = xml_to_array(post($post_data, $target));
  40. if ($charset == 'gbk') {
  41. $gets['SubmitResult']['msg'] = iconv('UTF-8', 'GBK', $gets['SubmitResult']['msg']);
  42. }
  43. return $gets;
  44. }
  45. function msend_regsms($sms_user, $sms_pwd, $mobile, $yzm, $sms_regtpl = '')
  46. {
  47. $content = str_replace('{code}', $yzm, $sms_regtpl);
  48. $content = str_replace('{mobile}', $mobile, $content);
  49. $content = $content ? $content : '您的验证码是:【' . $yzm . '】。请不要把验证码泄露给其他人。如非本人操作,可不用理会!';
  50. $status = msend_sms($sms_user, $sms_pwd, $mobile, $content);
  51. if ($status['SubmitResult']['code'] == 2) {
  52. }
  53. write_sms_sendrecord($mobile, $content, $status['SubmitResult']['msg'], 'ihuyi');
  54. }
  55. function msend_pwdsms($sms_user, $sms_pwd, $mobile, $yzm, $sms_pwdtpl = '')
  56. {
  57. $content = str_replace('{code}', $yzm, $sms_pwdtpl);
  58. $content = str_replace('{mobile}', $mobile, $content);
  59. $content = $content ? $content : '您的手机号:【' . $mobile . '】,找回密码验证码:【' . $yzm . '】,请不要把验证码泄露给其他人。如非本人操作,可不用理会!';
  60. $status = msend_sms($sms_user, $sms_pwd, $mobile, $content);
  61. if ($status['SubmitResult']['code'] == 2) {
  62. }
  63. write_sms_sendrecord($mobile, $content, $status['SubmitResult']['msg'], 'ihuyi');
  64. }
  65. ?>