Beispiel #1
0
 /**
  * Gets the default set of options for this data writer.
  *
  * @return array
  */
 protected function _getDefaultOptions()
 {
     $options = parent::_getDefaultOptions();
     $options[self::OPTION_MAX_MESSAGE_LENGTH] = XenForo_Application::getOptions()->Teams_commentLength;
     $options[self::OPTION_MAX_TAGGED_USERS] = 0;
     return $options;
 }
 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;
 }
Beispiel #3
0
 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()));
 }
Beispiel #4
0
 /**
  * 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);
     }
 }
Beispiel #5
0
 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));
     }
 }
Beispiel #6
0
 public static function template_hook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
 {
     switch ($hookName) {
         case 'attached_file_thumbnail':
             $xenOptions = XenForo_Application::getOptions();
             $cdnEnable = $xenOptions->Tinhte_AIO_CDNEnable;
             $cdnDomain = $xenOptions->Tinhte_AIO_CDNDomain;
             if (isset($hookParams['attachment']['thumbnailUrl'])) {
                 if ($cdnEnable) {
                     $hookParams['attachment_link'] = XenForo_Link::buildPublicLink('attachments', $hookParams['attachment']);
                     $hookParams['attachment_thumbnail'] = $hookParams['attachment']['thumbnailUrl'];
                     if (substr($hookParams['attachment_link'], 0, 7) != 'http://' && substr($hookParams['attachment_link'], 0, 8) != 'https://') {
                         $hookParams['attachment_link'] = self::_getValidUrl($cdnDomain) . $hookParams['attachment_link'];
                     }
                     if (substr($hookParams['attachment_thumbnail'], 0, 7) != 'http://' && substr($hookParams['attachment_thumbnail'], 0, 8) != 'https://') {
                         $hookParams['attachment_thumbnail'] = self::_getValidUrl($cdnDomain) . $hookParams['attachment_thumbnail'];
                     }
                     $hookParams['cdnDomain'] = self::_getValidUrl($cdnDomain);
                 } else {
                     $hookParams['attachment_link'] = XenForo_Link::buildPublicLink('full:attachments', $hookParams['attachment']);
                     $hookParams['attachment_thumbnail'] = $hookParams['attachment']['thumbnailUrl'];
                 }
                 $hookTemplate = $template->create('TinhTe_AIO_Attached', $hookParams);
                 $contents = $hookTemplate->render();
             }
             break;
     }
 }
Beispiel #7
0
 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: ");
         }
     }
 }
Beispiel #8
0
 public function applyCover($teamId, $fileName, $imageType = false, $width = false, $height = false, $existingCoverDate = 0)
 {
     if (!$imageType || !$width || !$height) {
         $imageInfo = @getimagesize($fileName);
         if (!$imageInfo) {
             throw new Nobita_Teams_Exception_Abstract('Non-image passed in to applyCover');
         }
         $width = $imageInfo[0];
         $height = $imageInfo[1];
         $imageType = $imageInfo[2];
     }
     if (!in_array($imageType, array(IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
         throw new Nobita_Teams_Exception_Abstract('Invalid image type passed in to applyCover');
     }
     if (!XenForo_Image_Abstract::canResize($width, $height)) {
         throw new Nobita_Teams_Exception_Abstract(new XenForo_Phrase('uploaded_image_is_too_big'), true);
     }
     $maxFileSize = XenForo_Application::getOptions()->Teams_coverFileSize;
     if ($maxFileSize && filesize($fileName) > $maxFileSize) {
         @unlink($fileName);
         throw new XenForo_Exception(new XenForo_Phrase('Teams_your_cover_file_size_large_smaller_x', array('size' => XenForo_Locale::numberFormat($maxFileSize, 'size'))), true);
     }
     if ($existingCoverDate) {
         $existedFile = $this->getCoverCropFilePath($teamId, $existingCoverDate);
         @unlink($existedFile);
     }
     $this->_witerCoverPhoto($teamId, $fileName);
     @unlink($fileName);
     $dwData = array('cover_date' => XenForo_Application::$time, 'cover_crop_details' => array('height' => $height, 'width' => $width));
     $dw = XenForo_DataWriter::create('Nobita_Teams_DataWriter_Team');
     $dw->setExistingData($teamId);
     $dw->bulkSet($dwData);
     $dw->save();
     return $dwData;
 }
Beispiel #9
0
 public function __construct($message, $userPrintable = false)
 {
     $routePrefix = XenForo_Application::getOptions()->Teams_routePrefix;
     switch ($routePrefix) {
         case 'teams':
             $prefix = '[Nobita] Social Teams';
             break;
         case 'groups':
             $prefix = '[Nobita] Social Groups';
             break;
         case 'guilds':
             $prefix = '[Nobita] Social Guilds';
             break;
         case 'clubs':
             $prefix = '[Nobita] Social Clubs';
             break;
         default:
             $prefix = '';
     }
     if (is_array($message) && count($message) > 0) {
         $message = reset($message);
     }
     $message = $prefix . ': ' . $message;
     parent::__construct($message, $userPrintable);
 }
Beispiel #10
0
 /**
  * Determines if the alert is viewable.
  * @see XenForo_AlertHandler_Abstract::canViewAlert()
  */
 public function canViewAlert(array $alert, $content, array $viewingUser)
 {
     if ($alert['action'] == 'trophy') {
         return XenForo_Application::getOptions()->enableTrophies;
     }
     return true;
 }
 static function getRegSpamScore(&$score, array $user, $verbose, $debug, $model)
 {
     $o = XenForo_Application::getOptions();
     if (trim($o->TPUDetectSpamRegEmail) != '') {
         $email = $user['email'];
         foreach (explode("\n", $o->TPUDetectSpamRegEmail) as $entry) {
             $entry = explode('|', trim($entry));
             if (count($entry) != 2) {
                 continue;
             }
             list($points, $match) = $entry;
             $regex = $model->buildWildcardRegex($match);
             if (preg_match('/^' . $regex . '$/iU', $email)) {
                 $model->logScore('tpu_detectspamreg_email_fail', $points, array('email' => $match));
                 if (is_numeric($points)) {
                     $score['points'] += $points;
                 } else {
                     $score[$points] = true;
                 }
             } else {
                 if ($debug) {
                     $model->logScore('tpu_detectspamreg_email_ok', 0, array('email' => $match));
                 }
             }
         }
     }
 }
Beispiel #12
0
 public static function get($key, $subKey = null)
 {
     $options = XenForo_Application::getOptions();
     switch ($key) {
         case '_is120+':
             return XenForo_Application::$versionId >= 1020000;
         case '_is130+':
             return XenForo_Application::$versionId >= 1030000;
         case '_activated':
             if (self::$_activated === null) {
                 $providers = self::getProviders();
                 self::$_activated = !empty($providers);
             }
             return self::$_activated;
         case '_showButtons':
             if (self::$_showButtons === null) {
                 self::$_showButtons = false;
                 if (!self::get('takeOver', 'login')) {
                     // no login take over, show the provider buttons
                     self::$_showButtons = true;
                 }
                 if (self::get('loginFacebook') or self::get('loginTwitter') or self::get('loginGoogle')) {
                     // show social buttons
                     self::$_showButtons = true;
                 }
             }
             return self::$_showButtons;
         case 'providers':
             if (self::$_providers === null) {
                 self::$_providers = $options->get('bdapi_consumer_providers');
             }
             return self::$_providers;
     }
     return $options->get('bdapi_consumer_' . $key, $subKey);
 }
 static function getRegSpamScore(&$score, array $user, $verbose, $debug, $model)
 {
     $o = XenForo_Application::getOptions();
     if (trim($o->TPUDetectSpamRegIPCountry) != '') {
         $ipCountry = self::getIPCountry($user['ip']);
         if ($verbose) {
             $model->logScore('tpu_detectspamreg_country_detected', 0, array('country' => $ipCountry));
         }
         foreach (explode("\n", $o->TPUDetectSpamRegIPCountry) as $entry) {
             $entry = explode('|', trim($entry));
             if (count($entry) != 2) {
                 continue;
             }
             list($points, $country) = $entry;
             if (strcasecmp($country, $ipCountry) == 0) {
                 $model->logScore('tpu_detectspamreg_country_fail', $points, array('country' => $country));
                 if (is_numeric($points)) {
                     $score['points'] += $points;
                 } else {
                     $score[$points] = true;
                 }
             } else {
                 if ($debug) {
                     $model->logScore('tpu_detectspamreg_country_ok', 0, array('country' => $country));
                 }
             }
         }
     }
 }
Beispiel #14
0
 protected function _render(array $widget, $positionCode, array $params, XenForo_Template_Abstract $renderTemplateObject)
 {
     if (!XenForo_Visitor::getInstance()->hasPermission('modm_ajaxchat', 'ajax_chat_view')) {
         return "";
     }
     /* @var $ajaxChatModel MODM_AJAXChat_Model_Chat */
     $ajaxChatModel = XenForo_Model::create("MODM_AJAXChat_Model_Chat");
     // Removes inactive users
     $ajaxChatModel->checkAndRemoveInactive();
     // Get online users for all accessible channels:
     $channels = $ajaxChatModel->getChannels();
     // Add the own private channel if allowed:
     if ($ajaxChatModel->isAllowedToCreatePrivateChannel()) {
         array_push($channels, $ajaxChat->getPrivateChannelID());
     }
     // Add the invitation channels:
     foreach ($ajaxChatModel->getInvitations() as $channelID) {
         if (!in_array($channelID, $channels)) {
             array_push($channels, $channelID);
         }
     }
     $userNames = $ajaxChatModel->getOnlineUsers($channels);
     /* @var $userModel XenForo_Model_User */
     $userModel = XenForo_Model::create("XenForo_Model_User");
     $guestUsers = array();
     $ajaxChat['onlineUsers'] = $userModel->getUsersByNames($userNames, array(), $guestUsers);
     $ajaxChat['members'] = count($ajaxChat['onlineUsers']);
     $ajaxChat['guests'] = XenForo_Application::getOptions()->get('modm_ajaxchat_options_allowguests') != "0" ? count($guestUsers) : null;
     $ajaxChat['total'] = $ajaxChat['members'] + $ajaxChat['guests'];
     $ajaxChat['limit'] = $ajaxChat['members'] < 10 ? $ajaxChat['members'] : 10;
     $ajaxChat['recordsUnseen'] = $ajaxChat['members'] > $ajaxChat['limit'] ? true : false;
     $renderTemplateObject->setParam('AjaxChat', $ajaxChat);
     return $renderTemplateObject->render();
 }
Beispiel #15
0
 public function actionPaymentwall()
 {
     $appKey = XenForo_Application::getOptions()->get('Paymentwall_appKey');
     if (empty($appKey)) {
         throw new XenForo_Exception('Project Key has not been configured');
     }
 }
Beispiel #16
0
 public function actionIndex()
 {
     $forumId = $this->_input->filterSingle('node_id', XenForo_Input::UINT);
     $forumName = $this->_input->filterSingle('node_name', XenForo_Input::STRING);
     if ($forumId || $forumName) {
         return $this->responseReroute(__CLASS__, 'forum');
     }
     if ($this->_routeMatch->getResponseType() == 'rss') {
         return $this->getGlobalForumRss();
     }
     $this->canonicalizeRequestUrl(XenForo_Link::buildPublicLink('forums'));
     $visitor = XenForo_Visitor::getInstance();
     $profilePostLimit = XenForo_Application::getOptions()->forumListNewProfilePosts;
     if ($profilePostLimit && $visitor->canViewProfilePosts()) {
         /** @var XenForo_Model_ProfilePost $profilePostModel */
         $profilePostModel = $this->getModelFromCache('XenForo_Model_ProfilePost');
         $profilePosts = $profilePostModel->getLatestProfilePosts(array('deleted' => false, 'moderated' => false), array('limit' => max($profilePostLimit * 2, 10), 'join' => XenForo_Model_ProfilePost::FETCH_USER_POSTER | XenForo_Model_ProfilePost::FETCH_USER_RECEIVER | XenForo_Model_ProfilePost::FETCH_USER_RECEIVER_PRIVACY, 'permissionCombinationId' => $visitor->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, $profilePostLimit, true);
     } else {
         $profilePosts = array();
     }
     $viewParams = array('nodeList' => $this->_getNodeModel()->getNodeDataForListDisplay(false, 0), 'onlineUsers' => $this->_getSessionActivityList(), 'boardTotals' => $this->_getBoardTotals(), 'canViewMemberList' => $this->getModelFromCache('XenForo_Model_User')->canViewMemberList(), 'profilePosts' => $profilePosts, 'canUpdateStatus' => XenForo_Visitor::getInstance()->canUpdateStatus());
     return $this->responseView('XenForo_ViewPublic_Forum_List', 'forum_list', $viewParams);
 }
 public function actionIndex()
 {
     if (!XenForo_Visitor::getInstance()->hasPermission('form', 'viewFormsList')) {
         throw $this->getErrorOrNoPermissionResponseException('do_not_have_permission');
     }
     $formModel = $this->_getFormModel();
     $page = $this->_input->filterSingle('page', XenForo_Input::UINT);
     $formsPerPage = XenForo_Application::get('options')->formsPerPage;
     $visitor = XenForo_Visitor::getInstance();
     $criteria = array('num_fields' => array(1, '>='), 'active' => 1, 'hide_from_list' => 0);
     $fetchOptions = array('perPage' => $formsPerPage, 'page' => $page, 'numResponses' => true, 'numUserResponses' => true, 'permissionCombinationId' => $visitor['permission_combination_id']);
     // sort by display order if custom
     if (XenForo_Application::getOptions()->lpsfSortOrder == 'custom') {
         $fetchOptions['order'] = 'display_order';
     }
     $forms = $formModel->getForms($criteria, $fetchOptions);
     foreach ($forms as $formId => &$form) {
         $form = $formModel->prepareForm($form);
         if (!$formModel->canRespondToForm($form, $errorPhraseKey)) {
             unset($forms[$formId]);
         }
     }
     $viewParams = array('forms' => $forms, 'visibleForms' => count($forms), 'formsPerPage' => $formsPerPage, 'page' => $page, 'totalForms' => $formModel->countForms($criteria));
     return $this->responseView('LiquidPro_SimpleForms_ViewPublic_Form_List', 'form_list', $viewParams);
 }
Beispiel #18
0
    /**
     * Get a list of all users watching a thread. Includes permissions for the forum the thread is in.
     *
     * Note that inactive users may be filtered out.
     *
     * @param integer $threadId
     * @param integer $nodeId Forum the thread is in.
     *
     * @return array Format: [user_id] => info
     */
    public function getUsersWatchingThread($threadId, $nodeId)
    {
        $autoReadDate = XenForo_Application::$time - XenForo_Application::get('options')->readMarkingDataLifetime * 86400;
        $activeLimitOption = XenForo_Application::getOptions()->watchAlertActiveOnly;
        if (!empty($activeLimitOption['enabled'])) {
            $activeLimit = ' AND user.last_activity >= ' . (XenForo_Application::$time - 86400 * $activeLimitOption['days']);
        } else {
            $activeLimit = '';
        }
        return $this->fetchAllKeyed('
			SELECT user.*,
				user_option.*,
				user_profile.*,
				thread_watch.email_subscribe,
				permission.cache_value AS node_permission_cache,
				GREATEST(COALESCE(thread_read.thread_read_date, 0), COALESCE(forum_read.forum_read_date, 0), ' . $autoReadDate . ') AS thread_read_date
			FROM xf_thread_watch AS thread_watch
			INNER JOIN xf_user AS user ON
				(user.user_id = thread_watch.user_id AND user.user_state = \'valid\' AND user.is_banned = 0' . $activeLimit . ')
			INNER JOIN xf_user_option AS user_option ON
				(user_option.user_id = user.user_id)
			INNER JOIN xf_user_profile AS user_profile ON
				(user_profile.user_id = user.user_id)
			LEFT JOIN xf_permission_cache_content AS permission
				ON (permission.permission_combination_id = user.permission_combination_id
					AND permission.content_type = \'node\'
					AND permission.content_id = ?)
			LEFT JOIN xf_thread_read AS thread_read
				ON (thread_read.thread_id = thread_watch.thread_id AND thread_read.user_id = user.user_id)
			LEFT JOIN xf_forum_read AS forum_read
				ON (forum_read.node_id = ? AND forum_read.user_id = user.user_id)
			WHERE thread_watch.thread_id = ?
		', 'user_id', array($nodeId, $nodeId, $threadId));
    }
Beispiel #19
0
 protected function _getMediaEditOrResponse(array $team, array $category)
 {
     $setup = Nobita_Teams_Setup::getInstance();
     $xenCatId = $setup->getOption('XenMediaCategoryId');
     $mediaCategoryModel = $this->getModelFromCache('XenGallery_Model_Category');
     $mediaModel = $this->getModelFromCache('XenGallery_Model_Media');
     $mediaCategory = $mediaCategoryModel->getCategoryById($xenCatId);
     if (!$mediaCategory) {
         throw $this->getNoPermissionResponseException();
     }
     $mediaCategory = $mediaCategoryModel->prepareCategory($mediaCategory);
     if (!$mediaCategoryModel->canAddMediaToCategory($mediaCategory, $error)) {
         throw $this->getErrorOrNoPermissionResponseException($error);
     }
     $container = $mediaCategory;
     $mediaSites = $this->getModelFromCache('XenForo_Model_BbCode')->getAllBbCodeMediaSites();
     $allowedSites = XenForo_Application::getOptions()->xengalleryMediaSites;
     foreach ($mediaSites as $key => $mediaSite) {
         if (!in_array($mediaSite['media_site_id'], $allowedSites)) {
             unset($mediaSites[$key]);
         }
     }
     $viewParams = array('team' => $team, 'category' => $category, 'container' => $container, 'mediaSites' => $mediaSites, 'imageUploadParams' => $mediaModel->getAttachmentParams($container), 'videoUploadParams' => $mediaModel->getAttachmentParams($container, 'video'), 'imageUploadConstraints' => $mediaModel->getUploadConstraints(), 'videoUploadConstraints' => $mediaModel->getUploadConstraints('video'), 'canUploadImage' => $container['canUploadImage'], 'canUploadVideo' => false, 'canEmbedVideo' => $container['canEmbedVideo'], 'mediaCategoryId' => $mediaCategory['category_id'], 'groupId' => $team['team_id']);
     return $this->_getTeamHelper()->getTeamViewWrapper('photos', $team, $category, $this->responseView('Nobita_Teams_ViewPublic_XenMedia_Add', 'Team_xenmedia_add', $viewParams));
 }
Beispiel #20
0
 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();
 }
 public static function install($existingAddOn, $addOnData)
 {
     $version = isset($existingAddOn['version_id']) ? $existingAddOn['version_id'] : 0;
     if ($version && $version < 1000300) {
         // migrate to remove the 'use' from the bad tag list
         $tags = XenForo_Application::getOptions()->SV_AttachImpro_badTags;
         $tags = explode(',', $tags);
         if (($key = array_search('use', $tags)) !== false) {
             unset($tags[$key]);
         }
         $dw = XenForo_DataWriter::create('XenForo_DataWriter_Option', XenForo_DataWriter::ERROR_SILENT);
         $dw->setExistingData('SV_AttachImpro_badTags');
         $dw->setOption(XenForo_DataWriter_Option::OPTION_REBUILD_CACHE, false);
         $dw->set('option_value', implode(',', $tags));
         $dw->save();
         XenForo_Application::defer(self::AddonNameSpace . 'Deferred_SVGAttachmentThumb', array());
     } else {
         if ($version == 0) {
             $addon = XenForo_Model::create('XenForo_Model_AddOn')->getAddOnById('SV_SVGAttachment');
             if (!empty($addon)) {
                 XenForo_Application::defer(self::AddonNameSpace . 'Deferred_SVGAttachmentThumb', array());
             }
         }
     }
     $addonsToUninstall = array('SV_SVGAttachment' => array(), 'SV_XARAttachment' => array());
     SV_Utils_Install::removeOldAddons($addonsToUninstall);
     return true;
 }
 public static function controllerPreDispatch(XenForo_Controller $controller, $action)
 {
     if ($controller instanceof XenForo_ControllerPublic_Abstract) {
         if (self::$_updatedMediaCounts === false) {
             self::$_updatedMediaCounts = true;
             $options = XenForo_Application::getOptions();
             $visitor = XenForo_Visitor::getInstance();
             if ($options->xengalleryUnviewedCounter['enabled'] && $visitor->xengallery_unviewed_media_count && XenForo_Application::isRegistered('session')) {
                 $time = XenForo_Application::$time;
                 $session = XenForo_Application::get('session');
                 $mediaUnviewed = $session->get('mediaUnviewed');
                 if ($mediaUnviewed === false || $mediaUnviewed['lastUpdateDate'] < $time - $options->xengalleryUnviewedCounter['length'] * 60) {
                     /** @var $mediaModel XenGallery_Model_Media */
                     $mediaModel = XenForo_Model::create('XenGallery_Model_Media');
                     $unviewedIds = $mediaModel->getUnviewedMediaIds($visitor->user_id, array('viewCategoryIds' => $mediaModel->getViewableCategoriesForVisitor($visitor->toArray()), 'viewAlbums' => XenForo_Permission::hasPermission($visitor->permissions, 'xengallery', 'viewAlbums')));
                     if ($unviewedIds !== false) {
                         if (sizeof($unviewedIds)) {
                             $mediaUnviewed = array('unviewed' => array_combine($unviewedIds, $unviewedIds), 'lastUpdateDate' => $time);
                         } else {
                             $mediaUnviewed = self::_getDefaultUnviewedArray();
                         }
                     }
                 } elseif (!$visitor->user_id) {
                     $mediaUnviewed = self::_getDefaultUnviewedArray();
                 }
                 $session->set('mediaUnviewed', $mediaUnviewed);
             }
         }
     }
 }
Beispiel #23
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);
 }
Beispiel #24
0
 public function getPermissionsFromContext(array $context, array $parentContext = null)
 {
     // Context could be some previously fetched permissions, media, album or category...
     if (isset($context['tagger_permissions'])) {
         return $context['tagger_permissions'];
     } else {
         if (isset($context['media_id'])) {
             $media = $context;
             $container = $parentContext;
         } else {
             $media = null;
             $container = $context;
         }
     }
     if (!$container || empty($container['album_id']) && empty($container['category_id'])) {
         throw new Exception("Context must be a media item and an album/category or just an album/category");
     }
     $visitor = XenForo_Visitor::getInstance();
     if ($media) {
         if ($media['user_id'] == $visitor['user_id'] && XenForo_Permission::hasPermission($visitor['permissions'], 'xengallery', 'manageOthersTagsOwnMedia')) {
             $removeOthers = true;
         } else {
             $removeOthers = XenForo_Permission::hasPermission($visitor['permissions'], 'xengallery', 'manageAnyTag');
         }
     } else {
         $removeOthers = false;
     }
     return array('edit' => $this->_getMediaModel()->canEditTags($media), 'removeOthers' => $removeOthers, 'minTotal' => isset($container['min_tags']) ? $container['min_tags'] : XenForo_Application::getOptions()->xengalleryAlbumMinTags);
 }
 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);
 }
Beispiel #26
0
 public function renderJson()
 {
     $output = array();
     $bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this)));
     $bbCodeOptions = array('states' => array('viewAttachments' => $this->_params['canViewAttachments']));
     XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages($this->_params['posts'], $bbCodeParser, $bbCodeOptions);
     $viewParams = $this->_params;
     unset($viewParams['posts']);
     foreach ($this->_params['posts'] as &$post) {
         $viewParams['post'] = $post;
         $template = $this->createTemplateObject('post', $viewParams);
         $output['posts'][] = $template->render();
     }
     if (XenForo_Application::getOptions()->sonnb_LiveThread_reserveOrder) {
         $lastPost = reset($this->_params['posts']);
     } else {
         $lastPost = end($this->_params['posts']);
     }
     $template = $this->createTemplateObject('', $viewParams);
     $viewOutput = $template->render();
     $output['css'] = $template->getRequiredExternals('css');
     $output['js'] = $template->getRequiredExternals('js');
     $output['lastDate'] = $lastPost['post_date'];
     $output['reserveOrder'] = isset($viewParams['reserveOrder']) ? $viewParams['reserveOrder'] : false;
     return XenForo_ViewRenderer_Json::jsonEncodeForOutput($output);
 }
Beispiel #27
0
 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) {
                 }
             }
         }
     }
 }
 protected function _navigationVisitorTabsEnd()
 {
     $position = XenForo_Application::getOptions()->th_langChooserPos_position;
     if ($position == 'top_right') {
         $this->_prependTemplate('th_top_right_langchooserpos');
     }
 }
Beispiel #29
0
    /**
     * Get a list of all users watching a resource.
     *
     * @param integer $resourceId
     * @param integer $categoryId
     *
     * @return array Format: [user_id] => info
     */
    public function getUsersWatchingResource($resourceId, $categoryId)
    {
        $activeLimitOption = XenForo_Application::getOptions()->watchAlertActiveOnly;
        if ($activeLimitOption && !empty($activeLimitOption['enabled'])) {
            $activeLimit = ' AND user.last_activity >= ' . (XenForo_Application::$time - 86400 * $activeLimitOption['days']);
        } else {
            $activeLimit = '';
        }
        return $this->fetchAllKeyed('
			SELECT user.*,
				user_option.*,
				user_profile.*,
				permission_combination.cache_value AS global_permission_cache,
				permission_cache_content.cache_value AS category_permission_cache,
				resource_watch.email_subscribe
			FROM xf_resource_watch AS resource_watch
			INNER JOIN xf_user AS user ON
				(user.user_id = resource_watch.user_id AND user.user_state = \'valid\' AND user.is_banned = 0' . $activeLimit . ')
			INNER JOIN xf_user_option AS user_option ON
				(user_option.user_id = user.user_id)
			INNER JOIN xf_user_profile AS user_profile ON
				(user_profile.user_id = user.user_id)
			INNER JOIN xf_permission_combination AS permission_combination ON
				(permission_combination.permission_combination_id = user.permission_combination_id)
			INNER JOIN xf_permission_cache_content AS permission_cache_content ON
				(permission_cache_content.permission_combination_id = user.permission_combination_id
					AND permission_cache_content.content_type = \'resource_category\'
					AND permission_cache_content.content_id = ?)
			WHERE resource_watch.resource_id = ?
		', 'user_id', array($categoryId, $resourceId));
    }
Beispiel #30
0
 public function actionIndex()
 {
     $options = GFNLinkProxy_Options::getInstance();
     if ($referer = $this->_request->getHeader('referer')) {
         if ($options->get('blockInvalidReferrer')) {
             if ($host = parse_url($referer, PHP_URL_HOST)) {
                 if (!in_array($host, array($this->_request->getServer('SERVER_NAME'), parse_url(XenForo_Application::getOptions()->get('boardUrl'), PHP_URL_HOST)))) {
                     return $this->responseNoPermission();
                 }
             }
         }
     }
     $url = base64_decode($this->_input->filterSingle('to', XenForo_Input::STRING));
     if (!$url) {
         return $this->responseNoPermission();
     }
     if (!parse_url($url)) {
         return $this->responseNoPermission();
     }
     if ($options->get('enableAutoRedirect')) {
         if ($options->get('autoRedirectDelay') == 0) {
             return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL, $url);
         }
         $title = $options->get('autoRedirectTitle');
         $message = $this->_parseMessage($options->get('autoRedirectMessage'), array('board' => XenForo_Application::getOptions()->get('boardTitle'), 'boardUrl' => XenForo_Application::getOptions()->get('boardUrl'), 'url' => $url, 'delay' => '<span class="delay">' . $options->get('autoRedirectDelay') . '</span>'));
     } else {
         $title = $options->get('title');
         $message = $this->_parseMessage($options->get('message'), array('board' => XenForo_Application::getOptions()->get('boardTitle'), 'boardUrl' => XenForo_Application::getOptions()->get('boardUrl'), 'url' => $url));
     }
     $viewParams = array('url' => $url, 'referer' => $referer ? $referer : XenForo_Application::getOptions()->get('boardUrl'), 'title' => $title, 'message' => $message, 'autoRedirect' => $options->get('enableAutoRedirect'), 'delay' => $options->get('autoRedirectDelay'));
     return $this->responseView('GFNLinkProxy_ViewPublic_Redirect', 'gfnlinkproxy_redirect', $viewParams);
 }