public static function validateNoForum(&$option, XenForo_DataWriter $dw, $fieldName) { $_request = new Zend_Controller_Request_Http(); $_input = new XenForo_Input($_request); $optionsInput = $_input->filterSingle('options', XenForo_Input::ARRAY_SIMPLE); $sandbox = isset($optionsInput['th_noForo_sandbox']); if (!isset($option['no_forum'])) { $option = array(); } if ($sandbox) { return true; } /* @var $noForoModel ThemeHouse_NoForo_Model_NoForo */ $noForoModel = XenForo_Model::create('ThemeHouse_NoForo_Model_NoForo'); if (isset($option['no_forum'])) { if (!isset($option['no_link_forums'])) { $option['no_link_forums'] = $noForoModel->isNoLinkForums(); } } $option = array_filter($option); if ($option) { $noForoModel->removeForum($option); } else { $noForoModel->rebuildForum(); } return true; }
/** * Determines if CAPTCHA is valid (passed). * * @see XenForo_Captcha_Abstract::isValid() */ public function isValid(array $input) { $cleaner = new XenForo_Input($input); $answer = $cleaner->filterSingle('captcha_question_answer', XenForo_Input::STRING); $hash = $cleaner->filterSingle('captcha_question_hash', XenForo_Input::STRING); return XenForo_Model_CaptchaQuestion::isCorrect($answer, $hash); }
/** * @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'))); }
/** * 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'); }
/** * Converts WYSIWYG editor HTML back to BB code * * @param string $messageTextHtml HTML to convert * @param XenForo_Input $input * @param integer $htmlCharacterLimit Max length of HTML before processing; defaults to 4 * message length option * * @return string BB code input */ public function convertEditorHtmlToBbCode($messageTextHtml, XenForo_Input $input, $htmlCharacterLimit = -1) { if ($htmlCharacterLimit < 0) { $htmlCharacterLimit = 4 * XenForo_Application::get('options')->messageMaxLength; // quadruple the limit as HTML can be a lot more verbose } if ($htmlCharacterLimit && utf8_strlen($messageTextHtml) > $htmlCharacterLimit) { throw new XenForo_Exception(new XenForo_Phrase('submitted_message_is_too_long_to_be_processed'), true); } $options = array(); $requestPaths = XenForo_Application::get('requestPaths'); $options['baseUrl'] = $requestPaths['fullBasePath']; $relativeResolver = $input->filterSingle('_xfRelativeResolver', XenForo_Input::STRING); if ($relativeResolver && isset($_SERVER['HTTP_USER_AGENT'])) { if (preg_match('#Firefox/([0-9]+)\\.([0-9]+)\\.([0-9]+)#i', $_SERVER['HTTP_USER_AGENT'], $match)) { // FF versions sometime before 3.6.12 have an issue with respecting the base tag of the editor, // 3.6.8 is a known version that has problems $useResolver = $match[1] <= 3 && $match[2] <= 6 && $match[3] <= 8; } else { $useResolver = false; } if ($useResolver) { // take off query string and then up to the last directory $relativeResolver = preg_replace('/\\?.*$/', '', $relativeResolver); $relativeResolver = preg_replace('#/[^/]+$#', '', $relativeResolver); $options['baseUrl'] = $relativeResolver; } } $rendered = XenForo_Html_Renderer_BbCode::renderFromHtml($messageTextHtml, $options); return trim(XenForo_Input::cleanString($rendered)); }
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')); }
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; }
public function verifyFromInput($context, XenForo_Input $input, array $user, array &$providerData) { $code = $input->filterSingle('code', XenForo_Input::STRING); $code = preg_replace('/[^0-9]/', '', $code); if (!$code) { return false; } $matched = null; foreach ($providerData['codes'] as $i => $expectedCode) { if (XenForo_Application::hashEquals($expectedCode, $code)) { $matched = $i; break; } } if ($matched === null) { return false; } $providerData['used'][] = $providerData['codes'][$matched]; unset($providerData['codes'][$matched]); if (!$providerData['codes']) { // regenerate automatically $regenerated = true; $this->generateInitialData($user, array()); } else { $regenerated = false; } $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $mail = XenForo_Mail::create('two_step_login_backup', array('user' => $user, 'ip' => $ip, 'regenerated' => $regenerated), $user['language_id']); $mail->send($user['email'], $user['username']); return true; }
public static function getTypeConstraintsFromInput(XenForo_Input $input, array $fields, $fieldType) { $xenOptions = XenForo_Application::get('options'); $constraints = array(); $fieldValues = $input->filterSingle('custom_fields', XenForo_Input::ARRAY_SIMPLE); if ($fieldValues && $fields) { foreach ($fields as $fieldId => $field) { if (empty($fieldValues[$fieldId])) { continue; } $fieldValue = $fieldValues[$fieldId]; if (in_array($field['field_type'], array('multiselect', 'checkbox'))) { if (is_array($fieldValue)) { $newFieldValue = array(); foreach ($fieldValue as $_fieldValue) { $newFieldValue[$_fieldValue] = $_fieldValue; } $fieldValue = array('=', serialize($newFieldValue)); } else { $fieldValue = array('LIKE', '%' . serialize($fieldValue) . '%'); } } elseif ($xenOptions->waindigo_customFields_partialSearch) { $fieldValue = array('LIKE', '%' . $fieldValue . '%'); } else { $fieldValue = array('=', $fieldValue); } $constraints[$fieldType . '_field_id_' . $fieldId] = $fieldId; $constraints[$fieldType . '_field_value_' . $fieldId] = $fieldValue; } } return $constraints; }
/** * 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'); }
protected function _preSave() { $_input = new XenForo_Input($_REQUEST); $bbm_bm_editor = $_input->filterSingle('bbm_bm_editor', XenForo_Input::STRING); $bbm_bm_editor = empty($bbm_bm_editor) ? 'disable' : $bbm_bm_editor; $this->set('bbm_bm_editor', $bbm_bm_editor); return parent::_preSave(); }
/** * Determines if CAPTCHA is valid (passed). * * @see XenForo_Captcha_Abstract::isValid() */ public function isValid(array $input) { $cleaner = new XenForo_Input($input); $answer = $cleaner->filterSingle('captcha_question_answer', XenForo_Input::STRING); $hash = $cleaner->filterSingle('captcha_question_hash', XenForo_Input::STRING); /** @var XenForo_Model_CaptchaQuestion $model */ $model = XenForo_Model::create('XenForo_Model_CaptchaQuestion'); return $model->verifyTextCaptcha($hash, $answer); }
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; }
protected function _preSave() { $options = XenForo_Application::get('options'); if (!$options->sedo_at_preventracing) { return parent::_preSave(); } $_input = new XenForo_Input($_REQUEST); $sedo_agent = $_input->filterSingle('allow_sedo_agent', XenForo_Input::UINT); if ($_input->inRequest('allow_sedo_agent')) { //The wrapped conditionnal prevents the field 'allow_sedo_agent' to be modified outside the page 'user' //Fixes a problem with profile posts $this->set('allow_sedo_agent', $sedo_agent); } return parent::_preSave(); }
public function verifyFromInput($context, XenForo_Input $input, array $user, array &$providerData) { if (empty($providerData['code']) || empty($providerData['codeGenerated'])) { return false; } if (time() - $providerData['codeGenerated'] > 900) { return false; } $code = $input->filterSingle('code', XenForo_Input::STRING); $code = preg_replace('/[^0-9]/', '', $code); if (!XenForo_Application::hashEquals($providerData['code'], $code)) { return false; } unset($providerData['code']); unset($providerData['codeGenerated']); return true; }
/** * 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; }
/** * 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'); }
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')); }
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')); }
/** * Turns a serialized (by jQuery) query string from input into a XenForo_Input object. * * @param string Name of index to fetch from $this->_input * @param boolean On error, throw an exception or return false * @param string * * @return XenForo_Input|false */ protected function _getInputFromSerialized($varname, $throw = true, &$errorPhraseKey = null) { if ($inputString = $this->_input->filterSingle($varname, XenForo_Input::STRING)) { try { return new XenForo_Input(XenForo_Application::parseQueryString($inputString)); } catch (Exception $e) { $errorPhraseKey = 'string_could_not_be_converted_to_input'; if ($throw) { throw $this->responseException($this->responseError(new XenForo_Phrase($errorPhraseKey))); } } } return false; }
/** * 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); }
public function verifyFromInput($context, XenForo_Input $input, array $user, array &$providerData) { if (empty($providerData['secret'])) { return false; } $code = $input->filterSingle('code', XenForo_Input::STRING); $code = preg_replace('/[^0-9]/', '', $code); if (!$code) { return false; } if (!empty($providerData['lastCode']) && $providerData['lastCode'] === $code) { // prevent a replay attack: once the code has been used, don't allow it to be used in the slice again if (!empty($providerData['lastCodeTime']) && time() - $providerData['lastCodeTime'] < 30) { return false; } } $auth = $this->_getAuthHandler(); if (!$auth->verifyCode($providerData['secret'], $code)) { return false; } $providerData['lastCode'] = $code; $providerData['lastCodeTime'] = time(); return true; }
public function actionPresetsSave() { $this->_assertPostOnly(); /* @var $presetsModel ThreePointStudio_CustomMarkupForUser_Model_Preset */ $presetsModel = $this->getModelFromCache("ThreePointStudio_CustomMarkupForUser_Model_Preset"); $preset_id = $this->_input->filterSingle("preset_id", XenForo_Input::UINT); if (!$preset_id) { $preset_id = 0; } $dwInput = $this->_input->filter(array("title" => XenForo_Input::STRING, "display_style_priority" => XenForo_Input::UINT, "enable_for" => array(XenForo_Input::UINT, 'array' => true), "user_groups" => array(XenForo_Input::UINT, 'array' => true))); $options = $this->_input->filterSingle("3ps_cmfu_options", XenForo_Input::ARRAY_SIMPLE); foreach ($options as $category => $catArray) { foreach ($catArray as $itemName => $itemValue) { if (ThreePointStudio_CustomMarkupForUser_Helpers::startsWith($itemName, "enable_")) { unset($options[$category][$itemName]); // Ignore any placeholders continue; } $options[$category][$itemName] = XenForo_Input::rawFilter($itemValue, ThreePointStudio_CustomMarkupForUser_Constants::$availableMarkups[$itemName]["type"]); } } foreach ($options as $category => $catArray) { foreach ($catArray as $itemName => $itemValue) { $itemArray = ThreePointStudio_CustomMarkupForUser_Constants::$availableMarkups[$itemName]; // Check if we have dependencies if (isset($itemArray["requires"])) { foreach ($itemArray["requires"] as $requirement) { if ($catArray[$requirement[0]] !== $requirement[1]) { unset($options[$category][$itemName]); // Dependency not match, skipping continue; } } } if (!call_user_func($itemArray["verify"]["func"], $itemValue)) { return $this->responseError(new XenForo_Phrase($itemArray["verify"]["error"])); // Validation failed, ragequit } } } $dwInput["config"] = serialize($options); $dwInput["user_groups"] = serialize($dwInput["user_groups"]); $dwInput["enable_for"] = serialize($dwInput["enable_for"]); $preset_id = $presetsModel->updatePreset($preset_id, $dwInput); return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink('3ps-cmfu/presets') . $this->getLastHash($preset_id)); }
protected function _prepareUserSearchCriteria(array $criteria) { if (!empty($criteria['last_activity'])) { $criteria['last_activity'] = array('>=', XenForo_Input::rawFilter($criteria['last_activity'], XenForo_Input::DATE_TIME)); } if (!empty($criteria['message_count'])) { $criteria['message_count'] = array('>=', $criteria['message_count']); } if (isset($criteria['is_banned']) && is_array($criteria['is_banned'])) { $criteria['is_banned'] = reset($criteria['is_banned']); } foreach (array('username', 'username2', 'email') as $field) { if (isset($criteria[$field]) && is_string($criteria[$field])) { $criteria[$field] = trim($criteria[$field]); } } return $criteria; }
protected static function _xenMediaPhotoIndexParams($team) { $categoryModel = self::$controller->getModelFromCache('XenGallery_Model_Category'); $category = $categoryModel->getCategoryById(self::$setup->getOption('XenMediaCategoryId')); $noPermission = false; if (!$category) { $noPermission = true; } else { if (!$categoryModel->canAddMediaToCategory($category)) { $noPermission = true; } } if ($noPermission) { return array('templateName' => 'Team_photo', 'viewName' => '', 'provider' => 'XenGallery', 'noPermission' => true); } $mediaModel = self::$controller->getModelFromCache('XenGallery_Model_Media'); $albumModel = self::$controller->getModelFromCache('XenGallery_Model_Album'); $order = self::$input->filterSingle('order', XenForo_Input::STRING); $type = self::$input->filterSingle('type', XenForo_Input::STRING); $page = self::$input->filterSingle('page', XenForo_Input::UINT); $perPage = XenForo_Application::getOptions()->xengalleryMediaMaxPerPage; $visitor = XenForo_Visitor::getInstance(); $conditions = array('deleted' => $mediaModel->canViewDeletedMedia(), 'type' => $type ? $type : 'all', 'privacyUserId' => $visitor->user_id, 'viewAlbums' => $albumModel->canViewAlbums(), 'viewCategoryIds' => $mediaModel->getViewableCategoriesForVisitor($visitor->toArray()), 'newerThan' => $mediaModel->getMediaHomeCutOff(), 'social_group_id' => $team['team_id']); $fetchOptions = self::_getMediaFetchOptions() + array('order' => $order ? $order : 'media_date', 'orderDirection' => 'desc', 'page' => $page, 'perPage' => $perPage); $fetchOptions['join'] |= XenGallery_Model_Media::FETCH_PRIVACY; $media = $mediaModel->getMedia($conditions, $fetchOptions); $media = $mediaModel->prepareMediaItems($media); $inlineModOptions = $mediaModel->prepareInlineModOptions($media); $ignoredNames = array(); foreach ($media as $item) { if (!empty($item['isIgnored'])) { $ignoredNames[] = $item['username']; } } $mediaCount = $mediaModel->countMedia($conditions, $fetchOptions); self::$controller->canonicalizePageNumber($page, $perPage, $mediaCount, TEAM_ROUTE_PREFIX . '/photos', $team); self::$controller->canonicalizeRequestUrl(XenForo_Link::buildPublicLink(TEAM_ROUTE_PREFIX . '/photos', $team, array('page' => $page))); $pageNavParams = array('order' => $order, 'type' => $type); return array('templateName' => 'Team_photo', 'viewName' => '', 'provider' => 'XenGallery', 'canViewRatings' => $mediaModel->canViewRatings(), 'mediaHome' => true, 'media' => $media, 'ignoredNames' => array_unique($ignoredNames), 'mediaCount' => $mediaCount, 'page' => $page <= 1 ? '' : $page, 'perPage' => $perPage, 'pageNavParams' => $pageNavParams, 'order' => $order, 'type' => $type, 'time' => XenForo_Application::$time, 'showTypeTabs' => $albumModel->canViewAlbums(), 'inlineModOptions' => $inlineModOptions, 'userPage' => false); }
public function parseOptionsInput(XenForo_Input $input, array $widget) { $configuration = $this->getConfiguration(); $options = empty($widget['options']) ? array() : $widget['options']; foreach ($configuration['options'] as $optionKey => $optionType) { $optionValue = $input->filterSingle(self::getNamePrefix() . $optionKey, $optionType); if ($this->_validateOptionValue($optionKey, $optionValue) !== false) { $options[$optionKey] = $optionValue; } } if (!empty($widget['widget_page_id'])) { if (empty($options['layout_sizeRow'])) { $options['layout_sizeRow'] = 1; } if (empty($options['layout_sizeCol'])) { $options['layout_sizeCol'] = 1; } } if (!empty($options['conditional']) and !empty($options['expression'])) { unset($options['expression']); } return $options; }
/** * Gets the search form controller response for this type. * * @see XenForo_Search_DataHandler_Abstract::getSearchFormControllerResponse() */ public function getSearchFormControllerResponse(XenForo_ControllerPublic_Abstract $controller, XenForo_Input $input, array $viewParams) { $params = $input->filterSingle('c', XenForo_Input::ARRAY_SIMPLE); $viewParams['search'] = array_merge($viewParams['search'], array('reply_count' => empty($params['reply_count']) ? '' : $params['reply_count'])); return $controller->responseView('XenForo_ViewPublic_Search_Form_Post', 'search_form_post', $viewParams); }
/** * Attempts to read HTML that has been selected from XenForo messages, * and turn it back into its source BB code. * * @param $html * * @return string */ public function getBbCodeFromSelectionHtml($html) { // attempt to parse the selected HTML into BB code $html = trim(strip_tags($html, '<b><i><u><a><img><span><ul><ol><li><pre><code><br>')); // handle PHP/CODE/HTML output and turn it back into BB code $html = preg_replace_callback('/<(pre|code) data-type="(\\w+)">(.*)<\\/\\1>/siU', array($this, '_bbCodeTagsHtmlToBbCode'), $html); $html = XenForo_Html_Renderer_BbCode::renderFromHtml($html); return trim(XenForo_Input::cleanString($html)); }
/** * 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')); }
/** * Gets the search form controller response for this type. * * @see XenForo_Search_DataHandler_Abstract::getSearchFormControllerResponse() */ public function getSearchFormControllerResponse(XenForo_ControllerPublic_Abstract $controller, XenForo_Input $input, array $viewParams) { $params = $input->filterSingle('c', XenForo_Input::ARRAY_SIMPLE); if (!empty($params['profile_user'])) { $profileUsers = $this->_getUserModel()->getUsersByIds($params['profile_user']); foreach ($profileUsers as &$profileUser) { $profileUser = $profileUser['username']; } } $viewParams['search'] = array_merge($viewParams['search'], array('profile_users' => empty($profileUsers) ? '' : implode(', ', $profileUsers))); return $controller->responseView('XenForo_ViewPublic_Search_Form_ProfilePost', 'search_form_profile_post', $viewParams); }