Advertisement:

Author Topic: 2.0.14 Login Form Fix  (Read 1792 times)

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 69,274
    • StoryBB/StoryBB on GitHub
2.0.14 Login Form Fix
« on: January 08, 2018, 10:47:23 AM »
Link to Mod

As a fix to the login form issues that have come in since 2.0.14 where things didn't get added to login forms, here's a patch that fixes it.

Works on PHP 5.3+, and should fix all themes and mods that have login forms. Works with Pretty URLs too.

Licence is 3-clause BSD as per SMF 2.0.x licence.


Version history:

1.0.1 - 4 July 2018
Fixed lazy mod packaging that caused weird things to happen with some other mods. Probably should uninstall 1.0 and install 1.0.1.

1.0 - 19 December 2017
Initial release
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 20,458
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: 2.0.14 Login Form Fix
« Reply #1 on: January 08, 2018, 11:20:44 AM »
Nicely done! And shows what you can when playing with the output. Thanks for checking with prettyurls
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 69,274
    • StoryBB/StoryBB on GitHub
Re: 2.0.14 Login Form Fix
« Reply #2 on: January 08, 2018, 11:45:02 AM »
I just wish it had occurred to me to do sooner :( playing with the output like this is not a new trick, SimpleDesk did something similar in its first release in standalone mode.

Pretty URLs was the one mod I wasn't sure it would play nice with, so explicitly had to check :) Did also check the quick login in SP, that seemed to work too.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Snrj

  • Jr. Member
  • **
  • Posts: 304
  • Gender: Male
    • Snrj Forumları
Re: 2.0.14 Login Form Fix
« Reply #3 on: January 30, 2018, 09:03:55 AM »
hello arantor
instead of code after
do not the code need to be replace

I tested at php 7
site view as a visitor
there is a white page fault
problem
if (! $ context ['user'] ['is_guest'])
When I do, the problem is getting up
if (isset ($ context ['user'] ['is_guest']))

I said to report the problem
bad english sorry
Google Translate

Offline phantomm

  • Sophist Member
  • *****
  • Posts: 1,064
  • Gender: Male
    • pages/smfpl/171860759503032 on Facebook
    • Polish ElkArte community
Re: 2.0.14 Login Form Fix
« Reply #4 on: February 09, 2018, 01:10:48 PM »
just a question, after installation there should be twice ob_start('ob_sessrewrite'); ?
Polskie wsparcie SMF na simplemachines.org

My mods

Offline Rock Lee

  • Native Language Support Specialist
  • SMF Hero
  • *
  • Posts: 1,848
  • Gender: Male
  • I also speak english :D
    • BomberCode.Oficial on Facebook
    • RockLee-BC on GitHub
    • @Bomber_Code on Twitter
    • Bomber Code ~ La nueva era del conocimiento
Re: 2.0.14 Login Form Fix
« Reply #5 on: February 12, 2018, 04:18:19 PM »
In version 2.0.15 this fix was not already introduced?


Regards!
¡Regresando como cual Fenix! ~ Bomber Code © 2018
Ayudas - Aportes - Tutoriales - Y mucho mas!!!


Ayudame via PayPal

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 57,080
  • Gender: Male
    • Kindred-999 on GitHub
Re: 2.0.14 Login Form Fix
« Reply #6 on: February 12, 2018, 04:34:33 PM »
no
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Rock Lee

  • Native Language Support Specialist
  • SMF Hero
  • *
  • Posts: 1,848
  • Gender: Male
  • I also speak english :D
    • BomberCode.Oficial on Facebook
    • RockLee-BC on GitHub
    • @Bomber_Code on Twitter
    • Bomber Code ~ La nueva era del conocimiento
Re: 2.0.14 Login Form Fix
« Reply #7 on: February 12, 2018, 05:00:41 PM »
no

So this goes to bookmarks in case you doubt then, thanks for clarifying my doubt.


Regards!
¡Regresando como cual Fenix! ~ Bomber Code © 2018
Ayudas - Aportes - Tutoriales - Y mucho mas!!!


Ayudame via PayPal

Online drewactual

  • Jr. Member
  • **
  • Posts: 309
    • College Football Fan Site CFB51
Re: 2.0.14 Login Form Fix
« Reply #8 on: March 07, 2018, 09:32:50 PM »
Q: if the login code has been already altered as advised in threads in the help section, will installing and running this mod cause issues if those hard coded alterations remain?

thanks!
https://www.cfb51.com is a College Football Fan Site, Store, and Publisher, launched in July of 2017

Offline vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 20,458
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: 2.0.14 Login Form Fix
« Reply #9 on: March 08, 2018, 12:48:04 AM »
It shouldn't as it looks for it.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline Sh@mbles

  • SMF Hero
  • ******
  • Posts: 4,909
  • Gender: Male
    • i30 Owners Club
Re: 2.0.14 Login Form Fix
« Reply #10 on: July 04, 2018, 11:57:49 AM »
Just a note here:

The mod duplicates the call to ob_start('ob_sessrewrite') within Subs.php

Code: (Find) [Select]
ob_start('ob_sessrewrite');
Code: (Add After) [Select]
ob_start('ob_sessrewrite');
ob_start(function ($buffer) {
global $context;
if (!$context['user']['is_guest'])
return $buffer;
return preg_replace_callback('~(<form[^<]+action=login2(.+))</form>~iUs' . (!empty($context['utf8']) ? 'u' : ''), function($m) use ($context) {
$repl = '';
if (strpos($m[0], $context['session_var']) === false)
$repl .= '<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"/>';

return $m[1] . $repl . '</form>';
}, $buffer);
});



This results in an extended copyright area for some members:

Code: (in Subs/php) [Select]
ob_start('ob_sessrewrite');ob_start('ob_sessrewrite');
ob_start(function ($buffer) {
global $context;
if (!$context['user']['is_guest'])
return $buffer;
return preg_replace_callback('~(<form[^<]+action=login2(.+))</form>~iUs' . (!empty($context['utf8']) ? 'u' : ''), function($m) use ($context) {
$repl = '';
if (strpos($m[0], $context['session_var']) === false)
$repl .= '<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"/>';

return $m[1] . $repl . '</form>';
}, $buffer);
});


Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 69,274
    • StoryBB/StoryBB on GitHub
Re: 2.0.14 Login Form Fix
« Reply #11 on: July 04, 2018, 12:09:55 PM »
Bah, I’ll fix that tonight.

It only duplicates where things modify the session rewriter buffer, which most mods don’t really have a reason to do...
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Sh@mbles

  • SMF Hero
  • ******
  • Posts: 4,909
  • Gender: Male
    • i30 Owners Club
Re: 2.0.14 Login Form Fix
« Reply #12 on: July 04, 2018, 12:41:01 PM »
Top banana.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 69,274
    • StoryBB/StoryBB on GitHub
Re: 2.0.14 Login Form Fix
« Reply #13 on: July 04, 2018, 01:45:10 PM »
And fixed in 1.0.1. If you were using 1.0, you probably should uninstall 1.0 and install 1.0.1.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Chalky

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,380
  • Gender: Female
  • If in doubt, give me beer...
    • ChalkCat
Re: 2.0.14 Login Form Fix
« Reply #14 on: July 05, 2018, 04:52:06 PM »
Sorry for being dumb but I missed this whole thing and some time spent searching the forums hasn't clarified it for me.  Do I need this fix?  I'm not aware that we've had any issues with session timeouts on login but now I'm worried that if members couldn't login they wouldn't have been able to tell me about it  :-\  I'm running 2.0.15 on a forum that's been incrementally updated since 2.0.2, and I'm currently using an old Crip theme.  Should I install the fix anyway just to be sure?

Offline vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 20,458
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: 2.0.14 Login Form Fix
« Reply #15 on: July 05, 2018, 04:56:03 PM »
Your theme looks updated. Some themes did not have the updated session check in the top login form in the left corner which could cause logins to fail
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Online GigaWatt

  • The Smiley Guy
  • Support Specialist
  • Sophist Member
  • *
  • Posts: 1,324
  • Gender: Male
    • Macedonian electronics forum
Re: 2.0.14 Login Form Fix
« Reply #16 on: July 05, 2018, 04:57:31 PM »
Simplest way to check, register a test account, see if you can login ;).

And if you're using a theme that was released before 2.0.14, you probably don't have the fix implemented. The only theme that can be patched for sure is Curve. It tries to find the adequate code in any other theme, but if it doesn't, it can't patch it. And you have to apply it on every theme you're using if you're using more than one theme. If one theme fails the test (the mod/fix can't find the code it's looking for), that theme basically doesn't have the fix implemented and you shouldn't be able to log in from that theme.
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Offline Chalky

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,380
  • Gender: Female
  • If in doubt, give me beer...
    • ChalkCat
Re: 2.0.14 Login Form Fix
« Reply #17 on: July 05, 2018, 05:04:08 PM »
Your theme looks updated. Some themes did not have the updated session check in the top login form in the left corner which could cause logins to fail

Thank you!

Simplest way to check, register a test account, see if you can login ;).

And if you're using a theme that was released before 2.0.14, you probably don't have the fix implemented. The only theme that can be patched for sure is Curve. It tries to find the adequate code in any other theme, but if it doesn't, it can't patch it. And you have to apply it on every theme you're using if you're using more than one theme. If one theme fails the test (the mod/fix can't find the code it's looking for), that theme basically doesn't have the fix implemented and you shouldn't be able to log in from that theme.

Ok, so it's a persistent error rather than intermittent?  I can log in with my test account just fine, and certainly some of my members have been successfully logging in and out.  So I'm ok then?  Thank you!

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 69,274
    • StoryBB/StoryBB on GitHub
Re: 2.0.14 Login Form Fix
« Reply #18 on: July 05, 2018, 05:08:52 PM »
Yup, you're OK.

A lot of themes stopped working correctly after 2.0.14 increased security, especially if they had a quick login area in the top of the theme. The portals have the same problem, too, and for the same reason - they have a login form that doesn't have the additional information in it.

If all the login boxes work for you, you're good and don't need this - and if you manually fix things, again you wouldn't need this, this just automates away having to fix a bunch of themes, or having to actually edit a theme itself in almost every case.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Chalky

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,380
  • Gender: Female
  • If in doubt, give me beer...
    • ChalkCat
Re: 2.0.14 Login Form Fix
« Reply #19 on: July 05, 2018, 05:10:54 PM »
Brilliant, thank you so much for putting my mind at rest!  And for providing the solution in the event I'd needed it  :D