$err_msg = "ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
    $err_msg .= "Usage: php install/step_01.php <PATH_TO_MATRIX>\n";
    echo $err_msg;
    exit(1);
}
define('SQ_SYSTEM_ROOT', $SYSTEM_ROOT);
define('SQ_INCLUDE_PATH', SQ_SYSTEM_ROOT . '/core/include');
define('SQ_LIB_PATH', SQ_SYSTEM_ROOT . '/core/lib');
define('SQ_DATA_PATH', SQ_SYSTEM_ROOT . '/data');
define('SQ_FUDGE_PATH', SQ_SYSTEM_ROOT . '/fudge');
define('SQ_PHP_CLI', php_sapi_name() == 'cli');
define('SQ_LOG_PATH', SQ_SYSTEM_ROOT . '/data/private/logs');
require_once SQ_INCLUDE_PATH . '/general.inc';
require_once SQ_INCLUDE_PATH . '/mysource_object.inc';
require_once SQ_INCLUDE_PATH . '/system_config.inc';
$cfg = new System_Config();
$cfg->save(array(), FALSE);
// Copy the DB config sample to the data directory
// Only overwrite the file if there is no file exists already
if (!file_exists(SQ_DATA_PATH . '/private/conf/db.inc')) {
    copy(dirname(__FILE__) . '/db-inc.sample', SQ_DATA_PATH . '/private/conf/db.inc');
}
// Do the same with the memcache config file
if (!file_exists(SQ_DATA_PATH . '/private/conf/memcache.inc')) {
    copy(dirname(__FILE__) . '/memcache-inc.sample', SQ_DATA_PATH . '/private/conf/memcache.inc');
}
// Do the same with the Redis config file
if (!file_exists(SQ_DATA_PATH . '/private/conf/redis.inc')) {
    copy(dirname(__FILE__) . '/redis-inc.sample', SQ_DATA_PATH . '/private/conf/redis.inc');
}
echo "\n";
if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT . '/core/include/init.inc')) {
    $err_msg = "ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
    $err_msg .= "Usage: php install/step_02.php <PATH_TO_MATRIX>\n";
    echo $err_msg;
    exit(1);
}
define('SQ_SYSTEM_ROOT', $SYSTEM_ROOT);
require_once $SYSTEM_ROOT . '/core/include/init.inc';
require_once $SYSTEM_ROOT . '/install/install.inc';
require_once SQ_LIB_PATH . '/db_install/db_install.inc';
require_once SQ_INCLUDE_PATH . '/system_config.inc';
require_once SQ_LIB_PATH . '/file_versioning/file_versioning.inc';
$exitRC = 0;
$GLOBALS['SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
// Re-generate the Config to make sure that we get any new defines that may have been issued
$cfg = new System_Config();
$cfg->save(array(), FALSE);
// check that we have valid DEFAULT and TECH email addresses - warn if missing
if (!SQ_CONF_TECH_EMAIL && !SQ_CONF_DEFAULT_EMAIL) {
    trigger_error('Neither the System Default nor Tech email addresses have been set', E_USER_WARNING);
} else {
    if (!SQ_CONF_TECH_EMAIL) {
        trigger_error('The System Tech email address has not been set', E_USER_WARNING);
    }
    if (!SQ_CONF_DEFAULT_EMAIL) {
        trigger_error('The System Default email address has not been set', E_USER_WARNING);
    }
}
if (DAL::getDbType() === 'oci') {
    $query = "SELECT value FROM nls_session_parameters WHERE parameter='NLS_DATE_FORMAT'";
    $value = DAL::executeSqlAssoc($query, 0);