Limited SSL Usage (original hook by ToonArmy)

Looking for an Extension? Have an Extension request? Post your request here for help. (Note: This forum is community supported; while there is an Extensions Development Team, said team does not dedicate itself to handling requests in this forum)
Ideas Centre
Post Reply
Pond Life
Registered User
Posts: 388
Joined: Sat Jan 20, 2007 1:55 am

Limited SSL Usage (original hook by ToonArmy)

Post by Pond Life »

In my 3.0.x installation I have been using the hook created by ToonArmy,
https://github.com/cs278/phpbb3/blob/ho ... ontrol.php, but I've found it doesn't work with 3.1.x, I get the following error:

Code: Select all

Catchable fatal error: Argument 1 passed to phpbb_hook_ssl_control::setTemplate() must be an instance of template, instance of phpbb\template\twig\twig given, called in <removed>/includes/hooks/hook_ssl-control.php on line 101 and defined in <removed>/includes/hooks/hook_ssl-control.php on line 118
line 101 is

Code: Select all

		$this->setTemplate($template ? $template : $GLOBALS['template']);
and line 118 is

Code: Select all

	public function setTemplate(template $template)
Using https for all pages is not an option due to non https embeded images and the tinypic plugin.

Would someone be able to either help me to make the hook work for 3.1 or convert it into an extension please?
Never argue with idiots, they will drag you down to their level and beat you with experience.
Pond Life
Registered User
Posts: 388
Joined: Sat Jan 20, 2007 1:55 am

Re: Limited SSL Usage (original hook by ToonArmy)

Post by Pond Life »

I have tried to figure out how to make the extension myself, I've read the guide on converting a MOD to an extension, but I'm struggling with it.

I have found a much simpler way around this for now, using .htaccess and a small core edit in includes/functions.php, but would still prefer an extension if possible.
Never argue with idiots, they will drag you down to their level and beat you with experience.
User avatar
3Di
Former Team Member
Posts: 16076
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano 🇮🇹 Frankfurt 🇩🇪
Name: Marco
Contact:

Re: Limited SSL Usage (original hook by ToonArmy)

Post by 3Di »

Yeah, you might be also interested in following this discussion.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
wolfbeast
Registered User
Posts: 69
Joined: Sat Aug 10, 2013 1:24 am

Re: Limited SSL Usage (original hook by ToonArmy)

Post by wolfbeast »

Pond Life wrote:I have tried to figure out how to make the extension myself, I've read the guide on converting a MOD to an extension, but I'm struggling with it.

I have found a much simpler way around this for now, using .htaccess and a small core edit in includes/functions.php, but would still prefer an extension if possible.
Would you mind sharing your workaround? I'm not using Apache but I can convert .htaccess rules to nginx if i know what's needed.
Pond Life
Registered User
Posts: 388
Joined: Sat Jan 20, 2007 1:55 am

Re: Limited SSL Usage (original hook by ToonArmy)

Post by Pond Life »

I'm no expert, I tinker with my own stuff at my own risk. If you use it you do so at your own risk. ;) It does involve editing a core file which tends to be frowned upon here. You have been warned.

includes/functions.php
find (around line 3134)

Code: Select all

		'S_LOGIN_ACTION'		=> build_url(array('f')),
replace with

Code: Select all

		'S_LOGIN_ACTION'      => 'https://<replace this with your forum url>' . build_url(array('f')),
find (around line 5203)

Code: Select all

			'S_LOGIN_ACTION'		=> ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("{$phpbb_admin_path}index.$phpEx", false, true, $user->session_id)),
replace with

Code: Select all

		'S_LOGIN_ACTION'      => ((!defined('ADMIN_START')) ? append_sid("https://{$user->host}{$user->page['root_script_path']}ucp.$phpEx", 'mode=login') : append_sid("{$phpbb_admin_path}index.$phpEx", false, true, $user->session_id)),
.htaccess
I have included a bit of the original .htaccess here to show where the changes are.

Code: Select all

<IfModule mod_rewrite.c>
RewriteEngine on

# The following 3 lines will rewrite URLs passed through the front controller
# to not require app.php in the actual URL. In other words, a controller is
# by default accessed at /app.php/my/controller, but can also be accessed at
# /my/controller
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ app.php [QSA,L]

# SSL on selected pages
RewriteCond %{HTTPS} !=on
RewriteCond %{QUERY_STRING} mode=(login|reg_details|register) [OR]
RewriteCond %{QUERY_STRING} i=(pm|ucp_pm) [OR]
RewriteCond %{REQUEST_URI} adm/
RewriteRule (.+) https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !.*\.(js|css|gif|png|jpg|woff|ttf)
RewriteCond %{QUERY_STRING} !.*\.(gif|png|jpg)

RewriteCond %{HTTPS} on
RewriteCond %{QUERY_STRING} !mode=(login|reg_details|register)
RewriteCond %{QUERY_STRING} !i=(pm|ucp_pm) 
RewriteCond %{REQUEST_URI} !adm/
RewriteRule (.+) http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

Options +FollowSymLinks
</IfModule>
Never argue with idiots, they will drag you down to their level and beat you with experience.
User avatar
wolfbeast
Registered User
Posts: 69
Joined: Sat Aug 10, 2013 1:24 am

Re: Limited SSL Usage (original hook by ToonArmy)

Post by wolfbeast »

Thanks! the info is certainly appreciated :)
Looks like I might be able to construct a workaround with this.

EDIT: With the php edits in place, I've decided to actually simplify the rules.
Considering anything /adm/, /ucp.php and /posting.php is something that requires or triggers a login, I've simply added a location statement to my nginx http server block like so:

Code: Select all

    location ~ /(adm/|ucp\.php|posting\.php) {
        return         301 https://$server_name$request_uri;
    }
The only part I no longer have is switching back to http upon logout (since phpbb 3.1 no longer seems to have a mode=logout URI) but that's not really a big issue; people can stay on their SSL if they were previously logged in anyway.

This seems to work fine otherwise! Problem solved, for now! :)
User avatar
wolfbeast
Registered User
Posts: 69
Joined: Sat Aug 10, 2013 1:24 am

Re: Limited SSL Usage (original hook by ToonArmy)

Post by wolfbeast »

Question: why is the core file edit needed?
Pond Life
Registered User
Posts: 388
Joined: Sat Jan 20, 2007 1:55 am

Re: Limited SSL Usage (original hook by ToonArmy)

Post by Pond Life »

It's for the login form on the index page.

http://startrekguide.com/community/view ... 10#p117761
Never argue with idiots, they will drag you down to their level and beat you with experience.
User avatar
RMcGirr83
Former Team Member
Posts: 21823
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: Limited SSL Usage (original hook by ToonArmy)

Post by RMcGirr83 »

Pond Life wrote:It's for the login form on the index page.

http://startrekguide.com/community/view ... 10#p117761

Code: Select all

		'S_LOGIN_ACTION'		=> ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("{$phpbb_admin_path}index.$phpEx", false, true, $user->session_id)),
Doesn't have to edited at all as there is an event available to overwrite that.
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then buy me a beerImage
Pond Life
Registered User
Posts: 388
Joined: Sat Jan 20, 2007 1:55 am

Re: Limited SSL Usage (original hook by ToonArmy)

Post by Pond Life »

Thanks Rich, I have no idea how to use events or create extensions though, which is why I posted the request here. I had intended my work around to be temporary but it will have to stay unless someone with more ability than I have can convert the hook into an extension.
Never argue with idiots, they will drag you down to their level and beat you with experience.
Post Reply

Return to “Extension Requests”