I am developing a stand-alone application, which uses drupal functions and I faced with some troubles. First of all my application must check has the user access to this application and if he doesn’t have permissions show error message. If user is logged on and has permissions my application must show him some actions… First of all I created subdomain in Apache, for example I named it:
myapps.site.com. The trouble is: when unauthorized user entered this address, main page of site.com is loaded (only text without pictures), not my page with error message, but when he printed myapps.site.com/index.php everything is OK and error message loads. When authorized user enters this page everything is OK. I have checked, that the problem is with
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
Here is my sample of code:
<?php
chdir('/www/mysite/');
require_once './includes/bootstrap.inc';
require_once './includes/form.inc';
// Here is problem
// if I comment this and show only err message everything is also OK
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
global $user;
// Here I am loading additional info to check if the user has access
profile_load_profile(&$user);
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="styles/styles.css" />
<script src="jscripts/jQuery.js"></script>
<title>app</title>
</head>
<body>';
// here i check user priviliges
if (!$user->uid || $user->profile_is_priviliged == FALSE )
{
echo 'some err msg';
}
else
{
echo 'some actions';
}
echo '</body></html>'; ?>
As I have understood the problem also may rise because of that this is subdomain and basic path in settings.php is site.com and by default drupal_bootstrap loads content of main page.
Use http://drupal.org/project/domain for this kind of thing, don’t code it yourself.