PbootCMS是全新內核且永久開源免費的PHP企業網站開發建設管理系統,是一套高效、簡潔、 強悍的可免費商用的PHP CMS源碼,能夠滿足各類企業網站開發建設的需要。系統采用簡單到想哭的模板標簽,只要懂HTML就可快速開發企業網站。小編對他還是比較了解的,今天小編就以新增短信接口為例,給大家講解一下如何進行二次開發,我們今天講解的是v3.1.2版本,使用的短信接口是我們短信寶短信群發平臺的短信接口,我們短信寶短信群發平臺的接口非常穩定,發送速度快,注冊就送測試短信,推薦大家使用
1:打開項目:\apps\admin\view\default\system\config.html 新增短信寶頁面
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
|
<div?class= "layui-tab-item" > ???????????????? <form?action= "{url./admin/Config/index}" ?method= "post" ?class= "layui-form" > ???????????????????? <input?type= "hidden" ?name= "formcheck" ?value= "{$formcheck}" ?> ???????????????????? <div?class= "layui-form-item" > ???????????????????????? <label?class= "layui-form-label" >是否開啟</label> ???????????????????????? <div?class= "layui-input-block" > ???????????????????????????? <input?type= "radio" ?name= "sms_status" ?value= "1" ?{ if ([$configs.sms_status.value]==1)}?checked= "checked" ?{/ if }?title= "是" > ???????????????????????????? <input?type= "radio" ?name= "sms_status" ?value= "0" ?{ if ([$configs.sms_status.value]==0)}?checked= "checked" ?{/ if }?title= "否" > ???????????????????????? </div> ???????????????????? </div> ???????????????????? <div?class= "layui-form-item" > ???????????????????????? <label?class= "layui-form-label" >短信寶賬號</label> ???????????????????????? <div?class= "layui-input-inline" > ???????????????????????????? <input?type= "text" ?name= "sms_account" ??value= "{$configs.sms_account.value}" ?placeholder= "請輸入短信寶賬號" ?class= "layui-input" > ???????????????????????? </div> ???????????????????? </div> ???????????????????? <div?class= "layui-form-item" > ???????????????????????? <label?class= "layui-form-label" >短信寶密碼</label> ???????????????????????? <div?class= "layui-input-inline" > ???????????????????????????? <input?type= "password" ?name= "sms_pwd" ?value= "{$configs.sms_pwd.value}" ?placeholder= "請輸入短信寶密碼" ?class= "layui-input" > ???????????????????????? </div> ???????????????????? </div> ???????????????????? <div?class= "layui-form-item" > ???????????????????????? <label?class= "layui-form-label" >短信寶簽名</label> ???????????????????????? <div?class= "layui-input-inline" > ???????????????????????????? <input?type= "text" ?name= "sms_signid" ??value= "{$configs.sms_signid.value}" ?placeholder= "請輸入短信寶簽名" ?class= "layui-input" > ???????????????????????? </div> ???????????????????? </div> ???????????????????? <div?class= "layui-form-item" > ???????????????????????? <label?class= "layui-form-label" >留言發送短信</label> ???????????????????????? <div?class= "layui-input-block" > ???????????????????????????? <input?type= "radio" ?name= "message_send_sms" ?value= "1" ?{ if ([$configs.message_send_sms.value]==1)}?checked= "checked" ?{/ if }?title= "啟用" > ???????????????????????????? <input?type= "radio" ?name= "message_send_sms" ?value= "0" ?{ if ([$configs.message_send_sms.value]==0)}?checked= "checked" ?{/ if }?title= "禁用" > ???????????????????????? </div> ???????????????????? </div> ???????????????????? <div?class= "layui-form-item" > ???????????????????????? <label?class= "layui-form-label" >表單發送短信</label> ???????????????????????? <div?class= "layui-input-block" > ???????????????????????????? <input?type= "radio" ?name= "form_send_sms" ?value= "1" ?{ if ([$configs.form_send_sms.value]==1)}?checked= "checked" ?{/ if }?title= "啟用" > ???????????????????????????? <input?type= "radio" ?name= "form_send_sms" ?value= "0" ?{ if ([$configs.form_send_sms.value]==0)}?checked= "checked" ?{/ if }?title= "禁用" > ???????????????????????? </div> ???????????????????? </div> ???????????????????? <div?class= "layui-form-item" > ???????????????????????? <label?class= "layui-form-label" >評論發送短信</label> ???????????????????????? <div?class= "layui-input-block" > ???????????????????????????? <input?type= "radio" ?name= "comment_send_sms" ?value= "1" ?{ if ([$configs.comment_send_sms.value]==1)}?checked= "checked" ?{/ if }?title= "啟用" > ???????????????????????????? <input?type= "radio" ?name= "comment_send_sms" ?value= "0" ?{ if ([$configs.comment_send_sms.value]==0)}?checked= "checked" ?{/ if }?title= "禁用" > ???????????????????????? </div> ???????????????????? </div> ???????????????????? <div?class= "layui-form-item" > ???????????????????????? <label?class= "layui-form-label" >信息接收手機號</label> ???????????????????????? <div?class= "layui-input-inline" > ???????????????????????????? <input?type= "text" ?name= "sms_send_to" ??value= "{$configs.sms_send_to.value}" ?placeholder= "請輸入信息接收手機號" ??class= "layui-input" > ???????????????????????? </div> ???????????????????? </div> ???????????????????? <div?class= "layui-form-item" > ???????????????????????? <div?class= "layui-input-block" > ???????????????????????????? <button?class= "layui-btn" ?lay-submit?name= "submit" ?value= "sms" >立即提交</button> ???????????????????????????? <button?type= "reset" ?class= "layui-btn?layui-btn-primary" >重置</button> ???????????????????????? </div> ???????????????????? </div> ???????????????? </form> ???????????? </div> |
2:打開項目:apps\home\controller\CommentController.php 修改評論短信發送
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
86
87
88
|
public? function ?add() ???? { ???????? if ?($_POST)?{ ???????????? ???????????? if ?($ this ->config( 'comment_status' )?===? '0' )?{ ???????????????? error( '系統已經關閉評論功能,請到后臺開啟再試!' ); ???????????? } ???????????? ???????????? if ?(time()?-?session( 'lastsub' )?<?10)?{ ???????????????? alert_back( '您提交太頻繁了,請稍后再試!' ); ???????????? } ???????????? ???????????? if ?(!?session( 'pboot_uid' )?&&?!?$ this ->config( 'comment_anonymous' ))?{ ???????????????? if ?(!?!?$backurl?=?$_SERVER[ 'HTTP_REFERER' ])?{ ???????????????????? alert_location( "請先注冊登錄后再評論!" ,?Url::home( 'member/login' ,? null ,? "backurl=" ?.?urlencode($backurl))); ???????????????? }? else ?{ ???????????????????? alert_location( "請先注冊登錄后再評論!" ,?Url::home( 'member/login' )); ???????????????? } ???????????? } ???????????? ???????????? //?驗證碼驗證 ???????????? $checkcode?=?strtolower(post( 'checkcode' ,? 'var' )); ???????????? if ?($ this ->config( 'comment_check_code' )?!==? '0' )?{ ???????????????? if ?(!?$checkcode)?{ ???????????????????? alert_back( '驗證碼不能為空!' ); ???????????????? } ???????????????? ???????????????? if ?($checkcode?!=?session( 'checkcode' ))?{ ???????????????????? alert_back( '驗證碼錯誤!' ); ???????????????? } ???????????? } ???????????? ???????????? //?接收數據 ???????????? ???????????? $status?=?$ this ->config( 'comment_verify' )?===? '0' ???1?:?0; ???????????? if ?(!?$contentid?=?request( 'contentid' ,? 'int' ))?{ ???????????????? alert_back( '文章ID未能正常獲取,請使用POST或URL參數傳遞!' ); ???????????? } ???????????? ???????????? $comment?=?post( 'comment' ); ???????????? ???????????? $data?=?array( ???????????????? 'pid' ?=>?request( 'pid' ,? 'int' )??:?0, ???????????????? 'contentid' ?=>?$contentid, ???????????????? 'comment' ?=>?$comment, ???????????????? 'uid' ?=>?session( 'pboot_uid' ), ???????????????? 'puid' ?=>?request( 'puid' ,? 'int' ), ???????????????? 'likes' ?=>?0, ???????????????? 'oppose' ?=>?0, ???????????????? 'status' ?=>?$status, ???????????????? 'user_ip' ?=>?ip2long(get_user_ip()), ???????????????? 'user_os' ?=>?get_user_os(), ???????????????? 'user_bs' ?=>?get_user_bs(), ???????????????? 'create_time' ?=>?get_datetime(), ???????????????? 'update_user' ?=>? '' , ???????????????? 'update_time' ?=>? '' ???????????? ); ???????????? ???????????? if ?($ this ->model->addComment($data))?{ ???????????????? session( 'lastsub' ,?time());? //?記錄最后提交時間 ???????????????? $ this ->log( '文章' ?.?$contentid?.? '評論提交成功!' ); ???????????????? if ?($ this ->config( 'sms_status' ))?{ ???????????????????? if ?($ this ->config( 'comment_send_sms' )?&&?$ this ->config( 'sms_send_to' ))?{ ???????????????????????? $sms_subject?=? "您有新的文章評論信息,請注意查收!" ; ???????????????????????? sendsms($ this ->config(),?$ this ->config( 'sms_send_to' ),?$sms_subject); ???????????????????? } ???????????????? } else { ???????????????????? if ?($ this ->config( 'comment_send_mail' )?&&?$ this ->config( 'message_send_to' ))?{ ???????????????????????? $mail_subject?=? "【" ?.?CMSNAME?.? "】您有新的文章評論信息,請注意查收!" ; ???????????????????????? $mail_body?=? '評論內容:' ?.?$comment?.? '<br>' ; ???????????????????????? $mail_body?.=? '<br>來自網站?' ?.?get_http_url()?.? '?(' ?.?date( 'Y-m-d?H:i:s' )?.? ')' ; ???????????????????????? sendmail($ this ->config(),?$ this ->config( 'message_send_to' ),?$mail_subject,?$mail_body); ???????????????????? } ???????????????? } ???????????????? if ?($status)?{ ???????????????????? alert_location( '評論提交成功!' ,? '-1' ,?1); ???????????????? }? else ?{ ???????????????????? alert_location( '評論提交成功,請等待管理員審核!' ,? '-1' ,?1); ???????????????? } ???????????? }? else ?{ ???????????????? $ this ->log( '文章評論提交失?。? ); ???????????????? alert_back( '提交失敗!' ); ???????????? } ???????? }? else ?{ ???????????? alert_back( '提交失敗,請使用POST方式提交!' ); ???????? } ???? } |
3:打開項目:\apps\home\controller\FormController.php 修改表單短信發送
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
86
87
|
? public? function ?index() ???? { ???????? //?在非兼容模式接受地址第二參數值 ???????? if ?(defined( 'RVAR' ))?{ ???????????? $_GET[ 'fcode' ]?=?RVAR; ???????? } ???????? ???????? if ?($_POST)?{ ???????????? ???????????? if ?($ this ->config( 'form_status' )?===? '0' )?{ ???????????????? error( '系統已經關閉表單功能,請到后臺開啟再試!' ); ???????????? } ???????????? ???????????? if ?(time()?-?session( 'lastsub' )?<?10)?{ ???????????????? alert_back( '您提交太頻繁了,請稍后再試!' ); ???????????? } ???????????? ???????????? if ?(!?$fcode?=?get( 'fcode' ,? 'var' ))?{ ???????????????? alert_back( '傳遞的表單編碼有誤!' ); ???????????? } ???????????? ???????????? if ?($fcode?==?1)?{ ???????????????? alert_back( '表單提交地址有誤,留言提交請使用留言專用地址!' ); ???????????? } ???????????? ???????????? //?驗證碼驗證 ???????????? $checkcode?=?strtolower(post( 'checkcode' ,? 'var' )); ???????????? if ?($ this ->config( 'form_check_code' )?!==? '0' )?{ ???????????????? if ?(!?$checkcode)?{ ???????????????????? alert_back( '驗證碼不能為空!' ); ???????????????? } ???????????????? if ?($checkcode?!=?session( 'checkcode' ))?{ ???????????????????? alert_back( '驗證碼錯誤!' ); ???????????????? } ???????????? } ???????????? ???????????? //?讀取字段 ???????????? if ?(!?$form?=?$ this ->model->getFormField($fcode))?{ ???????????????? alert_back( '接收表單不存在任何字段,請核對后重試!' ); ???????????? } ???????????? ???????????? //?接收數據 ???????????? $mail_body?=? '' ; ???????????? foreach?($form?as?$value)?{ ???????????????? $field_data?=?post($value->name); ???????????????? if ?(is_array($field_data))?{? //?如果是多選等情況時轉換 ???????????????????? $field_data?=?implode( ',' ,?$field_data); ???????????????? } ???????????????? $field_data?=?preg_replace_r( '/pboot:if/i' ,? '' ,?$field_data); ???????????????? if ?($value->required?&&?!?$field_data)?{ ???????????????????? alert_back($value->description?.? '不能為空!' ); ???????????????? }? else ?{ ???????????????????? $data[$value->name]?=?$field_data; ???????????????????? $mail_body?.=?$value->description?.? ':' ?.?$field_data?.? '<br>' ; ???????????????? } ???????????? } ???????????? ???????????? //?設置創建時間 ???????????? if ?($data)?{ ???????????????? $data[ 'create_time' ]?=?get_datetime(); ???????????? } ???????????? ???????????? //?寫入數據 ???????????? if ?($ this ->model->addForm($value->table_name,?$data))?{ ???????????????? session( 'lastsub' ,?time());? //?記錄最后提交時間 ???????????????? $ this ->log( '提交表單數據成功!' ); ???????????????? if ?($ this ->config( 'sms_status' ))?{ ???????????????????? if ?($ this ->config( 'form_send_sms' )?&&?$ this ->config( 'sms_send_to' ))?{ ???????????????????????? $sms_subject?=? "您有新的" ?.?$value->form_name?.? "信息,請注意查收!" ; ???????????????????????? sendsms($ this ->config(),?$ this ->config( 'sms_send_to' ),?$sms_subject); ???????????????????? } ???????????????? } else { ???????????????????? if ?($ this ->config( 'form_send_mail' )?&&?$ this ->config( 'message_send_to' ))?{ ???????????????????????? $mail_subject?=? "【" ?.?CMSNAME?.? "】您有新的" ?.?$value->form_name?.? "信息,請注意查收!" ; ???????????????????????? $mail_body?.=? '<br>來自網站' ?.?get_http_url()?.? '(' ?.?date( 'Y-m-d?H:i:s' )?.? ')' ; ???????????????????????? sendmail($ this ->config(),?$ this ->config( 'message_send_to' ),?$mail_subject,?$mail_body); ???????????????????? } ???????????????? } ???????????????? alert_location( '提交成功!' ,? '-1' ,?1); ???????????? }? else ?{ ???????????????? $ this ->log( '提交表單數據失??!' ); ???????????????? alert_back( '提交失??!' ); ???????????? } ???????? }? else ?{ ???????????? alert_back( '提交失敗,請使用POST方式提交!' ); ???????? } ???? } |
4:打開項目:apps\home\controller\MessageController.php 修改留言短信發送
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
86
87
88
89
90
91
92
93
|
public? function ?index() ???? { ???????? if ?($_POST)?{ ???????????? ???????????? if ?($ this ->config( 'message_status' )?===? '0' )?{ ???????????????? error( '系統已經關閉留言功能,請到后臺開啟再試!' ); ???????????? } ???????????? ???????????? if ?(time()?-?session( 'lastsub' )?<?10)?{ ???????????????? alert_back( '您提交太頻繁了,請稍后再試!' ); ???????????? } ???????????? ???????????? //?需登錄 ???????????? if ?($ this ->config( 'message_rqlogin' )?&&?!?session( 'pboot_uid' ))?{ ???????????????? if ?(!?!?$backurl?=?$_SERVER[ 'HTTP_REFERER' ])?{ ???????????????????? alert_location( "請先注冊登錄后再留言!" ,?Url::home( 'member/login' ,? null ,? "backurl=" ?.?urlencode($backurl))); ???????????????? }? else ?{ ???????????????????? alert_location( "請先注冊登錄后再留言!" ,?Url::home( 'member/login' )); ???????????????? } ???????????? } ???????????? ???????????? //?驗證碼驗證 ???????????? $checkcode?=?strtolower(post( 'checkcode' ,? 'var' )); ???????????? if ?($ this ->config( 'message_check_code' )?!==? '0' )?{ ???????????????? if ?(!?$checkcode)?{ ???????????????????? alert_back( '驗證碼不能為空!' ); ???????????????? } ???????????????? ???????????????? if ?($checkcode?!=?session( 'checkcode' ))?{ ???????????????????? alert_back( '驗證碼錯誤!' ); ???????????????? } ???????????? } ???????????? ???????????? //?讀取字段 ???????????? if ?(!?$form?=?$ this ->model->getFormField(1))?{ ???????????????? alert_back( '留言表單不存在任何字段,請核對后重試!' ); ???????????? } ???????????? ???????????? //?接收數據 ???????????? $mail_body?=? '' ; ???????????? foreach?($form?as?$value)?{ ???????????????? $field_data?=?post($value->name); ???????????????? if ?(is_array($field_data))?{? //?如果是多選等情況時轉換 ???????????????????? $field_data?=?implode( ',' ,?$field_data); ???????????????? } ???????????????? $field_data?=?preg_replace_r( '/pboot:if/i' ,? '' ,?$field_data); ???????????????? if ?($value->required?&&?!?$field_data)?{ ???????????????????? alert_back($value->description?.? '不能為空!' ); ???????????????? }? else ?{ ???????????????????? $data[$value->name]?=?$field_data; ???????????????????? $mail_body?.=?$value->description?.? ':' ?.?$field_data?.? '<br>' ; ???????????????? } ???????????? } ???????????? ???????????? $status?=?$ this ->config( 'message_verify' )?===? '0' ???1?:?0; ???????????? ???????????? //?設置額外數據 ???????????? if ?($data)?{ ???????????????? $data[ 'acode' ]?=?get_lg(); ???????????????? $data[ 'user_ip' ]?=?ip2long(get_user_ip()); ???????????????? $data[ 'user_os' ]?=?get_user_os(); ???????????????? $data[ 'user_bs' ]?=?get_user_bs(); ???????????????? $data[ 'recontent' ]?=? '' ; ???????????????? $data[ 'status' ]?=?$status; ???????????????? $data[ 'create_user' ]?=? 'guest' ; ???????????????? $data[ 'update_user' ]?=? 'guest' ; ???????????????? $data[ 'uid' ]?=?session( 'pboot_uid' ); ???????????? } ???????????? ???????????? if ?($ this ->model->addMessage($data))?{ ???????????????? session( 'lastsub' ,?time());? //?記錄最后提交時間 ???????????????? $ this ->log( '留言提交成功!' ); ???????????????? if ?($ this ->config( 'sms_status' ))?{ ???????????????????? if ?($ this ->config( 'message_send_sms' )?&&?$ this ->config( 'sms_send_to' ))?{ ???????????????????????? $sms_subject?=? "您有新的" ?.?$value->form_name?.? "信息,請注意查收!" ; ???????????????????????? sendsms($ this ->config(),?$ this ->config( 'sms_send_to' ),?$sms_subject); ???????????????????? } ???????????????? }? else ?{ ???????????????????? if ?($ this ->config( 'message_send_mail' )?&&?$ this ->config( 'message_send_to' ))?{ ???????????????????????? $mail_subject?=? "【" ?.?CMSNAME?.? "】您有新的" ?.?$value->form_name?.? "信息,請注意查收!" ; ???????????????????????? $mail_body?.=? '<br>來自網站?' ?.?get_http_url()?.? '?(' ?.?date( 'Y-m-d?H:i:s' )?.? ')' ; ???????????????????????? sendmail($ this ->config(),?$ this ->config( 'message_send_to' ),?$mail_subject,?$mail_body); ???????????????????? } ???????????????? } ???????????????? alert_location( '提交成功!' ,? '-1' ,?1); ???????????? }? else ?{ ???????????????? $ this ->log( '留言提交失??!' ); ???????????????? alert_back( '提交失敗!' ); ???????????? } ???????? }? else ?{ ???????????? alert_back( '提交失敗,請使用POST方式提交!' ); ???????? } ???? } |
5:打開項目:\core\function\helper.php 修改短信發送函數
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
|
//?發送短信 function ?sendsms(array?$config,?$to,?$content) { ???? $statusStr?=?array( ???????? "0" ?=>? "短信發送成功" , ???????? "-1" ?=>? "參數不全" , ???????? "-2" ?=>? "服務器空間不支持,請確認支持curl或者fsocket,聯系您的空間商解決或者更換空間!" , ???????? "30" ?=>? "密碼錯誤" , ???????? "40" ?=>? "賬號不存在" , ???????? "41" ?=>? "余額不足" , ???????? "42" ?=>? "帳戶已過期" , ???????? "43" ?=>? "IP地址限制" , ???????? "50" ?=>? "內容含有敏感詞" ???? ); ???? if ?(!?$to?||?!?$content)?{ ???????? return ?false ; ???? } ???? if ?($config[ 'sms_account' ]?==?0){ ???????? alert_back( '短信暫未開啟' ); ???? } ???? if ?(!?isset($config[ 'sms_account' ])?||?!?isset($config[ 'sms_pwd' ])?||?!?isset($config[ 'sms_signid' ]))?{ ???????? alert_back( '短信發送參數配置有誤' ); ???? } ???? $user?=?$config[ 'sms_account' ]; ???? $pass?=?md5($config[ 'sms_pwd' ]); ???? $content?=? "【" ?.?$config[ 'sms_signid' ]?.? "】" .$content; ???? $phone?=?$to;? //?替換空格 ???? $sendurl?=?$smsapi. "sms?u=" .$user. "&p=" .$pass. "&m=" .$phone. "&c=" .urlencode($content); ???? $res?=file_get_contents($sendurl)?; ????? if ?($res?==?0)?{ ????????? return ?true ; ???????? }? else ?{ ????????? error( '短信發送失敗,' ?.?$statusStr[$res]); ????? } } |
6:打開項目:apps\api\controller\CmsController.php 修改Api表單短信發送
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
|
public? function ?addform() ???? { ???????? if ?($_POST)?{ ???????????? ???????????? if ?(!?$fcode?=?request( 'fcode' ,? 'var' ))?{ ???????????????? json(0,? '傳遞的表單編碼fcode有誤!' ); ???????????? } ???????????? ???????????? if ?($ this ->config( 'form_status' )?===? '0' )?{ ???????????????? json(0,? '系統已經關閉表單功能,請到后臺開啟再試!' ); ???????????? } ???????????? ???????????? //?讀取字段 ???????????? if ?(!?$form?=?$ this ->model->getFormField($fcode))?{ ???????????????? json(0,? '接收表單不存在任何字段,請核對后重試!' ); ???????????? } ???????????? ???????????? //?接收數據 ???????????? $mail_body?=? '' ; ???????????? foreach?($form?as?$value)?{ ???????????????? $field_data?=?post($value->name); ???????????????? if ?(is_array($field_data))?{? //?如果是多選等情況時轉換 ???????????????????? $field_data?=?implode( ',' ,?$field_data); ???????????????? } ???????????????? $field_data?=?str_replace( 'pboot:if' ,? '' ,?$field_data); ???????????????? if ?($value->required?&&?!?$field_data)?{ ???????????????????? json(0,?$value->description?.? '不能為空!' ); ???????????????? }? else ?{ ???????????????????? $data[$value->name]?=?$field_data; ???????????????????? $mail_body?.=?$value->description?.? ':' ?.?$field_data?.? '<br>' ; ???????????????? } ???????????? } ???????????? ???????????? //?設置創建時間 ???????????? if ?($data)?{ ???????????????? $data[ 'create_time' ]?=?get_datetime(); ???????????? } ???????????? ???????????? //?寫入數據 ???????????? if ?($ this ->model->addForm($value->table_name,?$data))?{ ???????????????? $ this ->log( 'API提交表單數據成功!' ); ???????????????? if ?($ this ->config( 'sms_status' ))?{ ???????????????????? if ?($ this ->config( 'form_send_sms' )?&&?$ this ->config( 'sms_send_to' ))?{ ???????????????????????? $sms_subject?=? "您有新的" ?.?$value->form_name?.? "信息,請注意查收!" ; ???????????????????????? sendsms($ this ->config(),?$ this ->config( 'sms_send_to' ),?$sms_subject); ???????????????????? } ???????????????? } else { ???????????????????? if ?($ this ->config( 'form_send_mail' )?&&?$ this ->config( 'message_send_to' ))?{ ???????????????????????? $mail_subject?=? "【" ?.?CMSNAME?.? "】您有新的" ?.?$value->form_name?.? "信息,請注意查收!" ; ???????????????????????? $mail_body?.=? '<br>來自網站' ?.?get_http_url()?.? '(' ?.?date( 'Y-m-d?H:i:s' )?.? ')' ; ???????????????????????? sendmail($ this ->config(),?$ this ->config( 'message_send_to' ),?$mail_subject,?$mail_body); ???????????????????? } ???????????????? } ???????????????? json(1,? '表單提交成功!' ); ???????????? }? else ?{ ???????????????? $ this ->log( 'API提交表單數據失??!' ); ???????????????? json(0,? '表單提交失??!' ); ???????????? } ???????? }? else ?{ ???????????? json(0,? '表單提交失敗,請使用POST方式提交!' ); ???????? } ???? } |
經過上面的替換,短信寶的短信平臺已經替換成功了,可以正常使用了。進行測試發送:
報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,即便遇到敏感文字我們都不會人工審核,短信內容3~5秒就可送達。
另外:我們已經開發好完整的PbootCMS_V3.1.2系統短信寶插件,點擊此鏈接?下載及查看安裝流程。
最新更新
電商類
CMS類
微信類