phpyun人才系统在招聘人才系统中也是佼佼者,最近小编知道了php云人才系统更新到6.2版本了,之前的短信插件也无法使用了,小编也整理了一下,下面带着大家一起进行新版本的替换。我们使用的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信平台十分稳定,发送速度快,注册就送测试短信,推荐大家使用。
1:打开项目:app\template\admin\admin_msg_config.htm 修改48行左右 新增短信宝相关配置
1
2
3
4
5
6
7
8
9
10
11
12
|
<tr> <th width= "220" >短信宝账号:</th> <td><input class= "tty_input t_w250" type= "text" name= "sy_msg_appkey" id= "sy_msg_appkey" value= "{yun:}$config.sy_msg_appkey{/yun}" size= "30" /> </tr> <tr class= "admin_table_trbg" > <th width= "220" >短信宝密码:</th> <td><input class= "tty_input t_w250" type= "text" name= "sy_msg_appsecret" id= "sy_msg_appsecret" value= "{yun:}$config.sy_msg_appsecret{/yun}" size= "50" /> </tr> <tr> <th width= "220" >短信宝签名:</th> <td><input class= "tty_input t_w250" type= "text" name= "sy_msg_appsing" id= "sy_msg_appsing" value= "{yun:}$config.sy_msg_appsing{/yun}" size= "50" /> </tr> |
2:打开当前项目:admin_msg_config.htm修改js内容 增加短信签名和获取短信余额方法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
<script> layui.use([ 'layer' , 'form' ], function () { var layer = layui.layer , form = layui.form , $ = layui.$; }); $( function () { $( "#config" ).click( function () { var msgtime = $( "#moblie_codetime" ).val(); if (parseInt(msgtime) < 2) { parent.layer.msg( '短信验证时效因大于两分钟!' , 2, 8); return false ; } else { loadlayer(); $.post( "index.php?m=msgconfig&c=save" , { config: $( "#config" ).val(), sy_msg_isopen: $( "input[name=sy_msg_isopen]:checked" ).val(), sy_msg_appkey: $( "#sy_msg_appkey" ).val(), sy_msg_appsecret: $( "#sy_msg_appsecret" ).val(), sy_msg_appsing : $( "#sy_msg_appsing" ).val(), sy_kh_isopen: $( "input[name=sy_kh_isopen]:checked" ).val(), sy_kh_appkey: $( "#sy_kh_appkey" ).val(), sy_kh_appsecret: $( "#sy_kh_appsecret" ).val(), sy_kh_city: $( "#sy_kh_city" ).val(), sy_tyc_appkey: $( "#sy_tyc_appkey" ).val(), sy_tyc_appsecret: $( "#sy_tyc_appsecret" ).val(), pytoken: $( "#pytoken" ).val(), sy_msgsendnum: $( "#sy_msgsendnum" ).val(), ip_msgnum: $( "#ip_msgnum" ).val(), moblie_msgnum: $( "#moblie_msgnum" ).val(), cert_msgtime: $( "#cert_msgtime" ).val(), moblie_codetime: $( "#moblie_codetime" ).val(), integral_msg_proportion: $( "#integral_msg_proportion" ).val() }, function (data, textStatus) { parent.layer.closeAll( 'loading' ); config_msg(data); }); } }); $.post( "index.php?m=msgconfig&c=get_restnums" ,{pytoken : $( "#pytoken" ).val(),msguser : $( "#sy_msguser" ).val()}, function (data){ data = eval( '(' +data+ ')' ); if (data){ if (data){ $( "#rest_msgnum" ).val(data); } else { $( "#rest_msgnum" ).val(0); } $( "#rest_khnum" ).val(data.khnum); $( "#rest_businessnum" ).val(data.businessnum); } }); }) </script> |
3:打开项目:app\model\notice.model.php 修改 postSMS和sendSMS两个方法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
public function sendSMS($data){ if (!checkMsgOpen($ this -> config)){ return array( 'status' => -1, 'msg' => '还没有配置短信,请联系管理员!' ); } $data[ 'mobile' ] = $data[ 'moblie' ] ? $data[ 'moblie' ] : $data[ 'mobile' ]; if ($ this ->_isKey( 'mobile' , $data) == false || CheckMoblie($data[ 'mobile' ]) == false ){ return array( 'status' => -1, 'msg' => '手机号错误' ); } if ($ this ->config[ 'sy_web_mobile' ]!= '' ){ $regnamer=@explode( ';' ,$ this ->config[ 'sy_web_mobile' ]); if (in_array($data[ 'mobile' ],$regnamer)){ return array( 'status' => -1, 'msg' => '该手机号已被禁止使用' ); } } if ($ this ->_isKey( 'content' , $data) == false || $data[ 'content' ] == '' ){ return array( 'status' => -1, 'msg' => '短信内容为空' ); } //发送短信 $row = array( 'appsecret' => $ this ->config[ 'sy_msg_appsecret' ], 'appkey' => $ this ->config[ 'sy_msg_appkey' ], 'appsing' => $ this ->config[ 'sy_msg_appsing' ], 'phone' => $data[ 'mobile' ], 'content' => $data[ 'content' ], 'mid' => $data[ 'mid' ] ? $data[ 'mid' ] : '' ); $location = '' ; $re= $ this ->postSMS( 'msgsend' ,$row); //短信记录保存数据库 $sql_data = array( 'uid' => $data[ 'uid' ], 'cuid' => $data[ 'cuid' ] ? $data[ 'cuid' ] : 0, 'moblie' => $data[ 'mobile' ], 'ctime' => time(), 'content' => $data[ 'content' ], 'port' => $data[ 'port' ], 'location' => $location ); if (trim($re) == '0' ){ //检查是否需要发送系统预警 include_once( 'warning.model.php' ); $warning = new warning_model($ this ->db,$ this ->def); $warning -> warning(5); $sql_data[ 'state' ] = 0; $sql_data[ 'ip' ] = fun_ip_get(); $sqlResult = $ this -> insert_into( 'moblie_msg' ,$sql_data); return array( 'status' => 1, 'msg' => '发送成功!' ); } else { $sql_data[ 'state' ] = $re[ 'code' ]; $ this -> insert_into( 'moblie_msg' ,$sql_data); return array( 'status' => -1, 'msg' => '发送失败!状态:' .$re[ 'code' ]. "," . $re[ 'message' ]); } } private function postSMS($type= "msgsend" ,$data= '' ){ $sing = $ this ->config[ 'sy_msg_appsing' ]; $data[ 'content' ] = str_replace(array( " " , " " , "\t" , "\n" , "\r" ),array( "" , "" , "" , "" , "" ),$data[ 'content' ]); $url.= '?u=' .$data[ 'appkey' ]. '&p=' .md5($data[ 'appsecret' ]). '&m=' .$data[ 'phone' ]. '&c=【' .$sing. '】' .$data[ 'content' ]; if (function_exists( 'file_get_contents' )){ $file_contents = file_get_contents($url); } else { $ch = curl_init(); $timeout = 5; curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); } return $file_contents; } |
4:打开项目:admin\model\msgconfig.class.php 新增获取短信余额方法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
function get_restnums_action(){ $user = trim($ this ->config[ 'sy_msg_appkey' ]); $pass = trim($ this ->config[ 'sy_msg_appsecret' ]); $url.= '?u=' .$user. '&p=' .md5($pass); if (function_exists( 'file_get_contents' )){ $file_contents = file_get_contents($url); } else { $ch = curl_init(); $timeout = 5; curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); } $result = explode( "," , $file_contents); echo $result[ '1' ]; } |
经过上面的替换,短信宝的短信平台已经替换成功了,可以正常使用了。进行测试发送:
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的phpyun6.2系统短信宝插件,点击此链接 下载及查看安装流
最新更新
电商类
CMS类
微信类