$resultSMS = $modelQueue->setMailQueue($paramSMS); $resultEmail = $modelQueue->setMailQueue($paramEmail); $errMsg = array(); if ($resultSMS['success'] === false) { $errMsg[] = $GLOBALS['MOD_LANG']->getMessage('contact.test.send.sms.fail', array($resultSMS['errmsg'])); } if ($resultEmail['success'] === false) { $errMsg[] = $GLOBALS['MOD_LANG']->getMessage('contact.test.send.email.fail', array($resultEmail['errmsg'])); } if (count($errMsg) > 0) { $view['jsErrMsg'] = implode('<br>', $errMsg); } else { $view['jsMsg'] = $GLOBALS['MOD_LANG']->getMessage('contact.test.send.all.success', array($to_sms, $to_mail)); } break; default: header("location: " . WEB_ROOT . '/testContact/'); exit; break; } } $modelSP = new SMSService(); //$sp will be reset if post data is exists $view['testContact']['spOption'] = $modelSP->genServiceOptionsbyDomain($sp); $view['testContact']['formData'] = array('name' => &$to_name, 'email' => &$to_mail, 'mobile_area' => &$mobileArea, 'mobile' => &$mobile, 'msg' => &$msg); /*============================ * View Loading *===========================*/ include "view/b_sendContactMsg.php"; ?>
$result = $modelContact->delContact(webDataFilter('p', 'ctno', 'int')); if ($result['success'] === false) { printHTMLContent('genStandalongJSBlock', array(genJSExistBoxWithCloseRedirect(WEB_JS_ERRMSGBOX_ID, $result['errmsg'], WEB_ROOT . '/contact/'))); exit; } else { printSuccessMsgBox(); exit; } break; default: header("location: " . WEB_ROOT . '/contact/'); exit; break; } } $modelSP = new SMSService(); /*============================ * View Loading *===========================*/ switch ($action) { case 'add': $view['setContact']['spOption'] = $modelSP->genServiceOptionsbyIdx(); include "view/b_addContact.php"; break; case 'addPost': $view['setContact']['formData'] = array('contact_name' => &$name, 'contact_email' => &$email, 'contact_mobile_area' => &$mobileArea, 'contact_mobile' => &$mobile, 'sms_service' => &$sp); $view['setContact']['spOption'] = $modelSP->genServiceOptionsbyIdx($view['setContact']['formData']['sms_service']); include "view/b_addContact.php"; break; case 'modify': $result = $modelContact->getContact($ctno);
function gw_send_sms($mobile_sender, $sms_sender, $sms_to, $sms_msg, $gp_code = "", $uid = "", $smslog_id = "", $flash = false) { $result = array(); // $sms_msg = utf8_decode($sms_msg); $sms_to = ltrim($sms_to, '+'); if (strlen($sms_to) < 9) { $sms_to = "47{$sms_to}"; } $arguments = array('type' => '1', 'serviceid' => $this->pswin_param['serviceid'], 'content' => utf8_decode($sms_msg), 'originator' => $this->pswin_param['originator'], 'originatortype' => $this->pswin_param['originatortype'], 'recipient' => $sms_to, 'username' => $this->pswin_param['login'], 'password' => $this->pswin_param['password'], 'differentiator' => $this->pswin_param['differentiator']); if ($this->pswin_param['type'] == 'GET') { $query = http_build_query($arguments); $request = "{$this->pswin_param['send_url']}?{$query}"; $aContext = array('http' => array('proxy' => "{$this->pswin_param['proxy_host']}:{$this->pswin_param['proxy_port']}", 'request_fulluri' => True)); $cxContext = stream_context_create($aContext); $response = file_get_contents($request, False, $cxContext); $result = $this->parse_html($response); } else { require_once 'SMSService.php'; $options = array(); $options['soap_version'] = SOAP_1_1; $options['location'] = $this->pswin_param['service_url']; $options['uri'] = "http://sms.pswin.com/SOAP/SMS.asmx"; $options['trace'] = 1; $options['proxy_host'] = $this->pswin_param['proxy_host']; $options['proxy_port'] = $this->pswin_param['proxy_port']; $options['encoding'] = 'iso-8859-1'; //'UTF-8'; $service = new SMSService($this->pswin_param['wsdl'], $options); $SMSMessage = new SMSMessage(); $SMSMessage->ReceiverNumber = (string) $arguments['recipient']; $SMSMessage->SenderNumber = (string) $this->pswin_param['originator']; $SMSMessage->Text = (string) $arguments['content']; $SMSMessage->Network = (string) ''; $SMSMessage->TypeOfMessage = (string) 'Text'; $SMSMessage->Tariff = (int) 0; $SMSMessage->TimeToLive = (int) 0; $SMSMessage->CPATag = ''; $SMSMessage->RequestReceipt = (bool) false; $SMSMessage->SessionData = (string) ''; $SMSMessage->AffiliateProgram = (string) ''; $SMSMessage->DeliveryTime = (string) ''; $SMSMessage->ServiceCode = (string) ''; $SendSingleMessage = new SendSingleMessage(); $SendSingleMessage->username = $this->pswin_param['login']; $SendSingleMessage->password = $this->pswin_param['password']; $SendSingleMessage->m = $SMSMessage; $ReturnValue = $service->SendSingleMessage($SendSingleMessage); $result['statuscode'] = $ReturnValue->SendSingleMessageResult->Code; $result['messageid'] = $ReturnValue->SendSingleMessageResult->Reference; $result['description'] = $ReturnValue->SendSingleMessageResult->Description; } // p_status : // 0 = pending // 1 = delivered // 2 = failed // p_status : // 500 = pending // 200 = delivered // 100 = failed if ($result['statuscode'] == 200) { $this->setsmsdeliverystatus($smslog_id, $uid, 1); $ret = true; } else { if ($result['statuscode'] == 100) { $this->setsmsdeliverystatus($smslog_id, $uid, 2); $ret = false; throw new Exception($result['description']); } } return $ret; }
/** * 短信内容发送总接口 * 发发除了验证码之外的短信 * @param String $phone 手机号码 * @param int $tid 模板ID:-1表示不使用模板,直接发送短信内容$content * @param Array $params 模板参数:参数名param1、param2、param3、... * @param String $content 短信内容:模板ID为-1时才使用 * @return Boolean true:发送成功 false:发送失败 */ public static function sendSmsContent($phone, $tid = -1, $params = array(), $content = null) { $result = false; if ($tid != -1) { // 按模板发送 if (empty(self::TEMPLATE_SMS[$tid])) { return $result; } $contentArray = explode('【变量】', self::TEMPLATE_SMS[$tid]); if (count($contentArray) != count($params) + 1) { return $result; } $content_temp = ''; foreach ($contentArray as $k => $v) { if ($k == 0) { $content_temp = $v; } else { $key = "param" . $k; $content_temp .= $params[$key] . $v; } } // 优先调用互忆无线短信接口 $result = HuyiSmsService::sendSmsContent($phone, $content_temp); self::recordSmsLog(2, $result, false); // 记录互亿无线发送情况 if (!$result) { // 莫名短信发送接口 $status = SMSService::sendSMS($phone, $content_temp); if ($status == 100) { $result = true; } self::recordSmsLog(3, $result, false); // 记录莫名发送情况 } } else { // 直接发送短信内容:$content if (empty($content)) { return $result; } $status = SMSService::sendSMS($phone, $content); if ($status == 100) { $result = true; } self::recordSmsLog(3, $result, false); // 记录莫名发送情况 } return $result; }
/** * Parse the SMS notifications sent to you. Multiple notifications * may be recieved over time. You can check the status of the SMS * delivery using this. * * @param array $post_vars Pass in the system variable $_POST * * @return SMSTransaction Look at SMSTransaction for available information */ public function parseSMSNotify($post_vars) { return SMSService::parseSMSNotify($post_var); }