Advertisement:

Author Topic: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING  (Read 16226 times)

Offline madler

  • Semi-Newbie
  • *
  • Posts: 13
syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
« 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?
« Last Edit: June 21, 2006, 09:31:38 AM by madler »

Offline TiyulTalk

  • Newbie
  • *
  • Posts: 6
    • Tiyul Talk
Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
« Reply #1 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.
« Last Edit: June 21, 2006, 12:06:40 PM by TiyulTalk »
Tiyul Talk - hxxp:www.tiyultalk.com [nonactive]

Offline madler

  • Semi-Newbie
  • *
  • Posts: 13
Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
« Reply #2 on: June 23, 2006, 07:37:44 PM »
Just to bring this up front again to see if anyone has an answer ...

Offline kegobeer

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,994
  • Gender: Male
  • I am ninja!
    • The Kazebeer Family Website
Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
« Reply #3 on: June 23, 2006, 07:48:02 PM »
Check your Settings.php file.  If it is corrupted, replace it with Settings_bak.php.
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

Offline madler

  • Semi-Newbie
  • *
  • Posts: 13
Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
« Reply #4 on: June 23, 2006, 10:15:17 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

Offline kegobeer

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,994
  • Gender: Male
  • I am ninja!
    • The Kazebeer Family Website
Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
« Reply #5 on: June 23, 2006, 10:21:51 PM »
Open Settings.php and look at line 28.  It should be this:

Code: [Select]
$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.
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

Offline madler

  • Semi-Newbie
  • *
  • Posts: 13
Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
« Reply #6 on: June 23, 2006, 10:37:11 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:

Code: [Select]
<?php
/******************************************************************************
* Settings.php                                                                *
*******************************************************************************
* SMF: Simple Machines Forum                                                  *
* Open-Source Project Inspired by Zef Hemel (zef@zefhemel.com)                *
* =========================================================================== *
* 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&#39;ll have to make it 0 again manually!)
$mtitle = &#39;Maintenance Mode&#39;;           # Title for the Maintenance Mode message.
$mmessage = &#39;Ok faithful users...we\&#39;re attempting to restore an older backup of the database...news will be posted once we\&#39;re back!&#39;;         # Description of why the forum is in maintenance mode.

########## Forum Info ##########
$mbname = &#39;Caltech/JPL Flying Club&#39;;            # The name of your forum.
$language = &#39;english&#39;;          # The default language file set for the forum.
$boardurl = &#39;http://aacit.org/forum&#39;;           # URL to your forum&#39;s folder. (without the trailing /!)
$webmaster_email = &#39;madler@alumni.caltech.edu&#39;;         # Email address to send emails from. (like noreply@yourdomain.com.)
$cookiename = &#39;SMFCookie10&#39;;            # Name of the cookie to set for authentication.

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

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

########## Error-Catching ##########
# Note: You shouldn&#39;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__) . &#39;/agreement.txt&#39;))
        $boarddir dirname(__FILE__);
if (!
file_exists($sourcedir) && file_exists($boarddir . &#39;/Sources&#39;))
        $sourcedir $boarddir . &#39;/Sources&#39;;

?>


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

Reply: Oh yeah, thanks.
« Last Edit: June 24, 2006, 03:48:33 AM by madler »

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,561
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
« Reply #7 on: June 24, 2006, 01:39:19 AM »
If oyu don't have any mods installed reupload index.php.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline madler

  • Semi-Newbie
  • *
  • Posts: 13
Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
« Reply #8 on: June 24, 2006, 04:11:37 AM »
If oyu don't have any mods installed reupload index.php.

Alas, no joy.  The behavior was unchanged.

Offline Daniel15

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,216
  • Gender: Male
  • http://dan.cx/
    • daaniel on Facebook
    • daniel15 on LinkedIn
    • @Daniel15 on Twitter
    • Daniel15
Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
« Reply #9 on: June 24, 2006, 05:53:24 AM »
Quote
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.
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.
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

Offline madler

  • Semi-Newbie
  • *
  • Posts: 13
Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
« Reply #10 on: June 24, 2006, 12:22:50 PM »
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.

Code: [Select]
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:
« Last Edit: June 24, 2006, 12:26:22 PM by madler »

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,561
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
« Reply #11 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.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline madler

  • Semi-Newbie
  • *
  • Posts: 13
Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
« Reply #12 on: June 24, 2006, 05:21:48 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:

Code: [Select]
1:<?php
2
:/******************************************************************************
3:* QueryString.php                                                             *
4:*******************************************************************************
5:* SMF: Simple Machines Forum                                                  *
6:* Open-Source Project Inspired by Zef Hemel (zef@zefhemel.com)                *
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(&#39;SMF&#39;))
24:die(&#39;Hacking attempt...&#39;);
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[&#39;start&#39;].
36:- determines, or rather tries to determine, the client&#39;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, &#39;&#39;. (it wouldn&#39;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 . &#39;/index.php&#39;;
80:
81:// Save some memory.. (since we don&#39;t use these anyway.)
82:unset($GLOBALS[&#39;HTTP_POST_VARS&#39;]);
83:unset($GLOBALS[&#39;HTTP_POST_FILES&#39;]);
84:
85:// Get the correct query string.  It may be in an environment variable...
86:if (!isset($_SERVER[&#39;QUERY_STRING&#39;]))
87:$_SERVER[&#39;QUERY_STRING&#39;] = getenv(&#39;QUERY_STRING&#39;);
88:
89:// There&#39;s no query string, but there is a URL... try to get the data from there.
90:if (empty($_SERVER[&#39;QUERY_STRING&#39;]) && !empty($_SERVER[&#39;REQUEST_URI&#39;]))
91:{
92:// Remove the .html, assuming there is one.
93:if (substr($_SERVER[&#39;REQUEST_URI&#39;], strrpos($_SERVER[&#39;REQUEST_URI&#39;], &#39;.&#39;), 4) == &#39;.htm&#39;)
94:$_SERVER[&#39;REQUEST_URI&#39;] = substr($_SERVER[&#39;REQUEST_URI&#39;], 0, strrpos($_SERVER[&#39;REQUEST_URI&#39;], &#39;.&#39;));
95:
96:// Replace &#39;index.php/a,b/c/d,e&#39; with &#39;a=b&c=&d=e&#39; and parse it into $_GET.
97:parse_str(substr(preg_replace(&#39;/&(w+)(&|z)/&#39;, &#39;&$1=$2&#39;, strtr(substr($_SERVER[&#39;REQUEST_URI&#39;], strpos($_SERVER[&#39;REQUEST_URI&#39;], basename($scripturl)) + strlen(basename($scripturl))), &#39;/,&#39;, &#39;&=&#39;)), 1), $_GET);
98:}
99:// Are we going to need to parse the ; out?
100:elseif ((strpos(@ini_get(&#39;arg_separator.input&#39;), &#39;;&#39;) === false || @version_compare(PHP_VERSION, &#39;4.2.0&#39;) == -1) && !empty($_SERVER[&#39;QUERY_STRING&#39;]))
101:{
102:// Get rid of the old one!  You don&#39;t know where it&#39;s been!
103:$_GET = array();
104:
105:// Was this redirected?  If so, get the REDIRECT_QUERY_STRING.
106:$_SERVER[&#39;QUERY_STRING&#39;] = urldecode(substr($_SERVER[&#39;QUERY_STRING&#39;], 0, 5) == &#39;url=/&#39; ? $_SERVER[&#39;REDIRECT_QUERY_STRING&#39;] : $_SERVER[&#39;QUERY_STRING&#39;]);
107:
108:// Replace &#39;;&#39; with &#39;&&#39; and &#39;&something&&#39; with &#39;&something=&&#39;.  (this is done for compatibility...)
109:parse_str(preg_replace(&#39;/&(w+)(&|$)/&#39;, &#39;&$1=$2&#39;, strtr($_SERVER[&#39;QUERY_STRING&#39;], &#39;;&#39;, &#39;&&#39;)), $_GET);
110:}
111:elseif (strpos(@ini_get(&#39;arg_separator.input&#39;), &#39;;&#39;) !== 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][&#39;name&#39;] = addslashes__recursive($_FILES[$k][&#39;name&#39;]);
133:}
134:
135:// Take care of the server variables.
136:$_SERVER addslashes__recursive($_SERVER);
137:
138:// Let&#39;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[&#39;board&#39;]))
143:{
144:// If there&#39;s a slash in it, we&#39;ve got a start value! (old, compatible links.)
145:if (strpos($_REQUEST[&#39;board&#39;], &#39;/&#39;) !== false)
146:list ($_REQUEST[&#39;board&#39;], $_REQUEST[&#39;start&#39;]) = explode(&#39;/&#39;, $_REQUEST[&#39;board&#39;]);
147:// Same idea, but dots.  This is the currently used format - ?board=1.0...
148:elseif (strpos($_REQUEST[&#39;board&#39;], &#39;.&#39;) !== false)
149:list ($_REQUEST[&#39;board&#39;], $_REQUEST[&#39;start&#39;]) = explode(&#39;.&#39;, $_REQUEST[&#39;board&#39;]);
150:// Now make absolutely sure it&#39;s a number.
151:$board = (int) $_REQUEST[&#39;board&#39;];
152:
153:// This is for "Who&#39;s Online" because it might come via POST - and it should be an int here.
154:$_GET[&#39;board&#39;] = $board;
155:}
156:// Well, $board is going to be a number no matter what.
157:else
158:$board 0;
159:
160:// If there&#39;s a threadid, it&#39;s probably an old YaBB SE link.  Flow with it.
161:if (isset($_REQUEST[&#39;threadid&#39;]) && !isset($_REQUEST[&#39;topic&#39;]))
162:$_REQUEST[&#39;topic&#39;] = $_REQUEST[&#39;threadid&#39;];
163:
164:// We&#39;ve got topic!
165:if (isset($_REQUEST[&#39;topic&#39;]))
166:{
167:// Slash means old, beta style, formatting.  That&#39;s okay though, the link should still work.
168:if (strpos($_REQUEST[&#39;topic&#39;], &#39;/&#39;) !== false)
169:list ($_REQUEST[&#39;topic&#39;], $_REQUEST[&#39;start&#39;]) = explode(&#39;/&#39;, $_REQUEST[&#39;topic&#39;]);
170:// Dots are useful and fun ;).  This is ?topic=1.15.
171:elseif (strpos($_REQUEST[&#39;topic&#39;], &#39;.&#39;) !== false)
172:list ($_REQUEST[&#39;topic&#39;], $_REQUEST[&#39;start&#39;]) = explode(&#39;.&#39;, $_REQUEST[&#39;topic&#39;]);
173:
174:$topic = (int) $_REQUEST[&#39;topic&#39;];
175:
176:// Now make sure the online log gets the right number.
177:$_GET[&#39;topic&#39;] = $topic;
178:}
179:
180:// There should be a $_REQUEST[&#39;start&#39;], some at least.  If you need to default to other than 0, use $_GET[&#39;start&#39;].
181:if (empty($_REQUEST[&#39;start&#39;]) || $_REQUEST[&#39;start&#39;] < 0)
182:$_REQUEST[&#39;start&#39;] = 0;
183:
184:// Find the user&#39;s IP address. (but don&#39;t let it give you &#39;unknown&#39;!)
185:if (!empty($_SERVER[&#39;HTTP_CLIENT_IP&#39;]) && preg_match(&#39;~^((0|10|172.16|192.168|255|127.0).|unknown)~&#39;, $_SERVER[&#39;HTTP_CLIENT_IP&#39;]) == 0)
186:{
187:// Since they are in different blocks, it&#39;s probably reversed.
188:if (strtok($_SERVER[&#39;REMOTE_ADDR&#39;], &#39;.&#39;) != strtok($_SERVER[&#39;HTTP_CLIENT_IP&#39;], &#39;.&#39;))
189:$_SERVER[&#39;REMOTE_ADDR&#39;] = implode(&#39;.&#39;, array_reverse(explode(&#39;.&#39;, $_SERVER[&#39;HTTP_CLIENT_IP&#39;])));
190:else
191:$_SERVER[&#39;REMOTE_ADDR&#39;] = $_SERVER[&#39;HTTP_CLIENT_IP&#39;];
192:}
193:elseif (!empty($_SERVER[&#39;HTTP_X_FORWARDED_FOR&#39;]))
194:{
195:// If there are commas, get the last one.. probably.
196:if (strpos($_SERVER[&#39;HTTP_X_FORWARDED_FOR&#39;], &#39;,&#39;) !== false)
197:{
198:$ips array_reverse(explode(&#39;, &#39;, $_SERVER[&#39;HTTP_X_FORWARDED_FOR&#39;]));
199:
200:// Go through each IP...
201:foreach ($ips as $i => $ip)
202:{
203:// Make sure it&#39;s in a valid range...
204:if (preg_match(&#39;~^((0|10|172.16|192.168|255|127.0).|unknown)~&#39;, $ip) != 0)
205:continue;
206:
207:// Otherwise, we&#39;ve got an IP!
208:$_SERVER[&#39;REMOTE_ADDR&#39;] = trim($ip);
209:break;
210:}
211:}
212:// Otherwise just use the only one.
213:elseif (preg_match(&#39;~^((0|10|172.16|192.168|255|127.0).|unknown)~&#39;, $_SERVER[&#39;HTTP_X_FORWARDED_FOR&#39;]) == 0)
214:$_SERVER[&#39;REMOTE_ADDR&#39;] = $_SERVER[&#39;HTTP_X_FORWARDED_FOR&#39;];
215:}
216:
217:// Make sure REQUEST_URI is set.
218:if (empty($_SERVER[&#39;REQUEST_URI&#39;]))
219:$_SERVER[&#39;REQUEST_URI&#39;] = $scripturl . (!empty($_SERVER[&#39;QUERY_STRING&#39;]) ? &#39;?&#39; . $_SERVER[&#39;QUERY_STRING&#39;] : &#39;&#39;);
220:
221:// And make sure HTTP_USER_AGENT is set.
222:$_SERVER[&#39;HTTP_USER_AGENT&#39;] = isset($_SERVER[&#39;HTTP_USER_AGENT&#39;]) ? htmlspecialchars(stripslashes($_SERVER[&#39;HTTP_USER_AGENT&#39;]), ENT_QUOTES) : &#39;&#39;;
223:
224:// Some final checking.
225:if (preg_match(&#39;~^((([1]?d)?d|2[0-4]d|25[0-5]).){3}(([1]?d)?d|2[0-4]d|25[0-5])$~&#39;, $_SERVER[&#39;REMOTE_ADDR&#39;]) === 0)
226:$_SERVER[&#39;REMOTE_ADDR&#39;] = &#39;&#39;;
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 == &#39;&#39; || !defined(&#39;SID&#39;))
310:return $buffer;
311:
312:// Do nothing if the session is cookied, or they are a crawler - guests are caught by redirectexit().  This doesn&#39;t work below PHP 4.3.0, because it makes the output buffer bigger.
313:if (empty($_COOKIE) && SID != &#39;&#39; && (!$user_info[&#39;is_guest&#39;] || (strpos($_SERVER[&#39;HTTP_USER_AGENT&#39;], &#39;Mozilla&#39;) !== false || strpos($_SERVER[&#39;HTTP_USER_AGENT&#39;], &#39;Opera&#39;) !== false)) && @version_compare(PHP_VERSION, &#39;4.3.0&#39;) != -1)
314:$buffer preg_replace(&#39;/"&#39; . preg_quote($scripturl, &#39;/&#39;) . &#39;(?!?&#39; . preg_quote(SID, &#39;/&#39;) . &#39;)(?)?/&#39;, &#39;"&#39; . $scripturl . &#39;?&#39; . SID . &#39;&amp;&#39;, $buffer);
315:// You can&#39;t do both, because session_start() won&#39;t catch the session if you do.  But this should work even in 4.2.x, just not CGI.
316:elseif (!empty($modSettings[&#39;queryless_urls&#39;]) && !$context[&#39;server&#39;][&#39;is_cgi&#39;] && $context[&#39;server&#39;][&#39;is_apache&#39;])
317:$buffer preg_replace(&#39;/"&#39; . preg_quote($scripturl, &#39;/&#39;) . &#39;?((?:board|topic)=[^#"]+)(#[^"]*)?"/e&#39;, "&#39;"&#39; . $scripturl . &#39;/&#39; . strtr(&#39;$1&#39;, &#39;&;=&#39;, &#39;//,&#39;) . &#39;.html$2"&#39;", $buffer);
318:
319:// Return the changed buffer.
320:return $buffer;
321:}
322:

Offline winrules

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,085
  • Gender: Male
Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
« Reply #13 on: June 24, 2006, 05:42:42 PM »
Did you reupload the file?
winrules
SMF Developer
               My Mods
Please do not PM me for support.


Offline madler

  • Semi-Newbie
  • *
  • Posts: 13
Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
« Reply #14 on: June 24, 2006, 08:56:11 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?
« Last Edit: June 24, 2006, 09:43:37 PM by madler »

Offline kegobeer

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,994
  • Gender: Male
  • I am ninja!
    • The Kazebeer Family Website
Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
« Reply #15 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.
« Last Edit: June 27, 2006, 01:46:10 AM by Amacythe »
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

Offline TiyulTalk

  • Newbie
  • *
  • Posts: 6
    • Tiyul Talk
Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
« Reply #16 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?
Tiyul Talk - hxxp:www.tiyultalk.com [nonactive]

Offline madler

  • Semi-Newbie
  • *
  • Posts: 13
Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
« Reply #17 on: June 25, 2006, 01:57:21 AM »
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.)

Offline madler

  • Semi-Newbie
  • *
  • Posts: 13
Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
« Reply #18 on: June 26, 2006, 09:19:59 PM »
Bring to front ...

Offline kegobeer

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,994
  • Gender: Male
  • I am ninja!
    • The Kazebeer Family Website
Re: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
« Reply #19 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.
« Last Edit: June 26, 2006, 09:27:55 PM by kegobeer »
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")