Post by Joe1234 » Tue Jan 10, 2023 5:44 am

Is there a way I can give people access to the site while in maintenance mode? Or some other type of workaround to blocking general access to the site and giving specific people access by ways of registering them or a direct url?

....without giving them admin access. And without putting a bunch of IP addresses in my htaccess.
Last edited by Joe1234 on Thu Jan 12, 2023 2:16 pm, edited 1 time in total.

v3.0.4.0 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by straightlight » Tue Jan 10, 2023 9:07 am

Joe1234 wrote:
Tue Jan 10, 2023 5:44 am
Is there a way I can give people access to the site while in maintenance mode? Or some other type of workaround to blocking general access to the site and giving specific people access by ways of registering them or a direct url?

....without giving them admin access. And without putting a bunch of IP addresses in my htaccess.
Order desk.

https://www.opencart.com/index.php?rout ... aintenance

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by paulfeakins » Tue Jan 10, 2023 6:51 pm

Joe1234 wrote:
Tue Jan 10, 2023 5:44 am
....without giving them admin access. And without putting a bunch of IP addresses in my htaccess.
You can use an .htaccess password rather than restrict it to IPs.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by Joe1234 » Tue Jan 10, 2023 9:11 pm

@straightlight I was looking for an easy free solution, it's just for a one time need.

@paulfeakins forgot about htpassword, good thought, but I was hoping to avoid all of ht stuff because I have a signup and quick info on the maintenance page I wanted to display...I'm assuming with the htpassword I would set it in the main dir and turn off the maintenance.

v3.0.4.0 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by Joe1234 » Wed Jan 11, 2023 2:42 pm

I figured out how I want to attack this, but I need to know which file processes whether the site is in maintenance mode, any help?

v3.0.4.0 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by paulfeakins » Wed Jan 11, 2023 3:53 pm

Joe1234 wrote:
Wed Jan 11, 2023 2:42 pm
I need to know which file processes whether the site is in maintenance mode, any help?
What I would do first to find that out is inspect the button in the admin to find out its name which might give a hint at the variable / setting name being used in the code / database. Then I'd probably grep the source for that variable.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by ADD Creative » Wed Jan 11, 2023 6:27 pm

Have a look at catalog/controller/startup/maintenance.php.

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by pprmkr » Wed Jan 11, 2023 9:05 pm

Joe1234 wrote:
Tue Jan 10, 2023 5:44 am
Is there a way I can give people access to the site while in maintenance mode? Or some other type of workaround to blocking general access to the site and giving specific people access by ways of registering them or a direct url?

....without giving them admin access. And without putting a bunch of IP addresses in my htaccess.
Add column to customer_group in model/account/customer_group:

Code: Select all

	public function check_group_table() {
		$group_altered = $this->db->query("SHOW COLUMNS FROM `".DB_PREFIX."customer_group` LIKE 'grant_access';");
		if ( !$group_altered->row ) {
			$this->db->query("ALTER TABLE `".DB_PREFIX."customer_group` ADD `grant_access` tinyint NOT NULL DEFAULT '0';");	
		}
	}
And after:

Code: Select all

public function getCustomerGroup($customer_group_id) {
Add:

Code: Select all

		$this->check_group_table();
Assign selected customer to this group. In phpMyadmin set value = 1 to new column in customer_group !

Then in controller/startup/maintenance.php after:

Code: Select all

$this->user = new Cart\User($this->registry);
Add:

Code: Select all

			$this->load->model('account/customer');
			$customer_id = $this->customer->isLogged();
			$deny_access = true;
			if ($customer_id) {
				$customer_info = $this->model_account_customer->getCustomer($customer_id);
				$this->load->model('account/customer_group');
				$customer_group = $this->model_account_customer_group->getCustomerGroup($customer_info['customer_group_id']);

				if (isset($customer_group['grant_access']) && $customer_group['grant_access'] == 1) {
					$deny_access = false;
				}
			}
Also change ingnore array into:

Code: Select all

			$ignore = array(
				'account/login',
				'common/language/language',
				'common/currency/currency'
			);
Change:

Code: Select all

			if ((substr($route, 0, 17) != 'extension/payment' && substr($route, 0, 3) != 'api') && !in_array($route, $ignore) && !$this->user->isLogged()) {
into:

Code: Select all

			if ((substr($route, 0, 17) != 'extension/payment' && substr($route, 0, 3) != 'api') && !in_array($route, $ignore) && !$this->user->isLogged() && $deny_access) {
Edit: added change to ignore table. Otherwise customer cannot login!

User avatar
Active Member

Posts

Joined
Sat Jan 08, 2011 11:05 pm
Location - Netherlands

Post by Joe1234 » Thu Jan 12, 2023 2:16 pm

Thanks all. I ended up going a different route before I saw this last post. I decided to copy the site, and put the duplicate site behind an htpasswd, and put a link to the duplicate site on the primary site's maintenance page. This gives me all the functionality I need.

@pprmkr I'll test out that mod when I have a chance. It may still be useful to me, thanks.

v3.0.4.0 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am
Who is online

Users browsing this forum: No registered users and 43 guests