Esempio n. 1
0
 /**
  * Method to handle an error condition.
  *
  * @param   Exception  &$error  The Exception object to be handled.
  * @return  void
  */
 public static function handleError(&$error)
 {
     $renderer = new \Hubzero\Error\Renderer\Page(App::get('document'), App::get('template.loader'), App::get('config')->get('debug'));
     // Make sure the error is a 404 and we are not in the administrator.
     if (!App::isSite() || $error->getCode() != 404) {
         // Render the error page.
         return $renderer->render($error);
     }
     // Get the full current URI.
     $uri = Hubzero\Utility\Uri::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.
         return $renderer->render($error);
     }
     if (file_exists(PATH_CORE . DS . 'components' . DS . 'com_redirect' . DS . 'models' . DS . 'link.php')) {
         include_once PATH_CORE . DS . 'components' . DS . 'com_redirect' . DS . 'models' . DS . 'link.php';
         // See if the current url exists in the database as a redirect.
         $link = \Components\Redirect\Models\Link::all()->whereEquals('old_url', $current)->row();
         // If no published redirect was found try with the server-relative URL
         if (!$link->get('id') || $link->get('published') != 1) {
             $currRel = $uri->toString(array('path', 'query', 'fragment'));
             $link = \Components\Redirect\Models\Link::all()->whereEquals('old_url', $currRel)->row();
         }
         // If a redirect exists and is published, permanently redirect.
         if ($link->get('id') && $link->get('published') == 1) {
             App::redirect($link->new_url, null, null, true, false);
         }
         $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
         $row = \Components\Redirect\Models\Link::all()->whereEquals('old_url', substr($current, 0, 255))->row();
         if (!$row->get('id')) {
             $row->set(['old_url' => $current, 'new_url' => '', 'referer' => $referer, 'comment' => '', 'hits' => 1, 'published' => 0, 'created_date' => Date::toSql()]);
         } else {
             $row->set('hits', intval($row->get('hits', 0)) + 1);
         }
         try {
             $row->save();
         } catch (Exception $e) {
             // Do nothing for now.
             // @TODO  Log this?
         }
     }
     // Render the error page.
     $renderer->render($error);
 }
Esempio n. 2
0
defined('_HZEXEC_') or die;
$hash = App::hash(App::get('client')->name . ':authenticator');
if (($cookie = \Hubzero\Utility\Cookie::eat('authenticator')) && !Request::getInt('reset', false)) {
    $primary = $cookie->authenticator;
    $user = User::getInstance($cookie->user_id);
    $user_img = $cookie->user_img;
    Request::setVar('primary', $primary);
}
$usersConfig = Component::params('com_members');
$primary = Request::getWord('primary', false);
// use some reflections to inspect plugins for special behavior (added for shibboleth)
$refl = array();
foreach ($authenticators as $a) {
    $refl[$a['name']] = new \ReflectionClass("plgAuthentication{$a['name']}");
}
$current = Hubzero\Utility\Uri::getInstance()->toString();
$current .= strstr($current, '?') ? '&' : '?';
?>
<div class="hz_user">

<?php 
if ($primary && $primary != 'hubzero') {
    ?>
	<a class="primary" href="<?php 
    echo Route::url('index.php?option=com_users&view=login&authenticator=' . $primary . $returnQueryString);
    ?>
">
		<div class="<?php 
    echo $primary;
    ?>
 upper"></div>
Esempio n. 3
0
?>
		<img class="comment-author" src="<?php 
echo $creator->picture($comment->admin);
?>
" alt="" />
		<div class="comment-show">
			<span class="comment-details">
				<span class="actor"><?php 
echo $comment->admin == 1 ? Lang::txt('COM_PROJECTS_ADMIN') : $comment->author;
?>
</span>
				<span class="item-time">&middot; <?php 
echo \Components\Projects\Helpers\Html::showTime($comment->created, true);
?>
</span>
			</span>
			<?php 
echo '<div class="body">' . $shortComment;
if ($shorten) {
    echo ' <a href="#fullbodyc' . $comment->id . '" class="more-content">' . Lang::txt('COM_PROJECTS_MORE') . '</a>';
}
echo '</div>';
if ($shorten) {
    $fragment = ltrim(Hubzero\Utility\Uri::getInstance()->toString(['fragment']), '#');
    $cls = $fragment == 'fullbodyc' . $comment->id ? '' : ' hidden';
    echo '<div class="fullbody' . $cls . '" id="fullbodyc' . $comment->id . '">' . $longComment . '</div>';
}
?>
		</div>
	</li>