示例#1
0
文件: hsms.php 项目: herrify/iwebshop
 /**
  * @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;
 }
示例#2
0
 /**
  * @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);
 }