public function sendSMS()
 {
     $user = Account::findOne(['phone' => $this->phone]);
     if ($user) {
         $passToken = $user->generatePasswordResetToken()->getPasswordResetToken();
         $user->setScenario('reset-password');
         if ($user->save()) {
             $mes = 'only3.ru Код:' . $passToken;
             $phoneClient = preg_replace('/[^0-9]/', '', $this->phone);
             $login = '******';
             $password = '******';
             $phone = $phoneClient;
             $from = 'only3';
             $mes = iconv("UTF-8", "WINDOWS-1251", $mes);
             $msg = urlencode($mes);
             $checksumm = md5($login . md5($password) . $phone);
             $res = file_get_contents("http://sms48.ru/send_sms.php?login={$login}&to={$phone}&msg={$msg}&from={$from}&check2={$checksumm}");
             if ($res == 1) {
                 //sms was sending
                 return $user->id;
             }
         }
     }
     return false;
 }
示例#2
0
 /**
  * @param $id
  * @return string
  * @throws NotFoundHttpException
  */
 public function actionOurCars($slug_url)
 {
     $accountModel = Account::findOne(['slug_url' => $slug_url]);
     if (empty($accountModel)) {
         $this->setNotFoundHttpException();
     }
     $params['AutoSearch']['account_id'] = $accountModel->id;
     $this->title = "Автопрокат - " . $accountModel->username;
     $searchModel = new AutoSearch();
     $searchModel->setScenario('salon-cars');
     $dataProvider = $searchModel->search($params);
     return $this->render('ourCars', ['dataProvider' => $dataProvider, 'accountModel' => $accountModel]);
 }
示例#3
0
 /**
  * Resets password.
  *
  * @param string $token
  * @return mixed
  * @throws BadRequestHttpException
  */
 public function actionResetPassword($id)
 {
     $user = Account::findOne($id);
     $model = new ResetPasswordForm($user);
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if (!$user->findByPasswordResetToken($model->password_reset_token)) {
             $model->addError('password_reset_token');
         } else {
             $model->resetPassword();
             Yii::$app->session->setFlash('success', 'Смена пароля была произведена успешно');
             Yii::$app->user->login($user);
             return $this->redirect(Yii::$app->getUser()->getReturnUrl($this->goHome()));
         }
     }
     return $this->render('resetPassword', ['model' => $model]);
     /*
     try {
         $model = new ResetPasswordForm($token);
     } catch (InvalidParamException $e) {
         throw new BadRequestHttpException($e->getMessage());
     }
     
     if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) {
         Yii::$app->session->setFlash('success', 'New password was saved.');
     
         return $this->goHome();
     }
     
     return $this->render('resetPassword', [
         'model' => $model,
     ]);
     */
 }
示例#4
0
 /**
  * Returns the account associated with the value of the login attribute.
  *
  * @return Account model instance.
  */
 public function getAccount()
 {
     if ($this->_account === null) {
         $this->_account = Account::findOne([Module::getInstance()->phoneAttribute => $this->phone]);
     }
     return $this->_account;
 }
示例#5
0
 public function actionCheckis()
 {
     $secret_key = "jcJJmKzO5tJnZRTRLEj/N3kM";
     $sha1 = sha1($_POST['notification_type'] . '&' . $_POST['operation_id'] . '&' . $_POST['amount'] . '&643&' . $_POST['datetime'] . '&' . $_POST['sender'] . '&' . $_POST['codepro'] . '&' . $secret_key . '&' . $_POST['label']);
     if ($sha1 != $_POST['sha1_hash']) {
         exit;
     }
     if ($_POST['label'] != NULL) {
         $ac_id = intval($_POST['label']);
         $ac = Account::findOne(['id' => $ac_id]);
         $ac->balance = $ac->balance + intval($_POST['withdraw_amount']);
         $ac->save();
         $subject = "Оплата баланса";
         $subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
         $headers = "From: auto.only3.ru <*****@*****.**>\r\nContent-type: text/html; charset=utf-8 \r\n";
         $mes = "Выполнено пополнение баланса автопроката - '" . $ac->username . "' на сумму <b>" . $_POST['withdraw_amount'] . " рублей</b>.<br> Текущий баланс автопроката: " . $ac->balance . " рублей";
         mail('*****@*****.**', $subject, $mes, $headers);
         mail('*****@*****.**', $subject, $mes, $headers);
         exit;
     }
 }
示例#6
0
 public static function createUserDataToSalon($client_id, $salon_id)
 {
     $Account = Account::findOne($client_id);
     $UserData = new UsersData();
     $UserData->loadDefaultValues();
     $UserData->setAttribute('account_id', $Account->id);
     $UserData->setAttribute('salon_account_id', $salon_id);
     $UserData->setAttribute('name', $Account->username);
     $UserData->setAttribute('phone', $Account->phone);
     $UserData->save();
     return $UserData;
 }
示例#7
0
 public function afterDelete()
 {
     $Account = Account::findOne(['id' => $this->account_id]);
     $Account->setAttribute('count_autos', self::getAccountCountAutos($this->account_id));
     $Account->save();
     return parent::afterDelete();
 }
示例#8
0
 public static function createUserData($client_id)
 {
     $Account = Account::findOne($client_id);
     if ($Account) {
         $UserData = new UsersData();
         return $UserData::createUserDataFromAccount($client_id);
     } else {
         return false;
     }
 }
 protected function findModel($id)
 {
     if (($model = Account::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }