Ejemplo n.º 1
0
 /**
  * Verifies database connection information
  *
  * @param array $words List of words to censor (from input). Keys: word, exact, replace
  * @param XenForo_DataWriter $dw Calling DW
  * @param string $fieldName Name of field/option
  *
  * @return true
  */
 public static function verifyOption(array &$database, XenForo_DataWriter $dw = null, $fieldName = null)
 {
     if (array_key_exists('newInstall', $database)) {
         return true;
     }
     if (!array_key_exists('adapter', $database) || !array_key_exists('host', $database) || !array_key_exists('port', $database) || !array_key_exists('dbname', $database) || !array_key_exists('username', $database) || !array_key_exists('password', $database)) {
         return false;
     }
     try {
         $db = Zend_Db::factory($database['adapter'], array('host' => $database['host'], 'port' => $database['port'], 'dbname' => $database['dbname'], 'username' => $database['username'], 'password' => $database['password']));
         $db->getConnection();
         $sbTables = array($database['table_prefix'] . '_admins', $database['table_prefix'] . '_admins_servers_groups', $database['table_prefix'] . '_banlog', $database['table_prefix'] . '_bans', $database['table_prefix'] . '_comments', $database['table_prefix'] . '_demos', $database['table_prefix'] . '_groups', $database['table_prefix'] . '_log', $database['table_prefix'] . '_mods', $database['table_prefix'] . '_overrides', $database['table_prefix'] . '_protests', $database['table_prefix'] . '_servers', $database['table_prefix'] . '_servers_groups', $database['table_prefix'] . '_settings', $database['table_prefix'] . '_srvgroups', $database['table_prefix'] . '_srvgroups_overrides', $database['table_prefix'] . '_submissions');
         $query = $db->listTables();
         if (count(array_diff($sbTables, $query)) > 0) {
             $dw->error(new XenForo_Phrase('sourcebans_table_prefix_invalid'));
             return false;
         }
     } catch (Zend_Db_Adapter_Exception $e) {
         if ($dw) {
             $dw->error($e->getMessage(), $fieldName);
         }
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
 public static function watermark(array &$optionValues, XenForo_DataWriter $optionDw, $optionId)
 {
     if ($optionId !== 'sonnbXG_watermark') {
         return true;
     }
     if (!empty($optionValues['enabled'])) {
         switch ($optionValues['overlay']) {
             case 'image':
                 if (!Zend_Uri::check($optionValues['url']) && !is_file($optionValues['url'])) {
                     $optionDw->error(new XenForo_Phrase('sonnb_xengallery_watermark_image_not_valid'), $optionId);
                     return false;
                 }
                 break;
             case 'text':
                 if (!self::isTextColorValid($optionValues['textColor'])) {
                     $optionDw->error(new XenForo_Phrase('sonnb_xengallery_watermark_text_color_not_valid'), $optionId);
                     return false;
                 }
                 if (!self::isBgColorValid($optionValues['bgColor'])) {
                     $optionDw->error(new XenForo_Phrase('sonnb_xengallery_watermark_bg_color_not_valid'), $optionId);
                     return false;
                 }
                 if (!empty($optionValues['font']) && !is_file($optionValues['font'])) {
                     $optionDw->error(new XenForo_Phrase('sonnb_xengallery_watermark_font_path_not_valid'), $optionId);
                     return false;
                 }
                 break;
         }
     }
     return true;
 }
Ejemplo n.º 3
0
 public static function xenWrapperCallback(array &$configs, XenForo_DataWriter $dw, $fieldName)
 {
     if (isset($configs['Bbm_wrapper_callback']) && $configs['Bbm_wrapper_callback'] == 'callback' && !BBM_Helper_Bbm::callbackChecker($configs['class'], $configs['method'])) {
         $dw->error(new XenForo_Phrase('bbm_xenwrapper_callback_not_valid'));
     }
     return true;
 }
Ejemplo n.º 4
0
 public function schedule($optionId, XenForo_DataWriter $dw, $dwField, $key = false)
 {
     extract($this->_getTargets($optionId, $key));
     if (!empty($included)) {
         $dw->set($dwField, array('targets' => $targets));
     }
 }
Ejemplo n.º 5
0
 /**
  * Verifies that the Google Analytics Web Property ID is valid, if specified.
  * See https://www.google.com/support/googleanalytics/bin/answer.py?answer=113500
  *
  * @param string $wpId
  * @param XenForo_DataWriter $dw
  * @param string $fieldName
  *
  * @return boolean
  */
 public static function verifyGoogleAnalyticsWebPropertyId(&$wpId, XenForo_DataWriter $dw, $fieldName)
 {
     if ($wpId !== '' && !preg_match('/^UA-\\d+-\\d+$/', $wpId)) {
         $dw->error(new XenForo_Phrase('please_enter_your_google_analytics_web_property_id_in_format'), $fieldName);
         return false;
     }
     return true;
 }
Ejemplo n.º 6
0
 public static function verifyOption(&$optionValue, XenForo_DataWriter $dw, $fieldName)
 {
     if ($optionValue == 'imPecl' && !class_exists('Imagick')) {
         $dw->error(new XenForo_Phrase('must_have_imagick_pecl_extension'), $fieldName);
         return false;
     }
     return true;
 }
Ejemplo n.º 7
0
 /**
  * Verifies that the provided string is a valid URL
  *
  * @param string $url
  *
  * @return boolean
  */
 public static function verifyUri(&$uri, XenForo_DataWriter $dw, $fieldName = false)
 {
     if (Zend_Uri::check($uri)) {
         return true;
     }
     $dw->error(new XenForo_Phrase('please_enter_valid_url'), $fieldName);
     return false;
 }
Ejemplo n.º 8
0
 /**
  * Verifies the license key.
  *
  * @param string $licenseKey license key to be verified
  * @param XenForo_DataWriter $dw Calling DW
  * @param string $fieldName Name of field/option
  *
  * @return true
  */
 public static function verifyOption(&$licenseKey, XenForo_DataWriter $dw, $fieldName)
 {
     if (XenForo_Application::getOptions()->simpleFormsLicenseKey && !self::VerifyLicense($licenseKey)) {
         $errorMessage = 'The license key you entered is invalid. If you are having trouble with your license, please contact <a href="https://liquidpro.net/clients/clientarea.php" target="_blank">LiquidPro Support</a>.';
         $dw->error($errorMessage, $fieldName);
     }
     return true;
 }
Ejemplo n.º 9
0
 public static function validateOption(&$choices, XenForo_DataWriter $dw, $fieldName)
 {
     if ($dw->isInsert()) {
         return true;
     }
     if (!in_array($choices, self::$navbarPositions)) {
         $dw->error(new XenForo_Phrase('invalid_argument'), $fieldName);
         return false;
     }
     return true;
 }
 public static function verifyOption(&$optionValue, XenForo_DataWriter $dw, $fieldName)
 {
     if ($dw->isInsert()) {
         return true;
     }
     $redirects = new XenGallery_Option_Redirects();
     $redirects->addOnId = 'EWRmedio';
     $redirects->route = 'ewrmedio';
     $redirects->replaceRoute = 'media';
     $redirects->verifyOptionForAddOn($optionValue, $dw, $fieldName);
     return true;
 }
Ejemplo n.º 11
0
 /**
  * Verifies that the provided integer is a valid mood ID
  *
  * @param integer $moodId
  * @param XenForo_DataWriter The current running data writer
  * @param string Field being affected
  *
  * @return boolean
  */
 public static function verifyMoodId($moodId, XenForo_DataWriter $dw, $fieldName = false)
 {
     if ($moodId === 0) {
         // explicitly set to 0, use system default
         return true;
     }
     if ($dw->getModelFromCache('XenMoods_Model_Mood')->getMoodById($moodId)) {
         return true;
     }
     $dw->error(new XenForo_Phrase('please_select_valid_mood'), $fieldName);
     return false;
 }
Ejemplo n.º 12
0
 public static function verifyUsernameExists(&$username, XenForo_DataWriter $dw = null, $fieldName = null)
 {
     if ($username != '') {
         $userModel = XenForo_Model::create('XenForo_Model_User');
         $user = $userModel->getUserByName($username);
         if (!$user) {
             $dw->error(new XenForo_Phrase('AWickham_SourceBansSync_InvalidUsername'));
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 13
0
 /**
  * Updates the build date of styles after the value of the minifyCss option changes.
  *
  * @param boolean $option
  * @param XenForo_DataWriter $dw
  * @param string $fieldName
  *
  * @return boolean
  */
 public static function verifyOption(&$option, XenForo_DataWriter $dw, $fieldName)
 {
     if ($dw->isInsert()) {
         return true;
         // don't need to do anything
     }
     if ($option) {
         XenForo_Model::create('XenForo_Model_Template')->writeTemplateFiles(false, false);
     } else {
         XenForo_Model::create('XenForo_Model_Template')->deleteTemplateFiles();
     }
     return true;
 }
Ejemplo n.º 14
0
 /**
  * Verifies the autoEmbedMedia setting
  *
  * @param array $values
  * @param XenForo_DataWriter $dw Calling DW
  * @param string $fieldName Name of field/option
  *
  * @return true
  */
 public static function verifyOption(array &$values, XenForo_DataWriter $dw, $fieldName)
 {
     if (empty($values['linkBbCode'])) {
         $values['linkBbCode'] = '[i][size=2][url={$url}]View: {$url}[/url][/size][/i]';
     }
     if ($values['embedType'] != XenForo_Helper_Media::AUTO_EMBED_MEDIA_DISABLED) {
         if (strpos($values['linkBbCode'], '{$url}') === false) {
             $dw->error(new XenForo_Phrase('link_bbcode_must_include_url_token'), $fieldName);
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 15
0
 public static function verifySerialized(&$serial, XenForo_DataWriter $dw, $fieldName = false)
 {
     if (!is_string($serial)) {
         $serial = serialize($serial);
         return true;
     }
     if (@unserialize($serial) === false && $serial != serialize(false)) {
         // debugging message, no need for phrasing
         $dw->error('The data provided as a serialized array does not unserialize.', $fieldName);
         return false;
     }
     return true;
 }
Ejemplo n.º 16
0
 public static function validateColour($value, XenForo_DataWriter $dw, $fieldName)
 {
     // #fff and #fff444 are acceptable formats here
     if (strlen($value) != 7 && strlen($value) != 4) {
         $dw->error(new XenForo_Phrase("mc_assoc_errors_hex_colour"), $fieldName);
     }
     $truncatedValue = substr($value, 1);
     // chop off the #
     if (!ctype_xdigit($truncatedValue) || $value[0] != "#") {
         $dw->error(new XenForo_Phrase("mc_assoc_errors_hex_colour"), $fieldName);
     }
     return $dw;
 }
Ejemplo n.º 17
0
 public static function verifyTweetOption(array &$option, XenForo_DataWriter $dw, $fieldName)
 {
     if (!empty($option['enabled'])) {
         if (!empty($option['via']) && !XenForo_Helper_UserField::verifyTwitter(array(), $option['via'], $error)) {
             $dw->error($error, $fieldName);
             return false;
         }
         if (!empty($option['related']) && !XenForo_Helper_UserField::verifyTwitter(array(), $option['related'], $error)) {
             $dw->error($error, $fieldName);
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 18
0
 public static function verifyOption(array &$options, XenForo_DataWriter $dw, $fieldName)
 {
     if (!$dw->isInsert()) {
         $grouped = array();
         foreach ($options as $option) {
             if (!isset($option['group']) || strval($option['group']) === '') {
                 continue;
             }
             $grouped[strval($option['group'])][] = array('group' => strval($option['group']), 'name' => strval($option['name']), 'format' => strval($option['format']));
         }
         $options = $grouped;
     }
     return true;
 }
Ejemplo n.º 19
0
 public static function verifyTweetOption(array &$option, XenForo_DataWriter $dw, $fieldName)
 {
     if (!empty($option['enabled'])) {
         if (!XenForo_Model_IdentityService_Twitter::verifyAccountName($option['via'], $error)) {
             $dw->error($error);
             return false;
         }
         if (!XenForo_Model_IdentityService_Twitter::verifyAccountName($option['related'], $error)) {
             $dw->error($error);
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 20
0
 public static function verifyPosition(&$positions, XenForo_DataWriter $dw, $fieldName = false)
 {
     $positions = trim($positions);
     if (empty($positions)) {
         $dw->error(new XenForo_Phrase('wf_position_can_not_be_empty'), $fieldName);
     }
     if ('all' == $positions) {
         return true;
     }
     /** @var XenForo_Model_Template $templateModel */
     $templateModel = $dw->getModelFromCache('XenForo_Model_Template');
     $db = XenForo_Application::getDb();
     $positionsArray = explode(',', $positions);
     $positionsGood = array();
     $templateForHooks = array();
     foreach ($positionsArray as $position) {
         $position = trim($position);
         if (empty($position)) {
             continue;
         }
         if (in_array($position, array('wf_widget_page', 'hook:wf_widget_page_contents'), true) and !$dw->get('widget_page_id')) {
             $dw->error(new XenForo_Phrase('wf_position_x_requires_widget_page', array('position' => $position)), $fieldName);
             return false;
         }
         if (in_array($position, array('wf_widget_ajax'), true)) {
             $dw->error(new XenForo_Phrase('wf_invalid_position_x', array('position' => $position)), $fieldName);
             return false;
         }
         // sondh@2012-08-25
         // added support for hook:hook_name
         if (substr($position, 0, 5) == 'hook:') {
             // accept all kind of hooks, just need to get parent templates for them
             $templates = $db->fetchAll("\n\t\t\t\t\tSELECT title\n\t\t\t\t\tFROM `xf_template_compiled`\n\t\t\t\t\tWHERE template_compiled LIKE " . XenForo_Db::quoteLike('callTemplateHook(\'' . substr($position, 5) . '\',', 'lr') . "\n\t\t\t\t");
             if (count($templates) > 0) {
                 $templateForHooks[$position] = array();
                 foreach ($templates as $template) {
                     $templateForHooks[$position][] = $template['title'];
                 }
                 $templateForHooks[$position] = array_unique($templateForHooks[$position]);
             } else {
                 $dw->error(new XenForo_Phrase('wf_non_existent_hook_x', array('hook' => substr($position, 5))), $fieldName);
                 return false;
             }
         } elseif (!$templateModel->getTemplateInStyleByTitle($position)) {
             $dw->error(new XenForo_Phrase('wf_invalid_position_x', array('position' => $position)), $fieldName);
             return false;
         }
         $positionsGood[] = $position;
     }
     $dw->setExtraData(WidgetFramework_DataWriter_Widget::EXTRA_DATA_TEMPLATE_FOR_HOOKS, $templateForHooks);
     asort($positionsGood);
     $positions = implode(', ', $positionsGood);
     return true;
 }
 public static function verifyOption(array &$choices, XenForo_DataWriter $dw, $fieldName)
 {
     if ($dw->isInsert()) {
         // insert - just trust the default value
         return true;
     }
     $exclusions = array();
     foreach (XenForo_Model::create('XenForo_Model_AdminSearch')->getAllSearchTypes() as $searchType => $handlerName) {
         if (empty($choices[$searchType])) {
             $exclusions[$searchType] = true;
         }
     }
     $choices = $exclusions;
     return true;
 }
Ejemplo n.º 22
0
 public function execute(array $deferred, array $data, $targetRunTime, &$status)
 {
     $data = array_merge(array('batch' => 100, 'position' => 0, 'positionRebuild' => false), $data);
     /* @var $threadModel XenForo_Model_Thread */
     $threadModel = XenForo_Model::create('XenForo_Model_Thread');
     $threadIds = $threadModel->getThreadIdsInRange($data['position'], $data['batch']);
     if (sizeof($threadIds) == 0) {
         return false;
     }
     $forums = XenForo_Model::create('XenForo_Model_Forum')->getForumsByThreadIds($threadIds);
     foreach ($threadIds as $threadId) {
         $data['position'] = $threadId;
         $dw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread', XenForo_DataWriter::ERROR_SILENT);
         if ($dw->setExistingData($threadId)) {
             $dw->setOption(XenForo_DataWriter_Discussion::OPTION_UPDATE_CONTAINER, false);
             if (isset($forums[$dw->get('node_id')])) {
                 $dw->setExtraData(XenForo_DataWriter_Discussion_Thread::DATA_FORUM, $forums[$dw->get('node_id')]);
             }
             if ($data['positionRebuild']) {
                 $dw->rebuildDiscussion();
             } else {
                 $dw->rebuildDiscussionCounters();
             }
             $dw->save();
         }
     }
     $actionPhrase = new XenForo_Phrase('rebuilding');
     $typePhrase = new XenForo_Phrase('threads');
     $status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
     return $data;
 }
Ejemplo n.º 23
0
 public function actionSave()
 {
     $dwInput = $this->_input->filter(array('event_id' => XenForo_Input::STRING, 'description' => XenForo_Input::STRING, 'callback_class' => XenForo_Input::STRING, 'callback_method' => XenForo_Input::STRING, 'hint' => XenForo_Input::STRING, 'addon_id' => XenForo_Input::STRING));
     if (!empty($dwInput['event_id']) && empty($dwInput['description']) && empty($dwInput['callback_class']) && empty($dwInput['callback_class']) && !empty($dwInput['hint']) && !empty($dwInput['addon_id'])) {
         /** @var XenForo_Model_AddOn $addOnModel */
         $addOnModel = $this->getModelFromCache('XenForo_Model_AddOn');
         $addOn = $addOnModel->getAddOnById($dwInput['addon_id']);
         /** @var DevHelper_Model_Config $configModel */
         $configModel = $this->getModelFromCache('DevHelper_Model_Config');
         $config = $configModel->loadAddOnConfig($addOn);
         if (strpos($dwInput['event_id'], 'load_class') === 0) {
             $classPath = DevHelper_Generator_File::getClassPath($dwInput['hint']);
             if (is_file($classPath)) {
                 $method = DevHelper_Generator_Code_Listener::generateLoadClass($dwInput['hint'], $addOn, $config);
                 if ($method) {
                     $clazz = DevHelper_Generator_Code_Listener::getClassName($addOn, $config);
                     $this->_request->setParam('description', $dwInput['hint']);
                     $this->_request->setParam('callback_class', $clazz);
                     $this->_request->setParam('callback_method', $method);
                     XenForo_DataWriter::create('XenForo_DataWriter_CodeEventListener');
                 }
             }
         }
     }
     return parent::actionSave();
 }
Ejemplo n.º 24
0
 public function actionTrash()
 {
     if (!XenForo_Visitor::getInstance()->hasPermission('forum', 'trashThreads')) {
         throw $this->getErrorOrNoPermissionResponseException(false);
     }
     if (!($targetNode = XenForo_Application::getOptions()->nixfifty_trash_can)) {
         return $this->responseError(new XenForo_Phrase('trash_can_node_not_set'));
     }
     $threadId = $this->_input->filterSingle('thread_id', XenForo_Input::UINT);
     list($thread, $forum) = $this->getHelper('ForumThreadPost')->assertThreadValidAndViewable($threadId);
     if ($this->isConfirmedPost()) {
         $softDelete = $this->_input->filterSingle('trash_type', XenForo_Input::UINT);
         $trashType = $softDelete ? 'move' : 'soft';
         $options = array('reason' => $this->_input->filterSingle('reason', XenForo_Input::STRING));
         $dw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
         $dw->setExistingData($threadId);
         $dw->set('node_id', $targetNode);
         $dw->save();
         if ($trashType == 'soft' && XenForo_Visitor::getInstance()->hasPermission('forum', 'softDeleteTrashedThreads')) {
             $this->_getThreadModel()->deleteThread($threadId, $trashType, $options);
             XenForo_Model_Log::logModeratorAction('thread', $thread, 'delete_' . $trashType, array('reason' => $options['reason']));
         }
         XenForo_Model_Log::logModeratorAction('thread', $thread, 'move', array('from' => $forum['title']));
         $this->_updateModeratorLogThreadEdit($thread, $dw, array('node_id'));
         return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('forums', $forum));
     } else {
         return $this->responseView('', 'trash_thread', array('thread' => $thread));
     }
 }
Ejemplo n.º 25
0
 /**
  *
  * @see XenResource_DataWriter_Resource::_insertDiscussionThread()
  */
 protected function _insertDiscussionThread($nodeId, $prefixId = 0)
 {
     /* @var $nodeModel XenForo_Model_Node */
     $nodeModel = $this->getModelFromCache('XenForo_Model_Node');
     $node = $nodeModel->getNodeById($nodeId);
     if (!$node) {
         return false;
     }
     if ($node['node_type_id'] == 'SocialCategory') {
         $socialForumId = 0;
         if (isset($GLOBALS['XenResource_ControllerPublic_Resource'])) {
             /* @var $controller XenResource_ControllerPublic_Resource */
             $controller = $GLOBALS['XenResource_ControllerPublic_Resource'];
             $socialForumId = $controller->getInput()->filterSingle('social_forum_id', XenForo_Input::UINT);
         }
         if ($socialForumId) {
             $socialForumModel = ThemeHouse_SocialGroups_SocialForum::getSocialForumModel();
             $socialForum = $socialForumModel->getSocialForumById($socialForumId);
         }
         if (!empty($socialForum) && $socialForum['node_id'] == $node['node_id']) {
             ThemeHouse_SocialGroups_SocialForum::setup($socialForum);
             // TODO check permissions
         } else {
             $writer = XenForo_DataWriter::create('ThemeHouse_SocialGroups_DataWriter_SocialForum');
             $writer->bulkSet(array('node_id' => $nodeId, 'user_id' => XenForo_Visitor::getUserId(), 'title' => $this->_getThreadTitle(), 'description' => $this->get('tag_line'), 'social_forum_type' => 'resource'));
             $writer->save();
             ThemeHouse_SocialGroups_SocialForum::setup($writer->getMergedData());
             $this->set('social_forum_id', $writer->get('social_forum_id'), '', array('setAfterPreSave' => true));
         }
     }
     return parent::_insertDiscussionThread($nodeId, $prefixId);
 }
Ejemplo n.º 26
0
 protected function _log(array $logUser, array $content, $action, array $actionParams = array(), $parentContent = null)
 {
     $dw = XenForo_DataWriter::create('XenForo_DataWriter_ModeratorLog');
     $dw->bulkSet(array('user_id' => $logUser['user_id'], 'content_type' => 'resource_category', 'content_id' => $content['resource_category_id'], 'content_user_id' => $logUser['user_id'], 'content_username' => $logUser['username'], 'content_title' => $content['category_title'], 'content_url' => XenForo_Link::buildPublicLink('resources/categories', $content), 'discussion_content_type' => 'resource_category', 'discussion_content_id' => $content['resource_category_id'], 'action' => $action, 'action_params' => $actionParams));
     $dw->save();
     return $dw->get('moderator_log_id');
 }
Ejemplo n.º 27
0
 /**
  * @param array $logUser
  * @param array $content
  * @param $action
  * @param array $actionParams
  * @param null $parentContent
  * @return mixed
  */
 protected function _log(array $logUser, array $content, $action, array $actionParams = array(), $parentContent = null)
 {
     $dw = XenForo_DataWriter::create('XenForo_DataWriter_ModeratorLog');
     $dw->bulkSet(array('user_id' => $logUser['user_id'], 'content_type' => sonnb_XenGallery_Model_Photo::$xfContentType, 'content_id' => $content['content_id'], 'content_user_id' => $content['user_id'], 'content_username' => $content['username'], 'content_title' => XenForo_Helper_String::wordWrapString($content['title'], 140), 'content_url' => XenForo_Link::buildPublicLink('gallery/photos', $content), 'discussion_content_type' => sonnb_XenGallery_Model_Photo::$xfContentType, 'discussion_content_id' => $content['content_id'], 'action' => $action, 'action_params' => $actionParams));
     $dw->save();
     return $dw->get('moderator_log_id');
 }
Ejemplo n.º 28
0
 public function actionExpire()
 {
     $warningId = $this->_input->filterSingle('warning_id', XenForo_Input::UINT);
     $warning = $this->_getWarningOrError($warningId);
     if (!$this->_getUserModel()->canViewWarnings() || !$this->_getWarningModel()->canUpdateWarningExpiration($warning)) {
         return $this->responseNoPermission();
     }
     if ($this->isConfirmedPost()) {
         $expire = $this->_input->filterSingle('expire', XenForo_Input::STRING);
         if ($expire == 'now') {
             $expiryDate = XenForo_Application::$time;
         } else {
             if ($expire == 'future') {
                 $expiryLength = $this->_input->filterSingle('expiry_length', XenForo_Input::UINT);
                 $expiryUnit = $this->_input->filterSingle('expiry_unit', XenForo_Input::STRING);
                 $expiryDate = strtotime("+{$expiryLength} {$expiryUnit}");
                 $expiryDate = min(pow(2, 32) - 1, $expiryDate);
                 if (!$expiryDate || $expiryDate < XenForo_Application::$time) {
                     $expiryDate = XenForo_Application::$time;
                 }
             } else {
                 return $this->responseReroute(__CLASS__, 'index');
             }
         }
         $dw = XenForo_DataWriter::create('XenForo_DataWriter_Warning');
         $dw->setExistingData($warning, true);
         $dw->set('expiry_date', $expiryDate);
         $dw->save();
         return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect());
     } else {
         return $this->responseReroute(__CLASS__, 'index');
     }
 }
Ejemplo n.º 29
0
 /**
  * Displays a form to change the visitor's language, or changes it if a language_id is present.
  *
  * @return XenForo_ControllerResponse_Abstract
  */
 public function actionLanguage()
 {
     $visitor = XenForo_Visitor::getInstance();
     if ($this->_input->inRequest('language_id')) {
         $this->_checkCsrfFromToken($this->_input->filterSingle('_xfToken', XenForo_Input::STRING));
         $languageId = $this->_input->filterSingle('language_id', XenForo_Input::UINT);
         if ($languageId) {
             $languages = XenForo_Application::isRegistered('languages') ? XenForo_Application::get('languages') : XenForo_Model::create('XenForo_Model_Language')->getAllLanguagesForCache();
             if (!isset($languages[$languageId])) {
                 $languageId = 0;
             }
         }
         if ($visitor['user_id']) {
             $dw = XenForo_DataWriter::create('XenForo_DataWriter_User');
             $dw->setExistingData($visitor['user_id']);
             $dw->set('language_id', $languageId);
             $dw->save();
             XenForo_Helper_Cookie::deleteCookie('language_id');
         } else {
             XenForo_Helper_Cookie::setCookie('language_id', $languageId, 86400 * 365);
         }
         return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(false, false));
     } else {
         $languages = XenForo_Application::isRegistered('languages') ? XenForo_Application::get('languages') : XenForo_Model::create('XenForo_Model_Language')->getAllLanguagesForCache();
         $viewParams = array('languages' => $this->getModelFromCache('XenForo_Model_Language')->getAllLanguages(), 'redirect' => $this->getDynamicRedirect(false, false));
         return $this->responseView('XenForo_ViewPublic_Misc_Language', 'language_chooser', $viewParams);
     }
 }
Ejemplo n.º 30
0
 public function Team_actionAddThread(XenForo_DataWriter $dw)
 {
     $teamId = $this->_input->filterSingle('team_id', XenForo_Input::UINT);
     $team = $this->getModelFromCache('Nobita_Teams_Model_Team')->getFullTeamById($teamId, array('join' => Nobita_Teams_Model_Team::FETCH_CATEGORY));
     if (!$team) {
         // normal post.. outside of groups.
     } else {
         if (!$this->getModelFromCache('Nobita_Teams_Model_Thread')->canAddThread($team, $team, $error)) {
             // nothing to do
         } else {
             $dw->set('team_id', $team['team_id']);
             $dw->set('discussion_type', 'team');
         }
     }
     unset($GLOBALS[Nobita_Teams_Listener::TEAM_CONTROLLERPUBLIC_FORUM_ADDTHREAD]);
 }