public function actionBackgroundmsg($phone_nos,$msg) { $count = count($phone_nos); Yii::import('application.extensions.runactions.components.ERunActions'); //require_once "Mail.php"; if (ERunActions::runBackground()) { $output = implode(",",$phone_nos); $smsobj=new SmsApi; $r=$smsobj->sendsms($output,$msg); if(preg_match('/alert_/',$r)) echo 'sent'; } else { $this->redirect(array('admin')); } }
public function sendSMSCheckNO() { $phone = $this->post('phone'); $code = randCode(); $redis_key = $_SESSION['uid'] . ':sms'; $code_key = $_SESSION['uid'] . ':sms_code'; if (strlen($code) != 4) { echo '短信发送异常'; exit; } if (mobileCheck($phone)) { echo '手机号码不对'; exit; } //限制发送时间 if ($this->cacheKV()->exists($redis_key)) { echo '请稍后再发送'; exit; } $this->cacheKV()->setex($redis_key, $this->kvExTime(), 1); //发送成功标识,用来重发 Doo::loadClassAt('SmsApi', 'default'); $clapi = new SmsApi(); $result = $clapi->sendSMS($phone, '您好,您的验证码是 ' . $code . ' <微微乐>', 'true'); $result = $clapi->execResult($result); if ($result[1] == 0) { echo '发送成功'; $this->cacheKV()->setex($code_key, $this->kvExTime() * 10, $code); //10分钟内有效 } else { echo "发送失败{$result[1]}"; } exit; }
public function actionSend_sms() { if (Yii::app()->user->isGuest) { Yii::app()->user->loginRequired(); } $sms = new Sendsms(); if (isset($_POST['Sendsms'])) { $sms->attributes = $_POST['Sendsms']; $smsobj = new SmsApi(); $user_id->user_organization_id; $r = $smsobj->sendsms($sms->phone_no, $sms->message, $org); if (preg_match('/alert_/', $r)) { echo 'sent'; } } $this->render('send_sms', array('model' => $sms)); }
public function actionForgotpassword() { $this->layout = 'login_layout'; $model = new LoginForm(); if (isset($_POST['LoginForm'])) { $model->attributes = $_POST['LoginForm']; $user_id = User::model()->findByAttributes(array('user_organization_email_id' => $model->username)); //var_dump($user_id); exit; if (!empty($user_id)) { $random = substr(number_format(time() * rand(), 0, '', ''), 0, 10); $phone_no = 0; $check_user = StudentTransaction::model()->find('student_transaction_user_id =' . $user_id->user_id); if (!empty($check_user)) { $phone_no = StudentInfo::model()->findByPk($check_user->student_transaction_student_id)->student_mobile_no; } $check_user_emp = EmployeeTransaction::model()->find('employee_transaction_user_id =' . $user_id->user_id); if (!empty($check_user_emp)) { $phone_no = EmployeeInfo::model()->findByPk($check_user_emp->employee_transaction_employee_id)->employee_private_mobile; } if ($phone_no != 0) { $smsobj = new SmsApi(); $org = $user_id->user_organization_id; $r = $smsobj->sendsms($phone_no, $random, $org); if (preg_match('/alert_/', $r)) { $update_user = User::model()->findByPk($user_id->user_id); $update_user->user_password = md5($random . $random); $update_user->save(); $this->redirect(array('smsNotification', 'status' => 'success')); } else { $this->redirect(array('smsNotification', 'status' => 'getway-error')); } } $this->redirect(array('smsNotification', 'status' => 'user_not_exist')); } else { $this->redirect(array('smsNotification', 'status' => 'user_not_exist')); } } $this->render('forgotpassword', array('model' => $model)); }