Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Topic started by: madler on June 21, 2006, 09:27:41 AM

Title: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: madler on June 21, 2006, 09:27:41 AM
SMF Version: SMF 1.0.7

I just started getting this, and only this when trying to access my forum that has been working fine for months, currently running SMF 1.0.7:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/madler/public_html/aacit/forum/Sources/QueryString.php on line 317

I have made no changes, and my hosting service swears that there have been no changes or updates to PHP or MySQL.  A small PHP test page works fine.

Anyone out there know what this is?
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: TiyulTalk on June 21, 2006, 12:04:18 PM
I just started getting the same message (exact text below) when I try to access any page on my site.  It worked fine an hour ago and I haven't changed anything.  Using SMF 1.07.

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /.../.../.../.../smf/Sources/QueryString.php on line 317

Anyone know what's causing this and how to fix it?  Thank you.
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: madler on June 23, 2006, 07:37:44 PM
Just to bring this up front again to see if anyone has an answer ...
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: kegobeer on June 23, 2006, 07:48:02 PM
Check your Settings.php file.  If it is corrupted, replace it with Settings_bak.php.
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: madler on June 23, 2006, 10:15:17 PM
Quote from: kegobeer on June 23, 2006, 07:48:02 PM
Check your Settings.php file.  If it is corrupted, replace it with Settings_bak.php.

Ok, I tried that.  At least it changed the error a little bit:

Parse error: syntax error, unexpected T_STRING in /home/madler/public_html/aacit/forum/Settings.php on line 28
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: kegobeer on June 23, 2006, 10:21:51 PM
Open Settings.php and look at line 28.  It should be this:


$mmessage = 'Ok faithful users...we\'re attempting to restore an older backup of the database...news will be posted once we\'re back!'; # Description of why the forum is in maintenance mode.


Look at the rest of the file and make sure nothing is corrupted.  Lines 38-42 should have your MySQL database connection information.
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: madler on June 23, 2006, 10:37:11 PM
Quote from: kegobeer on June 23, 2006, 10:21:51 PM
Open Settings.php and look at line 28.
...
Look at the rest of the file and make sure nothing is corrupted.  Lines 38-42 should have your MySQL database connection information.

I did a diff of Settings_bak.php and Settings.php, and saw the added backslashes.  I fixed that in Settings_bak.php and made it Settings.php.  Then accessing the forum produced a blank page!  Viewing the source of that page is blank as well.  Not even any non-displaying tags.

The other differences between the two Settings.php are some indentation changes, and a very long line starting with "error_reporting(0);" in the one that gives the blank page.

I also found a script on this forum called repair_settings.php.  I tried that as well, but to no avail.

So how exactly do I "Look at the rest of the file and make sure nothing else is corrupted"?  What would I be looking for?

Following is the offending Settings.php file that results in the error on the subject line of these posts:

<?php
/******************************************************************************
* Settings.php                                                                *
*******************************************************************************
* SMF: Simple Machines Forum                                                  *
* Open-Source Project Inspired by Zef Hemel ([email protected])                *
* =========================================================================== *
* Software Version:           SMF 1.0                                         *
* 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.    *
******************************************************************************/

########## Maintenance ##########
# Note: If $maintenance is set to 2, the forum will be unusable!  Change it to 0 to fix it.
$maintenance 0;               # Set to 1 to enable Maintenance Mode, 2 to make the forum untouchable. (you'll have to make it 0 again manually!)
$mtitle 'Maintenance Mode';           # Title for the Maintenance Mode message.
$mmessage 'Ok faithful users...we\'re attempting to restore an older backup of the database...news will be posted once we\'re back!';         # Description of why the forum is in maintenance mode.

########## Forum Info ##########
$mbname 'Caltech/JPL Flying Club';            # The name of your forum.
$language 'english';          # The default language file set for the forum.
$boardurl 'http://aacit.org/forum';           # URL to your forum's folder. (without the trailing /!)
$webmaster_email '[email protected]';         # Email address to send emails from. (like [email protected].)
$cookiename 'SMFCookie10';            # Name of the cookie to set for authentication.

########## Database Info ##########
$db_server 'localhost';
$db_name 'madler_smf1';
$db_user 'madler_smf1';
$db_passwd 'REMOVED BY AMACYTHE';
$db_prefix 'smf_';
$db_persist 0;
$db_error_send 1;

########## Directories/Files ##########
# Note: These directories do not have to be changed unless you move things.
$boarddir '/home/madler/public_html/aacit/forum';             # The absolute path to the forum's folder. (not just '.'!)
$sourcedir '/home/madler/public_html/aacit/forum/Sources';            # Path to the Sources directory.

########## Error-Catching ##########
# Note: You shouldn't touch these settings.
$db_last_error 0;

# Make sure the paths are correct... at least try to fix them.
if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt'))
        $boarddir dirname(__FILE__);
if (!
file_exists($sourcedir) && file_exists($boarddir '/Sources'))
        $sourcedir $boarddir '/Sources';

?>



Edit: You don't want to display your db password for everyone that reads our boards!

Reply: Oh yeah, thanks.
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: JayBachatero on June 24, 2006, 01:39:19 AM
If oyu don't have any mods installed reupload index.php.
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: madler on June 24, 2006, 04:11:37 AM
Quote from: JayBachatero on June 24, 2006, 01:39:19 AM
If oyu don't have any mods installed reupload index.php.

Alas, no joy.  The behavior was unchanged.
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: Daniel15 on June 24, 2006, 05:53:24 AM
QuoteThe other differences between the two Settings.php are some indentation changes, and a very long line starting with "error_reporting(0);" in the one that gives the blank page.
error_reporting(0); turns off error reporting, so that's why the page is blank (you don't see that error).

Regarding the error:
Quote
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/madler/public_html/aacit/forum/Sources/QueryString.php on line 317

Please paste lines 310-320 here (preferably in a pastebin such as http://pastebin.dansoftaustralia.net/ ) so we can see what's causing the error.
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: madler on June 24, 2006, 12:22:50 PM
Quote from: daniel15 on June 24, 2006, 05:53:24 AM
Please paste lines 310-320 here ...

Thanks for your help.  Here they are from line 303 to the end of the file, with the lines prefixed by the line number.  Line 319 turns out to be a comment, so there must be something wrong just before that.

303:// Rewrite URLs to include the session ID.
304:function ob_sessrewrite($buffer)
305:{
306:global $scripturl, $modSettings, $user_info, $context;
307:
308:// If $scripturl is set to nothing, or the SID is not defined (SSI?) just quit.
309:if ($scripturl == '' || !defined('SID'))
310:return $buffer;
311:
312:// Do nothing if the session is cookied, or they are a crawler - guests are caught by redirectexit().  This doesn't work below PHP 4.3.0, because it makes the output buffer bigger.
313:if (empty($_COOKIE) && SID != '' && (!$user_info['is_guest'] || (strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false)) && @version_compare(PHP_VERSION, '4.3.0') != -1)
314:$buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '(?!?' . preg_quote(SID, '/') . ')(?)?/', '"' . $scripturl . '?' . SID . '&amp;', $buffer);
315:// You can't do both, because session_start() won't catch the session if you do.  But this should work even in 4.2.x, just not CGI.
316:elseif (!empty($modSettings['queryless_urls']) && !$context['server']['is_cgi'] && $context['server']['is_apache'])
317:$buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '?((?:board|topic)=[^#"]+)(#[^"]*)?"/e', "'"' . $scripturl . '/' . strtr('$1', '&;=', '//,') . '.html$2"'", $buffer);
318:
319:// Return the changed buffer.
320:return $buffer;
321:}
322:
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: JayBachatero on June 24, 2006, 02:03:11 PM
Reupload your QueryString.php file.  You are missing a whole chunk of lines.  That section of code is in the 400 lines not 300.
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: madler on June 24, 2006, 05:21:48 PM
Quote from: JayBachatero on June 24, 2006, 02:03:11 PM
Reupload your QueryString.php file.  You are missing a whole chunk of lines.  That section of code is in the 400 lines not 300.

You mean it's supposed to be in the 400's.  Here's the whole thing with line numbers:

1:<?php
2
:/******************************************************************************
3:* QueryString.php                                                             *
4:*******************************************************************************
5:* SMF: Simple Machines Forum                                                  *
6:* Open-Source Project Inspired by Zef Hemel ([email protected])                *
7:* =========================================================================== *
8:* Software Version:           SMF 1.0.7                                       *
9:* Software by:                Simple Machines (http://www.simplemachines.org) *
10:* Copyright 2001-2004 by:     Lewis Media (http://www.lewismedia.com)         *
11:* Support, News, Updates at:  http://www.simplemachines.org                   *
12:*******************************************************************************
13:* This program is free software; you may redistribute it and/or modify it     *
14:* under the terms of the provided license as published by Lewis Media.        *
15:*                                                                             *
16:* This program is distributed in the hope that it is and will be useful,      *
17:* but WITHOUT ANY WARRANTIES; without even any implied warranty of            *
18:* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                        *
19:*                                                                             *
20:* See the "license.txt" file for details of the Simple Machines license.      *
21:* The latest version can always be found at http://www.simplemachines.org.    *
22:******************************************************************************/
23:if (!defined('SMF'))
24:die('Hacking attempt...');
25:
26:/* This file does a lot of important stuff.  Mainly, this means it handles
27:the query string, request variables, and session management.  It contains
28:the following functions:
29:
30:void cleanRequest()
31:- cleans the request variables (ENV, GET, POST, COOKIE, SERVER) and
32:makes sure the query string was parsed correctly.
33:- handles the URLs passed by the queryless URLs option.
34:- makes sure, regardless of php.ini, everything has slashes.
35:- sets up $board, $topic, and $scripturl and $_REQUEST['start'].
36:- determines, or rather tries to determine, the client's IP.
37:
38:array addslashes__recursive(array var)
39:- returns the var, as an array or string, with slashes.
40:- importantly adds slashes to keys and values!
41:- calls itself recursively if necessary.
42:
43:array htmlspecialchars__recursive(array var)
44:- adds entities (&quot;, &lt;, &gt;) to the array or string var.
45:- importantly, does not effect keys, only values.
46:- calls itself recursively if necessary.
47:
48:array urldecode__recursive(array var)
49:- takes off url encoding (%20, etc.) from the array or string var.
50:- importantly, does it to keys too!
51:- calls itself recursively if there are any sub arrays.
52:
53:array stripslashes__recursive(array var)
54:- removes slashes, recursively, from the array or string var.
55:- effects both keys and values of arrays.
56:- calls itself recursively to handle arrays of arrays.
57:
58:array htmltrim__recursive(array var)
59:- trims a string or an the var array using html characters as well.
60:- does not effect keys, only values.
61:- may call itself recursively if needed.
62:
63:string ob_sessrewrite(string buffer)
64:- rewrites the URLs outputted to have the session ID, if the user
65:is not accepting cookies and is using a standard web browser.
66:- handles rewriting URLs for the queryless URLs option.
67:- can be turned off entirely by setting $scripturl to an empty
68:string, ''. (it wouldn't work well like that anyway.)
69:- because of bugs in certain builds of PHP, does not function in
70:versions lower than 4.3.0 - please upgrade if this hurts you.
71:*/
72:
73:// Clean the request variables - add html entities to GET and slashes if magic_quotes_gpc is Off.
74:function cleanRequest()
75:{
76:global $board$topic$boardurl$scripturl;
77:
78:// Makes it easier to refer to things this way.
79:$scripturl $boardurl '/index.php';
80:
81:// Save some memory.. (since we don't use these anyway.)
82:unset($GLOBALS['HTTP_POST_VARS']);
83:unset($GLOBALS['HTTP_POST_FILES']);
84:
85:// Get the correct query string.  It may be in an environment variable...
86:if (!isset($_SERVER['QUERY_STRING']))
87:$_SERVER['QUERY_STRING'] = getenv('QUERY_STRING');
88:
89:// There's no query string, but there is a URL... try to get the data from there.
90:if (empty($_SERVER['QUERY_STRING']) && !empty($_SERVER['REQUEST_URI']))
91:{
92:// Remove the .html, assuming there is one.
93:if (substr($_SERVER['REQUEST_URI'], strrpos($_SERVER['REQUEST_URI'], '.'), 4) == '.htm')
94:$_SERVER['REQUEST_URI'] = substr($_SERVER['REQUEST_URI'], 0strrpos($_SERVER['REQUEST_URI'], '.'));
95:
96:// Replace 'index.php/a,b/c/d,e' with 'a=b&c=&d=e' and parse it into $_GET.
97:parse_str(substr(preg_replace('/&(w+)(&|z)/''&$1=$2'strtr(substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], basename($scripturl)) + strlen(basename($scripturl))), '/,''&=')), 1), $_GET);
98:}
99:// Are we going to need to parse the ; out?
100:elseif ((strpos(@ini_get('arg_separator.input'), ';') === false || @version_compare(PHP_VERSION'4.2.0') == -1) && !empty($_SERVER['QUERY_STRING']))
101:{
102:// Get rid of the old one!  You don't know where it's been!
103:$_GET = array();
104:
105:// Was this redirected?  If so, get the REDIRECT_QUERY_STRING.
106:$_SERVER['QUERY_STRING'] = urldecode(substr($_SERVER['QUERY_STRING'], 05) == 'url=/' $_SERVER['REDIRECT_QUERY_STRING'] : $_SERVER['QUERY_STRING']);
107:
108:// Replace ';' with '&' and '&something&' with '&something=&'.  (this is done for compatibility...)
109:parse_str(preg_replace('/&(w+)(&|$)/''&$1=$2'strtr($_SERVER['QUERY_STRING'], ';''&')), $_GET);
110:}
111:elseif (strpos(@ini_get('arg_separator.input'), ';') !== false)
112:{
113:$_GET urldecode__recursive($_GET);
114:
115:if (get_magic_quotes_gpc() != 0)
116:$_GET stripslashes__recursive($_GET);
117:}
118:
119:// Add entities to GET.  This is kinda like the slashes on everything else.
120:$_GET htmlspecialchars__recursive($_GET);
121:
122:// Clean up after annoying ini settings.  (magic_quotes_gpc might be off...)
123:if (get_magic_quotes_gpc() == 0)
124:{
125:// E(G)PCS: ENV, (GET was already done), POST, COOKIE, SERVER.
126:$_ENV addslashes__recursive($_ENV);
127:$_POST addslashes__recursive($_POST);
128:$_COOKIE addslashes__recursive($_COOKIE);
129:
130:// FILES work like this: k -> name -> array.  So be careful.
131:foreach ($_FILES as $k => $dummy)
132:$_FILES[$k]['name'] = addslashes__recursive($_FILES[$k]['name']);
133:}
134:
135:// Take care of the server variables.
136:$_SERVER addslashes__recursive($_SERVER);
137:
138:// Let's not depend on the ini settings... why even have COOKIE in there, anyway?
139:$_REQUEST $_POST $_GET;
140:
141:// Make sure $board and $topic are numbers.
142:if (isset($_REQUEST['board']))
143:{
144:// If there's a slash in it, we've got a start value! (old, compatible links.)
145:if (strpos($_REQUEST['board'], '/') !== false)
146:list ($_REQUEST['board'], $_REQUEST['start']) = explode('/'$_REQUEST['board']);
147:// Same idea, but dots.  This is the currently used format - ?board=1.0...
148:elseif (strpos($_REQUEST['board'], '.') !== false)
149:list ($_REQUEST['board'], $_REQUEST['start']) = explode('.'$_REQUEST['board']);
150:// Now make absolutely sure it's a number.
151:$board = (int) $_REQUEST['board'];
152:
153:// This is for "Who's Online" because it might come via POST - and it should be an int here.
154:$_GET['board'] = $board;
155:}
156:// Well, $board is going to be a number no matter what.
157:else
158:$board 0;
159:
160:// If there's a threadid, it's probably an old YaBB SE link.  Flow with it.
161:if (isset($_REQUEST['threadid']) && !isset($_REQUEST['topic']))
162:$_REQUEST['topic'] = $_REQUEST['threadid'];
163:
164:// We've got topic!
165:if (isset($_REQUEST['topic']))
166:{
167:// Slash means old, beta style, formatting.  That's okay though, the link should still work.
168:if (strpos($_REQUEST['topic'], '/') !== false)
169:list ($_REQUEST['topic'], $_REQUEST['start']) = explode('/'$_REQUEST['topic']);
170:// Dots are useful and fun ;).  This is ?topic=1.15.
171:elseif (strpos($_REQUEST['topic'], '.') !== false)
172:list ($_REQUEST['topic'], $_REQUEST['start']) = explode('.'$_REQUEST['topic']);
173:
174:$topic = (int) $_REQUEST['topic'];
175:
176:// Now make sure the online log gets the right number.
177:$_GET['topic'] = $topic;
178:}
179:
180:// There should be a $_REQUEST['start'], some at least.  If you need to default to other than 0, use $_GET['start'].
181:if (empty($_REQUEST['start']) || $_REQUEST['start'] < 0)
182:$_REQUEST['start'] = 0;
183:
184:// Find the user's IP address. (but don't let it give you 'unknown'!)
185:if (!empty($_SERVER['HTTP_CLIENT_IP']) && preg_match('~^((0|10|172.16|192.168|255|127.0).|unknown)~'$_SERVER['HTTP_CLIENT_IP']) == 0)
186:{
187:// Since they are in different blocks, it's probably reversed.
188:if (strtok($_SERVER['REMOTE_ADDR'], '.') != strtok($_SERVER['HTTP_CLIENT_IP'], '.'))
189:$_SERVER['REMOTE_ADDR'] = implode('.'array_reverse(explode('.'$_SERVER['HTTP_CLIENT_IP'])));
190:else
191:$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CLIENT_IP'];
192:}
193:elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
194:{
195:// If there are commas, get the last one.. probably.
196:if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',') !== false)
197:{
198:$ips array_reverse(explode(', '$_SERVER['HTTP_X_FORWARDED_FOR']));
199:
200:// Go through each IP...
201:foreach ($ips as $i => $ip)
202:{
203:// Make sure it's in a valid range...
204:if (preg_match('~^((0|10|172.16|192.168|255|127.0).|unknown)~'$ip) != 0)
205:continue;
206:
207:// Otherwise, we've got an IP!
208:$_SERVER['REMOTE_ADDR'] = trim($ip);
209:break;
210:}
211:}
212:// Otherwise just use the only one.
213:elseif (preg_match('~^((0|10|172.16|192.168|255|127.0).|unknown)~'$_SERVER['HTTP_X_FORWARDED_FOR']) == 0)
214:$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
215:}
216:
217:// Make sure REQUEST_URI is set.
218:if (empty($_SERVER['REQUEST_URI']))
219:$_SERVER['REQUEST_URI'] = $scripturl . (!empty($_SERVER['QUERY_STRING']) ? '?' $_SERVER['QUERY_STRING'] : '');
220:
221:// And make sure HTTP_USER_AGENT is set.
222:$_SERVER['HTTP_USER_AGENT'] = isset($_SERVER['HTTP_USER_AGENT']) ? htmlspecialchars(stripslashes($_SERVER['HTTP_USER_AGENT']), ENT_QUOTES) : '';
223:
224:// Some final checking.
225:if (preg_match('~^((([1]?d)?d|2[0-4]d|25[0-5]).){3}(([1]?d)?d|2[0-4]d|25[0-5])$~'$_SERVER['REMOTE_ADDR']) === 0)
226:$_SERVER['REMOTE_ADDR'] = '';
227:}
228:
229:// Adds slashes to the array/variable.  Uses two underscores to guard against overloading.
230:function addslashes__recursive($var)
231:{
232:if (!is_array($var))
233:return addslashes($var);
234:
235:// Reindex the array with slashes.
236:$new_var = array();
237:
238:// Add slashes to every element, even the indexes!
239:foreach ($var as $k => $v)
240:$new_var[addslashes($k)] = addslashes__recursive($v);
241:
242:return $new_var;
243:}
244:
245:// Adds html entities to the array/variable.  Uses two underscores to guard against overloading.
246:function htmlspecialchars__recursive($var)
247:{
248:if (!is_array($var))
249:return htmlspecialchars($varENT_QUOTES);
250:
251:// Add the htmlspecialchars to every element.
252:foreach ($var as $k => $v)
253:$var[$k] = htmlspecialchars__recursive($v);
254:
255:return $var;
256:}
257:
258:// Removes url stuff from the array/variable.  Uses two underscores to guard against overloading.
259:function urldecode__recursive($var)
260:{
261:if (!is_array($var))
262:return urldecode($var);
263:
264:// Reindex the array...
265:$new_var = array();
266:
267:// Add the htmlspecialchars to every element.
268:foreach ($var as $k => $v)
269:$new_var[urldecode($k)] = urldecode__recursive($v);
270:
271:return $new_var;
272:}
273:// Strips the slashes off any array or variable.  Two underscores for the normal reason.
274:function stripslashes__recursive($var)
275:{
276:if (!is_array($var))
277:return stripslashes($var);
278:
279:// Reindex the array without slashes, this time.
280:$new_var = array();
281:
282:// Strip the slashes from every element.
283:foreach ($var as $k => $v)
284:$new_var[stripslashes($k)] = stripslashes__recursive($v);
285:
286:return $new_var;
287:}
288:
289:// Trim a string including the HTML space, character 160.
290:function htmltrim__recursive($var)
291:{
292:// Remove spaces (32), tabs (9), returns (13, 10, and 11), nulls (0), and hard spaces. (160)
293:if (!is_array($var))
294:return trim($var" tnrx0B0xA0");
295:
296:// Go through all the elements and remove the whitespace.
297:foreach ($var as $k => $v)
298:$var[$k] = htmltrim__recursive($v);
299:
300:return $var;
301:}
302:
303:// Rewrite URLs to include the session ID.
304:function ob_sessrewrite($buffer)
305:{
306:global $scripturl$modSettings$user_info$context;
307:
308:// If $scripturl is set to nothing, or the SID is not defined (SSI?) just quit.
309:if ($scripturl == '' || !defined('SID'))
310:return $buffer;
311:
312:// Do nothing if the session is cookied, or they are a crawler - guests are caught by redirectexit().  This doesn't work below PHP 4.3.0, because it makes the output buffer bigger.
313:if (empty($_COOKIE) && SID != '' && (!$user_info['is_guest'] || (strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false)) && @version_compare(PHP_VERSION'4.3.0') != -1)
314:$buffer preg_replace('/"' preg_quote($scripturl'/') . '(?!?' preg_quote(SID'/') . ')(?)?/''"' $scripturl '?' SID '&amp;'$buffer);
315:// You can't do both, because session_start() won't catch the session if you do.  But this should work even in 4.2.x, just not CGI.
316:elseif (!empty($modSettings['queryless_urls']) && !$context['server']['is_cgi'] && $context['server']['is_apache'])
317:$buffer preg_replace('/"' preg_quote($scripturl'/') . '?((?:board|topic)=[^#"]+)(#[^"]*)?"/e'"'"' . $scripturl . '/' . strtr('$1', '&;=', '//,') . '.html$2"'", $buffer);
318:
319:// Return the changed buffer.
320:return $buffer;
321:}
322:

Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: winrules on June 24, 2006, 05:42:42 PM
Did you reupload the file?
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: madler on June 24, 2006, 08:56:11 PM
Quote from: winrules on June 24, 2006, 05:42:42 PM
Did you reupload the file?

Ah, I thought he meant reupload it to this forum.  Now I get it.  (I'm a little slow sometimes.)

Yes, I had already tried reuploading the file to the server, in which case the error simply became:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/madler/public_html/aacit/forum/Sources/Subs.php on line 247

So then you'll say replace Subs.php.  Right?  Ok, so I try that.  Then I get:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/madler/public_html/aacit/forum/Sources/Load.php on line 132

So I can see this going for some time ...

The question is, how did this happen in the first place?  I didn't make any changes and my hosting company didn't make any changes.  It just woke up one day and started to give the error in the subject line.  A quick search of this forum shows that this has happened to several different users, all equally perplexed with no apparent cause or solution.  In fact one of them had it happen to them the same day, and posted to this thread!  This is obviously something that the SMF code is doing to itself.

I guess what I need to do is reinstall.  However, how do I make sure that I don't screw up what I've already set up?  I recall spending quite some time jiggering permissions within the forums to get it working right, and I fear having to go through all that again.

So is there an easy way to reinstall SMF 1.0.7 without losing all the things I've done, as well as of course all the users and posts?
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: kegobeer on June 24, 2006, 08:57:53 PM
You just simply upload fresh copies of the 1.0.7 files.  You don't perform the install process again.  If you have any mods installed, you'll have to manually reapply those mods.
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: TiyulTalk on June 24, 2006, 10:38:19 PM
I had this same exact problem that occurred on the same day.  I had to repair multiple files to fix the forum.

Could anyone explain what might have caused this?

Before this problem started, I hadn't touched any system files in months.  So why does this happen seemingly out of nowhere?
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: madler on June 25, 2006, 01:57:21 AM
Quote from: kegobeer on June 24, 2006, 08:57:53 PM
You just simply upload fresh copies of the 1.0.7 files.  You don't perform the install process again.  If you have any mods installed, you'll have to manually reapply those mods.

All of them?  Obviously not Settings.php.  What other files have things saved within?  It looks like many of the source files are modified compared to the distribution.  How do I know which ones I can replace without losing something I have done during the installation and set up?

(By the way, I have no mods.)
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: madler on June 26, 2006, 09:19:59 PM
Bring to front ...
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: kegobeer on June 26, 2006, 09:24:41 PM
If you have no mods, then upload all of the 1.0.7 files except Settings.php and Settings_bak.php.  Settings.php is the only file that contains any specific information.  All other settings are maintained in the database.

As to why this happens - I have no idea.  It could be something that happened to the server (hard drive starting to fail, system problems, etc) that corrupted your files.  It could be the moon's gravity.  It could be quite a few things.  It's always a good idea to make frequent backups of the database and the files (most sites have some sort of backup script for your files, and you can use phpMyAdmin to perform a database backup), just in case a wide scale problem develops.
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: madler on June 27, 2006, 12:12:16 AM
Quote from: kegobeer on June 26, 2006, 09:24:41 PM
If you have no mods, then upload all of the 1.0.7 files except Settings.php and Settings_bak.php.  Settings.php is the only file that contains any specific information.  All other settings are maintained in the database.

Excellent, thanks.

QuoteAs to why this happens - I have no idea.  It could be something that happened to the server (hard drive starting to fail, system problems, etc) that corrupted your files.  It could be the moon's gravity. ...

Well, I might believe that if this exact same error hasn't shown up for several other users, as documented on this forum.  Just search for the error message.

I do of course make frequent, periodic backups, but restoring a backup can be rather destructive so I do that only when there's no other choice.  I was looking for a solution that didn't destroy information, which simply replacing the files other than Settings does.  And I don't need the backup for that, just the distribution.

Thank you again for your help.
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: kegobeer on June 27, 2006, 05:50:37 AM
Quote
Well, I might believe that if this exact same error hasn't shown up for several other users, as documented on this forum.  Just search for the error message.

Considering the huge number of SMF forums out there, if several users report the same problem, it could very well be the same concidence that caused the corruption.

Quote
I was looking for a solution that didn't destroy information, which simply replacing the files other than Settings does.

As I stated in my previous post, uploading fresh copies does not destroy information.  The database holds all of the posts and forum settings.  Only Settings.php has the necessary information to make the initial connection to the database.  Replacing a file has no effect on the data stored in the MySQL database.
Title: Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Post by: madler on June 27, 2006, 12:35:52 PM
Quote from: kegobeer on June 27, 2006, 05:50:37 AM
Quote
I was looking for a solution that didn't destroy information, which simply replacing the files other than Settings does.

As I stated in my previous post, uploading fresh copies does not destroy information.  The database holds all of the posts and forum settings.  Only Settings.php has the necessary information to make the initial connection to the database.  Replacing a file has no effect on the data stored in the MySQL database.

Um, right.  That's what I was agreeing with.  As I said, thank you for your help.  I did replace the non-Settings files.