CC-1927 Remove PEAR DB

* Removed all traces of PEAR functions.
* Fixed AirtimeInstall::GetVersionInstalled() to return the correct answer
  even when it cant connect to the database.  Also fixed return value to
  be consistent on failure.
* Fixed phone_home_stat.php and soundcloud-uploader.php
This commit is contained in:
paul.baranowski 2012-04-05 02:22:21 -04:00 committed by Martin Konecny
parent c0da27b445
commit 96b010e7f0
10 changed files with 65 additions and 120 deletions

View file

@ -29,6 +29,12 @@ require_once($CC_CONFIG['phpDir'].'/application/configs/conf.php');
$CC_CONFIG['phpDir'] = $values['general']['airtime_dir'];
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
get_include_path(),
realpath($CC_CONFIG['phpDir'] . '/library')
)));
require_once($CC_CONFIG['phpDir'].'/application/models/User.php');
require_once($CC_CONFIG['phpDir'].'/application/models/StoredFile.php');
require_once($CC_CONFIG['phpDir'].'/application/models/Playlist.php');
@ -38,50 +44,39 @@ require_once($CC_CONFIG['phpDir'].'/application/models/ShowInstance.php');
require_once($CC_CONFIG['phpDir'].'/application/models/Preference.php');
require_once($CC_CONFIG['phpDir'].'/application/models/StreamSetting.php');
require_once('DB.php');
$CC_DBC = DB::connect($CC_CONFIG['dsn'], FALSE);
if (PEAR::isError($CC_DBC)) {
/*echo $CC_DBC->getMessage().PHP_EOL;
echo $CC_DBC->getUserInfo().PHP_EOL;
echo "Database connection problem.".PHP_EOL;
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
" with corresponding permissions.".PHP_EOL;*/
exit(1);
} else {
//echo "* Connected to database".PHP_EOL;
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
}
require_once 'propel/runtime/lib/Propel.php';
Propel::init($CC_CONFIG['phpDir']."/application/configs/airtime-conf-production.php");
if(Application_Model_Preference::GetSupportFeedback() == '1'){
$infoArray = Application_Model_Preference::GetSystemInfo(true);
$url = 'http://stat.sourcefabric.org/index.php?p=airtime';
//$url = 'http://stat-dev.sourcefabric.org/index.php?p=airtime';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = json_encode($infoArray);
$dataArray = array("data" => $data );
curl_setopt($ch, CURLOPT_POSTFIELDS, $dataArray);
$result = curl_exec($ch);
curl_close($ch);
}
// Get latest version from stat server and store to db
if(Application_Model_Preference::GetPlanLevel() == 'disabled'){
$url = 'http://stat.sourcefabric.org/airtime-stats/airtime_latest_version';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
if(curl_errno($ch)) {
echo "curl error: " . curl_error($ch) . "\n";
} else {
@ -89,7 +84,7 @@ if(Application_Model_Preference::GetPlanLevel() == 'disabled'){
Application_Model_Preference::SetLatestVersion($resultArray[0]);
Application_Model_Preference::SetLatestLink($resultArray[1]);
}
curl_close($ch);
}

View file

@ -24,6 +24,12 @@ require_once($CC_CONFIG['phpDir'].'/application/configs/conf.php');
$CC_CONFIG['phpDir'] = $values['general']['airtime_dir'];
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
get_include_path(),
realpath($CC_CONFIG['phpDir'] . '/library')
)));
require_once($CC_CONFIG['phpDir'].'/application/models/StoredFile.php');
require_once($CC_CONFIG['phpDir'].'/application/models/Preference.php');
require_once($CC_CONFIG['phpDir'].'/application/models/MusicDir.php');
@ -35,21 +41,8 @@ set_include_path($CC_CONFIG['phpDir']."/application/models" . PATH_SEPARATOR . g
require_once($CC_CONFIG['phpDir']."/library/propel/runtime/lib/Propel.php");
Propel::init($CC_CONFIG['phpDir']."/application/configs/airtime-conf.php");
require_once('DB.php');
$CC_DBC = DB::connect($CC_CONFIG['dsn'], FALSE);
if (PEAR::isError($CC_DBC)) {
/*echo $CC_DBC->getMessage().PHP_EOL;
echo $CC_DBC->getUserInfo().PHP_EOL;
echo "Database connection problem.".PHP_EOL;
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
" with corresponding permissions.".PHP_EOL;*/
if ($p_exitOnError) {
exit(1);
}
} else {
//echo "* Connected to database".PHP_EOL;
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
}
require_once 'propel/runtime/lib/Propel.php';
Propel::init($CC_CONFIG['phpDir']."/application/configs/airtime-conf-production.php");
if(count($argv) != 2){
exit;