PHP地方装修门户系统是基于PHP+MYSQL为核心开发的家居装饰web系统,它是开源的,使用范围非常广泛。本人对该系统还是比较熟悉的,今天我就来分享一下,如何进行二次开发。我以替换短信接口为例,一步一步的手把手教大家开发过程,我们做演示的短信平台是短信宝(http://www.smsbao.com)短信平台,我们公司和短信宝平台合作好几年了,他们的平台非常稳定,而且快速,注册还送免费测试短信,大家可以在短信宝平台注册一个账号,进行测试。
首先,我们先更换后台的显示界面文件。打开模板文件,替换一下模板文件。打开项目/themes/admin/site,替换的代码从10行~33行,代码如下图所示:
<form action="index.php?ctl=site&act=sms" target="hiden_frm" name="form1" id="myform" method="post">
<table width="100%" cellspacing="0" cellpadding="0" class="table_form">
<tbody>
<tr>
<th >短信说明:</th>
<td class="jq_service_sms" style="height: 80px; line-height: 25px;">
短信服务商为:<a href="http://www.smsbao.com" target="_blank" style="color:red;font-weight:bold;">短信宝</a>,www.smsbao.com<br />
尚未注册短信宝账号的,请点击<a href="http://www.smsbao.com" target="_blank" style="color:red;font-weight:bold;">免费注册</a><br />
报备模板后免审核,到达速度更快 <br />
有任何疑问,请联系短信宝<a href="http://wpa.b.qq.com/cgi/wpa.php?ln=1&key=XzkzODA0NjAyMV8yNTU0MzFfNDAwMDA5MDQ2NV8yXw" target="_blank" style="color:red;font-weight:bold;">客服</a>
</td>
</tr>
<tr>
<th >短信宝账号:</th>
<td>
<input type="text" size="40" name="data[username]" value="<?php echo isset($sms['username']) ? $sms['username'] : ''; ?>" /> 更换服务商后请手动修改账号和密码!
</td>
</tr>
<tr>
<th >短信宝密码:</th>
<td>
<input type="password" size="40" name="data[password]" value="<?php echo isset($sms['password']) ? $sms['password'] : ''; ?>" /> 更换服务商后请手动修改账号和密码!
</td>
</tr>
经过替换后,所有的显示都变成短信宝短信平台的了。第一步完成。接下来替换发送短信的业务代码。修改core/interface/sms.int.php文件。这个文件是PHP家居装饰的公用函数文件。替换代码从62~71行,代码如下图所示:
private function yunSmsSend($mobileArr,$content)
{
$mobile = join(',',$mobileArr);
$api = 'http://api.smsbao.com/sms?u='.$this->_cfg['username'].'&p='. strtolower(md5($this->_cfg['password'])).'&m='.$mobile.'&c='. urlencode($content);
$ret = file_get_contents($api);
$return = $ret =='0'? true : false;
return $return;
}
注:短信模板中请务必添加短信签名,签名添加在短信内容前面,报备VIP模版,这样就可以走短信宝的优质通道了,并且免审核了,短信内容3~5秒就可送达。