コード例 #1
0
 public function service()
 {
     if (isset($_REQUEST['number'])) {
         $number = $this->secure($_REQUEST['number']);
         $sentSmsManager = SentSmsManager::getInstance($this->config, $this->args);
         $number = SentSmsManager::getValidArmenianNumber($number);
         if ($number == null) {
             $jsonArr = array('status' => "err", "errText" => "Invalid cell phone number!", 'number_valid' => "false");
             echo json_encode($jsonArr);
             return false;
         }
         $company = $this->getCustomer();
         $lastSmsValidationCode = substr(uniqid(rand(), true), 0, 6);
         $companyManager = CompanyManager::getInstance($this->config, $this->args);
         $companyManager->setLastSmsValidationCode($company->getId(), $lastSmsValidationCode);
         $sentSmsManager->sendSmsToArmenia($number, $lastSmsValidationCode);
         $jsonArr = array('status' => "ok", 'number_valid' => "true");
         echo json_encode($jsonArr);
         return true;
     } elseif (isset($_REQUEST['code'])) {
         $code = $this->secure($_REQUEST['code']);
         $company = $this->getCustomer();
         $c = $company->getLastSmsValidationCode();
         if ($code == $c) {
             $jsonArr = array('status' => "ok", 'code_valid' => "true");
             echo json_encode($jsonArr);
             return true;
         } else {
             $jsonArr = array('status' => "err", "errText" => "Invalid sms code!", 'code_valid' => "false");
             echo json_encode($jsonArr);
             return false;
         }
     }
 }
コード例 #2
0
 public function load()
 {
     $this->addParam('pcstore_contact_number', $this->getCmsVar('pcstore_sales_phone_number'));
     $customer = $this->getCustomer();
     $sms_sent = false;
     if (isset($_REQUEST['co_code'])) {
         $code = $this->secure($_REQUEST['co_code']);
         $this->addParam('co_code', $code);
         if ($customer->getLastSmsValidationCode() === $code) {
             $this->addParam('order_confirmed', true);
         } else {
             $this->addParam('errorMessage', 223);
         }
         $this->addParam('sms_sent', true);
         return true;
     }
     $cell_phone_editable = $this->secure($_REQUEST['cho_do_shipping']) != 1;
     if ($cell_phone_editable) {
         $this->addParam('infoMessage', 362);
     }
     $cell_phone_number = $this->getPhoneNumberToSendSMS();
     $validNumber = null;
     if ($cell_phone_number != null) {
         $validNumber = SentSmsManager::getValidArmenianNumber($cell_phone_number);
     }
     if ($validNumber != null) {
         $lastSmsValidationCode = substr(uniqid(rand(), true), 0, 6);
         if ($this->getUserLevel() == UserGroups::$USER) {
             $userManager = UserManager::getInstance($this->config, $this->args);
             $userManager->setLastSmsValidationCode($customer->getId(), $lastSmsValidationCode);
         } elseif ($this->getUserLevel() == UserGroups::$COMPANY) {
             $companyManager = CompanyManager::getInstance($this->config, $this->args);
             $companyManager->setLastSmsValidationCode($customer->getId(), $lastSmsValidationCode);
         }
         $sentSmsManager = SentSmsManager::getInstance($this->config, $this->args);
         $sentSmsManager->sendSmsToArmenia($validNumber, $lastSmsValidationCode);
         $this->addParam('infoMessage', "`319` ({$validNumber})");
         $this->addParam('validNumber', "(" . $validNumber . ")");
         $this->addParam('sms_sent', true);
     } else {
         if (!empty($cell_phone_number)) {
             $this->addParam('errorMessage', 318);
         }
         $this->addParam('cell_phone_number', $cell_phone_number);
         if (!$cell_phone_editable) {
             $this->addParam('infoMessage', 387);
         }
     }
     $this->addParam('cell_phone_editable', $cell_phone_editable);
 }
コード例 #3
0
 public function service()
 {
     $sentSmsManager = SentSmsManager::getInstance($this->config, $this->args);
     $smsGatewaysManager = SmsGatewaysManager::getInstance($this->config, $this->args);
     $phoneNumber = $this->secure($_REQUEST['phone_number']);
     $gatewayId = $this->secure($_REQUEST['gateway']);
     $gateway = $smsGatewaysManager->selectByPK($gatewayId);
     if (!isset($gateway)) {
         $this->error(array('message' => 'Wrong gateway!'));
     }
     $message = $_REQUEST['message'];
     if (empty($message)) {
         $this->error(array('message' => 'Message can not be empty!'));
     }
     $validNumber = SentSmsManager::getValidArmenianNumber($phoneNumber);
     if (!isset($validNumber)) {
         $this->error(array('message' => 'Invalid phone number!'));
     }
     $sentSmsManager->sendSmsToArmenia($phoneNumber, $message, $gateway->getName());
     $this->ok();
 }