Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6838727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:37:54+00:00 2026-05-26T23:37:54+00:00

We have an MU (Multisite) installation of Drupal7 here at work, and are trying

  • 0

We have an MU (Multisite) installation of Drupal7 here at work, and are trying to
temporarily hold back the swarm of bots we receive until we get a chance to load our
content. I wrote a quick and and dirty script to send 503 headers if we find a certain
criteria in Xpath (This can ALSO be done as a strpos/preg_match if DOM is not formed).

In order to get the ball rolling though I need to figure out how to either

A) Hijack the Drupal7 bootstrap and pull all content through this filter below

B) ob_flush content through the filter before content is loaded

WORTH MENTIONING We use a Module that is called Domain Access, which I believe
has led me on this crazy chase in the first place. I know for a fact that it muddles
with quite a few files…

The issue that I am having is figuring out exactly where I can catch the content
at? It should be possible to push the stream into a variable, strpos it, then release it, correct? I thought that index.php in Drupal7 would be the suspect, but I’m a little
confused as to where or how I should capture the contents. Here’s the script,
and hopefully someone can point me in the right direction.

//error_reporting(-1);

    /* start query */

    $dom = new DOMDocument;
    $dom->preserveWhiteSpace = false;
    $dom->Load($_SERVER['PHP_SELF']);

    $xpath = new DOMXPath($dom);

        //if this exists we aren't ready to be read by bots
        $query = $xpath->query(".//*[@id='block-views-about-this-site-block']/div/div/div");
        //or $query = 'klat-badge'; //if this is a string not DOM

    /* end query */

if(strpos($query) !== false) { 

    //require banlist
    require('botlist.php'); 

    $str = strtolower('/'.implode('|', array_unique($list)).'/i'); 
    if(preg_match($str, strtolower($_SERVER['HTTP_USER_AGENT']))) {
        //so tell bots we're broken
        header('HTTP/1.1 503 Service Temporarily Unavailable');
        header('Status: 503 Service Temporarily Unavailable');
        exit;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:37:55+00:00Added an answer on May 26, 2026 at 11:37 pm

    It would be a lot easier to just define a constant in a module and check that instead. You could then use hook_init() to make a decision on whether the page is ready before the content is even built:

    define('IN_DEVELOPMENT', TRUE);
    
    function mymodule_init() {
      if (IN_DEVELOPMENT) {
        //require banlist
        require('botlist.php'); 
    
        $str = strtolower('/'.implode('|', array_unique($list)).'/i'); 
        if(preg_match($str, strtolower($_SERVER['HTTP_USER_AGENT']))) {
          //so tell bots we're broken
          header('HTTP/1.1 503 Service Temporarily Unavailable');
          header('Status: 503 Service Temporarily Unavailable');
          exit;
        }
      }
    }
    

    There might be a way to do what you want by loading the whole page content into a DOMDocument but it wont be easy in Drupal (as I’m sure you’ve already discovered!) and certainly not efficient.

    Hope that helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our company is trying to transition to WordPress Multisite but we have several issues
I am trying to get Wordpress 3.3.1 multisite (sub-domains) working in my localhost. However,
I have a website with Wordpress 3.0.4 installation, set up as multisite install. Some
I have a Wordpress Multisite which was working fine until I migrated the instance
I have a multisite Drupal installation with about 20 urls pointing to the same
I have a multisite Drupal installation with about 20 urls pointing to the same
I have a multisite drupal installation with domain access module. Off late, I have
I have some 20 sites with common codebase and database via Drupal Multisite installation.
I have 17 sites with a multisite installation and uses the domain access module.
I have a multi-site Drupal-6 installation containing websites of different customers. On each site,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.