Example #1
0
 /**
  * Initializes handling for processing a request callback.
  *
  * @param Zend_Controller_Request_Http $request
  */
 public function initCallbackHandling(Zend_Controller_Request_Http $request)
 {
     $this->_request = $request;
     $this->_input = new XenForo_Input($request);
     $this->_filtered = $this->_input->filter(array('test_ipn' => XenForo_Input::UINT, 'business' => XenForo_Input::STRING, 'receiver_email' => XenForo_Input::STRING, 'txn_type' => XenForo_Input::STRING, 'txn_id' => XenForo_Input::STRING, 'parent_txn_id' => XenForo_Input::STRING, 'mc_currency' => XenForo_Input::STRING, 'mc_gross' => XenForo_Input::UNUM, 'payment_status' => XenForo_Input::STRING, 'custom' => XenForo_Input::STRING, 'subscr_id' => XenForo_Input::STRING));
     $this->_paidContentModel = XenForo_Model::create('ThemeHouse_PayForContent_Model_PaidContent');
 }
Example #2
0
 /**
  * Initializes handling for processing a request callback.
  *
  * @param Zend_Controller_Request_Http $request
  */
 public function initCallbackHandling(Zend_Controller_Request_Http $request)
 {
     $this->_request = $request;
     $this->_input = new XenForo_Input($request);
     $this->_filtered = $this->_input->filter(array('test_ipn' => XenForo_Input::UINT, 'business' => XenForo_Input::STRING, 'txn_type' => XenForo_Input::STRING, 'txn_id' => XenForo_Input::STRING, 'mc_currency' => XenForo_Input::STRING, 'mc_gross' => XenForo_Input::UNUM, 'payment_status' => XenForo_Input::STRING, 'custom' => XenForo_Input::STRING));
     $this->_upgradeModel = XenForo_Model::create('XenForo_Model_UserUpgrade');
 }
 public function execute(array $deferred, array $data, $targetRunTime, &$status)
 {
     $inputHandler = new XenForo_Input($data);
     $input = $inputHandler->filter(array('batch' => XenForo_Input::UINT, 'start' => XenForo_Input::UINT, 'extra_data' => XenForo_Input::ARRAY_SIMPLE, 'delay' => XenForo_Input::UNUM, 'content_type' => XenForo_Input::STRING, 'delete_index' => XenForo_Input::UINT));
     if ($input['delay'] >= 0.01) {
         usleep($input['delay'] * 1000000);
     }
     /* @var $searchModel XenForo_Model_Search */
     $searchModel = XenForo_Model::create('XenForo_Model_Search');
     $searchContentTypes = $searchModel->getSearchContentTypes();
     $extraData = $input['extra_data'];
     if (!isset($extraData['content_types']) || !is_array($extraData['content_types'])) {
         if ($input['content_type'] && isset($searchContentTypes[$input['content_type']])) {
             $extraData['content_types'] = array($input['content_type']);
         } else {
             $extraData['content_types'] = array_keys($searchContentTypes);
         }
     }
     if (empty($extraData['current_type'])) {
         $extraData['current_type'] = array_shift($extraData['content_types']);
     }
     if (empty($extraData['type_start'])) {
         $extraData['type_start'] = 0;
     }
     $originalExtraData = $extraData;
     while (!isset($searchContentTypes[$extraData['current_type']])) {
         if (!$extraData['content_types']) {
             return false;
         }
         $extraData['current_type'] = array_shift($extraData['content_types']);
     }
     if ($input['delete_index']) {
         $source = XenForo_Search_SourceHandler_Abstract::getDefaultSourceHandler();
         $source->deleteIndex($input['content_type'] ? $input['content_type'] : null);
     }
     $dataHandler = false;
     $searchHandler = $searchContentTypes[$extraData['current_type']];
     if (class_exists($searchHandler)) {
         $dataHandler = XenForo_Search_DataHandler_Abstract::create($searchHandler);
         $indexer = new XenForo_Search_Indexer();
         $indexer->setIsRebuild(true);
         $nextStart = $dataHandler->rebuildIndex($indexer, $extraData['type_start'], $input['batch']);
         $indexer->finalizeRebuildSet();
     } else {
         $nextStart = false;
     }
     if ($nextStart === false) {
         // move on to next type
         $extraData['current_type'] = '';
         $extraData['type_start'] = 0;
     } else {
         $extraData['type_start'] = $nextStart;
     }
     $data = array('batch' => $input['batch'], 'start' => $input['start'] + 1, 'extra_data' => $extraData, 'delay' => $input['delay']);
     $actionPhrase = new XenForo_Phrase('rebuilding');
     $typePhrase = new XenForo_Phrase('search_index');
     $text = $dataHandler ? $dataHandler->getSearchContentTypePhrase() : new XenForo_Phrase($originalExtraData['current_type']);
     $status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, "{$text} " . XenForo_Locale::numberFormat($originalExtraData['type_start']));
     return $data;
 }
Example #4
0
 /**
  * @return XenForo_ControllerResponse_Redirect
  */
 public function actionSave()
 {
     $this->_assertPostOnly();
     $cameraId = $this->_input->filterSingle('camera_id', XenForo_Input::STRING);
     $newCameraId = $this->_input->filterSingle('new_camera_id', XenForo_Input::STRING);
     $dwInput = $this->_input->filter(array('camera_name' => XenForo_Input::STRING, 'camera_thumbnail' => XenForo_Input::STRING, 'camera_vendor' => XenForo_Input::STRING));
     $inputCameraData = $this->_input->filterSingle('camera_data', XenForo_Input::ARRAY_SIMPLE);
     $cameraDataHandler = new XenForo_Input($inputCameraData);
     $cameraData = $cameraDataHandler->filter(array('key_value' => array(XenForo_Input::STRING, array('array' => true)), 'key_name' => array(XenForo_Input::STRING, array('array' => true))));
     if (!empty($cameraData['key_value'])) {
         foreach ($cameraData['key_value'] as $_index => $_value) {
             if (isset($cameraData['key_name'][$_index])) {
                 $dwInput['camera_data'][$cameraData['key_name'][$_index]] = $_value;
             }
         }
     }
     $dw = XenForo_DataWriter::create('sonnb_XenGallery_DataWriter_Camera');
     if ($cameraId) {
         $dw->setExistingData($cameraId);
     }
     $dw->set('camera_id', $newCameraId);
     $dw->bulkSet($dwInput);
     $dw->save();
     return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink('gallery/cameras') . $this->getLastHash($dw->get('camera_id')));
 }
Example #5
0
 public function actionApiClientSave()
 {
     $this->_assertPostOnly();
     $client = null;
     $options = array();
     try {
         $client = $this->_bdApi_getClientOrError();
         $options = $client['options'];
     } catch (Exception $e) {
         // ignore
     }
     $dwInput = $this->_input->filter(array('name' => XenForo_Input::STRING, 'description' => XenForo_Input::STRING, 'redirect_uri' => XenForo_Input::STRING));
     $optionsInput = new XenForo_Input($this->_input->filterSingle('options', XenForo_Input::ARRAY_SIMPLE));
     $newOptions = array_merge($options, $optionsInput->filter(array('whitelisted_domains' => XenForo_Input::STRING, 'public_key' => XenForo_Input::STRING)));
     $dw = XenForo_DataWriter::create('bdApi_DataWriter_Client');
     if (!empty($client)) {
         $dw->setExistingData($client, true);
     } else {
         $dw->set('client_id', $this->_bdApi_getClientModel()->generateClientId());
         $dw->set('client_secret', $this->_bdApi_getClientModel()->generateClientSecret());
         $dw->set('user_id', XenForo_Visitor::getUserId());
     }
     $dw->bulkSet($dwInput);
     $dw->set('options', $newOptions);
     $dw->save();
     return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CREATED, XenForo_Link::buildPublicLink('account/api'));
 }
 /**
  * Initializes handling for processing a request callback.
  *
  * @param Zend_Controller_Request_Http $request
  */
 public function initCallbackHandling(Zend_Controller_Request_Http $request)
 {
     /**
      *  Collect the GET parameters from the request URL
      */
     $this->_request = $request;
     $this->_input = new XenForo_Input($request);
     $this->_filtered = $this->_input->filter(array('uid' => XenForo_Input::STRING, 'goodsid' => XenForo_Input::STRING, 'slength' => XenForo_Input::STRING, 'speriod' => XenForo_Input::STRING, 'type' => XenForo_Input::STRING, 'sig' => XenForo_Input::STRING, 'ref' => XenForo_Input::STRING, 'sign_version' => XenForo_Input::STRING, 'custom' => XenForo_Input::STRING));
     $this->_upgradeModel = XenForo_Model::create('XenForo_Model_UserUpgrade');
     $this->_bdUpgradeModel = XenForo_Model::create('bdPaygate_Model_Processor');
 }
Example #7
0
 public static function getJokePollInput(XenForo_Input $controllerInput)
 {
     $input['poll'] = $controllerInput->filterSingle('poll', XenForo_Input::ARRAY_SIMPLE);
     $pollInputHandler = new XenForo_Input($input['poll']);
     if (isset($input['poll']['joke'])) {
         $jokePollInputHandler = new XenForo_Input($input['poll']['joke']);
         $jokePollInput = $jokePollInputHandler->filter(array('first_choice' => XenForo_Input::UINT));
     } else {
         $jokePollInput = array();
     }
     return $jokePollInput;
 }
Example #8
0
 /**
  * Rebuilds the data.
  *
  * @see XenForo_CacheRebuilder_Abstract::rebuild()
  */
 public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
 {
     $inputHandler = new XenForo_Input($options);
     $input = $inputHandler->filter(array('batch' => XenForo_Input::UINT, 'start' => XenForo_Input::UINT, 'extra_data' => XenForo_Input::ARRAY_SIMPLE, 'delay' => XenForo_Input::UNUM));
     if ($input['delay'] >= 0.01) {
         usleep($input['delay'] * 1000000);
     }
     /* @var $searchModel XenForo_Model_Search */
     $searchModel = XenForo_Model::create('XenForo_Model_Search');
     $searchContentTypes = $searchModel->getSearchContentTypes();
     // TODO: potentially look at truncating the table (user option?)
     $extraData = $input['extra_data'];
     if (!isset($extraData['content_types']) || !is_array($extraData['content_types'])) {
         $extraData['content_types'] = array_keys($searchContentTypes);
     }
     if (empty($extraData['current_type'])) {
         $extraData['current_type'] = array_shift($extraData['content_types']);
     }
     if (empty($extraData['type_start'])) {
         $extraData['type_start'] = 0;
     }
     $originalExtraData = $extraData;
     while (!isset($searchContentTypes[$extraData['current_type']])) {
         if (!$extraData['content_types']) {
             return true;
         }
         $extraData['current_type'] = array_shift($extraData['content_types']);
     }
     $searchHandler = $searchContentTypes[$extraData['current_type']];
     $dataHandler = XenForo_Search_DataHandler_Abstract::create($searchHandler);
     $indexer = new XenForo_Search_Indexer();
     $indexer->setIsRebuild(true);
     $nextStart = $dataHandler->rebuildIndex($indexer, $extraData['type_start'], $input['batch']);
     $indexer->finalizeRebuildSet();
     if ($nextStart === false) {
         // move on to next type
         $extraData['current_type'] = '';
         $extraData['type_start'] = 0;
     } else {
         $extraData['type_start'] = $nextStart;
     }
     $options = array('batch' => $input['batch'], 'start' => $input['start'] + 1, 'extra_data' => $extraData, 'delay' => $input['delay']);
     $detailedMessage = "({$originalExtraData['current_type']} " . XenForo_Locale::numberFormat($originalExtraData['type_start']) . ")";
     return 1;
 }
Example #9
0
 public function actionUpdateDisplayOrder()
 {
     $input = $this->_input->filter(array('nodes' => XenForo_Input::ARRAY_SIMPLE));
     $nodeModel = $this->_getNodeModel();
     $nodes = $nodeModel->getAllNodes();
     $updatedNodes = array();
     foreach ($nodes as $node) {
         if (isset($input['nodes'][$node['node_id']])) {
             if ($input['nodes'][$node['node_id']]['parent_node_id'] != $node['parent_node_id'] || $input['nodes'][$node['node_id']]['display_order'] != $node['display_order']) {
                 $nodesInputHandler = new XenForo_Input($input['nodes'][$node['node_id']]);
                 $nodeInput = $nodesInputHandler->filter(array('parent_node_id' => XenForo_Input::UINT, 'display_order' => XenForo_Input::UINT));
                 $dw = $this->_getNodeDataWriter();
                 $dw->setExistingData($node['node_id']);
                 $dw->set('parent_node_id', $nodeInput['parent_node_id']);
                 $dw->set('display_order', $nodeInput['display_order']);
                 $dw->save();
             }
         }
     }
     return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink('nodes'));
 }
Example #10
0
 public function actionSave()
 {
     $this->_assertPostOnly();
     $id = $this->_input->filterSingle('existing_client_id', XenForo_Input::STRING);
     if (!empty($id)) {
         $client = $this->_getClientOrError($id);
     }
     $dwInput = $this->_input->filter(array('name' => XenForo_Input::STRING, 'description' => XenForo_Input::STRING, 'client_id' => XenForo_Input::STRING, 'client_secret' => XenForo_Input::STRING, 'redirect_uri' => XenForo_Input::STRING));
     $optionsInput = new XenForo_Input($this->_input->filterSingle('options', XenForo_Input::ARRAY_SIMPLE));
     $dwInput['options'] = $optionsInput->filter(array('whitelisted_domains' => XenForo_Input::STRING, 'public_key' => XenForo_Input::STRING, 'auto_authorize' => XenForo_Input::ARRAY_SIMPLE));
     $dw = $this->_getClientDataWriter();
     if (!empty($client)) {
         $dw->setExistingData($client, true);
         $dwInput['options'] = array_merge($client['options'], $dwInput['options']);
     }
     $dw->bulkSet($dwInput);
     if (!$dw->get('user_id')) {
         $dw->set('user_id', XenForo_Visitor::getUserId());
     }
     $dw->save();
     return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink('api-clients'));
 }
Example #11
0
 /**
  * Builds and adds the navigation for api data
  *
  * @param XenForo_Input $input
  * @param array $data
  * @param int $perPage
  * @param int $totalItems
  * @param int $page
  * @param string $linkType
  * @param mixed $linkData
  * @param array $linkParams
  * @param array $options
  */
 public static function addPageLinks(XenForo_Input $input, array &$data, $perPage, $totalItems, $page, $linkType, $linkData = null, array $linkParams = array(), array $options = array())
 {
     if (empty($perPage)) {
         return;
     }
     $pageNav = array();
     $inputData = $input->filter(array('fields_include' => XenForo_Input::STRING, 'fields_exclude' => XenForo_Input::STRING));
     if (!empty($inputData['fields_include'])) {
         $linkParams['fields_include'] = $inputData['fields_include'];
     } elseif (!empty($inputData['fields_exclude'])) {
         $linkParams['fields_exclude'] = $inputData['fields_exclude'];
     }
     if (empty($page)) {
         $page = 1;
     }
     $pageNav['pages'] = ceil($totalItems / $perPage);
     if ($pageNav['pages'] <= 1) {
         // do not do anything if there is only 1 page (or no pages)
         return;
     }
     $pageNav['page'] = $page;
     if ($page > 1) {
         // a previous link should only be added if we are not at page 1
         $pageNav['prev'] = XenForo_Link::buildApiLink($linkType, $linkData, array_merge($linkParams, array('page' => $page - 1)));
     }
     if ($page < $pageNav['pages']) {
         // a next link should only be added if we are not at the last page
         $pageNav['next'] = XenForo_Link::buildApiLink($linkType, $linkData, array_merge($linkParams, array('page' => $page + 1)));
     }
     // add the page navigation into `links`
     // the data may have existing links or not
     // we simply don't care
     if (empty($data['links'])) {
         $data['links'] = array();
     }
     $data['links'] = array_merge($data['links'], $pageNav);
 }
Example #12
0
File: User.php Project: sushj/bdApi
 public function actionPutIndex()
 {
     $input = $this->_input->filter(array('password' => XenForo_Input::STRING, 'password_old' => XenForo_Input::STRING, 'password_algo' => XenForo_Input::STRING, 'user_email' => XenForo_Input::STRING, 'username' => XenForo_Input::STRING, 'primary_group_id' => XenForo_Input::UINT, 'secondary_group_ids' => array(XenForo_Input::UINT, 'array' => true), 'user_dob_day' => XenForo_Input::UINT, 'user_dob_month' => XenForo_Input::UINT, 'user_dob_year' => XenForo_Input::UINT, 'user_fields' => XenForo_Input::ARRAY_SIMPLE));
     $user = $this->_getUserOrError();
     $visitor = XenForo_Visitor::getInstance();
     $session = bdApi_Data_Helper_Core::safeGetSession();
     $isAdmin = $session->checkScope(bdApi_Model_OAuth2::SCOPE_MANAGE_SYSTEM) && $visitor->hasAdminPermission('user');
     $requiredAuth = 0;
     if (!empty($input['password'])) {
         $requiredAuth++;
     }
     if (!empty($input['user_email'])) {
         $requiredAuth++;
     }
     if ($requiredAuth > 0) {
         $isAuth = false;
         if ($isAdmin && $visitor['user_id'] != $user['user_id']) {
             $isAuth = true;
         } elseif (!empty($input['password_old'])) {
             $auth = $this->_getUserModel()->getUserAuthenticationObjectByUserId($user['user_id']);
             if (!empty($auth)) {
                 $passwordOld = bdApi_Crypt::decrypt($input['password_old'], $input['password_algo']);
                 if ($auth->hasPassword() && $auth->authenticate($user['user_id'], $passwordOld)) {
                     $isAuth = true;
                 }
             }
         }
         if (!$isAuth) {
             return $this->responseError(new XenForo_Phrase('bdapi_slash_users_requires_password_old'), 403);
         }
     }
     /* @var $writer XenForo_DataWriter_User */
     $writer = XenForo_DataWriter::create('XenForo_DataWriter_User');
     $writer->setExistingData($user, true);
     if ($isAdmin) {
         $writer->setOption(XenForo_DataWriter_User::OPTION_ADMIN_EDIT, true);
     }
     if (!empty($input['password'])) {
         $password = bdApi_Crypt::decrypt($input['password'], $input['password_algo']);
         $writer->setPassword($password, $password);
     }
     if (!empty($input['user_email'])) {
         $writer->set('email', $input['user_email']);
         if ($writer->isChanged('email') && XenForo_Application::getOptions()->get('registrationSetup', 'emailConfirmation') && !$isAdmin) {
             switch ($writer->get('user_state')) {
                 case 'moderated':
                 case 'email_confirm':
                     $writer->set('user_state', 'email_confirm');
                     break;
                 default:
                     $writer->set('user_state', 'email_confirm_edit');
             }
         }
     }
     if (!empty($input['username'])) {
         $writer->set('username', $input['username']);
         if ($writer->isChanged('username') && !$isAdmin) {
             return $this->responseError(new XenForo_Phrase('bdapi_slash_users_denied_username'), 403);
         }
     }
     if ($input['primary_group_id'] > 0) {
         $userGroups = $this->_getUserGroupModel()->getAllUserGroups();
         if (!isset($userGroups[$input['primary_group_id']])) {
             return $this->responseError(new XenForo_Phrase('requested_user_group_not_found'));
         }
         if (!empty($input['secondary_group_ids'])) {
             foreach ($input['secondary_group_ids'] as $secondaryGroupId) {
                 if (!isset($userGroups[$secondaryGroupId])) {
                     return $this->responseError(new XenForo_Phrase('requested_user_group_not_found'));
                 }
             }
         }
         $writer->set('user_group_id', $input['primary_group_id']);
         $writer->setSecondaryGroups($input['secondary_group_ids']);
     }
     if (!empty($input['user_dob_day']) && !empty($input['user_dob_month']) && !empty($input['user_dob_year'])) {
         $writer->set('dob_day', $input['user_dob_day']);
         $writer->set('dob_month', $input['user_dob_month']);
         $writer->set('dob_year', $input['user_dob_year']);
         $hasExistingDob = false;
         $hasExistingDob = $hasExistingDob || !!$writer->getExisting('dob_day');
         $hasExistingDob = $hasExistingDob || !!$writer->getExisting('dob_month');
         $hasExistingDob = $hasExistingDob || !!$writer->getExisting('dob_year');
         if ($hasExistingDob && ($writer->isChanged('dob_day') || $writer->isChanged('dob_month') || $writer->isChanged('dob_year')) && !$isAdmin) {
             // setting new dob is fine but changing dob requires admin permission
             return $this->responseError(new XenForo_Phrase('bdapi_slash_users_denied_dob'), 403);
         }
     }
     if (!empty($input['user_fields'])) {
         $profileFieldsInput = new XenForo_Input($input['user_fields']);
         $profileFields = $profileFieldsInput->filter(array('about' => XenForo_Input::STRING, 'homepage' => XenForo_Input::STRING, 'location' => XenForo_Input::STRING, 'occupation' => XenForo_Input::STRING));
         $writer->bulkSet($profileFields);
         $writer->setCustomFields($input['user_fields']);
     }
     $writer->preSave();
     if (!$isAdmin) {
         if ($writer->isChanged('user_group_id') || $writer->isChanged('secondary_group_ids')) {
             // this has to be checked here because `secondary_group_ids` only get set within preSave()
             return $this->responseError(new XenForo_Phrase('bdapi_slash_users_denied_user_group'), 403);
         }
     }
     $writer->save();
     $user = $writer->getMergedData();
     if ($writer->isChanged('email') && in_array($user['user_state'], array('email_confirm', 'email_confirm_edit'))) {
         /* @var $userConfirmationModel XenForo_Model_UserConfirmation */
         $userConfirmationModel = $this->getModelFromCache('XenForo_Model_UserConfirmation');
         $userConfirmationModel->sendEmailConfirmation($user);
     }
     return $this->responseMessage(new XenForo_Phrase('changes_saved'));
 }
Example #13
0
 protected function _filterInput()
 {
     $request = new Zend_Controller_Request_Http();
     $input = new XenForo_Input($request);
     $this->_filtered = $input->filter(array('txn_type' => XenForo_Input::STRING, 'txn_id' => XenForo_Input::STRING, 'mc_currency' => XenForo_Input::STRING, 'mc_gross' => XenForo_Input::UNUM, 'payment_status' => XenForo_Input::STRING));
 }
Example #14
0
 public function actionImport()
 {
     if ($this->isConfirmedPost()) {
         if ($_input = $this->_getInputFromSerialized('_xfHookImportData', TRUE)) {
             $this->_input = $_input;
         }
         $input = $this->_input->filter(array('import' => XenForo_Input::ARRAY_SIMPLE, 'hooks' => XenForo_Input::ARRAY_SIMPLE));
         $_hooks = array();
         foreach ($input['import'] as $hookId) {
             if (empty($input['hooks'][$hookId])) {
                 continue;
             }
             $hookInput = new XenForo_Input($input['hooks'][$hookId]);
             $_hooks[$hookId] = $hookInput->filter(array('hook_title' => XenForo_Input::STRING, 'template' => XenForo_Input::STRING, 'hook_name' => XenForo_Input::STRING, 'active' => XenForo_Input::UINT));
         }
         $this->_getAdvHookModel()->massImportHooks($_hooks, $errors);
         if (empty($errors)) {
             return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink('advxf-hook'));
         } else {
             return $this->responseError($errors);
         }
     } else {
         return $this->responseView('Turki_Adv_ViewAdmin_Hook_Import', 'adv_hook_xenforo_import', array());
     }
 }
Example #15
0
 /**
  * Fetches name/value/existingDataKey from input. Primarily used for AJAX autovalidation actions of single fields.
  *
  * @return array [name, value, existingDataKey]
  */
 protected function _getFieldValidationInputParams()
 {
     return $this->_input->filter(array('name' => XenForo_Input::STRING, 'value' => XenForo_Input::STRING, 'existingDataKey' => XenForo_Input::STRING));
 }
Example #16
0
 public function validateCallback2(Zend_Controller_Request_Http $request, &$transactionId, &$paymentStatus, &$transactionDetails, &$itemId, &$amount, &$currency)
 {
     $input = new XenForo_Input($request);
     $filtered = $input->filter(array('test_ipn' => XenForo_Input::UINT, 'business' => XenForo_Input::STRING, 'receiver_email' => XenForo_Input::STRING, 'txn_type' => XenForo_Input::STRING, 'txn_id' => XenForo_Input::STRING, 'parent_txn_id' => XenForo_Input::STRING, 'subscr_id' => XenForo_Input::STRING, 'mc_currency' => XenForo_Input::STRING, 'mc_gross' => XenForo_Input::UNUM, 'payment_status' => XenForo_Input::STRING, 'custom' => XenForo_Input::STRING));
     $transactionId = !empty($filtered['txn_id']) ? 'paypal_' . $filtered['txn_id'] : '';
     $paymentStatus = bdPaygate_Processor_Abstract::PAYMENT_STATUS_OTHER;
     $transactionDetails = array_merge($_POST, $filtered);
     $itemId = $filtered['custom'];
     $amount = $filtered['mc_gross'];
     $currency = $filtered['mc_currency'];
     $processorModel = $this->getModelFromCache('bdPaygate_Model_Processor');
     try {
         if ($filtered['test_ipn'] && $this->_sandboxMode()) {
             $validator = XenForo_Helper_Http::getClient('https://www.sandbox.paypal.com/cgi-bin/webscr');
         } else {
             $validator = XenForo_Helper_Http::getClient('http://www.paypal.com/cgi-bin/webscr');
         }
         $validator->setParameterPost('cmd', '_notify-validate');
         $validator->setParameterPost($_POST);
         $validatorResponse = $validator->request('POST');
         if (!$validatorResponse || $validatorResponse->getBody() != 'VERIFIED' || $validatorResponse->getStatus() != 200) {
             if (!empty($validatorResponse)) {
                 $transactionDetails['validator'] = $validator->getUri(true);
                 $transactionDetails['validator_status'] = $validatorResponse->getStatus();
                 $transactionDetails['validator_response'] = $validatorResponse->getBody();
             }
             $this->_setError('Request not validated');
             return false;
         }
     } catch (Zend_Http_Client_Exception $e) {
         $this->_setError('Connection to PayPal failed');
         return false;
     }
     $accounts = preg_split('#\\r?\\n#', utf8_strtolower($this->_getAccount()), -1, PREG_SPLIT_NO_EMPTY);
     $filteredBusiness = utf8_strtolower($filtered['business']);
     $filteredReceiverEmail = utf8_strtolower($filtered['receiver_email']);
     $accountFound = false;
     $addressMatched = false;
     foreach ($accounts as $account) {
         if (!empty($account)) {
             $accountFound = true;
             if ($filteredBusiness === $account or $filteredReceiverEmail === $account) {
                 $addressMatched = true;
             }
         }
     }
     if ($accountFound and !$addressMatched) {
         $this->_setError('Invalid business or receiver_email');
         return false;
     }
     switch ($filtered['txn_type']) {
         case 'web_accept':
             $paymentStatus = bdPaygate_Processor_Abstract::PAYMENT_STATUS_ACCEPTED;
             break;
         case 'subscr_signup':
             $transactionDetails[bdPaygate_Processor_Abstract::TRANSACTION_DETAILS_SUBSCRIPTION_ID] = $filtered['subscr_id'];
             break;
         case 'subscr_payment':
             $paymentStatus = bdPaygate_Processor_Abstract::PAYMENT_STATUS_ACCEPTED;
             $transactionDetails[bdPaygate_Processor_Abstract::TRANSACTION_DETAILS_SUBSCRIPTION_ID] = $filtered['subscr_id'];
             break;
     }
     if ($filtered['payment_status'] == 'Refunded' or $filtered['payment_status'] == 'Reversed') {
         $paymentStatus = bdPaygate_Processor_Abstract::PAYMENT_STATUS_REJECTED;
         if (!empty($filtered['parent_txn_id'])) {
             $transactionDetails[bdPaygate_Processor_Abstract::TRANSACTION_DETAILS_PARENT_TID] = 'paypal_' . $filtered['parent_txn_id'];
         }
     } elseif ($filtered['payment_status'] == 'Canceled_Reversal') {
         $paymentStatus = bdPaygate_Processor_Abstract::PAYMENT_STATUS_ACCEPTED;
         if (!empty($filtered['parent_txn_id'])) {
             $transactionDetails[bdPaygate_Processor_Abstract::TRANSACTION_DETAILS_PARENT_TID] = 'paypal_' . $filtered['parent_txn_id'];
         }
     }
     return true;
 }
Example #17
0
 /**
  * Get type-specific constrints from input.
  *
  * @param XenForo_Input $input
  *
  * @return array
  */
 public function getTypeConstraintsFromInput(XenForo_Input $input)
 {
     $constraints = $input->filter(array('camera' => XenForo_Input::STRING, 'exposure' => XenForo_Input::STRING, 'focal' => XenForo_Input::UINT, 'iso' => XenForo_Input::UINT, 'aperture' => XenForo_Input::FLOAT));
     return $constraints;
 }
Example #18
0
 public function actionImport()
 {
     if ($this->isConfirmedPost()) {
         if ($_input = $this->_getInputFromSerialized('_xfSmilieImportData', true)) {
             $this->_input = $_input;
         }
         $input = $this->_input->filter(array('smilieCategories' => XenForo_Input::ARRAY_SIMPLE, 'import' => XenForo_Input::ARRAY_SIMPLE, 'smilies' => XenForo_Input::ARRAY_SIMPLE));
         $smilies = array();
         foreach ($input['import'] as $smilieId) {
             if (empty($input['smilies'][$smilieId])) {
                 continue;
             }
             $smilieInput = new XenForo_Input($input['smilies'][$smilieId]);
             $smilies[$smilieId] = $smilieInput->filter(array('title' => XenForo_Input::STRING, 'smilie_text' => XenForo_Input::STRING, 'image_url' => XenForo_Input::STRING, 'sprite_mode' => XenForo_Input::UINT, 'sprite_params' => array(XenForo_Input::INT, array('array' => true)), 'smilie_category_id' => XenForo_Input::STRING, 'display_order' => XenForo_Input::UINT, 'display_in_editor' => XenForo_Input::UINT));
         }
         $this->_getSmilieModel()->massImportSmilies($smilies, $input['smilieCategories'], $errors);
         if (empty($errors)) {
             return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink('smilies'));
         } else {
             return $this->responseError($errors);
         }
     } else {
         return $this->responseView('XenForo_ViewAdmin_Smilie_Import', 'smilie_import', array());
     }
 }
 /**
  * Gets the filter parameters from the input object.
  *
  * @param XenForo_Input $inputHandler Input object
  *
  * @return array Named params
  */
 public static function getParamsFromInput(XenForo_Input $inputHandler)
 {
     return $inputHandler->filter(array('filter' => XenForo_Input::STRING, 'prefixmatch' => XenForo_Input::BINARY));
 }
Example #20
0
 /**
  * Inserts a new thread into this forum.
  *
  * @return XenForo_ControllerResponse_Abstract
  */
 public function actionAddThread()
 {
     $this->_assertPostOnly();
     $forumId = $this->_input->filterSingle('node_id', XenForo_Input::UINT);
     $forumName = $this->_input->filterSingle('node_name', XenForo_Input::STRING);
     $ftpHelper = $this->getHelper('ForumThreadPost');
     $forum = $ftpHelper->assertForumValidAndViewable($forumId ? $forumId : $forumName);
     $forumId = $forum['node_id'];
     $this->_assertCanPostThreadInForum($forum);
     if (!XenForo_Captcha_Abstract::validateDefault($this->_input)) {
         return $this->responseCaptchaFailed();
     }
     $visitor = XenForo_Visitor::getInstance();
     $input = $this->_input->filter(array('title' => XenForo_Input::STRING, 'attachment_hash' => XenForo_Input::STRING, 'watch_thread_state' => XenForo_Input::UINT, 'watch_thread' => XenForo_Input::UINT, 'watch_thread_email' => XenForo_Input::UINT, '_set' => array(XenForo_Input::UINT, 'array' => true), 'discussion_open' => XenForo_Input::UINT, 'sticky' => XenForo_Input::UINT, 'poll' => XenForo_Input::ARRAY_SIMPLE));
     $input['message'] = $this->getHelper('Editor')->getMessageText('message', $this->_input);
     $input['message'] = XenForo_Helper_String::autoLinkBbCode($input['message']);
     $pollInputHandler = new XenForo_Input($input['poll']);
     $pollInput = $pollInputHandler->filter(array('question' => XenForo_Input::STRING, 'responses' => array(XenForo_Input::STRING, 'array' => true), 'multiple' => XenForo_Input::UINT, 'public_votes' => XenForo_Input::UINT, 'close' => XenForo_Input::UINT, 'close_length' => XenForo_Input::UNUM, 'close_units' => XenForo_Input::STRING));
     // note: assumes that the message dw will pick up the username issues
     $writer = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
     $writer->set('user_id', $visitor['user_id']);
     $writer->set('username', $visitor['username']);
     $writer->set('title', $input['title']);
     $writer->set('node_id', $forumId);
     // discussion state changes instead of first message state
     $writer->set('discussion_state', $this->getModelFromCache('XenForo_Model_Post')->getPostInsertMessageState(array(), $forum));
     // discussion open state - moderator permission required
     if (!empty($input['_set']['discussion_open']) && $this->_getForumModel()->canLockUnlockThreadInForum($forum)) {
         $writer->set('discussion_open', $input['discussion_open']);
     }
     // discussion sticky state - moderator permission required
     if (!empty($input['_set']['sticky']) && $this->_getForumModel()->canStickUnstickThreadInForum($forum)) {
         $writer->set('sticky', $input['sticky']);
     }
     $postWriter = $writer->getFirstMessageDw();
     $postWriter->set('message', $input['message']);
     $postWriter->setExtraData(XenForo_DataWriter_DiscussionMessage::DATA_ATTACHMENT_HASH, $input['attachment_hash']);
     $writer->preSave();
     if ($pollInput['question'] !== '') {
         $pollWriter = XenForo_DataWriter::create('XenForo_DataWriter_Poll');
         $pollWriter->bulkSet(XenForo_Application::arrayFilterKeys($pollInput, array('question', 'multiple', 'public_votes')));
         $pollWriter->set('content_type', 'thread');
         $pollWriter->set('content_id', 0);
         // changed before saving
         if ($pollInput['close']) {
             if (!$pollInput['close_length']) {
                 $pollWriter->error(new XenForo_Phrase('please_enter_valid_length_of_time'));
             } else {
                 $pollWriter->set('close_date', strtotime('+' . $pollInput['close_length'] . ' ' . $pollInput['close_units']));
             }
         }
         $pollWriter->addResponses($pollInput['responses']);
         $pollWriter->preSave();
         $writer->mergeErrors($pollWriter->getErrors());
         $writer->set('discussion_type', 'poll', '', array('setAfterPreSave' => true));
     } else {
         $pollWriter = false;
         foreach ($pollInput['responses'] as $response) {
             if ($response !== '') {
                 $writer->error(new XenForo_Phrase('you_entered_poll_response_but_no_question'));
                 break;
             }
         }
     }
     if (!$writer->hasErrors()) {
         $this->assertNotFlooding('post');
     }
     $writer->save();
     $thread = $writer->getMergedData();
     if ($pollWriter) {
         $pollWriter->set('content_id', $thread['thread_id'], '', array('setAfterPreSave' => true));
         $pollWriter->save();
     }
     $this->_getThreadWatchModel()->setVisitorThreadWatchStateFromInput($thread['thread_id'], $input);
     $this->_getThreadModel()->markThreadRead($thread, $forum, XenForo_Application::$time, $visitor['user_id']);
     if (!$this->_getThreadModel()->canViewThread($thread, $forum)) {
         $return = XenForo_Link::buildPublicLink('forums', $forum, array('posted' => 1));
     } else {
         $return = XenForo_Link::buildPublicLink('threads', $thread);
     }
     return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $return, new XenForo_Phrase('your_thread_has_been_posted'));
 }
Example #21
0
 public function setupNewPollFromForm(XenForo_Input $input)
 {
     $pollInput = $input->filter(array('question' => XenForo_Input::STRING, 'responses' => array(XenForo_Input::STRING, 'array' => true), 'max_votes_type' => XenForo_Input::STRING, 'max_votes_value' => XenForo_Input::UINT, 'public_votes' => XenForo_Input::BOOLEAN, 'change_vote' => XenForo_Input::BOOLEAN, 'view_results_unvoted' => XenForo_Input::BOOLEAN, 'close' => XenForo_Input::UINT, 'close_length' => XenForo_Input::UNUM, 'close_units' => XenForo_Input::STRING));
     $pollWriter = XenForo_DataWriter::create('XenForo_DataWriter_Poll');
     $pollWriter->bulkSet(array('question' => $pollInput['question'], 'public_votes' => $pollInput['public_votes'], 'change_vote' => $pollInput['change_vote'], 'view_results_unvoted' => $pollInput['view_results_unvoted']));
     switch ($pollInput['max_votes_type']) {
         case 'single':
             $pollWriter->set('max_votes', 1);
             break;
         case 'unlimited':
             $pollWriter->set('max_votes', 0);
             break;
         default:
             $pollWriter->set('max_votes', $pollInput['max_votes_value']);
     }
     if ($pollInput['close']) {
         if (!$pollInput['close_length']) {
             $pollWriter->error(new XenForo_Phrase('please_enter_valid_length_of_time'));
         } else {
             $pollWriter->set('close_date', $pollWriter->preVerifyCloseDate(strtotime('+' . $pollInput['close_length'] . ' ' . $pollInput['close_units'])));
         }
     }
     $pollWriter->addResponses($pollInput['responses']);
     return $pollWriter;
 }
Example #22
0
 /**
  * Inserts a new thread into this forum.
  *
  * @return XenForo_ControllerResponse_Abstract
  */
 public function actionAddThread()
 {
     $this->_assertPostOnly();
     $forumId = $this->_input->filterSingle('node_id', XenForo_Input::UINT);
     $forumName = $this->_input->filterSingle('node_name', XenForo_Input::STRING);
     $ftpHelper = $this->getHelper('ForumThreadPost');
     $forum = $ftpHelper->assertForumValidAndViewable($forumId ? $forumId : $forumName);
     $forumId = $forum['node_id'];
     $this->_assertCanPostThreadInForum($forum);
     if (!XenForo_Captcha_Abstract::validateDefault($this->_input)) {
         return $this->responseCaptchaFailed();
     }
     $visitor = XenForo_Visitor::getInstance();
     $input = $this->_input->filter(array('title' => XenForo_Input::STRING, 'prefix_id' => XenForo_Input::UINT, 'attachment_hash' => XenForo_Input::STRING, 'tags' => XenForo_Input::STRING, 'watch_thread_state' => XenForo_Input::UINT, 'watch_thread' => XenForo_Input::UINT, 'watch_thread_email' => XenForo_Input::UINT, '_set' => array(XenForo_Input::UINT, 'array' => true), 'discussion_open' => XenForo_Input::UINT, 'sticky' => XenForo_Input::UINT, 'poll' => XenForo_Input::ARRAY_SIMPLE));
     $input['message'] = $this->getHelper('Editor')->getMessageText('message', $this->_input);
     $input['message'] = XenForo_Helper_String::autoLinkBbCode($input['message']);
     if (!$this->_getPrefixModel()->verifyPrefixIsUsable($input['prefix_id'], $forumId)) {
         $input['prefix_id'] = 0;
         // not usable, just blank it out
     }
     // note: assumes that the message dw will pick up the username issues
     $writer = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
     $writer->bulkSet(array('user_id' => $visitor['user_id'], 'username' => $visitor['username'], 'title' => $input['title'], 'prefix_id' => $input['prefix_id'], 'node_id' => $forumId));
     // discussion state changes instead of first message state
     $writer->set('discussion_state', $this->getModelFromCache('XenForo_Model_Post')->getPostInsertMessageState(array(), $forum));
     // discussion open state - moderator permission required
     if (!empty($input['_set']['discussion_open']) && $this->_getForumModel()->canLockUnlockThreadInForum($forum)) {
         $writer->set('discussion_open', $input['discussion_open']);
     }
     // discussion sticky state - moderator permission required
     if (!empty($input['_set']['sticky']) && $this->_getForumModel()->canStickUnstickThreadInForum($forum)) {
         $writer->set('sticky', $input['sticky']);
     }
     $postWriter = $writer->getFirstMessageDw();
     $postWriter->set('message', $input['message']);
     $postWriter->setExtraData(XenForo_DataWriter_DiscussionMessage::DATA_ATTACHMENT_HASH, $input['attachment_hash']);
     $postWriter->setExtraData(XenForo_DataWriter_DiscussionMessage_Post::DATA_FORUM, $forum);
     $postWriter->setOption(XenForo_DataWriter_DiscussionMessage_Post::OPTION_MAX_TAGGED_USERS, $visitor->hasPermission('general', 'maxTaggedUsers'));
     $writer->setExtraData(XenForo_DataWriter_Discussion_Thread::DATA_FORUM, $forum);
     $pollWriter = false;
     if ($this->_getForumModel()->canPostPollInForum($forum)) {
         $pollInputHandler = new XenForo_Input($input['poll']);
         $pollInput = $pollInputHandler->filter(array('question' => XenForo_Input::STRING, 'responses' => array(XenForo_Input::STRING, 'array' => true)));
         if ($pollInput['question'] !== '') {
             /** @var XenForo_Model_Poll $pollModel */
             $pollModel = $this->getModelFromCache('XenForo_Model_Poll');
             $pollWriter = $pollModel->setupNewPollFromForm($pollInputHandler);
             $pollWriter->set('content_type', 'thread');
             $pollWriter->set('content_id', 0);
             // changed before saving
             $pollWriter->preSave();
             $writer->mergeErrors($pollWriter->getErrors());
             $writer->set('discussion_type', 'poll', '', array('setAfterPreSave' => true));
         } else {
             foreach ($pollInput['responses'] as $response) {
                 if ($response !== '') {
                     $writer->error(new XenForo_Phrase('you_entered_poll_response_but_no_question'));
                     break;
                 }
             }
         }
     }
     $tagger = null;
     if ($this->_getThreadModel()->canEditTags(null, $forum)) {
         /** @var XenForo_Model_Tag $tagModel */
         $tagModel = $this->getModelFromCache('XenForo_Model_Tag');
         $tagger = $tagModel->getTagger('thread');
         $tagger->setPermissionsFromContext($forum)->setTags($tagModel->splitTags($input['tags']));
         $writer->mergeErrors($tagger->getErrors());
     }
     $spamModel = $this->_getSpamPreventionModel();
     if (!$writer->hasErrors() && $writer->get('discussion_state') == 'visible' && $spamModel->visitorRequiresSpamCheck()) {
         switch ($spamModel->checkMessageSpam($input['title'] . "\n" . $input['message'], array(), $this->_request)) {
             case XenForo_Model_SpamPrevention::RESULT_MODERATED:
                 $writer->set('discussion_state', 'moderated');
                 break;
             case XenForo_Model_SpamPrevention::RESULT_DENIED:
                 $spamModel->logSpamTrigger('thread', null);
                 $writer->error(new XenForo_Phrase('your_content_cannot_be_submitted_try_later'));
                 break;
         }
     }
     $writer->preSave();
     if ($forum['require_prefix'] && !$writer->get('prefix_id') && $this->_getPrefixModel()->getUsablePrefixesInForums($forum['node_id'])) {
         $writer->error(new XenForo_Phrase('please_select_a_prefix'), 'prefix_id');
     }
     if (!$writer->hasErrors()) {
         $this->assertNotFlooding('post');
     }
     $writer->save();
     $thread = $writer->getMergedData();
     if ($pollWriter) {
         $pollWriter->set('content_id', $thread['thread_id'], '', array('setAfterPreSave' => true));
         $pollWriter->save();
     }
     if ($tagger) {
         $tagger->setContent($thread['thread_id'], true)->save();
     }
     $spamModel->logContentSpamCheck('thread', $thread['thread_id']);
     $spamModel->logSpamTrigger('thread', $thread['thread_id']);
     $this->_getDraftModel()->deleteDraft('forum-' . $forum['node_id']);
     $this->_getThreadWatchModel()->setVisitorThreadWatchStateFromInput($thread['thread_id'], $input);
     $this->_getThreadModel()->markThreadRead($thread, $forum, XenForo_Application::$time);
     if (!$this->_getThreadModel()->canViewThread($thread, $forum)) {
         $return = XenForo_Link::buildPublicLink('forums', $forum, array('posted' => 1));
     } else {
         $return = XenForo_Link::buildPublicLink('threads', $thread);
     }
     return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $return, new XenForo_Phrase('your_thread_has_been_posted'));
 }
Example #23
0
 public function processInput(XenForo_Input $input)
 {
     $data = $input->filter(array(Tinhte_XenTag_Constants::FORM_TAGS_ARRAY => XenForo_Input::ARRAY_SIMPLE, Tinhte_XenTag_Constants::FORM_TAGS_TEXT => XenForo_Input::STRING, Tinhte_XenTag_Constants::FORM_INCLUDED => XenForo_Input::UINT, Tinhte_XenTag_Constants::FORM_TAGS_TEXT_NO_INCLUDED => XenForo_Input::STRING));
     if (!empty($data[Tinhte_XenTag_Constants::FORM_INCLUDED])) {
         $tagTexts = $data[Tinhte_XenTag_Constants::FORM_TAGS_ARRAY];
         if (!empty($data[Tinhte_XenTag_Constants::FORM_TAGS_TEXT])) {
             $tagTexts2 = Tinhte_XenTag_Helper::explodeTags($data[Tinhte_XenTag_Constants::FORM_TAGS_TEXT]);
         } else {
             $tagTexts2 = array();
         }
         $merged = array_merge($tagTexts, $tagTexts2);
         foreach (array_keys($merged) as $key) {
             $merged[$key] = trim($merged[$key]);
             if (empty($merged[$key])) {
                 unset($merged[$key]);
             }
         }
         return $merged;
     } elseif (!empty($data[Tinhte_XenTag_Constants::FORM_TAGS_TEXT_NO_INCLUDED])) {
         // used as a checkbox in search bar
         // so no *_included field is coming with it
         // we just use it as it's is
         $tagTexts = Tinhte_XenTag_Helper::explodeTags($data[Tinhte_XenTag_Constants::FORM_TAGS_TEXT_NO_INCLUDED]);
         foreach (array_keys($tagTexts) as $key) {
             $tagTexts[$key] = trim($tagTexts[$key]);
             if (empty($tagTexts[$key])) {
                 unset($tagTexts[$key]);
             }
         }
         return $tagTexts;
     } else {
         return false;
     }
 }