<?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($MPmfx) { return ceil(mb_strlen($MPmfx) / 67); } public static function parseContent($XPQ0m, $Zrrbp = array()) { goto iN1p8; EFjEQ: foreach ($Zrrbp as $MFVkb => $YxV2x) { $OeEXH[] = '{' . $MFVkb . '}'; $pYc6B[] = $YxV2x; } goto wtUWn; gFVRL: $pYc6B = array(); goto EFjEQ; wtUWn: return str_replace($OeEXH, $pYc6B, $XPQ0m); goto vBtaD; iN1p8: $OeEXH = array(); goto gFVRL; vBtaD: } public static function parseTemplateParam($XPQ0m) { preg_match_all('/\\{(.*?)\\}/', $XPQ0m, $Uy2Nw); return $Uy2Nw[1]; } public static function replaceTemplate($XPQ0m, $iM85V = '#') { goto dQi1x; B4VsK: return $XPQ0m; goto gwJV7; dQi1x: $EPwwc = self::parseTemplateParam($XPQ0m); goto GusNP; GusNP: foreach ($EPwwc as $YxV2x) { if (is_string($iM85V)) { $XPQ0m = str_replace('{' . $YxV2x . '}', $iM85V . $YxV2x . $iM85V, $XPQ0m); } else { $XPQ0m = str_replace('{' . $YxV2x . '}', call_user_func($iM85V, $YxV2x), $XPQ0m); } } goto B4VsK; gwJV7: } public static function templates() { $mtgPx = array(array('name' => 'verify', 'title' => '验证码', 'desc' => '验证码模板变量为 code')); return $mtgPx; } public static function send($cz6lT, $XPQ0m, $YxsLg = array()) { goto FeUvE; mE9KJ: BizException::throwsIfEmpty('短信发送未设置', $O9Vtg); goto JoNAe; qP66f: BizException::throwsIfResponseError($Ecj99); goto DzF2a; DzF2a: return Response::generateSuccess(); goto OEp0N; FeUvE: $O9Vtg = app()->config->get('SmsSenderProvider'); goto mE9KJ; JoNAe: $Ecj99 = SmsSenderProvider::get($O9Vtg)->send($cz6lT, $XPQ0m, $YxsLg); goto qP66f; OEp0N: } }