Exemple #1
0
 protected function checkCaptcha()
 {
     $lastSendStamp = BOL_PreferenceService::getInstance()->getPreferenceValue('mailbox_create_conversation_stamp', $this->userId);
     $displayCaptcha = BOL_PreferenceService::getInstance()->getPreferenceValue('mailbox_create_conversation_display_capcha', $this->userId);
     if (!$displayCaptcha && $lastSendStamp + CreateConversationForm::DISPLAY_CAPTCHA_TIMEOUT > time()) {
         BOL_PreferenceService::getInstance()->savePreferenceValue('mailbox_create_conversation_display_capcha', true, $this->userId);
         $displayCaptcha = true;
     }
     $captcha = $this->getElement('captcha');
     $captcha->setRequired();
     return !$displayCaptcha || $captcha->isValid() && UTIL_Validator::isCaptchaValid($captcha->getValue());
 }
Exemple #2
0
 public function ajaxResponder()
 {
     if (empty($_POST["command"]) || !OW::getRequest()->isAjax()) {
         throw new Redirect404Exception();
     }
     $command = (string) $_POST["command"];
     switch ($command) {
         case 'checkCaptcha':
             $value = $_POST["value"];
             $result = UTIL_Validator::isCaptchaValid($value);
             if ($result) {
                 OW::getSession()->set('securimage_code_value', $value);
             }
             echo json_encode(array('result' => $result));
             break;
     }
     exit;
 }
Exemple #3
0
 public function ajaxResponder()
 {
     if (empty($_POST["command"]) || !OW::getRequest()->isAjax()) {
         throw new Redirect404Exception();
     }
     $command = (string) $_POST["command"];
     switch ($command) {
         case 'checkCaptcha':
             $value = $_POST["value"];
             $result = UTIL_Validator::isCaptchaValid($value);
             if ($result) {
                 OW::getSession()->set('securimage_code_value', $value);
             }
             $result === FALSE ? OW::getEventManager()->trigger(new OW_Event(ANTIBRUTEFORCE_BOL_Service::EVENT_AUTHENTICATE_FAIL)) : NULL;
             echo json_encode(array('result' => $result));
             break;
     }
     exit;
 }
 /**
  * Creates new conversation
  *
  * @param int $initiatorId
  * @param int $interlocutorId
  */
 public function process($initiatorId, $interlocutorId)
 {
     if (OW::getRequest()->isAjax()) {
         if (empty($initiatorId) || empty($interlocutorId)) {
             echo json_encode(array('result' => false));
             exit;
         }
         $isAuthorized = OW::getUser()->isAuthorized('mailbox', 'send_message');
         if (!$isAuthorized) {
             echo json_encode(array('result' => 'permission_denied'));
             exit;
         }
         // credits check
         $eventParams = array('pluginKey' => 'mailbox', 'action' => 'send_message', 'extra' => array('senderId' => $initiatorId, 'recipientId' => $interlocutorId));
         $credits = OW::getEventManager()->call('usercredits.check_balance', $eventParams);
         if ($credits === false) {
             $error = OW::getEventManager()->call('usercredits.error_message', $eventParams);
             echo json_encode(array('result' => 'permission_denied', 'message' => $error));
             exit;
         }
         $captcha = $this->getElement('captcha');
         $captcha->setRequired();
         if ($this->displayCapcha && (!$captcha->isValid() || !UTIL_Validator::isCaptchaValid($captcha->getValue()))) {
             echo json_encode(array('result' => 'display_captcha'));
             exit;
         }
         $values = $this->getValues();
         $conversationService = MAILBOX_BOL_ConversationService::getInstance();
         $uploadFiles = MAILBOX_BOL_FileUploadService::getInstance();
         $conversation = $conversationService->createConversation($initiatorId, $interlocutorId, htmlspecialchars($values['subject']), $values['message']);
         $message = $conversationService->getLastMessages($conversation->id);
         $fileDtoList = $uploadFiles->findUploadFileList($values['attachments']);
         foreach ($fileDtoList as $fileDto) {
             $attachmentDto = new MAILBOX_BOL_Attachment();
             $attachmentDto->messageId = $message->initiatorMessageId;
             $attachmentDto->fileName = htmlspecialchars($fileDto->fileName);
             $attachmentDto->fileSize = $fileDto->fileSize;
             $attachmentDto->hash = $fileDto->hash;
             if ($conversationService->fileExtensionIsAllowed(UTIL_File::getExtension($fileDto->fileName))) {
                 $conversationService->addAttachment($attachmentDto, $fileDto->filePath);
             }
             $uploadFiles->deleteUploadFile($fileDto->hash, $fileDto->userId);
         }
         // credits track
         if ($credits === true) {
             OW::getEventManager()->call('usercredits.track_action', $eventParams);
         }
         BOL_PreferenceService::getInstance()->savePreferenceValue('mailbox_create_conversation_display_capcha', false, OW::getUser()->getId());
         $timestamp = 0;
         if ($this->displayCapcha == false) {
             $timestamp = time();
         }
         BOL_PreferenceService::getInstance()->savePreferenceValue('mailbox_create_conversation_stamp', $timestamp, OW::getUser()->getId());
         echo json_encode(array('result' => true));
         exit;
     }
 }
Exemple #5
0
 public function checkValue($value)
 {
     return UTIL_Validator::isCaptchaValid($value);
 }