Example #1
0
 /**
  * Converting the site URL to fit to the HTTP request
  *
  */
 function onAfterInitialise()
 {
     global $_PROFILER;
     $app =& JFactory::getApplication();
     $user =& JFactory::getUser();
     if ($app->isAdmin() || JDEBUG) {
         return;
     }
     if (!$user->get('guest') && $_SERVER['REQUEST_METHOD'] == 'GET') {
         $this->_cache->setCaching(true);
     }
     $data = $this->_cache->get();
     if ($data !== false) {
         // the following code searches for a token in the cached page and replaces it with the
         // proper token.
         $token = JUtility::getToken();
         $search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#';
         $replacement = '<input type="hidden" name="' . $token . '" value="1" />';
         $data = preg_replace($search, $replacement, $data);
         JResponse::setBody($data);
         echo JResponse::toString($app->getCfg('gzip'));
         if (JDEBUG) {
             $_PROFILER->mark('afterCache');
             echo implode('', $_PROFILER->getBuffer());
         }
         $app->close();
     }
 }
Example #2
0
 function init()
 {
     $mainframe =& JFactory::getApplication();
     $file = JRequest::getVar('file');
     $folder = JRequest::getVar('folder');
     jimport('joomla.filesystem.file');
     // only allow files that have .inc.php in the file name
     if (!$file || strpos($file, '.inc.php') === false) {
         echo JText::_('Access Denied');
         exit;
     }
     if (!$mainframe->isAdmin() && !JRequest::getCmd('usetemplate')) {
         $mainframe->setTemplate('system');
     }
     $_REQUEST['tmpl'] = 'component';
     $mainframe->_messageQueue = array();
     $html = '';
     $path = JPATH_SITE;
     if ($folder) {
         $path .= DS . implode(DS, explode('.', $folder));
     }
     $file = $path . DS . $file;
     if (JFile::exists($file)) {
         ob_start();
         include $file;
         $html = ob_get_contents();
         ob_end_clean();
     }
     $document =& JFactory::getDocument();
     $document->setBuffer($html, 'component');
     $document->addStyleSheet(JURI::root(true) . '/plugins/system/nonumberelements/css/default.css');
     $mainframe->render();
     echo JResponse::toString($mainframe->getCfg('gzip'));
     exit;
 }
Example #3
0
 /**
  * Render the error page based on an exception.
  *
  * @param   Exception  $error  The exception for which to render the error page.
  *
  * @return  void
  *
  * @since   3.0
  */
 public static function render(Exception $error)
 {
     try {
         $app = JFactory::getApplication();
         $document = JDocument::getInstance('error');
         if (!$document) {
             // We're probably in an CLI environment
             exit($error->getMessage());
             $app->close(0);
         }
         $config = JFactory::getConfig();
         // Get the current template from the application
         $template = $app->getTemplate();
         // Push the error object into the document
         $document->setError($error);
         if (ob_get_contents()) {
             ob_end_clean();
         }
         $document->setTitle(JText::_('Error') . ': ' . $error->getCode());
         $data = $document->render(false, array('template' => $template, 'directory' => JPATH_THEMES, 'debug' => $config->get('debug')));
         // Failsafe to get the error displayed.
         if (empty($data)) {
             exit($error->getMessage());
         } else {
             // Do not allow cache
             JResponse::allowCache(false);
             JResponse::setBody($data);
             echo JResponse::toString();
         }
     } catch (Exception $e) {
         exit('Error displaying the error page: ' . $e->getMessage());
     }
 }
 /**
  * Converting the site URL to fit to the HTTP request
  *
  */
 function onAfterInitialise()
 {
     global $_PROFILER;
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     if ($app->isAdmin() || JDEBUG) {
         return;
     }
     if (count($app->getMessageQueue())) {
         return;
     }
     if ($user->get('guest') && $_SERVER['REQUEST_METHOD'] == 'GET') {
         $this->_cache->setCaching(true);
     }
     $data = $this->_cache->get();
     if ($data !== false) {
         JResponse::setBody($data);
         echo JResponse::toString($app->getCfg('gzip'));
         if (JDEBUG) {
             $_PROFILER->mark('afterCache');
             echo implode('', $_PROFILER->getBuffer());
         }
         $app->close();
     }
 }
/**
 * Output a correct response code when site is offline
 * to let know search engines that site data
 * should not be discarded or discounted
 */
function plgSh404sefofflinecode()
{
    $app = JFactory::getApplication();
    // are we in the backend, or not offline ?
    if (!defined('SH404SEF_IS_RUNNING') || $app->isAdmin() || !$app->getCfg('offline')) {
        return;
    }
    // get plugin params
    $plugin =& JPluginHelper::getPlugin('sh404sefcore', 'sh404sefofflinecode');
    $pluginParams = new JRegistry();
    $pluginParams->loadString($plugin->params);
    $disallowAdminAccess = $pluginParams->get('disallowAdminAccess', 0);
    if (!$disallowAdminAccess) {
        // admins are allowed, lets check if current user
        // is an admin, or if user is trying to log in
        $user =& JFactory::getUser();
        $option = JRequest::getCmd('option');
        $task = JRequest::getCmd('task');
        if ($option == 'com_users' && $task == 'user.login') {
            // Check for request forgeries
            JRequest::checkToken() or jexit('Invalid Token');
            $loggingIn = true;
        } else {
            $loggingIn = false;
        }
        // if already logged inadmin, or admin logging in, let it go
        if ($user->authorize('core.manage', 'com_sh404sef') || $loggingIn) {
            return;
        }
    }
    // need to render offline screen
    if ($disallowAdminAccess) {
        // admins not allowed, use our own
        // simplified template. Most likely being hacked so
        // close doors as much as possible
        $template = '';
        $file = 'sh404sef_offline_template.php';
        $directory = JPATH_ROOT . DS . 'plugins' . DS . 'sh404sefcore';
    } else {
        // admin can access, use Joomla! offline template,
        // that includes a login form
        $template = $app->getTemplate();
        $file = 'offline.php';
        $directory = JPATH_THEMES;
    }
    $params = array('template' => $template, 'file' => $file, 'directory' => $directory);
    $document =& JFactory::getDocument();
    $data = $document->render($app->getCfg('caching'), $params);
    // header : service unavailable
    JResponse::setHeader('HTTP/1.0 503', true);
    // give it some time
    $retryAfter = $pluginParams->get('retry_after_delay', 7400);
    // set header
    Jresponse::setheader('Retry-After', gmdate('D, d M Y H:i:s', time() + $retryAfter) . ' GMT');
    // echo document
    JResponse::setBody($data);
    echo JResponse::toString($app->getCfg('gzip'));
    // and terminate
    $app->close();
}
Example #6
0
 /**
  * Converting the site URL to fit to the HTTP request
  *
  */
 function onAfterInitialise()
 {
     global $mainframe, $_PROFILER;
     $user =& JFactory::getUser();
     if ($mainframe->isAdmin() || JDEBUG) {
         return;
     }
     if (!$user->get('aid') && $_SERVER['REQUEST_METHOD'] == 'GET') {
         $this->_cache->setCaching(true);
     }
     $data = $this->_cache->get();
     if ($data !== false) {
         // the following code searches for a token in the cached page and replaces it with the
         // proper token.
         $token = JUtility::getToken();
         $search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#';
         $replacement = '<input type="hidden" name="' . $token . '" value="1" />';
         $data = preg_replace($search, $replacement, $data);
         /** HTGMOD **/
         // do the same thing for the JomSocial ajax token
         $search = '/jax_token_var = \'[0-9a-f]{32}\'/';
         $replacement = 'jax_token_var = \'' . $token . '\'';
         $data = preg_replace($search, $replacement, $data);
         /** END HTGMOD **/
         JResponse::setBody($data);
         echo JResponse::toString($mainframe->getCfg('gzip'));
         if (JDEBUG) {
             $_PROFILER->mark('afterCache');
             echo implode('', $_PROFILER->getBuffer());
         }
         $mainframe->close();
     }
 }
Example #7
0
 /**
  * Converting the site URL to fit to the HTTP request
  *
  */
 function onAfterInitialise()
 {
     global $_PROFILER;
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     if ($app->isAdmin()) {
         return;
     }
     if (count($app->getMessageQueue())) {
         return;
     }
     if ($user->get('guest') && $app->input->getMethod() == 'GET') {
         $this->_cache->setCaching(true);
     }
     $data = $this->_cache->get($this->_cache_key);
     if ($data !== false) {
         // Set cached body
         JResponse::setBody($data);
         echo JResponse::toString($app->getCfg('gzip'));
         if (JDEBUG) {
             $_PROFILER->mark('afterCache');
         }
         $app->close();
     }
 }
Example #8
0
 function t3_init()
 {
     t3import('core.parameter');
     t3import('core.extendable');
     t3import('core.template');
     t3import('core.basetemplate');
     t3import('core.cache');
     t3import('core.head');
     t3import('core.hook');
     t3import('core.joomla.view');
     if (!class_exists('JModuleHelper', false)) {
         t3import('core.joomla.modulehelper');
     }
     t3import('core.joomla.pagination');
     //Load template language
     $this->loadLanguage('tpl_' . T3_ACTIVE_TEMPLATE, JPATH_SITE);
     $params = T3Common::get_template_based_params();
     //instance cache object.
     $devmode = $params ? $params->get('devmode', '0') == '1' : false;
     T3Cache::getInstance($devmode);
     //Check if enable T3 info mode. Enable by default (if not set)
     if ($params->get('infomode', 1) == 1) {
         if (!JRequest::getCmd('t3info') && JRequest::getCmd('tp')) {
             JRequest::setVar('t3info', JRequest::getCmd('tp'));
         }
     }
     $key = T3Cache::getPageKey();
     $data = null;
     $user =& JFactory::getUser();
     if (!$devmode && JRequest::getCmd('cache') != 'no') {
         T3Cache::setCaching(true);
         JResponse::allowCache(true);
     }
     $data = T3Cache::get($key);
     if ($data) {
         if (!preg_match('#<jdoc:include\\ type="([^"]+)" (.*)\\/>#iU', $data)) {
             $mainframe = JFactory::getApplication();
             $token = JUtility::getToken();
             $search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#';
             $replacement = '<input type="hidden" name="' . $token . '" value="1" />';
             $data = preg_replace($search, $replacement, $data);
             JResponse::setBody($data);
             echo JResponse::toString($mainframe->getCfg('gzip'));
             if (JDEBUG) {
                 global $_PROFILER;
                 $_PROFILER->mark('afterCache');
                 echo implode('', $_PROFILER->getBuffer());
             }
             $mainframe->close();
         }
     }
     //Preload template
     t3import('core.preload');
     $preload = T3Preload::getInstance();
     $preload->load();
     $doc =& JFactory::getDocument();
     $t3 = T3Template::getInstance($doc);
     $t3->_html = $data;
 }
Example #9
0
 function __construct()
 {
     $app = JFactory::getApplication();
     $url = JRequest::getVar('url');
     $func = new plgSystemNNFrameworkHelperFunctions();
     if ($url) {
         echo $func->getByUrl($url);
         die;
     }
     $file = JRequest::getVar('file');
     // only allow files that have .inc.php in the file name
     if (!$file || strpos($file, '.inc.php') === false) {
         die;
     }
     $folder = JRequest::getVar('folder');
     if ($folder) {
         $file = implode('/', explode('.', $folder)) . '/' . $file;
     }
     $allowed = array('administrator/components/com_dbreplacer/dbreplacer.inc.php', 'administrator/components/com_nonumbermanager/details.inc.php', 'administrator/components/com_rereplacer/images/image.inc.php', 'administrator/modules/mod_addtomenu/addtomenu/addtomenu.inc.php', 'plugins/editors-xtd/articlesanywhere/articlesanywhere.inc.php', 'plugins/editors-xtd/contenttemplater/contenttemplater.inc.php', 'plugins/editors-xtd/modulesanywhere/modulesanywhere.inc.php', 'plugins/editors-xtd/snippets/snippets.inc.php', 'plugins/editors-xtd/sourcerer/sourcerer.inc.php');
     if (!$file || in_array($file, $allowed) === false) {
         die;
     }
     jimport('joomla.filesystem.file');
     if ($app->isSite() && !JRequest::getCmd('usetemplate')) {
         if (version_compare(JVERSION, '1.6.0', 'l')) {
             $app->setTemplate('../administrator/templates/khepri');
         } else {
             $app->setTemplate('../administrator/templates/bluestork');
         }
     }
     $_REQUEST['tmpl'] = 'component';
     JRequest::setVar('option', '1');
     $app->set('_messageQueue', '');
     $file = JPATH_SITE . '/' . $file;
     $html = '';
     if (JFile::exists($file)) {
         ob_start();
         include $file;
         $html = ob_get_contents();
         ob_end_clean();
     }
     $document = JFactory::getDocument();
     $document->setBuffer($html, 'component');
     if (version_compare(JVERSION, '1.6.0', 'l')) {
         $document->addStyleSheet(JURI::root(true) . '/administrator/templates/khepri/css/template.css');
         $document->addStyleSheet(JURI::root(true) . '/administrator/templates/khepri/css/icon.css');
         $document->addStyleSheet(JURI::root(true) . '/administrator/templates/khepri/css/rounded.css');
     } else {
         $document->addStyleSheet(JURI::root(true) . '/administrator/templates/bluestork/css/template.css');
     }
     $document->addScript(JURI::root(true) . '/includes/js/joomla.javascript.js');
     $app->render();
     $html = JResponse::toString($app->getCfg('gzip'));
     $html = preg_replace('#\\s*<' . 'link [^>]*href="[^"]*templates/system/[^"]*\\.css[^"]*"[^>]* />#s', '', $html);
     echo $html;
     die;
 }
Example #10
0
 function raiseError($code, $msg, $info = null, $backtrace = false)
 {
     jimport('joomla.error.exception');
     $exception = new JException($msg, $code, E_ERROR, $info, $backtrace);
     JResponse::setHeader('status', $exception->code . ' ' . str_replace("\n", ' ', $exception->message));
     JResponse::setBody(json_encode($exception));
     echo JResponse::toString();
     exit;
 }
Example #11
0
 function __construct()
 {
     $url = JFactory::getApplication()->input->getString('url', '');
     require_once JPATH_PLUGINS . '/system/nnframework/helpers/functions.php';
     $func = new NNFrameworkFunctions();
     if ($url) {
         echo $func->getByUrl($url);
         die;
     }
     $file = JFactory::getApplication()->input->getString('file', '');
     // only allow files that have .inc.php in the file name
     if (!$file || strpos($file, '.inc.php') === false) {
         die;
     }
     $folder = JFactory::getApplication()->input->getString('folder', '');
     if ($folder) {
         $file = implode('/', explode('.', $folder)) . '/' . $file;
     }
     $allowed = array('administrator/components/com_dbreplacer/dbreplacer.inc.php', 'administrator/components/com_nonumbermanager/details.inc.php', 'administrator/modules/mod_addtomenu/addtomenu.inc.php', 'media/rereplacer/images/image.inc.php', 'plugins/editors-xtd/articlesanywhere/articlesanywhere.inc.php', 'plugins/editors-xtd/contenttemplater/contenttemplater.inc.php', 'plugins/editors-xtd/modulesanywhere/modulesanywhere.inc.php', 'plugins/editors-xtd/snippets/snippets.inc.php', 'plugins/editors-xtd/sourcerer/sourcerer.inc.php');
     if (!$file || in_array($file, $allowed) === false) {
         die;
     }
     jimport('joomla.filesystem.file');
     if (JFactory::getApplication()->isSite()) {
         JFactory::getApplication()->setTemplate('../administrator/templates/isis');
     }
     $_REQUEST['tmpl'] = 'component';
     JFactory::getApplication()->input->set('option', '1');
     JHtml::_('bootstrap.framework');
     JFactory::getDocument()->addScript(JURI::root(true) . '/administrator/templates/isis/js/template.js');
     JFactory::getDocument()->addStyleSheet(JURI::root(true) . '/administrator/templates/isis/css/template.css');
     JHtml::stylesheet('nnframework/popup.min.css', false, true);
     $file = JPATH_SITE . '/' . $file;
     $html = '';
     if (JFile::exists($file)) {
         ob_start();
         include $file;
         $html = ob_get_contents();
         ob_end_clean();
     }
     JFactory::getDocument()->setBuffer($html, 'component');
     if (version_compare(JVERSION, '3.2', 'l')) {
         JFactory::getApplication()->render();
     } else {
         nnApplication::render();
     }
     $html = JResponse::toString(JFactory::getApplication()->getCfg('gzip'));
     $html = preg_replace('#\\s*<' . 'link [^>]*href="[^"]*templates/system/[^"]*\\.css[^"]*"[^>]* />#s', '', $html);
     $html = preg_replace('#(<' . 'body [^>]*class=")#s', '\\1nnpopup ', $html);
     $html = str_replace('<' . 'body>', '<' . 'body class="nnpopup"', $html);
     echo $html;
     die;
 }
Example #12
0
 function __construct()
 {
     $mainframe =& JFactory::getApplication();
     $url = JRequest::getVar('url');
     $options = JRequest::getVar('url_options', array(), 'post', 'array');
     $func = new plgSystemNoNumberElementsHelperFunctions();
     if ($url) {
         echo $func->getByUrl($url, $options);
         exit;
     }
     $file = JRequest::getVar('file');
     // only allow files that have .inc.php in the file name
     if (!$file || strpos($file, '.inc.php') === false) {
         echo JText::_('Access Denied');
         exit;
     }
     $folder = JRequest::getVar('folder');
     jimport('joomla.filesystem.file');
     if ($mainframe->isSite() && !JRequest::getCmd('usetemplate')) {
         $mainframe->setTemplate('system');
     }
     $_REQUEST['tmpl'] = 'component';
     JRequest::setVar('option', '1');
     if (version_compare(JVERSION, '1.6.0', 'l')) {
         // For Joomla 1.5
         $mainframe->_messageQueue = array();
     } else {
         // Still have to figure out how to empty message queue in J1.6
     }
     $path = JPATH_SITE;
     if ($folder) {
         $path .= DS . implode(DS, explode('.', $folder));
     }
     $file = $path . DS . $file;
     $html = '';
     if (JFile::exists($file)) {
         ob_start();
         include $file;
         $html = ob_get_contents();
         ob_end_clean();
     }
     $document =& JFactory::getDocument();
     $document->setBuffer($html, 'component');
     $document->addStyleSheet(JURI::root(true) . '/templates/system/css/system.css');
     $document->addStyleSheet(JURI::root(true) . '/plugins/system/nonumberelements/css/default.css');
     $document->addScript(JURI::root(true) . '/includes/js/joomla.javascript.js');
     $mainframe->render();
     echo JResponse::toString($mainframe->getCfg('gzip'));
     exit;
 }
Example #13
0
 public function create()
 {
     $output = '';
     $size = JRequest::getCmd('size', '');
     if (!in_array($size, array('min', 'medium'))) {
         throw new Exception('The image size is not recognized', 500);
     }
     $image = JRequest::getVar('image', '');
     $id = JRequest::getInt('id', 0);
     $imagePath = JPATH_ROOT . DS . 'images' . DS . 'com_jea' . DS . 'images' . DS . $id . DS . $image;
     $thumbDir = JPATH_ROOT . DS . 'images' . DS . 'com_jea' . DS . 'thumb-' . $size;
     $thumbPath = $thumbDir . DS . $id . '-' . $image;
     if (file_exists($thumbPath)) {
         $output = readfile($thumbPath);
     } elseif (file_exists($imagePath)) {
         if (!JFolder::exists($thumbPath)) {
             JFolder::create($thumbDir);
         }
         $params = JComponentHelper::getParams('com_jea');
         if ($size == 'medium') {
             $width = $params->get('thumb_medium_width', 400);
             $height = $params->get('thumb_medium_height', 300);
         } else {
             $width = $params->get('thumb_min_width', 120);
             $height = $params->get('thumb_min_height', 90);
         }
         $quality = (int) $params->get('jpg_quality', 90);
         $cropThumbnails = (bool) $params->get('crop_thumbnails', 0);
         $JImage = new JImage($imagePath);
         if ($cropThumbnails) {
             $thumb = $JImage->resize($width, $height, true, JImage::SCALE_OUTSIDE);
             $left = $thumb->getWidth() > $width ? intval(($thumb->getWidth() - $width) / 2) : 0;
             $top = $thumb->getHeight() > $height ? intval(($thumb->getHeight() - $height) / 2) : 0;
             $thumb->crop($width, $height, $left, $top, false);
         } else {
             $thumb = $JImage->resize($width, $height);
         }
         $thumb->toFile($thumbPath, IMAGETYPE_JPEG, array('quality' => $quality));
         $output = readfile($thumbPath);
     } else {
         throw new Exception('The image ' . $image . ' was not found', 500);
     }
     JResponse::setHeader('Content-Type', 'image/jpeg', true);
     JResponse::setHeader('Content-Transfer-Encoding', 'binary');
     JResponse::allowCache(false);
     JResponse::setBody($output);
     echo JResponse::toString();
     exit;
 }
Example #14
0
 function __construct()
 {
     $mainframe =& JFactory::getApplication();
     $url = JRequest::getVar('url');
     $options = JRequest::getVar('url_options', array(), 'post', 'array');
     $func = new plgSystemNNFrameworkHelperFunctions();
     if ($url) {
         echo $func->getByUrl($url, $options);
         exit;
     }
     $file = JRequest::getVar('file');
     // only allow files that have .inc.php in the file name
     if (!$file || strpos($file, '.inc.php') === false) {
         die;
     }
     $folder = JRequest::getVar('folder');
     if ($folder) {
         $file = implode('/', explode('.', $folder)) . '/' . $file;
     }
     $allowed = array('administrator/components/com_dbreplacer/dbreplacer.inc.php', 'administrator/components/com_nonumbermanager/details.inc.php', 'administrator/components/com_rereplacer/images/image.inc.php', 'administrator/modules/mod_addtomenu/addtomenu/addtomenu.inc.php', 'plugins/editors-xtd/articlesanywhere/articlesanywhere.inc.php', 'plugins/editors-xtd/contenttemplater/contenttemplater.inc.php', 'plugins/editors-xtd/modulesanywhere/modulesanywhere.inc.php', 'plugins/editors-xtd/snippets/snippets.inc.php', 'plugins/editors-xtd/sourcerer/sourcerer.inc.php');
     if (!$file || in_array($file, $allowed) === false) {
         die;
     }
     jimport('joomla.filesystem.file');
     if ($mainframe->isSite() && !JRequest::getCmd('usetemplate')) {
         $mainframe->setTemplate('system');
     }
     $_REQUEST['tmpl'] = 'component';
     JRequest::setVar('option', '1');
     $mainframe->set('_messageQueue', '');
     $file = JPATH_SITE . '/' . $file;
     $html = '';
     if (JFile::exists($file)) {
         ob_start();
         include $file;
         $html = ob_get_contents();
         ob_end_clean();
     }
     $document =& JFactory::getDocument();
     $document->setBuffer($html, 'component');
     $document->addStyleSheet(JURI::root(true) . '/templates/system/css/system.css');
     $document->addStyleSheet(JURI::root(true) . '/plugins/system/nnframework/css/default.css');
     $document->addScript(JURI::root(true) . '/includes/js/joomla.javascript.js');
     $mainframe->render();
     echo JResponse::toString($mainframe->getCfg('gzip'));
     exit;
 }
Example #15
0
 function render()
 {
     $url = JFactory::getApplication()->input->getString('url', '');
     $func = new NNFrameworkFunctions();
     if ($url) {
         echo $func->getByUrl($url);
         die;
     }
     $allowed = array('administrator/components/com_dbreplacer/ajax.php', 'administrator/modules/mod_addtomenu/popup.php', 'media/rereplacer/images/popup.php', 'plugins/editors-xtd/articlesanywhere/popup.php', 'plugins/editors-xtd/contenttemplater/popup.php', 'plugins/editors-xtd/dummycontent/popup.php', 'plugins/editors-xtd/modals/popup.php', 'plugins/editors-xtd/modulesanywhere/popup.php', 'plugins/editors-xtd/sliders/popup.php', 'plugins/editors-xtd/snippets/popup.php', 'plugins/editors-xtd/sourcerer/popup.php', 'plugins/editors-xtd/tabs/popup.php', 'plugins/editors-xtd/tooltips/popup.php', 'administrator/components/com_dbreplacer/dbreplacer.inc.php', 'administrator/components/com_nonumbermanager/details.inc.php', 'administrator/modules/mod_addtomenu/addtomenu.inc.php', 'media/rereplacer/images/image.inc.php', 'plugins/editors-xtd/articlesanywhere/articlesanywhere.inc.php', 'plugins/editors-xtd/contenttemplater/contenttemplater.inc.php', 'plugins/editors-xtd/dummycontent/dummycontent.inc.php', 'plugins/editors-xtd/modulesanywhere/modulesanywhere.inc.php', 'plugins/editors-xtd/snippets/snippets.inc.php', 'plugins/editors-xtd/sourcerer/sourcerer.inc.php');
     $file = JFactory::getApplication()->input->getString('file', '');
     $folder = JFactory::getApplication()->input->getString('folder', '');
     if ($folder) {
         $file = implode('/', explode('.', $folder)) . '/' . $file;
     }
     if (!$file || in_array($file, $allowed) === false) {
         die;
     }
     jimport('joomla.filesystem.file');
     if (JFactory::getApplication()->isSite()) {
         JFactory::getApplication()->setTemplate('../administrator/templates/isis');
     }
     $_REQUEST['tmpl'] = 'component';
     JFactory::getApplication()->input->set('option', 'com_content');
     header('Content-Type: text/html; charset=utf-8');
     JHtml::_('bootstrap.framework');
     JFactory::getDocument()->addScript(JUri::root(true) . '/administrator/templates/isis/js/template.js');
     JFactory::getDocument()->addStyleSheet(JUri::root(true) . '/administrator/templates/isis/css/template.css');
     JHtml::stylesheet('nnframework/popup.min.css', false, true);
     $file = JPATH_SITE . '/' . $file;
     $html = '';
     if (JFile::exists($file)) {
         ob_start();
         include $file;
         $html = ob_get_contents();
         ob_end_clean();
     }
     JFactory::getDocument()->setBuffer($html, 'component');
     NNApplication::render();
     $html = JResponse::toString(JFactory::getApplication()->getCfg('gzip'));
     $html = preg_replace('#\\s*<' . 'link [^>]*href="[^"]*templates/system/[^"]*\\.css[^"]*"[^>]* />#s', '', $html);
     $html = preg_replace('#(<' . 'body [^>]*class=")#s', '\\1nnpopup ', $html);
     $html = str_replace('<' . 'body>', '<' . 'body class="nnpopup"', $html);
     echo $html;
     die;
 }
Example #16
0
 /**
  * Method to export features tables as CSV
  */
 public function export()
 {
     $features = JRequest::getVar('cid', array(), 'post', 'array');
     if (!empty($features)) {
         $config = JFactory::getConfig();
         $exportPath = $config->get('tmp_path') . DS . 'jea_export';
         if (JFolder::create($exportPath) === false) {
             $msg = JText::_('JLIB_FILESYSTEM_ERROR_FOLDER_CREATE') . ' : ' . $exportPath;
             $this->setRedirect('index.php?option=com_jea&view=features', $msg, 'warning');
         } else {
             $xmlPath = JPATH_COMPONENT . '/models/forms/features/';
             $xmlFiles = JFolder::files($xmlPath);
             $model = $this->getModel();
             $files = array();
             foreach ($xmlFiles as $filename) {
                 if (preg_match('/^[0-9]{2}-([a-z]*).xml/', $filename, $matches)) {
                     $feature = $matches[1];
                     if (in_array($feature, $features)) {
                         $form = simplexml_load_file($xmlPath . DS . $filename);
                         $table = (string) $form['table'];
                         $files[] = array('data' => $model->getCSVData($table), 'name' => $table . '.csv');
                     }
                 }
             }
             $zipFile = $exportPath . DS . 'jea_export_' . uniqid() . '.zip';
             $zip = JArchive::getAdapter('zip');
             $zip->create($zipFile, $files);
             JResponse::setHeader('Content-Type', 'application/zip');
             JResponse::setHeader('Content-Disposition', 'attachment; filename="jea_features.zip"');
             JResponse::setHeader('Content-Transfer-Encoding', 'binary');
             JResponse::setBody(readfile($zipFile));
             echo JResponse::toString();
             // clean tmp files
             JFile::delete($zipFile);
             JFolder::delete($exportPath);
             Jexit();
         }
     } else {
         $msg = JText::_('JERROR_NO_ITEMS_SELECTED');
         $this->setRedirect('index.php?option=com_jea&view=features', $msg);
     }
 }
Example #17
0
 function gzip()
 {
     $file = JRequest::getVar('file');
     //clean filepath
     $file = preg_replace('#[?\\#]+.*$#', '', $file);
     //check exists
     $filepath = T3Path::path(dirname($file)) . DS . basename($file);
     if (!is_file($filepath)) {
         echo "File {$file} {$filepath} not exist";
         return;
     }
     $type = strtolower(JRequest::getCmd('type', 'css'));
     //$type must be in css or js
     if (!in_array($type, array('css', 'js'))) {
         echo "Type {$type} not support";
         return;
     }
     //make sure the type of $file is the same with $type
     if (!preg_match('#\\.' . $type . '$#', $filepath)) {
         echo "Type {$type} not match";
         return;
     }
     jimport('joomla.filesystem.file');
     $data = @JFile::read($filepath);
     if (!$data) {
         echo "File {$filepath} empty";
         return;
     }
     if ($type == 'js') {
         $type = 'javascript';
     }
     JResponse::setHeader('Content-Type', "text/{$type};", true);
     //set cache time
     JResponse::setHeader('Cache-Control', "private", true);
     $offset = 365 * 24 * 60 * 60;
     //whenever the content is changed, the file name is changed also. Therefore we could set the cache time long.
     JResponse::setHeader('Expires', gmdate("D, d M Y H:i:s", time() + $offset) . " GMT", true);
     JResponse::allowCache(true);
     JResponse::setBody($data);
     echo JResponse::toString(1);
 }
Example #18
0
 function onAfterDispatch()
 {
     global $_PROFILER;
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     if ($app->isAdmin() || JDEBUG) {
         return;
     }
     if (count($app->getMessageQueue())) {
         return;
     }
     foreach ($this->_exclusions as $exclusion) {
         $count = count($exclusion);
         $our_count = 0;
         foreach ($exclusion as $param) {
             $key = isset($param[0]) ? $param[0] : '';
             $val = isset($param[1]) ? $param[1] : '';
             if ($key && JRequest::getVar($key, null, 'default', 'none', JREQUEST_ALLOWRAW) == $val) {
                 $our_count++;
             }
         }
         if ($count == $our_count) {
             $this->_excluded = true;
             return;
         }
     }
     if ($user->get('guest') && $_SERVER['REQUEST_METHOD'] == 'GET') {
         $this->_cache->setCaching(true);
     }
     $data = $this->_cache->get();
     if ($data !== false) {
         JResponse::setBody($data);
         echo JResponse::toString($app->getCfg('gzip'));
         if (JDEBUG) {
             $_PROFILER->mark('afterCache');
             echo implode('', $_PROFILER->getBuffer());
         }
         $app->close();
     }
 }
 /**
  * Converting the site URL to fit to the HTTP request
  *
  */
 public function onAfterInitialise()
 {
     global $_PROFILER;
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     if ($app->isAdmin()) {
         return;
     }
     $uri = JFactory::getURI()->toString();
     if ($this->isCacheable($uri)) {
         if (count($app->getMessageQueue())) {
             return;
         }
         if ($user->get('guest') && $_SERVER['REQUEST_METHOD'] == 'GET') {
             $this->_cache->setCaching(true);
         }
         if ((int) $this->params->get('use_custom_cache_lifetime', 0)) {
             $this->_cache->setLifeTime((int) $this->params->get('cache_lifetime', 15));
         }
         // Retrieve the Data from the Cache:
         $version = new JVersion();
         // Check the Joomla Version and Execute the appropriate code:
         if ($version->isCompatible('3.0')) {
             $data = $this->_cache->get($this->createId());
         } else {
             $data = $this->_cache->get();
         }
         if ($data !== false) {
             JResponse::setBody($data);
             if (JDEBUG) {
                 $_PROFILER->mark('afterCache');
                 $debugOutput = implode('', $_PROFILER->getBuffer());
             }
             echo JResponse::toString($app->getCfg('gzip'));
             $app->close();
         }
     }
 }
Example #20
0
 public static function raiseError($code, $msg, $info = null)
 {
     // Deprecation warning.
     JLog::add('JError::raiseError() is deprecated.', JLog::WARNING, 'deprecated');
     // set error message
     $error = new JObject();
     $error->errorNum = $code;
     $error->errorMsg = $msg;
     $error->info = $info;
     // set root
     $response = new JObject();
     $response->set('ApiError', $error);
     // set debug
     if (JDEBUG) {
         $debug = new JObject();
         $debug->backtrace = self::renderBacktrace();
         $response->set('debug', $debug);
     }
     $doc = JFactory::getDocument();
     $doc->setBuffer(json_encode($response));
     JResponse::setBody($doc->render());
     echo JResponse::toString();
     jexit();
 }
Example #21
0
 /**
  * Converting the site URL to fit to the HTTP request
  *
  */
 function onAfterInitialise()
 {
     global $mainframe, $_PROFILER;
     if ($mainframe->isAdmin()) {
         return;
     }
     $data = $this->_cache->get();
     if ($data !== false) {
         // the following code searches for a token in the cached page and replaces it with the
         // proper token.
         $user =& JFactory::getUser();
         $token = JUtility::getToken();
         $search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#';
         $replacement = '<input type="hidden" name="' . $token . '" value="1" />';
         $data = preg_replace($search, $replacement, $data);
         JResponse::setBody($data);
         echo JResponse::toString($mainframe->getCfg('gzip'));
         if (JDEBUG) {
             $_PROFILER->mark('afterCache');
             echo implode('', $_PROFILER->getBuffer());
         }
         $mainframe->close();
     }
 }
Example #22
0
 /**
  * Start the zip download
  *
  * @param   string  $filename  saved zip name
  * @param   string  $filepath  server path for zip
  *
  * @return  void
  */
 protected function triggerDownload($filename, $filepath)
 {
     $document = JFactory::getDocument();
     $size = filesize($filepath);
     $document->setMimeEncoding('application/zip');
     $str = file_get_contents($filepath);
     // Set the response to indicate a file download
     JResponse::setHeader('Content-Type', 'application/force-download');
     // JResponse::setHeader('Content-Type', 'application/zip');
     JResponse::setHeader('Content-Length', $size);
     JResponse::setHeader('Content-Disposition', 'attachment; filename="' . basename($filepath) . '"');
     JResponse::setHeader('Content-Transfer-Encoding', 'binary');
     JResponse::setBody($str);
     echo JResponse::toString(false);
 }
Example #23
0
/**
 * We need to refresh the jax token in case System Cache plugin is enable
 */
function azrulOnAfterInitialise()
{
    // If this is ajax call, no need to process this
    $task = JRequest::getWord('task', '');
    if ($task == 'azrul_ajax') {
        return true;
    }
    //Fix the registration issue when the System Cache plugin is enable
    $app = JFactory::getApplication();
    if ($app->getName() != 'site') {
        return true;
    }
    //We only do the replacement for guest users
    $user = JFactory::getUser();
    if ($user->get('guest') && $_SERVER['REQUEST_METHOD'] == 'GET') {
        $config =& JFactory::getConfig();
        $cache_plg = JPluginHelper::getPlugin('system', 'cache');
        if (!is_object($cache_plg)) {
            //cache plugin is disable, no need futher processing
            return;
        }
        jimport('joomla.html.parameter');
        $params = new JParameter($cache_plg->params);
        $options = array('cachebase' => JPATH_BASE . DS . 'cache', 'defaultgroup' => 'page', 'lifetime' => $params->get('cachetime', 15) * 60, 'browsercache' => false, 'caching' => true, 'language' => $config->getValue('config.language', 'en-GB'));
        jimport('joomla.cache.cache');
        $cache = JCache::getInstance('page', $options);
        $data = $cache->get();
        //Only replace if the page is cached before
        if ($data !== false) {
            // the following code searches for a token in the cached page and replaces it with the
            // proper token.
            $token = JUtility::getToken();
            $search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#';
            $replacement = '<input type="hidden" name="' . $token . '" value="1" />';
            $data = preg_replace($search, $replacement, $data);
            $tokenStr = 'var jax_token_var=\'' . JUtility::getToken() . '\';';
            $regex = '#var jax_token_var=\'([A-Za-z0-9-_]+)\';#m';
            $data = preg_replace($regex, $tokenStr, $data);
            JResponse::setBody($data);
            echo JResponse::toString($app->getCfg('gzip'));
            $app->close();
        }
    }
    return true;
}
Example #24
0
 *
 * NOTE :
 */
$mainframe->route();
// trigger the onAfterRoute events
JDEBUG ? $_PROFILER->mark('afterRoute') : null;
$mainframe->triggerEvent('onAfterRoute');
/**
 * DISPATCH THE APPLICATION
 *
 * NOTE :
 */
$option = JAdministratorHelper::findOption();
$mainframe->dispatch($option);
// trigger the onAfterDispatch events
JDEBUG ? $_PROFILER->mark('afterDispatch') : null;
$mainframe->triggerEvent('onAfterDispatch');
/**
 * RENDER THE APPLICATION
 *
 * NOTE :
 */
$mainframe->render();
// trigger the onAfterRender events
JDEBUG ? $_PROFILER->mark('afterRender') : null;
$mainframe->triggerEvent('onAfterRender');
/**
 * RETURN THE RESPONSE
 */
echo JResponse::toString($mainframe->getCfg('gzip'));
Example #25
0
 /**
  * Display a custom error page and exit gracefully
  *
  * @param   object  &$error  Exception object
  *
  * @return  void
  *
  * @deprecated  12.1
  * @since   11.1
  */
 public static function customErrorPage(&$error)
 {
     // Deprecation warning.
     JLog::add('JError::customErrorPage() is deprecated.', JLog::WARNING, 'deprecated');
     // Initialise variables.
     $app = JFactory::getApplication();
     $document = JDocument::getInstance('error');
     if ($document) {
         $config = JFactory::getConfig();
         // Get the current template from the application
         $template = $app->getTemplate();
         // Push the error object into the document
         $document->setError($error);
         // If site is offline and it's a 404 error, just go to index (to see offline message, instead of 404)
         if ($error->getCode() == '404' && JFactory::getConfig()->get('offline') == 1) {
             JFactory::getApplication()->redirect('index.php');
         }
         @ob_end_clean();
         $document->setTitle(JText::_('Error') . ': ' . $error->get('code'));
         $data = $document->render(false, array('template' => $template, 'directory' => JPATH_THEMES, 'debug' => $config->get('debug')));
         // Failsafe to get the error displayed.
         if (empty($data)) {
             self::handleEcho($error, array());
         } else {
             // Do not allow cache
             JResponse::allowCache(false);
             JResponse::setBody($data);
             echo JResponse::toString();
         }
     } else {
         // Just echo the error since there is no document
         // This is a common use case for Command Line Interface applications.
         self::handleEcho($error, array());
     }
     $app->close(0);
 }
Example #26
0
 function display($tpl = null)
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     $this->user = JFactory::getUser();
     $isNewsSitemap = JRequest::getInt('news', 0);
     // $dispatcher	= &JDispatcher::getInstance();
     $layout = $this->getLayout();
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     $this->canEdit = JFactory::getUser()->authorise('core.admin', 'com_xmap');
     // For now, news sitemaps are not editable
     $this->canEdit = $this->canEdit && !$isNewsSitemap;
     if ($layout == 'xsl') {
         return $this->displayXSL($layout);
     }
     // Get model data.
     $this->items = $this->get('Items');
     $this->sitemapItems = $this->get('SitemapItems');
     $this->extensions = $this->get('Extensions');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     // Add router helpers.
     $this->item->slug = $this->item->alias ? $this->item->id . ':' . $this->item->alias : $this->item->id;
     $this->item->rlink = JRoute::_('index.php?option=com_xmap&view=xml&id=' . $this->item->slug);
     // Create a shortcut to the paramemters.
     $params =& $this->state->params;
     $offset = $this->state->get('page.offset');
     if (!$this->item->params->get('access-view')) {
         if ($this->user->get('guest')) {
             // Redirect to login
             $uri = JFactory::getURI();
             $app->redirect('index.php?option=com_users&view=login&return=' . base64_encode($uri), JText::_('Xmap_Error_Login_to_view_sitemap'));
             return;
         } else {
             JError::raiseWarning(403, JText::_('Xmap_Error_Not_auth'));
             return;
         }
     }
     // Override the layout.
     if ($layout = $params->get('layout')) {
         $this->setLayout($layout);
     }
     // Load the class used to display the sitemap
     $this->loadTemplate('class');
     $this->displayer = new XmapXmlDisplayer($params, $this->item);
     $this->displayer->setJView($this);
     $this->displayer->isNews = $isNewsSitemap;
     $this->displayer->canEdit = $this->canEdit;
     $doCompression = $this->item->params->get('compress_xml') && !ini_get('zlib.output_compression') && ini_get('output_handler') != 'ob_gzhandler';
     @ob_end_clean();
     if ($doCompression) {
         ob_start();
     }
     parent::display($tpl);
     $model = $this->getModel();
     $model->hit($this->displayer->getCount());
     if ($doCompression) {
         $data = ob_get_contents();
         JResponse::setBody($data);
         @ob_end_clean();
         echo JResponse::toString(true);
     }
     exit;
 }
Example #27
0
 /**
  * Display a custom error page and exit gracefully
  *
  * @param   object  $error Exception object
  *
  * @return  void
  *
  * @deprecated
  * @since   11.1
  */
 public static function customErrorPage(&$error)
 {
     // Initialise variables.
     jimport('joomla.document.document');
     $app = JFactory::getApplication();
     $document = JDocument::getInstance('error');
     $config = JFactory::getConfig();
     // Get the current template from the application
     $template = $app->getTemplate();
     // Push the error object into the document
     $document->setError($error);
     @ob_end_clean();
     $document->setTitle(JText::_('Error') . ': ' . $error->get('code'));
     $data = $document->render(false, array('template' => $template, 'directory' => JPATH_THEMES, 'debug' => $config->get('debug')));
     // Do not allow cache
     JResponse::allowCache(false);
     JResponse::setBody($data);
     echo JResponse::toString();
     $app->close(0);
 }
Example #28
0
 function t3_init()
 {
     t3import('core.parameter');
     t3import('core.extendable');
     t3import('core.template');
     t3import('core.cache');
     t3import('core.head');
     t3import('core.hook');
     // Remove JDocumentHTML for compatible J1.6 & J1.7
     // if (!class_exists ('JDocumentHTML', false)) t3import ('core.joomla.documenthtml');
     if (!class_exists('JView', false)) {
         t3import('core.joomla.view');
     }
     if (!class_exists('JModuleHelper', false)) {
         t3import('core.joomla.modulehelper');
     }
     // if (! class_exists('JPagination', false)) t3import('core.joomla.pagination');
     //Load template language
     $this->loadLanguage('tpl_' . T3_ACTIVE_TEMPLATE, JPATH_SITE);
     $params = T3Common::get_template_based_params();
     //instance cache object.
     $devmode = $params ? $params->get('devmode', '0') == '1' : false;
     $t3cache = T3Cache::getT3Cache($devmode);
     //Check if enable T3 info mode. Enable by default (if not set)
     if ($params->get('infomode', 1) == 1) {
         if (!JRequest::getCmd('t3info') && JRequest::getCmd('tp') && JComponentHelper::getParams('com_templates')->get('template_positions_display')) {
             JRequest::setVar('t3info', JRequest::getCmd('tp'));
         }
     }
     $key = T3Cache::getPageKey();
     $user =& JFactory::getUser();
     $data = null;
     if ($devmode || JRequest::getCmd('cache') == 'no') {
         $t3cache->setCaching(false);
         JResponse::allowCache(false);
     } else {
         $t3cache->setCaching(true);
         JResponse::allowCache(true);
     }
     // Get cache
     $data = $t3cache->get($key);
     if ($data) {
         $mainframe = JFactory::getApplication();
         // Check HTTP header
         $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) : false;
         $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : false;
         $cache_time = (int) substr($data, 0, 20);
         $etag = md5($key);
         if ($if_modified_since && $if_none_match && $if_modified_since == $cache_time && $if_none_match == $etag) {
             header('HTTP/1.x 304 Not Modified', true);
             $mainframe->close();
         }
         $data = substr($data, 20);
         // Check cached data
         if (!preg_match('#<jdoc:include\\ type="([^"]+)" (.*)\\/>#iU', $data)) {
             $token = JUtility::getToken();
             $search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#';
             $replacement = '<input type="hidden" name="' . $token . '" value="1" />';
             $data = preg_replace($search, $replacement, $data);
             JResponse::setHeader('Last-Modified', gmdate('D, d M Y H:i:s', $cache_time) . ' GMT', true);
             JResponse::setHeader('ETag', $etag, true);
             JResponse::setBody($data);
             echo JResponse::toString($mainframe->getCfg('gzip'));
             if (JDEBUG) {
                 global $_PROFILER;
                 $_PROFILER->mark('afterCache');
                 echo implode('', $_PROFILER->getBuffer());
             }
             $mainframe->close();
         }
     }
     //Preload template
     t3import('core.preload');
     $preload = T3Preload::getInstance();
     $preload->load();
     //$doc = JFactory::getDocument();
     //$t3 = T3Template::getInstance($doc);
     //$t3->_html = $data;
     // Disable joomla cache when browsing by device
     $device = T3Common::mobile_device_detect();
     if ($device !== 'false') {
         $conf = JFactory::getConfig();
         $conf->set('caching', 0);
     }
     // Separate cache when browsing in each device
     /*
     $app = JFactory::getApplication();
     $registeredurlparams = $app->get('registeredurlparams');
     if (empty($registeredurlparams)) {
         $registeredurlparams = new stdClass;
     }
     $registeredurlparams->device = 'CMD';
     $app->set('registeredurlparams', $registeredurlparams);
     JRequest::setVar('device', T3Common::mobile_device_detect());
     */
 }
 /**
  * Returns the response as a string.
  *
  * @return  string  The response
  *
  * @since   11.1
  */
 public function __toString()
 {
     $compress = $this->getCfg('gzip', false);
     return JResponse::toString($compress);
 }
Example #30
0
 /**
  * This method should handle any authentication and report back to the subject
  *
  * @access	public
  * @param   array 	$credentials Array holding the user credentials
  * @param 	array   $options     Array of extra options (return, entry_url)
  * @param	object	$response	Authentication response object
  * @return	boolean
  * @since 1.5
  */
 function onAuthenticate($credentials, $options, &$response)
 {
     $mainframe =& JFactory::getApplication();
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         define('Auth_OpenID_RAND_SOURCE', null);
     } else {
         $f = @fopen('/dev/urandom', 'r');
         if ($f !== false) {
             define('Auth_OpenID_RAND_SOURCE', '/dev/urandom');
             fclose($f);
         } else {
             $f = @fopen('/dev/random', 'r');
             if ($f !== false) {
                 define('Auth_OpenID_RAND_SOURCE', '/dev/urandom');
                 fclose($f);
             } else {
                 define('Auth_OpenID_RAND_SOURCE', null);
             }
         }
     }
     jimport('openid.consumer');
     jimport('joomla.filesystem.folder');
     // Access the session data
     $session =& JFactory::getSession();
     // Create and/or start using the data store
     $store_path = JPATH_ROOT . '/tmp/_joomla_openid_store';
     if (!JFolder::exists($store_path) && !JFolder::create($store_path)) {
         $response->type = JAUTHENTICATE_STATUS_FAILURE;
         $response->error_message = "Could not create the FileStore directory '{$store_path}'. " . " Please check the effective permissions.";
         return false;
     }
     // Create store object
     $store = new Auth_OpenID_FileStore($store_path);
     // Create a consumer object
     $consumer = new Auth_OpenID_Consumer($store);
     if (!isset($_SESSION['_openid_consumer_last_token'])) {
         // Begin the OpenID authentication process.
         if (!($auth_request = $consumer->begin($credentials['username']))) {
             $response->type = JAUTHENTICATE_STATUS_FAILURE;
             $response->error_message = 'Authentication error : could not connect to the openid server';
             return false;
         }
         $sreg_request = Auth_OpenID_SRegRequest::build(array('email'), array('fullname', 'language', 'timezone'));
         if ($sreg_request) {
             $auth_request->addExtension($sreg_request);
         }
         $policy_uris = array();
         if ($this->params->get('phishing-resistant', 0)) {
             $policy_uris[] = 'http://schemas.openid.net/pape/policies/2007/06/phishing-resistant';
         }
         if ($this->params->get('multi-factor', 0)) {
             $policy_uris[] = 'http://schemas.openid.net/pape/policies/2007/06/multi-factor';
         }
         if ($this->params->get('multi-factor-physical', 0)) {
             $policy_uris[] = 'http://schemas.openid.net/pape/policies/2007/06/multi-factor-physical';
         }
         $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
         if ($pape_request) {
             $auth_request->addExtension($pape_request);
         }
         //Create the entry url
         $entry_url = isset($options['entry_url']) ? $options['entry_url'] : JURI::base();
         $entry_url = JURI::getInstance($entry_url);
         unset($options['entry_url']);
         //We don't need this anymore
         //Create the url query information
         $options['return'] = isset($options['return']) ? base64_encode($options['return']) : base64_encode(JURI::base());
         $options[JUtility::getToken()] = 1;
         $process_url = sprintf($entry_url->toString() . "?option=com_user&task=login&username=%s", $credentials['username']);
         $process_url .= '&' . JURI::buildQuery($options);
         $session->set('return_url', $process_url);
         $trust_url = $entry_url->toString(array('path', 'host', 'port', 'scheme'));
         $session->set('trust_url', $trust_url);
         // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
         // form to send a POST request to the server.
         if ($auth_request->shouldSendRedirect()) {
             $redirect_url = $auth_request->redirectURL($trust_url, $process_url);
             // If the redirect URL can't be built, display an error
             // message.
             if (Auth_OpenID::isFailure($redirect_url)) {
                 displayError("Could not redirect to server: " . $redirect_url->message);
             } else {
                 // Send redirect.
                 $mainframe->redirect($redirect_url);
                 return false;
             }
         } else {
             // Generate form markup and render it.
             $form_id = 'openid_message';
             $form_html = $auth_request->htmlMarkup($trust_url, $process_url, false, array('id' => $form_id));
             // Display an error if the form markup couldn't be generated;
             // otherwise, render the HTML.
             if (Auth_OpenID::isFailure($form_html)) {
                 //displayError("Could not redirect to server: " . $form_html->message);
             } else {
                 JResponse::setBody($form_html);
                 echo JResponse::toString($mainframe->getCfg('gzip'));
                 $mainframe->close();
                 return false;
             }
         }
     }
     $result = $consumer->complete($session->get('return_url'));
     switch ($result->status) {
         case Auth_OpenID_SUCCESS:
             $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($result);
             $sreg = $sreg_resp->contents();
             $usermode = $this->params->get('usermode', 2);
             /* in the following code, we deal with the transition from the old openid version to the new openid version
                In the old version, the username was always taken straight from the login form.  In the new version, we get a
                username back from the openid provider.  This is necessary for a number of reasons.  First, providers such as
                yahoo.com allow you to enter only the provider name in the username field (i.e. yahoo.com or flickr.com).  Taking
                this as the username would obviously cause problems because everybody who had an id from yahoo.com would have username
                yahoo.com.  Second, it is necessary because with the old way, we rely on the user entering the id the same every time.
                This is bad because if the user enters the http:// one time and not the second time, they end up as two different users.
                There are two possible settings here - the first setting, is to always use the new way, which is to get the username from
                the provider after authentication.  The second setting is to check if the username exists that we got from the provider.  If it
                doesn't, then we check if the entered username exists.  If it does, then we update the database with the username from the provider
                and continue happily along with the new username.
                We had talked about a third option, which would be to always used the old way, but that seems insecure in the case of somebody using
                a yahoo.com ID.
             */
             if ($usermode && $usermode == 1) {
                 $response->username = $result->getDisplayIdentifier();
             } else {
                 // first, check if the provider provided username exists in the database
                 $db =& JFactory::getDBO();
                 $query = 'SELECT username FROM #__users' . ' WHERE username='******' AND password=\'\'';
                 $db->setQuery($query);
                 $dbresult = $db->loadObject();
                 if ($dbresult) {
                     // if so, we set our username value to the provided value
                     $response->username = $result->getDisplayIdentifier();
                 } else {
                     // if it doesn't, we check if the username from the from exists in the database
                     $query = 'SELECT username FROM #__users' . ' WHERE username='******'username']) . ' AND password=\'\'';
                     $db->setQuery($query);
                     $dbresult = $db->loadObject();
                     if ($dbresult) {
                         // if it does, we update the database
                         $query = 'UPDATE #__users SET username='******' WHERE username='******'username']);
                         $db->setQuery($query);
                         $db->query();
                         if (!$db->query()) {
                             $response->status = JAUTHENTICATE_STATUS_FAILURE;
                             $response->error_message = $db->getErrorMsg();
                             //break out of the switch if we hit an error with our query
                             break;
                         }
                     }
                     $response->username = $result->getDisplayIdentifier();
                     // we return the username provided by the openid provider
                 }
             }
             $response->status = JAUTHENTICATE_STATUS_SUCCESS;
             $response->error_message = '';
             if (!isset($sreg['email'])) {
                 $response->email = str_replace(array('http://', 'https://'), '', $response->username);
                 $response->email = str_replace('/', '-', $response->email);
                 $response->email .= '@openid.';
             } else {
                 $response->email = $sreg['email'];
             }
             $response->fullname = isset($sreg['fullname']) ? $sreg['fullname'] : $response->username;
             $response->language = isset($sreg['language']) ? $sreg['language'] : '';
             $response->timezone = isset($sreg['timezone']) ? $sreg['timezone'] : '';
             break;
         case Auth_OpenID_CANCEL:
             $response->status = JAUTHENTICATE_STATUS_CANCEL;
             $response->error_message = 'Authentication cancelled';
             break;
         case Auth_OpenID_FAILURE:
             $response->status = JAUTHENTICATE_STATUS_FAILURE;
             $response->error_message = 'Authentication failed';
             break;
     }
 }