* 02110-1301 USA, or see the FSF site: http://www.fsf.org. ******************************************************************************/ include_once 'utils.php'; /** * Clean all the current data. * * @author Richard Friedman */ writeDatabaseInformation(); writeLine("<b>Cleaning up all the data.</b>"); $database = RingsideApiDbDatabase::getDatabaseConnection(); if ($database === false) { writeLine("No such database is currently available"); RingsideApiDbDatabase::closeConnection($database); } else { $schema = readSqlFile('RingsideDbCleanData.sql'); if ($schema === false) { writeError(' The SQL could not be loade from the application '); exit; } $result = RingsideApiDbDatabase::queryMultiLine($schema, $database); if ($result === false) { writeError('The database was not cleaned properly, check the error log.'); } else { writeLine("Database " . RingsideApiConfig::$db_name . " cleaned successfully "); } } writeLine(); writeLine("<b>Other options</b>"); writeLink("index.php", "Main Page"); writeLink("clean.php", "Clean Database");
/** * Load the basic data to get started out of box. * * @param string $defaultPassword * @param string $adminPassword * @param database_connection $database * @return true/false on setting up data. */ function loadBasicData($defaultPassword, $adminPassword, $database = null) { $fixtureInstallFailed = false; if ((include_once 'RingsideWebFixtures.php') === false) { writeError('Could not include web fixtures.'); } try { RingsideWebFixtures::installLocalDomain(); RingsideWebFixtures::installApps(); } catch (Exception $e) { writeError('Could not install web fixtures: ' . $e->getMessage()); $fixtureInstallFailed = true; } if (!$fixtureInstallFailed) { writeLine('Successfully installed web fixtures.'); } $schema = readSqlFile('RingsideDbBasicData.sql'); if ($schema === false) { writeError(' The SQL could not be loaded from the application '); return false; } // Some replacements need to happen for this script. $schema = str_replace('$everyPassword', sha1($defaultPassword), $schema); $schema = str_replace('$adminPassword', sha1($adminPassword), $schema); $schema = str_replace('$socialApiKey', RingsideSocialConfig::$apiKey, $schema); $schema = str_replace('$socialSecretKey', RingsideSocialConfig::$secretKey, $schema); $schema = str_replace('$webNetworkKey', RingsideWebConfig::$networkKey, $schema); $schema = str_replace('$webUrl', RingsideApiClientsConfig::$webUrl, $schema); $schema = str_replace('$socialUrl', RingsideApiClientsConfig::$socialUrl, $schema); $schema = str_replace('$serverUrl', RingsideApiClientsConfig::$serverUrl, $schema); global $demoUrl; if (isset($demoUrl) && !empty($demoUrl)) { $schema = str_replace('$demoUrl', $demoUrl, $schema); } else { $schema = str_replace('$demoUrl', RingsideApiClientsConfig::$webUrl, $schema); } $database = RingsideApiDbDatabase::getDatabaseConnection(); $result = RingsideApiDbDatabase::queryMultiLine($schema, $database); if ($result === false) { writeError('The database was not setup properly, check the error log. <br /> ' . mysql_error()); return false; } else { writeLine("Database <b>" . RingsideApiConfig::$db_name . "</b> setup successfully "); return true; } }