<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\Sms; use ModStart\Core\Exception\BizException; use ModStart\Core\Input\Response; use Module\Vendor\Provider\SmsSender\SmsSenderProvider; class SmsUtil { public static function calcNumber($eTwx_) { return ceil(mb_strlen($eTwx_) / 67); } public static function parseContent($H09n_, $XoEfM = array()) { goto reTAT; J3K05: $rh9_l = array(); goto YexVe; E2KKo: return str_replace($In71j, $rh9_l, $H09n_); goto HtIkD; YexVe: foreach ($XoEfM as $JdFJR => $PSYn9) { $In71j[] = '{' . $JdFJR . '}'; $rh9_l[] = $PSYn9; } goto E2KKo; reTAT: $In71j = array(); goto J3K05; HtIkD: } public static function parseTemplateParam($H09n_) { preg_match_all('/\\{(.*?)\\}/', $H09n_, $Qie0V); return $Qie0V[1]; } public static function replaceTemplate($H09n_, $wEfav = '#') { goto BdH9t; dB0rg: return $H09n_; goto c3_mO; HUVOT: foreach ($KJ3xr as $PSYn9) { if (is_string($wEfav)) { $H09n_ = str_replace('{' . $PSYn9 . '}', $wEfav . $PSYn9 . $wEfav, $H09n_); } else { $H09n_ = str_replace('{' . $PSYn9 . '}', call_user_func($wEfav, $PSYn9), $H09n_); } } goto dB0rg; BdH9t: $KJ3xr = self::parseTemplateParam($H09n_); goto HUVOT; c3_mO: } public static function templates() { $CzHKS = array(array('name' => 'verify', 'title' => '验证码', 'desc' => '验证码模板变量为 code')); return $CzHKS; } public static function send($lF49t, $H09n_, $JKXDQ = array()) { goto dTwmn; dTwmn: $sefXk = app()->config->get('SmsSenderProvider'); goto kjsKU; ADF6M: $Gs3Xd = SmsSenderProvider::get($sefXk)->send($lF49t, $H09n_, $JKXDQ); goto pbosY; kjsKU: BizException::throwsIfEmpty('短信发送未设置', $sefXk); goto ADF6M; pbosY: BizException::throwsIfResponseError($Gs3Xd); goto l5aSs; l5aSs: return Response::generateSuccess(); goto bVYDk; bVYDk: } }