📜 ⬆️ ⬇️

We close access to the site

From time to time in our studio there are situations when, for one reason or another, it is necessary to close access to a working site. For example, a new site that is only configured on the server, or on a running project, is updating the functionality.

Naturally the question is to close access for ordinary visitors, and for trusted people the site should function.

To be honest, I don’t remember how we did it before :), but now we are resolving this issue by following the introduction into the index file, which all requests go to with modrevrait. You can also embed in the library file, which is called from all project scripts.
')
 $ SecretKey = 'i-want-to-see-this-site';
 $ AdminCookie = 'HOHOHO!  I am super hacker! ';
 if ($ _COOKIE ['AdminCookie']! = $ AdminCookie && $ _SERVER ['QUERY_STRING']! = $ SecretKey) {
     require_once 'page_park.html';
     exit;
 } else {
     setcookie ('AdminCookie', $ AdminCookie, time () + 3600 * 24 * 365, '/');
     if ($ _SERVER ['QUERY_STRING'] == $ SecretKey) {
         header ('Location: /');
         exit;
     }
 }

Thanks to this small code, all people will get to page_park.html, and those who have chosen can simply go to http: // our_site /? I-want-to-see-this-site to get full access to the site. And most importantly, during subsequent visits, favorites will immediately get to the working site without any problems, which is very useful if the site is configured and launched within a few days.

UPD. This is a temporary “curtain”, and the key and the value of cookies are specially placed in variables so that they can be changed from update to update and from project to project.

PS Just this morning we set up a new website on the server, so I decided to share such an unpretentious chip with the public.

Source: https://habr.com/ru/post/77733/


All Articles