Advertisement
Guest User

EE config.master.php

a guest
Apr 10th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.66 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. /**
  4.  * Master Config
  5.  */
  6. //set time to london
  7. date_default_timezone_set('Europe/London');
  8.  
  9. // Require our environment declatation file if it hasn't
  10. // already been loaded in index.php or admin.php
  11. if ( ! defined('ENV'))
  12. {
  13.     require 'config.env.php';
  14. }
  15.  
  16.  
  17. // Setup our initial arrays
  18. $env_db = $env_config = $env_global = $master_global = array();
  19.  
  20.  
  21. /**
  22.  * Database override magic
  23.  *
  24.  * If this equates to TRUE then we're in the database.php file
  25.  * We don't want these settings bothered with in our config.php file
  26.  */
  27.  
  28.  
  29. if (isset($db['expressionengine']))
  30. {
  31.     /**
  32.      * Load our environment-specific config file
  33.      * which contains our database credentials
  34.      *
  35.      * @see config/config.local.php
  36.      * @see config/config.dev.php
  37.      * @see config/config.stage.php
  38.      * @see config/config.prod.php
  39.      */
  40.     require 'config.' . ENV . '.php';
  41.    
  42.     // Dynamically set the cache path (Shouldn't this be done by default? Who moves the cache path?)
  43.     $env_db['cachedir'] = APPPATH . 'cache/db_cache/';
  44.    
  45.     // Merge our database setting arrays
  46.     $db['expressionengine'] = array_merge($db['expressionengine'], $env_db);
  47.  
  48.     // No need to have this variable accessible for the rest of the app
  49.     unset($env_db);
  50. }
  51.  
  52. // End if (isset($db['expressionengine'])) {}
  53.  
  54.  
  55.  
  56. /**
  57.  * Config override magic
  58.  *
  59.  * If this equates to TRUE then we're in the config.php file
  60.  * We don't want these settings bothered with in our database.php file
  61.  */
  62. if (isset($config))
  63. {
  64.  
  65.     /**
  66.      * Dynamic path settings
  67.      *
  68.      * Make it easy to run the site in multiple environments and not have to switch up
  69.      * path settings in the database after each migration
  70.      * As inspired by Matt Weinberg: http://eeinsider.com/articles/multi-server-setup-for-ee-2/
  71.      */
  72.     $protocol                          = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
  73.     $base_url                          = $protocol . $_SERVER['HTTP_HOST'];
  74.    
  75.    
  76.     $base_path = $_SERVER['DOCUMENT_ROOT'];
  77.    
  78.    
  79.    
  80.     $system_folder                     = APPPATH;
  81.     $images_folder                     = 'images';
  82.     $images_path                       = $base_path . '/' . $images_folder;
  83.     $images_url                        = $base_url . '/' . $images_folder;
  84.  
  85.     $env_config['index_page']          = '';
  86.     $env_config['site_index']          = '';
  87.     $env_config['base_url']            = $base_url . '/';
  88.     $env_config['cookie_path']         = '/';
  89.     $env_config['site_url']            = $env_config['base_url'];
  90.     $env_config['cp_url']              = $env_config['base_url'] . '/webadmin.php';
  91.     $env_config['theme_folder_path']   = $base_path   . '/themes/';
  92.     $env_config['theme_folder_url']    = $base_url    . '/themes/';
  93.     $env_config['emoticon_path']       = $images_url  . '/smileys/';
  94.     $env_config['captcha_path']        = $images_path . '/captchas/';
  95.     $env_config['captcha_url']         = $images_url  . '/captchas/';
  96.     $env_config['avatar_path']         = $images_path . '/avatars/';
  97.     $env_config['avatar_url']          = $images_url  . '/avatars/';
  98.     $env_config['photo_path']          = $images_path . '/member_photos/';
  99.     $env_config['photo_url']           = $images_url  . '/member_photos/';
  100.     $env_config['sig_img_path']        = $images_path . '/signature_attachments/';
  101.     $env_config['sig_img_url']         = $images_url  . '/signature_attachments/';
  102.     $env_config['prv_msg_upload_path'] = $images_path . '/pm_attachments/';
  103.     // $env_config['third_party_path']    = $base_path . '/../third_party/';
  104.  
  105.     $downloads_url = $base_url;
  106.  
  107.     $env_config['upload_preferences'] = array(
  108.         1 => array(
  109.             'name'        => 'Hero Images',
  110.             'server_path' => $images_path . '/uploads/hero/',
  111.             'url'         => $images_url  . '/uploads/hero/'
  112.         ),
  113.         2 => array(
  114.             'name'        => 'Page Images',
  115.             'server_path' => $images_path . '/uploads/page_images/',
  116.             'url'         => $images_url  . '/uploads/page_images/'
  117.         ),
  118.         3 => array(
  119.             'name'        => 'Downloads',
  120.             'server_path' => $base_path . '/downloads/',
  121.             'url'         => $downloads_url  . '/downloads/'
  122.         ),
  123.         4 => array(
  124.             'name'        => 'Gallery Images',
  125.             'server_path' => $images_path . '/uploads/gallery_images/',
  126.             'url'         => $images_url  . '/uploads/gallery_images/'
  127.         ),
  128.         5 => array(
  129.             'name'        => 'Planner Images',
  130.             'server_path' => $images_path . '/uploads/planner/',
  131.             'url'         => $images_url  . '/uploads/planner/'
  132.         )
  133.     );
  134.         if( ENV == 'local'){
  135.             $env_config['upload_preferences'] = array(
  136.                 1 => array(
  137.                     'name'        => 'Hero Images',
  138.                     'server_path' => str_replace('/','\\',$images_path . '/uploads/hero/'),
  139.                     'url'         => $images_url  . '/uploads/hero/'
  140.                 ),
  141.                 2 => array(
  142.                     'name'        => 'Page Images',
  143.                     'server_path' => str_replace('/','\\',$images_path . '/uploads/page_images/'),
  144.                     'url'         => $images_url  . '/uploads/page_images/'
  145.                 ),
  146.                 3 => array(
  147.                     'name'        => 'Downloads',
  148.                     'server_path' => str_replace('/','\\',$base_path . '/downloads/'),
  149.                     'url'         => $downloads_url  . '/downloads/'
  150.                 ),
  151.                 4 => array(
  152.                     'name'        => 'Gallery Images',
  153.                     'server_path' => str_replace('/','\\',$images_path . '/uploads/gallery_images/'),
  154.                     'url'         => $images_url  . '/uploads/gallery_images/'
  155.                 ),
  156.                 5 => array(
  157.                     'name'        => 'Planner Images',
  158.                     'server_path' => str_replace('/','\\',$images_path . '/uploads/planner/'),
  159.                     'url'         => $images_url  . '/uploads/planner/'
  160.                 )
  161.             );
  162.  
  163.         }
  164.  
  165.  
  166.  
  167.  
  168.  
  169.     /**
  170.      * Template settings
  171.      *
  172.      * Working locally we want to reference our template files.
  173.      * In staging and production we do not use flat files (for ever-so-slightly better performance)
  174.      * This approach requires that we synchronize templates after each deployment of template changes
  175.      *
  176.      * For the distributed Focus Lab, LLC Master Config file this is commented out
  177.      * You can enable this "feature" by uncommenting the second 'save_tmpl_files' line
  178.      */
  179.     $env_config['save_tmpl_files']           = 'y';
  180.     // $env_config['save_tmpl_files']           = (ENV == 'prod') ? 'n' : 'y';
  181.     $env_config['tmpl_file_basepath']        = $base_path . '/core/_ee/templates';
  182.     $env_config['hidden_template_indicator'] = '_';
  183.  
  184.  
  185.  
  186.     /**
  187.      * Debugging settings
  188.      *
  189.      * These settings are helpful to have in one place
  190.      * for debugging purposes
  191.      */
  192.     $env_config['is_system_on']         = 'y';
  193.     $env_config['allow_extensions']     = 'y';
  194.     $env_config['email_debug']          = (ENV_DEBUG) ? 'y' : 'n' ;
  195.     // If we're not in production show the profile on the front-end but not in the CP
  196.     $env_config['show_profiler']        = ( ! ENV_DEBUG) ? 'n' : 'y' ;
  197.     // Show template debugging if we're not in production
  198.     $env_config['template_debugging']   = (ENV_DEBUG) ? 'y' : 'n' ;
  199.     /**
  200.      * Set debug to '2' if we're in dev mode, otherwise just '1'
  201.      *
  202.      * 0: no PHP/SQL errors shown
  203.      * 1: Errors shown to Super Admins
  204.      * 2: Errors shown to everyone
  205.      */
  206.     $env_config['debug']                = (ENV_DEBUG) ? '2' : '1' ;
  207.  
  208.  
  209.  
  210.     /**
  211.      * Tracking & Performance settings
  212.      *
  213.      * These settings may impact what happens on certain page loads
  214.      * and turning them off could help with performance in general
  215.      */
  216.     $env_config['disable_all_tracking']        = 'y'; // If set to 'y' some of the below settings are disregarded
  217.     $env_config['enable_sql_caching']          = 'n';
  218.     $env_config['disable_tag_caching']         = 'n';
  219.     $env_config['enable_online_user_tracking'] = 'n';
  220.     $env_config['dynamic_tracking_disabling']  = '500';
  221.     $env_config['enable_hit_tracking']         = 'n';
  222.     $env_config['enable_entry_view_tracking']  = 'n';
  223.     $env_config['log_referrers']               = 'n';
  224.     $env_config['gzip_output']                 = 'y';
  225.  
  226.  
  227.     /**
  228.      * Member-based settings
  229.      */
  230.     $env_config['profile_trigger']          = rand(0,time()); // randomize the member profile trigger word because we'll never need it
  231.  
  232.  
  233.     /**
  234.      * Other system settings
  235.      */
  236.     $env_config['new_version_check']        = 'n'; // no slowing my CP homepage down with this
  237.     $env_config['daylight_savings']         = date('I') ? 'y' : 'n'; // Autodetect
  238.     $env_config['use_category_name']        = 'y';
  239.     $env_config['reserved_category_word']   = 'category';
  240.     $env_config['word_separator']           = 'dash'; // dash|underscore
  241.  
  242.  
  243.     /**
  244.      * Add-ons
  245.      */
  246.  
  247.     // CE Image
  248.     $env_config['ce_image_cache_dir'] = '/images/sized/';
  249.     $env_config['ce_image_remote_dir'] = '/images/sized_remote/';
  250.  
  251.     // Snippet Sync
  252.     $env_config['snippet_file_basepath'] = $base_path . '/core/_ee/snippets/';
  253.  
  254.     //  Stash
  255.     // $env_config['stash_file_basepath'] = $base_path . '/core/_ee/stash_templates/';
  256.     // $env_config['stash_file_sync'] = TRUE;
  257.  
  258.     // Low Variables
  259.     $env_config['low_variables_save_as_files'] = 'y';
  260.     $env_config['low_variables_file_path'] = $base_path . '/core/_ee/variables/';
  261.  
  262.     /**
  263.      * Load our environment-specific config file
  264.      * May contain override values from similar above settings
  265.      *
  266.      * @see config/config.local.php
  267.      * @see config/config.dev.php
  268.      * @see config/config.stage.php
  269.      * @see config/config.prod.php
  270.      */
  271.  
  272.     require $_SERVER['DOCUMENT_ROOT'] . '/config/config.' . ENV . '.php';
  273.  
  274.  
  275.  
  276.     /**
  277.      * Setup our template-level global variables
  278.      *
  279.      * As inspired by NSM Bootstrap Config
  280.      * @see http://ee-garage.com/nsm-config-bootstrap
  281.      */
  282.     global $assign_to_config;
  283.  
  284.     if( ! isset($assign_to_config['global_vars']))
  285.     {
  286.         $assign_to_config['global_vars'] = array();
  287.     }
  288.  
  289.     $env_global['global:site_url'] = $env_config['site_url'];
  290.     // Start our array with environment variables. This gives us {global:env} and {global:env_full} tags for our templates.
  291.    
  292.     $master_global = array(
  293.         'global:env'               => ENV,
  294.         'global:env_full'          => ENV_FULL,
  295.         'global:env_type'          => ENV_TYPE,
  296.         'cp_session_ttl'           => '86400',
  297.         'global:ce_cache_time'     => '21600'
  298.     );
  299.  
  300.  
  301.  
  302.     /**
  303.      * Merge arrays to form final datasets
  304.      *
  305.      * We've created our base config and global key->value stores
  306.      * We've also included the environment-specific arrays now
  307.      * Here we'll merge the arrays to create our final array dataset which
  308.      * respects "most recent data" first if any keys are duplicated
  309.      *
  310.      * This is how our environment settings are "king" over any defaults
  311.      */
  312. //  $assign_to_config['global_vars'] = array();
  313.     $assign_to_config['global_vars'] = array_merge($assign_to_config['global_vars'], $master_global, $env_global); // global var arrays
  314.     $config = array_merge($config, $env_config); // config setting arrays
  315.     //print_r($config); die();
  316.  
  317. }
  318. // End if (isset($config)) {}
  319.  
  320.  
  321. /* End of file config.master.php */
  322. /* Location: ./config/config.master.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement