コード例 #1
0
ファイル: Error.php プロジェクト: darkearl/projectT122015
 public static function noControllerResponse(XenForo_RouteMatch $routeMatch, Zend_Controller_Request_Http $request)
 {
     self::sendErrorPageHeaders();
     if (XenForo_Application::debugMode()) {
         echo 'Failed to get controller response and reroute to error handler (' . $routeMatch->getControllerName() . '::action' . $routeMatch->getAction() . ')';
         if ($request->getParam('_exception')) {
             echo self::getExceptionTrace($request->getParam('_exception'));
         }
     } else {
         echo self::_getPhrasedTextIfPossible('An unexpected error occurred. Please try again later.', 'unexpected_error_occurred');
     }
 }
コード例 #2
0
ファイル: Template.php プロジェクト: Sywooch/forums
 protected function _dispatch(array $widget, $controllerName, $controllerAction)
 {
     if (empty(WidgetFramework_Listener::$fc)) {
         return null;
     }
     $routeMatch = new XenForo_RouteMatch($controllerName, $controllerAction);
     // do not use `html` response type to avoid being redirected by
     // XenForo_Controller::canonicalizeRequestUrl
     $routeMatch->setResponseType(get_class($this));
     try {
         $controllerResponse = WidgetFramework_Listener::$fc->dispatch($routeMatch);
         return $controllerResponse;
     } catch (Exception $e) {
         return null;
     }
 }
コード例 #3
0
 public static function frontControllerPreDispatch(XenForo_FrontController $fc, XenForo_RouteMatch &$routeMatch)
 {
     if (defined('DEVTOOLS_AUTOLOADER_SETUP') or self::$_checked or $routeMatch->getResponseType() != 'html') {
         return;
     }
     $paths = XenForo_Application::getInstance()->loadRequestPaths();
     $url = $paths['fullBasePath'] . 'filesync.php';
     if (class_exists('XenForo_Dependencies_Admin', false)) {
         $url .= '?admin=1';
     }
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     ob_start();
     curl_exec($ch);
     curl_close($ch);
     self::$_syncOutput = ob_get_contents();
     $logs = explode('<pre>', self::$_syncOutput);
     $errors = array();
     foreach ($logs as $log) {
         $lines = explode("\n", $log);
         foreach ($lines as $line) {
             if (strpos($line, 'E:') === 0) {
                 $origLine = str_replace('E: ', '', $line);
                 $line = '<strong>' . htmlspecialchars($origLine);
                 $pos = strpos($line, ':');
                 $line = substr($line, 0, $pos) . '</strong><i>' . substr($line, $pos);
                 $pos = strpos($line, ' in ' . DIRECTORY_SEPARATOR);
                 // hacked him!
                 $line = substr($line, 0, $pos) . '</i>' . substr($line, $pos);
                 $errors[] = $line;
                 DevTools_ChromePhp::error(trim($origLine));
             } else {
                 DevTools_ChromePhp::log(trim($line));
             }
         }
     }
     ob_end_clean();
     self::$_checked = true;
     self::$_errors = $errors;
 }
コード例 #4
0
 /**
  * Executes the controller dispatch loop.
  *
  * @param XenForo_RouteMatch $routeMatch
  *
  * @return XenForo_ControllerResponse_Abstract|null Null will only occur if error handling is broken
  */
 public function dispatch(XenForo_RouteMatch &$routeMatch)
 {
     $reroute = array('controllerName' => $routeMatch->getControllerName(), 'action' => $routeMatch->getAction());
     $allowReroute = true;
     do {
         if (isset($reroute['path'])) {
             $routeMatch = $this->route($reroute['path']);
             $reroute = array('controllerName' => $routeMatch->getControllerName(), 'action' => $routeMatch->getAction());
         }
         $controllerResponse = null;
         $controllerName = $reroute['controllerName'];
         $action = str_replace(array('-', '/'), ' ', strtolower($reroute['action']));
         $action = str_replace(' ', '', ucwords($action));
         if ($action === '') {
             $action = 'Index';
         }
         $reroute = false;
         $controller = $this->_getValidatedController($controllerName, $action, $routeMatch);
         if ($controller) {
             try {
                 try {
                     $controller->preDispatch($action, $controllerName);
                     $controllerResponse = $controller->{'action' . $action}();
                 } catch (XenForo_ControllerResponse_Exception $e) {
                     $controllerResponse = $e->getControllerResponse();
                 }
                 $controller->postDispatch($controllerResponse, $controllerName, $action);
                 $reroute = $this->_handleControllerResponse($controllerResponse, $controllerName, $action);
             } catch (Exception $e) {
                 // this is a bit hacky, but it's a selective catch so it's a strange case
                 if ($e instanceof XenForo_Exception && $e->isUserPrintable()) {
                     $controllerResponse = $this->_getErrorResponseFromException($e);
                     $controller->postDispatch($controllerResponse, $controllerName, $action);
                 } else {
                     if (!$allowReroute) {
                         break;
                     }
                     $reroute = $this->_rerouteServerError($e);
                     $allowReroute = false;
                     XenForo_Error::logException($e);
                 }
             }
             $responseType = $controller->getResponseType();
             $this->_dependencies->mergeViewStateChanges($controller->getViewStateChanges());
         } else {
             if (!$allowReroute) {
                 break;
             }
             $reroute = $this->_rerouteNotFound($controllerName, $action);
             $allowReroute = false;
         }
     } while ($reroute);
     if ($controllerResponse instanceof XenForo_ControllerResponse_Abstract) {
         $controllerResponse->controllerName = $controllerName;
         $controllerResponse->controllerAction = $action;
     }
     return $controllerResponse;
 }
コード例 #5
0
ファイル: Controller.php プロジェクト: Sywooch/forums
 /**
  * Gets the type of response that has been requested.
  *
  * @return string
  */
 public function getResponseType()
 {
     return $this->_routeMatch->getResponseType();
 }
コード例 #6
0
ファイル: ContentProtection.php プロジェクト: Sywooch/forums
 public static function controllerPreDispatch(XenForo_FrontController $fc, XenForo_RouteMatch &$routeMatch)
 {
     /* Listener - Execution order: #1 */
     self::$_responseType = $routeMatch->getResponseType();
 }
コード例 #7
0
ファイル: Publisher.php プロジェクト: Sywooch/forums
 /**
  * @return bdSocialShare_Shareable_Abstract
  */
 public function getShareableForRouteMatchAndRequest(XenForo_RouteMatch $routeMatch, Zend_Controller_Request_Http $request)
 {
     $shareable = null;
     switch ($routeMatch->getControllerName()) {
         case 'NFLJ_Showcase_ControllerPublic_Index':
         case 'NFLJ_Showcase_ControllerPublic_Showcase':
             $itemId = $request->getParam('item_id');
             if (!empty($itemId)) {
                 $shareable = bdSocialShare_Shareable_NFLJ_Showcase_Item::createFromId($itemId);
             }
             break;
         case 'sonnb_XenGallery_ControllerPublic_XenGallery_Photo':
             $contentId = $request->getParam('content_id');
             if (!empty($contentId)) {
                 $shareable = bdSocialShare_Shareable_sonnb_XenGallery_Photo::createFromId($contentId);
             }
             break;
         case 'sonnb_XenGallery_ControllerPublic_XenGallery_Video':
             $contentId = $request->getParam('content_id');
             if (!empty($contentId)) {
                 $shareable = bdSocialShare_Shareable_sonnb_XenGallery_Video::createFromId($contentId);
             }
             break;
         case 'XenForo_ControllerPublic_Post':
             $postId = $request->getParam('post_id');
             if (!empty($postId)) {
                 $shareable = bdSocialShare_Shareable_Post::createFromId($postId);
             }
             break;
         case 'XenForo_ControllerPublic_ProfilePost':
             $profilePostId = $request->getParam('profile_post_id');
             if (!empty($profilePostId)) {
                 $shareable = bdSocialShare_Shareable_ProfilePost::createFromId($profilePostId);
             }
             break;
         case 'XenForo_ControllerPublic_Thread':
             $threadId = $request->getParam('thread_id');
             if (!empty($threadId)) {
                 $thread = $this->getModelFromCache('XenForo_Model_Thread')->getThreadById($threadId);
                 if (!empty($thread)) {
                     $shareable = bdSocialShare_Shareable_Post::createFromId($thread['first_post_id']);
                 }
             }
             break;
         case 'XenGallery_ControllerPublic_Media':
             $mediaId = $request->getParam('media_id');
             if (!empty($mediaId)) {
                 $shareable = bdSocialShare_Shareable_XenGallery_Media::createFromId($mediaId);
             }
             break;
         case 'XenResource_ControllerPublic_Resource':
             $resourceId = $request->getParam('resource_id');
             if (!empty($resourceId)) {
                 $shareable = bdSocialShare_Shareable_XenResource_Resource::createFromId($resourceId);
             }
             break;
     }
     return $shareable;
 }
コード例 #8
0
ファイル: Tool.php プロジェクト: billyprice1/bdApi
 protected function _actionGetParseLink_getControllerResponse($link, Zend_Controller_Request_Http $request, XenForo_RouteMatch $routeMatch)
 {
     switch ($routeMatch->getControllerName()) {
         case 'XenForo_ControllerPublic_Forum':
             $nodeId = $request->getParam('node_id');
             if (empty($nodeId)) {
                 $nodeName = $request->getParam('node_name');
                 if (!empty($nodeName)) {
                     /* @var $nodeModel XenForo_Model_Node */
                     $nodeModel = $this->getModelFromCache('XenForo_Model_Node');
                     $node = $nodeModel->getNodeByName($nodeName, 'Forum');
                     if (!empty($node)) {
                         $nodeId = $node['node_id'];
                     }
                 }
             }
             if (!empty($nodeId)) {
                 $this->_request->setParam('forum_id', $nodeId);
             }
             return $this->responseReroute('bdApi_ControllerApi_Thread', 'get-index');
         case 'XenForo_ControllerPublic_Thread':
             $threadId = $request->getParam('thread_id');
             if (!empty($threadId)) {
                 $this->_request->setParam('thread_id', $threadId);
                 $linkFragment = parse_url($link, PHP_URL_FRAGMENT);
                 if (!empty($linkFragment) and preg_match('#^post-(?<post_id>\\d+)$#', $linkFragment, $fragment)) {
                     $this->_request->setParam('page_of_post_id', $fragment['post_id']);
                 }
                 return $this->responseReroute('bdApi_ControllerApi_Post', 'get-index');
             }
             break;
         case 'XenForo_ControllerPublic_Post':
             $postId = $request->getParam('post_id');
             if (!empty($postId)) {
                 $this->_request->setParam('page_of_post_id', $postId);
                 return $this->responseReroute('bdApi_ControllerApi_Post', 'get-index');
             }
             break;
     }
     return null;
 }