Esempio n. 1
0
	/**
	 * Get the current system DMI based on configuration values.
	 *
	 * @throws DMI_Exception
	 * @throws DMI_Authentication_Exception
	 *
	 * @return DMI
	 */
	public static function GetSystemDMI(){
		if(self::$_Interface !== null) return self::$_Interface;
		
		self::$_Interface = new DMI();
		

		if(file_exists(ROOT_PDIR . 'config/configuration.xml')){
			// Because this is the system data connection, I also need to pull the settings automatically.
			// This will only be done if the configuration file exists.
			$cs = ConfigHandler::LoadConfigFile("configuration");
		}
		elseif(\Core\Session::Get('configs/*') !== null){
			// If the file doesn't exist, (ie: during installation), I need to check the session data.
			$cs = \Core\Session::Get('configs/*');
		}
		else{
			throw new DMI_Exception('No database settings defined for the DMI');
		}

		self::$_Interface->setBackend($cs['database_type']);
		
		self::$_Interface->connect($cs['database_server'], $cs['database_user'], $cs['database_pass'], $cs['database_name']);
		
		return self::$_Interface;
	}
Esempio n. 2
0
	/**
	 *
	 * @param BackendInterface $interface
	 * @return Dataset
	 */
	public function execute($interface = null){
		// Default to the system interface.
		if(!$interface){
			$dmi = \DMI::GetSystemDMI();
			$interface = $dmi->connection();
		}

		// This actually goes the other way, as the interface has the logic.
		$interface->execute($this);

		if( $this->_data === null && $this->_mode == Dataset::MODE_GET ){
			// It's been executed, so data should at least be something.
			$this->_data = [];
			reset($this->_data);
		}

		// Allow Chaining
		return $this;
	}
	/**
	 * Test the database connection given the SESSION data.
	 * Will gracefully handle exceptions.
	 *
	 * @return array
	 */
	private function testDatabaseConnection(){

		try{
			require_once(ROOT_PDIR . 'core/libs/core/datamodel/DMI.class.php');
			$dbconn = \DMI::GetSystemDMI();
		}
		// The server can't be located
		catch(\DMI_ServerNotFound_Exception $e){
			return [
				'status' => 'failed',
				'message' => $e->getMessage(),
				'instructions' => '',
			];
		}
		// This is specific to user denied.
		catch(\DMI_Authentication_Exception $e){
			return [
				'status' => 'failed',
				'message' => $e->getMessage(),
				'instructions' => $this->getDatabaseUserInstructions(),
			];
		}
		// Any other error.
		// Couldn't establish connection... do something fun!
		catch(\Exception $e){
			return [
				'status' => 'failed',
				'message' => $e->getMessage(),
				'instructions' => $this->getDatabaseDatabaseInstructions(),
			];
		}

		// w00t, it must have worked!
		return ['status' => 'passed', 'message' => 'Connection succeeded', 'instructions' => ''];
	}
	}
	catch (Exception $e) {
		// Yeah... I probably don't care at this stage... but maybe I do...
		\Core\ErrorManagement\exception_handler($e);
	}
}

if(!defined('CDN_TYPE')){
	define('CDN_TYPE', 'local');
}
if(!defined('CDN_LOCAL_ASSETDIR')){
	define('CDN_LOCAL_ASSETDIR', 'files/assets/');
}
if(!defined('CDN_LOCAL_PUBLICDIR')){
	define('CDN_LOCAL_PUBLICDIR', 'files/public/');
}


require_once(ROOT_PDIR . 'core/libs/core/Core.class.php');
require_once(ROOT_PDIR . 'core/libs/core/ComponentHandler.class.php');
require_once(ROOT_PDIR . 'core/helpers/UpdaterHelper.class.php');
require_once(ROOT_PDIR . 'core/libs/core/datamodel/Dataset.php');

$db = DMI::GetSystemDMI();

$ds = new \Core\Datamodel\Dataset();
$ds->delete()->table('component')->execute($db);

// And now execute reinstall.
exec('"' . ROOT_PDIR . '../utilities/reinstall.php' . '"');
Esempio n. 5
0
);
$maindefines_time = microtime(true);


// Now the core of the application, config handler, and all necessary core
//  settings should be available.


/**************************  START EXECUTION *****************************/

\Core\Utilities\Profiler\Profiler::GetDefaultProfiler()->record('Core Plus bootstrapped and application starting');

// Datamodel, GOGO!
//require_once(ROOT_PDIR . 'core/libs/core/datamodel/DMI.class.php');
try {
	$dbconn = DMI::GetSystemDMI();
	ConfigHandler::_DBReadyHook();
}
	// This catch statement should be hit anytime the database is not available,
	// core table doesn't exist, or the like.
catch (Exception $e) {
	error_log($e->getMessage());
	// Couldn't establish connection... do something fun!
	// If it's in development mode, redirect back to the installer, which should hopefully
	// get whatever problem this was fixed.
	if (DEVELOPMENT_MODE) {
		//header('HTTP/1.1 302 Moved Temporarily');
		//header('Location: ' . ROOT_WDIR . 'install');
		die('Please <a href="' . ROOT_WDIR . 'install' . '">install Core Plus.</a>');
	}