Managing a development area
by
31 Jan 2010
This is a little something I came up with to deal with having somewhere to develop mods and somewhere to test things like install code. It also deals with the password protected requirement for development areas in one nice little package.
Edit config.php, at the bottom of the file above the ?> add:
PHP Code:
if (!isset($_SERVER['PHP_AUTH_USER']))
{
header('WWW-Authenticate: Basic realm="Vbulletin Development site"');
header('HTTP/1.0 401 Unauthorized');
echo 'You must login to access this resource';
exit;
}
else
{
if($_SERVER['PHP_AUTH_PW'] == $config['SpecialUsers']['htaccess'][$_SERVER['PHP_AUTH_USER']]['password'])
{
$config['Database']['tableprefix'] = $config['SpecialUsers']['htaccess'][$_SERVER['PHP_AUTH_USER']]['prefix'];
$config['Misc']['debug'] = $config['SpecialUsers']['htaccess'][$_SERVER['PHP_AUTH_USER']]['debug'];
if($config['SpecialUsers']['htaccess'][$_SERVER['PHP_AUTH_USER']]['demo'])
{
define('DEMO_MODE',true);
}
}
}
Anyone who is sufficiently astute will realise that that is performing http authentification AND setting debug mode and table prefix based on the username. All you need now is an array of settings for the users that are allowed to visit your dev area.
PHP Code:
$config['SpecialUsers']['htaccess']['carnage_test1'] = array('password'=>'mypassword','prefix'=>'test1','debug'=>true,'demo'=>false);
$config['SpecialUsers']['htaccess']['carnage_test2'] = array('password'=>'mypassword','prefix'=>'test2','debug'=>true,'demo'=>false);
Placing that array above the code from the top of this post defines two users, each of the users accesses a different database. You can then make two installs of vbulletin, sharing the same codebase. Once you've written a product, export it. Switch user (generally closing your browser is required; some browsers offer a htaccess logout button/method).
It gets better. Say you are working for two clients; developing a mod for one and a skin for another. During develoment you have two isntalls, one for each project with the prefixes above. If you want to show your client the work in progress and get some feedback you can set them up a login like this:
PHP Code:
$config['SpecialUsers']['htaccess']['clientx'] = array('password'=>'theirpassword','prefix'=>'test1','debug'=>false,'demo'=>true);
$config['SpecialUsers']['htaccess']['clienty'] = array('password'=>'theirpassword','prefix'=>'test2','debug'=>false,'demo'=>true);
neither will be able to access the other install and the demo mode setting will prevent them from messing around with sensitive admincp controls. You should set them their own admin account up as well and don't give it any permissions such as the ability to run sql queries.
Disclaimer:
This dosn't provide 100% security as it relies upon an unsupported, undocumented feature of vb: demo mode. You should make your own tests to ensure that its secure enough for your needs.
Some uses of the information contained above may require multiple vbulletin liscenses. It is your responsibility to ensure you have enough liscenses to cover your dev installs.
|