public static function keepWidgetChanges($widgetId, WidgetFramework_DataWriter_Widget $dw, array $newData)
 {
     if (!XenForo_Application::debugMode()) {
         return false;
     }
     foreach ($newData as $key => $value) {
         if ($key == 'options') {
             $existingOptions = $dw->getWidgetOptions(true);
             $options = $dw->getWidgetOptions();
             $optionKeys = array_unique(array_merge(array_keys($existingOptions), array_keys($options)));
             foreach ($optionKeys as $optionKey) {
                 $existingSerialized = null;
                 if (isset($existingOptions[$optionKey])) {
                     $existingSerialized = $existingOptions[$optionKey];
                 }
                 if (!is_string($existingSerialized)) {
                     $existingSerialized = serialize($existingSerialized);
                 }
                 $optionSerialized = null;
                 if (isset($options[$optionKey])) {
                     $optionSerialized = $options[$optionKey];
                 }
                 if (!is_string($optionSerialized)) {
                     $optionSerialized = serialize($optionSerialized);
                 }
                 if ($existingSerialized !== $optionSerialized) {
                     self::$_widgetChanges[$widgetId]['options'][$optionKey] = array($existingSerialized, $optionSerialized);
                 }
             }
         } else {
             self::$_widgetChanges[$widgetId][$key] = array($dw->getExisting($key), $value);
         }
     }
     return true;
 }
Beispiel #2
0
 public function actionApi()
 {
     $input = $this->_input->filter(array('redirect' => XenForo_Input::STRING, 'timestamp' => XenForo_Input::UINT, 'user_id' => XenForo_Input::STRING));
     $userId = 0;
     if (!empty($input['user_id']) && !empty($input['timestamp'])) {
         try {
             $userId = intval(bdApi_Crypt::decryptTypeOne($input['user_id'], $input['timestamp']));
         } catch (XenForo_Exception $e) {
             if (XenForo_Application::debugMode()) {
                 $this->_response->setHeader('X-Api-Exception', $e->getMessage());
             }
         }
     }
     if ($userId > 0) {
         $this->_response->setHeader('X-Api-Login-User', $userId);
         $this->_getUserModel()->setUserRememberCookie($userId);
         XenForo_Model_Ip::log($userId, 'user', $userId, 'login_api');
         $this->_getUserModel()->deleteSessionActivity(0, $this->_request->getClientIp(false));
         $session = XenForo_Application::get('session');
         $session->changeUserId($userId);
         XenForo_Visitor::setup($userId);
     }
     if (empty($input['redirect'])) {
         $input['redirect'] = $this->getDynamicRedirectIfNot(XenForo_Link::buildPublicLink('login'));
     }
     return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $input['redirect']);
 }
Beispiel #3
0
 public function actionErrorServer()
 {
     $upgradePending = false;
     try {
         $db = XenForo_Application::getDb();
         if ($db->isConnected()) {
             $dbVersionId = $db->fetchOne("SELECT option_value FROM xf_option WHERE option_id = 'currentVersionId'");
             if ($dbVersionId && $dbVersionId != XenForo_Application::$versionId) {
                 $upgradePending = true;
             }
         }
     } catch (Exception $e) {
     }
     if (XenForo_Application::debugMode()) {
         $showDetails = true;
     } else {
         if (XenForo_Visitor::hasInstance() && XenForo_Visitor::getInstance()->is_admin) {
             $showDetails = true;
         } else {
             $showDetails = false;
         }
     }
     if ($upgradePending && !$showDetails) {
         return $this->responseMessage(new XenForo_Phrase('board_currently_being_upgraded'));
     } else {
         if ($showDetails) {
             $view = $this->responseView('XenForo_ViewPublic_Error_ServerError', 'error_server_error', array('exception' => $this->_request->getParam('_exception')));
             $view->responseCode = 500;
             return $view;
         } else {
             return $this->responseError(new XenForo_Phrase('server_error_occurred'), 500);
         }
     }
 }
Beispiel #4
0
 /**
  * Adds system information into response data (both XML and JSON)
  *
  * @param array $data
  */
 public static function addDefaultResponse(array &$data)
 {
     if (XenForo_Application::debugMode()) {
         $data['debug'] = XenForo_Debug::getDebugTemplateParams();
         if (!empty($data['debug']['debug_url'])) {
             $data['debug']['debug_url'] = self::safeConvertApiUriToAbsoluteUri($data['debug']['debug_url'], true);
         }
         $session = self::safeGetSession();
         if (!empty($session)) {
             $clientId = $session->getOAuthClientId();
             if (!empty($clientId)) {
                 $data['debug']['client_id'] = $clientId;
                 $oauthToken = $session->getOAuthTokenText();
                 if (!empty($oauthToken)) {
                     $data['debug']['oauth_token'] = $oauthToken;
                 }
             }
             $languageId = $session->get('languageId');
             if (!empty($languageId)) {
                 $data['debug']['language_id'] = $languageId;
             }
         }
     }
     if (XenForo_Visitor::getUserId() > 0) {
         $data['system_info']['visitor_id'] = XenForo_Visitor::getUserId();
         $data['system_info']['time'] = XenForo_Application::$time;
     }
 }
Beispiel #5
0
 public function actionErrorNotFound()
 {
     $controllerName = $this->_request->getParam('_controllerName');
     $action = $this->_request->getParam('_action');
     if (substr($action, 0, 3) === 'Get') {
         // try to suggest POST entry point if available
         $newControllerName = XenForo_Application::resolveDynamicClass($controllerName, 'controller');
         if (method_exists($newControllerName, 'actionPost' . substr($action, 3))) {
             return $this->responseError(new XenForo_Phrase('bdapi_only_accepts_post_requests'), 400);
         }
     }
     if (is_callable(array($this, 'getNotFoundResponse'))) {
         // XenForo 1.2.0+ has this
         return $this->getNotFoundResponse();
     }
     if (XenForo_Application::debugMode()) {
         $controllerName = $this->_request->getParam('_controllerName');
         if (empty($controllerName)) {
             return $this->responseError(new XenForo_Phrase('controller_for_route_not_found', array('routePath' => $this->_request->getParam('_origRoutePath'))), 404);
         } else {
             return $this->responseError(new XenForo_Phrase('controller_x_does_not_define_action_y', array('controller' => $controllerName, 'action' => $this->_request->getParam('_action'))), 404);
         }
     } else {
         return $this->responseError(new XenForo_Phrase('requested_page_not_found'), 404);
     }
 }
Beispiel #6
0
 public static function get($key)
 {
     $options = XenForo_Application::get('options');
     static $keyPrefix = 'Tinhte_XenTag_';
     static $availableAutoTagModes = array(self::AUTO_TAG_MODE_THREAD_TAGS, self::AUTO_TAG_MODE_THREAD_TAGS_FIRST_POST_ONLY, self::AUTO_TAG_MODE_ALL_TAGS, self::AUTO_TAG_MODE_DISALBED);
     switch ($key) {
         case 'cloudLevelCount':
             return 3;
         case 'majorSection':
             return 'forums';
         case 'searchForceUseCache':
             return !XenForo_Application::debugMode();
         case 'autoTagMode':
             $mode = $options->get($keyPrefix . $key);
             if (!in_array($mode, $availableAutoTagModes)) {
                 $mode = self::AUTO_TAG_MODE_THREAD_TAGS_FIRST_POST_ONLY;
             }
             return $mode;
         case 'latestTaggedContentsLimit':
             return 10;
         case 'tagMinLength':
             return $options->get('tagLength', 'min');
     }
     return $options->get($keyPrefix . $key);
 }
 /**
  * Checks if the $post is the one specified in the $unreadLink. If the $unreadLink is
  * empty or there is no post id in the link, true will be return asap.
  * Please note that for the entire request, this method only return true once.
  *
  * Usage: {xen:helper wf_unreadLinkPost, $unreadLink, $post, $posts}
  * Recommended position: hook:message_below
  *
  * @param string $unreadLink
  * @param array $post
  * @param array $posts
  * @return bool
  */
 public function unreadLinkPost($unreadLink, $post, $posts)
 {
     static $found = false;
     static $postFragment = '#post-';
     if ($found) {
         // return true once
         return false;
     }
     if (!is_array($post) || !isset($post['post_id']) || !is_array($posts)) {
         // incorrect usage...
         if (XenForo_Application::debugMode()) {
             XenForo_Error::logError('{xen:helper wf_unreadLinkPost} requires (string $unreadLink),' . ' (array $post), (array $posts)');
         }
         $found = true;
     } else {
         $postPos = strpos($unreadLink, $postFragment);
         if ($postPos === false) {
             // wait for the last post and return true
             $postIds = array_keys($posts);
             $lastPostId = array_pop($postIds);
             $found = $lastPostId == $post['post_id'];
         } else {
             // return true for the specified unread post
             $unreadLinkPostId = substr($unreadLink, $postPos + strlen($postFragment));
             $found = $unreadLinkPostId == $post['post_id'];
         }
     }
     return $found;
 }
 public function run()
 {
     if ($this->_templateName == "PAGE_CONTAINER" && XenForo_Application::debugMode()) {
         $this->_debugMode();
     }
     return parent::run();
 }
 protected function _getModificationAddEditResponse(array $modification)
 {
     $addOnModel = $this->_getAddOnModel();
     $modification = $this->_adjustModificationForEdit($modification);
     $viewParams = array('modification' => $modification, 'addOnOptions' => XenForo_Application::debugMode() ? $addOnModel->getAddOnOptionsListIfAvailable() : array(), 'addOnSelected' => isset($modification['addon_id']) ? $modification['addon_id'] : $addOnModel->getDefaultAddOnId(), 'canEdit' => $this->_getModificationModel()->canEditModification($modification));
     return $this->responseView($this->_viewPrefix . 'Edit', $this->_templatePrefix . 'edit', $viewParams);
 }
Beispiel #10
0
 /**
  * Renders the container.
  * @see XenForo_ViewRenderer_Abstract::renderContainer()
  *
  * @param string
  * @param array
  *
  * @return string
  */
 public function renderContainer($contents, array $params = array(), array $newParams = array())
 {
     $params['contentTemplate'] = $this->_contentTemplate;
     $params['debugMode'] = XenForo_Application::debugMode();
     $params['serverTimeInfo'] = XenForo_Locale::getDayStartTimestamps();
     if (!empty($params['extraTabs'])) {
         foreach ($params['extraTabs'] as &$group) {
             foreach ($group as &$extraTab) {
                 if (!empty($extraTab['linksTemplate'])) {
                     $extraTab['linksTemplate'] = $this->createTemplateObject($extraTab['linksTemplate'], $extraTab);
                 }
             }
         }
     }
     $params = array_replace_recursive($params, $newParams);
     $templateName = !empty($params['containerTemplate']) ? $params['containerTemplate'] : 'PAGE_CONTAINER';
     $template = $this->createTemplateObject($templateName, $params);
     //if ($contents instanceof XenForo_Template_Abstract)
     //{
     //	$contents = $contents->render();
     //}
     $containerData = $this->_dependencies->getExtraContainerData();
     $template->setParams($containerData);
     $template->setParam('contents', $contents);
     $template->setParam('noH1', isset($containerData['h1']) && $containerData['h1'] === '');
     if ($params['debugMode']) {
         $template->setParams(XenForo_Debug::getDebugTemplateParams());
     }
     $rendered = $template->render();
     return $this->replaceRequiredExternalPlaceholders($template, $rendered);
 }
 public function renderCss()
 {
     // re-implement XenForo_CssOutput::renderCss() so we can change how caching works
     $cacheId = $this->getCacheId();
     if ($cacheObject = XenForo_Application::getCache()) {
         if ($cacheCss = $cacheObject->load($cacheId, true)) {
             return $cacheCss . "\n/* CSS returned from cache. */";
         }
     }
     $this->_prepareForOutput();
     if (XenForo_Application::isRegistered('bbCode')) {
         $bbCodeCache = XenForo_Application::get('bbCode');
     } else {
         $bbCodeCache = XenForo_Model::create('XenForo_Model_BbCode')->getBbCodeCache();
     }
     $params = array('displayStyles' => $this->_displayStyles, 'smilieSprites' => $this->_smilieSprites, 'customBbCodes' => !empty($bbCodeCache['bbCodes']) ? $bbCodeCache['bbCodes'] : array(), 'xenOptions' => XenForo_Application::get('options')->getOptions(), 'dir' => $this->_textDirection, 'pageIsRtl' => $this->_textDirection == 'RTL');
     $templates = array();
     foreach ($this->_cssRequested as $cssName) {
         $cssName = trim($cssName);
         if (!$cssName) {
             continue;
         }
         $templateName = $cssName . '.css';
         if (!isset($templates[$templateName])) {
             $templates[$templateName] = new XenForo_Template_Public($templateName, $params);
         }
     }
     $css = self::renderCssFromObjects($templates, XenForo_Application::debugMode());
     $css = self::prepareCssForOutput($css, $this->_textDirection, XenForo_Application::get('options')->minifyCss && $cacheObject);
     if ($cacheObject) {
         $cacheObject->save($css, $cacheId, array(), 86400);
     }
     return $css;
 }
 /**
  * Renders the container.
  * @see XenForo_ViewRenderer_Abstract::renderContainer()
  *
  * @param string
  * @param array
  *
  * @return string
  */
 public function renderContainer($contents, array $params = array())
 {
     $params['contentTemplate'] = $this->_contentTemplate;
     $params['debugMode'] = XenForo_Application::debugMode();
     $params['serverTimeInfo'] = XenForo_Locale::getDayStartTimestamps();
     if (!empty($params['extraTabs'])) {
         foreach ($params['extraTabs'] as &$group) {
             foreach ($group as &$extraTab) {
                 if (!empty($extraTab['linksTemplate'])) {
                     $extraTab['linksTemplate'] = $this->createTemplateObject($extraTab['linksTemplate'], $extraTab + $params);
                 }
             }
         }
     }
     $templateName = !empty($params['containerTemplate']) ? $params['containerTemplate'] : 'PAGE_CONTAINER';
     $template = $this->createTemplateObject($templateName, $params);
     if ($contents instanceof XenForo_Template_Abstract) {
         $contents = $contents->render();
     }
     $containerData = $this->_dependencies->getExtraContainerData();
     $containerData['notices'] = $this->_getNoticesContainerParams($template, $containerData);
     $template->setParams($containerData);
     $template->setParam('contents', $contents);
     $template->setParam('noH1', isset($containerData['h1']) && $containerData['h1'] === '');
     if ($params['debugMode']) {
         $template->setParams(XenForo_Debug::getDebugTemplateParams());
     }
     $rendered = $template->render();
     $rendered = $this->replaceRequiredExternalPlaceholders($template, $rendered);
     $language = XenForo_Visitor::getInstance()->getLanguage();
     if (isset($language['text_direction']) && $language['text_direction'] == 'RTL') {
         $rendered = XenForo_Template_Helper_RightToLeft::replaceRtlEntities($rendered);
     }
     return $rendered;
 }
 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 #14
0
 public static function get($key)
 {
     $options = XenForo_Application::get('options');
     static $keyPrefix = 'Tinhte_XenTag_';
     static $availablePositions = array('post_below', 'post_message_below', 'post_message_above', 'post_date_after', 'post_permalink_after', 'thread_pagenav_above', 'thread_messages_above', 'thread_qr_above', 'thread_qr_below');
     static $availableAutoTagModes = array(self::AUTO_TAG_MODE_THREAD_TAGS, self::AUTO_TAG_MODE_THREAD_TAGS_FIRST_POST_ONLY, self::AUTO_TAG_MODE_ALL_TAGS, self::AUTO_TAG_MODE_DISALBED);
     switch ($key) {
         case 'cloudLevelCount':
             return 3;
         case 'majorSection':
             return 'forums';
         case 'searchForceUseCache':
             return !XenForo_Application::debugMode();
         case 'displayPosition':
             $position = $options->get($keyPrefix . $key);
             if (!in_array($position, $availablePositions)) {
                 $position = $availablePositions[0];
             }
             return $position;
         case 'autoTagMode':
             $mode = $options->get($keyPrefix . $key);
             if (!in_array($mode, $availableAutoTagModes)) {
                 $mode = self::AUTO_TAG_MODE_THREAD_TAGS_FIRST_POST_ONLY;
             }
             return $mode;
         case 'latestTaggedContentsLimit':
             return 10;
     }
     return $options->get($keyPrefix . $key);
 }
Beispiel #15
0
 /**
  * Validates the callback request is valid. If failure happens, the response should
  * tell the processor to retry.
  *
  * @param string $errorString Output error string
  *
  * @return boolean
  */
 public function validateRequest(&$errorString)
 {
     try {
         if ($this->_filtered['test_ipn'] && XenForo_Application::debugMode()) {
             $validator = XenForo_Helper_Http::getClient('http://www.sandbox.paypal.com/cgi-bin/webscr');
         } else {
             $validator = XenForo_Helper_Http::getClient('http://www.paypal.com/cgi-bin/webscr');
         }
         $validator->setParameterPost('cmd', '_notify-validate');
         $validator->setParameterPost($_POST);
         $validatorResponse = $validator->request('POST');
         if (!$validatorResponse || $validatorResponse->getBody() != 'VERIFIED' || $validatorResponse->getStatus() != 200) {
             $errorString = 'Request not validated';
             return false;
         }
     } catch (Zend_Http_Client_Exception $e) {
         $errorString = 'Connection to PayPal failed';
         return false;
     }
     if (strtolower($this->_filtered['business']) != strtolower(XenForo_Application::get('options')->payPalPrimaryAccount)) {
         $errorString = 'Invalid business';
         return false;
     }
     return true;
 }
Beispiel #16
0
 public static function renderDevIconsOption(XenForo_View $view, $fieldPrefix, array $preparedOption, $canEdit)
 {
     if (!XenForo_Application::debugMode()) {
         return '';
     }
     $preparedOption['icons'] = array('add_ons_add' => new XenForo_Phrase('create_add_on'), 'code_events' => new XenForo_Phrase('code_events'), 'code_event_listeners' => new XenForo_Phrase('code_event_listeners'), 'admin_templates' => new XenForo_Phrase('admin_templates'), 'admin_style_properties' => new XenForo_Phrase('admin_style_properties'), 'admin_navigation' => new XenForo_Phrase('admin_navigation'), 'route_prefixes' => new XenForo_Phrase('route_prefixes'), 'email_templates' => new XenForo_Phrase('email_templates'));
     return self::renderOption($view, $fieldPrefix, $preparedOption, $canEdit);
 }
 /**
  * @param string $fieldId
  */
 protected function _userGroupsEdit($userGroupId, $title = '')
 {
     if (XenForo_Application::debugMode()) {
         $this->_assertResponseCode(200);
         $viewParams['userGroup'] = array('user_group_id' => $userGroupId, 'title' => $title);
         $this->_appendTemplateAfterTopCtrl('th_user_groups_topctrl_export_usergroups', $viewParams);
     }
 }
Beispiel #18
0
 public function actionIndex()
 {
     $response = parent::actionIndex();
     if ($response instanceof XenForo_ControllerResponse_View) {
         $response->params['canCreateModification'] = XenForo_Application::debugMode();
     }
     return $response;
 }
 public function search($searchText, array $phraseMatches = null)
 {
     if (!XenForo_Application::debugMode()) {
         return array();
     }
     /* @var $templateModel XenForo_Model_AdminTemplate */
     $templateModel = $this->getModelFromCache('XenForo_Model_AdminTemplate');
     return $templateModel->getAdminTemplatesForAdminQuickSearch($searchText);
 }
 protected function _removeUnlinkedEntries(array $navEntries)
 {
     foreach ($navEntries as $navId => $navEntry) {
         if ($navEntry['link'] == '' || $navEntry['debug_only'] && !XenForo_Application::debugMode()) {
             unset($navEntries[$navId]);
         }
     }
     return $navEntries;
 }
 /**
  * Fetches $styleId from cookie if it's available, or returns the default style ID.
  *
  * @return integer
  */
 protected function _getStyleIdFromCookie()
 {
     $styleId = XenForo_Helper_Cookie::getCookie('edit_style_id');
     if ($styleId === false) {
         $styleId = XenForo_Application::debugMode() ? 0 : XenForo_Application::get('options')->defaultStyleId;
     }
     if (!XenForo_Application::debugMode() && !$styleId) {
         $styleId = XenForo_Application::get('options')->defaultStyleId;
     }
     return $styleId;
 }
 public static function getVersionId($class, $path, $contents)
 {
     if (XenForo_Application::debugMode()) {
         return filemtime($path);
     }
     if (preg_match('#/\\*\\*.+?Class ' . preg_quote($class, '#') . '.+?@version (?<version>\\d+)\\s.+?\\*/#s', $contents, $matches)) {
         return intval($matches['version']);
     } else {
         return false;
     }
 }
 /**
  *
  * @param string $className Class to load
  * @param array $extraTabs
  * @param $selectedTabId
  *
  * @return array $extraTabs
  */
 public static function createAndRun($className, array &$extraTabs, $selectedTabId)
 {
     $createClass = self::create($className, $extraTabs, $selectedTabId);
     if (XenForo_Application::debugMode()) {
         return $createClass->run();
     }
     try {
         return $createClass->run();
     } catch (Exception $e) {
         return $this->_extraTabs;
     }
 }
Beispiel #24
0
 /**
  * Asserts that the installed version of the board matches the files.
  *
  * @param string $action
  */
 protected function _assertCorrectVersion($action)
 {
     if (XenForo_Application::debugMode()) {
         return;
     }
     if (!XenForo_Application::get('config')->checkVersion) {
         return;
     }
     if (XenForo_Application::$versionId != XenForo_Application::get('options')->currentVersionId) {
         $response = $this->responseMessage(new XenForo_Phrase('board_currently_being_upgraded'));
         throw $this->responseException($response, 503);
     }
 }
Beispiel #25
0
 public function actionErrorNotFound()
 {
     if (XenForo_Application::debugMode()) {
         $controllerName = $this->_request->getParam('_controllerName');
         if (empty($controllerName)) {
             return $this->responseError(new XenForo_Phrase('controller_for_route_not_found', array('routePath' => $this->_request->getParam('_origRoutePath'))), 404);
         } else {
             return $this->responseError(new XenForo_Phrase('controller_x_does_not_define_action_y', array('controller' => $controllerName, 'action' => $this->_request->getParam('_action'))), 404);
         }
     } else {
         return $this->responseError(new XenForo_Phrase('requested_page_not_found'), 404);
     }
 }
Beispiel #26
0
 public static function deleteAllCached()
 {
     foreach (self::$_cached as $url => $tempFile) {
         if (XenForo_Application::debugMode()) {
             $fileSize = @filesize($tempFile);
         }
         $deleted = @unlink($tempFile);
         if (XenForo_Application::debugMode()) {
             XenForo_Helper_File::log(__CLASS__, call_user_func_array('sprintf', array('delete %s -> %s, %s, %d bytes', $url, $tempFile, $deleted ? 'succeeded' : 'failed', !empty($fileSize) ? $fileSize : 0)));
         }
     }
     self::$_cached = array();
 }
Beispiel #27
0
 public function __construct(array $config = array(), Zend_Cache_Core $cache = null, Zend_Db_Adapter_Abstract $db = null)
 {
     $xenOptions = XenForo_Application::get('options');
     if ($xenOptions->th_onlineUsers_extendSessionExpiry) {
         if (!empty($config['admin'])) {
             $lifetime = XenForo_Application::debugMode() ? 86400 : 3600;
         } else {
             $lifetime = 3600;
         }
         $config['lifetime'] = max($lifetime, $xenOptions->onlineStatusTimeout);
     }
     parent::__construct($config, $cache, $db);
 }
Beispiel #28
0
 public function actionPostPasswordTest()
 {
     $input = $this->_input->filter(array('password' => XenForo_Input::STRING, 'password_algo' => XenForo_Input::STRING, 'decrypt' => XenForo_Input::UINT));
     if (!XenForo_Application::debugMode()) {
         return $this->responseNoPermission();
     }
     if (empty($input['decrypt'])) {
         $result = bdApi_Crypt::encrypt($input['password'], $input['password_algo']);
     } else {
         $result = bdApi_Crypt::decrypt($input['password'], $input['password_algo']);
     }
     $data = array('result' => $result);
     return $this->responseData('bdApi_ViewApi_Tool_PasswordTest', $data);
 }
Beispiel #29
0
 /**
  * Adds system information into response data (both XML and JSON)
  *
  * @param array $data
  */
 public static function addDefaultResponse(array &$data)
 {
     if (XenForo_Application::debugMode()) {
         $data['debug'] = XenForo_Debug::getDebugTemplateParams();
         $session = self::safeGetSession();
         if (!empty($session)) {
             $data['debug']['client_id'] = $session->getOAuthClientId();
             $data['debug']['oauth_token'] = $session->getOAuthTokenText();
         }
     }
     if (empty($data['system_info'])) {
         $data['system_info'] = array();
     }
     $data['system_info'] += array('visitor_id' => XenForo_Visitor::getUserId(), 'time' => XenForo_Application::$time);
 }
Beispiel #30
0
 public static function unexpectedException(Exception $e)
 {
     @header('Content-Type: text/html; charset=utf-8', true, 500);
     if (XenForo_Application::debugMode()) {
         echo self::getExceptionTrace($e);
     } else {
         if ($e instanceof Zend_Db_Exception) {
             $message = $e->getMessage();
             echo self::_getPhrasedTextIfPossible('An unexpected database error occurred. Please try again later.', 'unexpected_database_error_occurred');
             echo "\n<!-- " . htmlspecialchars($message) . " -->";
         } else {
             echo self::_getPhrasedTextIfPossible('An unexpected error occurred. Please try again later.', 'unexpected_error_occurred');
         }
     }
 }