How to call drupal_bootstrap from custom file in subfolder? I'm trying to call drupal_bootstrap from 'temp.php' in a subfolder called 'custom' my code as follow:

chdir('../');
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);


Once I call the temp.php I get Drupal homepage. 

I also tried an explicit physical path but with no use, code as follow:

define('DRUPAL_ROOT', '/var/htdocs/drupal7');
require_once '../includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);


temp.php located under the following folder structure:

- var
-- htdocs
--- drupal7
---- custom 
----- temp.php
take a look at http://drupal.org/project/js they implemented a custom js.php that bootstraps drupal.

/**
 * @file
 * Callback page that serves custom JavaScript requests on a Drupal installation.
 */

/**
 * @var The Drupal root
 */
define('DRUPAL_ROOT', getcwd());

/**
 * @} End of "Required core files".
 */

/**
 * @name Required core files
 * @{
 * The minimal core files required to be able to run a js request
 */
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
require_once DRUPAL_ROOT . '/includes/common.inc';
require_once DRUPAL_ROOT . '/includes/module.inc';
require_once DRUPAL_ROOT . '/includes/unicode.inc';
require_once DRUPAL_ROOT . '/includes/file.inc';
/**
 * @} End of "Required core files".
 */

// Do basic bootstrap to make sure the database can be accessed
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);