diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php index 153ce672d..7c9cf8c20 100644 --- a/airtime_mvc/application/Bootstrap.php +++ b/airtime_mvc/application/Bootstrap.php @@ -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(); diff --git a/airtime_mvc/application/common/ProvisioningHelper.php b/airtime_mvc/application/common/ProvisioningHelper.php index d8183a57c..a436e6974 100644 --- a/airtime_mvc/application/common/ProvisioningHelper.php +++ b/airtime_mvc/application/common/ProvisioningHelper.php @@ -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);