if (!copy($installer_root . '/../../framework/php/settings/cashmusic_template.ini.php', $installer_root . '/../../framework/php/settings/cashmusic.ini.php')) { echo '\\nOh. Shit. Something\'s wrong. Couldn\'t write the config file.\\n\\n' . 'the directory you specified for the framework.</p>'; break; } // move source files into place $file_write_success = false; $test_url = getTestEnv("CASHMUSIC_TEST_URL"); if (!$test_url) { $test_url = "http://dev.cashmusic.org:8080"; } if ($db_engine == 'sqlite') { if (findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'driver = "mysql', 'driver = "sqlite') && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'debug = 0', 'debug = 1') && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'database = "cashmusic', 'database = "cashmusic_test.sqlite') && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'apilocation = "http://localhost:8888/interfaces/php/api/', 'apilocation = "' . $test_url . '/interfaces/php/api/') && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'salt = "I was born of sun beams; Warming up our limbs', 'salt = "' . $system_salt)) { $file_write_success = true; } } else { if (findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'hostname = "127.0.0.1:8889', 'hostname = "' . $db_server) && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'username = "******"' . $db_username) && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'password = "******"' . $db_password) && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'database = "cashmusic', 'database = "' . $db_name) && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'debug = 0', 'debug = 1') && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'apilocation = "http://localhost:8888/interfaces/php/api/', 'apilocation = "' . $test_url . '/interfaces/php/api/') && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'salt = "I was born of sun beams; Warming up our limbs', 'salt = "' . $system_salt)) { $file_write_success = true; } } if (!$file_write_success) { echo "\nOh. Shit. Something's wrong. We had trouble editing a few files. Please try again.\n\n"; break; } else { try { $pdo->exec(file_get_contents(dirname(__FILE__) . '/../../framework/php/settings/sql/cashmusic_demo_data.sql')); echo "\n" . strtoupper($db_engine) . " TEST DB DEPLOYED! Fear of testing is the mind-killer.\n"; } catch (PDOException $e) { echo "\nSOME SUCCESS, SOME FAILURE:\nEverything is set up properly, but there was an error writing demo data.\n{$e}\n"; } } }
} if ($success) { $installer_root = dirname(__FILE__); // modify settings files if (!copy($installer_root . '/../../framework/php/settings/cashmusic_template.ini.php', $installer_root . '/../../framework/php/settings/cashmusic.ini.php')) { echo '\\nOh. Shit. Something\'s wrong. Couldn\'t write the config file.\\n\\n' . 'the directory you specified for the framework.</p>'; break; } // move source files into place $file_write_success = false; if ($db_engine == "sqlite") { if (findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'driver = "mysql', 'driver = "sqlite') && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'database = "seed', 'database = "cashmusic.sqlite') && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'salt = "I was born of sun beams; Warming up our limbs', 'salt = "' . $system_salt)) { $file_write_success = true; } } else { if (findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'hostname = "localhost:8889', 'hostname = "' . $db_server) && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'username = "******"' . $db_username) && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'password = "******"' . $db_password) && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'database = "seed', 'database = "' . $db_name) && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'salt = "I was born of sun beams; Warming up our limbs', 'salt = "' . $system_salt)) { $file_write_success = true; } } if (!$file_write_success) { echo "\nOh. Shit. Something's wrong. We had trouble editing a few files. Please try again.\n\n"; break; } else { if ($pdo->exec(file_get_contents(dirname(__FILE__) . '/../../framework/php/settings/sql/cashmusic_demo_data.sql'))) { echo "\nSUCCESS!\n\nLogin using:\n\nemail: {$user_email}\npassword: {$user_password}\n\n"; } else { echo "\nSOME SUCCESS, SOME FAILURE:\nEverything is set up properly, but there was an error writing demo data.\n\nLogin using:\n\nemail: {$user_email}\npassword: {$user_password}\n\n"; } } } }
`client_proxy` varchar(39), `expiration_date` int(11), `creation_date` int(11) DEFAULT NULL, `modification_date` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `system_sessions_session_id` (`session_id`), KEY `system_sessions_expiration_date` (`expiration_date`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; MYSQL; } } try { $pdo->exec($query); } catch (PDOException $e) { if ($cash_settings['driver'] == 'sqlite') { unlink(CASH_PLATFORM_ROOT . "/../db/{$cash_settings['database']}"); @rename(CASH_PLATFORM_ROOT . "/../db/{$cash_settings['database']}.bak", CASH_PLATFORM_ROOT . "/../db/{$cash_settings['database']}"); } $upgrade_failure = true; } /*************************** * * 1. MODIFY NEW FILES * ***************************/ $api_dir = rtrim(dirname($_SERVER['REQUEST_URI']), '/') . '/api'; $public_dir = rtrim(dirname($_SERVER['REQUEST_URI']), '/') . '/public'; if (!findReplaceInFile('./update/interfaces/php/api/.htaccess', 'RewriteBase /interfaces/php/api', 'RewriteBase ' . $api_dir) || !findReplaceInFile('./update/interfaces/php/public/request/.htaccess', 'RewriteBase /interfaces/php/public/request', 'RewriteBase ' . $public_dir . '/request') || !findReplaceInFile('./update/interfaces/php/public/request/constants.php', '$cashmusic_root = dirname(__FILE__) . "/../../../../framework/php/cashmusic.php', '$cashmusic_root = "' . $cash_root_location . '/cashmusic.php') || !findReplaceInFile('./update/interfaces/php/api/controller.php', "define('CASH_PLATFORM_ROOT', dirname(__FILE__).'/../../../framework/php", "define('CASH_PLATFORM_ROOT', '" . $cash_root_location)) { $upgrade_failure = true; } }
if (!mkdir($user_settings['frameworklocation'], 0755, true)) { echo "<h1>Oh. Shit. Something's wrong.</h1><p>Couldn't create a directory at" . $user_settings['frameworklocation'] . ".</p>"; break; } } else { if (is_dir($user_settings['frameworklocation'] . '/framework')) { rrmdir($user_settings['frameworklocation'] . '/framework'); //echo 'removed old framework directory at ' . $cash_root_location . '/framework' . '<br />'; } } } else { echo "<h1>Oh. Shit. Something's wrong.</h1><p>No core location specified.</p>"; break; } // modify settings files if (!findReplaceInFile('./source/interfaces/php/admin/.htaccess', 'RewriteBase /interfaces/php/admin', 'RewriteBase ' . $admin_dir) || !findReplaceInFile('./source/interfaces/php/admin/constants.php', '$cashmusic_root = $root . "/../../../framework/php/cashmusic.php', '$cashmusic_root = "' . $user_settings['frameworklocation'] . '/framework/cashmusic.php') || !findReplaceInFile('./source/interfaces/php/admin/constants.php', 'define(\'ADMIN_WWW_BASE_PATH\', \'/interfaces/php/admin', 'define(\'ADMIN_WWW_BASE_PATH\', \'' . $admin_dir) || !findReplaceInFile('./source/interfaces/php/api/controller.php', 'dirname(__FILE__).\'/../../../framework/php', '$cashmusic_root = "' . $user_settings['frameworklocation'] . '/framework') || !findReplaceInFile('./source/framework/php/settings/cashmusic_template.ini.php', 'driver = "mysql', 'driver = "sqlite') || !findReplaceInFile('./source/framework/php/settings/cashmusic_template.ini.php', 'database = "cashmusic', 'database = "cashmusic.sqlite') || !findReplaceInFile('./source/framework/php/settings/cashmusic_template.ini.php', 'apilocation = "http://*****:*****@cashmusic.org', 'systememail = "system@' . $_SERVER['SERVER_NAME'])) { echo "<h1>Oh. Shit. Something's wrong.</h1><p>We had trouble editing a few files. Please try again.</p>"; break; } // move source files into place if (!rename('./source/framework/php/settings/cashmusic_template.ini.php', './source/framework/php/settings/cashmusic.ini.php') || !rename('./source/framework/php', $user_settings['frameworklocation'] . '/framework') || !rename('./source/interfaces/php/admin', './admin') || !rename('./source/interfaces/php/api', './api') || !rename('./source/interfaces/php/public', './public')) { echo '<h1>Oh. Shit. Something\'s wrong.</h1> <p>We couldn\'t move files into place. Please make sure you have write access in ' . 'the directory you specified for the core.</p>'; break; } // if the directory was never created then create it now if (!file_exists($user_settings['frameworklocation'] . '/db')) { mkdir($user_settings['frameworklocation'] . '/db', 0755, true); } else { // blow away the old sqlite file. if (file_exists($user_settings['frameworklocation'] . '/db/cashmusic.sqlite')) { unlink($user_settings['frameworklocation'] . '/db/cashmusic.sqlite');
$file_write_success = false; if ($db_engine == "sqlite") { if ( findReplaceInFile($installer_root.'/../../framework/php/settings/cashmusic.ini.php','driver = "mysql','driver = "sqlite') && findReplaceInFile($installer_root.'/../../framework/php/settings/cashmusic.ini.php','database = "seed','database = "cashmusic.db') && findReplaceInFile($installer_root.'/../../framework/php/settings/cashmusic.ini.php','salt = "I was born of sun beams; Warming up our limbs','salt = "' . $system_salt) ) { $file_write_success = true; } } else { if ( findReplaceInFile($installer_root.'/../../framework/php/settings/cashmusic.ini.php','hostname = "localhost:8889','hostname = "' . $db_server) && findReplaceInFile($installer_root.'/../../framework/php/settings/cashmusic.ini.php','username = "******"' . $db_username) && findReplaceInFile($installer_root.'/../../framework/php/settings/cashmusic.ini.php','password = "******"' . $db_password) && findReplaceInFile($installer_root.'/../../framework/php/settings/cashmusic.ini.php','database = "seed','database = "' . $db_name) && findReplaceInFile($installer_root.'/../../framework/php/settings/cashmusic.ini.php','salt = "I was born of sun beams; Warming up our limbs','salt = "' . $system_salt) ) { $file_write_success = true; } } if (!$file_write_success) { echo "\nOh. Shit. Something's wrong. We had trouble editing a few files. Please try again.\n\n"; break; } else { if ($pdo->exec(file_get_contents(dirname(__FILE__) . '/../../framework/php/settings/sql/cashmusic_test_data.sql'))) { echo "\nSUCCESS!\n\nLogin using:\n\nemail: $user_email\npassword: $user_password\n\n"; } else { echo "\nSOME SUCCESS, SOME FAILURE:\nEverything is set up properly, but there was an error writing demo data.\n\nLogin using:\n\nemail: $user_email\npassword: $user_password\n\n"; } } }
echo "<h1>Oh. Shit. Something's wrong.</h1><p>No core location specified.</p>"; break; } // modify settings files if ( !findReplaceInFile('./source/interfaces/php/admin/.htaccess','RewriteBase /interfaces/php/admin','RewriteBase ' . $admin_dir) || !findReplaceInFile('./source/interfaces/php/admin/constants.php','$cashmusic_root = $root . "/../../../framework/php/cashmusic.php','$cashmusic_root = "' . $user_settings['frameworklocation'] . '/framework/cashmusic.php') || !findReplaceInFile('./source/interfaces/php/admin/constants.php','define(\'ADMIN_WWW_BASE_PATH\', \'/interfaces/php/admin','define(\'ADMIN_WWW_BASE_PATH\', \'' . $admin_dir) || !findReplaceInFile('./source/framework/php/settings/cashmusic_template.ini.php','hostname = "localhost:8889','hostname = "' . $user_settings['mysqlhost']) || !findReplaceInFile('./source/framework/php/settings/cashmusic_template.ini.php','username = "******"' . $user_settings['mysqluser']) || !findReplaceInFile('./source/framework/php/settings/cashmusic_template.ini.php','password = "******"' . $user_settings['mysqlpass']) || !findReplaceInFile('./source/framework/php/settings/cashmusic_template.ini.php','database = "seed','database = "' . $user_settings['mysqldbname']) || !findReplaceInFile('./source/framework/php/settings/cashmusic_template.ini.php','salt = "I was born of sun beams; Warming up our limbs','salt = "' . $user_settings['systemsalt']) ) { echo "<h1>Oh. Shit. Something's wrong.</h1><p>We had trouble editing a few files. Please try again.</p>"; break; } // move source files into place if ( !rename('./source/framework/php/settings/cashmusic_template.ini.php', './source/framework/php/settings/cashmusic.ini.php') || !rename('./source/framework/php', $user_settings['frameworklocation'] . '/framework') || !rename('./source/interfaces/php/admin', './admin') ) { echo '<h1>Oh. Shit. Something\'s wrong.</h1> <p>We couldn\'t move files into place. Please make sure you have write access in ' . 'the directory you specified for the core.</p>'; break; }
if (!mkdir($user_settings['frameworklocation'])) { echo "<h1>Oh. Shit. Something's wrong.</h1><p>Couldn't create a directory at" . $user_settings['frameworklocation'] . ".</p>"; break; } } else { if (is_dir($user_settings['frameworklocation'] . '/framework')) { rrmdir($user_settings['frameworklocation'] . '/framework'); //echo 'removed old framework directory at ' . $cash_root_location . '/framework' . '<br />'; } } } else { echo "<h1>Oh. Shit. Something's wrong.</h1><p>No core location specified.</p>"; break; } // modify settings files if (!findReplaceInFile('./source/interfaces/php/admin/.htaccess', 'RewriteBase /interfaces/php/admin', 'RewriteBase ' . $admin_dir) || !findReplaceInFile('./source/interfaces/php/admin/constants.php', '$cashmusic_root = $root . "/../../../framework/php/cashmusic.php', '$cashmusic_root = "' . $user_settings['frameworklocation'] . '/framework/cashmusic.php') || !findReplaceInFile('./source/interfaces/php/admin/constants.php', 'define(\'ADMIN_WWW_BASE_PATH\', \'/interfaces/php/admin', 'define(\'ADMIN_WWW_BASE_PATH\', \'' . $admin_dir) || !findReplaceInFile('./source/interfaces/php/api/controller.php', 'dirname(__FILE__).\'/../../../framework/php', '$cashmusic_root = "' . $user_settings['frameworklocation'] . '/framework') || !findReplaceInFile('./source/interfaces/php/demos/index.html', '../../../docs/assets/fonts', 'https://cashmusic.s3.amazonaws.com/permalink/fonts') || !findReplaceInFile('./source/interfaces/php/demos/index.html', '<a href="/interfaces/php/admin/">Admin</a> <a href="/interfaces/php/demos/">Demos</a> <a href="/docs/">Docs</a> <a href="http://github.com/cashmusic/DIY">Github Repo</a>', '<a href="../admin/">Admin</a> <a href="http://cashmusic.github.com/DIY/">Docs</a> <a href="http://github.com/cashmusic/DIY">Github Repo</a>') || !findReplaceInFile('./source/interfaces/php/demos/emailcontestentry/index.php', '../../../../framework/php/cashmusic.php', $user_settings['frameworklocation'] . '/framework/cashmusic.php') || !findReplaceInFile('./source/interfaces/php/demos/emailfordownload/index.php', '../../../../framework/php/cashmusic.php', $user_settings['frameworklocation'] . '/framework/cashmusic.php') || !findReplaceInFile('./source/interfaces/php/demos/filteredsocialfeeds/index.php', '../../../../framework/php/cashmusic.php', $user_settings['frameworklocation'] . '/framework/cashmusic.php') || !findReplaceInFile('./source/interfaces/php/demos/tourdates/index.php', '../../../../framework/php/cashmusic.php', $user_settings['frameworklocation'] . '/framework/cashmusic.php') || !findReplaceInFile('./source/interfaces/php/demos/emailcontestentry/index.php', '../../../../framework/php/settings/debug/cashmusic_debug.php', $user_settings['frameworklocation'] . '/framework/settings/debug/cashmusic_debug.php') || !findReplaceInFile('./source/interfaces/php/demos/emailfordownload/index.php', '../../../../framework/php/settings/debug/cashmusic_debug.php', $user_settings['frameworklocation'] . '/framework/settings/debug/cashmusic_debug.php') || !findReplaceInFile('./source/interfaces/php/demos/filteredsocialfeeds/index.php', '../../../../framework/php/settings/debug/cashmusic_debug.php', $user_settings['frameworklocation'] . '/framework/settings/debug/cashmusic_debug.php') || !findReplaceInFile('./source/interfaces/php/demos/tourdates/index.php', '../../../../framework/php/settings/debug/cashmusic_debug.php', $user_settings['frameworklocation'] . '/framework/settings/debug/cashmusic_debug.php') || !findReplaceInFile('./source/framework/php/settings/cashmusic_template.ini.php', 'driver = "mysql', 'driver = "sqlite') || !findReplaceInFile('./source/framework/php/settings/cashmusic_template.ini.php', 'database = "seed', 'database = "cashmusic.sqlite') || !findReplaceInFile('./source/framework/php/settings/cashmusic_template.ini.php', 'apilocation = "http://*****:*****@cashmusic.org', 'systememail = "system@' . $_SERVER['SERVER_NAME'])) { echo "<h1>Oh. Shit. Something's wrong.</h1><p>We had trouble editing a few files. Please try again.</p>"; break; } // move source files into place if (!rename('./source/framework/php/settings/cashmusic_template.ini.php', './source/framework/php/settings/cashmusic.ini.php') || !rename('./source/framework/php', $user_settings['frameworklocation'] . '/framework') || !rename('./source/interfaces/php/admin', './admin') || !rename('./source/interfaces/php/api', './api') || !rename('./source/interfaces/php/demos', './demos') || !rename('./source/interfaces/php/public', './public')) { echo '<h1>Oh. Shit. Something\'s wrong.</h1> <p>We couldn\'t move files into place. Please make sure you have write access in ' . 'the directory you specified for the core.</p>'; break; } // set up database, add user / password $user_password = substr(md5($user_settings['systemsalt'] . 'password'), 4, 7); // if the directory was never created then create it now if (!file_exists($user_settings['frameworklocation'] . '/db')) { mkdir($user_settings['frameworklocation'] . '/db'); } // connect to the new db...will create if not found
$installer_root = dirname(__FILE__); // modify settings files if (file_exists($installer_root . '/../../framework/php/settings/cashmusic.ini.php')) { rename($installer_root . '/../../framework/php/settings/cashmusic.ini.php', $installer_root . '/../../framework/php/settings/cashmusic.ini.pretest.bak'); } if (!copy($installer_root . '/../../framework/php/settings/cashmusic_template.ini.php', $installer_root . '/../../framework/php/settings/cashmusic.ini.php')) { echo '\\nOh. Shit. Something\'s wrong. Couldn\'t write the config file.\\n\\n' . 'the directory you specified for the framework.</p>'; break; } // move source files into place $file_write_success = false; $test_url = getTestEnv("CASHMUSIC_TEST_URL"); if (!$test_url) { $test_url = "http://dev.cashmusic.org:8080"; } if (findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'driver = "mysql', 'driver = "sqlite') && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'debug = 0', 'debug = 1') && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'database = "seed', 'database = "cashmusic_test.sqlite') && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'apilocation = "http://localhost:8888/interfaces/php/api/', 'apilocation = "' . $test_url . '/interfaces/php/api/') && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'salt = "I was born of sun beams; Warming up our limbs', 'salt = "' . $system_salt)) { $file_write_success = true; } if (!$file_write_success) { echo "\nOh. Shit. Something's wrong. We had trouble editing a few files. Please try again.\n\n"; break; } else { try { $pdo->exec(file_get_contents(dirname(__FILE__) . '/../../framework/php/settings/sql/cashmusic_demo_data.sql')); echo "\nTEST DATABASE DEPLOYED! Fear of testing is the mind-killer.\n"; } catch (PDOException $e) { echo "\nSOME SUCCESS, SOME FAILURE:\nEverything is set up properly, but there was an error writing demo data.\n{$e}\n"; } } } }