<commit_before><?php
/**
 * This file is part of the DreamFactory Services Platform(tm) (DSP)
 *
 * DreamFactory Services Platform(tm) <http://github.com/dreamfactorysoftware/dsp-core>
 * Copyright 2012-2013 DreamFactory Software, Inc. <<EMAIL>>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
use DreamFactory\Platform\Utility\Fabric;
use DreamFactory\Yii\Utility\Pii;
use Kisma\Core\Utility\Log;

/**
 * web.php
 * This is the main configuration file for the DreamFactory Services Platform server application.
 */
$_fabricHosted = false;

if ( !defined( 'DSP_VERSION' ) && file_exists( __DIR__ . '/constants.config.php' ) )
{
    require __DIR__ . '/constants.config.php';
}

/**
 * Load any environment variables first thing as they may be used by the database config
 */
/** @noinspection PhpIncludeInspection */
if ( false !== ( $_envConfig = Pii::includeIfExists( __DIR__ . ENV_CONFIG_PATH, true ) ) )
{
    if ( !empty( $_envConfig ) && is_array( $_envConfig ) )
    {
        foreach ( $_envConfig as $_key => $_value )
        {
            if ( !is_string( $_value ) )
            {
                $_value = json_encode( $_value );
            }

            if ( false === putenv( $_key . '=' . $_value ) )
            {
                Log::error( 'Error setting environment variable: ' . $_key . ' = ' . $_value );
            }
        }
    }
}

/**
 * Load up the database configuration, free edition, private hosted, or others.
 * Look for non-default database config to override.
 */
if ( false === ( $_dbConfig = Pii::includeIfExists( __DIR__ . DATABASE_CONFIG_PATH, true ) ) )
{
    if ( Fabric::fabricHosted() )
    {
        $_fabricHosted = true;
        $_dbConfig = Fabric::initialize();
    }
    else
    {
        /**
         * Database names vary by type of DSP:
         *
         *        1. Free Edition/Hosted:   DSP name
         *        2. Hosted Private:        hpp_<DSP Name>
         *        3. All others:            dreamfactory or whatever is in non-default config.
         */
        if ( false !== ( $_host = Fabric::hostedPrivatePlatform( true ) ) )
        {
            $_dbName =
                'hpp_' .
                str_ireplace( array('.dreamfactory.com', '-', '.cloud', '.'), array(null, '_', null, '_'), $_host );
        }
        else
        {
            $_dbName = 'dreamfactory';
        }

        // default config for local database
        $_dbConfig = array(
            'connectionString'      => 'mysql:host=localhost;port=3306;dbname=' . $_dbName,
            'username'              => 'dsp_user',
            'password'              => '<PASSWORD>',
            'emulatePrepare'        => true,
            'charset'               => 'utf8',
            'enableProfiling'       => defined( 'YII_DEBUG' ),
            'enableParamLogging'    => defined( 'YII_DEBUG' ),
            'schemaCachingDuration' => 3600,
        );
    }
}
/**
 * Load up the common configurations between the web and background apps,
 * setting globals whilst at it. REQUIRED file!
 */
/** @noinspection PhpIncludeInspection */
$_commonConfig = require( __DIR__ . COMMON_CONFIG_PATH );

//.........................................................................
//. The configuration
//.........................................................................

return array(
    /**
     * Basics
     */
    'basePath'           => $_basePath . '/app',
    'name'               => $_appName,
    'runtimePath'        => $_logFilePath,
    'defaultController'  => $_defaultController,
    /**
     * Service Handling: The default system resource namespaces
     *
     * @todo have ResourceStore::resource() scan sub-directories based on $_REQUEST['path']  -- GHA
     */
    'resourceNamespaces' => array(
        'DreamFactory\\Platform\\Resources',
        'DreamFactory\\Platform\\Resources\\System',
        'DreamFactory\\Platform\\Resources\\User',
    ),
    /**
     * Service Handling: The default system model namespaces
     *
     * @todo have ResourceStore::model() scan sub-directories based on $_REQUEST['path'] -- GHA
     */
    'modelNamespaces'    => array(
        'DreamFactory\\Platform\\Yii\\Models',
    ),
    /**
     * CORS Configuration
     */
    'corsWhitelist'      => array('*'),
    'autoAddHeaders'     => true,
    'extendedHeaders'    => true,
    /**
     * Preloads<commit_msg>CORS locked down by default<commit_after><?php
/**
 * This file is part of the DreamFactory Services Platform(tm) (DSP)
 *
 * DreamFactory Services Platform(tm) <http://github.com/dreamfactorysoftware/dsp-core>
 * Copyright 2012-2013 DreamFactory Software, Inc. <<EMAIL>>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
use DreamFactory\Platform\Utility\Fabric;
use DreamFactory\Yii\Utility\Pii;
use Kisma\Core\Utility\Log;

/**
 * web.php
 * This is the main configuration file for the DreamFactory Services Platform server application.
 */
$_fabricHosted = false;

if ( !defined( 'DSP_VERSION' ) && file_exists( __DIR__ . '/constants.config.php' ) )
{
    require __DIR__ . '/constants.config.php';
}

/**
 * Load any environment variables first thing as they may be used by the database config
 */
/** @noinspection PhpIncludeInspection */
if ( false !== ( $_envConfig = Pii::includeIfExists( __DIR__ . ENV_CONFIG_PATH, true ) ) )
{
    if ( !empty( $_envConfig ) && is_array( $_envConfig ) )
    {
        foreach ( $_envConfig as $_key => $_value )
        {
            if ( !is_string( $_value ) )
            {
                $_value = json_encode( $_value );
            }

            if ( false === putenv( $_key . '=' . $_value ) )
            {
                Log::error( 'Error setting environment variable: ' . $_key . ' = ' . $_value );
            }
        }
    }
}

/**
 * Load up the database configuration, free edition, private hosted, or others.
 * Look for non-default database config to override.
 */
if ( false === ( $_dbConfig = Pii::includeIfExists( __DIR__ . DATABASE_CONFIG_PATH, true ) ) )
{
    if ( Fabric::fabricHosted() )
    {
        $_fabricHosted = true;
        $_dbConfig = Fabric::initialize();
    }
    else
    {
        /**
         * Database names vary by type of DSP:
         *
         *        1. Free Edition/Hosted:   DSP name
         *        2. Hosted Private:        hpp_<DSP Name>
         *        3. All others:            dreamfactory or whatever is in non-default config.
         */
        if ( false !== ( $_host = Fabric::hostedPrivatePlatform( true ) ) )
        {
            $_dbName =
                'hpp_' .
                str_ireplace( array('.dreamfactory.com', '-', '.cloud', '.'), array(null, '_', null, '_'), $_host );
        }
        else
        {
            $_dbName = 'dreamfactory';
        }

        // default config for local database
        $_dbConfig = array(
            'connectionString'      => 'mysql:host=localhost;port=3306;dbname=' . $_dbName,
            'username'              => 'dsp_user',
            'password'              => '<PASSWORD>',
            'emulatePrepare'        => true,
            'charset'               => 'utf8',
            'enableProfiling'       => defined( 'YII_DEBUG' ),
            'enableParamLogging'    => defined( 'YII_DEBUG' ),
            'schemaCachingDuration' => 3600,
        );
    }
}
/**
 * Load up the common configurations between the web and background apps,
 * setting globals whilst at it. REQUIRED file!
 */
/** @noinspection PhpIncludeInspection */
$_commonConfig = require( __DIR__ . COMMON_CONFIG_PATH );

//.........................................................................
//. The configuration
//.........................................................................

return array(
    /**
     * Basics
     */
    'basePath'           => $_basePath . '/app',
    'name'               => $_appName,
    'runtimePath'        => $_logFilePath,
    'defaultController'  => $_defaultController,
    /**
     * Service Handling: The default system resource namespaces
     *
     * @todo have ResourceStore::resource() scan sub-directories based on $_REQUEST['path']  -- GHA
     */
    'resourceNamespaces' => array(
        'DreamFactory\\Platform\\Resources',
        'DreamFactory\\Platform\\Resources\\System',
        'DreamFactory\\Platform\\Resources\\User',
    ),
    /**
     * Service Handling: The default system model namespaces
     *
     * @todo have ResourceStore::model() scan sub-directories based on $_REQUEST['path'] -- GHA
     */
    'modelNamespaces'    => array(
        'DreamFactory\\Platform\\Yii\\Models',
    ),
    /**
     * CORS Configuration
     */
    'corsWhitelist'      => array(),
    'autoAddHeaders'     => true,
    'extendedHeaders'    => true,
    /**
     * Preloads
{'fraction_non_alphanumeric': 0.15440499334902283, 'fraction_numerical': 0.004911490842116034, 'mean_word_length': 1.9591280653950953, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7608691', 'n_tokens_mistral': 2732, 'n_tokens_neox': 2681, 'n_words': 743}