Example #1
0
 public function sendSms($params = array())
 {
     //extract($params);
     $type = $params['type'];
     $mobile = $params['mobile'];
     if (isset($type) && isset($mobile)) {
         // $type =='register','forget',
         $num = $this->getrandstr();
         $cache = Yii::app()->cache;
         $cache->hset($mobile, $type, $num);
         $sms = new Sms();
         $result = $sms->send($mobile, '【Urtime】您的注册验证码是:' . $num . '.请完成注册', true);
         $res = $sms->execResult($result);
         if ($res[1] == 0) {
             // echo '发送成功';
             $ret = $this->notice('OK', 0, '', $result);
         } else {
             //echo "发送失败{$result[1]}";
             $ret = $this->notice('ERR', 307, '', $result);
         }
     } else {
         $ret = $this->notice('ERR', 301, '', array('mobile' => isset($mobile) ? $mobile : 0, 'type' => isset($type) ? $type : ''));
     }
     return $ret;
 }
Example #2
0
 public function actionDelete()
 {
     $id = $this->_get('id');
     $user_id = $this->_get('user_id');
     $obj = User::model()->findByPk($user_id);
     if ($id && Report::model()->deleteByPk($id)) {
         $mobile = $obj->mobile;
         if (isset($mobile) && $mobile) {
             // $type =='register','forget',
             $sms = new Sms();
             $result = $sms->sendSMS($mobile, '您好,你的反馈我们已近收到,我们将尽快处理,Urtime谢谢你的宝贵意见', 'true');
             $result = $sms->execResult($result);
             if ($result[1] == 0) {
                 // echo '发送成功';
                 Yii::app()->user->setFlash('send', 1);
                 $this->redirect(array('report/index'));
             } else {
                 //echo "发送失败{$result[1]}";
                 Yii::app()->user->setFlash('send', 0);
                 $this->redirect(array('report/index'));
             }
         } else {
             Yii::app()->user->setFlash('report', 0);
             $this->redirect(array('report/index'));
         }
     } else {
         Yii::app()->user->setFlash('report', 0);
         $this->redirect(array('report/index'));
     }
 }