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


PHP JError::customErrorPage方法代码示例

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


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

示例1: handleError

 static function handleError(&$error)
 {
     // Get the application object.
     $app = JFactory::getApplication();
     // Make sure the error is a 404 and we are not in the administrator.
     if (!$app->isAdmin() and $error->getCode() == 404) {
         // Get the full current URI.
         $uri = JURI::getInstance();
         $current = $uri->toString(array('scheme', 'host', 'port', 'path', 'query', 'fragment'));
         // Attempt to ignore idiots.
         if (strpos($current, 'mosConfig_') !== false || strpos($current, '=http://') !== false) {
             // Render the error page.
             JError::customErrorPage($error);
         }
         // See if the current url exists in the database as a redirect.
         $db = JFactory::getDBO();
         $db->setQuery('SELECT `new_url`, `published`' . ' FROM `#__redirect_links`' . ' WHERE `old_url` = ' . $db->quote($current), 0, 1);
         $link = $db->loadObject();
         // If a redirect exists and is published, permanently redirect.
         if ($link and $link->published == 1) {
             $app->redirect($link->new_url, null, null, true, false);
         } else {
             $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
             // If not, add the new url to the database.
             $db->setQuery('INSERT IGNORE INTO `#__redirect_links` (`old_url`, `referer`, `published`, `created_date`)' . ' VALUES (' . $db->Quote($current) . ', ' . $db->Quote($referer) . ', 0, ' . $db->Quote(JFactory::getDate()->toMySQL()) . ')');
             $db->query();
             // Render the error page.
             JError::customErrorPage($error);
         }
     } else {
         // Render the error page.
         JError::customErrorPage($error);
     }
 }
开发者ID:carmerin,项目名称:cesae-web,代码行数:34,代码来源:redirect.php

示例2: handleError

 static function handleError(&$error)
 {
     // Get the application object.
     $app = JFactory::getApplication();
     // Make sure the error is a 404 and we are not in the administrator.
     if (!$app->isAdmin() and $error->getCode() == 404) {
         // Get the full current URI.
         $uri = JURI::getInstance();
         $current = $uri->toString(array('scheme', 'host', 'port', 'path', 'query', 'fragment'));
         // Attempt to ignore idiots.
         if (strpos($current, 'mosConfig_') !== false || strpos($current, '=http://') !== false) {
             // Render the error page.
             JError::customErrorPage($error);
         }
         // See if the current url exists in the database as a redirect.
         $db = JFactory::getDBO();
         $db->setQuery('SELECT ' . $db->quoteName('new_url') . ', ' . $db->quoteName('published') . ' FROM ' . $db->quoteName('#__redirect_links') . ' WHERE ' . $db->quoteName('old_url') . ' = ' . $db->quote($current), 0, 1);
         $link = $db->loadObject();
         // If no published redirect was found try with the server-relative URL
         if (!$link or $link->published != 1) {
             $currRel = $uri->toString(array('path', 'query', 'fragment'));
             $db->setQuery('SELECT ' . $db->quoteName('new_url') . ', ' . $db->quoteName('published') . ' FROM ' . $db->quoteName('#__redirect_links') . ' WHERE ' . $db->quoteName('old_url') . ' = ' . $db->quote($currRel), 0, 1);
             $link = $db->loadObject();
         }
         // If a redirect exists and is published, permanently redirect.
         if ($link and $link->published == 1) {
             $app->redirect($link->new_url, null, null, true, false);
         } else {
             $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
             $db->setQuery('SELECT id FROM ' . $db->quoteName('#__redirect_links') . '  WHERE old_url= ' . $db->quote($current));
             $res = $db->loadResult();
             if (!$res) {
                 // If not, add the new url to the database.
                 $query = $db->getQuery(true);
                 $query->insert($db->quoteName('#__redirect_links'), false);
                 $columns = array($db->quoteName('old_url'), $db->quoteName('new_url'), $db->quoteName('referer'), $db->quoteName('comment'), $db->quoteName('hits'), $db->quoteName('published'), $db->quoteName('created_date'));
                 $query->columns($columns);
                 $query->values($db->Quote($current) . ', ' . $db->Quote('') . ' ,' . $db->Quote($referer) . ', ' . $db->Quote('') . ',1,0, ' . $db->Quote(JFactory::getDate()->toSql()));
                 $db->setQuery($query);
                 $db->query();
             } else {
                 // Existing error url, increase hit counter
                 $query = $db->getQuery(true);
                 $query->update($db->quoteName('#__redirect_links'));
                 $query->set($db->quoteName('hits') . ' = ' . $db->quoteName('hits') . ' + 1');
                 $query->where('id = ' . (int) $res);
                 $db->setQuery((string) $query);
                 $db->query();
             }
             // Render the error page.
             JError::customErrorPage($error);
         }
     } else {
         // Render the error page.
         JError::customErrorPage($error);
     }
 }
开发者ID:joomline,项目名称:Joomla2.5.999,代码行数:57,代码来源:redirect.php

示例3: handleError

 static function handleError(&$error)
 {
     // Get the application object.
     $app = JFactory::getApplication();
     // Make sure the error is a 403 and we are in the frontend.
     if ($error->getCode() == 403 and $app->isSite()) {
         // Redirect to the home page
         $app->redirect('index.php', JText::_('PLG_SYSTEM_LOGOUT_REDIRECT'), null, true, false);
     } else {
         // Render the error page.
         JError::customErrorPage($error);
     }
 }
开发者ID:joomline,项目名称:Joomla2.5.999,代码行数:13,代码来源:logout.php

示例4: handleError

 /**
  * Method to handle an error condition.
  *
  * @param   Exception  $error  The Exception object to be handled.
  *
  * @return  void
  *
  * @since   1.6
  */
 public static function handleError($error)
 {
     // Get the application object.
     $app = JFactory::getApplication();
     // Make sure the error is a 403 and we are in the frontend.
     if ($error->getCode() == 403 && $app->isSite()) {
         // Load language file.
         parent::loadLanguage();
         // Redirect to the home page.
         $app->enqueueMessage(JText::_('PLG_SYSTEM_LOGOUT_REDIRECT'), 'message');
         $app->redirect(JRoute::_('index.php'));
     } else {
         // Render the custom error page.
         JError::customErrorPage($error);
     }
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:25,代码来源:logout.php

示例5: errorHandler

 /**
  * Custom JError callback
  *
  * Push the exception call stack in the JException returned through the call back
  * adn then rener the custom error page
  *
  * @param object A JException object
  * @return void
  */
 public function errorHandler($error)
 {
     if ($error instanceof Exception) {
         $exception = $error;
         $this->_exception = $exception;
         //store the exception for later use
         //Make sure we have a valid status code
         JError::raiseError(KHttpResponse::isError($exception->getCode()) ? $exception->getCode() : 500, $exception->getMessage());
         return;
     }
     $error->setProperties(array('backtrace' => $this->_exception->getTrace(), 'file' => $this->_exception->getFile(), 'line' => $this->_exception->getLine()));
     $debug = version_compare(JVERSION, '3.0', 'ge') ? JFactory::getConfig()->get('debug') : JFactory::getConfig()->getValue('config.debug');
     if ($debug) {
         $error->set('message', (string) $this->_exception);
     } else {
         $error->set('message', KHttpResponse::getMessage($error->get('code')));
     }
     //Make sure the buffers are cleared
     while (@ob_get_clean()) {
     }
     JError::customErrorPage($error);
 }
开发者ID:Roma48,项目名称:mayak,代码行数:31,代码来源:koowa.php

示例6: errorHandler

	/**
	 * Custom JError callback
	 *
	 * Push the exception call stack in the JException returned through the call back
	 * adn then rener the custom error page
	 *
	 * @param object A JException object
	 * @return void
	 */
	public function errorHandler($error)
	{
		$error->setProperties(array(
			'backtrace'	=> $this->_exception->getTrace(),
			'file'		=> $this->_exception->getFile(),
			'line'		=> $this->_exception->getLine()
		));
		
		if(KFactory::get('joomla:config')->getValue('config.debug')) {
			$error->set('message', (string) $this->_exception);
		} else {
			$error->set('message', KHttpResponse::getMessage($error->code));
		}
		
		//Make sure the buffers are cleared
		while(@ob_get_clean());
		JError::customErrorPage($error);
	}
开发者ID:raeldc,项目名称:com_learn,代码行数:27,代码来源:koowa.php

示例7: redirectNotAllowed

 /**
  * @param stdClass $error
  */
 public function redirectNotAllowed($error)
 {
     if ($error->code == 403) {
         $app = JFactory::getApplication();
         $app->redirect(JURI::base() . 'index.php?option=com_acctexp&task=NotAllowed');
     } else {
         JError::customErrorPage($error);
     }
 }
开发者ID:Ibrahim1,项目名称:aec,代码行数:12,代码来源:aecerrorhandler.php

示例8: handleError

 /**
  * Method to handle an error condition.
  *
  * @param   Exception  &$error  The Exception object to be handled.
  *
  * @return  void
  *
  * @since   1.6
  */
 public static function handleError(&$error)
 {
     // Get the application object.
     $app = JFactory::getApplication();
     // Make sure the error is a 404 and we are not in the administrator.
     if (!$app->isAdmin() and $error->getCode() == 404) {
         // Get the full current URI.
         $uri = JUri::getInstance();
         $current = rawurldecode($uri->toString(array('scheme', 'host', 'port', 'path', 'query', 'fragment')));
         // Attempt to ignore idiots.
         if (strpos($current, 'mosConfig_') !== false || strpos($current, '=http://') !== false) {
             // Render the error page.
             JError::customErrorPage($error);
         }
         // See if the current url exists in the database as a redirect.
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select($db->quoteName(array('new_url', 'header')))->select($db->quoteName('published'))->from($db->quoteName('#__redirect_links'))->where($db->quoteName('old_url') . ' = ' . $db->quote($current));
         $db->setQuery($query, 0, 1);
         $link = $db->loadObject();
         // If no published redirect was found try with the server-relative URL
         if (!$link or $link->published != 1) {
             $currRel = rawurldecode($uri->toString(array('path', 'query', 'fragment')));
             $query = $db->getQuery(true)->select($db->quoteName('new_url'))->select($db->quoteName('published'))->from($db->quoteName('#__redirect_links'))->where($db->quoteName('old_url') . ' = ' . $db->quote($currRel));
             $db->setQuery($query, 0, 1);
             $link = $db->loadObject();
         }
         // If a redirect exists and is published, permanently redirect.
         if ($link and $link->published == 1) {
             // If no header is set use a 301 permanent redirect
             if (!$link->header || JComponentHelper::getParams('com_redirect')->get('mode', 0) == false) {
                 $link->header = 301;
             }
             // If we have a redirect in the 300 range use JApplicationWeb::redirect().
             if ($link->header < 400 && $link->header >= 300) {
                 $new_link = JUri::isInternal($link->new_url) ? JRoute::_($link->new_url) : $link->new_url;
                 $app->redirect($new_link, intval($link->header));
             } else {
                 // Else rethrow the exeception with the new header and return
                 try {
                     throw new RuntimeException($error->getMessage(), $link->header, $error);
                 } catch (Exception $e) {
                     $newError = $e;
                 }
                 JError::customErrorPage($newError);
             }
         } else {
             $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
             $query = $db->getQuery(true)->select($db->quoteName('id'))->from($db->quoteName('#__redirect_links'))->where($db->quoteName('old_url') . ' = ' . $db->quote($current));
             $db->setQuery($query);
             $res = $db->loadResult();
             if (!$res) {
                 // If not, add the new url to the database but only if option is enabled
                 $params = new Registry(JPluginHelper::getPlugin('system', 'redirect')->params);
                 $collect_urls = $params->get('collect_urls', 1);
                 if ($collect_urls == true) {
                     $columns = array($db->quoteName('old_url'), $db->quoteName('new_url'), $db->quoteName('referer'), $db->quoteName('comment'), $db->quoteName('hits'), $db->quoteName('published'), $db->quoteName('created_date'));
                     $query->clear()->insert($db->quoteName('#__redirect_links'), false)->columns($columns)->values($db->quote($current) . ', ' . $db->quote('') . ' ,' . $db->quote($referer) . ', ' . $db->quote('') . ',1,0, ' . $db->quote(JFactory::getDate()->toSql()));
                     $db->setQuery($query);
                     $db->execute();
                 }
             } else {
                 // Existing error url, increase hit counter.
                 $query->clear()->update($db->quoteName('#__redirect_links'))->set($db->quoteName('hits') . ' = ' . $db->quoteName('hits') . ' + 1')->where('id = ' . (int) $res);
                 $db->setQuery($query);
                 $db->execute();
             }
             // Render the error page.
             JError::customErrorPage($error);
         }
     } else {
         // Render the error page.
         JError::customErrorPage($error);
     }
 }
开发者ID:educakanchay,项目名称:kanchay,代码行数:83,代码来源:redirect.php

示例9: _actionException

 /**
  * Callback to handle both JError and Exception
  * 
  * @param KCommandContext $context Command chain context
  * caller => KObject, data => mixed
  * 
  * @return KException
  */
 protected function _actionException($context)
 {
     $error = $context->data;
     if ($context->response->getHeader('Location')) {
         $context->response->send();
         exit(0);
     }
     JError::customErrorPage($error);
     exit(0);
 }
开发者ID:walteraries,项目名称:anahita,代码行数:18,代码来源:dispatcher.php

示例10: errorHandler

 /**
  * Custom JError callback
  *
  * Push the exception call stack in the JException returned through the call back
  * adn then rener the custom error page
  *
  * @param object A JException object
  * @return void
  */
 public function errorHandler($error)
 {
     $error->setProperties(array('backtrace' => $this->_exception->getTrace(), 'file' => $this->_exception->getFile(), 'line' => $this->_exception->getLine()));
     if (JFactory::getConfig()->getValue('config.debug')) {
         $error->set('message', (string) $this->_exception);
     } else {
         $error->set('message', KHttpResponse::getMessage($error->get('code')));
     }
     if ($this->_exception->getCode() == KHttpResponse::UNAUTHORIZED) {
         header('WWW-Authenticate: Basic Realm="' . KRequest::base() . '"');
     }
     //Make sure the buffers are cleared
     while (@ob_get_clean()) {
     }
     JError::customErrorPage($error);
 }
开发者ID:janssit,项目名称:www.marlinfishingcanaria.com,代码行数:25,代码来源:koowa.php


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