/** * @brief 发送短信 * @param string $mobile 手机号 * @param string $content 短信内容 * @param int $delay 延迟设置 * @return success or fail */ public static function send($mobile, $content, $delay = 1) { if (self::$smsInstance == null) { $platform = self::getPlatForm(); switch ($platform) { case "zhutong": $classFile = IWeb::$app->getBasePath() . 'plugins/hsms/zhutong.php'; require $classFile; self::$smsInstance = new zhutong(); break; default: $classFile = IWeb::$app->getBasePath() . 'plugins/hsms/haiyan.php'; require $classFile; self::$smsInstance = new haiyan(); } } if (IValidate::mobi($mobile) && $content) { $ip = IClient::getIp(); if ($ip) { if ($delay == 1) { $mobileKey = md5($ip); $sendTime = ISession::get($mobileKey); if ($sendTime && time() - $sendTime < 60) { return false; } ISession::set($mobileKey, time()); } return self::$smsInstance->send($mobile, $content); } } return false; }
/** * @brief 发送短信 * @param string $mobile * @param string $content * @return success or fail */ public static function send($mobile, $content) { if (self::$smsInstance == null) { $platform = self::getPlatForm(); switch ($platform) { case "zhutong": $classFile = IWeb::$app->getBasePath() . 'plugins/hsms/zhutong.php'; require $classFile; self::$smsInstance = new zhutong(); break; default: $classFile = IWeb::$app->getBasePath() . 'plugins/hsms/haiyan.php'; require $classFile; self::$smsInstance = new haiyan(); } } return self::$smsInstance->send($mobile, $content); }