当前位置: 首页>>代码示例>>PHP>>正文


PHP XenForo_Visitor::hasInstance方法代码示例

本文整理汇总了PHP中XenForo_Visitor::hasInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Visitor::hasInstance方法的具体用法?PHP XenForo_Visitor::hasInstance怎么用?PHP XenForo_Visitor::hasInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XenForo_Visitor的用法示例。


在下文中一共展示了XenForo_Visitor::hasInstance方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionErrorServer

 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);
         }
     }
 }
开发者ID:Sywooch,项目名称:forums,代码行数:34,代码来源:Error.php

示例2: __construct

 public function __construct($options = array())
 {
     self::configure($this, $options);
     $class = XenForo_Application::resolveDynamicClass('XenForo_BbCode_Formatter_Base', 'bb_code');
     $this->_otherFormatters = new $class();
     self::configure($this->_otherFormatters, $options);
     $this->_tags = $this->getTags();
     $this->preLoadData();
     if (XenForo_Visitor::hasInstance()) {
         $visitor = XenForo_Visitor::getInstance();
         if (!empty($visitor['ignoredUsers'])) {
             $this->_ignoredUsers = $visitor['ignoredUsers'];
         }
         $language = $visitor->getLanguage();
         $this->_textDirection = $language['text_direction'];
     }
 }
开发者ID:Sywooch,项目名称:forums,代码行数:17,代码来源:Ritsu.php

示例3: actionErrorServer

 public function actionErrorServer()
 {
     if (XenForo_Application::debugMode()) {
         $showDetails = true;
     } else {
         if (XenForo_Visitor::hasInstance() && XenForo_Visitor::getInstance()->is_admin) {
             $showDetails = true;
         } else {
             $showDetails = false;
         }
     }
     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);
     }
 }
开发者ID:hahuunguyen,项目名称:DTUI_201105,代码行数:19,代码来源:Error.php

示例4: unexpectedException

 public static function unexpectedException(Exception $e)
 {
     @header('Content-Type: text/html; charset=utf-8', true, 500);
     $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()) {
         $showTrace = true;
     } else {
         if (XenForo_Visitor::hasInstance()) {
             $showTrace = XenForo_Visitor::getInstance()->is_admin;
         } else {
             $showTrace = false;
         }
     }
     if ($upgradePending) {
         echo self::_getPhrasedTextIfPossible('The board is currently being upgraded. Please check back later.', 'board_currently_being_upgraded');
     } else {
         if (!empty($showTrace)) {
             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');
             }
         }
     }
 }
开发者ID:robclancy,项目名称:XenForo-Developer-Tools,代码行数:39,代码来源:Error.php

示例5: logException

 public static function logException(Exception $e, $rollbackTransactions = true)
 {
     try {
         $db = XenForo_Application::get('db');
         if ($db->getConnection()) {
             $rootDir = XenForo_Application::getInstance()->getRootDir();
             $file = $e->getFile();
             if (strpos($file, $rootDir) === 0) {
                 $file = substr($file, strlen($rootDir));
                 if (strlen($file) && ($file[0] == '/' || $file[0] == '\\')) {
                     $file = substr($file, 1);
                 }
             }
             $requestPaths = XenForo_Application::get('requestPaths');
             $request = array('url' => $requestPaths['fullUri'], '_GET' => $_GET, '_POST' => $_POST);
             if ($rollbackTransactions) {
                 XenForo_Db::rollbackAll($db);
             }
             $db->insert('xf_error_log', array('exception_date' => XenForo_Application::$time, 'user_id' => XenForo_Visitor::hasInstance() ? XenForo_Visitor::getUserId() : null, 'ip_address' => XenForo_Model::create('XenForo_Model_Login')->convertIpToLong(), 'exception_type' => get_class($e), 'message' => $e->getMessage(), 'filename' => $file, 'line' => $e->getLine(), 'trace_string' => $e->getTraceAsString(), 'request_state' => serialize($request)));
         }
     } catch (Exception $e) {
     }
 }
开发者ID:hahuunguyen,项目名称:DTUI_201105,代码行数:23,代码来源:Error.php

示例6: logException

 public static function logException($e, $rollbackTransactions = true, $messagePrefix = '')
 {
     $isValidArg = $e instanceof Exception || $e instanceof Throwable;
     if (!$isValidArg) {
         throw new Exception("logException requires an Exception or a Throwable");
     }
     try {
         $db = XenForo_Application::getDb();
         if ($db->getConnection()) {
             if ($rollbackTransactions) {
                 @XenForo_Db::rollbackAll($db);
             }
             $dbVersionId = @$db->fetchOne("SELECT option_value FROM xf_option WHERE option_id = 'currentVersionId'");
             if ($dbVersionId && $dbVersionId != XenForo_Application::$versionId) {
                 // do not log errors when an upgrade is pending
                 return;
             }
             if (!file_exists(XenForo_Helper_File::getInternalDataPath() . '/install-lock.php')) {
                 // install hasn't finished yet, don't write
                 return;
             }
             $rootDir = XenForo_Application::getInstance()->getRootDir();
             $file = $e->getFile();
             if (strpos($file, $rootDir) === 0) {
                 $file = substr($file, strlen($rootDir));
                 if (strlen($file) && ($file[0] == '/' || $file[0] == '\\')) {
                     $file = substr($file, 1);
                 }
             }
             $requestPaths = XenForo_Application::get('requestPaths');
             $request = array('url' => $requestPaths['fullUri'], '_GET' => $_GET, '_POST' => $_POST);
             // don't log passwords
             foreach ($request['_POST'] as $key => &$value) {
                 if (strpos($key, 'password') !== false || $key == '_xfToken') {
                     $value = '********';
                 }
             }
             $db->insert('xf_error_log', array('exception_date' => XenForo_Application::$time, 'user_id' => XenForo_Visitor::hasInstance() ? XenForo_Visitor::getUserId() : null, 'ip_address' => XenForo_Helper_Ip::getBinaryIp(), 'exception_type' => get_class($e), 'message' => $messagePrefix . $e->getMessage(), 'filename' => $file, 'line' => $e->getLine(), 'trace_string' => $e->getTraceAsString(), 'request_state' => serialize($request)));
         }
     } catch (Exception $e) {
     }
 }
开发者ID:darkearl,项目名称:projectT122015,代码行数:42,代码来源:Error.php

示例7: __construct

 /**
  * Constructor.
  */
 public function __construct()
 {
     $this->_tags = $this->getTags();
     $this->preLoadData();
     if (XenForo_Visitor::hasInstance()) {
         $visitor = XenForo_Visitor::getInstance();
         if (!empty($visitor['ignoredUsers'])) {
             $this->_ignoredUsers = $visitor['ignoredUsers'];
         }
         $language = $visitor->getLanguage();
         $this->_textDirection = $language['text_direction'];
     }
 }
开发者ID:darkearl,项目名称:projectT122015,代码行数:16,代码来源:Base.php

示例8: prepareUser

 /**
  * Prepares a user record for display. Note that this may be called on incomplete guest records.
  *
  * @param array $user User info
  *
  * @return array Prepared user info
  */
 public function prepareUser(array $user)
 {
     if (empty($user['user_group_id'])) {
         $user['display_style_group_id'] = self::$defaultGuestGroupId;
     }
     $user['customFields'] = !empty($user['custom_fields']) ? @unserialize($user['custom_fields']) : array();
     $user['externalAuth'] = !empty($user['external_auth']) ? @unserialize($user['external_auth']) : array();
     // "trusted" user check - used to determine if no follow is enabled
     $user['isTrusted'] = !empty($user['user_id']) && (!empty($user['is_admin']) || !empty($user['is_moderator']));
     if (XenForo_Visitor::hasInstance()) {
         $user['isIgnored'] = XenForo_Visitor::getInstance()->isIgnoring($user['user_id']);
     }
     return $user;
 }
开发者ID:darkearl,项目名称:projectT122015,代码行数:21,代码来源:User.php

示例9: preRenderView

 /**
  * Performs any pre-view rendering setup, such as getting style information and
  * ensuring the correct data is registered.
  *
  * @param XenForo_ControllerResponse_Abstract|null $controllerResponse
  */
 public function preRenderView(XenForo_ControllerResponse_Abstract $controllerResponse = null)
 {
     // note this intentionally doesn't call the abstract version
     if (XenForo_Application::isRegistered('session')) {
         $this->_defaultTemplateParams['session'] = XenForo_Application::get('session')->getAll();
     }
     if (XenForo_Visitor::hasInstance()) {
         $this->_defaultTemplateParams['visitor'] = XenForo_Visitor::getInstance()->toArray();
     }
     $this->_defaultTemplateParams['requestPaths'] = XenForo_Application::get('requestPaths');
 }
开发者ID:Sywooch,项目名称:forums,代码行数:17,代码来源:Install.php

示例10: _doClean

 protected static function _doClean($filterName, array $filterOptions, $data, $defaultData)
 {
     switch ($filterName) {
         case self::STRING:
             $data = is_scalar($data) ? strval($data) : $defaultData;
             if (strlen($data) && !preg_match('/./u', $data)) {
                 $data = $defaultData;
             }
             $data = self::cleanString($data);
             if (empty($filterOptions['noTrim'])) {
                 $data = trim($data);
             }
             break;
         case self::NUM:
             $data = strval($data) + 0;
             break;
         case self::UNUM:
             $data = strval($data) + 0;
             $data = $data < 0 ? $defaultData : $data;
             break;
         case self::INT:
             $data = intval($data);
             break;
         case self::UINT:
             $data = ($data = intval($data)) < 0 ? $defaultData : $data;
             break;
         case self::FLOAT:
             $data = floatval($data);
             break;
         case self::BOOLEAN:
             if ($data === 'n' || $data === 'no' || $data === 'N') {
                 $data = false;
             } else {
                 $data = (bool) $data;
             }
             break;
         case self::BINARY:
             $data = strval($data);
             break;
         case self::ARRAY_SIMPLE:
             if (!is_array($data)) {
                 $data = $defaultData;
             }
             $data = self::cleanStringArray($data);
             break;
         case self::JSON_ARRAY:
             if (is_string($data)) {
                 $data = json_decode($data, true);
             }
             if (!is_array($data)) {
                 $data = $defaultData;
             }
             $data = self::cleanStringArray($data);
             break;
         case self::DATE_TIME:
             if (!$data) {
                 $data = 0;
             } else {
                 if (is_string($data)) {
                     $data = trim($data);
                     if ($data === strval(intval($data))) {
                         // data looks like an int, treat as timestamp
                         $data = intval($data);
                     } else {
                         if (isset($filterOptions['timeZone'])) {
                             $tz = $filterOptions['timeZone'];
                         } else {
                             $tz = XenForo_Visitor::hasInstance() ? XenForo_Locale::getDefaultTimeZone() : null;
                         }
                         try {
                             $date = new DateTime($data, $tz);
                             if (!empty($filterOptions['dayEnd'])) {
                                 $date->setTime(23, 59, 59);
                             }
                             $data = $date->format('U');
                         } catch (Exception $e) {
                             $data = 0;
                         }
                     }
                 }
             }
             if (!is_int($data)) {
                 $data = intval($data);
             }
             break;
         default:
             if ($filterName instanceof Zend_Validate_Interface) {
                 if ($filterName->isValid($data) === false) {
                     $data = $defaultData;
                 }
             } else {
                 throw new XenForo_Exception("Unknown input type in " . __CLASS__ . "::" . __METHOD__);
             }
     }
     return $data;
 }
开发者ID:darkearl,项目名称:projectT122015,代码行数:96,代码来源:Input.php

示例11: _getStyleLanguageChangerParams

 protected function _getStyleLanguageChangerParams(Zend_Controller_Request_Http $request)
 {
     $params = array();
     $canChangeStyleLanguage = $request->isGet() && empty($this->_viewStateChanges['styleId']);
     if ($request->isGet()) {
         if (!empty($this->_viewStateChanges['styleId'])) {
             $params['canChangeStyle'] = false;
         } else {
             $styles = XenForo_Application::isRegistered('styles') ? XenForo_Application::get('styles') : array();
             if (count($styles) <= 1) {
                 $params['canChangeStyle'] = false;
             } else {
                 if (XenForo_Visitor::hasInstance() && XenForo_Visitor::getInstance()->is_admin) {
                     $params['canChangeStyle'] = count($styles) > 1;
                 } else {
                     $changable = 0;
                     $params['canChangeStyle'] = false;
                     foreach ($styles as $style) {
                         if ($style['user_selectable']) {
                             $changable++;
                             if ($changable > 1) {
                                 $params['canChangeStyle'] = true;
                                 break;
                             }
                         }
                     }
                 }
             }
         }
         $languages = XenForo_Application::isRegistered('languages') ? XenForo_Application::get('languages') : array();
         $params['canChangeLanguage'] = count($languages) > 1;
     } else {
         $params['canChangeStyle'] = false;
         $params['canChangeLanguage'] = false;
     }
     return $params;
 }
开发者ID:darkearl,项目名称:projectT122015,代码行数:37,代码来源:Public.php


注:本文中的XenForo_Visitor::hasInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。