コード例 #1
0
ファイル: User.php プロジェクト: Sywooch/forums
 /**
  * Post-save handling.
  *
  * Note: not run when importing
  */
 protected function _postSave()
 {
     parent::_postSave();
     if ($this->isInsert() && !empty(XenForo_Application::getOptions()->dpAnalyticsEvents['registration']) && !empty(XenForo_Application::getOptions()->dpAnalyticsInternal['v'])) {
         if (XenForo_Application::isRegistered('fc')) {
             $action = preg_split('/\\b/', strtolower(trim(XenForo_Application::getFc()->route()->getAction())));
             switch ($action[1]) {
                 case 'facebook':
                     $label = 'Facebook';
                     break;
                 case 'google':
                     $label = 'Google';
                     break;
                 case 'twitter':
                     $label = 'Twitter';
                     break;
                 default:
                     $label = 'Standard';
                     // would have preferred to leave this blank, but a null value causes it to be omitted from certain reports in Analytics
             }
         } else {
             $label = null;
         }
         $user = $this->getMergedData();
         if (XenForo_Application::isRegistered('fc')) {
             $analyticsClientId = XenForo_Application::getFc()->getRequest()->getCookie('_ga');
         } else {
             $analyticsClientId = null;
         }
         DigitalPointBetterAnalytics_Helper_Analytics::getInstance()->event(XenForo_Application::getOptions()->googleAnalyticsWebPropertyId, $analyticsClientId, $user['user_id'], @$_SERVER['REMOTE_ADDR'], 'User', 'Registration', $label);
     }
 }
コード例 #2
0
ファイル: XfAuthentication.php プロジェクト: ngdvan/lntguitar
 public function login($username, $password)
 {
     /**
      * @var $loginModel XenForo_Model_Login
      * @var $userModel XenForo_Model_User
      * @var $session XenForo_Session
      */
     $loginModel = XenForo_Model::create('XenForo_Model_Login');
     $userModel = XenForo_Model::create('XenForo_Model_User');
     $userId = $userModel->validateAuthentication($username, $password, $this->error);
     //var_dump($userId);
     //die;
     if (!$userId) {
         $loginModel->logLoginAttempt($username);
         return false;
     }
     $loginModel->clearLoginAttempts($username);
     /* if ($data['remember'])
        {
        $userModel->setUserRememberCookie($userId);
        } */
     XenForo_Model_Ip::log($userId, 'user', $userId, 'login');
     $userModel->deleteSessionActivity(0, $this->getClientIp(false));
     $session = XenForo_Application::get('session');
     //die('aaabb');
     /*if(!$this->session){
           $this->session = XenForo_Application::get('session');
       }*/
     $session->changeUserId($userId);
     XenForo_Visitor::setup($userId);
     $this->visitor = XenForo_Visitor::getInstance();
     $userInfo = $userModel->getFullUserById($this->visitor->getUserId());
     return $userInfo;
 }
コード例 #3
0
ファイル: Location.php プロジェクト: Sywooch/forums
 /**
  * @param int $position
  * @param array $options
  * @param string $detailedMessage
  * @return bool|int|string|true
  */
 public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
 {
     $options['batch'] = max(1, isset($options['batch']) ? $options['batch'] : 10);
     /* @var sonnb_XenGallery_Model_Location $locationModel */
     $locationModel = XenForo_Model::create('sonnb_XenGallery_Model_Location');
     $locations = $locationModel->getLocationsWithoutCoordinate($position, $options['batch']);
     if (count($locations) < 1) {
         return true;
     }
     XenForo_Db::beginTransaction();
     $db = XenForo_Application::getDb();
     /** @var sonnb_XenGallery_Model_Location $locationModel */
     $locationModel = XenForo_Model::create('sonnb_XenGallery_Model_Location');
     foreach ($locations as $locationId => $location) {
         $position = $location['location_id'];
         try {
             $client = XenForo_Helper_Http::getClient($locationModel->getGeocodeUrlForAddress($location['location_name']));
             $response = $client->request('GET');
             $response = @json_decode($response->getBody(), true);
             if (empty($response['results'][0])) {
                 continue;
             }
             $address = $response['results'][0]['formatted_address'];
             $lat = $response['results'][0]['geometry']['location']['lat'];
             $lng = $response['results'][0]['geometry']['location']['lng'];
             $db->update('sonnb_xengallery_location', array('location_name' => $address, 'location_lat' => $lat, 'location_lng' => $lng), array('location_id = ?' => $location['location_id']));
         } catch (Exception $e) {
             continue;
         }
     }
     XenForo_Db::commit();
     $detailedMessage = XenForo_Locale::numberFormat($position);
     return $position;
 }
コード例 #4
0
ファイル: Nakano.php プロジェクト: Sywooch/forums
 public function getActiveRoutes()
 {
     if ($this->routes != null) {
         return $this->routes;
     }
     $routes = trim(XenForo_Application::get('options')->dark_azucloud_routes);
     $routes = explode("\n", str_replace("\r", "", $routes));
     $routes_extra = array();
     foreach ($routes as $key => &$route) {
         $route = trim($route);
         if ($route == '') {
             unset($routes[$key]);
             continue;
         }
         // stick in a slash if there isn't already, otherwise remove it and keep existing either way
         if (substr($route, -1) == '/') {
             $routes_extra[] = substr($route, 0, strlen($route) - 1);
         } else {
             $routes_extra[] = $route . '/';
         }
     }
     $routes = array_merge($routes, $routes_extra);
     $this->routes = $routes;
     return $routes;
 }
コード例 #5
0
ファイル: Groups.php プロジェクト: Quartzcraft/Website
 public static function runSyncGroups()
 {
     $QCDB = WebSync_Database_Core::getQuartzcoreDatabase();
     $options = XenForo_Application::get('options');
     $userModel = XenForo_Model::create('XenForo_Model_User');
     $userFieldModel = XenForo_Model::create('XenForo_Model_UserField');
     if ($options->syncGroups) {
         $fetchOptions = array('validOnly' => true);
         $users = $userModel->getAllUsers($fetchOptions);
         foreach ($users as $user) {
             $hasUpdated = false;
             $coreId = $userFieldModel->getUserFieldValues($user['user_id'])['CoreID'];
             $secondaryGroups = $user['secondary_group_ids'];
             $groups_raw = file_get_contents($options->restApiUrl . 'group.php?action=getAllGroups');
             $groups = json_decode($groups_raw, true);
             while ($groupId = mysqli_fetch_array($groups)) {
                 $group_raw = file_get_contents($options->restApiUrl . 'group.php?action=getGroup&id=' . $groupId);
                 $group = json_decode($group_raw);
                 foreach ($userGroups as $userGroup) {
                     if ($userGroup == $group['site_group_id']) {
                         $player_raw = file_get_contents($options->restApiUrl . 'player.php?action=updatePlayer&id=' . $coreId . '&primaryGroupID=' . $group['id'] . '&apikey=07af7e75676eab410d1f83937d7afb62');
                         $player = json_decode($player_raw, true);
                         $hasUpdated = $player['hasUpdated'];
                     }
                 }
             }
             if ($hasUpdated == false) {
                 $player_raw = file_get_contents($options->restApiUrl . 'player.php?action=updatePlayer&id=' . $coreId . '&primaryGroupID=2&apikey=07af7e75676eab410d1f83937d7afb62');
                 $player = json_decode($player_raw, true);
                 $hasUpdated = $player['hasUpdated'];
             }
         }
     }
 }
コード例 #6
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();
 }
コード例 #7
0
ファイル: Forums.php プロジェクト: ThemeHouse-XF/SocialGroups
 /**
  *
  * @see XenForo_Route_Prefix_Forums::buildLink()
  */
 public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
 {
     if (isset($data['social_forum_id'])) {
         if (ThemeHouse_SocialGroups_SocialForum::hasInstance()) {
             $socialForum = ThemeHouse_SocialGroups_SocialForum::getInstance()->toArray();
         } else {
             $socialForum = $data;
         }
         $class = XenForo_Application::resolveDynamicClass('ThemeHouse_SocialGroups_Route_Prefix_SocialForums', 'route_prefix');
         $router = new $class();
         $link = $router->buildLink('social-forums', 'social-forums', $action, $extension, $socialForum, $extraParams);
         if (XenForo_Application::isRegistered('routeFiltersOut')) {
             $routeFilters = XenForo_Application::get('routeFiltersOut');
             if (isset($routeFilters['social-forums'])) {
                 foreach ($routeFilters['social-forums'] as $filter) {
                     if (array_key_exists('find_route', $filter) && array_key_exists('replace_route', $filter)) {
                         list($from, $to) = XenForo_Link::translateRouteFilterToRegex($filter['find_route'], $filter['replace_route']);
                         $newLink = preg_replace($from, $to, $link);
                     } else {
                         $newLink = $link;
                     }
                     if ($newLink != $link) {
                         $link = $newLink;
                         break;
                     }
                 }
             }
         }
         return $link;
     }
     return parent::buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, $extraParams);
 }
コード例 #8
0
ファイル: Subscription.php プロジェクト: billyprice1/bdApi
 public static function prepareDiscoveryParams(array &$params, Zend_Controller_Response_Http $response, $topicType, $topicId, $selfLink, $subscriptionOption)
 {
     if (!bdApi_Option::getSubscription($topicType)) {
         // subscription for this topic type has been disabled
         return false;
     }
     // subscription discovery
     $hubLink = bdApi_Data_Helper_Core::safeBuildApiLink('subscriptions', null, array('hub.topic' => bdApi_Model_Subscription::getTopic($topicType, $topicId), 'oauth_token' => ''));
     $response->setHeader('Link', sprintf('<%s>; rel=hub', $hubLink));
     $response->setHeader('Link', sprintf('<%s>; rel=self', $selfLink));
     // subscription info
     if (!empty($subscriptionOption)) {
         $subscriptionOption = @unserialize($subscriptionOption);
         if (!empty($subscriptionOption['subscriptions'])) {
             /* @var $session bdApi_Session */
             $session = XenForo_Application::getSession();
             $clientId = $session->getOAuthClientId();
             foreach ($subscriptionOption['subscriptions'] as $subscription) {
                 if ($subscription['client_id'] == $clientId) {
                     $params['subscription_callback'] = $subscription['callback'];
                 }
             }
         }
     }
     return true;
 }
コード例 #9
0
ファイル: Listener.php プロジェクト: darkearl/projectT122015
 public static function templatePostRender($templateName, &$content, array &$containerData, XenForo_Template_Abstract $template)
 {
     $param = array();
     switch ($templateName) {
         case 'node_list.css':
             $cacheDataForum = XenForo_Application::isRegistered('brcnsCacheDataForum') ? XenForo_Application::get('brcnsCacheDataForum') : XenForo_Model::create('XenForo_Model_DataRegistry')->get('brcnsCacheDataForum');
             $cacheDataPage = XenForo_Application::isRegistered('brcnsCacheDataPage') ? XenForo_Application::get('brcnsCacheDataPage') : XenForo_Model::create('XenForo_Model_DataRegistry')->get('brcnsCacheDataPage');
             $cacheDataLink = XenForo_Application::isRegistered('brcnsCacheDataLink') ? XenForo_Application::get('brcnsCacheDataLink') : XenForo_Model::create('XenForo_Model_DataRegistry')->get('brcnsCacheDataLink');
             $cacheDataCategory = XenForo_Application::isRegistered('brcnsCacheDataCategory') ? XenForo_Application::get('brcnsCacheDataCategory') : XenForo_Model::create('XenForo_Model_DataRegistry')->get('brcnsCacheDataCategory');
             $cacheDataCategoryRoot = XenForo_Application::isRegistered('brcnsCacheDataCateRoot') ? XenForo_Application::get('brcnsCacheDataCateRoot') : XenForo_Model::create('XenForo_Model_DataRegistry')->get('brcnsCacheDataCateRoot');
             XenForo_Application::set('brcnsCustomNodeStylesForum', $cacheDataForum);
             XenForo_Application::set('brcnsCustomNodeStylesPage', $cacheDataPage);
             XenForo_Application::set('brcnsCustomNodeStylesLink', $cacheDataLink);
             XenForo_Application::set('brcnsCustomNodeStylesCategory', $cacheDataCategory);
             XenForo_Application::set('brcnsCustomNodeStylesCategoryRoot', $cacheDataCategoryRoot);
             $param['CustomNodeStylesForums'] = XenForo_Application::get('brcnsCustomNodeStylesForum');
             $param['CustomNodeStylesPages'] = XenForo_Application::get('brcnsCustomNodeStylesPage');
             $param['CustomNodeStylesLinks'] = XenForo_Application::get('brcnsCustomNodeStylesLink');
             $param['CustomNodeStylescategories'] = XenForo_Application::get('brcnsCustomNodeStylesCategory');
             $param['CustomNodeStylesCategoriesRoot'] = XenForo_Application::get('brcnsCustomNodeStylesCategoryRoot');
             $options = XenForo_Application::get('options');
             $param['size'] = $options->BRCNS_size_icon;
             $newTemplate = $template->create('BRCNS_custom_node_style.css', $template->getParams());
             $newTemplate->setParams($param);
             $content = $content . $newTemplate->render();
             break;
     }
 }
コード例 #10
0
 public function actionAdd()
 {
     $response = parent::actionAdd();
     if ($response instanceof XenForo_ControllerResponse_View) {
         $threadNodeId = $this->_input->filterSingle('thread_node_id', XenForo_Input::UINT);
         if ($threadNodeId && !empty($response->params['categories'])) {
             foreach ($response->params['categories'] as $resourceCategoryId => $category) {
                 if ($category['thread_node_id'] != $threadNodeId) {
                     unset($response->params['categories'][$resourceCategoryId]);
                 }
             }
             $response->params['redirectToThread'] = true;
         } else {
             $redirectToThread = $this->_input->filterSingle('redirect_to_thread', XenForo_Input::UINT);
             if ($redirectToThread) {
                 $response->params['redirectToThread'] = true;
             }
         }
         $addOns = XenForo_Application::get('addOns');
         if (!empty($addOns['ThemeHouse_SocialGroups'])) {
             $socialForumId = $this->_input->filterSingle('social_forum_id', XenForo_Input::UINT);
             if ($socialForumId) {
                 $response->params['socialForumId'] = $socialForumId;
             }
         }
     }
     return $response;
 }
コード例 #11
0
ファイル: Log.php プロジェクト: ThemeHouse-XF/ModeratorLog
 public function logModeratorActionLocal($contentType, array $content, $action, array $actionParams = array(), $parentContent = null, array $logUser = null)
 {
     $xenOptions = XenForo_Application::get('options');
     if ($xenOptions->th_moderatorLog_splitMoveCopyPosts) {
         $existingActions = array('post_copy_target_existing', 'post_move_target_existing');
         $actions = array_merge($existingActions, array('post_copy_target', 'post_move_target'));
         if (in_array($action, $actions)) {
             $newAction = substr($action, strlen('post_'));
             /* @var $postModel XenForo_Model_Post */
             $postModel = $this->getModelFromCache('XenForo_Model_Post');
             $posts = $postModel->getPostsByIds(explode(', ', $actionParams['ids']));
             unset($actionParams['ids']);
             $logId = false;
             $i = 0;
             foreach ($posts as $postId => $post) {
                 if ($i > 0 && !in_array($action, $existingActions)) {
                     $newAction = substr($newAction, 0, strlen('move_target'));
                 }
                 $actionParams['id'] = $postId;
                 $logId = $this->logModeratorActionLocal('post', $post, $newAction, $actionParams, $content, $logUser);
                 $i++;
             }
             return $logId;
         }
     }
     return parent::logModeratorActionLocal($contentType, $content, $action, $actionParams, $parentContent, $logUser);
 }
コード例 #12
0
ファイル: FindNew.php プロジェクト: hahuunguyen/DTUI_201105
 public function findNewThreads()
 {
     $threadModel = $this->_getThreadModel();
     $searchModel = $this->_getSearchModel();
     $userId = XenForo_Visitor::getUserId();
     $limitOptions = array('limit' => XenForo_Application::get('options')->maximumSearchResults);
     $days = $this->_input->filterSingle('days', XenForo_Input::UINT);
     $recent = $this->_input->filterSingle('recent', XenForo_Input::UINT);
     if ($userId && !$days && !$recent) {
         $threadIds = $threadModel->getUnreadThreadIds($userId, $limitOptions);
         $searchType = 'new-threads';
     } else {
         if ($days < 1) {
             $days = 3;
         }
         $fetchOptions = $limitOptions + array('order' => 'last_post_date', 'orderDirection' => 'desc');
         $threadIds = array_keys($threadModel->getThreads(array('last_post_date' => array('>', XenForo_Application::$time - 86400 * $days), 'deleted' => false, 'moderated' => false), $fetchOptions));
         $searchType = 'recent-threads';
     }
     $results = array();
     foreach ($threadIds as $threadId) {
         $results[] = array(XenForo_Model_Search::CONTENT_TYPE => 'thread', XenForo_Model_Search::CONTENT_ID => $threadId);
     }
     $results = $searchModel->getViewableSearchResults($results);
     if (!$results) {
         return $this->getNoResultsResponse();
     }
     $search = $searchModel->insertSearch($results, $searchType, '', array(), 'date', false);
     return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('find-new/threads', $search));
 }
コード例 #13
0
ファイル: Description.php プロジェクト: Sywooch/forums
 public function renderHtml()
 {
     XenForo_Application::set('view', $this);
     $bbCodeParser = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this)));
     $bbCodeOptions = array('states' => array('viewAttachments' => $this->_params['canViewImages']), 'showSignature' => false);
     $this->_params['update']['messageHtml'] = XenForo_ViewPublic_Helper_Message::getBbCodeWrapper($this->_params['update'], $bbCodeParser, $bbCodeOptions);
 }
コード例 #14
0
 public function actionIndex()
 {
     $commentModel = $this->_getCommentModel();
     $mediaHelper = $this->_getMediaHelper();
     $commentId = $this->_input->filterSingle('comment_id', XenForo_Input::UINT);
     $fetchOptions = array('join' => XenGallery_Model_Comment::FETCH_USER | XenGallery_Model_Comment::FETCH_MEDIA | XenGallery_Model_Comment::FETCH_CATEGORY);
     $redirect = 'xengallery';
     $comment = $commentModel->getCommentById($commentId, $fetchOptions);
     if ($comment['content_type'] == 'media') {
         $content = $mediaHelper->assertMediaValidAndViewable($comment['content_id']);
         $pageParam = 'page';
     } else {
         $content = $mediaHelper->assertAlbumValidAndViewable($comment['content_id']);
         $redirect .= '/albums';
         $pageParam = 'commentpage';
     }
     $moderated = $commentModel->canViewUnapprovedComment();
     if (!$moderated) {
         $moderated = XenForo_Visitor::getUserId();
     }
     $conditions = array('content_id' => $comment['content_id'], 'content_type' => $comment['content_type'], 'deleted' => $commentModel->canViewDeletedComment(), 'moderated' => $moderated, 'comment_id_lt' => $commentId);
     $commentsBefore = $commentModel->countComments($conditions);
     $commentsPerPage = XenForo_Application::getOptions()->xengalleryMaxCommentsPerPage;
     $page = floor($commentsBefore / $commentsPerPage) + 1;
     $linkParams = array();
     if ($page > 1) {
         $linkParams = array($pageParam => $page);
     }
     return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL_PERMANENT, XenForo_Link::buildPublicLink($redirect, $content, $linkParams) . '#comment-' . $commentId);
 }
コード例 #15
0
 public function renderRaw()
 {
     $attachment = $this->_params['attachment'];
     if (!headers_sent() && function_exists('header_remove')) {
         header_remove('Expires');
         header('Cache-control: private');
     }
     $extension = XenForo_Helper_File::getFileExtension($attachment['filename']);
     $imageTypes = array('svg' => 'image/svg+xml', 'gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'png' => 'image/png');
     if (isset($imageTypes[$extension]) && ($attachment['width'] && $attachment['height'])) {
         $this->_response->setHeader('Content-type', $imageTypes[$extension], true);
         $this->setDownloadFileName($attachment['filename'], true);
     } else {
         $this->_response->setHeader('Content-type', 'application/octet-stream', true);
         $this->setDownloadFileName($attachment['filename']);
     }
     $this->_response->setHeader('ETag', '"' . $attachment['attach_date'] . '"', true);
     $this->_response->setHeader('Content-Length', $attachment['file_size'], true);
     $this->_response->setHeader('X-Content-Type-Options', 'nosniff');
     $attachmentFile = $this->_params['attachmentFile'];
     $options = XenForo_Application::getOptions();
     if ($options->SV_AttachImpro_XAR) {
         if (SV_AttachmentImprovements_AttachmentHelper::ConvertFilename($attachmentFile)) {
             if (XenForo_Application::debugMode() && $options->SV_AttachImpro_log) {
                 XenForo_Error::debug('X-Accel-Redirect:' . $attachmentFile);
             }
             $this->_response->setHeader('X-Accel-Redirect', $attachmentFile);
             return '';
         }
         if (XenForo_Application::debugMode() && $options->SV_AttachImpro_log) {
             XenForo_Error::debug('X-Accel-Redirect skipped');
         }
     }
     return new XenForo_FileOutput($attachmentFile);
 }
コード例 #16
0
 public function run()
 {
     if ($this->_templateName == "PAGE_CONTAINER" && XenForo_Application::debugMode()) {
         $this->_debugMode();
     }
     return parent::run();
 }
コード例 #17
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;
 }
コード例 #18
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');
     }
 }
コード例 #19
0
ファイル: SocialBar.php プロジェクト: Sywooch/forums
 public static function runOften()
 {
     $feeds = XenForo_Model::create('DigitalPointSocialBar_Model_SocialBar')->getSlugsFromOptions();
     shuffle($feeds);
     // randomize order in case someone has absurd number of lists attached to forums (would need to be more than 180 unique) to work around Twitter API limits
     $cacheObject = XenForo_Application::getCache();
     $twitter = DigitalPointSocialBar_Helper_Twitter::getService(XenForo_Application::getOptions()->dpTwitterAccessToken, XenForo_Application::getOptions()->dpTwitterAccessTokenSecret, XenForo_Application::getOptions()->dpTwitterUsername);
     // forum specific feeds
     if ($feeds) {
         foreach ($feeds as $slug) {
             $tweets_array = array();
             $results = $twitter->listsStatuses(array('slug' => $slug, 'owner_screen_name' => XenForo_Application::getOptions()->dpTwitterUsername, 'count' => 250, 'include_rts' => 1, 'include_entities' => 1));
             if (count($results)) {
                 try {
                     for ($i = 0; $i < count($results); $i++) {
                         $tweet = $results[$i];
                         if (is_object($tweet->user)) {
                             $screen_name = $tweet->user->screen_name;
                             if (!@isset($tweets_array[$screen_name])) {
                                 $tweets_array[$screen_name] = DigitalPointSocialBar_Helper_Twitter::parseTweet($tweet);
                             }
                         }
                     }
                     $cacheObject->save(json_encode(array_values($tweets_array)), 'social_bar_' . str_replace('-', '_', $slug), array(), 604800);
                     // 7 day cache
                 } catch (Exception $e) {
                 }
             }
         }
     }
 }
コード例 #20
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;
     }
 }
コード例 #21
0
ファイル: View.php プロジェクト: hahuunguyen/DTUI_201105
 public function renderRss()
 {
     $forum = $this->_params['forum'];
     $buggyXmlNamespace = defined('LIBXML_DOTTED_VERSION') && LIBXML_DOTTED_VERSION == '2.6.24';
     $feed = new Zend_Feed_Writer_Feed();
     $feed->setEncoding('utf-8');
     $feed->setTitle($forum['title']);
     $feed->setDescription($forum['description'] ? $forum['description'] : $forum['title']);
     $feed->setLink(XenForo_Link::buildPublicLink('canonical:forums', $forum));
     if (!$buggyXmlNamespace) {
         $feed->setFeedLink(XenForo_Link::buildPublicLink('canonical:forums.rss', $forum), 'rss');
     }
     $feed->setDateModified(XenForo_Application::$time);
     $feed->setLastBuildDate(XenForo_Application::$time);
     if (XenForo_Application::get('options')->boardTitle) {
         $feed->setGenerator(XenForo_Application::get('options')->boardTitle);
     }
     foreach ($this->_params['threads'] as $thread) {
         // TODO: add contents of first post in future
         // TODO: wrap in exception handling down the line
         $entry = $feed->createEntry();
         $entry->setTitle($thread['title']);
         $entry->setLink(XenForo_Link::buildPublicLink('canonical:threads', $thread));
         $entry->setDateCreated(new Zend_Date($thread['post_date'], Zend_Date::TIMESTAMP));
         $entry->setDateModified(new Zend_Date($thread['last_post_date'], Zend_Date::TIMESTAMP));
         if (!$buggyXmlNamespace) {
             $entry->addAuthor(array('name' => $thread['username'], 'uri' => XenForo_Link::buildPublicLink('canonical:members', $thread)));
             if ($thread['reply_count']) {
                 $entry->setCommentCount($thread['reply_count']);
             }
         }
         $feed->addEntry($entry);
     }
     return $feed->export('rss');
 }
コード例 #22
0
ファイル: ConversationMessage.php プロジェクト: burtay/bdApi
 public function actionGetIndex()
 {
     $messageId = $this->_input->filterSingle('message_id', XenForo_Input::UINT);
     if (!empty($messageId)) {
         return $this->responseReroute(__CLASS__, 'single');
     }
     $conversationId = $this->_input->filterSingle('conversation_id', XenForo_Input::UINT);
     if (empty($conversationId)) {
         return $this->responseError(new XenForo_Phrase('bdapi_slash_conversation_messages_requires_conversation_id'), 400);
     }
     $conversation = $this->_getConversationOrError($conversationId);
     $pageNavParams = array('conversation_id' => $conversation['conversation_id']);
     $page = $this->_input->filterSingle('page', XenForo_Input::UINT);
     $limit = XenForo_Application::get('options')->messagesPerPage;
     $inputLimit = $this->_input->filterSingle('limit', XenForo_Input::UINT);
     if (!empty($inputLimit)) {
         $limit = $inputLimit;
         $pageNavParams['limit'] = $inputLimit;
     }
     $fetchOptions = array('limit' => $limit, 'page' => $page);
     $messages = $this->_getConversationModel()->getConversationMessages($conversation['conversation_id'], $this->_getConversationModel()->getFetchOptionsToPrepareApiDataForMessages($fetchOptions));
     if (!$this->_isFieldExcluded('attachments')) {
         $messages = $this->_getConversationModel()->getAndMergeAttachmentsIntoConversationMessages($messages);
     }
     $total = $conversation['reply_count'] + 1;
     $data = array('messages' => $this->_filterDataMany($this->_getConversationModel()->prepareApiDataForMessages($messages, $conversation)), 'messages_total' => $total);
     bdApi_Data_Helper_Core::addPageLinks($this->getInput(), $data, $limit, $total, $page, 'conversation-messages', array(), $pageNavParams);
     return $this->responseData('bdApi_ViewApi_ConversationMessage_List', $data);
 }
コード例 #23
0
 public function verifyFromInput($context, XenForo_Input $input, array $user, array &$providerData)
 {
     $code = $input->filterSingle('code', XenForo_Input::STRING);
     $code = preg_replace('/[^0-9]/', '', $code);
     if (!$code) {
         return false;
     }
     $matched = null;
     foreach ($providerData['codes'] as $i => $expectedCode) {
         if (XenForo_Application::hashEquals($expectedCode, $code)) {
             $matched = $i;
             break;
         }
     }
     if ($matched === null) {
         return false;
     }
     $providerData['used'][] = $providerData['codes'][$matched];
     unset($providerData['codes'][$matched]);
     if (!$providerData['codes']) {
         // regenerate automatically
         $regenerated = true;
         $this->generateInitialData($user, array());
     } else {
         $regenerated = false;
     }
     $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
     $mail = XenForo_Mail::create('two_step_login_backup', array('user' => $user, 'ip' => $ip, 'regenerated' => $regenerated), $user['language_id']);
     $mail->send($user['email'], $user['username']);
     return true;
 }
コード例 #24
0
ファイル: MediaCloudWidget.php プロジェクト: Sywooch/forums
 protected function _render(array $widget, $positionCode, array $params, XenForo_Template_Abstract $renderTemplateObject)
 {
     $mediaCloudModel = XenForo_Model::create('EWRmedio_Model_Keywords');
     //		$model = XenForo_Model::create('EWRporta_Model_Options');
     //		$option = $model->getOptionById('MediaCloud');
     $options = XenForo_Application::get('options');
     $sidebar['keywords'] = $mediaCloudModel->getKeywordCloud($options->EWRmedio_cloudcount, $options->EWRmedio_mincloud, $options->EWRmedio_maxcloud);
     if ($options->EWRmedio_animatedcloud && $sidebar['keywords']) {
         $sidebar['animated'] = $mediaCloudModel->getAnimatedCloud($sidebar['keywords']);
     }
     /*		$limit = $option['limit'];
     		$mincloud = $option['mincloud'];
     		$maxcloud = $option['maxcloud'];
     		$animated = $option['animated'];
     		
     		$cloud['keywords'] = $mediaCloudModel->getKeywordCloud($limit, $mincloud, $maxcloud);
     
     		if ($animated && $cloud['keywords'])
     		{
     			$cloud['animated'] = $mediaCloudModel->getAnimatedCloud($cloud['keywords']);
     		}*/
     $viewParams = array('MediaCloud' => $sidebar);
     $renderTemplateObject->setParams($viewParams);
     return $renderTemplateObject->render();
 }
コード例 #25
0
ファイル: Camera.php プロジェクト: Sywooch/forums
 public function actionShopping()
 {
     $xenOptions = XenForo_Application::getOptions();
     $cameraPortion = $this->_input->filterSingle('camera_url', XenForo_Input::STRING);
     $cameraPortion = sonnb_XenGallery_Model_Gallery::getTitleForUrl($cameraPortion);
     if (!$cameraPortion || !$xenOptions->sonnbXG_amazonEnable || !class_exists('SoapClient')) {
         return $this->responseReroute(__CLASS__, 'index');
     }
     $cameraModel = $this->_getCameraModel();
     $page = max(1, $this->_input->filterSingle('page', XenForo_Input::UINT));
     $camera = $cameraModel->getCamerasByCameraUrl($cameraPortion);
     $camera = reset($camera);
     if ($camera) {
         $camera = $cameraModel->getDataCameras(array('camera_name' => $camera['camera_name']));
         $camera = reset($camera);
     }
     $response = array();
     if ($camera) {
         $camera['camera_url'] = $cameraPortion;
         $amazonEcs = new sonnb_XenGallery_Model_AmazonECS($xenOptions->sonnbXG_amazonAccessKey, $xenOptions->sonnbXG_amazonSecretKey, $xenOptions->sonnbXG_amazonSite, $xenOptions->sonnbXG_amazonAssociateTag);
         $amazonEcs->returnType(sonnb_XenGallery_Model_AmazonECS::RETURN_TYPE_ARRAY);
         $amazonEcs->page($page);
         try {
             $response = $amazonEcs->category('Electronics')->responseGroup('Large')->search($camera['camera_name']);
         } catch (Exception $e) {
         }
     }
     return $this->responseView('sonnb_XenGallery_ViewPublic_Camera_Shopping', 'sonnb_xengallery_camera_shopping', array('camera' => $camera, 'items' => empty($response['Items']['Item']) ? array() : $response['Items']['Item'], 'page' => $page, 'perPage' => 10, 'totalItems' => empty($response['Items']['TotalResults']) ? 0 : $response['Items']['TotalResults'], 'totalPages' => empty($response['Items']['TotalPages']) ? 0 : $response['Items']['TotalPages'], 'breadCrumbs' => $cameraModel->getCameraBreadCrumbs()));
 }
コード例 #26
0
ファイル: DailyStats.php プロジェクト: Sywooch/forums
 public function actionFeatured()
 {
     $parent = parent::actionFeatured();
     $options = XenForo_Application::get('options');
     $rmEnabled = $options->dailystats_rm_enable;
     $scEnabled = $options->dailystats_sc_enable;
     $xfmgEnabled = $options->dailystats_xfmg_enable;
     $DailyStatsModel = $this->_getDailyStatsModel();
     $DS_totalUsers = XenForo_Model::create('XenForo_Model_DataRegistry')->get('DS_totalUsers');
     $DS_totalPosts = XenForo_Model::create('XenForo_Model_DataRegistry')->get('DS_totalPosts');
     $DS_totalThreads = XenForo_Model::create('XenForo_Model_DataRegistry')->get('DS_totalThreads');
     $parent->params['DS_totalUsers'] = $DS_totalUsers;
     $parent->params['DS_totalPosts'] = $DS_totalPosts;
     $parent->params['DS_totalThreads'] = $DS_totalThreads;
     //Check if RM option is enabled
     switch ($rmEnabled) {
         case '1':
             $DS_totalResource = XenForo_Model::create('XenForo_Model_DataRegistry')->get('DS_totalResource');
             $parent->params['DS_totalResource'] = $DS_totalResource;
             break;
     }
     //Check if Showcase option is enabled
     switch ($scEnabled) {
         case '1':
             $DS_totalShowcase = XenForo_Model::create('XenForo_Model_DataRegistry')->get('DS_totalShowcase');
             $parent->params['DS_totalShowcase'] = $DS_totalShowcase;
             break;
     }
     return $parent;
 }
コード例 #27
0
ファイル: Abstract.php プロジェクト: robclancy/XenPlus
 /**
  * Helper method to get the database object.
  *
  * @return Zend_Db_Adapter_Abstract
  */
 protected function _getDb()
 {
     if ($this->_db === null) {
         $this->_db = XenForo_Application::getDb();
     }
     return $this->_db;
 }
コード例 #28
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));
     }
 }
コード例 #29
0
ファイル: Error.php プロジェクト: Sywooch/forums
 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);
         }
     }
 }
コード例 #30
0
 public static function uninstall()
 {
     $db = XenForo_Application::get('db');
     $db->query("\n            DELETE FROM xf_permission_entry\n            WHERE permission_id in ('attach_count', 'attach_size')\n        ");
     $db->query("\n            DELETE FROM xf_permission_entry_content\n            WHERE permission_id in ('attach_count', 'attach_size')\n        ");
     return true;
 }