public function actionDiscordLink() { $this->_assertPostOnly(); $visitor = XenForo_Visitor::getInstance(); if (!$visitor->hasPermission('general', 'linkDiscord')) { return $this->responseNoPermission(); } $tokenModel = $this->_getTokenmodel(); $generate = $this->_input->filterSingle('create', XenForo_Input::STRING, array('default' => '')); if (strlen($generate)) { $dw = XenForo_DataWriter::create('DiscordAuth_DataWriter_Token'); $existing = $tokenModel->getTokenByUserId($visitor['user_id']); if ($existing === false || !$existing['valid']) { if ($existing !== false) { $dw->setExistingData($existing, true); } try { $dw->set('user_id', $visitor['user_id']); $dw->set('token', self::generateToken()); $dw->save(); // self::generateToken may throw Exception } catch (Exception $e) { XenForo_Error::logException($e, false); } } } $unlink = $this->_input->filterSingle('unlink', XenForo_Input::STRING, array('default' => '')); if (strlen($unlink)) { $dw = XenForo_DataWriter::create('XenForo_DataWriter_User'); $dw->setExistingData($visitor['user_id']); $dw->set('da_discord_id', null); $dw->save(); } return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(XenForo_Link::buildPublicLink('account/discord'))); }
public function getUser() { $visitor = XenForo_Visitor::getInstance(); $userModel = XenForo_Model::create('XenForo_Model_User'); $userInfo = $userModel->getFullUserById($visitor->getUserId()); return $userInfo; }
public function actionErrorServer() { $upgradePending = false; try { $db = XenForo_Application::getDb(); if ($db->isConnected()) { $dbVersionId = $db->fetchOne("SELECT option_value FROM xf_option WHERE option_id = 'currentVersionId'"); if ($dbVersionId && $dbVersionId != XenForo_Application::$versionId) { $upgradePending = true; } } } catch (Exception $e) { } if (XenForo_Application::debugMode()) { $showDetails = true; } else { if (XenForo_Visitor::hasInstance() && XenForo_Visitor::getInstance()->is_admin) { $showDetails = true; } else { $showDetails = false; } } if ($upgradePending && !$showDetails) { return $this->responseMessage(new XenForo_Phrase('board_currently_being_upgraded')); } else { if ($showDetails) { $view = $this->responseView('XenForo_ViewPublic_Error_ServerError', 'error_server_error', array('exception' => $this->_request->getParam('_exception'))); $view->responseCode = 500; return $view; } else { return $this->responseError(new XenForo_Phrase('server_error_occurred'), 500); } } }
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)); } }
/** * * @see XenForo_DataWriter_DiscussionMessage_Post::_messagePreSave() */ protected function _messagePreSave() { if ($this->isDiscussionFirstMessage() && isset($GLOBALS['XenForo_ControllerPublic_Forum'])) { $visitor = XenForo_Visitor::getInstance(); $this->set('original_poster_th', array('user_id' => $visitor->user_id, 'username' => $visitor->username)); } if (!empty($GLOBALS['XenForo_ControllerPublic_Thread'])) { /* @var $controller XenForo_ControllerPublic_Thread */ $controller = $GLOBALS['XenForo_ControllerPublic_Thread']; $this->set('original_poster_th', array('user_id' => $this->get('user_id'), 'username' => $this->get('username'))); /* @var $userModel XenForo_Model_User */ $userModel = XenForo_Model::create('XenForo_Model_User'); $input = $controller->getInput()->filter(array('post_as_user_id' => XenForo_Input::UINT, 'post_as_username' => XenForo_Input::STRING)); if ($input['post_as_username']) { $user = $userModel->getUserByName($input['post_as_username']); $input['post_as_user_id'] = $user['user_id']; } if (!isset($user) && $input['post_as_user_id']) { $user = $userModel->getUserById($input['post_as_user_id']); } if (isset($user) && $userModel->canPostAsDifferentUser($user)) { $this->set('user_id', $user['user_id']); $this->set('username', $user['username']); if (XenForo_Application::get('options')->th_postAsUser_updateLastActivity) { /* @var $userModel XenForo_Model_User */ $userModel = $this->getModelFromCache('XenForo_Model_User'); $request = $controller->getRequest(); $routeMatch = $controller->getRouteMatch(); $userModel->updateSessionActivity($user['user_id'], $request->getClientIp(false), $routeMatch->getControllerName(), $routeMatch->getAction(), 'valid', $request->getUserParams()); } } } parent::_messagePreSave(); }
protected function _getSessionActivityList() { $visitor = XenForo_Visitor::getInstance(); /** @var $sessionModel XenForo_Model_Session */ $sessionModel = $this->getModelFromCache('XenForo_Model_Session'); return $sessionModel->getSessionActivityQuickList($visitor->toArray(), array('cutOff' => array('>', $sessionModel->getOnlineStatusTimeout())), $visitor['user_id'] ? $visitor->toArray() : null); }
/** * Single-stage logout procedure */ public function actionIndex() { $csrfToken = $this->_input->filterSingle('_xfToken', XenForo_Input::STRING); $redirectResponse = $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(false, false)); $userId = XenForo_Visitor::getUserId(); if (!$userId) { return $redirectResponse; } if ($this->_noRedirect() || !$csrfToken) { // request is likely from JSON, probably XenForo.OverlayTrigger, so show a confirmation dialog return $this->responseView('XenForo_ViewPublic_LogOut', 'log_out'); } else { $this->_checkCsrfFromToken($csrfToken); // remove an admin session if we're logged in as the same person if (XenForo_Visitor::getInstance()->get('is_admin')) { $class = XenForo_Application::resolveDynamicClass('XenForo_Session'); $adminSession = new $class(array('admin' => true)); $adminSession->start(); if ($adminSession->get('user_id') == $userId) { $adminSession->delete(); } } $this->getModelFromCache('XenForo_Model_Session')->processLastActivityUpdateForLogOut(XenForo_Visitor::getUserId()); XenForo_Application::get('session')->delete(); XenForo_Helper_Cookie::deleteAllCookies($this->_getRetainedCookies(), array('user' => array('httpOnly' => false))); XenForo_Visitor::setup(0); return $redirectResponse; } }
public function getPermissionsFromContext(array $context, array $parentContext = null) { // Context could be some previously fetched permissions, media, album or category... if (isset($context['tagger_permissions'])) { return $context['tagger_permissions']; } else { if (isset($context['media_id'])) { $media = $context; $container = $parentContext; } else { $media = null; $container = $context; } } if (!$container || empty($container['album_id']) && empty($container['category_id'])) { throw new Exception("Context must be a media item and an album/category or just an album/category"); } $visitor = XenForo_Visitor::getInstance(); if ($media) { if ($media['user_id'] == $visitor['user_id'] && XenForo_Permission::hasPermission($visitor['permissions'], 'xengallery', 'manageOthersTagsOwnMedia')) { $removeOthers = true; } else { $removeOthers = XenForo_Permission::hasPermission($visitor['permissions'], 'xengallery', 'manageAnyTag'); } } else { $removeOthers = false; } return array('edit' => $this->_getMediaModel()->canEditTags($media), 'removeOthers' => $removeOthers, 'minTotal' => isset($container['min_tags']) ? $container['min_tags'] : XenForo_Application::getOptions()->xengalleryAlbumMinTags); }
protected function _thSocialForumDescriptionAboveSocialgroups() { $viewParams = $this->_fetchViewParams(); if ($viewParams['socialForum']['social_forum_type'] == 'resource') { /* @var $resourceModel XenResource_Model_Resource */ $resourceModel = XenForo_Model::create('XenResource_Model_Resource'); $fetchOptions = array('join' => XenResource_Model_Resource::FETCH_CATEGORY | XenResource_Model_Resource::FETCH_USER | XenResource_Model_Resource::FETCH_ATTACHMENT | XenResource_Model_Resource::FETCH_VERSION, 'watchUserId' => XenForo_Visitor::getUserId()); if (XenForo_Visitor::getInstance()->hasPermission('resource', 'viewDeleted')) { $fetchOptions['join'] |= XenResource_Model_Resource::FETCH_DELETION_LOG; } $resource = $resourceModel->getResourceBySocialForumId($viewParams['socialForum']['social_forum_id'], $fetchOptions); if ($resource && $resourceModel->canViewResourceAndContainer($resource, $resource)) { /* @var $categoryModel XenResource_Model_Category */ $categoryModel = XenForo_Model::create('XenResource_Model_Category'); $updateConditions = $categoryModel->getPermissionBasedFetchConditions($resource); if ($updateConditions['deleted'] === true || $updateConditions['moderated'] === true || $updateConditions['moderated'] == $resource['user_id']) { /* @var $updateModel XenResource_Model_Update */ $updateModel = XenForo_Model::create('XenResource_Model_Update'); $resourceUpdateCount = $updateModel->countUpdates($updateConditions + array('resource_id' => $resource['resource_id'], 'resource_update_id_not' => $resource['description_update_id'])); } else { $resourceUpdateCount = $resource['update_count']; } $resource = $resourceModel->prepareResource($resource, $resource); $this->_appendTemplate('resource_view_tabs', $viewParams + array('resource' => $resource, 'resourceUpdateCount' => $resourceUpdateCount, 'selectedTab' => 'discussion')); ThemeHouse_SocialGroups_SocialForum::getInstance()->setResource($resource); } } }
public static function controllerPreDispatch(XenForo_Controller $controller, $action) { if ($controller instanceof XenForo_ControllerPublic_Abstract) { if (self::$_updatedMediaCounts === false) { self::$_updatedMediaCounts = true; $options = XenForo_Application::getOptions(); $visitor = XenForo_Visitor::getInstance(); if ($options->xengalleryUnviewedCounter['enabled'] && $visitor->xengallery_unviewed_media_count && XenForo_Application::isRegistered('session')) { $time = XenForo_Application::$time; $session = XenForo_Application::get('session'); $mediaUnviewed = $session->get('mediaUnviewed'); if ($mediaUnviewed === false || $mediaUnviewed['lastUpdateDate'] < $time - $options->xengalleryUnviewedCounter['length'] * 60) { /** @var $mediaModel XenGallery_Model_Media */ $mediaModel = XenForo_Model::create('XenGallery_Model_Media'); $unviewedIds = $mediaModel->getUnviewedMediaIds($visitor->user_id, array('viewCategoryIds' => $mediaModel->getViewableCategoriesForVisitor($visitor->toArray()), 'viewAlbums' => XenForo_Permission::hasPermission($visitor->permissions, 'xengallery', 'viewAlbums'))); if ($unviewedIds !== false) { if (sizeof($unviewedIds)) { $mediaUnviewed = array('unviewed' => array_combine($unviewedIds, $unviewedIds), 'lastUpdateDate' => $time); } else { $mediaUnviewed = self::_getDefaultUnviewedArray(); } } } elseif (!$visitor->user_id) { $mediaUnviewed = self::_getDefaultUnviewedArray(); } $session->set('mediaUnviewed', $mediaUnviewed); } } } }
public function getWrapper($selectedGroup, $selectedLink, XenForo_ControllerResponse_View $subView) { $viewParams = array('selectedGroup' => $selectedGroup, 'selectedLink' => $selectedLink, 'selectedKey' => "{$selectedGroup}/{$selectedLink}", 'canStartConversation' => $this->_controller->getModelFromCache('XenForo_Model_Conversation')->canStartConversations(), 'canEditSignature' => XenForo_Visitor::getInstance()->canEditSignature(), 'canEditProfile' => XenForo_Visitor::getInstance()->canEditProfile()); $wrapper = $this->_controller->responseView('XenForo_ViewPublic_Account_Wrapper', 'account_wrapper', $viewParams); $wrapper->subView = $subView; return $wrapper; }
public function actionIndex() { // styles $styleModel = $this->getModelFromCache('XenForo_Model_Style'); $styles = $styleModel->getAllStylesAsFlattenedTree(); $styles = $styleModel->countCustomTemplatesPerStyle($styles); if ($styleModel->showMasterStyle()) { $masterStyle = $styleModel->getStyleById(0, true); $masterTemplates = $styleModel->countMasterTemplates(); } else { $masterStyle = null; $masterTemplates = 0; } // languages $languageModel = $this->getModelFromCache('XenForo_Model_Language'); $languages = $languageModel->getAllLanguagesAsFlattenedTree(); $languages = $languageModel->countTranslatedPhrasesPerLanguage($languages); if ($languageModel->showMasterLanguage()) { $masterLanguage = $languageModel->getLanguageById(0, true); $masterPhrases = $languageModel->countMasterPhrases(); } else { $masterLanguage = null; $masterPhrases = 0; } $visitor = XenForo_Visitor::getInstance(); $viewParams = array('canEditStyles' => $visitor->hasAdminPermission('style'), 'canEditLanguages' => $visitor->hasAdminPermission('language'), 'styles' => $styles, 'masterStyle' => $masterStyle, 'masterTemplates' => $masterTemplates, 'languages' => $languages, 'masterLanguage' => $masterLanguage, 'masterPhrases' => $masterPhrases); return $this->responseView('XenForo_ViewAdmin_Appearance_Splash', 'appearance_splash', $viewParams); }
public static function get($key) { if (self::$_options === null) { self::$_options = XenForo_Application::get('options'); } switch ($key) { case 'applicationVersionId': return XenForo_Application::$versionId; case 'cacheCutoffDays': return 7; case 'indexTabId': return 'WidgetFramework_home'; case 'layoutEditorEnabled': if (self::$_layoutEditorEnabled === null) { if (!XenForo_Application::isRegistered('session')) { // no session yet... return false; } $session = XenForo_Application::getSession(); self::$_layoutEditorEnabled = $session->get('_WidgetFramework_layoutEditor') === true; if (!self::$_layoutEditorEnabled and !empty($_REQUEST['_layoutEditor'])) { $visitor = XenForo_Visitor::getInstance(); if ($visitor->hasAdminPermission('style')) { self::$_layoutEditorEnabled = true; } } } // use the cached value return self::$_layoutEditorEnabled; } return self::$_options->get('wf_' . $key); }
public function actionGuide() { $options = XenForo_Application::get('options'); if (!XenForo_Visitor::getInstance()->hasPermission('games', 'labdefence') && !XenForo_Visitor::getInstance()->isSuperAdmin() || !$options->displayLabDefence && !XenForo_Visitor::getInstance()->isSuperAdmin() || !$options->displayLabDefenceGuide && !XenForo_Visitor::getInstance()->isSuperAdmin()) { return $this->responseNoPermission(); } /* Set the ID of the post to be loaded */ $postId = $options->labDefenceGuidePostId; /* Create a new ControllerHelper that will help us to get the post */ $ftpHelper = new XenForo_ControllerHelper_ForumThreadPost($this); /* Use the ControllerHelper to see if the post we want to get is viewable by the user browsing */ list($post, $thread) = $ftpHelper->assertPostValidAndViewable($postId); /* If the post has attachments */ if ($post['attach_count'] > 0) { /* Let's get all the attachments of this post, if exists */ $attachmentModel = XenForo_Model::create('XenForo_Model_Attachment'); $attachments = $attachmentModel->getAttachmentsByContentId('post', $postId); foreach ($attachments as $attachment) { /* Insert into the post data the attachments */ $post['attachments'][$attachment['attachment_id']] = $attachmentModel->prepareAttachment($attachment); } } /* These parameters will be used in our template. We need to pass them into the response view. The $post param will be used too in the XenForo_ViewPublic instance */ $viewParams = array('post' => $post); return $this->responseView('QCGames_ViewPublic_LabDefence_Guide', 'labdefence_guide', $viewParams); }
public function actionProfileresultsdisplay() { $maxRes = 100; $visitor = XenForo_Visitor::getInstance(); if (!$visitor['user_id']) { throw $this->getNoPermissionResponseException(); } $uid = $visitor['user_id']; unset($visitor); $query = mb_strtolower($this->_input->filterSingle('q', XenForo_Input::STRING), 'UTF-8'); $q = substr($query, 0, 255); ProfileNdx_search_engine::cleanOldsFromLimit(); ProfileNdx_search_engine::cleanOldsFromCache(); $permission = ProfileNdx_search_engine::userCanSearch($uid, $q); if (!$permission['status']) { return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('search/profileresultswait/', '', array('redirect' => XenForo_Link::buildPublicLink('search/profileresultsdisplay/', '', array('q' => $query)), 'wait' => $permission['wait'])), ''); } $viewpar = ProfileNdx_search_engine::getFromCache($q); if ($viewpar == null) { $results = (new ProfileNdx_search_engine())->search($q); $viewpar = array('search' => array('search_query' => $query), 'results' => array_slice($results, 0, $maxRes), 'totalResults' => count($results), 'resultStartOffset' => 0, 'resultEndOffset' => min(count($results), $maxRes)); $results = (new ProfileNdx_search_engine())->toHtml($viewpar['results']); $viewpar['results'] = $results; ProfileNdx_search_engine::saveToCache($q, $viewpar); } return $this->responseView('XenForo_ViewPublic_Base', 'kiror_search_results', $viewpar); }
public function getPermissionsFromContext(array $context, array $parentContext = null) { if (isset($context['thread_id'])) { $thread = $context; $forum = $parentContext; } else { $thread = null; $forum = $context; } if (!$forum || !isset($forum['node_id'])) { throw new Exception("Context must be a thread and a forum or just a forum"); } $visitor = XenForo_Visitor::getInstance(); // creating a new thread (all tags would be by us) $nodePermissions = $visitor->getNodePermissions($forum['node_id']); if ($thread) { if ($thread['user_id'] == $visitor['user_id'] && XenForo_Permission::hasContentPermission($nodePermissions, 'manageOthersTagsOwnThread')) { $removeOthers = true; } else { $removeOthers = XenForo_Permission::hasContentPermission($nodePermissions, 'manageAnyTag'); } } else { $removeOthers = false; } return array('edit' => $this->_getThreadModel()->canEditTags($thread, $forum), 'removeOthers' => $removeOthers, 'minTotal' => $forum['min_tags']); }
public function actionIndex() { $codes = $this->_getBbmBBCodeModel()->getAllBbCodes(); $bbcodesWithCallbackErrors = $this->_classAndMethodIntegrityCheck($codes); //Add class foreach ($codes as &$code) { if ($code['tag'][0] == '@') { $code['class'] = 'orphanButton'; $code['orphanButton'] = true; } else { $code['class'] = 'normalButton'; $code['orphanButton'] = false; } $code['disableAddon'] = false; if (XenForo_Application::isRegistered('addOns')) { $enableAddons = XenForo_Application::get('addOns'); if (!empty($code['bbcode_addon']) && !isset($enableAddons[$code['bbcode_addon']])) { $code['class'] .= ' disableAddon'; $code['disableAddon'] = true; } } } $viewParams = array('codes' => $codes, 'callbackErrors' => $bbcodesWithCallbackErrors, 'permsBbm' => XenForo_Visitor::getInstance()->hasAdminPermission('bbm_BbCodesAndButtons')); return $this->responseView('Bbm_ViewAdmin_Bbm_BbCodes_List', 'bbm_bb_codes_list', $viewParams); }
public function actionStaff() { $options = XenForo_Application::get('options'); if (!XenForo_Visitor::getInstance()->hasPermission('players', 'view') || !$options->displayPlayers && !XenForo_Visitor::getInstance()->isSuperAdmin() || !$options->displayStaffList && !XenForo_Visitor::getInstance()->isSuperAdmin()) { return $this->responseNoPermission(); } /* Set the ID of the post to be loaded */ $postId = $options->applyStaffPostId; /* Create a new ControllerHelper that will help us to get the post */ $ftpHelper = new XenForo_ControllerHelper_ForumThreadPost($this); /* Use the ControllerHelper to see if the post we want to get is viewable by the user browsing */ list($post, $thread) = $ftpHelper->assertPostValidAndViewable($postId); /* If the post has attachments */ if ($post['attach_count'] > 0) { /* Let's get all the attachments of this post, if exists */ $attachmentModel = XenForo_Model::create('XenForo_Model_Attachment'); $attachments = $attachmentModel->getAttachmentsByContentId('post', $postId); foreach ($attachments as $attachment) { /* Insert into the post data the attachments */ $post['attachments'][$attachment['attachment_id']] = $attachmentModel->prepareAttachment($attachment); } } $mod_raw = file_get_contents($options->restApiUrl . 'player.php?action=getMods&value=name'); $ss_raw = file_get_contents($options->restApiUrl . 'player.php?action=getSS&value=name'); $mods = array(); $ss = array(); while ($name = json_decode($mod_raw, true)) { array_push($mods, $name); } while ($name = json_decode($ss_raw, true)) { array_push($ss, $name); } $viewParams = array('mods' => $mods, 'ss' => $ss, 'post' => $post); return $this->responseView('QCPlayers_ViewPublic_Players_staff', 'player_staff_list', $viewParams); }
public static function navigationTabs(&$extraTabs, $selectedTabId) { $options = XenForo_Application::get('options'); if (XenForo_Visitor::getInstance()->hasPermission('players', 'view') && $options->displayPlayersTab && $options->displayPlayers) { $extraTabs['players'] = array('title' => new XenForo_Phrase('players'), 'href' => XenForo_Link::buildPublicLink('full:players'), 'position' => 'home', 'linksTemplate' => 'player_tab_links'); } }
public function actionPromote() { if (!$this->perms['promote']) { return $this->responseNoPermission(); } $input = $this->_input->filter(array('thread_id' => XenForo_Input::UINT, 'promote_date' => XenForo_Input::UINT, 'promote_icon' => XenForo_Input::STRING, 'attach_data' => XenForo_Input::UINT, 'image_data' => XenForo_Input::STRING, 'medio_data' => XenForo_Input::UINT, 'date' => XenForo_Input::STRING, 'hour' => XenForo_Input::UINT, 'mins' => XenForo_Input::UINT, 'ampm' => XenForo_Input::STRING, 'zone' => XenForo_Input::STRING, 'delete' => XenForo_Input::STRING)); $ftpHelper = $this->getHelper('ForumThreadPost'); list($thread, $forum) = $ftpHelper->assertThreadValidAndViewable($input['thread_id']); if ($this->_request->isPost()) { $this->getModelFromCache('EWRporta_Model_Promotes')->updatePromotion($input); $this->getModelFromCache('EWRporta_Model_Caches')->emptyBlockCache(array('block_id' => 'RecentFeatures')); $this->getModelFromCache('EWRporta_Model_Caches')->emptyBlockCache(array('block_id' => 'RecentNews')); } else { $threadPromote = $this->getModelFromCache('EWRporta_Model_Promotes')->getPromoteByThreadId($thread['thread_id']); $visitor = XenForo_Visitor::getInstance(); $datetime = $threadPromote ? $threadPromote['promote_date'] : $thread['post_date']; $datetime = new DateTime(date('r', $datetime)); $datetime->setTimezone(new DateTimeZone($visitor['timezone'])); $datetime = explode('.', $datetime->format('Y-m-d.h.i.A.T')); $datetime = array('date' => $datetime[0], 'hour' => $datetime[1], 'mins' => $datetime[2], 'meri' => $datetime[3], 'zone' => $datetime[4]); $icons = $this->getModelFromCache('EWRporta_Model_Promotes')->getPromoteIcons($thread); $viewParams = array('thread' => $thread, 'icons' => $icons, 'threadPromote' => $threadPromote, 'datetime' => $datetime, 'nodeBreadCrumbs' => $ftpHelper->getNodeBreadCrumbs($forum)); return $this->responseView('EWRporta_ViewPublic_Promote', 'EWRporta_Promote', $viewParams); } return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('threads', $thread)); }
public function actionPostIndex() { $conversationId = $this->_input->filterSingle('conversation_id', XenForo_Input::UINT); $conversation = $this->_getConversationOrError($conversationId); if (!$this->_getConversationModel()->canReplyToConversation($conversation, $errorPhraseKey)) { throw $this->getErrorOrNoPermissionResponseException($errorPhraseKey); } // TODO $input = $this->_input->filter(array()); /* @var $editorHelper XenForo_ControllerHelper_Editor */ $editorHelper = $this->getHelper('Editor'); $input['message_body'] = $editorHelper->getMessageText('message_body', $this->_input); $input['message_body'] = XenForo_Helper_String::autoLinkBbCode($input['message_body']); $visitor = XenForo_Visitor::getInstance(); $messageDw = XenForo_DataWriter::create('XenForo_DataWriter_ConversationMessage'); $messageDw->setExtraData(XenForo_DataWriter_ConversationMessage::DATA_MESSAGE_SENDER, $visitor->toArray()); $messageDw->set('conversation_id', $conversation['conversation_id']); $messageDw->set('user_id', $visitor['user_id']); $messageDw->set('username', $visitor['username']); $messageDw->set('message', $input['message_body']); $messageDw->setExtraData(XenForo_DataWriter_ConversationMessage::DATA_ATTACHMENT_HASH, $this->_getAttachmentHelper()->getAttachmentTempHash($conversation)); $messageDw->preSave(); if (!$messageDw->hasErrors()) { $this->assertNotFlooding('conversation'); } $messageDw->save(); $message = $messageDw->getMergedData(); $this->_getConversationModel()->markConversationAsRead($conversation['conversation_id'], XenForo_Visitor::getUserId(), XenForo_Application::$time, 0, false); $this->_request->setParam('message_id', $message['message_id']); return $this->responseReroute(__CLASS__, 'single'); }
public static function get() { //Check if mobile if (class_exists('Sedo_DetectBrowser_Listener_Visitor')) { //External addon $visitor = XenForo_Visitor::getInstance(); if (!$visitor->getBrowser['isMobile']) { return; } //Tablets if ($visitor->getBrowser['isTablet']) { foreach ($visitor->getBrowser['mobile']['tablets'] as $key => $value) { if ($key != 'isGenericTablet' && $value != false) { return $key; } } return 'isTablet'; } //Phones foreach ($visitor->getBrowser['mobile']['phones'] as $key => $value) { if ($key != 'isGenericPhone' && $value != false) { return $key; } } return 'isMobile'; } //XenForo if (!XenForo_Visitor::isBrowsingWith('mobile')) { return; } return 'isMobile'; }
protected function _getProfilePosts(array $widget, $positionCode, array $params, XenForo_Template_Abstract $renderTemplateObject) { if ($positionCode == 'forum_list' and $widget['options']['limit'] == XenForo_Application::getOptions()->get('forumListNewProfilePosts')) { if (!empty($params['profilePosts'])) { return $params['profilePosts']; } } $core = WidgetFramework_Core::getInstance(); $visitor = XenForo_Visitor::getInstance(); /** @var WidgetFramework_XenForo_Model_ProfilePost $profilePostModel */ $profilePostModel = $core->getModelFromCache('XenForo_Model_ProfilePost'); $profilePosts = $profilePostModel->WidgetFramework_getLatestProfilePosts(array('deleted' => false, 'moderated' => false), array('limit' => $widget['options']['limit'] * 3, 'join' => XenForo_Model_ProfilePost::FETCH_USER_POSTER | XenForo_Model_ProfilePost::FETCH_USER_RECEIVER | XenForo_Model_ProfilePost::FETCH_USER_RECEIVER_PRIVACY, 'permissionCombinationId' => $visitor->get('permission_combination_id'))); foreach ($profilePosts as $id => &$profilePost) { $receivingUser = $profilePostModel->getProfileUserFromProfilePost($profilePost); if (!$profilePostModel->canViewProfilePostAndContainer($profilePost, $receivingUser)) { unset($profilePosts[$id]); } $profilePost = $profilePostModel->prepareProfilePost($profilePost, $receivingUser); if (!empty($profilePost['isIgnored'])) { unset($profilePosts[$id]); } } $profilePosts = array_slice($profilePosts, 0, $widget['options']['limit'], true); return $profilePosts; }
public function logRequest($requestMethod, $requestUri, array $requestData, $responseCode, array $responseOutput, array $bulkSet = array()) { $days = bdApi_Option::get('logRetentionDays'); if ($days == 0) { return false; } $dw = XenForo_DataWriter::create('bdApi_DataWriter_Log'); $dw->bulkSet($bulkSet); if (!isset($bulkSet['client_id'])) { /* @var $session bdApi_Session */ $session = XenForo_Application::getSession(); $dw->set('client_id', $session->getOAuthClientId()); } if (!isset($bulkSet['user_id'])) { $visitor = XenForo_Visitor::getInstance(); $dw->set('user_id', $visitor->get('user_id')); } if (!isset($bulkSet['ip_address'])) { $dw->set('ip_address', isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''); } $dw->set('request_date', XenForo_Application::$time); $dw->set('request_method', $requestMethod); $dw->set('request_uri', $requestUri); $dw->set('request_data', $this->_filterData($requestData)); $dw->set('response_code', $responseCode); $dw->set('response_output', $this->_filterData($responseOutput)); return $dw->save(); }
public function generateHtmlRecurrence($days, $amount, $currency, $comment, array $data, XenForo_View $view) { $data[] = utf8_strtolower($currency); $data[] = $amount; $processorModel = $this->_getProcessorModel(); $itemId = $processorModel->generateItemId('bdshop', XenForo_Visitor::getInstance(), $data); $processorNames = $processorModel->getProcessorNames(); $processors = array(); foreach ($processorNames as $processorId => $processorClass) { $processors[$processorId] = bdPaygate_Processor_Abstract::create($processorClass); } $recurringInterval = false; $recurringUnit = false; if ($days > 0) { if ($days % 360 == 0) { $recurringInterval = $days / 365; $recurringUnit = bdPaygate_Processor_Abstract::RECURRING_UNIT_YEAR; } elseif ($days % 30 == 0) { $recurringInterval = $days / 30; $recurringUnit = bdPaygate_Processor_Abstract::RECURRING_UNIT_MONTH; } else { $recurringInterval = $days; $recurringUnit = bdPaygate_Processor_Abstract::RECURRING_UNIT_DAY; } } return implode('', bdPaygate_Processor_Abstract::prepareForms($processors, $amount, $currency, $comment, $itemId, $recurringInterval, $recurringUnit, array(bdPaygate_Processor_Abstract::EXTRA_RETURN_URL => XenForo_Link::buildPublicLink('full:shop/thanks')))); }
/** * Pre-dispatch, ensure visitor is a moderator. */ protected function _preDispatch($action) { $visitor = XenForo_Visitor::getInstance(); if (!$visitor['is_moderator'] && !$visitor['is_admin']) { throw $this->getNoPermissionResponseException(); } }
protected function _preDispatch($action) { parent::_preDispatch($action); $this->perms = $this->getModelFromCache('EWRatendo_Model_Perms')->getPermissions(); $visitor = XenForo_Visitor::getInstance(); date_default_timezone_set($visitor['timezone']); }
public function bakeBbmTags() { $bbmTags = BBM_Helper_Bbm::getBbmBbCodes(); $activeAddons = XenForo_Application::isRegistered('addOns') ? XenForo_Application::get('addOns') : array(); $visitor = XenForo_Visitor::getInstance(); if (!is_array($bbmTags)) { return false; } $allBbmTags = array(); foreach ($bbmTags as $bbm) { if (!$bbm['active']) { continue; } if (!empty($activeAddons) && !empty($bbm['bbcode_addon'])) { if (!isset($activeAddons[$bbm['bbcode_addon']])) { //Skip Bb Codes linked to an addon when this addon is disabled continue; } } $tagName = $bbm['tag']; if (!empty($bbm['preParser'])) { $this->addPreParserBbCode($tagName); } } $this->_bbmTags = $allBbmTags; /**** * XenForo Options - only need to call once the options ***/ $options = XenForo_Application::get('options'); if (!empty($options->Bbm_PreCache_XenTags)) { foreach ($options->Bbm_PreCache_XenTags as $tagName) { $this->addPreParserBbCode($tagName); } } }
/** * Check and apply the association request. * * @return XenForo_ControllerResponse_Redirect|XenForo_ControllerResponse_View */ public function actionIndex() { $mcAssoc = $this->getMcAssoc(); $inputData = $this->_input->filterSingle('data', XenForo_Input::STRING); $visitor = XenForo_Visitor::getInstance(); $isAdmin = $visitor['is_admin']; $visitorName = $visitor['username']; try { $data = $mcAssoc->unwrapData($inputData); $username = $mcAssoc->unwrapKey($data->key); if ($username != $visitorName) { throw new Exception("Username does not match."); } $this->handleData($visitor, $data); return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink("mc-association/view")); } catch (Exception $e) { if ($inputData == null) { $message = "No data provided."; } else { $message = $e->getMessage(); } $opts = XenForo_Application::get('options'); $message .= "<br /><pre>Credentials in use" . json_encode(["site_id" => $opts->mcAssocSiteId, "instance_secret" => $opts->mcAssocInstanceSecret, "shared_secret" => $opts->mcAssocSharedSecret]) . "</pre>"; return $this->responseView('AssociationMc_ViewPublic_Error', 'association_error', array("exceptionMessage" => $isAdmin ? $message : "Please contact an administrator for more information.")); } }
public function actionAdmin() { /** @var XenForo_Model_Admin $adminModel */ $adminModel = $this->getModelFromCache('XenForo_Model_Admin'); $visitor = XenForo_Visitor::getInstance(); $admin = $adminModel->getAdminById($visitor->user_id); 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; } } $dw = XenForo_DataWriter::create('XenForo_DataWriter_Admin'); $dw->setExistingData($admin); $dw->set('admin_language_id', $languageId); $dw->save(); return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(false, false)); } else { $viewParams = array('languages' => $this->getModelFromCache('XenForo_Model_Language')->getAllLanguages(), 'redirect' => $this->_input->filterSingle('redirect', XenForo_Input::STRING)); return $this->responseView('XenForo_ViewAdmin_Language_Admin', 'language_chooser', $viewParams); } }