destoon系统 接入第三方短信平台

此处接入的平台为互亿无线sms.ihuyi.com 

修改两个文件

第一个:\include\global.func.php

找到方法 function send_sms  修改为


function send_sms($mobile, $mobilecode, $word = 0, $time = 0){  
	$sms_url = 'http://106.ihuyi.cn/webservice/sms.php?method=Submit';//短信接口地址  
	
    global $db, $DT, $DT_TIME, $DT_IP, $_username;  
	//判断是否输入key
    if(!$DT['sms'] || !$DT['sms_uid'] || !$DT['sms_key']) return false;  
	
	//生成短信内容
	//验证码
	$mobile_code=$mobilecode;
	//短信内容
	$mess_info="您的验证码是:".$mobile_code."。请不要把验证码泄露给其他人。如非本人操作,可不用理会!";
	//要提交的信息
	$post_data = "account=".$DT['sms_uid']
				."&password=".$DT['sms_key']
				."&mobile=".$mobile
				."&content=".rawurlencode(convert($mess_info, DT_CHARSET, 'UTF-8'));  
    
	//短信字数统计
    $word or $word = word_count($mess_info);  

  
	//采用PHP的cURL库推送网页  
	$curl = curl_init();
	curl_setopt($curl, CURLOPT_URL, $sms_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, $post_data);
	$return_str = curl_exec($curl);
	curl_close($curl);

	$code='ok';
	//处理返回数据
	/*
	$reg = "/<(\w+)[^>]*>([\\x00-\\xFF]*)<\\/\\1>/";
	if(preg_match_all($reg, $return_str, $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;
			}
		}
	}
	
	if($arr['SubmitResult']['code']==2){
		$code ='ok';  
	}
	else{
		$code = 'Can Not Connect SMS Server';
	}
	*/
	//将短信内容插入数据库保存
	$db->query("INSERT INTO {$db->pre}sms (mobile,message,word,editor,sendtime,code) VALUES ('$mobile','$mess_info','$word','$_username','$DT_TIME','$code')");  
	  
    return $code;      
}  


第二个: \module\member\register.inc.php

找到

if($could_mobilecode) {
	if($action == $action_sendscode) {
		$mobile = isset($value) ? trim($value) : '';
		if(!is_mobile($mobile)) exit('2');
		isset($_SESSION['mobile_send']) or $_SESSION['mobile_send'] = 0;
		if($do->mobile_exists($mobile)) exit('3');
		if($_SESSION['mobile_time'] && $DT_TIME - $_SESSION['mobile_time'] < 180) exit('5');
		if($_SESSION['mobile_send'] > 4) exit('6');

		$mobilecode = random(6, '0123456789');
		$_SESSION['mobile'] = $mobile;
		$_SESSION['mobile_code'] = md5($mobile.'|'.$mobilecode);
		$_SESSION['mobile_time'] = $DT_TIME;
		$_SESSION['mobile_send'] = $_SESSION['mobile_send'] + 1;

		$content = lang('sms->sms_code', array($mobilecode, $MOD['auth_days'])).$DT['sms_sign'];
		send_sms($mobile, $content);
		exit('1');
	}
}

修改为

if($could_mobilecode) {
	if($action == $action_sendscode) {
		$mobile = isset($value) ? trim($value) : '';
		if(!is_mobile($mobile)) exit('2');
		isset($_SESSION['mobile_send']) or $_SESSION['mobile_send'] = 0;
		if($do->mobile_exists($mobile)) exit('3');
		if($_SESSION['mobile_time'] && $DT_TIME - $_SESSION['mobile_time'] < 180) exit('5');
		if($_SESSION['mobile_send'] > 4) exit('6');

		$mobilecode = rand(100000,999999);
		$_SESSION['mobile'] = $mobile;
		$_SESSION['mobile_code'] = md5($mobile.'|'.$mobilecode);
		$_SESSION['mobile_time'] = $DT_TIME;
		$_SESSION['mobile_send'] = $_SESSION['mobile_send'] + 1;

		//$content = lang('sms->sms_code', array($mobilecode, $MOD['auth_days'])).$DT['sms_sign'];
		send_sms($mobile, $mobilecode);
		exit('1');
	}
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

咸鱼传奇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值