2014-11-28 00:48:03 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once(LIB_PATH . "propel/runtime/lib/Propel.php");
|
|
|
|
|
2014-11-28 01:10:23 +01:00
|
|
|
/**
|
|
|
|
* Check to see if Airtime is properly configured.
|
|
|
|
*
|
|
|
|
* @return boolean true if all Airtime dependencies and services are
|
|
|
|
* properly configured and running
|
|
|
|
*/
|
|
|
|
function airtimeCheckConfiguration() {
|
2014-11-28 21:30:11 +01:00
|
|
|
return airtimeCheckPhpDependencies()
|
|
|
|
&& airtimeCheckDatabaseConfiguration();
|
2014-11-28 01:10:23 +01:00
|
|
|
}
|
|
|
|
|
2014-11-28 21:30:11 +01:00
|
|
|
/**
|
|
|
|
* Check for Airtime's PHP dependencies and return an associative
|
|
|
|
* array with the results
|
|
|
|
*
|
|
|
|
* @return array associative array of dependency check results
|
|
|
|
*/
|
|
|
|
function airtimeCheckPhpDependencies() {
|
|
|
|
return array(
|
|
|
|
"zend" => airtimeCheckMvcDependencies(),
|
|
|
|
"postgres" => airtimeCheckDatabaseDependencies()
|
|
|
|
);
|
2014-11-28 00:48:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-11-28 21:30:11 +01:00
|
|
|
* Check that the Zend framework libraries are installed
|
2014-11-28 00:48:03 +01:00
|
|
|
*
|
2014-11-28 21:30:11 +01:00
|
|
|
* @return boolean true if Zend exists in /usr/share/php
|
2014-11-28 00:48:03 +01:00
|
|
|
*/
|
2014-11-28 21:30:11 +01:00
|
|
|
function airtimeCheckMvcDependencies() {
|
|
|
|
return file_exists('/usr/share/php/libzend-framework-php')
|
|
|
|
|| file_exists('/usr/share/php/zendframework'); // Debian version
|
|
|
|
}
|
2014-11-28 01:10:23 +01:00
|
|
|
|
2014-11-28 21:30:11 +01:00
|
|
|
/**
|
|
|
|
* Check that the PHP dependencies for the database exist
|
|
|
|
*
|
|
|
|
* @return boolean true if the database dependencies exist
|
|
|
|
*/
|
|
|
|
function airtimeCheckDatabaseDependencies() {
|
|
|
|
if (!isset($extensions)) {
|
|
|
|
$extensions = get_loaded_extensions();
|
2014-11-28 00:48:03 +01:00
|
|
|
}
|
2014-11-28 21:30:11 +01:00
|
|
|
// Check the PHP extension list for the Postgres db extensions
|
|
|
|
return (in_array('pdo_pgsql', $extensions)
|
|
|
|
&& in_array('pgsql', $extensions));
|
|
|
|
}
|
2014-11-28 00:48:03 +01:00
|
|
|
|
2014-11-28 21:30:11 +01:00
|
|
|
/**
|
|
|
|
* Check the database configuration by fetching a connection from Propel
|
|
|
|
*
|
|
|
|
* @return boolean true if a connection is made to the database
|
|
|
|
*/
|
|
|
|
function airtimeCheckDatabaseConfiguration() {
|
|
|
|
airtimeConfigureDatabase();
|
2014-11-28 00:48:03 +01:00
|
|
|
|
|
|
|
try {
|
2014-11-28 21:30:11 +01:00
|
|
|
// Try to establish a database connection. If something goes
|
|
|
|
// wrong, the database is improperly configured
|
|
|
|
Propel::getConnection();
|
|
|
|
Propel::close();
|
2014-11-28 00:48:03 +01:00
|
|
|
} catch (Exception $e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-28 21:30:11 +01:00
|
|
|
/**
|
|
|
|
* Initialize Propel to configure the Airtime database
|
|
|
|
*/
|
2014-11-28 00:48:03 +01:00
|
|
|
function airtimeConfigureDatabase() {
|
2014-11-28 21:30:11 +01:00
|
|
|
Propel::init(CONFIG_PATH . 'airtime-conf-production.php');
|
2014-11-28 00:48:03 +01:00
|
|
|
}
|