| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- function Post($curlPost, $url)
- {
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, $url);
- curl_setopt($curl, CURLOPT_HEADER, false);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_NOBODY, true);
- curl_setopt($curl, CURLOPT_POST, true);
- curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);
- $return_str = curl_exec($curl);
- curl_close($curl);
- return $return_str;
- }
- function xml_to_array($xml)
- {
- $reg = '/<(\\w+)[^>]*>([\\x00-\\xFF]*)<\\/\\1>/';
- if (preg_match_all($reg, $xml, $matches)) {
- $count = count($matches[0]);
- for ($i = 0; $i < $count; $i++) {
- $subxml = $matches[2][$i];
- $key = $matches[1][$i];
- if (preg_match($reg, $subxml)) {
- $arr[$key] = xml_to_array($subxml);
- }
- else {
- $arr[$key] = $subxml;
- }
- }
- }
- return $arr;
- }
- function msend_sms($sms_user, $sms_pwd, $mobile, $content)
- {
- global $charset;
- $statusStr = array(0 => '短信发送成功', -1 => '参数不全', -2 => '服务器空间不支持,请确认支持curl或者fsocket,联系您的空间商解决或者更换空间!', 30 => '密码错误', 40 => '账号不存在', 41 => '余额不足', 42 => '帐户已过期', 43 => 'IP地址限制', 50 => '内容含有敏感词');
- $smsapi = 'http://api.smsbao.com/';
- $user = $sms_user;
- $pass = md5($sms_pwd);
- $content = rawurlencode($content);
- $phone = $mobile;
- $sendurl = $smsapi . 'sms?u=' . $user . '&p=' . $pass . '&m=' . $phone . '&c=' . $content;
- $result = file_get_contents($sendurl);
- $gets['SubmitResult']['code'] = $result;
- $gets['SubmitResult']['msg'] = $charset == 'gbk' ? iconv('UTF-8', 'GBK', $statusStr[$result]) : $statusStr[$result];
- return $gets;
- }
- function msend_regsms($sms_user, $sms_pwd, $mobile, $yzm, $sms_regtpl = '')
- {
- $content = str_replace('{code}', $yzm, $sms_regtpl);
- $content = str_replace('{mobile}', $mobile, $content);
- $content = $content ? $content : '您的验证码是' . $yzm . '请不要把验证码泄露给其他人。如非本人操作,可不用理会!';
- $status = msend_sms($sms_user, $sms_pwd, $mobile, $content);
- if ($status['SubmitResult']['code'] == 0) {
- }
- write_sms_sendrecord($mobile, $content, $status['SubmitResult']['msg'], 'smsbao');
- }
- function msend_pwdsms($sms_user, $sms_pwd, $mobile, $yzm, $sms_pwdtpl = '')
- {
- $content = str_replace('{code}', $yzm, $sms_pwdtpl);
- $content = str_replace('{mobile}', $mobile, $content);
- $content = $content ? $content : '您的手机号:' . $mobile . ',找回密码验证码:' . $yzm . ',请不要把验证码泄露给其他人。如非本人操作,可不用理会!';
- $status = msend_sms($sms_user, $sms_pwd, $mobile, $content);
- if ($status['SubmitResult']['code'] == 0) {
- }
- write_sms_sendrecord($mobile, $content, $status['SubmitResult']['msg'], 'smsbao');
- }
- ?>
|