Very short trick: maintenance mode via IP

When developing a product (website, Blog, Facebook App) online, if you have not been able to build an infrastructure development / operations, it may be necessary under certain circumstances put "off-line" service, upgrades, debugging or interventions maintenance. WordPress, for example, can be turned off using simple and convenient Plugin, as Maintenance Mode . In all other cases, let me show you how to allow access to a system, only to yourself or a number of persons who are authorized by simply checking the IP address. What you need is PHP and be able to place the lines of code at the highest point of the system, ie, in that part of the code (or pages) that is called normally always first; type the header of a site to be clear:

1
2
3
4
5
6
7
8
9
10
/ / I build a list of authorized IP address
array ( "87.6.45.33" , "234.34.34.2" ) ; // etc... $ AllowIP = array ("87.6.45.33", "234.34.34.2"); / / etc ...

/ / If the IP is not among those allowed
! in_array ( $_SERVER [ 'REMOTE_ADDR' ] , $allowIP ) { if ( in_array ($ _SERVER ['REMOTE_ADDR'], $ allowIP) {
/ / Include maintenance mode
; die ();
}

/ / Continue the normal display

There are no comments for this post

Leave a comment

TAG XHTML PERMITS: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> CODE ENTRY:
 <pre></pre> // blocco generico <code></code> // blocco generico [cc_actionscript][/cc_actionscript] // Actionscript [cc_actionscript3][/cc_actionscript3] // Actionscript 3 [cc_css][/cc_css] // CSS Style Sheet [cc_html][/cc_html] // HTML [cc_js][/cc_js] // Javascript [cc_objc][/cc_objc] // Objective-C [cc_php][/cc_objc] // PHP [cc_sql][/cc_sql] // SQL