コード例 #1
0
ファイル: UserEmail.php プロジェクト: darkearl/projectT122015
 protected function _sendEmail(array $email, array $user, Zend_Mail_Transport_Abstract $transport)
 {
     if (!$user['email']) {
         return;
     }
     $phraseTitles = XenForo_Helper_String::findPhraseNamesFromStringSimple($email['email_title'] . $email['email_body']);
     /** @var XenForo_Model_Phrase $phraseModel */
     $phraseModel = XenForo_Model::create('XenForo_Model_Phrase');
     $phrases = $phraseModel->getPhraseTextFromPhraseTitles($phraseTitles, $user['language_id']);
     foreach ($phraseTitles as $search => $phraseTitle) {
         if (isset($phrases[$phraseTitle])) {
             $email['email_title'] = str_replace($search, $phrases[$phraseTitle], $email['email_title']);
             $email['email_body'] = str_replace($search, $phrases[$phraseTitle], $email['email_body']);
         }
     }
     $mailObj = new Zend_Mail('utf-8');
     $mailObj->setSubject($email['email_title'])->addTo($user['email'], $user['username'])->setFrom($email['from_email'], $email['from_name']);
     $options = XenForo_Application::getOptions();
     $bounceEmailAddress = $options->bounceEmailAddress;
     if (!$bounceEmailAddress) {
         $bounceEmailAddress = $options->defaultEmailAddress;
     }
     $toEmail = $user['email'];
     $bounceHmac = substr(hash_hmac('md5', $toEmail, XenForo_Application::getConfig()->globalSalt), 0, 8);
     $mailObj->addHeader('X-To-Validate', "{$bounceHmac}+{$toEmail}");
     if ($options->enableVerp) {
         $verpValue = str_replace('@', '=', $toEmail);
         $bounceEmailAddress = str_replace('@', "+{$bounceHmac}+{$verpValue}@", $bounceEmailAddress);
     }
     $mailObj->setReturnPath($bounceEmailAddress);
     if ($email['email_format'] == 'html') {
         $replacements = array('{name}' => htmlspecialchars($user['username']), '{email}' => htmlspecialchars($user['email']), '{id}' => $user['user_id']);
         $email['email_body'] = strtr($email['email_body'], $replacements);
         $text = trim(htmlspecialchars_decode(strip_tags($email['email_body'])));
         $mailObj->setBodyHtml($email['email_body'])->setBodyText($text);
     } else {
         $replacements = array('{name}' => $user['username'], '{email}' => $user['email'], '{id}' => $user['user_id']);
         $email['email_body'] = strtr($email['email_body'], $replacements);
         $mailObj->setBodyText($email['email_body']);
     }
     if (!$mailObj->getMessageId()) {
         $mailObj->setMessageId();
     }
     $thisTransport = XenForo_Mail::getFinalTransportForMail($mailObj, $transport);
     try {
         $mailObj->send($thisTransport);
     } catch (Exception $e) {
         if (method_exists($thisTransport, 'resetConnection')) {
             XenForo_Error::logException($e, false, "Email to {$user['email']} failed: ");
             $thisTransport->resetConnection();
             try {
                 $mailObj->send($thisTransport);
             } catch (Exception $e) {
                 XenForo_Error::logException($e, false, "Email to {$user['email']} failed (after retry): ");
             }
         } else {
             XenForo_Error::logException($e, false, "Email to {$user['email']} failed: ");
         }
     }
 }
コード例 #2
0
ファイル: View.php プロジェクト: maitandat1507/Tinhte_XenTag
 protected function _Tinhte_XenTag_prepareRssEntry($result, Zend_Feed_Writer_Feed $feed)
 {
     $entry = false;
     if ($result[XenForo_Model_Search::CONTENT_TYPE] == 'thread') {
         $thread = $result['content'];
         $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));
         $discussionRssContentLength = XenForo_Application::getOptions()->get('discussionRssContentLength');
         if (!empty($thread['message']) && $discussionRssContentLength > 0) {
             $bbCodeParser = $this->_Tinhte_XenTag_getBbCodeParser('Base');
             $bbCodeSnippetParser = $this->_Tinhte_XenTag_getBbCodeParser('XenForo_BbCode_Formatter_BbCode_Clean');
             $rendererStates = array('disableProxying' => true);
             $wordTrimmed = XenForo_Helper_String::wholeWordTrim($thread['message'], $discussionRssContentLength);
             $snippet = $bbCodeSnippetParser->render($wordTrimmed, $rendererStates);
             if ($snippet != $thread['message']) {
                 $snippet .= "\n\n[url='" . XenForo_Link::buildPublicLink('canonical:threads', $thread) . "']" . $thread['title'] . '[/url]';
             }
             $content = trim($bbCodeParser->render($snippet, $rendererStates));
             if (strlen($content)) {
                 $entry->setContent($content);
             }
         }
         if (!$this->_Tinhte_XenTag_isBuggyXmlNamespace()) {
             $entry->addAuthor(array('name' => $thread['username'], 'uri' => XenForo_Link::buildPublicLink('canonical:members', $thread)));
             if ($thread['reply_count']) {
                 $entry->setCommentCount($thread['reply_count']);
             }
         }
     }
     return $entry;
 }
コード例 #3
0
ファイル: Abstract.php プロジェクト: namgiangle90/tokyobaito
 /**
  * Default, empty string filterer.
  *
  * @see XenForo_BbCode_Formatter_Base::filterString()
  */
 public function filterString($string, array $rendererStates)
 {
     if ($this->_censorString) {
         $string = XenForo_Helper_String::censorString($string);
     }
     return $string;
 }
コード例 #4
0
ファイル: Photo.php プロジェクト: Sywooch/forums
 /**
  * @param array $logUser
  * @param array $content
  * @param $action
  * @param array $actionParams
  * @param null $parentContent
  * @return mixed
  */
 protected function _log(array $logUser, array $content, $action, array $actionParams = array(), $parentContent = null)
 {
     $dw = XenForo_DataWriter::create('XenForo_DataWriter_ModeratorLog');
     $dw->bulkSet(array('user_id' => $logUser['user_id'], 'content_type' => sonnb_XenGallery_Model_Photo::$xfContentType, 'content_id' => $content['content_id'], 'content_user_id' => $content['user_id'], 'content_username' => $content['username'], 'content_title' => XenForo_Helper_String::wordWrapString($content['title'], 140), 'content_url' => XenForo_Link::buildPublicLink('gallery/photos', $content), 'discussion_content_type' => sonnb_XenGallery_Model_Photo::$xfContentType, 'discussion_content_id' => $content['content_id'], 'action' => $action, 'action_params' => $actionParams));
     $dw->save();
     return $dw->get('moderator_log_id');
 }
コード例 #5
0
ファイル: Conversation.php プロジェクト: burtay/bdApi
 public function actionPostIndex()
 {
     if (!$this->_getConversationModel()->canStartConversations($errorPhraseKey)) {
         throw $this->getErrorOrNoPermissionResponseException($errorPhraseKey);
     }
     $input = $this->_input->filter(array('recipients' => XenForo_Input::STRING, 'conversation_title' => XenForo_Input::STRING));
     /* @var $editorHelper XenForo_ControllerHelper_Editor */
     $editorHelper = $this->getHelper('Editor');
     $input['message_body'] = $editorHelper->getMessageText('message_body', $this->_input);
     $input['message_body'] = XenForo_Helper_String::autoLinkBbCode($input['message_body']);
     $visitor = XenForo_Visitor::getInstance();
     /* @var $conversationDw XenForo_DataWriter_ConversationMaster */
     $conversationDw = XenForo_DataWriter::create('XenForo_DataWriter_ConversationMaster');
     $conversationDw->setExtraData(XenForo_DataWriter_ConversationMaster::DATA_ACTION_USER, $visitor->toArray());
     $conversationDw->setExtraData(XenForo_DataWriter_ConversationMaster::DATA_MESSAGE, $input['message_body']);
     $conversationDw->set('user_id', $visitor['user_id']);
     $conversationDw->set('username', $visitor['username']);
     $conversationDw->set('title', $input['conversation_title']);
     $conversationDw->addRecipientUserNames(explode(',', $input['recipients']));
     // checks permissions
     $messageDw = $conversationDw->getFirstMessageDw();
     $messageDw->set('message', $input['message_body']);
     $messageDw->setExtraData(XenForo_DataWriter_ConversationMessage::DATA_ATTACHMENT_HASH, $this->_getAttachmentHelper()->getAttachmentTempHash());
     $conversationDw->preSave();
     if (!$conversationDw->hasErrors()) {
         $this->assertNotFlooding('conversation');
     }
     $conversationDw->save();
     $conversation = $conversationDw->getMergedData();
     $this->_getConversationModel()->markConversationAsRead($conversation['conversation_id'], XenForo_Visitor::getUserId(), XenForo_Application::$time);
     $this->_request->setParam('conversation_id', $conversation['conversation_id']);
     return $this->responseReroute(__CLASS__, 'single');
 }
コード例 #6
0
ファイル: Totp.php プロジェクト: VoDongMy/xenforo-laravel5.1
 public function renderVerification(XenForo_View $view, $context, array $user, array $providerData, array $triggerData)
 {
     $issuer = XenForo_Helper_String::wholeWordTrim(str_replace(':', '', XenForo_Application::getOptions()->boardTitle), 50);
     $user = str_replace(':', '', $user['username']);
     $params = array('secret' => $providerData['secret'], 'otpUrl' => $this->_getAuthHandler()->getOtpAuthUrl("{$issuer}: {$user}", $providerData['secret'], $issuer), 'data' => $providerData, 'context' => $context);
     return $view->createTemplateObject('two_step_totp', $params)->render();
 }
コード例 #7
0
ファイル: Base.php プロジェクト: Sywooch/forums
 public function renderTagCode(array $tag, array $rendererStates)
 {
     if (strtolower(strval($tag['option'])) == 'html') {
         $tag['option'] = 'html5';
     }
     if (!$tag['option']) {
         $tag['option'] = 'text';
     }
     $content = $this->stringifyTree($tag['children']);
     $content = XenForo_Helper_String::censorString($content);
     $geshi = new GeSHi($content, $tag['option']);
     if (XenForo_Application::get('options')->get('dpSyntaxHighlighterShowLines')) {
         $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
     }
     $geshi->set_link_target('_blank" rel="nofollow');
     $geshi->set_header_type(GESHI_HEADER_NONE);
     $geshi->set_tab_width(4);
     $content = $geshi->parse_code();
     if ($this->_view) {
         $template = $this->_view->createTemplateObject('dp_bb_code_tag_code', array('content' => $content, 'language' => $geshi->get_language_name()));
         return $template->render();
     } else {
         return '<div style="margin: 1em auto" title="Code">' . $content . '</div>';
     }
 }
コード例 #8
0
ファイル: Feed.php プロジェクト: hahuunguyen/DTUI_201105
 public function actionSave()
 {
     if ($this->_input->inRequest('preview')) {
         return $this->responseReroute(__CLASS__, 'preview');
     }
     $this->_assertPostOnly();
     $feedId = $this->_input->filterSingle('feed_id', XenForo_Input::UINT);
     $data = $this->_getFeedFormData();
     $data['message_template'] = $this->getHelper('Editor')->getMessageText('message_template', $this->_input);
     $data['message_template'] = XenForo_Helper_String::autoLinkBbCode($data['message_template']);
     if ($data['user_id'] == -1) {
         $username = $this->_input->filterSingle('username', XenForo_Input::STRING);
         if ($user = $this->getModelFromCache('XenForo_Model_User')->getUserByName($username)) {
             $data['user_id'] = $user['user_id'];
         }
     }
     $data['user_id'] = intval(max($data['user_id'], 0));
     $writer = XenForo_DataWriter::create('XenForo_DataWriter_Feed');
     if ($feedId) {
         $writer->setExistingData($feedId);
     }
     $writer->bulkSet($data);
     $writer->save();
     return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink('feeds'));
 }
コード例 #9
0
ファイル: AutoLink.php プロジェクト: ThemeHouse-XF/Biblea
 public function autoLinkTag(array $tag, array $rendererStates)
 {
     $text = parent::autoLinkTag($tag, $rendererStates);
     if ($tag['tag'] == 'verse') {
         $bibleId = null;
         $option = explode(',', $tag['option']);
         $xenOptions = XenForo_Application::get('options');
         $verse = '';
         $version = null;
         if (count($option) > 1) {
             $verse = $option[0];
             $version = strtoupper($option[1]);
         } elseif ($option[0]) {
             if (preg_match('#^[A-z]+$#', $tag['option'])) {
                 $verse = '';
                 $version = strtoupper($tag['option']);
             } else {
                 $verse = $tag['option'];
                 $version = strtoupper($xenOptions->th_bible_defaultBible);
             }
         }
         if (in_array(strtolower($version), $xenOptions->th_bible_bbCodeBibles)) {
             $bibleId = strtolower($version);
         } elseif ($verse) {
             return $text;
         } else {
             $bibleId = null;
         }
         /* @var $verseModel ThemeHouse_Bible_Model_Verse */
         $verseModel = XenForo_Model::create('ThemeHouse_Bible_Model_Verse');
         if (!$verse) {
             $verse = XenForo_Helper_String::bbCodeStrip($text);
         }
         $verseText = $verseModel->getVerseFromText($verse, $bibleId);
         if ($verseText) {
             $verseTextStripped = XenForo_Helper_String::bbCodeStrip(str_ireplace('versenum', 'quote', $verseText), true);
             $textStripped = XenForo_Helper_String::bbCodeStrip(str_ireplace('versenum', 'quote', $text), true);
             $verseTextStripped = strtolower(preg_replace('!\\s+!', ' ', $verseTextStripped));
             // remove square brackets (i.e., extra comments)
             $textStripped = preg_replace('/\\[[^\\]]*\\]/', '', $textStripped);
             // remove double spaces, line breaks, etc.
             $textStripped = strtolower(preg_replace('!\\s+!', ' ', $textStripped));
             // split at elipsis
             $textStrippedSplit = preg_split("#(?:…)|(?:\\.\\.\\.)#", $textStripped);
             foreach ($textStrippedSplit as $_textStripped) {
                 if (!trim($_textStripped)) {
                     continue;
                 }
                 $strPos = strpos($verseTextStripped, $_textStripped);
                 if ($strPos === false) {
                     return '[VERSE=' . $verse . ',' . strtoupper($bibleId) . ']' . $verseText . '[/VERSE]';
                 } else {
                     $verseTextStripped = substr($verseTextStripped, $strPos + strlen($_textStripped));
                 }
             }
         }
     }
     return $text;
 }
コード例 #10
0
ファイル: Collection.php プロジェクト: Sywooch/forums
 public function prepareCollection(array $collection, $viewingUser = null)
 {
     $this->standardizeViewingUserReference($viewingUser);
     if (!empty($collection)) {
         $collection['title'] = XenForo_Helper_String::censorString($collection['title']);
         $collection['description'] = XenForo_Helper_String::censorString($collection['description']);
     }
     return $collection;
 }
コード例 #11
0
ファイル: List.php プロジェクト: AndroidOS/SocialGroups
 /**
  * Help render the HTML output.
  *
  * @return mixed
  */
 public function renderHtml()
 {
     foreach ($this->_params['socialForums'] as &$forum) {
         $forum['urls'] = ThemeHouse_SocialGroups_Template_Helper_SocialForum::getAvatarUrls($forum);
         $forum['description'] = XenForo_Helper_String::bbCodeStrip($forum['description'], true);
     }
     unset($forum);
     $this->_params['renderedSocialForums'] = ThemeHouse_SocialGroups_ViewPublic_Helper::renderSocialForumsListFromDisplayArray($this, $this->_params['socialForums']);
 }
コード例 #12
0
ファイル: AutoLink.php プロジェクト: hahuunguyen/DTUI_201105
 /**
  * Callback for the auto-linker regex.
  *
  * @param array $match
  *
  * @return string
  */
 protected function _autoLinkUrlCallback(array $match)
 {
     $link = XenForo_Helper_String::prepareAutoLinkedUrl($match[0]);
     if ($link['url'] === $link['linkText']) {
         $tag = '[url]' . $link['url'] . '[/url]';
     } else {
         $tag = '[url="' . $link['url'] . '"]' . $link['linkText'] . '[/url]';
     }
     return $tag . $link['suffixText'];
 }
コード例 #13
0
ファイル: Update.php プロジェクト: Sywooch/forums
 /**
  * Fetches the content required by alerts.
  *
  * @param array $contentIds
  * @param XenForo_Model_Alert $model Alert model invoking this
  * @param integer $userId User ID the alerts are for
  * @param array $viewingUser Information about the viewing user (keys: user_id, permission_combination_id, permissions)
  *
  * @return array
  */
 public function getContentByIds(array $contentIds, $model, $userId, array $viewingUser)
 {
     $updateModel = $this->_getUpdateModel();
     $updates = $updateModel->getUpdatesByIds($contentIds, array('join' => XenResource_Model_Update::FETCH_RESOURCE | XenResource_Model_Update::FETCH_CATEGORY, 'permissionCombinationId' => $viewingUser['permission_combination_id']));
     foreach ($updates as &$update) {
         $update['resource_title'] = XenForo_Helper_String::censorString($update['resource_title']);
         $update['title'] = XenForo_Helper_String::censorString($update['title']);
     }
     return $updates;
 }
コード例 #14
0
 /**
  * Prepares the news feed item for display
  *
  * @param array $item News feed item
  * @param array $content News feed item content
  * @param array $viewingUser Information about the viewing user (keys: user_id, permission_combination_id, permissions)
  *
  * @return array
  */
 protected function _prepareNewsFeedItemAfterAction(array $item, $content, array $viewingUser)
 {
     $item['content'] = array('title' => XenForo_Helper_String::censorString($content['title']));
     foreach ($this->_getContentPrimaryKeynames() as $key) {
         if (isset($content[$key])) {
             $item['content'][$key] = $content[$key];
         }
     }
     return $item;
 }
コード例 #15
0
ファイル: User.php プロジェクト: namgiangle90/tokyobaito
 /**
  * Prepares the news feed item for display
  *
  * @param array $item News feed item
  * @param array $content News feed item content
  * @param array $viewingUser Information about the viewing user (keys: user_id, permission_combination_id, permissions)
  *
  * @return array
  */
 protected function _prepareNewsFeedItemAfterAction(array $item, $content, array $viewingUser)
 {
     if (isset($item[$item['action']]['old'])) {
         $item[$item['action']]['old'] = XenForo_Helper_String::censorString($item[$item['action']]['old']);
     }
     if (isset($item[$item['action']]['new'])) {
         $item[$item['action']]['new'] = XenForo_Helper_String::censorString($item[$item['action']]['new']);
     }
     return $item;
 }
コード例 #16
0
ファイル: Categories.php プロジェクト: Sywooch/forums
 public function updateCategory($input)
 {
     $dw = XenForo_DataWriter::create('EWRmedio_DataWriter_Categories');
     if (!empty($input['category_id']) && ($category = $this->getCategoryByID($input['category_id']))) {
         $dw->setExistingData($category);
     }
     $dw->bulkSet(array('category_name' => $input['category_name'], 'category_description' => XenForo_Helper_String::autoLinkBbCode($input['category_description']), 'category_parent' => $input['category_parent'], 'category_disabled' => $input['category_disabled']));
     $dw->save();
     $input['category_id'] = $dw->get('category_id');
     return $input;
 }
コード例 #17
0
ファイル: Media.php プロジェクト: VoDongMy/xenforo-laravel5.1
 /**
  * Gets the title of the specified content.
  *
  * @see XenForo_ReportHandler_Abstract:getContentTitle()
  */
 public function getContentTitle(array $report, array $contentInfo)
 {
     if (!empty($contentInfo['media']['album_id']) && isset($contentInfo['media']['album_title'])) {
         return new XenForo_Phrase('xengallery_media_x_in_album_y', array('title' => XenForo_Helper_String::censorString($contentInfo['media']['media_title']), 'album' => $contentInfo['media']['album_title']));
     } else {
         if (!empty($contentInfo['media']['category_id']) && isset($contentInfo['media']['category_title'])) {
             return new XenForo_Phrase('xengallery_media_x_in_category_y', array('title' => XenForo_Helper_String::censorString($contentInfo['media']['media_title']), 'category' => $contentInfo['media']['category_title']));
         }
     }
     return new XenForo_Phrase('xengallery_media');
 }
コード例 #18
0
ファイル: Post.php プロジェクト: Sywooch/forums
 protected function _insertIntoIndex(XenForo_Search_Indexer $indexer, array $data, array $parentData = null)
 {
     $message = $data['message'];
     $message = trim(XenForo_Helper_String::stripQuotes($message, 0));
     $tagTexts = Tinhte_XenTag_Integration::parseHashtags($message);
     if (!empty($tagTexts)) {
         $extraMetadata = array();
         $extraMetadata[Tinhte_XenTag_Constants::SEARCH_METADATA_TAGS] = Tinhte_XenTag_Helper::getSafeTagsTextArrayForSearch($tagTexts);
         $indexer = new Tinhte_XenTag_XenForo_Search_Indexer($indexer, $extraMetadata);
     }
     $result = parent::_insertIntoIndex($indexer, $data, $parentData);
 }
コード例 #19
0
ファイル: List.php プロジェクト: Sywooch/forums
 public function renderJson()
 {
     $options = XenForo_Application::get('options');
     $formatter = XenForo_BbCode_Formatter_Base::create('Dark_TaigaChat_BbCode_Formatter_Tenori', array('view' => $this));
     switch ($options->dark_taigachat_bbcode) {
         case 'Full':
             $formatter->displayableTags = true;
             break;
         case 'Basic':
         default:
             $formatter->displayableTags = array('img', 'url', 'email', 'b', 'u', 'i', 's', 'color');
             break;
         case 'None':
             $formatter->displayableTags = array('url', 'email');
             break;
     }
     $formatter->getTagsAgain();
     $parser = new XenForo_BbCode_Parser($formatter);
     if ($options->dark_taigachat_imagemode == 'Link') {
         foreach ($this->_params['taigachat']['messages'] as &$message) {
             $message['message'] = str_ireplace(array("[img]", "[/img]"), array("[url]", "[/url]"), $message['message']);
         }
     }
     $maxid = $this->_params['taigachat']['lastrefresh'];
     foreach ($this->_params['taigachat']['messages'] as &$message) {
         if ($options->dark_taigachat_bbcode == 'Full') {
             $message['message'] = XenForo_Helper_String::autoLinkBbCode($message['message']);
         } else {
             // We don't want to parse youtube etc. urls if [media] is disabled
             $autoLinkParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Dark_TaigaChat_BbCode_Formatter_BbCode_AutoLink', false));
             $message['message'] = $autoLinkParser->render($message['message']);
         }
         if ($message['id'] > $maxid) {
             $maxid = $message['id'];
         }
     }
     XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages($this->_params['taigachat']['messages'], $parser);
     if ($options->dark_taigachat_direction) {
         $this->_params['taigachat']['messages'] = array_reverse($this->_params['taigachat']['messages']);
     }
     $template = $this->createTemplateObject($this->_templateName, $this->_params);
     $template->setParams($this->_params);
     $rendered = $template->render();
     $rendered = preg_replace('/\\s+<\\/(.*?)>\\s+</si', ' </$1> <', $rendered);
     $rendered = preg_replace('/\\s+<(.*?)([ >])/si', ' <$1$2', $rendered);
     //$rendered = str_replace(array("\r", "\n", "\t"), "", $rendered);
     $derp = XenForo_ViewRenderer_Json::jsonEncodeForOutput(array("templateHtml" => $rendered, "reverse" => $options->dark_taigachat_direction, "lastrefresh" => $maxid));
     $extraHeaders = XenForo_Application::gzipContentIfSupported($derp);
     foreach ($extraHeaders as $extraHeader) {
         header("{$extraHeader['0']}: {$extraHeader['1']}", $extraHeader[2]);
     }
     return $derp;
 }
コード例 #20
0
ファイル: Abstract.php プロジェクト: hahuunguyen/DTUI_201105
 /**
  * Prepares a news feed item for rendering.
  * Designed to be overriden by extended classes, while retaining the call to _prepareAlert.
  *
  * @param array $alert
  * @param array $viewingUser Information about the viewing user (keys: user_id, permission_combination_id, permissions)
  *
  * @return array
  */
 public function prepareAlert(array $item, array $viewingUser)
 {
     $methodName = '_prepare' . ucfirst($item['action']);
     $item = $this->_prepareAlertBeforeAction($item, $item['content'], $viewingUser);
     if (isset($item['content']['title'])) {
         $item['content']['title'] = XenForo_Helper_String::censorString($item['content']['title']);
     }
     if (method_exists($this, $methodName)) {
         $item = call_user_func(array($this, $methodName), $item, $viewingUser);
     }
     return $this->_prepareAlertAfterAction($item, $item['content'], $viewingUser);
 }
コード例 #21
0
ファイル: Abstract.php プロジェクト: namgiangle90/tokyobaito
 public final function prepareEntry(array $entry)
 {
     $entry['content_title'] = XenForo_Helper_String::censorString($entry['content_title']);
     $entry['ipAddress'] = $entry['ip_address'] ? XenForo_Helper_Ip::convertIpBinaryToString($entry['ip_address']) : '';
     $entry = $this->_prepareEntry($entry);
     if (!isset($entry['actionText'])) {
         $entry['actionText'] = new XenForo_Phrase('moderator_log_' . $entry['content_type'] . '_' . $entry['action'], json_decode($entry['action_params'], true));
     }
     if (!isset($entry['contentUser'])) {
         $entry['contentUser'] = array('user_id' => $entry['content_user_id'], 'username' => $entry['content_username']);
     }
     return $entry;
 }
コード例 #22
0
ファイル: Thread.php プロジェクト: Sywooch/forums
 public function actionAddReply()
 {
     $this->_assertPostOnly();
     $threadId = $this->_input->filterSingle('thread_id', XenForo_Input::UINT);
     $message = $this->getHelper('Editor')->getMessageText('message', $this->_input);
     $message = XenForo_Helper_String::autoLinkBbCode($message);
     //Get visitor id and check for duplicate post
     $visitorId = XenForo_Visitor::getUserId();
     $xenOptions = XenForo_Application::getOptions();
     $timeDiff = $xenOptions->sonnbPreventDoublePost_duration;
     $this->_assertIsDoublePost($message, $visitorId, $threadId, $timeDiff);
     return parent::actionAddReply();
 }
コード例 #23
0
 public static function processMessagesForView(&$params, &$view)
 {
     $options = XenForo_Application::get('options');
     $formatter = XenForo_BbCode_Formatter_Base::create('Dark_TaigaChat_BbCode_Formatter_Tenori', array('view' => $view));
     switch ($options->dark_taigachat_bbcode) {
         case 'Full':
             $formatter->displayableTags = true;
             break;
         case 'Basic':
         default:
             $formatter->displayableTags = array('img', 'url', 'email', 'b', 'u', 'i', 's', 'color');
             break;
         case 'None':
             $formatter->displayableTags = array('url', 'email');
             break;
     }
     $formatter->getTagsAgain();
     $parser = new XenForo_BbCode_Parser($formatter);
     if ($options->dark_taigachat_imagemode == 'Link') {
         foreach ($params['taigachat']['messages'] as &$message) {
             $message['message'] = str_ireplace(array("[img]", "[/img]"), array("[url]", "[/url]"), $message['message']);
         }
     }
     $maxUpdate = $params['taigachat']['lastrefresh'];
     foreach ($params['taigachat']['messages'] as &$message) {
         if ($options->dark_taigachat_bbcode == 'Full') {
             $message['message'] = XenForo_Helper_String::autoLinkBbCode($message['message']);
         } else {
             // We don't want to parse youtube etc. urls if [media] is disabled
             $autoLinkParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Dark_TaigaChat_BbCode_Formatter_BbCode_AutoLink', false));
             $message['message'] = $autoLinkParser->render($message['message']);
         }
         if ($message['last_update'] > $maxUpdate) {
             $maxUpdate = $message['last_update'];
         }
         if (substr($message['message'], 0, 3) == '/me') {
             $message['message'] = substr($message['message'], 4);
             $message['me'] = true;
         }
     }
     if ($options->dark_taigachat_smilies) {
         XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages($params['taigachat']['messages'], $parser);
     } else {
         XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages($params['taigachat']['messages'], $parser, array("states" => array("stopSmilies" => true)));
     }
     if ($options->dark_taigachat_direction) {
         $params['taigachat']['messages'] = array_reverse($params['taigachat']['messages']);
     }
     return max($maxUpdate, XenForo_Application::getSimpleCacheData('taigachat_lastUpdate'));
 }
コード例 #24
0
ファイル: Post.php プロジェクト: namgiangle90/tokyobaito
 /**
  * Approves the specified moderation queue entry.
  *
  * @see XenForo_ModerationQueueHandler_Abstract::approveModerationQueueEntry()
  */
 public function approveModerationQueueEntry($contentId, $message, $title)
 {
     $message = XenForo_Helper_String::autoLinkBbCode($message);
     $dw = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post', XenForo_DataWriter::ERROR_SILENT);
     $dw->setExistingData($contentId);
     $dw->set('message_state', 'visible');
     $dw->set('message', $message);
     if ($dw->save()) {
         XenForo_Model_Log::logModeratorAction('post', $dw->getMergedData(), 'approve');
         return true;
     } else {
         return false;
     }
 }
コード例 #25
0
 public function processTagImg(array $tag, array $rendererStates)
 {
     $url = $this->stringifyTree($tag['children']);
     $validUrl = $this->_getValidUrl($url);
     if (!$validUrl) {
         return $this->filterString($url, $rendererStates);
     }
     $censored = XenForo_Helper_String::censorString($validUrl);
     if ($censored != $validUrl) {
         return $this->filterString($url, $rendererStates);
     }
     $this->_urls[$url] = $validUrl;
     return '[IMG]' . $this->_urlPrefix . $url . $this->_urlSuffix . '[/IMG]';
 }
コード例 #26
0
 public function save()
 {
     $userId = $this->_options['conversation_send_by_user_id']['option_value'] != '' ? $this->_options['conversation_send_by_user_id']['option_value'] : XenForo_Visitor::getUserId();
     $recipientUserId = $this->_options['conversation_recipient_user_id']['option_value'];
     $recipientUserId = explode(',', $recipientUserId);
     // guests can't participate in conversations
     if (!$userId) {
         return false;
     }
     // users can't send themselves messages
     if ($userId == $recipientUserId) {
         return false;
     }
     $userModel = XenForo_Model::create('XenForo_Model_User');
     $user = $userModel->getUserById($userId);
     if ($this->_options['conversation_message_template']['option_value'] == '') {
         $message = '';
         foreach ($this->_templateFields as $field) {
             if ($this->_options['conversation_hide_empty_fields']['option_value'] == array() || $this->_options['conversation_hide_empty_fields']['option_value'] !== array() && $field['value'] != '') {
                 $message .= $field['title'] . ':' . PHP_EOL;
                 if ($field['field_type'] == 'wysiwyg') {
                     $message .= '[INDENT="1"]' . $field['value'] . '[/INDENT]' . PHP_EOL;
                 } else {
                     $message .= '[INDENT="1"][B]' . $field['value'] . '[/B][/INDENT]' . PHP_EOL;
                 }
             }
         }
     } else {
         $message = $this->_options['conversation_message_template']['option_value'];
     }
     $message = XenForo_Helper_String::autoLinkBbCode($message);
     $locked = $this->_options['conversation_locked']['option_value'] !== array() ? true : false;
     $conversationDw = XenForo_DataWriter::create('XenForo_DataWriter_ConversationMaster');
     $conversationDw->setExtraData(XenForo_DataWriter_ConversationMaster::DATA_ACTION_USER, $user);
     $conversationDw->setExtraData(XenForo_DataWriter_ConversationMaster::DATA_MESSAGE, $message);
     $conversationDw->set('user_id', $user['user_id']);
     $conversationDw->set('username', $user['username']);
     $conversationDw->set('title', $this->_options['conversation_title_template']['option_value']);
     $conversationDw->set('conversation_open', $locked ? 0 : 1);
     $conversationDw->addRecipientUserIds($recipientUserId);
     $messageDw = $conversationDw->getFirstMessageDw();
     $messageDw->set('message', $message);
     if ($this->_attachmentHash) {
         $messageDw->setExtraData(XenForo_DataWriter_ConversationMessage::DATA_ATTACHMENT_HASH, $this->_attachmentHash);
     }
     $conversationDw->preSave();
     $conversationDw->save();
     $conversation = $conversationDw->getMergedData();
     $this->_getConversationModel()->markConversationAsRead($conversation['conversation_id'], $user['user_id'], XenForo_Application::$time);
 }
コード例 #27
0
ファイル: Resource.php プロジェクト: darkearl/projectT122015
 /**
  * Gets the HTML value of the resource field.
  *
  * @param array $field
  * @param mixed $value Value of the field; if null, pulls from field_value
  *        in field
  */
 public static function getResourceFieldValueHtml(XenForo_View $view, array $field, $value = null)
 {
     if ($value === null && isset($field['field_value'])) {
         $value = $field['field_value'];
     }
     if ($value === '' || $value === null) {
         return '';
     }
     $multiChoice = false;
     $choice = '';
     switch ($field['field_type']) {
         case 'radio':
         case 'select':
             $choice = $value;
             $value = new XenForo_Phrase("resource_field_{$field['field_id']}_choice_{$value}");
             $value->setPhraseNameOnInvalid(false);
             break;
         case 'checkbox':
         case 'multiselect':
             $multiChoice = true;
             if (!is_array($value) || count($value) == 0) {
                 return '';
             }
             $newValues = array();
             foreach ($value as $id => $choice) {
                 $phrase = new XenForo_Phrase("resource_field_{$field['field_id']}_choice_{$choice}");
                 $phrase->setPhraseNameOnInvalid(false);
                 $newValues[$choice] = $phrase;
             }
             $value = $newValues;
             break;
         case 'textbox':
         case 'textarea':
         default:
             $value = nl2br(htmlspecialchars(XenForo_Helper_String::censorString($value)));
     }
     if (!empty($field['display_callback_class']) && !empty($field['display_callback_method'])) {
         $value = call_user_func_array(array($field['display_callback_class'], $field['display_callback_method']), array($view, $field, $value));
     } elseif (!empty($field['display_template'])) {
         if ($multiChoice && is_array($value)) {
             foreach ($value as $choice => &$thisValue) {
                 $thisValue = strtr($field['display_template'], array('{$fieldId}' => $field['field_id'], '{$value}' => $thisValue, '{$valueUrl}' => urlencode($thisValue), '{$choice}' => $choice));
             }
         } else {
             $value = strtr($field['display_template'], array('{$fieldId}' => $field['field_id'], '{$value}' => $value, '{$valueUrl}' => urlencode($value), '{$choice}' => $choice));
         }
     }
     return $value;
 }
コード例 #28
0
 /**
  * Approves the specified moderation queue entry.
  *
  * @see XenForo_ModerationQueueHandler_Abstract::approveModerationQueueEntry()
  */
 public function approveModerationQueueEntry($contentId, $message, $title)
 {
     $message = XenForo_Helper_String::autoLinkBbCode($message);
     $dw = XenForo_DataWriter::create('ThemeHouse_SocialGroups_DataWriter_SocialForum', XenForo_DataWriter::ERROR_SILENT);
     $dw->setExistingData($contentId);
     $dw->set('group_state', 'visible');
     $dw->set('title', $title);
     $dw->set('description', $message);
     if ($dw->save()) {
         XenForo_Model_Log::logModeratorAction('socialForum', $dw->getMergedData(), 'approve');
         return true;
     } else {
         return false;
     }
 }
コード例 #29
0
ファイル: Thread.php プロジェクト: Sywooch/forums
 public function bretiPrepareThread(array $thread, array $nodePermissions = null, array $viewingUser = null)
 {
     $forum = array('node_id' => $thread['node_id']);
     if (isset($thread['node_title'])) {
         $forum['title'] = $thread['node_title'];
         $thread['forum'] = $forum;
     }
     $thread['title'] = XenForo_Helper_String::censorString($thread['title']);
     $thread['titleCensored'] = true;
     $options = XenForo_Application::get('options');
     if ($options->BRETI_showPreview) {
         $thread['hasPreview'] = $this->hasPreview($thread, $forum, $nodePermissions, $viewingUser);
     }
     return $thread;
 }
コード例 #30
0
ファイル: Library.php プロジェクト: darkearl/projectT122015
 /**
  * Shows thumbs of images in the thread being created.
  *
  * @return XenForo_ControllerResponse_Abstract
  */
 public function actionCreateArticleThumbnails()
 {
     $this->_assertPostOnly();
     $forumId = $this->_input->filterSingle('node_id', XenForo_Input::UINT);
     $forumName = $this->_input->filterSingle('node_name', XenForo_Input::STRING);
     $ftpHelper = $this->getHelper('ForumThreadPost');
     $forum = $ftpHelper->assertForumValidAndViewable($forumId ? $forumId : $forumName);
     $forumId = $forum['node_id'];
     $this->_assertCanPostThreadInForum($forum);
     $message = $this->getHelper('Editor')->getMessageText('message', $this->_input);
     $message = XenForo_Helper_String::autoLinkBbCode($message);
     $thumbnailsModel = $this->_getThumbnailsModel();
     $thumbs = $thumbnailsModel->getImagesFromMessage($message);
     $viewParams = array('forum' => $forum, 'thumbs' => $thumbs);
     return $this->responseView('Waindigo_Thumbnails_ViewPublic_Thread_Thumbnails', 'waindigo_thread_create_thumbs_thumbnails', $viewParams);
 }