예제 #1
0
function sendsms($mob, $content)
{
    $server_url = 'http://3tong.net/services/sms?wsdl';
    $user_name = 'dh21944';
    $password = '******';
    include_once dirname(dirname(__FILE__)) . "/sms/dahan/class.dahansms.php";
    $dahan = new dahanClient();
    $dahan->Client($server_url, $user_name, $password);
    $res = $dahan->dahanSMS($mob, $content);
    //插入数据库中短信信息
    $currenttime = date('Y-m-d H:i:s', time());
    $bdb = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PWD);
    $sql = sprintf("INSERT INTO %s (telephone,send_content,back_result,send_time) VALUES ('%s','%s','%s','%s') ", 'lzh_sendsms', $mob, addslashes($content), addslashes($res), $currenttime);
    $stmt1 = $bdb->prepare($sql);
    $stmt1->execute();
    $bdb = null;
    // file_put_contents('a.txt',date('m-d H:i:s')." ".print_r($res,true)."\n",FILE_APPEND);
    return true;
}
예제 #2
0
파일: DataSource.php 프로젝트: GStepOne/CI
function sendsms($mob, $content)
{
    //add by whh 2015-1-27
    file_put_contents('/tmp/debug', date('m-d H:i:s') . " " . print_r($mob, true) . "\n", FILE_APPEND);
    file_put_contents('/tmp/debug', date('m-d H:i:s') . " " . print_r($content, true) . "\n", FILE_APPEND);
    $server_url = 'http://3tong.net/services/sms?wsdl';
    $user_name = 'dh21944';
    $password = '******';
    include_once dirname(__FILE__) . "/sms/dahan/class.dahansms.php";
    $dahan = new dahanClient();
    $dahan->Client($server_url, $user_name, $password);
    $res = $dahan->dahanSMS($mob, $content);
    //发送短信结束 以下是插入数据库
    $data['telephone'] = $mob;
    $data['send_content'] = $content;
    $data['back_result'] = $res;
    $data['send_time'] = date('Y-m-d H:i:s', time());
    M('sendsms')->add($data);
    return true;
    include_once dirname(__FILE__) . "/sms/dream/class.dream.php";
    $dream = new dream();
    $res = $dream->send($mob, $content);
    file_put_contents('/tmp/debug', date('m-d H:i:s') . " " . print_r($res, true) . "\n", FILE_APPEND);
    return true;
    $msgconfig = FS("Webconfig/msgconfig");
    $type = $msgconfig['sms']['type'];
    // type=0 吉信通短信接口   type=1 漫道短信接口   type=2 亿美短信接口
    if ($type == 0) {
        $uid = $msgconfig['sms']['user1'];
        //分配给你的账号
        $pwd = $msgconfig['sms']['pass1'];
        //密码
        $mob = $mob;
        //发送号码用逗号分隔
        if (PATH_SEPARATOR == ':') {
            //如果是Linux系统,则执行linux短息接口
            $url = "http://service.winic.org:8009/sys_port/gateway/?id=%s&pwd=%s&to=%s&content=%s&time=";
            $id = urlencode($uid);
            $pwd = urlencode($pwd);
            $to = urlencode($mob);
            $content = iconv("UTF-8", "GB2312", $content);
            $rurl = sprintf($url, $id, $pwd, $to, $content);
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_URL, $rurl);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $result = curl_exec($ch);
            curl_close($ch);
            $status = substr($result, 0, 3);
            if ($status === "000") {
                return true;
            } else {
                return false;
            }
        } else {
            $content = urlencode(auto_charset($content, "utf-8", 'gbk'));
            //短信内容
            $sendurl = "http://service.winic.org:8009/sys_port/gateway/?";
            $sdata = "id=" . $uid . "&pwd=" . $pwd . "&to=" . $mob . "&content=" . $content . "&time=";
            $xhr = new COM("MSXML2.XMLHTTP");
            $xhr->open("POST", $sendurl, false);
            $xhr->setRequestHeader("Content-type:", "text/xml;charset=GB2312");
            $xhr->setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            $xhr->send($sdata);
            $data = explode("/", $xhr->responseText);
            if ($data[0] == "000") {
                return true;
            } else {
                return false;
            }
        }
    } elseif ($type == 1) {
        /////////////////////////////////////////漫道短信接口 开始/////////////////////////////////////////////////////////////
        //如果您的系统是utf-8,请转成GB2312 后,再提交、
        $flag = 0;
        //要post的数据
        $argv = array('sn' => $msgconfig['sms']['user2'], 'pwd' => $msgconfig['sms']['pass2'], 'mobile' => $mob, 'content' => iconv("UTF-8", "gb2312//IGNORE", $content), 'ext' => '', 'stime' => '', 'rrid' => '');
        //构造要post的字符串
        foreach ($argv as $key => $value) {
            if ($flag != 0) {
                $params .= "&";
                $flag = 1;
            }
            $params .= $key . "=";
            $params .= urlencode($value);
            $flag = 1;
        }
        $length = strlen($params);
        //创建socket连接
        $fp = fsockopen("sdk2.zucp.net", 8060, $errno, $errstr, 10) or exit($errstr . "--->" . $errno);
        //构造post请求的头
        $header = "POST /webservice.asmx/mt HTTP/1.1\r\n";
        $header .= "Host:sdk2.zucp.net\r\n";
        $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
        $header .= "Content-Length: " . $length . "\r\n";
        $header .= "Connection: Close\r\n\r\n";
        //添加post的字符串
        $header .= $params . "\r\n";
        //发送post的数据
        fputs($fp, $header);
        $inheader = 1;
        while (!feof($fp)) {
            $line = fgets($fp, 1024);
            //去除请求包的头只显示页面的返回数据
            if ($inheader && ($line == "\n" || $line == "\r\n")) {
                $inheader = 0;
            }
            if ($inheader == 0) {
                // echo $line;
            }
        }
        $line = str_replace("\n<string xmlns=\"http://tempuri.org/\">", "", $line);
        $line = str_replace("</string>\n", "", $line);
        $result = explode("-", $line);
        if (count($result) > 1) {
            return false;
        } else {
            return true;
        }
        /////////////////////////////////////////漫道短信接口 结束/////////////////////////////////////////////////////////////
    } elseif ($type == 2) {
        ////////////////////////////////////////////////////////亿美短信接口 开始/////////////////////////////////////////////
        $uid = $msgconfig['sms']['user3'];
        //分配给你的账号
        $pwd = $msgconfig['sms']['pass3'];
        //密码
        $mob = $mob;
        //发送号码用逗号分隔
        $content = urlencode(auto_charset($content, "utf-8", 'gbk'));
        //短信内容
        $sendurl = "http://sdk229ws.eucp.b2m.cn:8080/sdkproxy/sendsms.action?";
        $sendurl .= 'cdkey=' . $serialNumber . '&password='******'&phone=' . $mob . '&message=' . $content . '&addserial=';
        $d = @file_get_contents($sendurl, false);
        preg_match_all('/
<response>
(.*)<\\/response>/isU', $d, $arr);
        foreach ($arr[1] as $k => $v) {
            preg_match_all('#
<error>(.*)</error>
#isU', $v, $ar[$k]);
            $data[] = $ar[$k][1];
        }
        if ($data[0][0] == "0") {
            return true;
        } else {
            return false;
        }
        ////////////////////////////////////////////////////////亿美短信接口 结束/////////////////////////////////////////////
    } else {
        return false;
    }
}
예제 #3
0
function sendsms($mob, $content)
{
    $server_url = 'http://3tong.net/services/sms?wsdl';
    $user_name = 'dh21944';
    $password = '******';
    include_once dirname(dirname(__FILE__)) . "/sms/dahan/class.dahansms.php";
    $dahan = new dahanClient();
    $dahan->Client($server_url, $user_name, $password);
    $res = $dahan->dahanSMS($mob, $content);
    // file_put_contents('a.txt',date('m-d H:i:s')." ".print_r($res,true)."\n",FILE_APPEND);
    $user = core::Singleton('user.member');
    $user->addSms($mob, $content, $res);
    return true;
}