Code displayed at top of pages

Need help installing Joomla! 3.x? For all Joomla! 3.x installation issues please use this forum. Note: Users creating new sites can use either version 2.5 or 3.x. Please consider the availability of third-party templates and extensions when deciding which Joomla version to use.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
bmichu
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed Feb 12, 2014 1:45 pm

Code displayed at top of pages

Postby bmichu » Wed Feb 12, 2014 1:57 pm

I have created a local install of my website with Xampp. I've got the site running locally, but i have a bunch of code that is displayed at the top of each page (also in admin backend, see below). How can I get rid of that?
Thanks!

params= new JRegistry(); $this->params->loadString($plugin->params, 'JSON'); $this->_cacheEnabled = $this->params->get('cache_enabled'); if ($this->_cacheEnabled === null) $this->_cacheEnabled == 1; $this->_autoflush = $this->params->get('autoFlush'); if ($this->_autoflush === null) $this->_autoflush = 1; $this->_autoflush3rdParty = $this->params->get('autoFlush-ThirdParty'); if ($this->_autoflush3rdParty === null) $this->_autoflush3rdParty = 1; $this->_autoflushClientSide = $this->params->get('autoFlush-ClientSide'); if ($this->_autoflushClientSide === null) $this->_autoflushClientSide = 0; } /** * Heartbeat cache checking function. Will also monitor $_GET for the jSGCache parameter * (pressing the purge cache button in admin) * * * @access public * @return null */ public function onAfterInitialise() { if (!$this->_cacheEnabled) { JResponse::setHeader('X-Cache-Enabled','False',true); } if ($this->_cacheEnabled) { JResponse::setHeader('X-Cache-Enabled','True',true); } //Init the application url $this->_applicationPath = str_replace(array('administrator/index.php','index.php'),'',str_replace($_SERVER['DOCUMENT_ROOT'],'',$_SERVER['SCRIPT_FILENAME'])); //Check for any admin action and proceed to flushMonitor and 3rd party plugins if ( isset($_POST['task']) || isset($_GET['task']) || isset($_GET['cart_virtuemart_product_id'])) { $this->_flushMonitor(); if ($this->_autoflush3rdParty) $this->_monitorThirdPartyPlugins(); } //Check if we have a logged in user and enable cache bypass cookie 'task' => string 'user.login' $user = JFactory::getUser(); if (!$user->guest || (isset($_POST['task']) && preg_match('/login/i', $_POST['task']))) { $_POST[JSession::getFormToken()] = 1; //Force the correct token, since the login box on the page is cached with the 1st visitors' token //Enable the cache bypass for logged users by setting a cache bypass cookie setcookie('jSGCacheBypass',1,time() + 6000,'/'); } if ($user->guest || (isset($_POST['task']) && $_POST['task'] == 'user.logout')) { //Remove the bypass cookie if not a logged user if (isset($_COOKIE['jSGCacheBypass'])) setcookie('jSGCacheBypass',0, time() - 3600,'/'); } // Handle purge button press when get has jSGCache=purge, but only in admin with a logged user if(isset($_GET['jSGCache']) && $_GET['jSGCache'] == 'purge' && JFactory::getApplication()->isAdmin() && !$user->guest ) $this->_purgeCache(true); } /** * Admin panel icon display * * @access public * @param string $context * @return array */ public function onGetIcons( $context ) { return array(array( 'link'=>'?jSGCache=purge', 'image'=>'header/icon-48-purge.png', 'text'=>JText::_('Purge jSGCache'), 'id'=>'jSGCache' )); } /** * Calls the cache server to purge the cache * * @access public * @param string|bool $message Message to be displayed if purge is successful. If this param is false no output would be done * @return null */ private function _purgeCache( $message = true ) { $purgeRequest = $this->_applicationPath . '(.*)'; // Check if caching server is online $hostname = trim(file_get_contents('/etc/sgcache_ip',true)); $cacheServerSocket = fsockopen($hostname, 80, $errno, $errstr, 2); if(!$cacheServerSocket) { JError::raise(E_ERROR,500,JText::_('Connection to cache server failed!')); JError::raise(E_ERROR,500,JText::_($errstr ($errno))); return; } $request = "BAN {$purgeRequest} HTTP/1.0\r\n"; $request .= "Host: {$_SERVER['SERVER_NAME']}\r\n"; $request .= "Connection: Close\r\n\r\n"; fwrite($cacheServerSocket, $request); $response = fgets($cacheServerSocket); fclose($cacheServerSocket); if($message !== false) { if(preg_match('/200/',$response)) { if ($message === true) JFactory::getApplication()->enqueueMessage(JText::_('SG Cache Successfully Purged!')); else JFactory::getApplication()->enqueueMessage(JText::_( $message )); } else { JError::raise(E_NOTICE,501, JText::_('SG Cache: Purge was not successful!')); JError::raise(E_NOTICE,501, jText::_('Error: ' . $response)); } } } /** * 3rd party plugin monitor * * @access private * @return null */ private function _monitorThirdPartyPlugins() { // K2 if ($this->params->get('autoFlush-ThirdParty-K2') == 1) if (isset($_POST['option']) && $_POST['option']=='com_k2') $this->_purgeCache(false); // Kunena if ($this->params->get('autoFlush-ThirdParty-Kunena') == 1) if (isset($_POST['option']) && $_POST['option' ]== 'com_kunena') $this->_purgeCache(false); // VirtueMart if ( (isset($_POST['option']) && $_POST['option'] == 'com_virtuemart') || ( isset($_GET['option']) && $_GET['option'] == 'com_virtuemart' ) || isset($_GET['cart_virtuemart_product_id']) ) { if($this->params->get('autoFlush-ThirdParty-VirtueMart') == 1) $this->_purgeCache(false); } } /** * Action monitor * * @access private * @return null */ private function _flushMonitor() { $user = JFactory::getUser(); if ((!JFactory::getApplication()->isAdmin() && !$this->_autoflushClientSide) || $user->guest) return; $autoflush = $this->params->get('autoFlush'); if ($autoflush === null) $autoflush = 1; if (isset($_POST['task']) && $_POST['task'] && !in_array($_POST['task'],self::$_ignoreTasks) && $autoflush == 1) $this->_purgeCache(false); } }

User avatar
brian
Joomla! Master
Joomla! Master
Posts: 11540
Joined: Fri Aug 12, 2005 7:19 am
Location: Leeds, UK
Contact:

Re: Code displayed at top of pages

Postby brian » Wed Feb 12, 2014 2:32 pm

Go to the plugin manager and dsiable the System - jSGCache plugin
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/

bmichu
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed Feb 12, 2014 1:45 pm

Re: Code displayed at top of pages

Postby bmichu » Wed Feb 12, 2014 3:20 pm

You're the man!!
Thanks a lot!

Does this mean, that the jSGCache plugin does not work on a local install? Because I've copied my site one-to-one....?

User avatar
brian
Joomla! Master
Joomla! Master
Posts: 11540
Joined: Fri Aug 12, 2005 7:19 am
Location: Leeds, UK
Contact:

Re: Code displayed at top of pages

Postby brian » Wed Feb 12, 2014 3:28 pm

Yes thats exactly correct
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/

ClueMan
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sat Oct 24, 2015 11:27 pm

Re: Code displayed at top of pages

Postby ClueMan » Sat Oct 24, 2015 11:30 pm

Thank you so much for both posting and answering this question!

ultimezabdul
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Wed Oct 28, 2015 10:23 am
Location: India
Contact:

Re: Code displayed at top of pages

Postby ultimezabdul » Wed Oct 28, 2015 10:27 am

Thank you Brian, even i was facing the same issues.

User avatar
cybervigilante
Joomla! Explorer
Joomla! Explorer
Posts: 493
Joined: Mon Apr 23, 2007 11:59 pm
Location: Apache Junction, AZ
Contact:

Re: Code displayed at top of pages

Postby cybervigilante » Wed Apr 06, 2016 5:43 pm

Of course, the supercacher is one of the enticements for paying siteground more, so they need to fix it. I also have xampp and it bombed locally. But does this mean a restore would work on the remote for some reason? Both local and remote use the same php, so it seems odd that it would only bomb locally. I'd use wamp but they make you install a ton of msoft runtimes, and it still died ;')
Arguing with trolls is like watering bricks and expecting flowers.

Eugeniotibi
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Sat May 20, 2017 10:51 pm

Re: Code displayed at top of pages

Postby Eugeniotibi » Thu Jun 08, 2017 11:02 pm

I have the same problem AND i can't access the administrator to disable the plugin.
When I try to access i get
<<
params= new JRegistry(); $this->params->loadString($plugin->params, 'JSON'); $this->_cacheEnabled = $this->params->get('cache_enabled'); if ($this->_cacheEnabled === null) $this->_cacheEnabled == 1; $this->_autoflush = $this->params->get('autoFlush'); if ($this->_autoflush === null) $this->_autoflush = 1; $this->_autoflush3rdParty = $this->params->get('autoFlush-ThirdParty'); if ($this->_autoflush3rdParty === null) $this->_autoflush3rdParty = 1; $this->_autoflushClientSide = $this->params->get('autoFlush-ClientSide'); if ($this->_autoflushClientSide === null) $this->_autoflushClientSide = 0; } /** * Heartbeat cache checking function. Will also monitor $_GET for the jSGCache parameter * (pressing the purge cache button in admin) * * * @access public * @return null */ public function onAfterInitialise() { if (!$this->_cacheEnabled || $this->_isBlacklisted($this->_applicationPath)) { JResponse::setHeader('X-Cache-Enabled','False',true); return; } if ($this->_cacheEnabled) { JResponse::setHeader('X-Cache-Enabled','True',true); } //Init the application url $this->_applicationPath = str_replace(array('administrator/index.php','index.php'),'',str_replace($_SERVER['DOCUMENT_ROOT'],'',$_SERVER['SCRIPT_FILENAME'])); //Check for any admin action and proceed to flushMonitor and 3rd party plugins if ( isset($_POST['task']) || isset($_GET['task']) || isset($_GET['cart_virtuemart_product_id'])) { $this->_flushMonitor(); if ($this->_autoflush3rdParty) $this->_monitorThirdPartyPlugins(); } //Check if we have a logged in user and enable cache bypass cookie 'task' => string 'user.login' $user = JFactory::getUser(); if (!$user->guest || (isset($_POST['task']) && preg_match('/login/i', $_POST['task']))) { $_POST[JSession::getFormToken()] = 1; //Force the correct token, since the login box on the page is cached with the 1st visitors' token //Enable the cache bypass for logged users by setting a cache bypass cookie setcookie('jSGCacheBypass',1,time() + 6000,'/'); } if ($user->guest || (isset($_POST['task']) && $_POST['task'] == 'user.logout')) { //Remove the bypass cookie if not a logged user if (isset($_COOKIE['jSGCacheBypass'])) setcookie('jSGCacheBypass',0, time() - 3600,'/'); } // Handle purge button press when get has jSGCache=purge, but only in admin with a logged user if(isset($_GET['jSGCache']) && $_GET['jSGCache'] == 'purge' && JFactory::getApplication()->isAdmin() && !$user->guest ) $this->_purgeCache(true); } /** * Admin panel icon display * * @access public * @param string $context * @return array */ public function onGetIcons( $context ) { return array(array( 'link'=>'?jSGCache=purge', 'image'=>'header/icon-48-purge.png', 'text'=>JText::_('Purge jSGCache'), 'id'=>'jSGCache' )); } /** * Calls the cache server to purge the cache * * @access public * @param string|bool $message Message to be displayed if purge is successful. If this param is false no output would be done * @return null */ private function _purgeCache( $message = true ) { $purgeRequest = $this->_applicationPath . '(.*)'; // Check if caching server is varnish or nginx. $sgcache_ip = '/etc/sgcache_ip'; $hostname = $_SERVER['SERVER_ADDR']; $purge_method = "PURGE"; if (file_exists($sgcache_ip)) { $hostname = trim( file_get_contents( $sgcache_ip, true ) ); $purge_method = "BAN"; } $cacheServerSocket = fsockopen($hostname, 80, $errno, $errstr, 2); if(!$cacheServerSocket) { JError::raise(E_ERROR,500,JText::_('Connection to cache server failed!')); JError::raise(E_ERROR,500,JText::_($errstr ($errno))); return; } $request = "$purge_method {$purgeRequest} HTTP/1.0\r\nHost: {$_SERVER['SERVER_NAME']}\r\nConnection: Close\r\n\r\n"; if (preg_match('/^www\./',$_SERVER['SERVER_NAME'])) { $domain_no_www = preg_replace('/^www\./', '', $_SERVER['SERVER_NAME']); $request2 = "$purge_method {$purgeRequest} HTTP/1.0\r\nHost: {$domain_no_www}\r\nConnection: Close\r\n\r\n"; } else $request2 = "$purge_method {$purgeRequest} HTTP/1.0\r\nHost: www.{$_SERVER['SERVER_NAME']}\r\nConnection: Close\r\n\r\n"; fwrite($cacheServerSocket, $request); $response = fgets($cacheServerSocket); fclose($cacheServerSocket); $cacheServerSocket = fsockopen($hostname, 80, $errno, $errstr, 2); fwrite($cacheServerSocket, $request2); fclose($cacheServerSocket); if($message !== false) { if(preg_match('/200/',$response)) { if ($message === true) JFactory::getApplication()->enqueueMessage(JText::_('SG Cache Successfully Purged!')); else JFactory::getApplication()->enqueueMessage(JText::_( $message )); } else { JError::raise(E_NOTICE,501, JText::_('SG Cache: Purge was not successful!')); JError::raise(E_NOTICE,501, jText::_('Error: ' . $response)); } } } /** * Check if url is in caching blacklist * * @param string $applicationPath * * @return bool */ private function _isBlacklisted($applicationPath) { $blacklistArray = explode("\n",$this->params->get('blacklist')); $blacklistRegexArray = array(); $indexIsBlacklisted = false; foreach($blacklistArray as $key=>$row) { $row = trim($row); if ($row != '/' && $quoted = preg_quote($row,'/')) $blacklistRegexArray[$key] = $quoted; if ($row == '/') $indexIsBlacklisted = true; } if ($indexIsBlacklisted && $_SERVER['REQUEST_URI'] == $applicationPath) return true; if (empty($blacklistRegexArray)) return false; $blacklistRegex = '/('.implode('|',$blacklistRegexArray) . ')/i'; return preg_match($blacklistRegex, $_SERVER['REQUEST_URI']); } /** * 3rd party plugin monitor * * @access private * @return null */ private function _monitorThirdPartyPlugins() { // Kunena & K2 if ($this->params->get('autoFlush-ThirdParty') == 1 && isset($_POST['option']) && ($_POST['option']=='com_k2' || $_POST['option' ]== 'com_kunena')) { $this->_purgeCache(false); } // VirtueMart if ( (isset($_POST['option']) && $_POST['option'] == 'com_virtuemart') || ( isset($_GET['option']) && $_GET['option'] == 'com_virtuemart' ) || isset($_GET['cart_virtuemart_product_id']) ) { if($this->params->get('autoFlush-ThirdParty') == 1) $this->_purgeCache(false); } } /** * Action monitor * * @access private * @return null */ private function _flushMonitor() { $user = JFactory::getUser(); if ((!JFactory::getApplication()->isAdmin() && !$this->_autoflushClientSide) || $user->guest) return; $autoflush = $this->params->get('autoFlush'); if ($autoflush === null) $autoflush = 1; if (isset($_POST['task']) && $_POST['task'] && !in_array($_POST['task'],self::$_ignoreTasks) && $autoflush == 1) $this->_purgeCache(false); } }

Rawson Group

Error
Se ha producido un error.
0 Failed to start the session because headers have already been sent by "C:\wamp64\www\rawson\plugins\system\jSGCache\jSGCache.php" at line 1.
Volver al panel de control
>>

Any ideas please? Txs in advance.

In production I ran php 7.0.19
in wamp php 7.0.20.

Zollaa1
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sun Feb 25, 2018 10:04 am

Re: Code displayed at top of pages

Postby Zollaa1 » Sun Feb 25, 2018 10:10 am

It is late to answer this but anyway: You should just simply delete that plugin folder (jSGCache plugin) from plugins -> system and the site will work (appear) without problem.

User avatar
JAVesey
Joomla! Ace
Joomla! Ace
Posts: 1636
Joined: Tue May 14, 2013 1:21 pm
Location: Cardiff, Wales, UK
Contact:

Re: Code displayed at top of pages

Postby JAVesey » Sun Feb 25, 2018 1:18 pm

cybervigilante wrote:Of course, the supercacher is one of the enticements for paying siteground more, so they need to fix it.
Supercacher and the jSGCache plugin are not the same thing.

Supercacher works at server level and nothing is installed to a user's Joomla system. Using this does not cause any issues with a local installation and it seems to work well on live sites.

I had problems with the jSGCache plugin so uninstalled it on my "live" site. Can't honestly say that I noticed any difference with or without it (I guess it must do something!), but I would use it if it didn't cause local site issues.
John V
Cardiff, Wales, UK
Website: https://www.llanmon.org.uk (Joomla 3.8.7)


Return to “Installation Joomla! 3.x”

Who is online

Users browsing this forum: No registered users and 7 guests