diff --git a/airtime_mvc/application/configs/conf.php b/airtime_mvc/application/configs/conf.php index 3f6426e69..cf8e610bc 100644 --- a/airtime_mvc/application/configs/conf.php +++ b/airtime_mvc/application/configs/conf.php @@ -11,48 +11,24 @@ define('AIRTIME_COPYRIGHT_DATE', '2010-2011'); define('AIRTIME_REST_VERSION', '1.1'); global $CC_CONFIG; -$values = load_airtime_config(); $CC_CONFIG = array( - - // Name of the web server user - 'webServerUser' => $values['general']['web_server_user'], - - 'rabbitmq' => $values['rabbitmq'], - - 'baseFilesDir' => $values['general']['base_files_dir'], - // main directory for storing binary media files - 'storageDir' => $values['general']['base_files_dir']."/stor", - - // Database config - 'dsn' => array( - 'username' => $values['database']['dbuser'], - 'password' => $values['database']['dbpass'], - 'hostspec' => $values['database']['host'], - 'phptype' => 'pgsql', - 'database' => $values['database']['dbname']), - // prefix for table names in the database 'tblNamePrefix' => 'cc_', /* ================================================ storage configuration */ - 'apiKey' => array($values['general']['api_key']), - 'apiPath' => '/api/', - 'soundcloud-client-id' => '2CLCxcSXYzx7QhhPVHN4A', 'soundcloud-client-secret' => 'pZ7beWmF06epXLHVUP1ufOg2oEnIt9XhE8l8xt0bBs', - 'soundcloud-connection-retries' => $values['soundcloud']['connection_retries'], - 'soundcloud-connection-wait' => $values['soundcloud']['time_between_retries'], - "rootDir" => __DIR__."/../..", 'pearPath' => dirname(__FILE__).'/../../library/pear', 'zendPath' => dirname(__FILE__).'/../../library/Zend', - 'phingPath' => dirname(__FILE__).'/../../library/phing', - + 'phingPath' => dirname(__FILE__).'/../../library/phing' ); +$CC_CONFIG = Config::loadConfig($CC_CONFIG); + // Add database table names $CC_CONFIG['playListTable'] = $CC_CONFIG['tblNamePrefix'].'playlist'; $CC_CONFIG['playListContentsTable'] = $CC_CONFIG['tblNamePrefix'].'playlistcontents'; @@ -83,20 +59,17 @@ 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('/etc/airtime/airtime.conf', true); - return $ini_array; -} - class Config { - public static function reload_config() { - global $CC_CONFIG; + public static function loadConfig($CC_CONFIG) { $values = parse_ini_file('/etc/airtime/airtime.conf', true); // Name of the web server user $CC_CONFIG['webServerUser'] = $values['general']['web_server_user']; $CC_CONFIG['rabbitmq'] = $values['rabbitmq']; + $CC_CONFIG['baseUrl'] = $values['general']['base_url']; + $CC_CONFIG['basePort'] = $values['general']['base_port']; + $CC_CONFIG['baseFilesDir'] = $values['general']['base_files_dir']; // main directory for storing binary media files $CC_CONFIG['storageDir'] = $values['general']['base_files_dir']."/stor"; @@ -111,5 +84,7 @@ class Config { $CC_CONFIG['soundcloud-connection-retries'] = $values['soundcloud']['connection_retries']; $CC_CONFIG['soundcloud-connection-wait'] = $values['soundcloud']['time_between_retries']; + + return $CC_CONFIG; } } diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 82e68aafd..322919c29 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -1513,7 +1513,8 @@ class StoredFile { public function getFileUrl() { global $CC_CONFIG; - return $this->gunid.".".$this->getFileExtension(); + return "http://$CC_CONFIG[baseUrl]:$CC_CONFIG[basePort]/".$this->gunid.".".$this->getFileExtension(); + //return $CC_CONFIG["base_url"]..$this->gunid.".".$this->getFileExtension(); } /** diff --git a/airtime_mvc/build/airtime.conf b/airtime_mvc/build/airtime.conf index 9135f09e4..982d5a762 100644 --- a/airtime_mvc/build/airtime.conf +++ b/airtime_mvc/build/airtime.conf @@ -16,6 +16,8 @@ api_key = AAA web_server_user = www-data airtime_dir = x base_files_dir = x +base_url = localhost +base_port = 80 [soundcloud] connection_retries = 3 diff --git a/install/upgrades/airtime-1.8/airtime-upgrade.php b/install/upgrades/airtime-1.8/airtime-upgrade.php index a961bdbe5..6563e98b4 100644 --- a/install/upgrades/airtime-1.8/airtime-upgrade.php +++ b/install/upgrades/airtime-1.8/airtime-upgrade.php @@ -61,7 +61,7 @@ AirtimeInstall::InstallBinaries(); echo "* Initializing INI files".PHP_EOL; AirtimeIni::UpdateIniFiles(); -Config::reload_config(); +Config::loadConfig(); echo "* Creating default storage directory".PHP_EOL; AirtimeInstall::InstallStorageDirectory(); diff --git a/python_apps/api_clients/api_client.py b/python_apps/api_clients/api_client.py index 8a38e682e..84a03d19e 100644 --- a/python_apps/api_clients/api_client.py +++ b/python_apps/api_clients/api_client.py @@ -220,9 +220,9 @@ class AirTimeApiClient(ApiClientInterface): logger = logging.getLogger() try: - src = "http://%s:%s/%s/%s" % \ - (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["get_media_url"]) - src = src.replace("%%file%%", uri) + #src = "http://%s:%s/%s/%s" % \ + #(self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["get_media_url"]) + src = uri logger.info("try to download from %s to %s", src, dst) src = src.replace("%%api_key%%", self.config["api_key"]) # check if file exists already before downloading again