SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    gimme the uuuuuuuuuuu duuudie's Avatar
    Join Date
    Feb 2004
    Location
    Switzerland
    Posts
    2,253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    what would be the best way to close your website if needed?

    Hi

    Anyone familiar with bboard softs know that you can close your board when you don't want people to have access to your site for some reasons.

    I was wondering what would be the best way to handle it?

    There is one obvious and easy solution: include a file at the top of each with a request to a table. If the value for the 'open' col is false --> redirect to a page displaying the 'close' message.

    Somwhow, hiting the db at the top of each page doesn't seem the best solution to me. Is there a better way? For example, is there a way to let the server know that in a 'closed website' situation he has to redirect users to a specific page? How tell the server (Apache in my case) that the situation is a 'closed website' one?

    thanks in advance for your time and your help

  2. #2
    does not play well with others frezno's Avatar
    Join Date
    Jan 2003
    Location
    Munich, Germany
    Posts
    1,391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If i recall correctly there's a possibility to individualize your 403/404 page.
    It might be possible to set up an htaccess to deactivate everything and output just your own 403 or 404 page.
    That might be a possibility to think about.

    Sorry that i can just be that vague but i'm no expert in htaccess and it's just an idea...
    We are the Borg. Resistance is futile. Prepare to be assimilated.
    I'm Pentium of Borg.Division is futile.Prepare to be approximated.

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    New Jersey
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to close it, put in .htaccess:
    RewriteEngine On
    RewriteRule .+ /closed.php

  4. #4
    gimme the uuuuuuuuuuu duuudie's Avatar
    Join Date
    Feb 2004
    Location
    Switzerland
    Posts
    2,253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by plugged
    If you want to close it, put in .htaccess:
    RewriteEngine On
    RewriteRule .+ /closed.php
    that way, all browsers requesting smthg to the server would be redirected to closed.php right?

  5. #5
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,672
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    duuudie,

    plugged didn't mention that his .htaccess addition should be in the directory that you want your requests redirected. That means, if you put it at the (virtual) site's root level, ALL site pages will get redirected.

    I've assumed (as has plugged?) that your bboard pages will be in their own directory and you'll only want those page requests redirected.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  6. #6
    SitePoint Enthusiast
    Join Date
    Mar 2003
    Location
    Fredericton NB
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would define a constant to indicate that the site is disabled, include the following at the top of every file in the site:

    PHP Code:
    if (SITE_DISABLED) {
        include(
    '/path/to/disabled.php');
        exit();

    You could even get fancier and tie it into a user group/permission system (if you have one) that would let YOU access the site, but deny everyone else.
    Red Cow Technologies, Inc
    RealAdmin - Software For Real Estate Agents
    myBusinessAdmin - Affordable CMS and web design solution.

  7. #7
    Employed Again Viflux's Avatar
    Join Date
    May 2003
    Location
    London, On.
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Along those same lines, I use an access control on each page.

    The pages that are accessable contain a
    PHP Code:
    define'ALLOWED' true ); 
    and then each page that is not directly accessable contains a
    PHP Code:
    if( !defined'ALLOWED' ) || ( ALLOWED != true ) ) {
      
    header'Location:http://www.hyfen8.com/errorPage?id=101');
      die();

    This allows me to redirect the user to the page I want, and can include different messages based on the ID passed.

    A simple search+replace for the define statement throughout the site will allow me to "disable" the site by switching it to false. The error page allows me to offer an explanation.

  8. #8
    gimme the uuuuuuuuuuu duuudie's Avatar
    Join Date
    Feb 2004
    Location
    Switzerland
    Posts
    2,253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for your replies

    Could you tell me more about how I would define constants, where and based on what?

    thanks in advance

  9. #9
    SitePoint Evangelist
    Join Date
    Dec 2000
    Posts
    528
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think this would work...at the top of each file:
    PHP Code:
    <?php

    require_once('status.php');

    ?>
    Then the status file. If you want to disable your site...
    PHP Code:
    echo('This site is closed. We apologize for the inconvenience.');
    die(); 
    Otherwise, just have that file blank.

    [Edit: Corbb can't spell]
    Last edited by JustForWebmasters; Jun 22, 2004 at 21:08.
    Corbb O'Connor
    Looking for quality website design or database programming?
    Contact me for more information and a FREE quote!

  10. #10
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,672
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    I had a terrible time searching for this last night but "pippo" over in the Apache forum has provided an .htaccess AUTO_PREPEND so that all your PHP files do not have to be modified to include a file! That thread is here.

    pippo's info was:
    # private/prepend.php will be parsed before any .php file content
    php_value auto_prepend private/prepend.php
    [Edit: There is more info about "auto_prepend_file" as a php.ini entry so the above may need to be modified.]

    Unfortunately, I can't find anything on the apache.org site, the php.net site and only a few postings here at sitepoint about auto_prepend except that its designated file is parsed BEFORE anything on the requested page as if it was included at the start of the file.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  11. #11
    gimme the uuuuuuuuuuu duuudie's Avatar
    Join Date
    Feb 2004
    Location
    Switzerland
    Posts
    2,253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you very much for your help guys

    it's really REALLY appreciated.

    (and sorry for the late follow up: $alex->holydays(); )


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •