コード例 #1
0
ファイル: Confirm.php プロジェクト: adamjdev/XenForo-MCASSOC
 /**
  * Do the data writing.
  *
  * @param XenForo_Visitor $visitor The visitor object.
  * @param StdClass $data Data from MCAssoc service.
  */
 private function handleData(XenForo_Visitor $visitor, $data)
 {
     $associationDw = XenForo_DataWriter::create('AssociationMc_DataWriter_AssociationEntry');
     $associationDw->set('xenforo_id', $visitor->getUserId());
     $associationDw->set('minecraft_uuid', hex2bin($data->uuid));
     $associationDw->set('last_username', $data->username);
     $associationDw->save();
 }
コード例 #2
0
ファイル: Listener.php プロジェクト: Sywooch/forums
 public static function visitor_setup(XenForo_Visitor &$visitor)
 {
     $options = $visitor->get('bdsocialshare_options');
     if (!empty($options)) {
         $visitor['_bdSocialShare_options'] = bdSocialShare_Helper_Common::unserializeOrFalse($options);
     } else {
         $visitor['_bdSocialShare_options'] = array();
     }
     $visitor['_bdSocialShare_canStaffShare'] = $visitor->hasPermission('general', 'bdSocialShare_staffShare');
 }
コード例 #3
0
 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);
 }
コード例 #4
0
ファイル: Error.php プロジェクト: Sywooch/forums
 public function actionBanned()
 {
     $userId = XenForo_Visitor::getUserId();
     $bannedUser = $this->getModelFromCache('XenForo_Model_Banning')->getBannedUserById($userId);
     if (!$bannedUser) {
         return $this->responseNoPermission();
     } else {
         if ($bannedUser['triggered'] && !$bannedUser['end_date']) {
             /** @var XenForo_Model_Warning $warningModel */
             $warningModel = $this->getModelFromCache('XenForo_Model_Warning');
             $minUnbanDate = $warningModel->getMinimumWarningUnbanDate($userId);
             if ($minUnbanDate) {
                 $bannedUser['end_date'] = $minUnbanDate;
             }
         }
         if ($bannedUser['user_reason']) {
             $message = new XenForo_Phrase('you_have_been_banned_for_following_reason_x', array('reason' => $bannedUser['user_reason']));
         } else {
             $message = new XenForo_Phrase('you_have_been_banned');
         }
         if ($bannedUser['end_date'] > XenForo_Application::$time) {
             $message .= ' ' . new XenForo_Phrase('your_ban_will_be_lifted_on_x', array('date' => XenForo_Locale::dateTime($bannedUser['end_date'])));
         }
         return $this->responseError($message, 403);
     }
 }
コード例 #5
0
 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);
 }
コード例 #6
0
ファイル: StockPricing.php プロジェクト: E2Dev/bdPaygates
 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'))));
 }
コード例 #7
0
ファイル: XfAuthentication.php プロジェクト: ngdvan/lntguitar
 public function getUser()
 {
     $visitor = XenForo_Visitor::getInstance();
     $userModel = XenForo_Model::create('XenForo_Model_User');
     $userInfo = $userModel->getFullUserById($visitor->getUserId());
     return $userInfo;
 }
コード例 #8
0
ファイル: Resource.php プロジェクト: AndroidOS/SocialGroups
 /**
  *
  * @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);
 }
コード例 #9
0
 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;
 }
コード例 #10
0
ファイル: Players.php プロジェクト: Quartzcraft/Website
 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);
 }
コード例 #11
0
ファイル: Thread.php プロジェクト: darkearl/projectT122015
 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));
 }
コード例 #12
0
 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);
         }
     }
 }
コード例 #13
0
 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']);
 }
コード例 #14
0
ファイル: Media.php プロジェクト: VoDongMy/xenforo-laravel5.1
 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);
 }
コード例 #15
0
 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;
 }
コード例 #16
0
 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);
             }
         }
     }
 }
コード例 #17
0
ファイル: Listener.php プロジェクト: Quartzcraft/Website
 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');
     }
 }
コード例 #18
0
ファイル: Detector.php プロジェクト: Sywooch/forums
 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';
 }
コード例 #19
0
ファイル: Logout.php プロジェクト: darkearl/projectT122015
 /**
  * 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;
     }
 }
コード例 #20
0
ファイル: Log.php プロジェクト: billyprice1/bdApi
 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();
 }
コード例 #21
0
ファイル: Thread.php プロジェクト: darkearl/projectT122015
 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));
     }
 }
コード例 #22
0
 /**
  * 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();
     }
 }
コード例 #23
0
ファイル: Post.php プロジェクト: ThemeHouse-XF/PostAsUser
 /**
  *
  * @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();
 }
コード例 #24
0
ファイル: Wysiwyg.php プロジェクト: Sywooch/forums
 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);
         }
     }
 }
コード例 #25
0
ファイル: Camera.php プロジェクト: Sywooch/forums
 public function actionView()
 {
     $cameraPortion = $this->_input->filterSingle('camera_url', XenForo_Input::STRING);
     $cameraPortion = sonnb_XenGallery_Model_Gallery::getTitleForUrl($cameraPortion);
     if (!$cameraPortion) {
         return $this->responseReroute(__CLASS__, 'index');
     }
     $cameraModel = $this->_getCameraModel();
     $photoModel = $this->_getPhotoModel();
     $xenOptions = XenForo_Application::getOptions();
     $page = max(1, $this->_input->filterSingle('page', XenForo_Input::UINT));
     $photosPerPage = $xenOptions->sonnbXG_photoPerPage;
     list($defaultOrder, $defaultOrderDirection) = $this->_getDefaultPhotoSort();
     $order = $this->_input->filterSingle('order', XenForo_Input::STRING, array('default' => $defaultOrder));
     $orderDirection = $this->_input->filterSingle('direction', XenForo_Input::STRING, array('default' => $defaultOrderDirection));
     $conditions = array('camera_url' => $cameraPortion);
     $fetchOptions = array('join' => sonnb_XenGallery_Model_Camera::FETCH_CAMERA, 'perPage' => $photosPerPage, 'page' => $page, 'order' => 'camera_id', 'orderDirection' => 'desc');
     $cameras = $cameraModel->getCameras($conditions, $fetchOptions);
     $camera = reset($cameras);
     if ($camera) {
         $camera = $cameraModel->prepareCamera($camera);
     }
     $photoFetchOptions = array('join' => sonnb_XenGallery_Model_Photo::FETCH_USER | sonnb_XenGallery_Model_Photo::FETCH_DATA | sonnb_XenGallery_Model_Photo::FETCH_ALBUM, 'likeUserId' => XenForo_Visitor::getUserId(), 'followingUserId' => XenForo_Visitor::getUserId());
     $photos = $cameraModel->getPhotosByCameras($cameras, $photoFetchOptions);
     $totalPhotos = $cameraModel->countCameras($conditions, $fetchOptions);
     foreach ($photos as $_photoId => $_photo) {
         if (!$photoModel->canViewContentAndContainer($_photo, $_photo['album'], $errorKey)) {
             unset($photos[$_photoId]);
         }
     }
     $pageNavParams = array();
     $pageNavParams['order'] = $order != $defaultOrder ? $order : false;
     $pageNavParams['direction'] = $orderDirection != $defaultOrderDirection ? $orderDirection : false;
     return $this->responseView('sonnb_XenGallery_ViewPublic_Camera_View', 'sonnb_xengallery_camera_view', array('camera' => $camera, 'contents' => $photos, 'page' => $page, 'photosPerPage' => $photosPerPage, 'order' => $order, 'orderDirection' => $orderDirection, 'pageNavParams' => $pageNavParams, 'totalPhotos' => $totalPhotos, 'breadCrumbs' => $cameraModel->getCameraBreadCrumbs($camera)));
 }
コード例 #26
0
 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);
 }
コード例 #27
0
ファイル: Birthdays.php プロジェクト: Sywooch/forums
 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']);
 }
コード例 #28
0
ファイル: BbCodes.php プロジェクト: Sywooch/forums
 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);
 }
コード例 #29
0
 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);
 }
コード例 #30
0
ファイル: User.php プロジェクト: VoDongMy/xenforo-laravel5.1
 public function unfollow($followUserId, $userId = null)
 {
     $parent = parent::unfollow($followUserId, $userId);
     if ($userId === null) {
         $userId = XenForo_Visitor::getUserId();
     }
     $albumModel = $this->_getAlbumModel();
     $addConditions = array('album_user_id' => $userId, 'add_type' => 'followed');
     $addAlbums = $albumModel->getAlbums($addConditions);
     $viewConditions = array('album_user_id' => $userId, 'view_type' => 'followed');
     $viewAlbums = $albumModel->getAlbums($viewConditions);
     $albums = $addAlbums + $viewAlbums;
     foreach ($albums as $album) {
         $album = $albumModel->prepareAlbumWithPermissions($album);
         if (!isset($album['albumPermissions'])) {
             continue;
         }
         $shareUsers = $albumModel->unshare($followUserId, $album);
         if ($album['albumPermissions']['view']['access_type'] == 'followed') {
             $albumViewData = array('album_id' => $album['album_id'], 'permission' => 'view', 'access_type' => 'followed', 'share_users' => $shareUsers);
             $albumModel->writeAlbumPermission($albumViewData, $album['albumPermissions']['view']);
         }
         if ($album['albumPermissions']['add']['access_type'] == 'followed') {
             $albumAddData = array('album_id' => $album['album_id'], 'permission' => 'add', 'access_type' => 'followed', 'share_users' => $shareUsers);
             $albumModel->writeAlbumPermission($albumAddData, $album['albumPermissions']['add']);
         }
     }
     return $parent;
 }