if ($databaseExisted) { //Database already exists. Ask the user how they want to //proceed. Warn them that creating the database tables again //will cause them to lose their old ones. $userAnswer = "x"; while (!in_array($userAnswer, array("y", "Y", "n", "N", ""))) { echo PHP_EOL . "Database already exists. Do you want to delete all tables and recreate? (y/N)"; $userAnswer = trim(fgets(STDIN)); } if (in_array($userAnswer, array("y", "Y"))) { AirtimeInstall::CreateDatabaseTables($dbuser, $dbpasswd, $dbname, $dbhost); } } else { //Database was just created, meaning the tables do not //exist. Let's create them. AirtimeInstall::CreateDatabaseTables($dbuser, $dbpasswd, $dbname, $dbhost); } } echo " * Setting Airtime version" . PHP_EOL; AirtimeInstall::SetAirtimeVersion(AIRTIME_VERSION); if (AirtimeInstall::$databaseTablesCreated) { AirtimeInstall::SetDefaultTimezone(); // set up some keys in DB AirtimeInstall::SetUniqueId(); AirtimeInstall::SetImportTimestamp(); $ini = parse_ini_file(__DIR__ . "/airtime-install.ini"); $stor_dir = realpath($ini["storage_dir"]) . "/"; echo " * Inserting stor directory location {$stor_dir} into music_dirs table" . PHP_EOL; $con = Propel::getConnection(); $sql = "INSERT INTO cc_music_dirs (directory, type) VALUES ('{$stor_dir}', 'stor')"; try {
if ($databaseExisted) { //Database already exists. Ask the user how they want to //proceed. Warn them that creating the database tables again //will cause them to lose their old ones. $userAnswer = "x"; while (!in_array($userAnswer, array("y", "Y", "n", "N", ""))) { echo PHP_EOL . "Database already exists. Do you want to delete all tables and recreate? (y/N)"; $userAnswer = trim(fgets(STDIN)); } if (in_array($userAnswer, array("y", "Y"))) { AirtimeInstall::CreateDatabaseTables(); } } else { //Database was just created, meaning the tables do not //exist. Let's create them. AirtimeInstall::CreateDatabaseTables(); } } echo "* Setting Airtime version" . PHP_EOL; AirtimeInstall::SetAirtimeVersion(AIRTIME_VERSION); // set up some keys in DB AirtimeInstall::SetUniqueId(); AirtimeInstall::SetImportTimestamp(); if (AirtimeInstall::$databaseTablesCreated) { $ini = parse_ini_file(__DIR__ . "/airtime-install.ini"); $stor_dir = realpath($ini["storage_dir"]) . "/"; echo "* Inserting stor directory location {$stor_dir} into music_dirs table" . PHP_EOL; $sql = "INSERT INTO cc_music_dirs (directory, type) VALUES ('{$stor_dir}', 'stor')"; $result = $CC_DBC->query($sql); if (PEAR::isError($result)) { echo "* Failed inserting {$stor_dir} in cc_music_dirs" . PHP_EOL;