public function execute() { global $gvPath, $gvPhoneCodeLength; if ($this->redirect) { return $this->redirect; } $this->message = ''; $phone = gfPostVar('phone'); if (!$phone) { $this->message = 'Il campo è obbligatorio.'; return true; } // Check only digits have been typed if (!preg_match('/^[0-9]{5,}$/', $phone)) { $this->message = 'Il valore inserito non è valido.'; return true; } // Remove international prefix if present $phone = preg_replace('/^(00|\\+)?39/', '', $phone); $phone = '39' . $phone; // Check no ticket is reserved with this phone number $ticket = Ticket::fromDatabaseBySourceId($phone); if ($ticket) { $this->message = 'Hai già prenotato un ticket con questo numero.'; return true; } // Check phone number is not banned if (Ban::isBanned($phone)) { $this->message = 'Questo numero di telefono è stato bloccato.'; return true; } $hashRandom = (string) mt_rand(0, 100000); $hashRandom .= (string) mt_rand(0, 100000); $hashRandom = strtoupper(sha1($hashRandom)); $positionRandom = mt_rand(0, 40 - $gvPhoneCodeLength); $phone_code = substr($hashRandom, $positionRandom, $gvPhoneCodeLength); $_SESSION['phone_code'] = $phone_code; $_SESSION['phone'] = $phone; // Send SMS $sender = new SmsSender($phone); if (!$sender->sendVerificationCode($phone_code)) { $this->message = 'Errore nell\'invio del messaggio. Verificare che il numero di telefono sia corretto.'; return true; } $_SESSION['step'] = 2; $redirect = new RedirectOutput("{$gvPath}/web/checkPhone"); return $redirect; }
public function getVCode() { if (!IS_POST) { return 1; // err } $token = $_POST['token']; $wecha_id = $_POST['wecha_id']; $telno = $_POST['telno']; $func = $_POST['func']; // 获得公司名字, 作为短信落款 $merchant = M('wxuser')->where(array('token' => $token, 'status' => 1))->field('company')->find(); if (empty($merchant['company'])) { $company = "领众科技"; } else { $company = $merchant['company']; } $result['errcode'] = 0; $result['msg'] = ''; $Cache = Cache::getInstance('File', array('expire' => '610')); $code = $Cache->get('vcode_' . $token . $telno); if (empty($code)) { $code = sprintf("%0" . strlen($max) . "d", mt_rand(100000, 999999)); $Cache->set('vcode_' . $token . $telno, $code); //$truth_code = $Cache->get('vcode_'.$token.$telno); } Log::record('truthcode:' . 'vcode_' . $token . $telno . ':' . $code); Log::save(); include LIB_PATH . 'Action/SmsSender.class.php'; $smsSender = new SmsSender(); $vcode_tmpl = C('vcode'); if (isset($vcode_tmpl)) { $smsContent = str_replace("#merchant#", $company, $vcode_tmpl); $smsContent = str_replace("#code#", $code, $smsContent); $res = $smsSender->notify($token, $func, $smsContent, $telno); if ($res !== 0) { $result['errcode'] = 1; } } else { $result['errcode'] = 1; } $this->ajaxReturn($result, 'json'); }
public function execute() { global $gvPath, $gvPhoneCodeLength; if ($this->redirect) { return $this->redirect; } $this->message = ''; $phone_code = gfPostVar('phone_code', ''); $phone_code = strtoupper($phone_code); if (!$phone_code) { $this->message = 'Il campo è obbligatorio.'; return true; } if ($phone_code != $this->phone_code) { $this->message = 'Il codice inserito non è corretto.'; return true; } // check td existence and activation $td_code = gfSessionVar('td_code', ''); $td = TopicalDomain::fromDatabaseByCode($td_code); if (!$td || !$td->getActive()) { // This is very improbable in this // case start again the wizard $_SESSION['step'] = 0; return true; } $ticket = Ticket::nextNewTicket($td_code, 'web', gfSessionVar('phone')); $ticket->save(); $sender = new SmsSender(gfSessionVar('phone')); if (!$sender->sendNewTicket($ticket)) { // False means error while sending $this->message = "Errore nella prenotazione. Assicurarsi di aver inserito il numero corretto."; return true; } $_SESSION['step'] = 3; $_SESSION['ticket'] = $ticket; $redirect = new RedirectOutput("{$gvPath}/web/complete"); return $redirect; }
logFile("[ content={$content}, address={$address}, requestId={$requestId}, applicationId={$applicationId}, encoding={$encoding}, version={$version} ]"); $responseMsg; //your logic goes here...... $split = explode(' ', $content); $split_number = explode(':', $address); //split address $tag = "{$split['2']} {$split['3']}"; // set tag name $responseMsg = $split[1]; $time_to_stop = $split[4]; $user_iD = $split_number[1]; $contentarray = $split[0]; $store_data = $split[1]; //echo $responseMsg; // $responseMsg = $user_iD; $update_time = time() + $time_to_stop * 60 * 60; $con1 = mysqli_connect("localhost", "billz", "asdasd", "notification"); mysqli_query($con1, "UPDATE priority_taglist SET autho='{$responseMsg}', timetostop= '{$update_time}' WHERE user_id='{$user_iD}' AND tag_name ='{$tag}' "); $sender = new SmsSender("https://localhost:7443/sms/send"); //sending a one message $applicationId = $applicationId; $encoding = "0"; $version = "1.0"; $password = "******"; $sourceAddress = "77160"; $deliveryStatusRequest = "1"; $charging_amount = ":15.75"; $destinationAddresses = $address; //array("tel:94771122336"); $binary_header = ""; $res = $sender->sms($responseMsg, $destinationAddresses, $password, $applicationId, $sourceAddress, $deliveryStatusRequest, $charging_amount, $encoding, $version, $binary_header);
public function getcode() { $token = $this->_get('token'); $wecha_id = $this->_get('wecha_id'); $tel = $this->_post('tel'); $cardnum = $this->_post('cardnum'); $where = array('token' => $token, 'tel' => $tel, 'cardnum' => $cardnum); //根据电话号码验证会员是否被导入 $userinfo = M("physical_member")->where($where)->find(); if (!$userinfo) { echo '{"success":0,"msg":"没有找到您的会员卡信息,请联系商家导入。"}'; exit; } elseif ($userinfo['binded']) { echo '{"success":0,"msg":"此手机号已被绑定."}'; exit; } elseif ($userinfo['cardnum'] != $cardnum) { echo '{"success":0,"msg":"您输入的手机号与卡号不匹配,请重新输入。"}'; exit; } $Cache = Cache::getInstance('File', array('expire' => '310')); $scode = $Cache->get($token . $tel); if (!empty($scode)) { // 避免多次发送 echo '{"success":0,"msg":"验证码已发送,请稍侯。"}'; exit; } $code = $this->rand_number(100000, 999999); $Cache->set($token . $tel, $code); Log::record("Send code : " . $code . " at " . date("Y-m-d H:i:s") . "\r\n", Log::DEBUG); include LIB_PATH . 'Action/SmsSender.class.php'; $smsSender = new SmsSender(); $binding_tmpl = C('card_binding'); $smsContent = ''; if (isset($binding_tmpl)) { $smsContent = str_replace("#merchant#", '领众科技', $binding_tmpl); $smsContent = str_replace("#code#", $code, $smsContent); } if ($smsContent != '') { $re = $smsSender->notify($this->_get('token'), "huiyuan", $smsContent, $tel); if ($re == 0) { $Cache->set($token . $tel, $code); echo '{"success":1,"msg":"验证码已发送,请输入收到的短信验证码!"}'; } else { echo '{"success":0,"msg":"验证码发送失败,请稍侯再试。"}'; } } else { echo '{"success":0,"msg":"验证码发送失败,请稍侯再试。"}'; } }
$production = false; if ($production == false) { $CASS_SERVER_URL = "http://localhost:7000/caas/direct/debit"; $SMS_SERVER_URL = "http://localhost:7000/sms/send"; } else { $CASS_SERVER_URL = 'https://api.dialog.lk/caas/direct/debit'; $SMS_SERVER_URL = "https://api.dialog.lk/sms/send"; } $logger = new Logger(); try { $receiver = new SMSReceiver(); $message = $receiver->getMessage(); // Get the message sent to the app $address = $receiver->getAddress(); // Get the phone no from which the message was sent list($keyword, $amount) = explode(" ", $message); // Setting up CAAS $cass = new DirectDebitSender($CASS_SERVER_URL, $APP_ID, $PASSWORD); $sender = new SmsSender($SMS_SERVER_URL, $APP_ID, $PASSWORD); try { if (isset($amount)) { $cass->cass($EXTERNAL_TRX_ID, $address, $amount); $sender->sms("Thank you for your generosity, You Have made a donation for " . $amount . " Rupees", $address); } } catch (CassException $ex) { $logger->WriteLog($ex); $sender->sms("You do not have sufficient credit to make this donation", $address); } } catch (Exception $e) { $logger->WriteLog($e); }
public function getcode() { $code = $this->rand_number(100000, 999999); //普通提交方式 include_once 'HttpClient.class.php'; //目标主机的地址,我这里填上测试的地址 $Client = new HttpClient("mssms.cn:8000"); $url = "http://222.185.228.25:8000/msm/sdk/http/sendsmsutf8.jsp"; //请求的页面地址 //POST的参数 $mobile = $this->_post('mobile'); $params = array('username' => "JSMB260705", 'scode' => "095169", 'mobile' => $mobile, 'content' => "@1@={$code}", 'tempid' => "MB-2013102300"); $pageContents = HttpClient::quickPost($url, $params); echo "提交返回=" . $pageContents; exit; $token = '540e6acfz71'; $wecha_id = $this->_get('wecha_id'); $tel = '15678456321'; $cardnum = 'LZ948820080012'; $where = array('token' => $token, 'tel' => $tel, 'cardnum' => $cardnum); //根据电话号码验证会员是否被导入 $userinfo = M("physical_member")->where($where)->find(); if (!$userinfo) { echo '{"success":0,"msg":"没有找到您的会员卡信息,请联系商家导入。"}'; exit; } elseif ($userinfo['binded']) { echo '{"success":0,"msg":"此手机号已被绑定."}'; exit; } elseif ($userinfo['cardnum'] != $cardnum) { echo '{"success":0,"msg":"您输入的手机号与卡号不匹配,请重新输入。"}'; exit; } $Cache = Cache::getInstance('File', array('expire' => '310')); $scode = $Cache->get($token . $tel); if (!empty($scode)) { // 避免多次发送 echo '{"success":0,"msg":"验证码已发送,请稍侯。"}'; exit; } $code = $this->rand_number(100000, 999999); $Cache->set($token . $tel, $code); Log::record("Send code : " . $code . " at " . date("Y-m-d H:i:s") . "\r\n", Log::DEBUG); include LIB_PATH . 'Action/SmsSender.class.php'; $smsSender = new SmsSender(); $binding_tmpl = C('card_binding'); $smsContent = ''; if (isset($binding_tmpl)) { $smsContent = str_replace("#merchant#", '领众科技', $binding_tmpl); $smsContent = str_replace("#code#", $code, $smsContent); } if ($smsContent != '') { $re = $smsSender->notify($this->_get('token'), "huiyuan", $smsContent, $tel); if ($re == 0) { $Cache->set($token . $tel, $code); echo '{"success":1,"msg":"验证码已发送,请输入收到的短信验证码!"}'; } else { echo '{"success":0,"msg":"验证码发送失败,请稍侯再试。"}'; } } else { echo '{"success":0,"msg":"验证码发送失败,请稍侯再试。"}'; } }
// put cellphone number into session, in case user use an different number to register. $sessionController->addCellphone($phone); } $last_time = $sessionController->getVerifyTime(); if (!empty($last_time)) { $this_time = time(); $interval = $this_time - $last_time; if ($interval < 120) { echo "时间间隔太短!"; return; } } $user = $userDao->getByPhone($phone); if ($user) { echo "手机号已被注册"; return; } // Generate a 6-digits random number $random = rand(100000, 999999); // Send to user's cellphone $sms = new SmsSender(); if ($sms->sendVerifyCode($phone, $random)) { echo "{\"msg\":\"success\"}"; // put it in the session $sessionController->addCode($random); $sessionController->addVerifyTime(time()); } else { echo "\n短信服务失败!"; } // temporary return to page // echo $random;
public function book() { // 检查是否需要短信验证码 $token = $this->token; $enable_vcode = 0; $smsset = M('sms_set')->where(array('token' => $token))->find(); if (!empty($smsset)) { if (strpos($smsset['function'], 'vccanyin') !== FALSE) { $enable_vcode = 1; } } $tel = $this->_post('tel'); $smsvcode = $this->_post('smsvcode'); if ($enable_vcode) { if (!SmsvcodeAction::verifyVCode($token, $tel, $smsvcode)) { // 验证码不匹配 Log::save(); $this->ajaxReturn("请输入正确的短信验证码!", "ERROR", 0); } } $menus = $this->_post('menus'); $cart_id = $this->_post('cart_id'); $username = $this->_post('username'); $guestnum = $this->_post('guestnum'); $note = $this->_post('note'); $dinetime = $this->_post('dinetime'); $where['id'] = $cart_id; //获取token以便发送短信提醒 $order_info = M('dine_order')->join('tp_dine_rest on tp_dine_order.rest_id = tp_dine_rest.id')->where(array('tp_dine_order.id' => $cart_id))->field('tp_dine_rest.token,tp_dine_order.sn')->order('createtime desc')->find(); $menus = htmlspecialchars_decode($menus); $menus = htmlspecialchars_decode($menus); $jmenus = json_decode($menus, true); $price = 0; $dishnum = count($jmenus); $dishname = ''; for ($j = 0; $j < count($jmenus); $j++) { $price += (double) $jmenus[$j]['price'] * (int) $jmenus[$j]['nums']; $dishname .= $jmenus[$j]['name'] . ' '; } $data['price'] = $price; $data['tel'] = $tel; $data['username'] = $username; $data['menus'] = $menus; $data['status'] = 2; $data['submittime'] = time(); $data['guestnum'] = $guestnum; $data['note'] = $note; $data['dinetime'] = $dinetime; $data['dishnum'] = $dishnum; $data['table'] = $this->_post('table'); $order = M('dine_order')->where($where)->save($data); if ($order) { include LIB_PATH . 'Action/SmsSender.class.php'; // 获得公司名字, 作为短信落款 $company = ''; $merchant = M('wxuser')->where(array('token' => $this->token, 'status' => 1))->field('company')->find(); if (empty($merchant['company'])) { $company = "领众科技"; } else { $company = $merchant['company']; } $smsSender = new SmsSender(); $notify_tmpl = C('dine_notify'); if (isset($notify_tmpl)) { $smsContent = str_replace("#merchant#", $company, $notify_tmpl); $smsContent = str_replace("#username#", $data['username'], $smsContent); $smsContent = str_replace("#tel#", $data['tel'], $smsContent); $smsContent = str_replace("#dinetime#", $data['dinetime'], $smsContent); $smsContent = str_replace("#guestnum#", $data['guestnum'], $smsContent); $smsContent = str_replace("#dishnum#", $data['dishnum'], $smsContent); $smsContent = str_replace("#sn#", $order_info['sn'], $smsContent); $smsContent = str_replace("#menus#", $dishname, $smsContent); if ($data['table']) { $table_info = $data['table'] . "号桌"; $smsContent = str_replace("#table#", $table_info, $smsContent); } else { $smsContent = str_replace("#table#", '桌号无', $smsContent); } $res = $smsSender->notify($order_info['token'], "canyin_order", $smsContent); $this->ajaxReturn($order, "OK", 1); } } else { $this->ajaxReturn("服务器繁忙,订单生成失败,请稍后再试!", "ERROR", 0); } }
function sendReply($reply, $mask, $url, $info) { $responder = new SmsSender($url); $responder->sms($reply, $mask, $info['password'], $info['appId'], $info['srcAddr'], $info['deliveryStatus'], $info['chrgAmnt'], $info['encoding'], $info['ver'], $info['binaryHeader']); }
public function book() { if ($_POST) { $token = $this->_get('token'); // 检查是否需要短信验证码 $enable_vcode = 0; $smsset = M('sms_set')->where(array('token' => $token))->find(); if (!empty($smsset)) { if (strpos($smsset['function'], 'vchotel') !== FALSE) { $enable_vcode = 1; } } $tel = $this->_post('tel'); $smsvcode = $this->_post('smsvcode'); if ($enable_vcode) { if (!SmsvcodeAction::verifyVCode($token, $tel, $smsvcode)) { // 验证码不匹配 echo '{"success":0,"msg":"请输入正确的短信验证码。"}'; exit; } } $data['wecha_id'] = $this->_post('wecha_id'); $data['book_people'] = $this->_post('truename'); $data['remarks'] = $this->_post('remarks'); $data['tel'] = $this->_post('tel'); $data['book_num'] = $this->_post('nums'); $data['book_time'] = strtotime($this->_post('dateline')); $data['book_lefttime'] = strtotime($this->_post('leftdateline')); $id = $this->_post('id'); $data['room_type'] = $this->_post('roomtype'); $data['order_status'] = 3; $data['hid'] = $this->_get('hid'); $data['token'] = $this->_get('token'); $data['submit_time'] = time(); $data['sn'] = $this->get_order_sn(); $data['room_id'] = $_POST['room_id']; // $data['payment'] = $_POST['payment']; $price = M('Hotel_room')->where(array('id' => $id, 'token' => $data['token'], 'hid' => $data['hid'], 'status' => 1))->find(); //判断库存 if ($price['open_inventory'] == 1 && $price['inventory'] < $data['book_num']) { echo '{"success":0,"msg":"库存不足,请联系商家!"}'; exit; } $day = round(($data['leftbook_time'] - $data['book_time']) / 3600 / 24); if ($day <= 0) { $day = 1; } $data['price'] = $day * $price['yhprice'] * $data['book_num']; // $data['prepayment'] = $day* $price['sale_price'] * $data['book_num']; $data['text_cols'] = serialize($this->_post('text_cols')); $data['select_cols'] = serialize($this->_post('select_cols')); $order = M('Hotel_order')->data($data)->add(); //若下单成功则减库存 if ($order) { $booking['inventory'] = $price['inventory'] - $data['book_num']; M('Hotel_room')->where(array('id' => $id, 'token' => $data['token']))->data($booking)->save(); } if ($order) { include LIB_PATH . 'Action/SmsSender.class.php'; $smsSender = new SmsSender(); $re = $smsSender->notify($this->_get('token'), "dingdan", "您有一个新的微预订:来自" . $data['book_people'] . ",预订商品:" . $data['room_type'] . ",预订时间:" . $this->_post('dateline')); echo '{"success":1,"msg":"恭喜,预定成功。"}'; } else { echo '{"success":0,"msg":"请从新预定。"}'; } exit; } }
public function book() { if ($_POST['action'] == 'book') { $token = $this->_get('token'); // 检查是否需要短信验证码 $enable_vcode = 0; $smsset = M('sms_set')->where(array('token' => $token))->find(); if (!empty($smsset)) { if (strpos($smsset['function'], 'vcdindan') !== FALSE) { $enable_vcode = 1; } } $tel = $this->_post('tel'); $smsvcode = $this->_post('smsvcode'); if ($enable_vcode) { if (!SmsvcodeAction::verifyVCode($token, $tel, $smsvcode)) { // 验证码不匹配 echo '{"success":0,"msg":"请输入正确的短信验证码。"}'; exit; } } $data['wecha_id'] = $this->_post('wecha_id'); $data['book_people'] = $this->_post('truename'); $data['remarks'] = $this->_post('remarks'); $data['tel'] = $this->_post('tel'); $data['book_num'] = $this->_post('nums'); $data['book_time'] = strtotime($this->_post('dateline')); $id = $this->_post('id'); $data['room_type'] = $this->_post('roomtype'); $data['order_status'] = 3; $data['hid'] = $this->_get('hid'); $data['booking_id'] = $this->_post('id'); $data['token'] = $this->_get('token'); $data['submit_time'] = time(); $data['sn'] = $this->get_order_sn(); $price = M('Host_list_add')->where(array('id' => $id, 'token' => $data['token'], 'hid' => $data['hid'], 'status' => 1))->find(); //判断库存 if ($price['open_inventory'] == 1 && $price['inventory'] < $data['book_num']) { echo '{"success":0,"msg":"库存不足,请联系商家!"}'; exit; } $data['price'] = $price['yhprice'] * $data['book_num']; $data['text_cols'] = serialize($this->_post('text_cols')); $data['select_cols'] = serialize($this->_post('select_cols')); $order = M('Host_order')->data($data)->add(); //若下单成功则减库存 if ($price['open_inventory'] == 1 && $order) { $booking['inventory'] = $price['inventory'] - $data['book_num']; M('host_list_add')->where(array('id' => $id, 'token' => $data['token']))->data($booking)->save(); } if ($order) { include LIB_PATH . 'Action/SmsSender.class.php'; $smsSender = new SmsSender(); $notify_tmpl = C('host_notify'); $smsContent = ''; if (isset($notify_tmpl)) { $smsContent = str_replace("#merchant#", '领众科技', $notify_tmpl); $smsContent = str_replace("#book_people#", $data['book_people'], $smsContent); $smsContent = str_replace("#tel#", $data['tel'], $smsContent); $smsContent = str_replace("#room_type#", $data['room_type'], $smsContent); $smsContent = str_replace("#book_num#", $data['book_num'], $smsContent); $smsContent = str_replace("#dateline#", $this->_post('dateline'), $smsContent); $smsContent = str_replace("#price#", $data['price'], $smsContent); $smsContent = str_replace("#sn#", $data['sn'], $smsContent); } if ($smsContent != '') { $re = $smsSender->notify($this->_get('token'), "dingdan", $smsContent); } echo '{"success":1,"msg":"恭喜,预定成功。"}'; } else { echo '{"success":0,"msg":"系统忙,请稍后预定。"}'; } exit; } }
/** * @covers \SmsZilla\SmsSender::__construct */ public function testConstructorParams() { $reference = new \SmsZilla\Adapter\FileAdapter(['store_path' => __DIR__]); $result = new SmsSender(new \SmsZilla\Adapter\FileAdapter(), ['store_path' => __DIR__]); $this->assertEquals($reference, $result->getAdapter()); }
$address = $receiver->getAddress(); // get the sender's address $requestId = $receiver->getRequestID(); // get the request ID $applicationId = $receiver->getApplicationId(); // get application ID $encoding = $receiver->getEncoding(); // get the encoding value $version = $receiver->getVersion(); // get the version logFile("[ content={$content}, address={$address}, requestId={$requestId}, applicationId={$applicationId}, encoding={$encoding}, version={$version} ]"); $responseMsg; //your logic goes here...... $responseMsg = "You are not in the disaster area.You are in uva wellassa"; // Create the sender object server url $sender = new SmsSender("https://api.dialog.lk/sms/send"); //sending a one message $applicationId = "APP_018053"; $encoding = "0"; $version = "1.0"; $password = "******"; $destinationAddresses = array($address); $res = $sender->sms($responseMsg, $destinationAddresses, $password, $applicationId, $encoding, $version); } catch (SmsException $ex) { //throws when failed sending or receiving the sms error_log("ERROR: {$ex->getStatusCode()} | {$ex->getStatusMessage()}"); } /* BMI logic function **/ function bmiLogicHere($split)