Made provisioning helper slightly more robust
This commit is contained in:
parent
52813045a6
commit
95db8533b5
|
@ -36,7 +36,7 @@ require_once (APPLICATION_PATH."/logging/Logging.php");
|
|||
Logging::setLogPath('/var/log/airtime/zendphp.log');
|
||||
|
||||
// We need to manually route because we can't load Zend without the database being initialized first.
|
||||
if (array_key_exists("REQUEST_URI", $_SERVER) && (strpos($_SERVER["REQUEST_URI"], "/provisioning/create") !== false)) {
|
||||
if (array_key_exists("REQUEST_URI", $_SERVER) && (stripos($_SERVER["REQUEST_URI"], "/provisioning/create") !== false)) {
|
||||
$provisioningHelper = new ProvisioningHelper($CC_CONFIG["apiKey"][0]);
|
||||
$provisioningHelper->createAction();
|
||||
die();
|
||||
|
|
|
@ -37,28 +37,31 @@ class ProvisioningHelper
|
|||
$this->parsePostParams();
|
||||
|
||||
//For security, the Airtime Pro provisioning system creates the database for the user.
|
||||
$this->setNewDatabaseConnection();
|
||||
if ($this->dbhost && !empty($this->dbhost)) {
|
||||
$this->setNewDatabaseConnection();
|
||||
|
||||
//if ($this->checkDatabaseExists()) {
|
||||
// throw new Exception("ERROR: Airtime database already exists");
|
||||
//}
|
||||
//if ($this->checkDatabaseExists()) {
|
||||
// throw new Exception("ERROR: Airtime database already exists");
|
||||
//}
|
||||
|
||||
if (!$this->checkDatabaseExists()) {
|
||||
throw new Exception("ERROR: $this->dbname database does not exist.");
|
||||
}
|
||||
if (!$this->checkDatabaseExists()) {
|
||||
throw new Exception("ERROR: $this->dbname database does not exist.");
|
||||
}
|
||||
|
||||
//We really want to do this check because all the Propel-generated SQL starts with "DROP TABLE IF EXISTS".
|
||||
//If we don't check, then a second call to this API endpoint would wipe all the tables!
|
||||
if ($this->checkTablesExist()) {
|
||||
throw new Exception("ERROR: airtime tables already exists");
|
||||
//We really want to do this check because all the Propel-generated SQL starts with "DROP TABLE IF EXISTS".
|
||||
//If we don't check, then a second call to this API endpoint would wipe all the tables!
|
||||
if ($this->checkTablesExist()) {
|
||||
throw new Exception("ERROR: airtime tables already exists");
|
||||
}
|
||||
|
||||
$this->createDatabaseTables();
|
||||
$this->initializeMusicDirsTable($this->instanceId);
|
||||
}
|
||||
|
||||
//$this->createDatabase();
|
||||
|
||||
//All we need to do is create the database tables.
|
||||
|
||||
$this->createDatabaseTables();
|
||||
$this->initializeMusicDirsTable($this->instanceId);
|
||||
$this->initializePrefs();
|
||||
} catch (Exception $e) {
|
||||
http_response_code(400);
|
||||
|
|
Loading…
Reference in New Issue