ESPCMS是一款基于LAMP開發(fā)的企業(yè)網(wǎng)站管理系統(tǒng),二次開發(fā)及后期維護(hù)方便,小編對(duì)這款系統(tǒng)還是比較了解的,今天小編就以替換短信接口為例為大家講解一下如何進(jìn)行二次開發(fā),使用的短信接口是我們短信寶短信群發(fā)平臺(tái),我們短信寶短信群發(fā)平臺(tái)非常穩(wěn)定,發(fā)送速度快,注冊(cè)就送測(cè)試短信,推薦大家使用。
首先我們打開項(xiàng)目\ESPCMS_V8\ESPCMS_V8\espcms_public\ESPCMS_Core.php文件,增加postsmsbao 方法
|
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
|
public static function postsmsbao($data=''){ if ($data['smsmoblie'] == $data['moblienumber']) { $http = $url."u=".$data['userid']."&p=".$data['smssnid']."&m=".$data['moblienumber']."&c=【".$data['smskey']."】".$data['smscontent']; }else{ $http = $url."u=".$data['userid']."&p=".$data['smssnid']."&m=".$data['smsmoblie']."&c=【".$data['smskey']."】".$data['smscontent']; } if (function_exists('file_get_contents')) { $info = file_get_contents($http); }else{ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $http); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); if (!empty($data)) { curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); } curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $info = curl_exec($curl); curl_close($curl); } return $info;} |
接著打開項(xiàng)目\ESPCMS_V8\ESPCMS_V8\espcms_interface\ESPCMS_SendMessage.php文件替換smssend方法
|
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
|
public static function smssend($smsContent = null, $toMoblie = 0, $isSendtype = 0) { global $espcms_command; $smsContent = trim(strip_tags($smsContent)); if (empty($smsContent) || empty($toMoblie)) { return false; } if (!preg_match("/^1[0-9]{10}$/i", $toMoblie)) { return false; } $userid = $espcms_command['SMS_USER_ID']; $smssnid = $espcms_command['SMS_MESSAGE_ID']; $smskey = $espcms_command['SMS_KEY']; $moblienumber = $espcms_command['SMS_MOBLIE_NB']; $ipadd = real_remote_ip(true); $post['userid'] = $userid; $post['smssnid'] = md5($smssnid); $post['smskey'] = $smskey; $post['ip'] = $ipadd; $post['smsmoblie'] = $moblienumber; $post['sendmoblie'] = $toMoblie; $post['smscontent'] = $smsContent; $service_status = ESPCMS_Core::postsmsbao($post); if ($service_status == '0') { return true; } else { return false; } } |
在項(xiàng)目根目錄下創(chuàng)建\ESPCMS_V8\ESPCMS_V8\smsbao.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
|
<?phpheader("Content-type:text/html;charset=utf-8");require_once('./espcms_public/ESPCMS_Mysql.php' );require('./espcms_datacache/espcms_config.php');$conn = mysqli_connect(ESPCMS_DB_HOST,ESPCMS_DB_USER, ESPCMS_DB_PASSWORD);if(! $conn ){ die('連接失敗: ' . mysqli_error($conn));}mysqli_query($conn , "set names".ESPCMS_DB_CHARSET);mysqli_select_db( $conn, ESPCMS_DB_NAME );$db_table = ESPCMS_DB_PREFIX . 'config';$newsql = sreadfile("smsbao.sql");$sqls = explode(";", $newsql);foreach ($sqls as $sql) { $sqls = trim($sql); $sql = str_replace('$db_table',$db_table,$sqls); if (empty($sql)) { continue; } if(!$query = $query = mysqli_query( $conn, $sql )) { echo "執(zhí)行sql語(yǔ)句成功 ".mysql_error(); exit(); }}echo "<h4>ESPSMS短信寶短信插件安裝成功,請(qǐng)刪除此文件。</h4>";function sreadfile($filename){ $content = ''; if(function_exists('file_get_contents')) { @$content = file_get_contents($filename); } else { if(@$fp = fopen($filename, 'r')) { @$content = fread($fp, filesize($filename)); @fclose($fp); } } return $content;} |
最后在系統(tǒng)根目錄中\(zhòng)ESPCMS_V8\ESPCMS_V8\smsbao.sql
|
1
2
3
|
UPDATE `$db_table` SET config_title='短信寶用戶名',config_validation='',config_content='沒(méi)有賬號(hào)?請(qǐng)去http://www.gjrencai.com/reg注冊(cè)賬號(hào)' WHERE config_name='SMS_USER_ID';UPDATE `$db_table` SET config_title='短信寶密碼',config_validation='',config_content='請(qǐng)?zhí)顚懩亩绦艑毭艽a' WHERE config_name='SMS_MESSAGE_ID';UPDATE `$db_table` SET config_title='短信簽名',config_validation='',config_content='請(qǐng)?zhí)顚懩亩绦藕灻?nbsp;' WHERE config_name='SMS_KEY'; |
經(jīng)過(guò)上面的替換,短信寶的短信平臺(tái)已經(jīng)替換成功了,可以正常使用了。進(jìn)行測(cè)試發(fā)送:

報(bào)備一下短信寶的VIP模板,這樣就可以走短信寶的優(yōu)質(zhì)通道了,即便遇到敏感文字我們都不會(huì)人工審核,短信內(nèi)容3~5秒就可送達(dá)。
另外:我們已經(jīng)開發(fā)好完整的ESPCMS企業(yè)網(wǎng)站管理系統(tǒng)短信寶插件,點(diǎn)擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類