<?php
// defines database connection data
//Cause browser to reload page every time
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past

// set syatem constants
define( 'DS', DIRECTORY_SEPARATOR );

//get root folder
$rootFolder = explode(DS,dirname(__FILE__));
	
//current level in diretoty structure
$currentfolderlevel = 6;

array_splice($rootFolder,-$currentfolderlevel);

$base_folder = implode(DS,$rootFolder);


if(is_dir($base_folder.DS.'libraries'.DS.'joomla'))   
{
	
		
	define( '_JEXEC', 1 );
	
	define('JPATH_BASE',implode(DS,$rootFolder));
	
	require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
		
	/* Load in the configuation file */
	
	//require_once( '../../../../../../../configuration.php' );
	require_once( JPATH_CONFIGURATION	.DS.'configuration.php' );
	
	/*load loader class */
	
	require_once(JPATH_LIBRARIES .DS.'loader.php' );
	require_once(JPATH_LIBRARIES .DS. 'joomla' .DS . 'methods.php' ); 
	
	
	/* Load Joomla's required classes */
	
	jimport('joomla.base.object');
	jimport('joomla.filter.filterinput');
	jimport('joomla.database.database');
	jimport('joomla.factory');
	jimport('joomla.error.error');
	jimport('joomla.environment.uri');
	
	
	
	//get system parameters
	
	$JConfig = new JConfig();
	
								
	define('DB_DRIVER',$JConfig->dbtype);
	define('DB_HOST', $JConfig->host);
	define('DB_USER', $JConfig->user );
	define('DB_PASSWORD',$JConfig->password);
	define('DB_DATABASE', $JConfig->db ); 
	define('DB_PREFIX', $JConfig->dbprefix); 
	define('DB_OFFLINE', $JConfig->offline);
}
else
{
	require_once( '../../../../../../configuration.php' );
	/* Load Joomla's DB Class */
	define( '_VALID_MOS', 1 );
	require_once( '../../../../../../includes/database.php' );
	/* Create a new Instance */

	define('DB_HOST', $mosConfig_host );
	define('DB_USER', $mosConfig_user );
	define('DB_PASSWORD',$mosConfig_password);
	define('DB_DATABASE', $mosConfig_db ); 
	define('DB_PREFIX', $mosConfig_dbprefix); 
	define('DB_OFFLINE', $mosConfig_offline);
}
