Is their a simple way to repair this?

Started by uth, February 13, 2015, 08:36:52 PM

Previous topic - Next topic

uth

Hoping to solve this with out starting over. When some one trys to register they now get this error......

Parse error: syntax error, unexpected ':', expecting ')' in /home/ut***/public_html/forums/Sources/Register.php on line 311

Kindred

Smf version?
  What mod did you recently try to install?
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

uth

SMF 2.0.9 | SMF © 2014, Simple Machines

Haven't installed a mod in months, I did have to manually add some users through a data base. Had printed out another user and used it to fill everything out. Users are working great just now a few days later this is popping up and I am lost.

Kindred

First of all...  You should never add users directly in the database.
If you need to manually add users, there are ways to do so as an admin, from inside the smf admin tools.  By adding them directly in the database, you have bypassed several of the things which the system does when a user account is created... More than just adding a row to the members table.


Second... The error thatbyou indicate is a code error. That means that you made a change to the source code in the file... For some reason... And made a bad edit.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

uth

Thank you for the reply,
      The options to register a user I saw from the admin console didn't work had kept telling me that the user existed so I went this way....apparently screwed up. Not sure what or how I got to the source code . I take it the answer is to scrap it and start over?

Kindred

You could include lines 280 to 310 of the register.php file in a post...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

uth

#6
Thank you it is truly appreciated.

'buddy_list',
'pm_ignore_list',
'smiley_set',
'signature', 'personal_text', 'avatar',
'lngfile',
'secret_question', 'secret_answer',
);
$possible_ints = array(
'pm_email_notify',
'notify_types',
'icq',
'gender',
'id_theme',
);
$possible_floats = array(
'time_offset',
);
$possible_bools = array(
'notify_announcements', 'notify_regularity', 'notify_send_body',
'hide_email', 'show_online',
);

if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '')
$_POST['secret_answer'] = md5($_POST['secret_answer']);

// Needed for isReservedName() and registerMember().
require_once($sourcedir . '/Subs-Members.php');

// Validation... even if we're not a mall.
if (isset($_POST['real_name']) && (!empty($modSettings['allow_editDisplayName']) || allowedTo('moderate_forum')))
{
$_POST['real_name'] = trim(: '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $_POST['real_name']));

Burke ♞ Knight

uth, it is always best to use the code tags, when posting code.



[code][/code]




Kindred

Oops...   Ask, I just realized that I misread your line number...   Can you also include through line 320?
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Shambles

The last line posted above is the failing one - looks like a whole chunk of code got snipped out

Code (find) Select
// Validation... even if we're not a mall.
if (isset($_POST['real_name']) && (!empty($modSettings['allow_editDisplayName']) || allowedTo('moderate_forum')))
{
$_POST['real_name'] = trim(: '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $_POST['real_name']));



Code (replace) Select
// Validation... even if we're not a mall.
if (isset($_POST['real_name']) && (!empty($modSettings['allow_editDisplayName']) || allowedTo('moderate_forum')))
{
$_POST['real_name'] = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? ($context['server']['complex_preg_chars'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : "\xC2\xA0\xC2\xAD\xE2\x80\x80-\xE2\x80\x8F\xE2\x80\x9F\xE2\x80\xAF\xE2\x80\x9F\xE3\x80\x80\xEF\xBB\xBF") : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $_POST['real_name']));



Chances are that other bits have been snipped out - smells of erroneous editing...

uth

Hello Every one, thank you for the reply's and sorry for not using the indicators.


[code] // Collect all extra registration fields someone might have filled in.
$possible_strings = array(
'website_url', 'website_title',
'aim', 'yim',
'location', 'birthdate',
'time_format',
'buddy_list',
'pm_ignore_list',
'smiley_set',
'signature', 'personal_text', 'avatar',
'lngfile',
'secret_question', 'secret_answer',
);
$possible_ints = array(
'pm_email_notify',
'notify_types',
'icq',
'gender',
'id_theme',
);
$possible_floats = array(
'time_offset',
);
$possible_bools = array(
'notify_announcements', 'notify_regularity', 'notify_send_body',
'hide_email', 'show_online',
);

if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '')
$_POST['secret_answer'] = md5($_POST['secret_answer']);

// Needed for isReservedName() and registerMember().
require_once($sourcedir . '/Subs-Members.php');

// Validation... even if we're not a mall.
if (isset($_POST['real_name']) && (!empty($modSettings['allow_editDisplayName']) || allowedTo('moderate_forum')))
{
$_POST['real_name'] = trim(: '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $_POST['real_name']));
if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60)
$possible_strings[] = 'real_name';
}

if (isset($_POST['msn']) && preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $_POST['msn']) != 0)
$profile_strings[] = 'msn';

// Handle a string as a birthdate...
if (isset($_POST['birthdate']) && $_POST['birthdate'] != '')
$_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate']));
// Or birthdate parts...
elseif (!empty($_POST['bday1']) && !empty($_POST['bday2']))
$_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']);
         

Shambles

Correct the code as I demonstrated in my post above yours.

uth

Quote from: Shambles on February 14, 2015, 03:40:13 AM
The last line posted above is the failing one - looks like a whole chunk of code got snipped out

Code (find) Select
// Validation... even if we're not a mall.
if (isset($_POST['real_name']) && (!empty($modSettings['allow_editDisplayName']) || allowedTo('moderate_forum')))
{
$_POST['real_name'] = trim(: '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $_POST['real_name']));



Code (replace) Select
// Validation... even if we're not a mall.
if (isset($_POST['real_name']) && (!empty($modSettings['allow_editDisplayName']) || allowedTo('moderate_forum')))
{
$_POST['real_name'] = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? ($context['server']['complex_preg_chars'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : "\xC2\xA0\xC2\xAD\xE2\x80\x80-\xE2\x80\x8F\xE2\x80\x9F\xE2\x80\xAF\xE2\x80\x9F\xE3\x80\x80\xEF\xBB\xBF") : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $_POST['real_name']));



Chances are that other bits have been snipped out - smells of erroneous editing...

I copied the replace code from the post into the php and it repaired the original error it now points to line 851 that is here.

Parse error: syntax error, unexpected ':' in /home/uth**/public_html/forums/Sources/Register.php on line 851


// Clean it up like mother would.
$context['checked_username'] = : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $context['checked_username']);
if ($smcFunc['strlen']($context['checked_username']) > 25)
$context['checked_username'] = $smcFunc['htmltrim']($smcFunc['substr']($context['checked_username'], 0, 25));


Thank you every one for the help, it is appreciated, means I can give her good news or at least hope when I head up to the hospital. I apologize that something I did some how is having you all work at trying to undo my mistakes. I am grateful for it!

Shambles

Quote from: Shambles
Chances are that other bits have been snipped out - smells of erroneous editing...

Simplest way is to grab yourself a fresh copy of register.php and compare it with yours, for the lines which are faulty. Otherwise we could be here all day fixing bits of snipped code here and there ;)

uth

Thank you, is their a place to download one? And any danger in just replacing the whole thing with the downloaded one?

Shambles

Depends if you have any mods applied that affected register.php

Get a copy from the SMF 2.0.9 download section, or from your backup assuming you took one.


uth

Hello,
  Thank you again for the help. I renamed the old file registerold and uploaded the new one and everything seems to be working so far. Had one last question, do you know how to edit the e-mail the system sends out when a user's registration is rejected, would like to customize what is said in the rejection letter.
  Again, thank you every one!!

Off to learn how to make a back up :)

EDIT:
Sorry forgot to ask this, what is the better way of adding a user when the forum claims they already exist although do not actually exist? Not sure if it is getting confused from the wordpress site, the smf forums are on a sub domain.

Sir Osis of Liver

/Themes/default/languages/EmailTemplates.english.php -



'admin_approve_reject' => array(
/*
@additional_params: admin_approve_reject
USERNAME: The user name for the member receiving the email.
@description:
*/
'subject' => 'Registration Rejected',
'body' => '{USERNAME},

Regrettably, your application to join {FORUMNAME} has been rejected.

{REGARDS}',
),


Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

uth


uth

Spoke to soon :) Now they can not log out....and get this message.

"Unable to verify referring url. Please go back and try again."

Or this when trying to complete registration.

"Parse error: syntax error, unexpected ':', expecting ')' in /home/ut**/public_html/forums/Sources/Subs-Members.php on line 505"

Here is the list of plugins
1. SimpleAds 1.0.1
2. BK Modding StatCounter 1.0
3. Board Icons 1.0
4. Tidy Child Boards 1.4.1 
5. Menu Buttons 1.1
6. Simple Audio Video Embedder


uth

Strange, it is working again.....I had edited the rejection letter and that seems to have broken the other two. I copied the code above back in and the logging out works again and the ability to register.

Is their a limit on the rejection info?

Arantor


Kindred

You obviously have a whole bunch of badly edited files.

Read the FAQ on how to load a clean set of files... And then reinstall your mods, one at a a time.

Regarding the url...muse repair_settings.pho to change the cookie name
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

uth

Quote from: Arantor on February 14, 2015, 05:15:52 PM
What *exactly* did you use?

Note pad and then when it not work directly in it.

Everything is working as it should be now, cant believe that entering a user into the data base directly could have been so devastating. makes me a bit nervous since their are a couple more users who claim they already exist and yet do not.

Will try to figure out how to get them added and not do it the way I did last time.

Kindred

So, how do they claim that they exist? And how do you know that they do not exist?


Additionally...  Do not use notepad. Ever.

Notepad++ or context are your best bets.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Synergy Hub

Quote from: Kindred on February 14, 2015, 08:26:13 PM
So, how do they claim that they exist? And how do you know that they do not exist?

Additionally...  Do not use notepad. Ever.

Notepad++ or context are your best bets.

We had a similar claim made.. and discovered that they had not finished registering.  i.e. not clicked the confirmation link in the email sent. 

We did not see them in the normal membership list, BUT did find them listed by clicking Admin in main menu, then going down to the bottom of that page and clicking on "Members"... it showed us the ones in question.

Kindred

In the admin, there is a list of users awaiting activation.. And those can be manually activated by the admin. Such users will not be visible in the standard memberlist and the user would not be able to log in, because they never completed the registration process.

I will note... The issues reported by the original poster can not have been caused by any database edits. Period.  It is still the wrong way to do things and, overall, a bad idea... But editing the database will not cause file errors.   Those were caused by bad edits. Ever someone manually made edits and did them wrong... Or a mod really screwed things up.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

uth

Hello,
  Thank you for the help. I can see the members awaiting activation and they were not in that list. Even rejected each one awaiting before trying to register them through the admin console. It is possible she had tried to edit something before the car wreck, I honestly have no idea. Either way, the help is truly appreciated I am grateful for everyone who did help :)

  Back to figuring out to safely add them, thanks again.

Kindred

There are only two ways to safely, properly add a user.1- use the standard registration, just like any user or 2- use the admin register a user option.
Those are the only ways to do it.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

uth

Thank you,
   Sadly I guess that means one more data base entry :( but at least this time I will have the system backed up.

Kindred

Have you not been listening? Do not add users directly to the database. Just don't do it.

If you are having issues adding a user in the admin tool, then fix that problem, don't try to bypass it with database edits.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: