Пример #1
0
 public function getImage(XenForo_Model $model)
 {
     $photoData = $this->_getPhotoData($model);
     $image = $model->getModelFromCache('sonnb_XenGallery_Model_ContentData')->getContentDataLargeThumbnailUrl($photoData);
     $image = XenForo_Link::convertUriToAbsoluteUri($image, true);
     return $image;
 }
Пример #2
0
 /**
  *
  * @see XenForo_ControllerPublic_Thread::actionAddReply()
  */
 public function actionAddReply()
 {
     $response = parent::actionAddReply();
     if ($response instanceof XenForo_ControllerResponse_Redirect) {
         $xenOptions = XenForo_Application::get('options');
         if ($xenOptions->th_moderateReplies_moderateMessage) {
             $message = $response->redirectMessage;
             if ($message instanceof XenForo_Phrase && $message->getPhraseName() == 'your_message_has_been_posted') {
                 $target = XenForo_Link::getCanonicalLinkPrefix() . XenForo_Link::convertUriToAbsoluteUri($response->redirectTarget);
                 $result = $this->parseRouteUrl($target);
                 if ($result) {
                     $match = $result['match'];
                     $controllerName = $match->getControllerName();
                     if ($controllerName == 'XenForo_ControllerPublic_Thread') {
                         $response->redirectMessage = new XenForo_Phrase('message_submitted_displayed_pending_approval');
                     } elseif ($controllerName == 'XenForo_ControllerPublic_Post') {
                         $post = $this->_getPostModel()->getPostById($result['params']['post_id']);
                         if ($post['message_state'] == 'moderated') {
                             $response->redirectMessage = new XenForo_Phrase('message_submitted_displayed_pending_approval');
                         }
                     }
                 }
             }
         }
     }
     return $response;
 }
Пример #3
0
 public static function runDailyCleanUp()
 {
     $options = XenForo_Application::get('options');
     $model = XenForo_Model::create('Dark_TaigaChat_Model_TaigaChat');
     if ($options->dark_taigachat_archivethread > 0) {
         $messages = array_reverse($model->getMessagesToday());
         if (count($messages) > 0) {
             $userModel = XenForo_Model::create('XenForo_Model_User');
             $post = "";
             foreach ($messages as $message) {
                 $date = XenForo_Locale::dateTime($message['date'], 'absolute');
                 if ($message['user_id'] > 0) {
                     $url = XenForo_Link::convertUriToAbsoluteUri(XenForo_Link::buildPublicLink("members/" . $message['user_id']), true);
                     $user = "******";
                 } else {
                     $user = "******";
                 }
                 $post .= "{$date} - {$user}: {$message['message']}\r\n";
             }
             $username = "******";
             if ($options->dark_taigachat_archiveuser > 0) {
                 $user = $userModel->getUserById($options->dark_taigachat_archiveuser);
                 $username = $user['username'];
             }
             $writer = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post');
             $writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_IS_AUTOMATED, true);
             $writer->set('user_id', $options->dark_taigachat_archiveuser);
             $writer->set('username', $username);
             $writer->set('message', $post);
             $writer->set('thread_id', $options->dark_taigachat_archivethread);
             $writer->save();
         }
     }
     $model->deleteOldMessages();
 }
Пример #4
0
 /**
  * Constructor.
  *
  * @param array $input Array of input (intended to normally be $_REQUEST)
  * @param XenForo_Dependencies_Abstract $dependencies
  */
 public function __construct(array $input, XenForo_Dependencies_Abstract $dependencies)
 {
     $this->_dependencies = $dependencies;
     $this->_response = new Zend_Controller_Response_Http();
     if (!empty($input['image']) && is_scalar($input['image'])) {
         $this->_mode = 'image';
         $this->_url = trim(strval($input['image']));
     }
     if (!empty($input['link']) && is_scalar($input['link'])) {
         $this->_mode = 'link';
         $this->_url = trim(strval($input['link']));
     }
     if (!empty($input['hash']) && is_scalar($input['hash'])) {
         $this->_hash = trim(strval($input['hash']));
     }
     $this->_json = !empty($input['_xfResponseType']) && $input['_xfResponseType'] === 'json';
     if ($this->_json && $this->_mode == 'link' && !empty($input['_xfRequestUri']) && is_scalar($input['_xfRequestUri'])) {
         // only use this if we're using JSON output (in a handler that supports it)
         $this->_referrer = XenForo_Link::convertUriToAbsoluteUri($input['_xfRequestUri'], true);
     }
     if (!$this->_referrer && !empty($_SERVER['HTTP_REFERER'])) {
         $this->_referrer = $_SERVER['HTTP_REFERER'];
     }
     if ($this->_referrer && !preg_match('#^https?://#i', $this->_referrer)) {
         $this->_referrer = null;
     }
 }
Пример #5
0
 public static function helperAvatarUrl(array $team, $canonical = false)
 {
     $url = self::getAvatarUrl($team);
     if ($canonical) {
         $url = XenForo_Link::convertUriToAbsoluteUri($url, true);
     }
     return htmlspecialchars($url);
 }
Пример #6
0
 public static function listen(array &$extraTabs, $selectedTabId)
 {
     $options = XenForo_Application::get('options');
     $visitor = XenForo_Visitor::getInstance();
     if ($options->dark_taigachat_navtab && $visitor->hasPermission("dark_taigachat", "view")) {
         $extraTabs['taigachat'] = array('title' => new Xenforo_Phrase("dark_shoutbox"), 'href' => XenForo_Link::convertUriToAbsoluteUri(XenForo_Link::buildPublicLink($options->dark_taigachat_route), true), 'selected' => $selectedTabId == 'taigachat', 'linksTemplate' => 'dark_taigachat_links', 'taigachat' => array("route" => $options->dark_taigachat_route));
     }
 }
Пример #7
0
 public function getImage(XenForo_Model $model)
 {
     $imageUrl = bdMedal_Model_Medal::getImageUrl($this->_medal);
     if (!empty($imageUrl)) {
         return XenForo_Link::convertUriToAbsoluteUri($imageUrl, true);
     }
     return parent::getImage($model);
 }
Пример #8
0
 public function getData(array $entry)
 {
     $result = array('loc' => XenForo_Link::buildPublicLink('canonical:xengallery/albums', $entry), 'lastmod' => $entry['last_update_date']);
     if (isset($entry['mediaCache']['placeholder'])) {
         $result['image'] = XenForo_Link::convertUriToAbsoluteUri($entry['mediaCache']['placeholder'], true, $this->getCanonicalPaths());
     }
     return $result;
 }
Пример #9
0
 public function getImage(XenForo_Model $model)
 {
     $resource = $this->_resourceDw->getMergedData();
     if (isset(XenForo_Template_Helper_Core::$helperCallbacks['resourceiconurl'])) {
         $iconUrl = XenForo_Template_Helper_Core::callHelper('resourceiconurl', array($resource));
         return XenForo_Link::convertUriToAbsoluteUri($iconUrl, true);
     }
     return parent::getImage($model);
 }
Пример #10
0
 public function getData(array $entry)
 {
     $result = array('loc' => XenForo_Link::buildPublicLink('canonical:xengallery/users/albums', $entry), 'priority' => 0.3);
     if ($entry['gravatar'] || $entry['avatar_date']) {
         $avatarUrl = htmlspecialchars_decode(XenForo_Template_Helper_Core::callHelper('avatar', array($entry, 'l')));
         $avatarUrl = XenForo_Link::convertUriToAbsoluteUri($avatarUrl, true, $this->getCanonicalPaths());
         $result['image'] = $avatarUrl;
     }
     return $result;
 }
Пример #11
0
 public function getData(array $entry)
 {
     $result = array('loc' => XenForo_Link::buildPublicLink('canonical:xengallery', $entry), 'lastmod' => $entry['last_edit_date']);
     if (isset($entry['thumbnailUrl'])) {
         if ($entry['media_type'] == 'image_upload') {
             $result['image'] = XenForo_Link::buildPublicLink('canonical:xengallery/full', $entry);
         } else {
             $result['image'] = XenForo_Link::convertUriToAbsoluteUri($entry['thumbnailUrl'], true, $this->getCanonicalPaths());
         }
     }
     return $result;
 }
Пример #12
0
 public static function updateResponseRedirect(XenForo_Controller $controller, XenForo_ControllerResponse_Redirect $controllerResponse)
 {
     $action = false;
     $userId = 0;
     if ($controller instanceof XenForo_ControllerPublic_Login) {
         /** @var bdApiConsumer_XenForo_ControllerPublic_Login $controller */
         if (XenForo_Visitor::getUserId() > 0 && XenForo_Visitor::getUserId() != $controller->bdApiConsumer_getBeforeLoginVisitorId()) {
             // a successful login
             $action = 'login';
             $userId = XenForo_Visitor::getUserId();
         }
     } elseif ($controller instanceof XenForo_ControllerPublic_Logout) {
         /** @var bdApiConsumer_XenForo_ControllerPublic_Logout $controller */
         if (XenForo_Visitor::getUserId() == 0) {
             // a successful logout
             $action = 'logout';
             $userId = $controller->bdApiConsumer_getBeforeLogoutVisitorId();
         }
     }
     if ($action !== false && $userId > 0) {
         $redirectTarget = $controllerResponse->redirectTarget;
         $originalTarget = $redirectTarget;
         /** @var bdApiConsumer_XenForo_Model_UserExternal $userExternalModel */
         $userExternalModel = $controller->getModelFromCache('XenForo_Model_UserExternal');
         $auths = $userExternalModel->bdApiConsumer_getExternalAuthAssociations($userId);
         if (!empty($auths)) {
             foreach ($auths as $auth) {
                 $provider = bdApiConsumer_Option::getProviderByCode($auth['provider']);
                 if (empty($provider)) {
                     continue;
                 }
                 $accessToken = $userExternalModel->bdApiConsumer_getAccessTokenFromAuth($provider, $auth);
                 if (empty($accessToken)) {
                     continue;
                 }
                 $ott = bdApiConsumer_Helper_Api::generateOneTimeToken($provider, $auth['provider_key'], $accessToken);
                 $redirectTarget = XenForo_Link::convertUriToAbsoluteUri($redirectTarget, true);
                 switch ($action) {
                     case 'login':
                         $redirectTarget = bdApiConsumer_Helper_Api::getLoginLink($provider, $ott, $redirectTarget);
                         break;
                     case 'logout':
                         $redirectTarget = bdApiConsumer_Helper_Api::getLogoutLink($provider, $ott, $redirectTarget);
                         break;
                 }
             }
         }
         if ($redirectTarget !== $originalTarget) {
             $controllerResponse->redirectTarget = $redirectTarget;
         }
     }
 }
Пример #13
0
 public function renderRss()
 {
     $xenOptions = XenForo_Application::getOptions();
     if ($xenOptions->sonnbXG_enableRSS) {
         $title = new XenForo_Phrase('sonnb_xengallery');
         $title = $title->render();
         $description = new XenForo_Phrase('sonnb_xengallery_short_description', array('title' => $xenOptions->boardTitle));
         $description = $description->render();
         $buggyXmlNamespace = defined('LIBXML_DOTTED_VERSION') && LIBXML_DOTTED_VERSION == '2.6.24';
         $feed = new Zend_Feed_Writer_Feed();
         $feed->setEncoding('utf-8');
         $feed->setTitle($title);
         $feed->setDescription($description);
         $feed->setLink(XenForo_Link::buildPublicLink('canonical:gallery'));
         if (!$buggyXmlNamespace) {
             $feed->setFeedLink(XenForo_Link::buildPublicLink('canonical:gallery/index.rss'), 'rss');
         }
         $feed->setDateModified(XenForo_Application::$time);
         $feed->setLastBuildDate(XenForo_Application::$time);
         $feed->setGenerator($title);
         $formatter = XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_Text', array('view' => $this));
         $parser = new XenForo_BbCode_Parser($formatter);
         foreach ($this->_params['albums'] as $album) {
             $albumDescription = $parser->render($album['description']);
             $entry = $feed->createEntry();
             if (!empty($album['contents'])) {
                 $albumDescription .= '<br /><br />';
                 foreach ($album['contents'] as $content) {
                     $albumDescription .= '<a href="' . XenForo_Link::buildPublicLink('canonical:gallery/' . $content['content_type'] . 's', $content) . '"><img src="' . XenForo_Link::convertUriToAbsoluteUri($content['thumbnailUrl'], true) . '" /></a>';
                 }
             }
             if ($albumDescription) {
                 $entry->setDescription($albumDescription);
             }
             $entry->setTitle($album['title'] ? $album['title'] : $album['title'] . ' ');
             $entry->setLink(XenForo_Link::buildPublicLink('canonical:gallery/albums', $album));
             $entry->setDateCreated(new Zend_Date($album['album_date'], Zend_Date::TIMESTAMP));
             $entry->setDateModified(new Zend_Date($album['album_updated_date'], Zend_Date::TIMESTAMP));
             if (!$buggyXmlNamespace) {
                 $entry->addAuthor(array('name' => $album['username'], 'uri' => XenForo_Link::buildPublicLink('canonical:gallery/authors', $album)));
                 if ($album['comment_count']) {
                     $entry->setCommentCount($album['comment_count']);
                     $entry->setCommentLink(XenForo_Link::buildPublicLink('canonical:gallery/albums', $album) . '#album-' . $album['album_id']);
                 }
             }
             $feed->addEntry($entry);
         }
         return $feed->export('rss');
     }
 }
Пример #14
0
 public function save()
 {
     $response = parent::save();
     if (!empty($this->_newData['xf_post']['thread_id']) && !empty($this->_newData['xf_post']['post_id'])) {
         $options = XenForo_Application::get('options');
         if ($options->dark_taigachat_activity != 'None') {
             $visitor = XenForo_Visitor::getInstance();
             $isThread = $this->_newData['xf_post']['position'] == 0;
             /** @var XenForo_Model_Thread */
             $threadModel = XenForo_Model::create("XenForo_Model_Thread");
             $thread = $threadModel->getThreadById($this->_newData['xf_post']['thread_id']);
             /** @var XenForo_Model_Node */
             $nodeModel = XenForo_Model::create("XenForo_Model_Node");
             $node = $nodeModel->getNodeById($thread['node_id']);
             $ok = false;
             // making the not-too-risky assumption that 1 will be guest group
             $permissionCombinationId = 1;
             if ($options->dark_taigachat_activity_userid > 0) {
                 /** @var XenForo_Model_User */
                 $userModel = XenForo_Model::create("XenForo_Model_User");
                 $activityUser = $userModel->getUserById($options->dark_taigachat_activity_userid);
                 $permissionCombinationId = $activityUser['permission_combination_id'];
             }
             $nodePermissions = $nodeModel->getNodePermissionsForPermissionCombination($permissionCombinationId);
             foreach ($nodePermissions as $nodeId => $nodePermission) {
                 if ($nodeId == $node['node_id'] && XenForo_Permission::hasContentPermission($nodePermission, 'view') && XenForo_Permission::hasContentPermission($nodePermission, 'viewOthers')) {
                     $ok = true;
                 }
             }
             if ($ok) {
                 if ($isThread) {
                     $activityMessage = new XenForo_Phrase('dark_posted_new_thread_in_x_x', array('forum' => "[url='" . XenForo_Link::convertUriToAbsoluteUri(XenForo_Link::buildPublicLink("forums", $node), true) . "']" . $node['title'] . "[/url]", 'thread' => "[url='" . XenForo_Link::convertUriToAbsoluteUri(XenForo_Link::buildPublicLink("threads", $thread), true) . "']" . $thread['title'] . "[/url]"), false);
                 } else {
                     $activityMessage = new XenForo_Phrase('dark_replied_to_x', array('thread' => "[url='" . XenForo_Link::convertUriToAbsoluteUri(XenForo_Link::buildPublicLink("posts", $this->_newData['xf_post']), true) . "']" . $thread['title'] . "[/url]"), false);
                 }
                 if ($isThread || $options->dark_taigachat_activity == 'Both') {
                     $dw = XenForo_DataWriter::create('Dark_TaigaChat_DataWriter_Message');
                     $dw->setOption(Dark_TaigaChat_DataWriter_Message::OPTION_IS_AUTOMATED, true);
                     $dw->set('user_id', $visitor['user_id']);
                     $dw->set('username', $visitor['user_id'] > 0 ? $visitor['username'] : new XenForo_Phrase('guest'));
                     $dw->set('message', $activityMessage);
                     $dw->set('activity', 1);
                     $dw->save();
                 }
             }
         }
     }
     return $response;
 }
Пример #15
0
 public static function runDailyCleanUp()
 {
     $options = XenForo_Application::get('options');
     $model = XenForo_Model::create('Dark_TaigaChat_Model_TaigaChat');
     if ($options->dark_taigachat_archivethread > 0) {
         // swap timezone to default temporarily
         $oldTimeZone = XenForo_Locale::getDefaultTimeZone()->getName();
         XenForo_Locale::setDefaultTimeZone($options->guestTimeZone);
         $messages = array_reverse($model->getMessagesToday());
         if (count($messages) > 0) {
             $userModel = XenForo_Model::create('XenForo_Model_User');
             $post = "";
             foreach ($messages as $message) {
                 $message['message'] = XenForo_Helper_String::autoLinkBbCode($message['message']);
                 $date = XenForo_Locale::dateTime($message['date'], 'absolute');
                 if ($message['user_id'] > 0) {
                     $url = XenForo_Link::convertUriToAbsoluteUri(XenForo_Link::buildPublicLink("members/" . $message['user_id']), true);
                     $user = "******";
                 } else {
                     $user = "******";
                 }
                 $me = substr($message['message'], 0, 3) == '/me';
                 if ($me) {
                     $message['message'] = substr($message['message'], 3);
                     $post .= "{$date} - [i]{$user} {$message['message']}[/i]\r\n";
                 } else {
                     $post .= "{$date} - {$user}: {$message['message']}\r\n";
                 }
             }
             $username = "******";
             if ($options->dark_taigachat_archiveuser > 0) {
                 $user = $userModel->getUserById($options->dark_taigachat_archiveuser);
                 $username = $user['username'];
             }
             $writer = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post');
             $writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_IS_AUTOMATED, true);
             $writer->set('user_id', $options->dark_taigachat_archiveuser);
             $writer->set('username', $username);
             $writer->set('message', $post);
             $writer->set('thread_id', $options->dark_taigachat_archivethread);
             $writer->save();
         }
         // put timezone back to how it was
         XenForo_Locale::setDefaultTimeZone($oldTimeZone);
     }
     $model->deleteOldMessages();
 }
Пример #16
0
 public function getRecords($previousLast, $limit, array $viewingUser)
 {
     if ($previousLast) {
         return array();
     }
     $result = array(1 => array('loc' => XenForo_Link::buildPublicLink('canonical:index')));
     $canonicalPaths = $this->getCanonicalPaths();
     $extras = preg_split('/\\r?\\n/', XenForo_Application::getOptions()->sitemapExtraUrls, -1, PREG_SPLIT_NO_EMPTY);
     foreach ($extras as $extra) {
         $url = XenForo_Link::convertUriToAbsoluteUri($extra, true, $canonicalPaths);
         if (strpos($url, $canonicalPaths['fullBasePath']) === 0) {
             // right prefix
             $result[] = array('loc' => $url);
         }
     }
     return $result;
 }
Пример #17
0
 public function getImage(XenForo_Model $model)
 {
     $item = $this->_itemDw->getMergedData();
     if ($item['attach_count'] > 0) {
         if ($this->_image === false) {
             $item = $model->getModelFromCache('NFLJ_Showcase_Model_Item')->getAndMergeAttachmentsIntoItem($item);
             if (!empty($item['cover_image'])) {
                 $this->_image = XenForo_Link::convertUriToAbsoluteUri($item['cover_image']['thumbnailUrl'], true);
             } else {
                 $this->_image = '';
             }
         }
         if (!empty($this->_image)) {
             return $this->_image;
         }
     }
     return parent::getImage($model);
 }
Пример #18
0
 public static function listen(array &$extraTabs, $selectedTabId)
 {
     $options = XenForo_Application::get('options');
     $visitor = XenForo_Visitor::getInstance();
     if ($options->dark_taigachat_navtab && $visitor->hasPermission("dark_taigachat", "view")) {
         $counter = array();
         if ($options->dark_taigachat_navtab_numinchat) {
             /** @var Dark_TaigaChat_Model_TaigaChat */
             $taigamodel = XenForo_Model::create('Dark_TaigaChat_Model_TaigaChat');
             $numInChat = $taigamodel->getActivityUserCount();
             if ($numInChat > 0) {
                 $counter = array('counter' => $numInChat);
             }
         }
         $extraTabs['taigachat'] = $counter + array('title' => new Xenforo_Phrase("dark_shoutbox"), 'href' => XenForo_Link::convertUriToAbsoluteUri(XenForo_Link::buildPublicLink($options->dark_taigachat_route), true), 'selected' => $selectedTabId == 'taigachat', 'linksTemplate' => 'dark_taigachat_links', 'taigachat' => array("route" => $options->dark_taigachat_route, "popupenabled" => $options->dark_taigachat_popupenabled));
         if (!$options->dark_taigachat_popupenabled) {
             unset($extraTabs['taigachat']['linksTemplate']);
         }
     }
 }
Пример #19
0
 public static function convertUrisToAbsoluteUris($html)
 {
     $offset = 0;
     while (true) {
         if (preg_match('#<a[^>]+href="([^"]+)"#', $html, $matches, PREG_OFFSET_CAPTURE, $offset)) {
             $href = $matches[1];
             $uri = $href[0];
             $absoluteUri = XenForo_Link::convertUriToAbsoluteUri($uri, true);
             if ($uri !== $absoluteUri) {
                 $html = substr_replace($html, $absoluteUri, $href[1], strlen($uri));
                 $offset = $href[1] + strlen($absoluteUri);
             } else {
                 $offset = $href[1] + strlen($uri);
             }
         } else {
             break;
         }
     }
     return $html;
 }
Пример #20
0
 public static function helperItemImageUrl($item, $size, $forceType = null, $canonical = false)
 {
     if (!is_array($item)) {
         $item = array();
     }
     if ($forceType) {
         switch ($forceType) {
             case 'default':
             case 'custom':
                 break;
             default:
                 $forceType = null;
                 break;
         }
     }
     $url = self::getItemImageUrl($item, $size, $forceType);
     if ($canonical) {
         $url = XenForo_Link::convertUriToAbsoluteUri($url, true);
     }
     return htmlspecialchars($url);
 }
Пример #21
0
 public function runXenDynamic($html)
 {
     global $XenDynamic_indexFile, $XenDynamic_container;
     ob_start();
     $this->setup();
     $this->_request->setBasePath(XenForo_Link::convertUriToAbsoluteUri("{$XenDynamic_indexFile}"));
     $this->setRequestPaths();
     $showDebugOutput = $this->showDebugOutput();
     $this->_dependencies->preLoadData();
     XenForo_CodeEvent::fire('front_controller_pre_route', array($this));
     $routeMatch = $this->route();
     XenForo_CodeEvent::fire('front_controller_pre_dispatch', array($this, &$routeMatch));
     $controllerResponse = $this->dispatch($routeMatch);
     $controllerResponse = new XenForo_ControllerResponse_View();
     $controllerResponse->templateName = "XenDynamic";
     $controllerResponse->viewName = "XenDynamic_Index";
     /*
     		$title = "";
     		if(preg_match('/<title>(.*?)<\/title>/i', $html, $matches) && count($matches) == 2){
     			$title = $matches[1];
     		}
     		$controllerResponse->params = array(
     			'title' => $title,
     			'html' => $html
     		);                
     */
     $viewRenderer = $this->_getViewRenderer('html');
     if (!$viewRenderer) {
         XenForo_Error::noViewRenderer($this->_request);
         exit;
     }
     $viewRenderer->setNeedsContainer($XenDynamic_container);
     $containerParams = array();
     XenForo_CodeEvent::fire('front_controller_pre_view', array($this, &$controllerResponse, &$viewRenderer, &$containerParams));
     $content = $this->renderView($controllerResponse, $viewRenderer, $containerParams);
     if ($showDebugOutput) {
         $content = $this->renderDebugOutput($content);
     }
     $bufferedContents = ob_get_contents();
     ob_end_clean();
     if ($bufferedContents !== '') {
         $content = $bufferedContents . $content;
     }
     XenForo_CodeEvent::fire('front_controller_post_view', array($this, &$content));
     /*
     		if ($this->_sendResponse)
     		{
     			$headers = $this->_response->getHeaders();
     			$isText = false;
     			foreach ($headers AS $header)
     			{
     				if ($header['name'] == 'Content-Type')
     				{
     					if (strpos($header['value'], 'text/') === 0)
     					{
     						$isText = true;
     					}
     					break;
     				}
     			}
     			if ($isText && is_string($content) && $content)
     			{
     				$extraHeaders = XenForo_Application::gzipContentIfSupported($content);
     				foreach ($extraHeaders AS $extraHeader)
     				{
     					$this->_response->setHeader($extraHeader[0], $extraHeader[1], $extraHeader[2]);
     				}
     			}
     
     			if (is_string($content) && $content && !ob_get_level() && XenForo_Application::get('config')->enableContentLength)
     			{
     				$this->_response->setHeader('Content-Length', strlen($content), true);
     			}
     
     			$this->_response->sendHeaders();
     
     			if ($content instanceof XenForo_FileOutput)
     			{
     				$content->output();
     			}
     			else
     			{
     				echo $content;
     			}
     		}
     		else
     		{
     */
     return $content;
     // 		}
 }
Пример #22
0
 /**
  * Parses a URL that should contain a route match in it into
  * the route match and any request params set by it.
  *
  * @param string $url
  *
  * @return array|bool False if parsing fails, otherwise array with match and params keys
  */
 public function parseRouteUrl($url)
 {
     if (!XenForo_Application::isRegistered('fc')) {
         return false;
     }
     $requestPaths = XenForo_Application::get('requestPaths');
     $url = XenForo_Link::convertUriToAbsoluteUri($url);
     if (strpos($url, $requestPaths['fullBasePath']) !== 0) {
         return false;
     }
     $urlParts = parse_url($url);
     $requestUri = (isset($urlParts['path']) ? $urlParts['path'] : '/') . (isset($urlParts['query']) ? '?' . $urlParts['query'] : '');
     $request = clone $this->_request;
     $request->setRequestUri($requestUri);
     $match = XenForo_Application::getFc()->getDependencies()->getRouter()->match($request);
     return array('match' => $match, 'params' => $request->getUserParams());
 }
Пример #23
0
 protected function _getImageForAttachment($attachment, XenForo_Model $model)
 {
     // try to use full size link if possible
     $image = XenForo_Link::buildPublicLink('attachments', $attachment);
     if (Zend_URi::check($image) and substr($image, -1) !== '/') {
         $filename = basename($image);
         $ext = XenForo_Helper_File::getFileExtension($filename);
         if (in_array($ext, array('gif', 'jpg', 'jpeg', 'png'), true)) {
             return $image;
         }
     }
     // fallback to thumbnail
     $image = $model->getModelFromCache('XenForo_Model_Attachment')->getAttachmentThumbnailUrl($attachment);
     $image = XenForo_Link::convertUriToAbsoluteUri($image, true);
     return $image;
 }
Пример #24
0
/**
* For use via preg_replace_callback; makes urls absolute before wrapping them in [url]
*/
function parse_local_link($input)
{
    return "[URL=" . XenForo_Link::convertUriToAbsoluteUri($input[1], true) . "]{$input[2]}[/URL]";
}
Пример #25
0
 public function getEventCalendarEntries(array $events)
 {
     $entries = array();
     $i = 0;
     foreach ($events as $eventId => $event) {
         $i++;
         $currentDate = XenForo_Locale::date($event['begin_date'], 'Y-m-d H:i:s');
         if ($event['end_date']) {
             $nextDate = XenForo_Locale::date($event['end_date'], 'Y-m-d H:i:s');
         } else {
             $nextDate = Date('Y-m-d', strtotime('+1 day', strtotime($currentDate)));
             $nextDate .= ' 00:00:00';
         }
         $entries[] = array('id' => $eventId, 'title' => XenForo_Helper_String::wholeWordTrim($event['event_title'], 25), 'start' => "{$currentDate}", 'url' => XenForo_Link::convertUriToAbsoluteUri(XenForo_Link::buildPublicLink(TEAM_ROUTE_ACTION . '/events', $event), true), 'allDay' => false, 'end' => "{$nextDate}", 'className' => 'eventEntry');
     }
     return $entries;
 }
Пример #26
0
 /**
  * Returns a Gravatar URL for the user
  *
  * @param array $user
  * @param string|integer $size (s,m,l)
  * @param string Override default (useful to use '404')
  */
 protected static function _getGravatarUrl(array $user, $size, $default = '')
 {
     $md5 = md5(strtolower(trim($user['gravatar'])));
     if ($default === '') {
         $default = '&d=' . urlencode(XenForo_Link::convertUriToAbsoluteUri(self::_getDefaultAvatarUrl($user, $size), true));
     } else {
         if (!empty($default)) {
             $default = '&d=' . urlencode($default);
         }
     }
     if (is_string($size)) {
         $size = XenForo_Model_Avatar::getSizeFromCode($size);
     }
     return (XenForo_Application::$secure ? 'https://secure' : 'http://www') . ".gravatar.com/avatar/{$md5}?s={$size}{$default}";
 }
 /**
  * Renders the view.
  *
  * @param XenForo_ControllerResponse_Abstract Controller response object from last controller
  * @param XenForo_ViewRenderer_Abstract       View renderer for specified response type
  * @param array                            Extra container params (probably "sections" from routing)
  *
  * @return string View output
  */
 public function renderView(XenForo_ControllerResponse_Abstract $controllerResponse, XenForo_ViewRenderer_Abstract $viewRenderer, array $containerParams = array())
 {
     $this->_dependencies->preRenderView($controllerResponse);
     $this->_response->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true);
     if ($controllerResponse->responseCode) {
         $this->_response->setHttpResponseCode($controllerResponse->responseCode);
         if (!empty($controllerResponse->containerParams['allowHeader'])) {
             $this->_response->setHeader('Allow', $controllerResponse->containerParams['allowHeader']);
         }
     }
     if ($controllerResponse instanceof XenForo_ControllerResponse_Error) {
         $innerContent = $viewRenderer->renderError($controllerResponse->errorText);
     } else {
         if ($controllerResponse instanceof XenForo_ControllerResponse_Message) {
             $innerContent = $viewRenderer->renderMessage($controllerResponse->message);
         } else {
             if ($controllerResponse instanceof XenForo_ControllerResponse_View) {
                 $viewRenderer->addJsonParams($controllerResponse->jsonParams);
                 $innerContent = $viewRenderer->renderView($controllerResponse->viewName, $controllerResponse->params, $controllerResponse->templateName, $controllerResponse->subView);
             } else {
                 if ($controllerResponse instanceof XenForo_ControllerResponse_Redirect) {
                     $target = XenForo_Link::convertUriToAbsoluteUri($controllerResponse->redirectTarget, true);
                     $innerContent = $viewRenderer->renderRedirect($controllerResponse->redirectType, $target, $controllerResponse->redirectMessage, $controllerResponse->redirectParams);
                 } else {
                     // generally shouldn't happen
                     $innerContent = false;
                 }
             }
         }
     }
     if ($innerContent === false || $innerContent === null) {
         $innerContent = $viewRenderer->renderUnrepresentable();
     }
     if ($viewRenderer->getNeedsContainer()) {
         $specificContainerParams = XenForo_Application::mapMerge($containerParams, $controllerResponse->containerParams);
         $containerParams = $this->_dependencies->getEffectiveContainerParams($specificContainerParams, $this->_request);
         return $viewRenderer->renderContainer($innerContent, $containerParams);
     } else {
         return $innerContent;
     }
 }
Пример #28
0
 /**
  * Registers a new account (or associates with an existing one) using Facebook.
  *
  * @return XenForo_ControllerResponse_Abstract
  */
 public function actionFacebookRegister()
 {
     $this->_assertPostOnly();
     $fbToken = $this->_input->filterSingle('fb_token', XenForo_Input::STRING);
     $fbUser = XenForo_Helper_Facebook::getUserInfo($fbToken);
     if (empty($fbUser['id'])) {
         return $this->responseError(new XenForo_Phrase('error_occurred_while_connecting_with_facebook'));
     }
     $userModel = $this->_getUserModel();
     $userExternalModel = $this->_getUserExternalModel();
     $doAssoc = $this->_input->filterSingle('associate', XenForo_Input::STRING) || $this->_input->filterSingle('force_assoc', XenForo_Input::UINT);
     if ($doAssoc) {
         $associate = $this->_input->filter(array('associate_login' => XenForo_Input::STRING, 'associate_password' => XenForo_Input::STRING));
         $loginModel = $this->_getLoginModel();
         if ($loginModel->requireLoginCaptcha($associate['associate_login'])) {
             return $this->responseError(new XenForo_Phrase('your_account_has_temporarily_been_locked_due_to_failed_login_attempts'));
         }
         $userId = $userModel->validateAuthentication($associate['associate_login'], $associate['associate_password'], $error);
         if (!$userId) {
             $loginModel->logLoginAttempt($associate['associate_login']);
             return $this->responseError($error);
         }
         $userExternalModel->updateExternalAuthAssociation('facebook', $fbUser['id'], $userId);
         XenForo_Helper_Facebook::setUidCookie($fbUser['id']);
         XenForo_Application::get('session')->changeUserId($userId);
         XenForo_Visitor::setup($userId);
         $redirect = XenForo_Application::get('session')->get('fbRedirect');
         XenForo_Application::get('session')->remove('fbRedirect');
         if (!$redirect) {
             $redirect = $this->getDynamicRedirect(false, false);
         }
         return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $redirect);
     }
     $this->_assertRegistrationActive();
     $data = $this->_input->filter(array('username' => XenForo_Input::STRING, 'timezone' => XenForo_Input::STRING));
     if (XenForo_Dependencies_Public::getTosUrl() && !$this->_input->filterSingle('agree', XenForo_Input::UINT)) {
         return $this->responseError(new XenForo_Phrase('you_must_agree_to_terms_of_service'));
     }
     $options = XenForo_Application::get('options');
     $gender = '';
     if (isset($fbUser['gender'])) {
         switch ($fbUser['gender']) {
             case 'man':
             case 'male':
                 $gender = 'male';
                 break;
             case 'woman':
             case 'female':
                 $gender = 'female';
                 break;
         }
     }
     $writer = XenForo_DataWriter::create('XenForo_DataWriter_User');
     if ($options->registrationDefaults) {
         $writer->bulkSet($options->registrationDefaults, array('ignoreInvalidFields' => true));
     }
     $writer->bulkSet($data);
     $writer->bulkSet(array('gender' => $gender, 'email' => $fbUser['email'], 'location' => isset($fbUser['location']['name']) ? $fbUser['location']['name'] : ''));
     if (!empty($fbUser['birthday'])) {
         $birthdayParts = explode('/', $fbUser['birthday']);
         if (count($birthdayParts) == 3) {
             list($month, $day, $year) = $birthdayParts;
             $userAge = $this->_getUserProfileModel()->calculateAge($year, $month, $day);
             if ($userAge < intval($options->get('registrationSetup', 'minimumAge'))) {
                 // TODO: set a cookie to prevent re-registration attempts
                 return $this->responseError(new XenForo_Phrase('sorry_you_too_young_to_create_an_account'));
             }
             $writer->bulkSet(array('dob_year' => $year, 'dob_month' => $month, 'dob_day' => $day));
         }
     }
     if (!empty($fbUser['website'])) {
         list($website) = preg_split('/\\r?\\n/', $fbUser['website']);
         if ($website && Zend_Uri::check($website)) {
             $writer->set('homepage', $website);
         }
     }
     $auth = XenForo_Authentication_Abstract::create('XenForo_Authentication_NoPassword');
     $writer->set('scheme_class', $auth->getClassName());
     $writer->set('data', $auth->generate(''), 'xf_user_authenticate');
     $writer->set('user_group_id', XenForo_Model_User::$defaultRegisteredGroupId);
     $writer->set('language_id', XenForo_Visitor::getInstance()->get('language_id'));
     $writer->advanceRegistrationUserState(false);
     $writer->preSave();
     // TODO: option for extra user group
     $writer->save();
     $user = $writer->getMergedData();
     $avatarFile = tempnam(XenForo_Helper_File::getTempDir(), 'xf');
     if ($avatarFile) {
         $data = XenForo_Helper_Facebook::getUserPicture($fbToken);
         if ($data && $data[0] != '{') {
             file_put_contents($avatarFile, $data);
             try {
                 $user = array_merge($user, $this->getModelFromCache('XenForo_Model_Avatar')->applyAvatar($user['user_id'], $avatarFile));
             } catch (XenForo_Exception $e) {
             }
         }
         @unlink($avatarFile);
     }
     $userExternalModel->updateExternalAuthAssociation('facebook', $fbUser['id'], $user['user_id']);
     XenForo_Model_Ip::log($user['user_id'], 'user', $user['user_id'], 'register');
     XenForo_Helper_Facebook::setUidCookie($fbUser['id']);
     XenForo_Application::get('session')->changeUserId($user['user_id']);
     XenForo_Visitor::setup($user['user_id']);
     $redirect = $this->_input->filterSingle('redirect', XenForo_Input::STRING);
     $viewParams = array('user' => $user, 'redirect' => $redirect ? XenForo_Link::convertUriToAbsoluteUri($redirect) : '', 'facebook' => true);
     return $this->responseView('XenForo_ViewPublic_Register_Process', 'register_process', $viewParams, $this->_getRegistrationContainerParams());
 }
Пример #29
0
 protected function _getExternalAuthRedirect()
 {
     $redirect = XenForo_Link::convertUriToAbsoluteUri($this->getDynamicRedirect(), true);
     $baseDomain = preg_replace('#^([a-z]+://[^/]+).*$#i', '$1', XenForo_Link::convertUriToAbsoluteUri(XenForo_Application::getOptions()->boardUrl, true));
     if (strpos($redirect, $baseDomain) !== 0) {
         $redirect = XenForo_Link::buildPublicLink('canonical:index');
     }
     return $redirect;
 }
Пример #30
0
 public function prepareApiDataForAttachment(array $attachment, array $post, array $thread, array $forum, $tempHash = '')
 {
     /* @var $attachmentModel XenForo_Model_Attachment */
     $attachmentModel = $this->getModelFromCache('XenForo_Model_Attachment');
     $attachment = $attachmentModel->prepareAttachment($attachment);
     $publicKeys = array('attachment_id' => 'attachment_id', 'content_id' => 'post_id', 'view_count' => 'attachment_download_count', 'filename' => 'filename');
     $data = bdApi_Data_Helper_Core::filter($attachment, $publicKeys);
     $paths = XenForo_Application::get('requestPaths');
     $paths['fullBasePath'] = XenForo_Application::getOptions()->get('boardUrl') . '/';
     $data['links'] = array('permalink' => XenForo_Link::buildPublicLink('attachments', $attachment));
     if (!empty($attachment['thumbnailUrl'])) {
         $data['links']['thumbnail'] = XenForo_Link::convertUriToAbsoluteUri($attachment['thumbnailUrl'], true, $paths);
     }
     if (!empty($post['post_id'])) {
         $data['links'] += array('data' => bdApi_Data_Helper_Core::safeBuildApiLink('posts/attachments', $post, array('attachment_id' => $attachment['attachment_id'])), 'post' => bdApi_Data_Helper_Core::safeBuildApiLink('posts', $post));
     }
     $data['permissions'] = array('view' => !empty($tempHash) ? $attachmentModel->canViewAttachment($attachment, $tempHash) : $this->canViewAttachmentOnPost($post, $thread, $forum), 'delete' => !empty($tempHash) ? $attachmentModel->canDeleteAttachment($attachment, $tempHash) : $this->canEditPost($post, $thread, $forum));
     if (isset($post['messageHtml'])) {
         $data['attachment_is_inserted'] = empty($post['attachments'][$attachment['attachment_id']]);
     }
     return $data;
 }