<?php
define('AIRTIME_VERSION', '1.7.0-alpha');
define('AIRTIME_COPYRIGHT_DATE', '2010-2011');
define('AIRTIME_REST_VERSION', '1.1');

// These are the default values for the config.
global $CC_CONFIG;
$values = load_airtime_config();

// **********************************
// ***** START CUSTOMIZING HERE *****
// **********************************

// Set the location where you want to store all of your audio files.
//
// For example:
// $baseFilesDir = '/home/john/radio-files';
$baseFilesDir = __DIR__.'/../../files';

$CC_CONFIG = array(

    // Name of the web server user
    'webServerUser' => 'www-data',

    'rabbitmq' => array("host" => "127.0.0.1",
                        "port" => "5672",
                        "user" => "guest",
                        "password" => "guest",
                        "vhost" => "/"),

    // ***********************************************************************
	// STOP CUSTOMIZING HERE
	//
	// You don't need to touch anything below this point.
	// ***********************************************************************

    'baseFilesDir' => $baseFilesDir,
    // main directory for storing binary media files
    'storageDir'    =>  "$baseFilesDir/stor",

	// Database config
    'dsn' => $values['database'],

    // prefix for table names in the database
    'tblNamePrefix' => 'cc_',

    /* ================================================ storage configuration */

    'apiKey' => $values['api_key'],
    'apiPath' => '/api/',

    'soundcloud-client-id' => '2CLCxcSXYzx7QhhPVHN4A',
    'soundcloud-client-secret' => 'pZ7beWmF06epXLHVUP1ufOg2oEnIt9XhE8l8xt0bBs',

    "rootDir" => __DIR__."/../..",
    'pearPath'      =>  dirname(__FILE__).'/../../library/pear',
    'zendPath'      =>  dirname(__FILE__).'/../../library/Zend',
    'phingPath'      =>  dirname(__FILE__).'/../../library/phing',

);

// Add database table names
$CC_CONFIG['playListTable'] = $CC_CONFIG['tblNamePrefix'].'playlist';
$CC_CONFIG['playListContentsTable'] = $CC_CONFIG['tblNamePrefix'].'playlistcontents';
$CC_CONFIG['filesTable'] = $CC_CONFIG['tblNamePrefix'].'files';
$CC_CONFIG['accessTable'] = $CC_CONFIG['tblNamePrefix'].'access';
$CC_CONFIG['permTable'] = $CC_CONFIG['tblNamePrefix'].'perms';
$CC_CONFIG['sessTable'] = $CC_CONFIG['tblNamePrefix'].'sess';
$CC_CONFIG['subjTable'] = $CC_CONFIG['tblNamePrefix'].'subjs';
$CC_CONFIG['smembTable'] = $CC_CONFIG['tblNamePrefix'].'smemb';
$CC_CONFIG['prefTable'] = $CC_CONFIG['tblNamePrefix'].'pref';
$CC_CONFIG['scheduleTable'] = $CC_CONFIG['tblNamePrefix'].'schedule';
$CC_CONFIG['playListTimeView'] = $CC_CONFIG['tblNamePrefix'].'playlisttimes';
$CC_CONFIG['showSchedule'] = $CC_CONFIG['tblNamePrefix'].'show_schedule';
$CC_CONFIG['showDays'] = $CC_CONFIG['tblNamePrefix'].'show_days';
$CC_CONFIG['showTable'] = $CC_CONFIG['tblNamePrefix'].'show';
$CC_CONFIG['showInstances'] = $CC_CONFIG['tblNamePrefix'].'show_instances';

$CC_CONFIG['playListSequence'] = $CC_CONFIG['playListTable'].'_id';
$CC_CONFIG['filesSequence'] = $CC_CONFIG['filesTable'].'_id';
$CC_CONFIG['prefSequence'] = $CC_CONFIG['prefTable'].'_id';
$CC_CONFIG['permSequence'] = $CC_CONFIG['permTable'].'_id';
$CC_CONFIG['subjSequence'] = $CC_CONFIG['subjTable'].'_id';
$CC_CONFIG['smembSequence'] = $CC_CONFIG['smembTable'].'_id';

// Add libs to the PHP path
$old_include_path = get_include_path();
set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath']
					.PATH_SEPARATOR.$CC_CONFIG['zendPath']
					.PATH_SEPARATOR.$old_include_path);

function load_airtime_config(){
	$ini_array = parse_ini_file(dirname(__FILE__).'/../../build/airtime.conf', true);

	return array(
            'database' => array(
                'username'      => $ini_array['database']['dbuser'],
                'password'      => $ini_array['database']['dbpass'],
                'hostspec'      => $ini_array['database']['host'],
                'phptype'       => 'pgsql',
                'database'      => $ini_array['database']['dbname']),
            'api_key' => array($ini_array['general']['api_key'])
        );
}