Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
710389a416
|
@ -2,31 +2,17 @@
|
|||
|
||||
require_once __DIR__."/logging/Logging.php";
|
||||
Logging::setLogPath('/var/log/airtime/zendphp.log');
|
||||
|
||||
require_once __DIR__."/configs/conf.php";
|
||||
|
||||
require_once __DIR__."/configs/ACL.php";
|
||||
require_once 'propel/runtime/lib/Propel.php';
|
||||
Propel::init(__DIR__."/configs/airtime-conf-production.php");
|
||||
|
||||
require_once __DIR__."/configs/constants.php";
|
||||
require_once 'DB.php';
|
||||
|
||||
require_once 'Preference.php';
|
||||
require_once "DateHelper.php";
|
||||
require_once "OsPath.php";
|
||||
require_once __DIR__.'/controllers/plugins/RabbitMqPlugin.php';
|
||||
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$dsn = $CC_CONFIG['dsn'];
|
||||
|
||||
$CC_DBC = DB::connect($dsn, FALSE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
global $CC_CONFIG;
|
||||
$CC_CONFIG['airtime_version'] = Application_Model_Preference::GetAirtimeVersion();
|
||||
|
||||
require_once __DIR__."/configs/navigation.php";
|
||||
|
@ -116,8 +102,6 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|||
protected function _initZFDebug()
|
||||
{
|
||||
if (APPLICATION_ENV == "development"){
|
||||
global $CC_DBC;
|
||||
|
||||
$autoloader = Zend_Loader_Autoloader::getInstance();
|
||||
$autoloader->registerNamespace('ZFDebug');
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ class ApiController extends Zend_Controller_Action
|
|||
if (ctype_alnum($file_id) && strlen($file_id) == 32)
|
||||
{
|
||||
$media = Application_Model_StoredFile::RecallByGunid($file_id);
|
||||
if ( $media != null && !PEAR::isError($media))
|
||||
if ( $media != null )
|
||||
{
|
||||
$filepath = $media->getFilePath();
|
||||
if(is_file($filepath)){
|
||||
|
@ -342,8 +342,6 @@ class ApiController extends Zend_Controller_Action
|
|||
exit;
|
||||
}
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
|
||||
$data = Application_Model_Schedule::GetScheduledPlaylists();
|
||||
echo json_encode($data, JSON_FORCE_OBJECT);
|
||||
}
|
||||
|
@ -368,12 +366,7 @@ class ApiController extends Zend_Controller_Action
|
|||
$schedule_group_id = $this->_getParam("schedule_id");
|
||||
$media_id = $this->_getParam("media_id");
|
||||
$result = Application_Model_Schedule::UpdateMediaPlayedStatus($media_id);
|
||||
|
||||
if (!PEAR::isError($result)) {
|
||||
echo json_encode(array("status"=>1, "message"=>""));
|
||||
} else {
|
||||
echo json_encode(array("status"=>0, "message"=>"DB Error:".$result->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
public function recordedShowsAction()
|
||||
|
|
|
@ -19,6 +19,8 @@ class AudiopreviewController extends Zend_Controller_Action
|
|||
*/
|
||||
public function audioPreviewAction()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
$audioFileID = $this->_getParam('audioFileID');
|
||||
$audioFileArtist = $this->_getParam('audioFileArtist');
|
||||
$audioFileTitle = $this->_getParam('audioFileTitle');
|
||||
|
@ -28,9 +30,9 @@ class AudiopreviewController extends Zend_Controller_Action
|
|||
|
||||
$baseDir = dirname($_SERVER['SCRIPT_FILENAME']);
|
||||
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/audiopreview/preview_jplayer.js?'.filemtime($baseDir.'/js/audiopreview/preview_jplayer.js'),'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/jplayer/jplayer.playlist.min.js?'.filemtime($baseDir.'/js/jplayer/jplayer.playlist.min.js'),'text/javascript');
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/js/jplayer/skin/jplayer.audio-preview.blue.monday.css?'.filemtime($baseDir.'/js/jplayer/skin/jplayer.audio-preview.blue.monday.css'));
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/audiopreview/preview_jplayer.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/jplayer/jplayer.playlist.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/js/jplayer/skin/jplayer.audio-preview.blue.monday.css?'.$CC_CONFIG['airtime_version']);
|
||||
$this->_helper->layout->setLayout('audioPlayer');
|
||||
|
||||
$logo = Application_Model_Preference::GetStationLogo();
|
||||
|
@ -52,6 +54,8 @@ class AudiopreviewController extends Zend_Controller_Action
|
|||
*/
|
||||
public function playlistPreviewAction()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
$playlistIndex = $this->_getParam('playlistIndex');
|
||||
$playlistID = $this->_getParam('playlistID');
|
||||
|
||||
|
@ -60,9 +64,9 @@ class AudiopreviewController extends Zend_Controller_Action
|
|||
|
||||
$baseDir = dirname($_SERVER['SCRIPT_FILENAME']);
|
||||
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/audiopreview/preview_jplayer.js?'.filemtime($baseDir.'/js/audiopreview/preview_jplayer.js'),'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/jplayer/jplayer.playlist.min.js?'.filemtime($baseDir.'/js/jplayer/jplayer.playlist.min.js'),'text/javascript');
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/js/jplayer/skin/jplayer.audio-preview.blue.monday.css?'.filemtime($baseDir.'/js/jplayer/skin/jplayer.audio-preview.blue.monday.css'));
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/audiopreview/preview_jplayer.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/jplayer/jplayer.playlist.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/js/jplayer/skin/jplayer.audio-preview.blue.monday.css?'.$CC_CONFIG['airtime_version']);
|
||||
$this->_helper->layout->setLayout('audioPlayer');
|
||||
|
||||
$logo = Application_Model_Preference::GetStationLogo();
|
||||
|
@ -121,6 +125,8 @@ class AudiopreviewController extends Zend_Controller_Action
|
|||
*/
|
||||
public function showPreviewAction()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
$showID = $this->_getParam('showID');
|
||||
$showIndex = $this->_getParam('showIndex');
|
||||
|
||||
|
@ -129,9 +135,9 @@ class AudiopreviewController extends Zend_Controller_Action
|
|||
|
||||
$baseDir = dirname($_SERVER['SCRIPT_FILENAME']);
|
||||
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/audiopreview/preview_jplayer.js?'.filemtime($baseDir.'/js/audiopreview/preview_jplayer.js'),'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/jplayer/jplayer.playlist.min.js?'.filemtime($baseDir.'/js/jplayer/jplayer.playlist.min.js'),'text/javascript');
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/js/jplayer/skin/jplayer.audio-preview.blue.monday.css?'.filemtime($baseDir.'/js/jplayer/skin/jplayer.audio-preview.blue.monday.css'));
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/audiopreview/preview_jplayer.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/jplayer/jplayer.playlist.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/js/jplayer/skin/jplayer.audio-preview.blue.monday.css?'.$CC_CONFIG['airtime_version']);
|
||||
$this->_helper->layout->setLayout('audioPlayer');
|
||||
|
||||
$logo = Application_Model_Preference::GetStationLogo();
|
||||
|
|
|
@ -46,7 +46,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
$master_dj_port = new Zend_Form_Element_Text('master_harbor_input_port');
|
||||
$master_dj_port->setLabel("Master Source Port")
|
||||
->setValue($m_port)
|
||||
->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999))))
|
||||
->setValidators(array(new Zend_Validate_Between(array('min'=>1024, 'max'=>49151))))
|
||||
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.')))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$this->addElement($master_dj_port);
|
||||
|
@ -65,7 +65,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
$live_dj_port = new Zend_Form_Element_Text('dj_harbor_input_port');
|
||||
$live_dj_port->setLabel("Show Source Port")
|
||||
->setValue($l_port)
|
||||
->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999))))
|
||||
->setValidators(array(new Zend_Validate_Between(array('min'=>1024, 'max'=>49151))))
|
||||
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.')))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$this->addElement($live_dj_port);
|
||||
|
@ -99,7 +99,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
$live_dj_connection_url = "N/A";
|
||||
}
|
||||
|
||||
$overrideDescription = "If Airtime is behind a router or firewall, you may need to configure port forwarding and this field information will be incorrect. In this case you will need to manually update this field so it shows the correct host/port/mount that your DJ's need to connect to. For more detail, please read the <a target=\"_blank\" href=\"http://manuals.sourcefabric.org/\">Airtime manual</a>.";
|
||||
$overrideDescription = "If Airtime is behind a router or firewall, you may need to configure port forwarding and this field information will be incorrect. In this case you will need to manually update this field so it shows the correct host/port/mount that your DJ's need to connect to. The allowed range is between 1024 and 49151. For more detail, please read the <a target=\"_blank\" href=\"http://manuals.sourcefabric.org/\">Airtime manual</a>.";
|
||||
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml', 'master_dj_connection_url'=>$master_dj_connection_url, 'live_dj_connection_url'=>$live_dj_connection_url,'overrideDescription' => $overrideDescription))
|
||||
|
@ -117,6 +117,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
$element->addError("You cannot use same port as Master DJ port.");
|
||||
}
|
||||
if($master_harbor_input_port != ""){
|
||||
if(is_numeric($master_harbor_input_port)){
|
||||
if($master_harbor_input_port != Application_Model_StreamSetting::GetMasterLiveSteamPort()){
|
||||
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
||||
$res = socket_bind($sock, 0, $master_harbor_input_port);
|
||||
|
@ -127,8 +128,12 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
}
|
||||
socket_close($sock);
|
||||
}
|
||||
}else{
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
if($dj_harbor_input_port != ""){
|
||||
if(is_numeric($dj_harbor_input_port)){
|
||||
if($dj_harbor_input_port != Application_Model_StreamSetting::GetDJLiveSteamPort()){
|
||||
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
||||
$res = socket_bind($sock, 0, $dj_harbor_input_port);
|
||||
|
@ -139,6 +144,9 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
}
|
||||
socket_close($sock);
|
||||
}
|
||||
}else{
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
return $isValid;
|
||||
}
|
||||
|
|
|
@ -94,9 +94,6 @@ class Application_Model_Datatables {
|
|||
Logging::debug($e->getMessage());
|
||||
}
|
||||
|
||||
//display sql executed in airtime log for testing
|
||||
Logging::debug($sql);
|
||||
|
||||
return array(
|
||||
"sEcho" => intval($data["sEcho"]),
|
||||
"iTotalDisplayRecords" => intval($totalDisplayRows),
|
||||
|
|
|
@ -5,41 +5,32 @@ class Application_Model_LoginAttempts {
|
|||
}
|
||||
|
||||
public static function increaseAttempts($ip){
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "select count(*) from cc_login_attempts WHERE ip='$ip'";
|
||||
$res = $CC_DBC->GetOne($sql);
|
||||
$res = $con->query($sql)->fetchColumn(0);
|
||||
if ($res) {
|
||||
$sql = "UPDATE cc_login_attempts SET attempts=attempts+1 WHERE ip='$ip'";
|
||||
$res = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$con->exec($sql);
|
||||
} else {
|
||||
$sql = "INSERT INTO cc_login_attempts (ip, attempts) values ('$ip', '1')";
|
||||
$res = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$con->exec($sql);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getAttempts($ip){
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "select attempts from cc_login_attempts WHERE ip='$ip'";
|
||||
$res = $CC_DBC->GetOne($sql);
|
||||
return $res;
|
||||
$res = $con->query($sql)->fetchColumn(0);
|
||||
return $res ? $res : 0;
|
||||
}
|
||||
|
||||
public static function resetAttempts($ip){
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "select count(*) from cc_login_attempts WHERE ip='$ip'";
|
||||
$res = $CC_DBC->GetOne($sql);
|
||||
if($res){
|
||||
$res = $con->query($sql)->fetchColumn(0);
|
||||
if ($res > 0) {
|
||||
$sql = "DELETE FROM cc_login_attempts WHERE ip='$ip'";
|
||||
$res = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$con->exec($sql);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -58,7 +58,8 @@ class Application_Model_MusicDir {
|
|||
return $this->_dir->getExists();
|
||||
}
|
||||
|
||||
/** There are 2 cases where this function can be called.
|
||||
/**
|
||||
* There are 2 cases where this function can be called.
|
||||
* 1. When watched dir was removed
|
||||
* 2. When some dir was watched, but it was unmounted
|
||||
*
|
||||
|
@ -67,21 +68,23 @@ class Application_Model_MusicDir {
|
|||
*
|
||||
* When $userAddedWatchedDir is true, it will set "Watched" flag to false
|
||||
* otherwise, it will set "Exists" flag to true
|
||||
**/
|
||||
*/
|
||||
public function remove($userAddedWatchedDir=true)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$music_dir_id = $this->getId();
|
||||
|
||||
$sql = "SELECT DISTINCT s.instance_id from cc_music_dirs as md LEFT JOIN cc_files as f on f.directory = md.id
|
||||
RIGHT JOIN cc_schedule as s on s.file_id = f.id WHERE md.id = $music_dir_id";
|
||||
$sql = "SELECT DISTINCT s.instance_id from cc_music_dirs as md "
|
||||
." LEFT JOIN cc_files as f on f.directory = md.id"
|
||||
." RIGHT JOIN cc_schedule as s on s.file_id = f.id WHERE md.id = $music_dir_id";
|
||||
|
||||
$show_instances = $CC_DBC->GetAll($sql);
|
||||
$show_instances = $con->query($sql)->fetchAll();
|
||||
|
||||
// get all the files on this dir
|
||||
$sql = "SELECT f.id FROM cc_music_dirs as md LEFT JOIN cc_files as f on f.directory = md.id WHERE md.id = $music_dir_id";
|
||||
$files = $CC_DBC->GetAll($sql);
|
||||
$sql = "SELECT f.id FROM cc_music_dirs as md "
|
||||
." LEFT JOIN cc_files as f on f.directory = md.id WHERE md.id = $music_dir_id";
|
||||
$files = $con->query($sql)->fetchAll();
|
||||
|
||||
// set file_exist flag to false
|
||||
foreach ($files as $file_row) {
|
||||
|
|
|
@ -769,10 +769,12 @@ class Application_Model_Playlist {
|
|||
return $res;
|
||||
}
|
||||
|
||||
public static function getPlaylistCount(){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
public static function getPlaylistCount()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = 'SELECT count(*) as cnt FROM '.$CC_CONFIG["playListTable"];
|
||||
return $CC_DBC->GetOne($sql);
|
||||
return $con->query($sql)->fetchColumn(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,8 @@ class Application_Model_Preference
|
|||
{
|
||||
|
||||
public static function SetValue($key, $value, $isUserValue = false){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
//called from a daemon process
|
||||
if(!class_exists("Zend_Auth", false) || !Zend_Auth::getInstance()->hasIdentity()) {
|
||||
|
@ -27,7 +28,7 @@ class Application_Model_Preference
|
|||
$sql .= " AND subjid = '$id'";
|
||||
}
|
||||
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
$result = $con->query($sql)->fetchColumn(0);
|
||||
|
||||
if($result == 1) {
|
||||
// result found
|
||||
|
@ -55,11 +56,12 @@ class Application_Model_Preference
|
|||
}
|
||||
}
|
||||
|
||||
return $CC_DBC->query($sql);
|
||||
return $con->exec($sql);
|
||||
}
|
||||
|
||||
public static function GetValue($key, $isUserValue = false){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
//Check if key already exists
|
||||
$sql = "SELECT COUNT(*) FROM cc_pref"
|
||||
|
@ -72,8 +74,7 @@ class Application_Model_Preference
|
|||
$sql .= " AND subjid = '$id'";
|
||||
}
|
||||
}
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
|
||||
$result = $con->query($sql)->fetchColumn(0);
|
||||
if ($result == 0)
|
||||
return "";
|
||||
else {
|
||||
|
@ -85,8 +86,8 @@ class Application_Model_Preference
|
|||
$sql .= " AND subjid = '$id'";
|
||||
}
|
||||
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
return $result;
|
||||
$result = $con->query($sql)->fetchColumn(0);
|
||||
return ($result !== false) ? $result : "";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,10 +366,11 @@ class Application_Model_Preference
|
|||
return self::GetValue("uniqueId");
|
||||
}
|
||||
|
||||
public static function GetCountryList(){
|
||||
global $CC_DBC;
|
||||
public static function GetCountryList()
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT * FROM cc_country";
|
||||
$res = $CC_DBC->GetAll($sql);
|
||||
$res = $con->query($sql)->fetchAll();
|
||||
$out = array();
|
||||
$out[""] = "Select Country";
|
||||
foreach($res as $r){
|
||||
|
|
|
@ -9,10 +9,11 @@ class Application_Model_Schedule {
|
|||
*/
|
||||
public function IsFileScheduledInTheFuture($p_fileId)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT COUNT(*) FROM ".$CC_CONFIG["scheduleTable"]
|
||||
." WHERE file_id = {$p_fileId} AND starts > NOW()";
|
||||
$count = $CC_DBC->GetOne($sql);
|
||||
$count = $con->query($sql)->fetchColumn(0);
|
||||
if (is_numeric($count) && ($count != '0')) {
|
||||
return TRUE;
|
||||
} else {
|
||||
|
@ -70,18 +71,19 @@ class Application_Model_Schedule {
|
|||
if ($p_previousShowID == null && $p_currentShowID == null && $p_nextShowID == null)
|
||||
return;
|
||||
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = 'Select ft.artist_name,
|
||||
ft.track_title,
|
||||
st.starts as starts,
|
||||
st.ends as ends,
|
||||
st.media_item_played as media_item_played,
|
||||
si.ends as show_ends
|
||||
FROM cc_schedule st
|
||||
LEFT JOIN cc_files ft ON st.file_id = ft.id
|
||||
LEFT JOIN cc_show_instances si on st.instance_id = si.id
|
||||
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = 'Select ft.artist_name, ft.track_title, st.starts as starts, st.ends as ends, st.media_item_played as media_item_played, si.ends as show_ends
|
||||
FROM cc_schedule st LEFT JOIN cc_files ft ON st.file_id = ft.id LEFT JOIN cc_show_instances si on st.instance_id = si.id
|
||||
WHERE ';
|
||||
|
||||
/* Alternate SQL...merge conflict and I'm not sure which on is right.... -MK
|
||||
$sql = 'Select ft.artist_name, ft.track_title, st.starts as starts, st.ends as ends, st.media_item_played as media_item_played, si.ends as show_ends
|
||||
FROM cc_schedule st LEFT JOIN cc_files ft ON st.file_id = ft.id
|
||||
WHERE ';
|
||||
*/
|
||||
|
||||
if (isset($p_previousShowID)){
|
||||
if (isset($p_nextShowID) || isset($p_currentShowID))
|
||||
$sql .= '(';
|
||||
|
@ -105,8 +107,8 @@ class Application_Model_Schedule {
|
|||
|
||||
$sql .= ' AND st.playout_status > 0 ORDER BY st.starts';
|
||||
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
|
||||
$rows = $con->query($sql)->fetchAll();
|
||||
$numberOfRows = count($rows);
|
||||
|
||||
$results['previous'] = null;
|
||||
|
@ -130,7 +132,6 @@ class Application_Model_Schedule {
|
|||
"ends"=> (($rows[$i]["ends"] > $rows[$i]["show_ends"]) ? $rows[$i]["show_ends"]: $rows[$i]["ends"]),
|
||||
"media_item_played"=>$rows[$i]["media_item_played"],
|
||||
"record"=>0);
|
||||
|
||||
if ( isset($rows[$i+1])){
|
||||
$results['next'] = array("name"=>$rows[$i+1]["artist_name"]." - ".$rows[$i+1]["track_title"],
|
||||
"starts"=>$rows[$i+1]["starts"],
|
||||
|
@ -159,8 +160,8 @@ class Application_Model_Schedule {
|
|||
}
|
||||
|
||||
public static function GetLastScheduleItem($p_timeNow){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT"
|
||||
." ft.artist_name, ft.track_title,"
|
||||
." st.starts as starts, st.ends as ends"
|
||||
|
@ -175,14 +176,14 @@ class Application_Model_Schedule {
|
|||
." ORDER BY st.ends DESC"
|
||||
." LIMIT 1";
|
||||
|
||||
$row = $CC_DBC->GetAll($sql);
|
||||
$row = $con->query($sql)->fetchAll();
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
||||
public static function GetCurrentScheduleItem($p_timeNow, $p_instanceId){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
/* Note that usually there will be one result returned. In some
|
||||
* rare cases two songs are returned. This happens when a track
|
||||
* that was overbooked from a previous show appears as if it
|
||||
|
@ -200,13 +201,13 @@ class Application_Model_Schedule {
|
|||
." ORDER BY st.starts DESC"
|
||||
." LIMIT 1";
|
||||
|
||||
$row = $CC_DBC->GetAll($sql);
|
||||
$row = $con->query($sql)->fetchAll();
|
||||
return $row;
|
||||
}
|
||||
|
||||
public static function GetNextScheduleItem($p_timeNow){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT"
|
||||
." ft.artist_name, ft.track_title,"
|
||||
." st.starts as starts, st.ends as ends"
|
||||
|
@ -221,7 +222,7 @@ class Application_Model_Schedule {
|
|||
." ORDER BY st.starts"
|
||||
." LIMIT 1";
|
||||
|
||||
$row = $CC_DBC->GetAll($sql);
|
||||
$row = $con->query($sql)->fetchAll();
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
@ -236,8 +237,8 @@ class Application_Model_Schedule {
|
|||
*/
|
||||
public static function GetScheduleDetailItems($p_start, $p_end, $p_shows)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT DISTINCT
|
||||
|
||||
showt.name AS show_name, showt.color AS show_color,
|
||||
|
@ -273,26 +274,27 @@ class Application_Model_Schedule {
|
|||
|
||||
$sql .= " ORDER BY si.starts, sched.starts;";
|
||||
|
||||
Logging::debug($sql);
|
||||
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
$rows = $con->query($sql)->fetchAll();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public static function UpdateMediaPlayedStatus($p_id)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "UPDATE ".$CC_CONFIG['scheduleTable']
|
||||
." SET media_item_played=TRUE"
|
||||
." WHERE id=$p_id";
|
||||
$retVal = $CC_DBC->query($sql);
|
||||
$retVal = $con->exec($sql);
|
||||
return $retVal;
|
||||
}
|
||||
|
||||
public static function getSchduledPlaylistCount(){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
public static function getSchduledPlaylistCount()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG['scheduleTable'];
|
||||
return $CC_DBC->GetOne($sql);
|
||||
return $con->query($sql)->fetchColumn(0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -411,7 +413,8 @@ class Application_Model_Schedule {
|
|||
* arrays representing each row.
|
||||
*/
|
||||
public static function GetItems($p_startTime, $p_endTime) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$baseQuery = "SELECT st.file_id AS file_id,"
|
||||
." st.id as id,"
|
||||
|
@ -437,13 +440,10 @@ class Application_Model_Schedule {
|
|||
|
||||
$sql = $baseQuery.$predicates;
|
||||
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
if (PEAR::isError($rows)) {
|
||||
return null;
|
||||
}
|
||||
$rows = $con->query($sql)->fetchAll();
|
||||
|
||||
if (count($rows) < 3){
|
||||
Logging::debug("Get Schedule: Less than 3 results returned. Do another query in an attempt to get 3.");
|
||||
Logging::debug("Get Schedule: Less than 3 results returned. Doing another query since we need a minimum of 3 results.");
|
||||
|
||||
$dt = new DateTime("@".time());
|
||||
$dt->add(new DateInterval("PT24H"));
|
||||
|
@ -457,10 +457,7 @@ class Application_Model_Schedule {
|
|||
." LIMIT 3";
|
||||
|
||||
$sql = $baseQuery.$predicates;
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
if (PEAR::isError($rows)) {
|
||||
return null;
|
||||
}
|
||||
$rows = $con->query($sql)->fetchAll();
|
||||
}
|
||||
|
||||
return $rows;
|
||||
|
@ -468,7 +465,7 @@ class Application_Model_Schedule {
|
|||
|
||||
public static function GetScheduledPlaylists($p_fromDateTime = null, $p_toDateTime = null){
|
||||
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
|
||||
/* if $p_fromDateTime and $p_toDateTime function parameters are null, then set range
|
||||
* from "now" to "now + 24 hours". */
|
||||
|
@ -578,8 +575,9 @@ class Application_Model_Schedule {
|
|||
|
||||
public static function deleteAll()
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$CC_DBC->query("TRUNCATE TABLE ".$CC_CONFIG["scheduleTable"]);
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$con->exec("TRUNCATE TABLE ".$CC_CONFIG["scheduleTable"]);
|
||||
}
|
||||
|
||||
public static function deleteWithFileId($fileId){
|
||||
|
|
|
@ -113,13 +113,13 @@ class Application_Model_Show {
|
|||
|
||||
public function getHosts()
|
||||
{
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$sql = "SELECT first_name, last_name
|
||||
FROM cc_show_hosts LEFT JOIN cc_subjs ON cc_show_hosts.subjs_id = cc_subjs.id
|
||||
WHERE show_id = {$this->_showId}";
|
||||
|
||||
$hosts = $CC_DBC->GetAll($sql);
|
||||
$hosts = $con->query($sql)->fetchAll();
|
||||
|
||||
$res = array();
|
||||
foreach ($hosts as $host) {
|
||||
|
@ -131,18 +131,20 @@ class Application_Model_Show {
|
|||
|
||||
public function getHostsIds()
|
||||
{
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$sql = "SELECT subjs_id
|
||||
FROM cc_show_hosts
|
||||
WHERE show_id = {$this->_showId}";
|
||||
|
||||
$hosts = $CC_DBC->GetAll($sql);
|
||||
$hosts = $con->query($sql)->fetchAll();
|
||||
|
||||
return $hosts;
|
||||
}
|
||||
|
||||
//remove everything about this show.
|
||||
/**
|
||||
* remove everything about this show.
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
//usually we hide the show-instance, but in this case we are deleting the show template
|
||||
|
@ -155,7 +157,7 @@ class Application_Model_Show {
|
|||
|
||||
public function resizeShow($deltaDay, $deltaMin)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
if ($deltaDay > 0) {
|
||||
return "Shows can have a max length of 24 hours.";
|
||||
|
@ -186,7 +188,7 @@ class Application_Model_Show {
|
|||
AND ((CAST(duration AS interval) + interval '{$deltaDay} days' + interval '{$hours}:{$mins}') <= interval '24:00')";
|
||||
|
||||
//do both the queries at once.
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
|
||||
$con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
|
||||
$con->beginTransaction();
|
||||
|
@ -215,7 +217,7 @@ class Application_Model_Show {
|
|||
|
||||
public function cancelShow($day_timestamp)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$timeinfo = explode(" ", $day_timestamp);
|
||||
|
||||
|
@ -227,7 +229,7 @@ class Application_Model_Show {
|
|||
SET modified_instance = TRUE
|
||||
WHERE starts >= '{$day_timestamp}' AND show_id = {$this->_showId}";
|
||||
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
|
||||
// check if we can safely delete the show
|
||||
$showInstancesRow = CcShowInstancesQuery::create()
|
||||
|
@ -237,7 +239,7 @@ class Application_Model_Show {
|
|||
|
||||
if(is_null($showInstancesRow)){
|
||||
$sql = "DELETE FROM cc_show WHERE id = {$this->_showId}";
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
}
|
||||
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
|
@ -258,7 +260,7 @@ class Application_Model_Show {
|
|||
*/
|
||||
public function removeUncheckedDaysInstances($p_uncheckedDays)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
//need to convert local doftw to UTC doftw (change made for 2.0 since shows are stored in UTC)
|
||||
$daysRemovedUTC = array();
|
||||
|
@ -273,9 +275,9 @@ class Application_Model_Show {
|
|||
}
|
||||
|
||||
foreach($showDays as $showDay) {
|
||||
Logging::log("Local show day is: {$showDay->getDbDay()}");
|
||||
Logging::log("First show day is: {$showDay->getDbFirstShow()}");
|
||||
Logging::log("Id show days is: {$showDay->getDbId()}");
|
||||
//Logging::log("Local show day is: {$showDay->getDbDay()}");
|
||||
//Logging::log("First show day is: {$showDay->getDbFirstShow()}");
|
||||
//Logging::log("Id show days is: {$showDay->getDbId()}");
|
||||
|
||||
if (in_array($showDay->getDbDay(), $p_uncheckedDays)) {
|
||||
$showDay->reload();
|
||||
|
@ -283,11 +285,11 @@ class Application_Model_Show {
|
|||
//Logging::log("First show day is: {$showDay->getDbFirstShow()}");
|
||||
//Logging::log("Id show days is: {$showDay->getDbId()}");
|
||||
$startDay = new DateTime("{$showDay->getDbFirstShow()} {$showDay->getDbStartTime()}", new DateTimeZone($showDay->getDbTimezone()));
|
||||
Logging::log("Show start day: {$startDay->format('Y-m-d H:i:s')}");
|
||||
//Logging::log("Show start day: {$startDay->format('Y-m-d H:i:s')}");
|
||||
$startDay->setTimezone(new DateTimeZone("UTC"));
|
||||
Logging::log("Show start day UTC: {$startDay->format('Y-m-d H:i:s')}");
|
||||
//Logging::log("Show start day UTC: {$startDay->format('Y-m-d H:i:s')}");
|
||||
$daysRemovedUTC[] = $startDay->format('w');
|
||||
Logging::log("UTC show day is: {$startDay->format('w')}");
|
||||
//Logging::log("UTC show day is: {$startDay->format('w')}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,9 +303,9 @@ class Application_Model_Show {
|
|||
." AND starts > TIMESTAMP '$timestamp'"
|
||||
." AND show_id = $showId";
|
||||
|
||||
Logging::log($sql);
|
||||
//Logging::log($sql);
|
||||
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -351,7 +353,7 @@ class Application_Model_Show {
|
|||
*/
|
||||
public function getRebroadcastsAbsolute()
|
||||
{
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$showId = $this->getId();
|
||||
|
||||
|
@ -359,9 +361,9 @@ class Application_Model_Show {
|
|||
."WHERE instance_id = (SELECT id FROM cc_show_instances WHERE show_id = $showId ORDER BY starts LIMIT 1) AND rebroadcast = 1 "
|
||||
."ORDER BY starts";
|
||||
|
||||
Logging::log($sql);
|
||||
//Logging::log($sql);
|
||||
|
||||
$rebroadcasts = $CC_DBC->GetAll($sql);
|
||||
$rebroadcasts = $con->query($sql)->fetchAll();
|
||||
|
||||
$rebroadcastsLocal = array();
|
||||
//get each rebroadcast show in cc_show_instances, convert to current timezone to get start date/time.
|
||||
|
@ -389,14 +391,14 @@ class Application_Model_Show {
|
|||
*/
|
||||
public function getRebroadcastsRelative()
|
||||
{
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$showId = $this->getId();
|
||||
$sql = "SELECT day_offset, start_time FROM cc_show_rebroadcast "
|
||||
."WHERE show_id = $showId "
|
||||
."ORDER BY day_offset";
|
||||
|
||||
return $CC_DBC->GetAll($sql);
|
||||
return $con->query($sql)->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -447,21 +449,17 @@ class Application_Model_Show {
|
|||
* Return the end date for the repeating show or the empty
|
||||
* string if there is no end.
|
||||
*/
|
||||
public function getRepeatingEndDate(){
|
||||
global $CC_DBC;
|
||||
public function getRepeatingEndDate()
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$showId = $this->getId();
|
||||
$sql = "SELECT last_show FROM cc_show_days"
|
||||
." WHERE show_id = $showId"
|
||||
." ORDER BY last_show DESC";
|
||||
|
||||
$endDate = $CC_DBC->GetOne($sql);
|
||||
|
||||
if (is_null($endDate)){
|
||||
return "";
|
||||
} else {
|
||||
return $endDate;
|
||||
}
|
||||
$query = $con->query($sql)->fetchColumn(0);
|
||||
return ($query !== false) ? $query : "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -475,7 +473,7 @@ class Application_Model_Show {
|
|||
* be gone for good.
|
||||
*/
|
||||
public function deleteAllInstances(){
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$timestamp = gmdate("Y-m-d H:i:s");
|
||||
|
||||
|
@ -484,7 +482,7 @@ class Application_Model_Show {
|
|||
." WHERE starts > TIMESTAMP '$timestamp'"
|
||||
." AND show_id = $showId";
|
||||
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -492,7 +490,7 @@ class Application_Model_Show {
|
|||
* show object from the show_instances table.
|
||||
*/
|
||||
public function deleteAllRebroadcasts(){
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$timestamp = gmdate("Y-m-d H:i:s");
|
||||
|
||||
|
@ -502,7 +500,7 @@ class Application_Model_Show {
|
|||
." AND show_id = $showId"
|
||||
." AND rebroadcast = 1";
|
||||
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -515,7 +513,7 @@ class Application_Model_Show {
|
|||
* The date which to delete after, if null deletes from the current timestamp.
|
||||
*/
|
||||
public function removeAllInstancesFromDate($p_date=null){
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$timestamp = gmdate("Y-m-d H:i:s");
|
||||
|
||||
|
@ -530,7 +528,7 @@ class Application_Model_Show {
|
|||
." AND starts > TIMESTAMP '$timestamp'"
|
||||
." AND show_id = $showId";
|
||||
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
|
||||
}
|
||||
|
||||
|
@ -547,7 +545,7 @@ class Application_Model_Show {
|
|||
* The date which to delete before
|
||||
*/
|
||||
public function removeAllInstancesBeforeDate($p_date){
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$timestamp = gmdate("Y-m-d H:i:s");
|
||||
|
||||
|
@ -557,7 +555,7 @@ class Application_Model_Show {
|
|||
." AND starts > TIMESTAMP '$timestamp'"
|
||||
." AND show_id = $showId";
|
||||
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -567,7 +565,7 @@ class Application_Model_Show {
|
|||
* The start date in the format YYYY-MM-DD
|
||||
*/
|
||||
public function getStartDate(){
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$showId = $this->getId();
|
||||
$sql = "SELECT first_show, start_time, timezone FROM cc_show_days"
|
||||
|
@ -575,11 +573,12 @@ class Application_Model_Show {
|
|||
." ORDER BY first_show"
|
||||
." LIMIT 1";
|
||||
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
$query = $con->query($sql);
|
||||
|
||||
if (count($rows) == 0){
|
||||
if ($query->rowCount() == 0){
|
||||
return "";
|
||||
} else {
|
||||
$rows = $query->fetchAll();
|
||||
$row = $rows[0];
|
||||
|
||||
$dt = new DateTime($row["first_show"]." ".$row["start_time"], new DateTimeZone($row["timezone"]));
|
||||
|
@ -596,7 +595,7 @@ class Application_Model_Show {
|
|||
*/
|
||||
|
||||
public function getStartTime(){
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$showId = $this->getId();
|
||||
$sql = "SELECT first_show, start_time, timezone FROM cc_show_days"
|
||||
|
@ -604,11 +603,12 @@ class Application_Model_Show {
|
|||
." ORDER BY first_show"
|
||||
." LIMIT 1";
|
||||
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
$query = $con->query($sql);
|
||||
|
||||
if (count($rows) == 0){
|
||||
if ($query->rowCount() == 0){
|
||||
return "";
|
||||
} else {
|
||||
$rows = $query->fetchAll();
|
||||
$row = $rows[0];
|
||||
$dt = new DateTime($row["first_show"]." ".$row["start_time"], new DateTimeZone($row["timezone"]));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
|
@ -676,7 +676,7 @@ class Application_Model_Show {
|
|||
* scheduled in the future.
|
||||
*/
|
||||
public function getAllFutureInstanceIds(){
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$date = new Application_Common_DateHelper;
|
||||
$timestamp = $date->getTimestamp();
|
||||
|
@ -687,7 +687,7 @@ class Application_Model_Show {
|
|||
." AND starts > TIMESTAMP '$timestamp'"
|
||||
." AND modified_instance != TRUE";
|
||||
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
$rows = $con->query($sql)->fetchAll();
|
||||
|
||||
$instance_ids = array();
|
||||
foreach ($rows as $row) {
|
||||
|
@ -705,8 +705,7 @@ class Application_Model_Show {
|
|||
*/
|
||||
private function updateDurationTime($p_data){
|
||||
//need to update cc_show_instances, cc_show_days
|
||||
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$date = new Application_Common_DateHelper;
|
||||
$timestamp = $date->getUtcTimestamp();
|
||||
|
@ -714,20 +713,20 @@ class Application_Model_Show {
|
|||
$sql = "UPDATE cc_show_days "
|
||||
."SET duration = '$p_data[add_show_duration]' "
|
||||
."WHERE show_id = $p_data[add_show_id]";
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
|
||||
$sql = "UPDATE cc_show_instances "
|
||||
."SET ends = starts + INTERVAL '$p_data[add_show_duration]' "
|
||||
."WHERE show_id = $p_data[add_show_id] "
|
||||
."AND ends > TIMESTAMP '$timestamp'";
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function updateStartDateTime($p_data, $p_endDate){
|
||||
//need to update cc_schedule, cc_show_instances, cc_show_days
|
||||
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$date = new Application_Common_DateHelper;
|
||||
$timestamp = $date->getTimestamp();
|
||||
|
@ -742,7 +741,7 @@ class Application_Model_Show {
|
|||
$sql .= "last_show = DATE '$p_endDate' ";
|
||||
}
|
||||
$sql .= "WHERE show_id = $p_data[add_show_id]";
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
|
||||
$dtOld = new DateTime($this->getStartDate()." ".$this->getStartTime(), new DateTimeZone("UTC"));
|
||||
$dtNew = new DateTime($p_data['add_show_start_date']." ".$p_data['add_show_start_time'], new DateTimeZone(date_default_timezone_get()));
|
||||
|
@ -753,7 +752,7 @@ class Application_Model_Show {
|
|||
."ends = ends + INTERVAL '$diff sec' "
|
||||
."WHERE show_id = $p_data[add_show_id] "
|
||||
."AND starts > TIMESTAMP '$timestamp'";
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
|
||||
$showInstanceIds = $this->getAllFutureInstanceIds();
|
||||
if (count($showInstanceIds) > 0 && $diff != 0){
|
||||
|
@ -762,7 +761,7 @@ class Application_Model_Show {
|
|||
."SET starts = starts + INTERVAL '$diff sec', "
|
||||
."ends = ends + INTERVAL '$diff sec' "
|
||||
."WHERE instance_id IN ($showIdsImploded)";
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -848,7 +847,8 @@ class Application_Model_Show {
|
|||
* @return CcShowInstancesQuery: An propel object representing a
|
||||
* row in the cc_show_instances table. */
|
||||
public function getInstanceOnDate($p_dateTime){
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$timestamp = $p_dateTime->format("Y-m-d H:i:s");
|
||||
|
||||
$showId = $this->getId();
|
||||
|
@ -856,7 +856,8 @@ class Application_Model_Show {
|
|||
." WHERE date(starts) = date(TIMESTAMP '$timestamp') "
|
||||
." AND show_id = $showId";
|
||||
|
||||
$row = $CC_DBC->GetOne($sql);
|
||||
$query = $con->query();
|
||||
$row = $query ? $query->fetchColumn(0) : null;
|
||||
return CcShowInstancesQuery::create()
|
||||
->findPk($row);
|
||||
}
|
||||
|
@ -1164,7 +1165,7 @@ class Application_Model_Show {
|
|||
*/
|
||||
public static function populateShowUntil($p_showId)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
$date = Application_Model_Preference::GetShowsPopulatedUntil();
|
||||
|
||||
if (is_null($date)) {
|
||||
|
@ -1175,7 +1176,7 @@ class Application_Model_Show {
|
|||
}
|
||||
|
||||
$sql = "SELECT * FROM cc_show_days WHERE show_id = $p_showId";
|
||||
$res = $CC_DBC->GetAll($sql);
|
||||
$res = $con->query($sql)->fetchAll();
|
||||
|
||||
foreach ($res as $showRow) {
|
||||
Application_Model_Show::populateShow($showRow, $p_populateUntilDateTime);
|
||||
|
@ -1220,7 +1221,7 @@ class Application_Model_Show {
|
|||
*/
|
||||
private static function populateNonRepeatingShow($p_showRow, $p_populateUntilDateTime)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$show_id = $p_showRow["show_id"];
|
||||
$first_show = $p_showRow["first_show"]; //non-UTC
|
||||
|
@ -1261,9 +1262,9 @@ class Application_Model_Show {
|
|||
}
|
||||
|
||||
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
|
||||
$rebroadcasts = $CC_DBC->GetAll($sql);
|
||||
$rebroadcasts = $con->query($sql)->fetchAll();
|
||||
|
||||
Logging::log('$start time of non repeating record '.$start);
|
||||
//Logging::log('$start time of non repeating record '.$start);
|
||||
|
||||
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
|
||||
}
|
||||
|
@ -1283,7 +1284,7 @@ class Application_Model_Show {
|
|||
*/
|
||||
private static function populateRepeatingShow($p_showRow, $p_populateUntilDateTime, $p_interval)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$show_id = $p_showRow["show_id"];
|
||||
$next_pop_date = $p_showRow["next_pop_date"];
|
||||
|
@ -1308,7 +1309,7 @@ class Application_Model_Show {
|
|||
$utcLastShowDateTime = $last_show ? Application_Common_DateHelper::ConvertToUtcDateTime($last_show, $timezone) : null;
|
||||
|
||||
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
|
||||
$rebroadcasts = $CC_DBC->GetAll($sql);
|
||||
$rebroadcasts = $con->query($sql)->fetchAll();
|
||||
|
||||
$show = new Application_Model_Show($show_id);
|
||||
|
||||
|
@ -1481,7 +1482,7 @@ class Application_Model_Show {
|
|||
*/
|
||||
public static function getShows($start_timestamp, $end_timestamp, $excludeInstance=NULL, $onlyRecord=FALSE)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
//UTC DateTime object
|
||||
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
|
||||
|
@ -1527,8 +1528,8 @@ class Application_Model_Show {
|
|||
|
||||
//Logging::log("getShows");
|
||||
//Logging::log($sql);
|
||||
|
||||
return $CC_DBC->GetAll($sql);
|
||||
$result = $con->query($sql)->fetchAll();
|
||||
return $result;
|
||||
}
|
||||
|
||||
private static function setNextPop($next_date, $show_id, $day)
|
||||
|
@ -1554,7 +1555,7 @@ class Application_Model_Show {
|
|||
*/
|
||||
public static function populateAllShowsInRange($p_startTimestamp, $p_endTimestamp)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$endTimeString = $p_endTimestamp->format("Y-m-d H:i:s");
|
||||
if (!is_null($p_startTimestamp)) {
|
||||
|
@ -1569,9 +1570,8 @@ class Application_Model_Show {
|
|||
WHERE last_show IS NULL
|
||||
OR first_show < '{$endTimeString}' AND last_show > '{$startTimeString}'";
|
||||
|
||||
Logging::log($sql);
|
||||
|
||||
$res = $CC_DBC->GetAll($sql);
|
||||
//Logging::log($sql);
|
||||
$res = $con->query($sql)->fetchAll();
|
||||
|
||||
foreach ($res as $row) {
|
||||
Application_Model_Show::populateShow($row, $p_endTimestamp);
|
||||
|
@ -1588,14 +1588,10 @@ class Application_Model_Show {
|
|||
*/
|
||||
public static function getFullCalendarEvents($p_start, $p_end, $p_editable=false)
|
||||
{
|
||||
|
||||
$events = array();
|
||||
|
||||
$interval = $p_start->diff($p_end);
|
||||
$days = $interval->format('%a');
|
||||
|
||||
$shows = Application_Model_Show::getShows($p_start, $p_end);
|
||||
|
||||
$today_timestamp = gmdate("Y-m-d H:i:s");
|
||||
|
||||
foreach ($shows as $show) {
|
||||
|
@ -1689,7 +1685,7 @@ class Application_Model_Show {
|
|||
$showDay->setDbFirstShow($dt)->setDbStartTime($dt)
|
||||
->save();
|
||||
|
||||
Logging::log("setting show's first show.");
|
||||
//Logging::log("setting show's first show.");
|
||||
}
|
||||
|
||||
/* Takes in a UTC DateTime object
|
||||
|
@ -1722,7 +1718,8 @@ class Application_Model_Show {
|
|||
*/
|
||||
public static function GetCurrentShow($timeNow=null)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
if($timeNow == null){
|
||||
$date = new Application_Common_DateHelper;
|
||||
$timeNow = $date->getUtcTimestamp();
|
||||
|
@ -1736,8 +1733,7 @@ class Application_Model_Show {
|
|||
." AND modified_instance != TRUE";
|
||||
|
||||
// Convert back to local timezone
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
|
||||
$rows = $con->query($sql)->fetchAll();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
@ -1746,7 +1742,8 @@ class Application_Model_Show {
|
|||
*/
|
||||
public static function getPrevCurrentNext($p_timeNow)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
//TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin
|
||||
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url, starts, ends"
|
||||
." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
|
||||
|
@ -1757,7 +1754,7 @@ class Application_Model_Show {
|
|||
." ORDER BY si.starts";
|
||||
|
||||
// Convert back to local timezone
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
$rows = $con->query($sql)->fetchAll();
|
||||
$numberOfRows = count($rows);
|
||||
|
||||
$results['previousShow'] = array();
|
||||
|
@ -1826,6 +1823,7 @@ class Application_Model_Show {
|
|||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a start time $timeStart and end time $timeEnd, returns the next $limit
|
||||
* number of shows within the time interval;
|
||||
|
@ -1840,7 +1838,8 @@ class Application_Model_Show {
|
|||
*/
|
||||
public static function GetNextShows($timeStart, $limit = "0", $timeEnd = "")
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
// defaults to retrieving shows from next 2 days if no end time has
|
||||
// been specified
|
||||
|
@ -1864,8 +1863,7 @@ class Application_Model_Show {
|
|||
$sql = $sql . " LIMIT $limit";
|
||||
}
|
||||
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
|
||||
$rows = $con->query($sql)->fetchAll();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
@ -1890,10 +1888,12 @@ class Application_Model_Show {
|
|||
}
|
||||
|
||||
public static function GetMaxLengths() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$sql = "SELECT column_name, character_maximum_length FROM information_schema.columns"
|
||||
." WHERE table_name = 'cc_show' AND character_maximum_length > 0";
|
||||
$result = $CC_DBC->GetAll($sql);
|
||||
$result = $con->query($sql)->fetchAll();
|
||||
|
||||
// store result into assoc array
|
||||
$assocArray = array();
|
||||
|
|
|
@ -146,8 +146,9 @@ class Application_Model_ShowInstance {
|
|||
$this->_showInstance->getDbModifiedInstance();
|
||||
}
|
||||
|
||||
public function correctScheduleStartTimes(){
|
||||
global $CC_DBC;
|
||||
public function correctScheduleStartTimes()
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$instance_id = $this->getShowInstanceId();
|
||||
$sql = "SELECT starts from cc_schedule"
|
||||
|
@ -155,9 +156,9 @@ class Application_Model_ShowInstance {
|
|||
." ORDER BY starts"
|
||||
." LIMIT 1";
|
||||
|
||||
$scheduleStarts = $CC_DBC->GetOne($sql);
|
||||
$scheduleStarts = $con->query($sql)->fetchColumn(0);
|
||||
|
||||
if (!is_null($scheduleStarts)){
|
||||
if ($scheduleStarts) {
|
||||
$scheduleStartsEpoch = strtotime($scheduleStarts);
|
||||
$showStartsEpoch = strtotime($this->getShowInstanceStart());
|
||||
|
||||
|
@ -169,7 +170,7 @@ class Application_Model_ShowInstance {
|
|||
." ends = ends + INTERVAL '$diff' second"
|
||||
." WHERE instance_id = $instance_id";
|
||||
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
}
|
||||
}
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
|
@ -300,7 +301,7 @@ class Application_Model_ShowInstance {
|
|||
*/
|
||||
public function resizeShow($deltaDay, $deltaMin)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$hours = $deltaMin/60;
|
||||
if($hours > 0)
|
||||
|
@ -319,7 +320,7 @@ class Application_Model_ShowInstance {
|
|||
}
|
||||
|
||||
$sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'";
|
||||
$new_ends = $CC_DBC->GetOne($sql);
|
||||
$new_ends = $con->query($sql)->fetchColumn(0);
|
||||
|
||||
//only need to check overlap if show increased in size.
|
||||
if (strtotime($new_ends) > strtotime($ends)) {
|
||||
|
@ -339,7 +340,7 @@ class Application_Model_ShowInstance {
|
|||
if($this->isRecorded()) {
|
||||
$sql = "UPDATE cc_show_instances SET ends = (ends + interval '{$deltaDay} days' + interval '{$hours}:{$mins}')
|
||||
WHERE rebroadcast = 1 AND instance_id = {$this->_instanceId}";
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
}
|
||||
|
||||
$this->setShowEnd($new_ends);
|
||||
|
@ -481,8 +482,6 @@ class Application_Model_ShowInstance {
|
|||
|
||||
public function delete()
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
// see if it was recording show
|
||||
$recording = $this->isRecorded();
|
||||
// get show id
|
||||
|
@ -631,16 +630,16 @@ class Application_Model_ShowInstance {
|
|||
|
||||
public function getShowListContent()
|
||||
{
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM (cc_schedule AS s LEFT JOIN cc_files AS f ON f.id = s.file_id)
|
||||
WHERE s.instance_id = '{$this->_instanceId}' AND s.playout_status >= 0
|
||||
ORDER BY starts";
|
||||
|
||||
Logging::log($sql);
|
||||
//Logging::log($sql);
|
||||
|
||||
$results = $CC_DBC->GetAll($sql);
|
||||
$results = $con->query($sql)->fetchAll();
|
||||
|
||||
foreach ($results as &$row) {
|
||||
|
||||
|
@ -656,15 +655,17 @@ class Application_Model_ShowInstance {
|
|||
return $results;
|
||||
}
|
||||
|
||||
public function getLastAudioItemEnd(){
|
||||
global $CC_DBC;
|
||||
public function getLastAudioItemEnd()
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$sql = "SELECT ends FROM cc_schedule "
|
||||
."WHERE instance_id = {$this->_instanceId} "
|
||||
."ORDER BY ends DESC "
|
||||
."LIMIT 1";
|
||||
|
||||
return $CC_DBC->GetOne($sql);
|
||||
$query = $con->query($sql)->fetchColumn(0);
|
||||
return ($query !== false) ? $query : NULL;
|
||||
}
|
||||
|
||||
public function getShowEndGapTime(){
|
||||
|
@ -682,7 +683,8 @@ class Application_Model_ShowInstance {
|
|||
}
|
||||
|
||||
public static function GetLastShowInstance($p_timeNow){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$sql = "SELECT si.id"
|
||||
." FROM $CC_CONFIG[showInstances] si"
|
||||
|
@ -691,16 +693,18 @@ class Application_Model_ShowInstance {
|
|||
." ORDER BY si.ends DESC"
|
||||
." LIMIT 1";
|
||||
|
||||
$id = $CC_DBC->GetOne($sql);
|
||||
if (is_null($id)){
|
||||
return null;
|
||||
} else {
|
||||
$id = $con->query($sql)->fetchColumn(0);
|
||||
if ($id) {
|
||||
return new Application_Model_ShowInstance($id);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetCurrentShowInstance($p_timeNow){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
public static function GetCurrentShowInstance($p_timeNow)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
/* Orderby si.starts descending, because in some cases
|
||||
* we can have multiple shows overlapping each other. In
|
||||
|
@ -716,16 +720,18 @@ class Application_Model_ShowInstance {
|
|||
." ORDER BY si.starts DESC"
|
||||
." LIMIT 1";
|
||||
|
||||
$id = $CC_DBC->GetOne($sql);
|
||||
if (is_null($id)){
|
||||
return null;
|
||||
} else {
|
||||
$id = $con->query($sql)->fetchColumn(0);
|
||||
if ($id) {
|
||||
return new Application_Model_ShowInstance($id);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetNextShowInstance($p_timeNow){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
public static function GetNextShowInstance($p_timeNow)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$sql = "SELECT si.id"
|
||||
." FROM $CC_CONFIG[showInstances] si"
|
||||
|
@ -734,24 +740,28 @@ class Application_Model_ShowInstance {
|
|||
." ORDER BY si.starts"
|
||||
." LIMIT 1";
|
||||
|
||||
$id = $CC_DBC->GetOne($sql);
|
||||
if (is_null($id)){
|
||||
return null;
|
||||
} else {
|
||||
$id = $con->query($sql)->fetchColumn(0);
|
||||
if ($id) {
|
||||
return new Application_Model_ShowInstance($id);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// returns number of show instances that ends later than $day
|
||||
public static function GetShowInstanceCount($day){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
public static function GetShowInstanceCount($day)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT count(*) as cnt FROM $CC_CONFIG[showInstances] WHERE ends < '$day'";
|
||||
return $CC_DBC->GetOne($sql);
|
||||
return $con->query($sql)->fetchColumn(0);
|
||||
}
|
||||
|
||||
// this returns end timestamp of all shows that are in the range and has live DJ set up
|
||||
public static function GetEndTimeOfNextShowWithLiveDJ($p_startTime, $p_endTime){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
public static function GetEndTimeOfNextShowWithLiveDJ($p_startTime, $p_endTime)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$sql = "SELECT ends
|
||||
FROM cc_show_instances as si
|
||||
|
@ -759,7 +769,7 @@ class Application_Model_ShowInstance {
|
|||
WHERE si.ends > '$p_startTime' and si.ends < '$p_endTime' and (sh.live_stream_using_airtime_auth or live_stream_using_custom_auth)
|
||||
ORDER BY si.ends";
|
||||
|
||||
return $CC_DBC->GetAll($sql);
|
||||
return $con->query($sql)->fetchAll();
|
||||
}
|
||||
|
||||
function isRepeating(){
|
||||
|
|
|
@ -238,20 +238,18 @@ class Application_Model_StoredFile {
|
|||
* 'empty'|'incomplete'|'ready'|'edited'
|
||||
* @param int $p_editedby
|
||||
* user id | 'NULL' for clear editedBy field
|
||||
* @return TRUE|PEAR_Error
|
||||
* @return TRUE
|
||||
*/
|
||||
public function setState($p_state, $p_editedby=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$escapedState = pg_escape_string($p_state);
|
||||
$eb = (!is_null($p_editedby) ? ", editedBy=$p_editedby" : '');
|
||||
$sql = "UPDATE ".$CC_CONFIG['filesTable']
|
||||
." SET state='$escapedState'$eb, mtime=now()"
|
||||
." WHERE gunid='{$this->gunid}'";
|
||||
$res = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$res = $con->exec($sql);
|
||||
$this->state = $p_state;
|
||||
$this->editedby = $p_editedby;
|
||||
return TRUE;
|
||||
|
@ -262,11 +260,12 @@ class Application_Model_StoredFile {
|
|||
* @return array
|
||||
*/
|
||||
public function getPlaylists() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT playlist_id "
|
||||
." FROM ".$CC_CONFIG['playistTable']
|
||||
." WHERE file_id='{$this->id}'";
|
||||
$ids = $CC_DBC->getAll($sql);
|
||||
$ids = $con->query($sql)->fetchAll();
|
||||
$playlists = array();
|
||||
if (is_array($ids) && count($ids) > 0) {
|
||||
foreach ($ids as $id) {
|
||||
|
@ -820,11 +819,9 @@ Logging::log("getting media! - 2");
|
|||
$md5 = md5_file($audio_file);
|
||||
$duplicate = Application_Model_StoredFile::RecallByMd5($md5, true);
|
||||
|
||||
|
||||
$result = null;
|
||||
if ($duplicate) {
|
||||
if (PEAR::isError($duplicate)) {
|
||||
$result = array("code" => 105, "message" => $duplicate->getMessage());
|
||||
}
|
||||
if (file_exists($duplicate->getFilePath())) {
|
||||
$duplicateName = $duplicate->getMetadataValue('MDATA_KEY_TITLE');
|
||||
$result = array( "code" => 106, "message" => "An identical audioclip named '$duplicateName' already exists on the server.");
|
||||
|
@ -865,9 +862,11 @@ Logging::log("getting media! - 2");
|
|||
|
||||
public static function getFileCount()
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG["filesTable"]." WHERE file_exists";
|
||||
return $CC_DBC->GetOne($sql);
|
||||
return $con->query($sql)->fetchColumn(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -876,8 +875,9 @@ Logging::log("getting media! - 2");
|
|||
* @param $dir_id - if this is not provided, it returns all files with full path constructed.
|
||||
* @param $propelObj - if this is true, it returns array of proepl obj
|
||||
*/
|
||||
public static function listAllFiles($dir_id=null, $propelObj=false){
|
||||
global $CC_DBC;
|
||||
public static function listAllFiles($dir_id=null, $propelObj=false)
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
|
||||
if ($propelObj) {
|
||||
$sql = "SELECT m.directory || f.filepath as fp"
|
||||
|
@ -889,7 +889,7 @@ Logging::log("getting media! - 2");
|
|||
." FROM CC_FILES"
|
||||
." WHERE directory = $dir_id and file_exists = 'TRUE'";
|
||||
}
|
||||
$rows = $CC_DBC->getAll($sql);
|
||||
$rows = $con->query($sql)->fetchAll();
|
||||
|
||||
$results = array();
|
||||
foreach ($rows as $row) {
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
<?php
|
||||
class Application_Model_StreamSetting {
|
||||
|
||||
public static function SetValue($key, $value, $type){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
public static function SetValue($key, $value, $type)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$key = pg_escape_string($key);
|
||||
$value = pg_escape_string($value);
|
||||
|
@ -11,7 +13,7 @@ class Application_Model_StreamSetting {
|
|||
$sql = "SELECT COUNT(*) FROM cc_stream_setting"
|
||||
." WHERE keyname = '$key'";
|
||||
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
$result = $con->query($sql)->fetchColumn(0);
|
||||
|
||||
if ($result == 1) {
|
||||
$sql = "UPDATE cc_stream_setting"
|
||||
|
@ -22,16 +24,18 @@ class Application_Model_StreamSetting {
|
|||
." VALUES ('$key', '$value', '$type')";
|
||||
}
|
||||
|
||||
return $CC_DBC->query($sql);
|
||||
return $con->exec($sql);
|
||||
}
|
||||
|
||||
public static function GetValue($key){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
public static function GetValue($key)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
//Check if key already exists
|
||||
$sql = "SELECT COUNT(*) FROM cc_stream_setting"
|
||||
." WHERE keyname = '$key'";
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
$result = $con->query($sql)->fetchColumn(0);
|
||||
|
||||
if ($result == 0)
|
||||
return "";
|
||||
|
@ -39,21 +43,22 @@ class Application_Model_StreamSetting {
|
|||
$sql = "SELECT value FROM cc_stream_setting"
|
||||
." WHERE keyname = '$key'";
|
||||
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
return $result;
|
||||
$result = $con->query($sql)->fetchColumn(0);
|
||||
return ($result !== false) ? $result : NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns the id's of all streams that are enabled in an array. An
|
||||
* example of the array returned in JSON notation is ["s1", "s2", "s3"] */
|
||||
public static function getEnabledStreamIds(){
|
||||
global $CC_DBC;
|
||||
public static function getEnabledStreamIds()
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT * "
|
||||
."FROM cc_stream_setting "
|
||||
."WHERE keyname LIKE '%_enable' "
|
||||
."AND value='true'";
|
||||
|
||||
$rows = $CC_DBC->getAll($sql);
|
||||
$rows = $con->query($sql)->fetchAll();
|
||||
$ids = array();
|
||||
|
||||
foreach ($rows as $row) {
|
||||
|
@ -61,18 +66,18 @@ class Application_Model_StreamSetting {
|
|||
}
|
||||
|
||||
//Logging::log(print_r($ids, true));
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/* Retruns only global data as array*/
|
||||
public static function getGlobalData(){
|
||||
global $CC_DBC;
|
||||
/* Returns only global data as array*/
|
||||
public static function getGlobalData()
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT * "
|
||||
."FROM cc_stream_setting "
|
||||
."WHERE keyname IN ('output_sound_device', 'icecast_vorbis_metadata')";
|
||||
|
||||
$rows = $CC_DBC->getAll($sql);
|
||||
$rows = $con->query($sql)->fetchAll();
|
||||
$data = array();
|
||||
|
||||
foreach ($rows as $row) {
|
||||
|
@ -81,15 +86,17 @@ class Application_Model_StreamSetting {
|
|||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/* Returns all information related to a specific stream. An example
|
||||
* of a stream id is 's1' or 's2'. */
|
||||
public static function getStreamData($p_streamId){
|
||||
global $CC_DBC;
|
||||
public static function getStreamData($p_streamId)
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT * "
|
||||
."FROM cc_stream_setting "
|
||||
."WHERE keyname LIKE '${p_streamId}_%'";
|
||||
|
||||
$rows = $CC_DBC->getAll($sql);
|
||||
$rows = $con->query($sql)->fetchAll();
|
||||
$data = array();
|
||||
|
||||
foreach ($rows as $row) {
|
||||
|
@ -99,13 +106,14 @@ class Application_Model_StreamSetting {
|
|||
return $data;
|
||||
}
|
||||
|
||||
public static function getStreamSetting(){
|
||||
global $CC_DBC;
|
||||
public static function getStreamSetting()
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT *"
|
||||
." FROM cc_stream_setting"
|
||||
." WHERE keyname not like '%_error'";
|
||||
|
||||
$rows = $CC_DBC->getAll($sql);
|
||||
$rows = $con->query($sql)->fetchAll();
|
||||
|
||||
$exists = array();
|
||||
|
||||
|
@ -143,17 +151,18 @@ class Application_Model_StreamSetting {
|
|||
* @param $data - array that contains all the data. $data is [][] which
|
||||
* contains multiple stream information
|
||||
*/
|
||||
public static function setStreamSetting($data){
|
||||
global $CC_DBC;
|
||||
public static function setStreamSetting($data)
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
|
||||
foreach ($data as $key=>$d) {
|
||||
if ($key == "output_sound_device" || $key == "icecast_vorbis_metadata") {
|
||||
$v = $d == 1?"true":"false";
|
||||
$sql = "UPDATE cc_stream_setting SET value='$v' WHERE keyname='$key'";
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
} else if ($key == "output_sound_device_type") {
|
||||
$sql = "UPDATE cc_stream_setting SET value='$d' WHERE keyname='$key'";
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
} else if (is_array($d)) {
|
||||
$temp = explode('_', $key);
|
||||
$prefix = $temp[0];
|
||||
|
@ -164,7 +173,7 @@ class Application_Model_StreamSetting {
|
|||
}
|
||||
$v = trim($v);
|
||||
$sql = "UPDATE cc_stream_setting SET value='$v' WHERE keyname='$keyname'";
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
}
|
||||
} else {
|
||||
Logging::log("Warning unexpected value: ".$key);
|
||||
|
@ -177,12 +186,13 @@ class Application_Model_StreamSetting {
|
|||
*
|
||||
* $data - data array. $data is [].
|
||||
*/
|
||||
public static function setIndivisualStreamSetting($data){
|
||||
global $CC_DBC;
|
||||
public static function setIndivisualStreamSetting($data)
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
|
||||
foreach ($data as $keyname => $v) {
|
||||
$sql = "UPDATE cc_stream_setting SET value='$v' WHERE keyname='$keyname'";
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,15 +200,16 @@ class Application_Model_StreamSetting {
|
|||
* Stores liquidsoap status if $boot_time > save time.
|
||||
* save time is the time that user clicked save on stream setting page
|
||||
*/
|
||||
public static function setLiquidsoapError($stream_id, $msg, $boot_time=null){
|
||||
global $CC_DBC;
|
||||
public static function setLiquidsoapError($stream_id, $msg, $boot_time=null)
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$update_time = Application_Model_Preference::GetStreamUpdateTimestemp();
|
||||
if ($boot_time == null || $boot_time > $update_time) {
|
||||
$keyname = "s".$stream_id."_liquidsoap_error";
|
||||
$sql = "SELECT COUNT(*) FROM cc_stream_setting"
|
||||
." WHERE keyname = '$keyname'";
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
$result = $con->query($sql)->fetchColumn(0);
|
||||
if ($result == 1) {
|
||||
$sql = "UPDATE cc_stream_setting"
|
||||
." SET value = '$msg'"
|
||||
|
@ -207,28 +218,30 @@ class Application_Model_StreamSetting {
|
|||
$sql = "INSERT INTO cc_stream_setting (keyname, value, type)"
|
||||
." VALUES ('$keyname', '$msg', 'string')";
|
||||
}
|
||||
$res = $CC_DBC->query($sql);
|
||||
$res = $con->exec($sql);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getLiquidsoapError($stream_id){
|
||||
global $CC_DBC;
|
||||
public static function getLiquidsoapError($stream_id)
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$keyname = "s".$stream_id."_liquidsoap_error";
|
||||
$sql = "SELECT value FROM cc_stream_setting"
|
||||
." WHERE keyname = '$keyname'";
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
$result = $con->query($sql)->fetchColumn(0);
|
||||
|
||||
return $result;
|
||||
return ($result !== false) ? $result : NULL;
|
||||
}
|
||||
|
||||
public static function getStreamEnabled($stream_id){
|
||||
global $CC_DBC;
|
||||
public static function getStreamEnabled($stream_id)
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$keyname = "s" . $stream_id . "_enable";
|
||||
$sql = "SELECT value FROM cc_stream_setting"
|
||||
." WHERE keyname = '$keyname'";
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
$result = $con->query($sql)->fetchColumn(0);
|
||||
if ($result == 'false') {
|
||||
$result = false;
|
||||
} else {
|
||||
|
@ -241,8 +254,9 @@ class Application_Model_StreamSetting {
|
|||
* Only returns info that is needed for data collection
|
||||
* returns array('s1'=>array(keyname=>value))
|
||||
*/
|
||||
public static function getStreamInfoForDataCollection(){
|
||||
global $CC_DBC;
|
||||
public static function getStreamInfoForDataCollection()
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$out = array();
|
||||
$enabled_stream = self::getEnabledStreamIds();
|
||||
|
@ -253,7 +267,7 @@ class Application_Model_StreamSetting {
|
|||
$sql = "SELECT keyname, value FROM cc_stream_setting"
|
||||
." WHERE keyname IN ($keys)";
|
||||
|
||||
$rows = $CC_DBC->getAll($sql);
|
||||
$rows = $con->query($sql)->fetchAll();
|
||||
$info = array();
|
||||
foreach ($rows as $r) {
|
||||
$temp = explode("_", $r['keyname']);
|
||||
|
|
|
@ -28,16 +28,15 @@ class Application_Model_Subjects {
|
|||
*/
|
||||
public static function Authenticate($login, $pass='')
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$cpass = md5($pass);
|
||||
$sql = "SELECT id FROM ".$CC_CONFIG['subjTable']
|
||||
." WHERE login='$login' AND pass='$cpass' AND type='U'";
|
||||
$id = $CC_DBC->getOne($sql);
|
||||
if (PEAR::isError($id)) {
|
||||
return $id;
|
||||
." WHERE login='$login' AND pass='$cpass' AND type='U'"
|
||||
." LIMIT 1";
|
||||
$query = $con->query($sql)->fetchColumn(0);
|
||||
return $query;
|
||||
}
|
||||
return (is_null($id) ? FALSE : $id);
|
||||
} // fn authenticate
|
||||
|
||||
|
||||
/**
|
||||
|
@ -54,7 +53,8 @@ class Application_Model_Subjects {
|
|||
*/
|
||||
public static function Passwd($login, $oldpass=null, $pass='', $passenc=FALSE)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
if (!$passenc) {
|
||||
$cpass = md5($pass);
|
||||
} else {
|
||||
|
@ -68,12 +68,9 @@ class Application_Model_Subjects {
|
|||
}
|
||||
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET pass='$cpass'"
|
||||
." WHERE login='$login' $oldpCond AND type='U'";
|
||||
$r = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$con->exec($sql);
|
||||
return TRUE;
|
||||
} // fn passwd
|
||||
}
|
||||
|
||||
|
||||
/* --------------------------------------------------------------- groups */
|
||||
|
@ -84,20 +81,21 @@ class Application_Model_Subjects {
|
|||
* Get subject id from login
|
||||
*
|
||||
* @param string $login
|
||||
* @return int|PEAR_Error
|
||||
* @return int|false
|
||||
*/
|
||||
public static function GetSubjId($login)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT id FROM ".$CC_CONFIG['subjTable']
|
||||
." WHERE login='$login'";
|
||||
return $CC_DBC->getOne($sql);
|
||||
} // fn getSubjId
|
||||
$query = $con->query($sql)->fetchColumn(0);
|
||||
return ($query !== false) ? $query : NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return true if uid is [id]direct member of gid
|
||||
* Return true if uid is direct member of gid
|
||||
*
|
||||
* @param int $uid
|
||||
* local user id
|
||||
|
@ -107,47 +105,42 @@ class Application_Model_Subjects {
|
|||
*/
|
||||
public static function IsMemberOf($uid, $gid)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT count(*) as cnt"
|
||||
." FROM ".$CC_CONFIG['smembTable']
|
||||
." WHERE uid='$uid' AND gid='$gid'";
|
||||
$res = $CC_DBC->getOne($sql);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$res = $con->query($sql)->fetchColumn(0);
|
||||
return (intval($res) > 0);
|
||||
} // fn isMemberOf
|
||||
}
|
||||
|
||||
public static function increaseLoginAttempts($login){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
public static function increaseLoginAttempts($login)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET login_attempts = login_attempts+1"
|
||||
." WHERE login='$login'";
|
||||
$res = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$res = $con->exec($sql);
|
||||
return (intval($res) > 0);
|
||||
}
|
||||
|
||||
public static function resetLoginAttempts($login){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
public static function resetLoginAttempts($login)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET login_attempts = '0'"
|
||||
." WHERE login='$login'";
|
||||
$res = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
return (intval($res) > 0);
|
||||
$res = $con->exec($sql);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public static function getLoginAttempts($login){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
public static function getLoginAttempts($login)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT login_attempts FROM ".$CC_CONFIG['subjTable']." WHERE login='$login'";
|
||||
$res = $CC_DBC->getOne($sql);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
return $res;
|
||||
$res = $con->query($sql)->fetchColumn(0);
|
||||
return ($res !== false) ? $res : 0;
|
||||
}
|
||||
|
||||
} // class Subjects
|
||||
|
|
|
@ -185,10 +185,9 @@ class Application_Model_User {
|
|||
return $user;
|
||||
}
|
||||
|
||||
public static function getUsers($type, $search=NULL) {
|
||||
global $CC_DBC;
|
||||
|
||||
$sql;
|
||||
public static function getUsers($type, $search=NULL)
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$sql_gen = "SELECT login AS value, login AS label, id as index FROM cc_subjs ";
|
||||
$sql = $sql_gen;
|
||||
|
@ -213,14 +212,12 @@ class Application_Model_User {
|
|||
|
||||
$sql = $sql ." ORDER BY login";
|
||||
|
||||
return $CC_DBC->GetAll($sql);
|
||||
return $con->query($sql)->fetchAll();;
|
||||
}
|
||||
|
||||
public static function getUserCount($type=NULL){
|
||||
global $CC_DBC;
|
||||
|
||||
$sql;
|
||||
|
||||
$con = Propel::getConnection();
|
||||
$sql = '';
|
||||
$sql_gen = "SELECT count(*) AS cnt FROM cc_subjs ";
|
||||
|
||||
if (!isset($type)) {
|
||||
|
@ -240,7 +237,8 @@ class Application_Model_User {
|
|||
$sql = $sql_gen ." WHERE (". $sql_type.") ";
|
||||
}
|
||||
|
||||
return $CC_DBC->GetOne($sql);
|
||||
$query = $con->query($sql)->fetchColumn(0);
|
||||
return ($query !== false) ? $query : NULL;
|
||||
}
|
||||
|
||||
public static function getHosts($search=NULL) {
|
||||
|
@ -277,13 +275,13 @@ class Application_Model_User {
|
|||
}
|
||||
|
||||
public static function getUserData($id){
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$sql = "SELECT login, first_name, last_name, type, id, email, skype_contact, jabber_contact"
|
||||
." FROM cc_subjs"
|
||||
." WHERE id = $id";
|
||||
|
||||
return $CC_DBC->GetRow($sql);
|
||||
return $con->query($sql)->fetch();
|
||||
}
|
||||
|
||||
public static function GetUserID($login){
|
||||
|
|
|
@ -3,7 +3,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . $path);
|
|||
$WHITE_SCREEN_OF_DEATH = false;
|
||||
|
||||
require_once(dirname(__FILE__).'/../../configs/conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('PHPUnit.php');
|
||||
require_once 'StoredFileTests.php';
|
||||
require_once 'SchedulerTests.php';
|
||||
|
|
|
@ -4,11 +4,12 @@ require_once(dirname(__FILE__)."/../Schedule.php");
|
|||
|
||||
class SchedulerExportTests extends PHPUnit_TestCase {
|
||||
function setup() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
// Clear the files table
|
||||
$sql = "DELETE FROM ".$CC_CONFIG["filesTable"];
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
|
||||
|
@ -20,7 +21,7 @@ class SchedulerExportTests extends PHPUnit_TestCase {
|
|||
|
||||
// Clear the schedule table
|
||||
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"];
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
|
||||
// Create a playlist
|
||||
$playlist = new Application_Model_Playlist();
|
||||
|
|
|
@ -8,11 +8,10 @@ class SchedulerTests extends PHPUnit_TestCase {
|
|||
private $storedFile2;
|
||||
|
||||
function setup() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
|
||||
// Clear the files table
|
||||
//$sql = "DELETE FROM ".$CC_CONFIG["filesTable"];
|
||||
//$CC_DBC->query($sql);
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
|
||||
|
@ -24,7 +23,6 @@ class SchedulerTests extends PHPUnit_TestCase {
|
|||
|
||||
// Clear the schedule table
|
||||
//$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"];
|
||||
//$CC_DBC->query($sql);
|
||||
}
|
||||
|
||||
function testDateToId() {
|
||||
|
@ -46,9 +44,6 @@ class SchedulerTests extends PHPUnit_TestCase {
|
|||
function testAddAndRemoveAudioFile() {
|
||||
$i = new Application_Model_ScheduleGroup();
|
||||
$this->groupIdCreated = $i->add('2010-10-10 01:30:23', $this->storedFile->getId());
|
||||
if (PEAR::isError($this->groupIdCreated)) {
|
||||
$this->fail("Failed to create scheduled item: ". $this->groupIdCreated->getMessage());
|
||||
}
|
||||
|
||||
$i = new Application_Model_ScheduleGroup($this->groupIdCreated);
|
||||
$result = $i->remove();
|
||||
|
@ -67,9 +62,6 @@ class SchedulerTests extends PHPUnit_TestCase {
|
|||
|
||||
$i = new Application_Model_ScheduleGroup();
|
||||
$this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId());
|
||||
if (PEAR::isError($this->groupIdCreated)) {
|
||||
$this->fail("Failed to create scheduled item: ". $this->groupIdCreated->getMessage());
|
||||
}
|
||||
$group = new Application_Model_ScheduleGroup($this->groupIdCreated);
|
||||
if ($group->count() != 3) {
|
||||
$this->fail("Wrong number of items added.");
|
||||
|
@ -90,10 +82,6 @@ class SchedulerTests extends PHPUnit_TestCase {
|
|||
function testIsScheduleEmptyInRange() {
|
||||
$i = new Application_Model_ScheduleGroup();
|
||||
$this->groupIdCreated = $i->add('2011-10-10 01:30:23', $this->storedFile->getId());
|
||||
if (PEAR::isError($this->groupIdCreated)) {
|
||||
$this->fail($this->groupIdCreated->getMessage());
|
||||
return;
|
||||
}
|
||||
if (Application_Model_Schedule::isScheduleEmptyInRange('2011-10-10 01:30:23', '00:00:12.555')) {
|
||||
$this->fail("Reporting empty schedule when it isnt.");
|
||||
return;
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
<?php
|
||||
require_once(dirname(__FILE__).'/../StoredFile.php');
|
||||
|
||||
$dsn = $CC_CONFIG['dsn'];
|
||||
$CC_DBC = DB::connect($dsn, FALSE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
class StoredFileTest extends PHPUnit_TestCase {
|
||||
|
||||
function __construct($name) {
|
||||
|
@ -21,10 +13,6 @@ class StoredFileTest extends PHPUnit_TestCase {
|
|||
function testGetAudioMetadata() {
|
||||
$filePath = dirname(__FILE__)."/ex1.mp3";
|
||||
$metadata = Metadata::LoadFromFile($filePath);
|
||||
if (PEAR::isError($metadata)) {
|
||||
$this->fail($metadata->getMessage());
|
||||
return;
|
||||
}
|
||||
if (($metadata["dc:description"] != "Tmu sem tam videla ...")
|
||||
|| ($metadata["audio"]["dataformat"] != "mp3")
|
||||
|| ($metadata["dc:type"] != "Speech")) {
|
||||
|
@ -52,10 +40,6 @@ class StoredFileTest extends PHPUnit_TestCase {
|
|||
$values = array("filepath" => $filePath,
|
||||
"dc:description" => "Unit test ".time());
|
||||
$storedFile = Application_Model_StoredFile::Insert($values, false);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
$this->fail("Failed to create StoredFile: ".$storedFile->getMessage());
|
||||
return;
|
||||
}
|
||||
//var_dump($storedFile);
|
||||
$id = $storedFile->getId();
|
||||
if (!is_numeric($id)) {
|
||||
|
|
|
@ -15,12 +15,13 @@ require_once __DIR__.'/../../../library/propel/runtime/lib/Propel.php';
|
|||
Propel::init(__DIR__.'/../../configs/airtime-conf.php');
|
||||
|
||||
AirtimeInstall::DbConnect(true);
|
||||
$con = Propel::getConnection();
|
||||
$sql = "DELETE FROM cc_show";
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
$sql = "DELETE FROM cc_show_days";
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
$sql = "DELETE FROM cc_show_instances";
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
|
||||
/*
|
||||
// Create a playlist
|
||||
|
|
|
@ -132,10 +132,18 @@ function dayClick(date, allDay, jsEvent, view){
|
|||
// duration in milisec
|
||||
var duration = (duration_h * 60 * 60 * 1000) + (duration_m * 60 * 1000);
|
||||
|
||||
var startTime_string, startTime
|
||||
// get start time value on the form
|
||||
var startTime_string = $("#add_show_start_time").val();
|
||||
if(view.name === "month") {
|
||||
startTime_string = $("#add_show_start_time").val();
|
||||
var startTime_info = startTime_string.split(':');
|
||||
var startTime = (parseInt(startTime_info[0],10) * 60 * 60 * 1000) + (parseInt(startTime_info[1], 10) * 60 * 1000);
|
||||
startTime = (parseInt(startTime_info[0],10) * 60 * 60 * 1000) + (parseInt(startTime_info[1], 10) * 60 * 1000);
|
||||
}else{
|
||||
// if in day or week view, selected has all the time info as well
|
||||
// so we don't ahve to calculate it explicitly
|
||||
startTime_string = selected.getHours()+":"+selected.getMinutes()
|
||||
startTime = 0
|
||||
}
|
||||
|
||||
// calculate endDateTime
|
||||
var endDateTime = new Date(selected.getTime() + startTime + duration);
|
||||
|
@ -146,6 +154,11 @@ function dayClick(date, allDay, jsEvent, view){
|
|||
$("#add_show_start_date").val(chosenDate);
|
||||
$("#add_show_end_date_no_repeat").val(endDateFormat);
|
||||
$("#add_show_end_date").val(endDateFormat);
|
||||
if(view.name !== "month") {
|
||||
var endTimeString = endDateTime.getHours()+":"+endDateTime.getMinutes();
|
||||
$("#add_show_start_time").val(startTime_string)
|
||||
$("#add_show_end_time").val(endTimeString)
|
||||
}
|
||||
$("#schedule-show-when").show();
|
||||
|
||||
openAddShowForm();
|
||||
|
@ -199,8 +212,10 @@ function viewDisplay( view ) {
|
|||
}
|
||||
|
||||
if(($("#add-show-form").length == 1) && ($("#add-show-form").css('display')=='none') && ($('.fc-header-left > span').length == 5)) {
|
||||
if($.trim($("#add-show-form").html()) != ""){
|
||||
makeAddShowButton();
|
||||
}
|
||||
}
|
||||
|
||||
//save view name to db
|
||||
var url = '/Schedule/set-time-scale/format/json';
|
||||
|
|
|
@ -39,7 +39,7 @@ php-pear php5-gd postgresql odbc-postgresql python2.6 libsoundtouch-ocaml \
|
|||
libtaglib-ocaml libao-ocaml libmad-ocaml ecasound \
|
||||
libesd0 libportaudio2 libsamplerate0 rabbitmq-server patch \
|
||||
php5-curl mpg123 monit python-virtualenv multitail libcamomile-ocaml-data \
|
||||
libpulse0 vorbis-tools lsb-release php-db
|
||||
libpulse0 vorbis-tools lsb-release
|
||||
|
||||
#install packages with --force-yes option (this is useful in the case
|
||||
#of Debian, where these packages are unauthorized)
|
||||
|
|
|
@ -42,7 +42,7 @@ php-pear php5-gd postgresql odbc-postgresql python2.6 libsoundtouch-ocaml \
|
|||
libtaglib-ocaml libao-ocaml libmad-ocaml ecasound \
|
||||
libesd0 libportaudio2 libsamplerate0 rabbitmq-server patch \
|
||||
php5-curl mpg123 monit python-virtualenv multitail libcamomile-ocaml-data \
|
||||
libpulse0 vorbis-tools lsb-release php-db
|
||||
libpulse0 vorbis-tools lsb-release
|
||||
|
||||
#install packages with --force-yes option (this is useful in the case
|
||||
#of Debian, where these packages are unauthorized)
|
||||
|
|
|
@ -5,7 +5,6 @@ if (file_exists('/usr/share/php/libzend-framework-php')){
|
|||
set_include_path('/usr/share/php/libzend-framework-php' . PATH_SEPARATOR . get_include_path());
|
||||
}
|
||||
require_once('Zend/Loader/Autoloader.php');
|
||||
require_once('DB.php');
|
||||
|
||||
class AirtimeInstall
|
||||
{
|
||||
|
@ -39,63 +38,57 @@ class AirtimeInstall
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the version of Airtime currently installed.
|
||||
* If not installed, return null.
|
||||
*
|
||||
* @return NULL|string
|
||||
*/
|
||||
public static function GetVersionInstalled()
|
||||
{
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
global $CC_CONFIG;
|
||||
try {
|
||||
$con = Propel::getConnection();
|
||||
} catch (PropelException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (file_exists('/etc/airtime/airtime.conf')) {
|
||||
$values = parse_ini_file('/etc/airtime/airtime.conf', true);
|
||||
}
|
||||
else {
|
||||
//echo "New Airtime Install.".PHP_EOL;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Database config
|
||||
$CC_CONFIG['dsn']['username'] = $values['database']['dbuser'];
|
||||
$CC_CONFIG['dsn']['password'] = $values['database']['dbpass'];
|
||||
$CC_CONFIG['dsn']['hostspec'] = $values['database']['host'];
|
||||
$CC_CONFIG['dsn']['phptype'] = 'pgsql';
|
||||
$CC_CONFIG['dsn']['database'] = $values['database']['dbname'];
|
||||
$sql = "SELECT valstr FROM cc_pref WHERE keystr = 'system_version' LIMIT 1";
|
||||
$version = $con->query($sql)->fetchColumn(0);
|
||||
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], FALSE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
//echo "New Airtime Install.".PHP_EOL;
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$sql = "SELECT valstr FROM cc_pref WHERE keystr = 'system_version'";
|
||||
$version = $CC_DBC->GetOne($sql);
|
||||
|
||||
if (PEAR::isError($version)) {
|
||||
if (!$version) {
|
||||
// no pref table something is wrong.
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($version == '') {
|
||||
try {
|
||||
// If this table exists, then it's 1.7.0
|
||||
$sql = "SELECT * FROM cc_show_rebroadcast LIMIT 1";
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if (!PEAR::isError($result)) {
|
||||
$result = $con->query($sql)->fetchColumn(0);
|
||||
$version = "1.7.0";
|
||||
//echo "Airtime Version: ".$version." ".PHP_EOL;
|
||||
}
|
||||
else {
|
||||
$version = false;
|
||||
} catch (Exception $e) {
|
||||
$version = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $version;
|
||||
}
|
||||
}
|
||||
|
||||
public static function DbTableExists($p_name)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT * FROM ".$p_name;
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
$con = Propel::getConnection();
|
||||
try {
|
||||
$sql = "SELECT * FROM ".$p_name." LIMIT 1";
|
||||
$con->query($sql);
|
||||
} catch (PDOException $e){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -103,35 +96,46 @@ class AirtimeInstall
|
|||
|
||||
public static function InstallQuery($sql, $verbose = true)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
echo "Error! ".$result->getMessage()."\n";
|
||||
echo " SQL statement was:\n";
|
||||
echo " ".$sql."\n\n";
|
||||
} else {
|
||||
$con = Propel::getConnection();
|
||||
try {
|
||||
$con->exec($sql);
|
||||
if ($verbose) {
|
||||
echo "done.\n";
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo "Error!\n".$e->getMessage()."\n";
|
||||
echo " SQL statement was:\n";
|
||||
echo " ".$sql."\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
public static function DropSequence($p_sequenceName)
|
||||
{
|
||||
AirtimeInstall::InstallQuery("DROP SEQUENCE IF EXISTS $p_sequenceName");
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to connect to the database. Return true on success, false on failure.
|
||||
* @param boolean $p_exitOnError
|
||||
* Exit the program on failure.
|
||||
* @return boolean
|
||||
*/
|
||||
public static function DbConnect($p_exitOnError = true)
|
||||
{
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
$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;
|
||||
global $CC_CONFIG;
|
||||
try {
|
||||
$con = Propel::getConnection();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage().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 {
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -139,7 +143,7 @@ class AirtimeInstall
|
|||
* install script. */
|
||||
public static function InstallStorageDirectory()
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
echo "* Storage directory setup".PHP_EOL;
|
||||
|
||||
$ini = parse_ini_file(__DIR__."/airtime-install.ini");
|
||||
|
@ -231,10 +235,11 @@ class AirtimeInstall
|
|||
|
||||
public static function InstallPostgresScriptingLanguage()
|
||||
{
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
// Install postgres scripting language
|
||||
$langIsInstalled = $CC_DBC->GetOne('SELECT COUNT(*) FROM pg_language WHERE lanname = \'plpgsql\'');
|
||||
$sql = 'SELECT COUNT(*) FROM pg_language WHERE lanname = \'plpgsql\'';
|
||||
$langIsInstalled = $con->query($sql)->fetchColumn(0);
|
||||
if ($langIsInstalled == '0') {
|
||||
echo " * Installing Postgres scripting language".PHP_EOL;
|
||||
$sql = "CREATE LANGUAGE 'plpgsql'";
|
||||
|
@ -284,13 +289,13 @@ class AirtimeInstall
|
|||
|
||||
public static function SetAirtimeVersion($p_version)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "DELETE FROM cc_pref WHERE keystr = 'system_version'";
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '$p_version')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
$result = $con->exec($sql);
|
||||
if ($result < 1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -298,13 +303,12 @@ class AirtimeInstall
|
|||
|
||||
public static function SetUniqueId()
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
$con = Propel::getConnection();
|
||||
$uniqueId = md5(uniqid("", true));
|
||||
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('uniqueId', '$uniqueId')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
$result = $con->exec($sql);
|
||||
if ($result < 1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -312,13 +316,11 @@ class AirtimeInstall
|
|||
|
||||
public static function SetDefaultTimezone()
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
$con = Propel::getConnection();
|
||||
$defaultTimezone = exec("cat /etc/timezone");
|
||||
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', '$defaultTimezone')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
$result = $con->exec($sql);
|
||||
if ($result < 1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -326,11 +328,10 @@ class AirtimeInstall
|
|||
|
||||
public static function SetImportTimestamp()
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
$con = Propel::getConnection();
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('import_timestamp', '0')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
$result = $con->exec($sql);
|
||||
if ($result < 1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -339,13 +340,9 @@ class AirtimeInstall
|
|||
|
||||
public static function GetAirtimeVersion()
|
||||
{
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT valstr FROM cc_pref WHERE keystr = 'system_version'";
|
||||
$version = $CC_DBC->GetOne($sql);
|
||||
|
||||
if (PEAR::isError($version)) {
|
||||
return false;
|
||||
}
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT valstr FROM cc_pref WHERE keystr = 'system_version' LIMIT 1";
|
||||
$version = $con->query($sql)->fetchColumn(0);
|
||||
return $version;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
* cannot be created. So this script is run after all DEB packages have been installed.
|
||||
*/
|
||||
|
||||
set_include_path(__DIR__.'/../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
require_once(dirname(__FILE__).'/AirtimeIni.php');
|
||||
require_once(dirname(__FILE__).'/AirtimeInstall.php');
|
||||
require_once(__DIR__.'/AirtimeIni.php');
|
||||
require_once(__DIR__.'/AirtimeInstall.php');
|
||||
require_once(__DIR__.'/airtime-constants.php');
|
||||
|
||||
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php');
|
||||
require_once 'propel/runtime/lib/Propel.php';
|
||||
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php");
|
||||
|
||||
echo PHP_EOL."* Database Installation".PHP_EOL;
|
||||
|
||||
|
@ -65,12 +65,13 @@ if (AirtimeInstall::$databaseTablesCreated) {
|
|||
|
||||
$stor_dir = realpath($ini["storage_dir"])."/";
|
||||
echo " * Inserting stor directory location $stor_dir into music_dirs table".PHP_EOL;
|
||||
|
||||
$con = Propel::getConnection();
|
||||
$sql = "INSERT INTO cc_music_dirs (directory, type) VALUES ('$stor_dir', 'stor')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
try {
|
||||
$con->exec($sql);
|
||||
} catch (Exception $e) {
|
||||
echo " * Failed inserting {$stor_dir} in cc_music_dirs".PHP_EOL;
|
||||
echo " * Message {$result->getMessage()}".PHP_EOL;
|
||||
echo " * Message {$e->getMessage()}".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,12 @@
|
|||
* Checks if a previous version of Airtime is currently installed and upgrades Airtime if so.
|
||||
* Performs a new install (new configs, database install) otherwise.
|
||||
*/
|
||||
require_once(dirname(__FILE__).'/AirtimeIni.php');
|
||||
require_once(dirname(__FILE__).'/AirtimeInstall.php');
|
||||
require_once(__DIR__.'/AirtimeIni.php');
|
||||
require_once(__DIR__.'/AirtimeInstall.php');
|
||||
require_once(__DIR__.'/airtime-constants.php');
|
||||
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php');
|
||||
require_once 'propel/runtime/lib/Propel.php';
|
||||
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php");
|
||||
|
||||
$version = AirtimeInstall::GetVersionInstalled();
|
||||
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Airtime
|
||||
* @copyright 2011 Sourcefabric O.P.S.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
*
|
||||
* Checks if a current version of Airtime is installed.
|
||||
* If so, the user is presented with the help menu and can
|
||||
* choose -r to reinstall.
|
||||
|
@ -13,16 +9,21 @@
|
|||
* Returns 2 if a previous version of Airtime is installed we can upgrade from
|
||||
* Returns 3 if a version of Airtime is installed that we can't upgrade from.
|
||||
*/
|
||||
require_once(dirname(__FILE__).'/AirtimeInstall.php');
|
||||
require_once(__DIR__.'/AirtimeInstall.php');
|
||||
require_once(__DIR__.'/airtime-constants.php');
|
||||
|
||||
AirtimeInstall::ExitIfNotRoot();
|
||||
|
||||
require_once(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/conf.php");
|
||||
require_once('propel/runtime/lib/Propel.php');
|
||||
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php");
|
||||
|
||||
$version = AirtimeInstall::GetVersionInstalled();
|
||||
|
||||
// The current version is already installed.
|
||||
echo "* Checking for existing Airtime installation...".PHP_EOL;
|
||||
if (isset($version)){
|
||||
if ($version === false){
|
||||
if (is_null($version)){
|
||||
//version of Airtime older than 1.7.0 detected
|
||||
exit(3);
|
||||
} else {
|
||||
|
|
|
@ -25,8 +25,8 @@ echo "* Uninstalling Airtime ".AIRTIME_VERSION.PHP_EOL;
|
|||
//------------------------------------------------------------------------
|
||||
// Delete the database
|
||||
// Note: Do not put a call to AirtimeInstall::DbConnect()
|
||||
// before this function, even if you called $CC_DBC->disconnect(), there will
|
||||
// still be a connection to the database and you wont be able to delete it.
|
||||
// before this function, it will create a connection to the database
|
||||
// and you wont be able to delete it.
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
//close connection for any process id using airtime database since we are about to drop the database.
|
||||
|
@ -47,12 +47,14 @@ $command = "su postgres -c \"dropdb ".$CC_CONFIG["dsn"]["database"]."\"";
|
|||
//------------------------------------------------------------------------
|
||||
if ($dbDeleteFailed) {
|
||||
echo " * Couldn't delete the database, so deleting all the DB tables...".PHP_EOL;
|
||||
AirtimeInstall::DbConnect(false);
|
||||
$connected = AirtimeInstall::DbConnect(false);
|
||||
|
||||
if (!PEAR::isError($CC_DBC)) {
|
||||
if ($connected) {
|
||||
$con = Propel::getConnection();
|
||||
$sql = "select * from pg_tables where tableowner = 'airtime'";
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
if (PEAR::isError($rows)) {
|
||||
try {
|
||||
$rows = $con->query($sql)->fetchAll();
|
||||
} catch (Exception $e) {
|
||||
$rows = array();
|
||||
}
|
||||
|
||||
|
@ -63,8 +65,7 @@ if ($dbDeleteFailed) {
|
|||
if (AirtimeInstall::DbTableExists($tablename)) {
|
||||
$sql = "DROP TABLE $tablename CASCADE";
|
||||
AirtimeInstall::InstallQuery($sql, false);
|
||||
|
||||
$CC_DBC->dropSequence($tablename."_id");
|
||||
AirtimeInstall::DropSequence($tablename."_id");
|
||||
}
|
||||
echo "done.".PHP_EOL;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,15 @@ if(posix_geteuid() != 0){
|
|||
exit(1);
|
||||
}
|
||||
|
||||
function pause(){
|
||||
require_once(__DIR__.'/airtime-constants.php');
|
||||
require_once(__DIR__.'/AirtimeIni.php');
|
||||
require_once(__DIR__.'/AirtimeInstall.php');
|
||||
require_once 'propel/runtime/lib/Propel.php';
|
||||
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php");
|
||||
|
||||
|
||||
function pause()
|
||||
{
|
||||
/* Type "sudo -s" to change to root user then type "export AIRTIME_INSTALL_DEBUG=1" and then
|
||||
* start airtime-install to enable this feature. Is used to pause between upgrade scripts
|
||||
* to examine the state of the system and see if everything is as expected. */
|
||||
|
@ -26,33 +34,8 @@ function pause(){
|
|||
}
|
||||
}
|
||||
|
||||
const CONF_FILE_AIRTIME = "/etc/airtime/airtime.conf";
|
||||
|
||||
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
|
||||
$values = parse_ini_file('/etc/airtime/airtime.conf', true);
|
||||
|
||||
// Database config
|
||||
$CC_CONFIG['dsn']['username'] = $values['database']['dbuser'];
|
||||
$CC_CONFIG['dsn']['password'] = $values['database']['dbpass'];
|
||||
$CC_CONFIG['dsn']['hostspec'] = $values['database']['host'];
|
||||
$CC_CONFIG['dsn']['phptype'] = 'pgsql';
|
||||
$CC_CONFIG['dsn']['database'] = $values['database']['dbname'];
|
||||
|
||||
$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);
|
||||
}
|
||||
AirtimeInstall::DbConnect(true);
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$version = AirtimeInstall::GetVersionInstalled();
|
||||
|
||||
|
@ -121,13 +104,13 @@ if (strcmp($version, "2.1.0") < 0){
|
|||
|
||||
//set the new version in the database.
|
||||
$sql = "DELETE FROM cc_pref WHERE keystr = 'system_version'";
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
|
||||
$values = parse_ini_file(CONF_FILE_AIRTIME, true);
|
||||
$phpDir = $values['general']['airtime_dir'];
|
||||
|
||||
$newVersion = AIRTIME_VERSION;
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '$newVersion')";
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
|
||||
echo "******************************* Upgrade Complete *******************************".PHP_EOL;
|
||||
|
|
|
@ -55,6 +55,7 @@ $CC_CONFIG = array(
|
|||
);
|
||||
|
||||
AirtimeInstall::DbConnect(true);
|
||||
$con = Propel::getConnection();
|
||||
|
||||
echo PHP_EOL."*** Updating Database Tables ***".PHP_EOL;
|
||||
|
||||
|
@ -68,11 +69,11 @@ AirtimeInstall::MigrateTablesToVersion(__DIR__, '20110406182005');
|
|||
|
||||
//setting data for new aggregate show length column.
|
||||
$sql = "SELECT id FROM cc_show_instances";
|
||||
$show_instances = $CC_DBC->GetAll($sql);
|
||||
$show_instances = $con->query($sql)->fetchAll();
|
||||
|
||||
foreach ($show_instances as $show_instance) {
|
||||
$sql = "UPDATE cc_show_instances SET time_filled = (SELECT SUM(clip_length) FROM cc_schedule WHERE instance_id = {$show_instance["id"]}) WHERE id = {$show_instance["id"]}";
|
||||
$CC_DBC->query($sql);
|
||||
$con->exec($sql);
|
||||
}
|
||||
//end setting data for new aggregate show length column.
|
||||
|
||||
|
|
|
@ -1,17 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Airtime
|
||||
* @subpackage StorageServer
|
||||
* @copyright 2010 Sourcefabric O.P.S.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
*/
|
||||
|
||||
set_include_path(__DIR__.'/../../../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
|
||||
require_once 'conf.php';
|
||||
require_once 'DB.php';
|
||||
|
||||
require_once 'propel/runtime/lib/Propel.php';
|
||||
|
||||
set_include_path(__DIR__.'/propel' . PATH_SEPARATOR . get_include_path());
|
||||
Propel::init(__DIR__."/propel/airtime-conf.php");
|
||||
|
||||
|
@ -75,10 +65,11 @@ class AirtimeInstall{
|
|||
|
||||
public static function DbTableExists($p_name)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT * FROM ".$p_name;
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
$con = Propel::getConnection();
|
||||
try {
|
||||
$sql = "SELECT * FROM ".$p_name." LIMIT 1";
|
||||
$con->query($sql);
|
||||
} catch (PDOException $e){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -371,13 +362,12 @@ class AirtimeInstall{
|
|||
|
||||
public static function SetUniqueId()
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
$con = Propel::getConnection();
|
||||
$uniqueId = md5(uniqid("", true));
|
||||
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('uniqueId', '$uniqueId')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
$result = $con->exec($sql);
|
||||
if ($result < 1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -385,11 +375,10 @@ class AirtimeInstall{
|
|||
|
||||
public static function SetImportTimestamp()
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
$con = Propel::getConnection();
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('import_timestamp', '0')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
$result = $con->exec($sql);
|
||||
if ($result < 1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -586,31 +575,30 @@ class Airtime190Upgrade{
|
|||
}
|
||||
|
||||
|
||||
public static function execSqlQuery($sql){
|
||||
global $CC_DBC;
|
||||
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
public static function execSqlQuery($sql)
|
||||
{
|
||||
$result = 0;
|
||||
try {
|
||||
$con = Propel::getConnection();
|
||||
$result = $con->exec($sql);
|
||||
} catch (Exception $e) {
|
||||
echo "* Failed sql query: $sql".PHP_EOL;
|
||||
echo "* Message {$result->getMessage()}".PHP_EOL;
|
||||
echo "* Message {$e->getMessage()}".PHP_EOL;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function connectToDatabase(){
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
|
||||
$values = parse_ini_file('/etc/airtime/airtime.conf', true);
|
||||
|
||||
// Database config
|
||||
$CC_CONFIG['dsn']['username'] = $values['database']['dbuser'];
|
||||
$CC_CONFIG['dsn']['password'] = $values['database']['dbpass'];
|
||||
$CC_CONFIG['dsn']['hostspec'] = $values['database']['host'];
|
||||
$CC_CONFIG['dsn']['phptype'] = 'pgsql';
|
||||
$CC_CONFIG['dsn']['database'] = $values['database']['dbname'];
|
||||
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], FALSE);
|
||||
public static function connectToDatabase()
|
||||
{
|
||||
try {
|
||||
$con = Propel::getConnection();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage().PHP_EOL;
|
||||
echo "Database connection problem.".PHP_EOL;
|
||||
echo "Check if database exists with corresponding permissions.".PHP_EOL;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function backupFileInfoInStorToFile($values) {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once('DB.php');
|
||||
|
||||
/* These are helper functions that are common to each upgrade such as
|
||||
* creating connections to a database, backing up config files etc.
|
||||
*/
|
||||
|
@ -20,29 +18,28 @@ class UpgradeCommon{
|
|||
|
||||
public static function connectToDatabase($p_exitOnError = true)
|
||||
{
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
$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;
|
||||
try {
|
||||
$con = Propel::getConnection();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage().PHP_EOL;
|
||||
echo "Database connection problem.".PHP_EOL;
|
||||
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
|
||||
" with corresponding permissions.".PHP_EOL;
|
||||
echo "Check if database exists with corresponding permissions.".PHP_EOL;
|
||||
if ($p_exitOnError) {
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static function DbTableExists($p_name)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT * FROM ".$p_name;
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
$con = Propel::getConnection();
|
||||
try {
|
||||
$sql = "SELECT * FROM ".$p_name." LIMIT 1";
|
||||
$con->query($sql);
|
||||
} catch (PDOException $e){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -234,12 +231,14 @@ class UpgradeCommon{
|
|||
fclose($fp);
|
||||
}
|
||||
|
||||
public static function queryDb($p_sql){
|
||||
global $CC_DBC;
|
||||
public static function queryDb($p_sql)
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$result = $CC_DBC->query($p_sql);
|
||||
if (PEAR::isError($result)) {
|
||||
echo "Error executing $sql. Exiting.";
|
||||
try {
|
||||
$result = $con->exec($p_sql);
|
||||
} catch (Exception $e) {
|
||||
echo "Error executing $p_sql. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,586 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Airtime
|
||||
* @subpackage StorageServer
|
||||
* @copyright 2010 Sourcefabric O.P.S.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
*/
|
||||
|
||||
set_include_path(__DIR__.'/../../../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
|
||||
set_include_path(__DIR__.'/../../../airtime_mvc/library/pear' . PATH_SEPARATOR . get_include_path());
|
||||
set_include_path(__DIR__.'/../../../airtime_mvc/application/models' . PATH_SEPARATOR . get_include_path());
|
||||
set_include_path(__DIR__.'/../../../airtime_mvc/application/configs' . PATH_SEPARATOR . get_include_path());
|
||||
require_once 'conf.php';
|
||||
require_once 'DB.php';
|
||||
|
||||
require_once 'propel/runtime/lib/Propel.php';
|
||||
Propel::init(__DIR__."/../../../airtime_mvc/application/configs/airtime-conf.php");
|
||||
|
||||
class AirtimeInstall{
|
||||
const CONF_DIR_BINARIES = "/usr/lib/airtime";
|
||||
|
||||
public static function SetDefaultTimezone()
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
$defaultTimezone = date_default_timezone_get();
|
||||
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', '$defaultTimezone')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function GetUtilsSrcDir()
|
||||
{
|
||||
return __DIR__."/../../../utils";
|
||||
}
|
||||
|
||||
public static function InstallBinaries()
|
||||
{
|
||||
echo "* Installing binaries to ".AirtimeInstall::CONF_DIR_BINARIES.PHP_EOL;
|
||||
exec("mkdir -p ".AirtimeInstall::CONF_DIR_BINARIES);
|
||||
exec("cp -R ".AirtimeInstall::GetUtilsSrcDir()." ".AirtimeInstall::CONF_DIR_BINARIES);
|
||||
}
|
||||
|
||||
public static function CreateSymlinksToUtils()
|
||||
{
|
||||
echo "* Installing airtime-log".PHP_EOL;
|
||||
$dir = AirtimeInstall::CONF_DIR_BINARIES."/utils/airtime-log";
|
||||
copy(AirtimeInstall::GetUtilsSrcDir()."/airtime-log.php", AirtimeInstall::CONF_DIR_BINARIES."/utils/airtime-log.php");
|
||||
|
||||
exec("ln -s $dir /usr/bin/airtime-log");
|
||||
}
|
||||
|
||||
public static function SetDefaultStreamSetting()
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
echo "* Setting up default stream setting".PHP_EOL;
|
||||
$sql = "INSERT INTO cc_pref(keystr, valstr) VALUES('stream_type', 'ogg, mp3');
|
||||
INSERT INTO cc_pref(keystr, valstr) VALUES('stream_bitrate', '24, 32, 48, 64, 96, 128, 160, 192, 224, 256, 320');
|
||||
INSERT INTO cc_pref(keystr, valstr) VALUES('num_of_streams', '3');
|
||||
INSERT INTO cc_pref(keystr, valstr) VALUES('max_bitrate', '128');
|
||||
INSERT INTO cc_pref(keystr, valstr) VALUES('plan_level', 'disabled');
|
||||
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('output_sound_device', 'false', 'boolean');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('icecast_vorbis_metadata', 'false', 'boolean');
|
||||
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_output', 'icecast', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_type', 'ogg', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_bitrate', '128', 'integer');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_host', '127.0.0.1', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_port', '8000', 'integer');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_user', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_pass', 'hackme', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_mount', 'airtime_128', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_url', 'http://airtime.sourcefabric.org', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_description', 'Airtime Radio! Stream #1', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_genre', 'genre', 'string');
|
||||
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_output', 'disabled', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_type', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_bitrate', '', 'integer');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_host', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_port', '', 'integer');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_user', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_pass', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_mount', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_url', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_description', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_genre', '', 'string');
|
||||
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_output', 'disabled', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_type', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_bitrate', '', 'integer');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_host', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_port', '', 'integer');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_user', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_pass', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_mount', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_url', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_description', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_genre', '', 'string');";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function BypassMigrations($dir, $version)
|
||||
{
|
||||
$appDir = AirtimeInstall::GetAirtimeSrcDir();
|
||||
$command = "php $appDir/library/doctrine/migrations/doctrine-migrations.phar ".
|
||||
"--configuration=$dir/../../DoctrineMigrations/migrations.xml ".
|
||||
"--db-configuration=$appDir/library/doctrine/migrations/migrations-db.php ".
|
||||
"--no-interaction --add migrations:version $version";
|
||||
system($command);
|
||||
}
|
||||
|
||||
public static function MigrateTablesToVersion($dir, $version)
|
||||
{
|
||||
$appDir = AirtimeInstall::GetAirtimeSrcDir();
|
||||
$command = "php $appDir/library/doctrine/migrations/doctrine-migrations.phar ".
|
||||
"--configuration=$dir/../../DoctrineMigrations/migrations.xml ".
|
||||
"--db-configuration=$appDir/library/doctrine/migrations/migrations-db.php ".
|
||||
"--no-interaction migrations:migrate $version";
|
||||
system($command);
|
||||
}
|
||||
|
||||
public static function GetAirtimeSrcDir()
|
||||
{
|
||||
return __DIR__."/../../../airtime_mvc";
|
||||
}
|
||||
|
||||
public static function DbTableExists($p_name)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT * FROM ".$p_name;
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static function GetOldLiquidsoapCfgAndUpdate(){
|
||||
global $CC_DBC;
|
||||
echo "* Retrieving old liquidsoap configuration".PHP_EOL;
|
||||
$map = array();
|
||||
$fh = fopen("/etc/airtime/liquidsoap.cfg", 'r');
|
||||
$newConfigMap = array();
|
||||
|
||||
while(!feof($fh)){
|
||||
$line = fgets($fh);
|
||||
if(substr(trim($line), 0, 1) == '#' || trim($line) == ""){
|
||||
continue;
|
||||
}else{
|
||||
$info = explode('=', $line, 2);
|
||||
$map[trim($info[0])] = trim($info[1]);
|
||||
}
|
||||
}
|
||||
$newConfigMap['output_sound_device'] = $map['output_sound_device'];
|
||||
$newConfigMap['icecast_vorbis_metadata'] = $map['output_icecast_vorbis_metadata'];
|
||||
$newConfigMap['log_file'] = $map['log_file'];
|
||||
|
||||
$count = 1;
|
||||
if( $map['output_icecast_vorbis'] == 'true'){
|
||||
$newConfigMap['s'.$count.'_output'] = 'icecast';
|
||||
$newConfigMap['s'.$count.'_host'] = $map['icecast_host'];
|
||||
$newConfigMap['s'.$count.'_port'] = $map['icecast_port'];
|
||||
$newConfigMap['s'.$count.'_pass'] = $map['icecast_pass'];
|
||||
$newConfigMap['s'.$count.'_mount'] = $map['mount_point_vorbis'];
|
||||
$newConfigMap['s'.$count.'_url'] = $map['icecast_url'];
|
||||
$newConfigMap['s'.$count.'_description'] = $map['icecast_description'];
|
||||
$newConfigMap['s'.$count.'_genre'] = $map['icecast_genre'];
|
||||
$newConfigMap['s'.$count.'_type'] = "ogg";
|
||||
$newConfigMap['s'.$count.'_bitrate'] = "128";
|
||||
$count++;
|
||||
}
|
||||
if($map['output_icecast_mp3'] == 'true'){
|
||||
$newConfigMap['s'.$count.'_output'] = 'icecast';
|
||||
$newConfigMap['s'.$count.'_host'] = $map['icecast_host'];
|
||||
$newConfigMap['s'.$count.'_port'] = $map['icecast_port'];
|
||||
$newConfigMap['s'.$count.'_pass'] = $map['icecast_pass'];
|
||||
$newConfigMap['s'.$count.'_mount'] = $map['mount_point_mp3'];
|
||||
$newConfigMap['s'.$count.'_url'] = $map['icecast_url'];
|
||||
$newConfigMap['s'.$count.'_description'] = $map['icecast_description'];
|
||||
$newConfigMap['s'.$count.'_genre'] = $map['icecast_genre'];
|
||||
$newConfigMap['s'.$count.'_type'] = "mp3";
|
||||
$newConfigMap['s'.$count.'_bitrate'] = "128";
|
||||
$count++;
|
||||
}
|
||||
if($map['output_shoutcast'] == 'true'){
|
||||
$newConfigMap['s'.$count.'_output'] = 'shoutcast';
|
||||
$newConfigMap['s'.$count.'_host'] = $map['shoutcast_host'];
|
||||
$newConfigMap['s'.$count.'_port'] = $map['shoutcast_port'];
|
||||
$newConfigMap['s'.$count.'_pass'] = $map['shoutcast_pass'];
|
||||
$newConfigMap['s'.$count.'_url'] = $map['shoutcast_url'];
|
||||
$newConfigMap['s'.$count.'_genre'] = $map['shoutcast_genre'];
|
||||
$newConfigMap['s'.$count.'_type'] = "mp3";
|
||||
$newConfigMap['s'.$count.'_bitrate'] = "128";
|
||||
$count++;
|
||||
}
|
||||
|
||||
$sql = "";
|
||||
foreach( $newConfigMap as $key=>$val){
|
||||
if(substr($val, 0, 1) == '"' && substr($val, strlen($val)-1,1)){
|
||||
$val = ltrim($val, '"');
|
||||
$val = rtrim($val, '"');
|
||||
}
|
||||
$sql .= "UPDATE cc_stream_setting SET value='$val' WHERE keyname='$key';";
|
||||
}
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class Airtime200Upgrade{
|
||||
|
||||
public static function connectToDatabase(){
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
|
||||
$values = parse_ini_file('/etc/airtime/airtime.conf', true);
|
||||
|
||||
// Database config
|
||||
$CC_CONFIG['dsn']['username'] = $values['database']['dbuser'];
|
||||
$CC_CONFIG['dsn']['password'] = $values['database']['dbpass'];
|
||||
$CC_CONFIG['dsn']['hostspec'] = $values['database']['host'];
|
||||
$CC_CONFIG['dsn']['phptype'] = 'pgsql';
|
||||
$CC_CONFIG['dsn']['database'] = $values['database']['dbname'];
|
||||
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], FALSE);
|
||||
}
|
||||
|
||||
public static function InstallAirtimePhpServerCode($phpDir)
|
||||
{
|
||||
|
||||
$AIRTIME_SRC = realpath(__DIR__.'/../../../airtime_mvc');
|
||||
|
||||
// delete old files
|
||||
exec("rm -rf ".$phpDir);
|
||||
echo "* Installing PHP code to ".$phpDir.PHP_EOL;
|
||||
exec("mkdir -p ".$phpDir);
|
||||
exec("cp -R ".$AIRTIME_SRC."/* ".$phpDir);
|
||||
}
|
||||
|
||||
public static function RemoveOldMonitFile(){
|
||||
unlink("/etc/monit/conf.d/airtime-monit.cfg");
|
||||
}
|
||||
}
|
||||
|
||||
class ConvertToUtc{
|
||||
|
||||
public static function setPhpDefaultTimeZoneToSystemTimezone(){
|
||||
//we can get the default system timezone on debian/ubuntu by reading "/etc/timezone"
|
||||
$filename = "/etc/timezone";
|
||||
$handle = fopen($filename, "r");
|
||||
$contents = trim(fread($handle, filesize($filename)));
|
||||
echo "System timezone detected as: $contents".PHP_EOL;
|
||||
fclose($handle);
|
||||
|
||||
date_default_timezone_set($contents);
|
||||
}
|
||||
|
||||
public static function convert_cc_playlist(){
|
||||
/* cc_playlist has a field that keeps track of when the playlist was last modified. */
|
||||
$playlists = CcPlaylistQuery::create()->find();
|
||||
|
||||
foreach ($playlists as $pl){
|
||||
$dt = new DateTime($pl->getDbMtime(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$pl->setDbMtime($dt);
|
||||
|
||||
$pl->save();
|
||||
}
|
||||
}
|
||||
|
||||
public static function convert_cc_schedule(){
|
||||
/* cc_schedule has start and end fields that need to be changed to UTC. */
|
||||
$schedules = CcScheduleQuery::create()->find();
|
||||
|
||||
foreach ($schedules as $s){
|
||||
$dt = new DateTime($s->getDbStarts(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$s->setDbStarts($dt);
|
||||
|
||||
$dt = new DateTime($s->getDbEnds(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$s->setDbEnds($dt);
|
||||
|
||||
$s->save();
|
||||
}
|
||||
}
|
||||
|
||||
public static function convert_cc_show_days(){
|
||||
/* cc_show_days has first_show, last_show and start_time fields that need to be changed to UTC. */
|
||||
$showDays = CcShowDaysQuery::create()->find();
|
||||
|
||||
foreach ($showDays as $sd){
|
||||
$dt = new DateTime($sd->getDbFirstShow()." ".$sd->getDbStartTime(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$sd->setDbFirstShow($dt->format("Y-m-d"));
|
||||
$sd->setDbStartTime($dt->format("H:i:s"));
|
||||
|
||||
$dt = new DateTime($sd->getDbLastShow()." ".$sd->getDbStartTime(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$sd->setDbLastShow($dt->format("Y-m-d"));
|
||||
|
||||
$sd->save();
|
||||
}
|
||||
}
|
||||
|
||||
public static function convert_cc_show_instances(){
|
||||
/* convert_cc_show_instances has starts and ends fields that need to be changed to UTC. */
|
||||
$showInstances = CcShowInstancesQuery::create()->find();
|
||||
|
||||
foreach ($showInstances as $si){
|
||||
$dt = new DateTime($si->getDbStarts(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$si->setDbStarts($dt);
|
||||
|
||||
$dt = new DateTime($si->getDbEnds(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$si->setDbEnds($dt);
|
||||
|
||||
$si->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AirtimeIni200{
|
||||
|
||||
const CONF_FILE_AIRTIME = "/etc/airtime/airtime.conf";
|
||||
const CONF_FILE_PYPO = "/etc/airtime/pypo.cfg";
|
||||
const CONF_FILE_RECORDER = "/etc/airtime/recorder.cfg";
|
||||
const CONF_FILE_LIQUIDSOAP = "/etc/airtime/liquidsoap.cfg";
|
||||
const CONF_FILE_MEDIAMONITOR = "/etc/airtime/media-monitor.cfg";
|
||||
const CONF_FILE_API_CLIENT = "/etc/airtime/api_client.cfg";
|
||||
|
||||
const CONF_PYPO_GRP = "pypo";
|
||||
const CONF_WWW_DATA_GRP = "www-data";
|
||||
|
||||
/**
|
||||
* This function updates an INI style config file.
|
||||
*
|
||||
* A property and the value the property should be changed to are
|
||||
* supplied. If the property is not found, then no changes are made.
|
||||
*
|
||||
* @param string $p_filename
|
||||
* The path the to the file.
|
||||
* @param string $p_property
|
||||
* The property to look for in order to change its value.
|
||||
* @param string $p_value
|
||||
* The value the property should be changed to.
|
||||
*
|
||||
*/
|
||||
public static function UpdateIniValue($p_filename, $p_property, $p_value)
|
||||
{
|
||||
$lines = file($p_filename);
|
||||
$n=count($lines);
|
||||
foreach ($lines as &$line) {
|
||||
if ($line[0] != "#"){
|
||||
$key_value = explode("=", $line);
|
||||
$key = trim($key_value[0]);
|
||||
|
||||
if ($key == $p_property){
|
||||
$line = "$p_property = $p_value".PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fp=fopen($p_filename, 'w');
|
||||
for($i=0; $i<$n; $i++){
|
||||
fwrite($fp, $lines[$i]);
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
public static function ReadPythonConfig($p_filename)
|
||||
{
|
||||
$values = array();
|
||||
|
||||
$fh = fopen($p_filename, 'r');
|
||||
|
||||
while(!feof($fh)){
|
||||
$line = fgets($fh);
|
||||
if(substr(trim($line), 0, 1) == '#' || trim($line) == ""){
|
||||
continue;
|
||||
}else{
|
||||
$info = explode('=', $line, 2);
|
||||
$values[trim($info[0])] = trim($info[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
public static function MergeConfigFiles($configFiles, $suffix) {
|
||||
foreach ($configFiles as $conf) {
|
||||
// we want to use new liquidsoap.cfg so don't merge
|
||||
// also for monit
|
||||
if( $conf == AirtimeIni200::CONF_FILE_LIQUIDSOAP){
|
||||
continue;
|
||||
}
|
||||
if (file_exists("$conf$suffix.bak")) {
|
||||
|
||||
if($conf === AirtimeIni200::CONF_FILE_AIRTIME) {
|
||||
// Parse with sections
|
||||
$newSettings = parse_ini_file($conf, true);
|
||||
$oldSettings = parse_ini_file("$conf$suffix.bak", true);
|
||||
}
|
||||
else {
|
||||
$newSettings = AirtimeIni200::ReadPythonConfig($conf);
|
||||
$oldSettings = AirtimeIni200::ReadPythonConfig("$conf$suffix.bak");
|
||||
}
|
||||
|
||||
$settings = array_keys($newSettings);
|
||||
|
||||
foreach($settings as $section) {
|
||||
if(isset($oldSettings[$section])) {
|
||||
if(is_array($oldSettings[$section])) {
|
||||
$sectionKeys = array_keys($newSettings[$section]);
|
||||
foreach($sectionKeys as $sectionKey) {
|
||||
// skip airtim_dir as we want to use new value
|
||||
if($sectionKey != "airtime_dir"){
|
||||
if(isset($oldSettings[$section][$sectionKey])) {
|
||||
AirtimeIni200::UpdateIniValue($conf, $sectionKey, $oldSettings[$section][$sectionKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
AirtimeIni200::UpdateIniValue($conf, $section, $oldSettings[$section]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Re: http://dev.sourcefabric.org/browse/CC-2797
|
||||
* We don't want config files to be world-readable so we
|
||||
* set the strictest permissions possible. */
|
||||
public static function changeConfigFilePermissions(){
|
||||
if (!self::ChangeFileOwnerGroupMod(AirtimeIni200::CONF_FILE_AIRTIME, self::CONF_WWW_DATA_GRP)){
|
||||
echo "Could not set ownership of api_client.cfg to 'pypo'. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!self::ChangeFileOwnerGroupMod(AirtimeIni200::CONF_FILE_API_CLIENT, self::CONF_PYPO_GRP)){
|
||||
echo "Could not set ownership of api_client.cfg to 'pypo'. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!self::ChangeFileOwnerGroupMod(AirtimeIni200::CONF_FILE_PYPO, self::CONF_PYPO_GRP)){
|
||||
echo "Could not set ownership of pypo.cfg to 'pypo'. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!self::ChangeFileOwnerGroupMod(AirtimeIni200::CONF_FILE_RECORDER, self::CONF_PYPO_GRP)){
|
||||
echo "Could not set ownership of recorder.cfg to 'pypo'. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!self::ChangeFileOwnerGroupMod(AirtimeIni200::CONF_FILE_LIQUIDSOAP, self::CONF_PYPO_GRP)){
|
||||
echo "Could not set ownership of liquidsoap.cfg to 'pypo'. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!self::ChangeFileOwnerGroupMod(AirtimeIni200::CONF_FILE_MEDIAMONITOR, self::CONF_PYPO_GRP)){
|
||||
echo "Could not set ownership of media-monitor.cfg to 'pypo'. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static function ChangeFileOwnerGroupMod($filename, $user){
|
||||
return (chown($filename, $user) &&
|
||||
chgrp($filename, $user) &&
|
||||
chmod($filename, 0640));
|
||||
}
|
||||
|
||||
public static function upgradeConfigFiles(){
|
||||
|
||||
$configFiles = array(AirtimeIni200::CONF_FILE_AIRTIME,
|
||||
AirtimeIni200::CONF_FILE_PYPO,
|
||||
AirtimeIni200::CONF_FILE_RECORDER,
|
||||
AirtimeIni200::CONF_FILE_LIQUIDSOAP,
|
||||
AirtimeIni200::CONF_FILE_MEDIAMONITOR,
|
||||
AirtimeIni200::CONF_FILE_API_CLIENT);
|
||||
|
||||
// Backup the config files
|
||||
$suffix = date("Ymdhis")."-2.0.0";
|
||||
foreach ($configFiles as $conf) {
|
||||
// do not back up monit cfg
|
||||
if (file_exists($conf)) {
|
||||
echo "Backing up $conf to $conf$suffix.bak".PHP_EOL;
|
||||
//copy($conf, $conf.$suffix.".bak");
|
||||
exec("cp -p $conf $conf$suffix.bak"); //use cli version to preserve file attributes
|
||||
}
|
||||
}
|
||||
|
||||
$default_suffix = "200";
|
||||
AirtimeIni200::CreateIniFiles($default_suffix);
|
||||
AirtimeIni200::MergeConfigFiles($configFiles, $suffix);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function creates the /etc/airtime configuration folder
|
||||
* and copies the default config files to it.
|
||||
*/
|
||||
public static function CreateIniFiles($suffix)
|
||||
{
|
||||
if (!file_exists("/etc/airtime/")){
|
||||
if (!mkdir("/etc/airtime/", 0755, true)){
|
||||
echo "Could not create /etc/airtime/ directory. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!copy(__DIR__."/airtime.conf.$suffix", AirtimeIni200::CONF_FILE_AIRTIME)){
|
||||
echo "Could not copy airtime.conf to /etc/airtime/. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!copy(__DIR__."/pypo.cfg.$suffix", AirtimeIni200::CONF_FILE_PYPO)){
|
||||
echo "Could not copy pypo.cfg to /etc/airtime/. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!copy(__DIR__."/recorder.cfg.$suffix", AirtimeIni200::CONF_FILE_RECORDER)){
|
||||
echo "Could not copy recorder.cfg to /etc/airtime/. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
/*if (!copy(__DIR__."/liquidsoap.cfg.$suffix", AirtimeIni200::CONF_FILE_LIQUIDSOAP)){
|
||||
echo "Could not copy liquidsoap.cfg to /etc/airtime/. Exiting.";
|
||||
exit(1);
|
||||
}*/
|
||||
if (!copy(__DIR__."/api_client.cfg.$suffix", AirtimeIni200::CONF_FILE_API_CLIENT)){
|
||||
echo "Could not copy airtime-monit.cfg to /etc/monit/conf.d/. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Airtime200Upgrade::connectToDatabase();
|
||||
AirtimeInstall::SetDefaultTimezone();
|
||||
|
||||
AirtimeInstall::InstallBinaries();
|
||||
AirtimeInstall::CreateSymlinksToUtils();
|
||||
|
||||
/* Airtime 2.0.0 starts interpreting all database times in UTC format. Prior to this, all the times
|
||||
* were stored using the local time zone. Let's convert to UTC time. */
|
||||
ConvertToUtc::setPhpDefaultTimeZoneToSystemTimezone();
|
||||
ConvertToUtc::convert_cc_playlist();
|
||||
ConvertToUtc::convert_cc_schedule();
|
||||
ConvertToUtc::convert_cc_show_days();
|
||||
ConvertToUtc::convert_cc_show_instances();
|
||||
|
||||
// merging/updating config files
|
||||
echo "* Updating configFiles\n";
|
||||
AirtimeIni200::changeConfigFilePermissions();
|
||||
AirtimeIni200::upgradeConfigFiles();
|
||||
|
||||
$values = parse_ini_file(AirtimeIni200::CONF_FILE_AIRTIME, true);
|
||||
$phpDir = $values['general']['airtime_dir'];
|
||||
Airtime200Upgrade::InstallAirtimePhpServerCode($phpDir);
|
||||
|
||||
if(AirtimeInstall::DbTableExists('doctrine_migration_versions') === false) {
|
||||
$migrations = array('20110312121200', '20110331111708', '20110402164819', '20110406182005', '20110629143017', '20110711161043', '20110713161043');
|
||||
foreach($migrations as $migration) {
|
||||
AirtimeInstall::BypassMigrations(__DIR__, $migration);
|
||||
}
|
||||
}
|
||||
|
||||
AirtimeInstall::MigrateTablesToVersion(__DIR__, '20110925171256');
|
||||
|
||||
AirtimeInstall::SetDefaultStreamSetting();
|
||||
|
||||
AirtimeInstall::GetOldLiquidsoapCfgAndUpdate();
|
||||
|
||||
AirtimeUpgrade::RemoveOldMonitFile();
|
||||
|
||||
// restart monit
|
||||
exec("service monit restart");
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Airtime
|
||||
* @subpackage StorageServer
|
||||
* @copyright 2010 Sourcefabric O.P.S.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
*/
|
||||
|
||||
/*
|
||||
* In the future, most Airtime upgrades will involve just mutating the
|
||||
* data that is stored on the system. For example, The only data
|
||||
|
@ -29,7 +22,8 @@ require_once 'UpgradeCommon.php';
|
|||
*/
|
||||
class AirtimeDatabaseUpgrade {
|
||||
|
||||
public static function start(){
|
||||
public static function start()
|
||||
{
|
||||
self::doDbMigration();
|
||||
|
||||
self::setPhpDefaultTimeZoneToSystemTimezone();
|
||||
|
@ -47,13 +41,14 @@ class AirtimeDatabaseUpgrade{
|
|||
|
||||
private static function SetDefaultTimezone()
|
||||
{
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$defaultTimezone = date_default_timezone_get();
|
||||
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', '$defaultTimezone')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
try {
|
||||
$result = $con->exec($sql);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -241,7 +236,7 @@ class AirtimeDatabaseUpgrade{
|
|||
|
||||
private static function SetDefaultStreamSetting()
|
||||
{
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
echo "* Setting up default stream setting".PHP_EOL;
|
||||
$sql = "INSERT INTO cc_pref(keystr, valstr) VALUES('stream_type', 'ogg, mp3');
|
||||
|
@ -292,15 +287,18 @@ class AirtimeDatabaseUpgrade{
|
|||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_url', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_description', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_genre', '', 'string');";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
try {
|
||||
$con->exec($sql);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static function GetOldLiquidsoapCfgAndUpdate(){
|
||||
global $CC_DBC;
|
||||
private static function GetOldLiquidsoapCfgAndUpdate()
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
|
||||
echo "* Retrieving old liquidsoap configuration".PHP_EOL;
|
||||
$map = array();
|
||||
$fh = fopen("/etc/airtime/liquidsoap.cfg", 'r');
|
||||
|
@ -366,8 +364,9 @@ class AirtimeDatabaseUpgrade{
|
|||
}
|
||||
$sql .= "UPDATE cc_stream_setting SET value='$val' WHERE keyname='$key';";
|
||||
}
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
try {
|
||||
$con->exec($sql);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once('DB.php');
|
||||
|
||||
/* These are helper functions that are common to each upgrade such as
|
||||
* creating connections to a database, backing up config files etc.
|
||||
*/
|
||||
|
@ -30,29 +28,28 @@ class UpgradeCommon{
|
|||
|
||||
public static function connectToDatabase($p_exitOnError = true)
|
||||
{
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
$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;
|
||||
try {
|
||||
$con = Propel::getConnection();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage().PHP_EOL;
|
||||
echo "Database connection problem.".PHP_EOL;
|
||||
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
|
||||
" with corresponding permissions.".PHP_EOL;
|
||||
echo "Check if database exists with corresponding permissions.".PHP_EOL;
|
||||
if ($p_exitOnError) {
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static function DbTableExists($p_name)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT * FROM ".$p_name;
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
$con = Propel::getConnection();
|
||||
try {
|
||||
$sql = "SELECT * FROM ".$p_name." LIMIT 1";
|
||||
$con->query($sql);
|
||||
} catch (PDOException $e){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -245,11 +242,12 @@ class UpgradeCommon{
|
|||
}
|
||||
|
||||
public static function queryDb($p_sql){
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$result = $CC_DBC->getRow($p_sql, $fetchmode=DB_FETCHMODE_ASSOC);
|
||||
if (PEAR::isError($result)) {
|
||||
echo "Error executing $sql. Exiting.";
|
||||
try {
|
||||
$result = $con->exec($p_sql);
|
||||
} catch (Exception $e) {
|
||||
echo "Error executing $p_sql. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,586 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Airtime
|
||||
* @subpackage StorageServer
|
||||
* @copyright 2010 Sourcefabric O.P.S.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
*/
|
||||
|
||||
set_include_path(__DIR__.'/../../../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
|
||||
set_include_path(__DIR__.'/../../../airtime_mvc/library/pear' . PATH_SEPARATOR . get_include_path());
|
||||
set_include_path(__DIR__.'/../../../airtime_mvc/application/models' . PATH_SEPARATOR . get_include_path());
|
||||
set_include_path(__DIR__.'/../../../airtime_mvc/application/configs' . PATH_SEPARATOR . get_include_path());
|
||||
require_once 'conf.php';
|
||||
require_once 'DB.php';
|
||||
|
||||
require_once 'propel/runtime/lib/Propel.php';
|
||||
Propel::init(__DIR__."/../../../airtime_mvc/application/configs/airtime-conf.php");
|
||||
|
||||
class AirtimeInstall{
|
||||
const CONF_DIR_BINARIES = "/usr/lib/airtime";
|
||||
|
||||
public static function SetDefaultTimezone()
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
$defaultTimezone = date_default_timezone_get();
|
||||
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', '$defaultTimezone')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function GetUtilsSrcDir()
|
||||
{
|
||||
return __DIR__."/../../../utils";
|
||||
}
|
||||
|
||||
public static function InstallBinaries()
|
||||
{
|
||||
echo "* Installing binaries to ".AirtimeInstall::CONF_DIR_BINARIES.PHP_EOL;
|
||||
exec("mkdir -p ".AirtimeInstall::CONF_DIR_BINARIES);
|
||||
exec("cp -R ".AirtimeInstall::GetUtilsSrcDir()." ".AirtimeInstall::CONF_DIR_BINARIES);
|
||||
}
|
||||
|
||||
public static function CreateSymlinksToUtils()
|
||||
{
|
||||
echo "* Installing airtime-log".PHP_EOL;
|
||||
$dir = AirtimeInstall::CONF_DIR_BINARIES."/utils/airtime-log";
|
||||
copy(AirtimeInstall::GetUtilsSrcDir()."/airtime-log.php", AirtimeInstall::CONF_DIR_BINARIES."/utils/airtime-log.php");
|
||||
|
||||
exec("ln -s $dir /usr/bin/airtime-log");
|
||||
}
|
||||
|
||||
public static function SetDefaultStreamSetting()
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
echo "* Setting up default stream setting".PHP_EOL;
|
||||
$sql = "INSERT INTO cc_pref(keystr, valstr) VALUES('stream_type', 'ogg, mp3');
|
||||
INSERT INTO cc_pref(keystr, valstr) VALUES('stream_bitrate', '24, 32, 48, 64, 96, 128, 160, 192, 224, 256, 320');
|
||||
INSERT INTO cc_pref(keystr, valstr) VALUES('num_of_streams', '3');
|
||||
INSERT INTO cc_pref(keystr, valstr) VALUES('max_bitrate', '128');
|
||||
INSERT INTO cc_pref(keystr, valstr) VALUES('plan_level', 'disabled');
|
||||
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('output_sound_device', 'false', 'boolean');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('icecast_vorbis_metadata', 'false', 'boolean');
|
||||
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_output', 'icecast', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_type', 'ogg', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_bitrate', '128', 'integer');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_host', '127.0.0.1', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_port', '8000', 'integer');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_user', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_pass', 'hackme', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_mount', 'airtime_128', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_url', 'http://airtime.sourcefabric.org', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_description', 'Airtime Radio! Stream #1', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_genre', 'genre', 'string');
|
||||
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_output', 'disabled', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_type', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_bitrate', '', 'integer');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_host', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_port', '', 'integer');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_user', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_pass', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_mount', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_url', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_description', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_genre', '', 'string');
|
||||
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_output', 'disabled', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_type', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_bitrate', '', 'integer');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_host', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_port', '', 'integer');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_user', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_pass', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_mount', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_url', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_description', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_genre', '', 'string');";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function BypassMigrations($dir, $version)
|
||||
{
|
||||
$appDir = AirtimeInstall::GetAirtimeSrcDir();
|
||||
$command = "php $appDir/library/doctrine/migrations/doctrine-migrations.phar ".
|
||||
"--configuration=$dir/../../DoctrineMigrations/migrations.xml ".
|
||||
"--db-configuration=$appDir/library/doctrine/migrations/migrations-db.php ".
|
||||
"--no-interaction --add migrations:version $version";
|
||||
system($command);
|
||||
}
|
||||
|
||||
public static function MigrateTablesToVersion($dir, $version)
|
||||
{
|
||||
$appDir = AirtimeInstall::GetAirtimeSrcDir();
|
||||
$command = "php $appDir/library/doctrine/migrations/doctrine-migrations.phar ".
|
||||
"--configuration=$dir/../../DoctrineMigrations/migrations.xml ".
|
||||
"--db-configuration=$appDir/library/doctrine/migrations/migrations-db.php ".
|
||||
"--no-interaction migrations:migrate $version";
|
||||
system($command);
|
||||
}
|
||||
|
||||
public static function GetAirtimeSrcDir()
|
||||
{
|
||||
return __DIR__."/../../../airtime_mvc";
|
||||
}
|
||||
|
||||
public static function DbTableExists($p_name)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT * FROM ".$p_name;
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static function GetOldLiquidsoapCfgAndUpdate(){
|
||||
global $CC_DBC;
|
||||
echo "* Retrieving old liquidsoap configuration".PHP_EOL;
|
||||
$map = array();
|
||||
$fh = fopen("/etc/airtime/liquidsoap.cfg", 'r');
|
||||
$newConfigMap = array();
|
||||
|
||||
while(!feof($fh)){
|
||||
$line = fgets($fh);
|
||||
if(substr(trim($line), 0, 1) == '#' || trim($line) == ""){
|
||||
continue;
|
||||
}else{
|
||||
$info = explode('=', $line, 2);
|
||||
$map[trim($info[0])] = trim($info[1]);
|
||||
}
|
||||
}
|
||||
$newConfigMap['output_sound_device'] = $map['output_sound_device'];
|
||||
$newConfigMap['icecast_vorbis_metadata'] = $map['output_icecast_vorbis_metadata'];
|
||||
$newConfigMap['log_file'] = $map['log_file'];
|
||||
|
||||
$count = 1;
|
||||
if( $map['output_icecast_vorbis'] == 'true'){
|
||||
$newConfigMap['s'.$count.'_output'] = 'icecast';
|
||||
$newConfigMap['s'.$count.'_host'] = $map['icecast_host'];
|
||||
$newConfigMap['s'.$count.'_port'] = $map['icecast_port'];
|
||||
$newConfigMap['s'.$count.'_pass'] = $map['icecast_pass'];
|
||||
$newConfigMap['s'.$count.'_mount'] = $map['mount_point_vorbis'];
|
||||
$newConfigMap['s'.$count.'_url'] = $map['icecast_url'];
|
||||
$newConfigMap['s'.$count.'_description'] = $map['icecast_description'];
|
||||
$newConfigMap['s'.$count.'_genre'] = $map['icecast_genre'];
|
||||
$newConfigMap['s'.$count.'_type'] = "ogg";
|
||||
$newConfigMap['s'.$count.'_bitrate'] = "128";
|
||||
$count++;
|
||||
}
|
||||
if($map['output_icecast_mp3'] == 'true'){
|
||||
$newConfigMap['s'.$count.'_output'] = 'icecast';
|
||||
$newConfigMap['s'.$count.'_host'] = $map['icecast_host'];
|
||||
$newConfigMap['s'.$count.'_port'] = $map['icecast_port'];
|
||||
$newConfigMap['s'.$count.'_pass'] = $map['icecast_pass'];
|
||||
$newConfigMap['s'.$count.'_mount'] = $map['mount_point_mp3'];
|
||||
$newConfigMap['s'.$count.'_url'] = $map['icecast_url'];
|
||||
$newConfigMap['s'.$count.'_description'] = $map['icecast_description'];
|
||||
$newConfigMap['s'.$count.'_genre'] = $map['icecast_genre'];
|
||||
$newConfigMap['s'.$count.'_type'] = "mp3";
|
||||
$newConfigMap['s'.$count.'_bitrate'] = "128";
|
||||
$count++;
|
||||
}
|
||||
if($map['output_shoutcast'] == 'true'){
|
||||
$newConfigMap['s'.$count.'_output'] = 'shoutcast';
|
||||
$newConfigMap['s'.$count.'_host'] = $map['shoutcast_host'];
|
||||
$newConfigMap['s'.$count.'_port'] = $map['shoutcast_port'];
|
||||
$newConfigMap['s'.$count.'_pass'] = $map['shoutcast_pass'];
|
||||
$newConfigMap['s'.$count.'_url'] = $map['shoutcast_url'];
|
||||
$newConfigMap['s'.$count.'_genre'] = $map['shoutcast_genre'];
|
||||
$newConfigMap['s'.$count.'_type'] = "mp3";
|
||||
$newConfigMap['s'.$count.'_bitrate'] = "128";
|
||||
$count++;
|
||||
}
|
||||
|
||||
$sql = "";
|
||||
foreach( $newConfigMap as $key=>$val){
|
||||
if(substr($val, 0, 1) == '"' && substr($val, strlen($val)-1,1)){
|
||||
$val = ltrim($val, '"');
|
||||
$val = rtrim($val, '"');
|
||||
}
|
||||
$sql .= "UPDATE cc_stream_setting SET value='$val' WHERE keyname='$key';";
|
||||
}
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class Airtime200Upgrade{
|
||||
|
||||
public static function connectToDatabase(){
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
|
||||
$values = parse_ini_file('/etc/airtime/airtime.conf', true);
|
||||
|
||||
// Database config
|
||||
$CC_CONFIG['dsn']['username'] = $values['database']['dbuser'];
|
||||
$CC_CONFIG['dsn']['password'] = $values['database']['dbpass'];
|
||||
$CC_CONFIG['dsn']['hostspec'] = $values['database']['host'];
|
||||
$CC_CONFIG['dsn']['phptype'] = 'pgsql';
|
||||
$CC_CONFIG['dsn']['database'] = $values['database']['dbname'];
|
||||
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], FALSE);
|
||||
}
|
||||
|
||||
public static function InstallAirtimePhpServerCode($phpDir)
|
||||
{
|
||||
|
||||
$AIRTIME_SRC = realpath(__DIR__.'/../../../airtime_mvc');
|
||||
|
||||
// delete old files
|
||||
exec("rm -rf ".$phpDir);
|
||||
echo "* Installing PHP code to ".$phpDir.PHP_EOL;
|
||||
exec("mkdir -p ".$phpDir);
|
||||
exec("cp -R ".$AIRTIME_SRC."/* ".$phpDir);
|
||||
}
|
||||
|
||||
public static function RemoveOldMonitFile(){
|
||||
unlink("/etc/monit/conf.d/airtime-monit.cfg");
|
||||
}
|
||||
}
|
||||
|
||||
class ConvertToUtc{
|
||||
|
||||
public static function setPhpDefaultTimeZoneToSystemTimezone(){
|
||||
//we can get the default system timezone on debian/ubuntu by reading "/etc/timezone"
|
||||
$filename = "/etc/timezone";
|
||||
$handle = fopen($filename, "r");
|
||||
$contents = trim(fread($handle, filesize($filename)));
|
||||
echo "System timezone detected as: $contents".PHP_EOL;
|
||||
fclose($handle);
|
||||
|
||||
date_default_timezone_set($contents);
|
||||
}
|
||||
|
||||
public static function convert_cc_playlist(){
|
||||
/* cc_playlist has a field that keeps track of when the playlist was last modified. */
|
||||
$playlists = CcPlaylistQuery::create()->find();
|
||||
|
||||
foreach ($playlists as $pl){
|
||||
$dt = new DateTime($pl->getDbMtime(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$pl->setDbMtime($dt);
|
||||
|
||||
$pl->save();
|
||||
}
|
||||
}
|
||||
|
||||
public static function convert_cc_schedule(){
|
||||
/* cc_schedule has start and end fields that need to be changed to UTC. */
|
||||
$schedules = CcScheduleQuery::create()->find();
|
||||
|
||||
foreach ($schedules as $s){
|
||||
$dt = new DateTime($s->getDbStarts(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$s->setDbStarts($dt);
|
||||
|
||||
$dt = new DateTime($s->getDbEnds(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$s->setDbEnds($dt);
|
||||
|
||||
$s->save();
|
||||
}
|
||||
}
|
||||
|
||||
public static function convert_cc_show_days(){
|
||||
/* cc_show_days has first_show, last_show and start_time fields that need to be changed to UTC. */
|
||||
$showDays = CcShowDaysQuery::create()->find();
|
||||
|
||||
foreach ($showDays as $sd){
|
||||
$dt = new DateTime($sd->getDbFirstShow()." ".$sd->getDbStartTime(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$sd->setDbFirstShow($dt->format("Y-m-d"));
|
||||
$sd->setDbStartTime($dt->format("H:i:s"));
|
||||
|
||||
$dt = new DateTime($sd->getDbLastShow()." ".$sd->getDbStartTime(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$sd->setDbLastShow($dt->format("Y-m-d"));
|
||||
|
||||
$sd->save();
|
||||
}
|
||||
}
|
||||
|
||||
public static function convert_cc_show_instances(){
|
||||
/* convert_cc_show_instances has starts and ends fields that need to be changed to UTC. */
|
||||
$showInstances = CcShowInstancesQuery::create()->find();
|
||||
|
||||
foreach ($showInstances as $si){
|
||||
$dt = new DateTime($si->getDbStarts(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$si->setDbStarts($dt);
|
||||
|
||||
$dt = new DateTime($si->getDbEnds(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$si->setDbEnds($dt);
|
||||
|
||||
$si->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AirtimeIni200{
|
||||
|
||||
const CONF_FILE_AIRTIME = "/etc/airtime/airtime.conf";
|
||||
const CONF_FILE_PYPO = "/etc/airtime/pypo.cfg";
|
||||
const CONF_FILE_RECORDER = "/etc/airtime/recorder.cfg";
|
||||
const CONF_FILE_LIQUIDSOAP = "/etc/airtime/liquidsoap.cfg";
|
||||
const CONF_FILE_MEDIAMONITOR = "/etc/airtime/media-monitor.cfg";
|
||||
const CONF_FILE_API_CLIENT = "/etc/airtime/api_client.cfg";
|
||||
|
||||
const CONF_PYPO_GRP = "pypo";
|
||||
const CONF_WWW_DATA_GRP = "www-data";
|
||||
|
||||
/**
|
||||
* This function updates an INI style config file.
|
||||
*
|
||||
* A property and the value the property should be changed to are
|
||||
* supplied. If the property is not found, then no changes are made.
|
||||
*
|
||||
* @param string $p_filename
|
||||
* The path the to the file.
|
||||
* @param string $p_property
|
||||
* The property to look for in order to change its value.
|
||||
* @param string $p_value
|
||||
* The value the property should be changed to.
|
||||
*
|
||||
*/
|
||||
public static function UpdateIniValue($p_filename, $p_property, $p_value)
|
||||
{
|
||||
$lines = file($p_filename);
|
||||
$n=count($lines);
|
||||
foreach ($lines as &$line) {
|
||||
if ($line[0] != "#"){
|
||||
$key_value = explode("=", $line);
|
||||
$key = trim($key_value[0]);
|
||||
|
||||
if ($key == $p_property){
|
||||
$line = "$p_property = $p_value".PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fp=fopen($p_filename, 'w');
|
||||
for($i=0; $i<$n; $i++){
|
||||
fwrite($fp, $lines[$i]);
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
public static function ReadPythonConfig($p_filename)
|
||||
{
|
||||
$values = array();
|
||||
|
||||
$fh = fopen($p_filename, 'r');
|
||||
|
||||
while(!feof($fh)){
|
||||
$line = fgets($fh);
|
||||
if(substr(trim($line), 0, 1) == '#' || trim($line) == ""){
|
||||
continue;
|
||||
}else{
|
||||
$info = explode('=', $line, 2);
|
||||
$values[trim($info[0])] = trim($info[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
public static function MergeConfigFiles($configFiles, $suffix) {
|
||||
foreach ($configFiles as $conf) {
|
||||
// we want to use new liquidsoap.cfg so don't merge
|
||||
// also for monit
|
||||
if( $conf == AirtimeIni200::CONF_FILE_LIQUIDSOAP){
|
||||
continue;
|
||||
}
|
||||
if (file_exists("$conf$suffix.bak")) {
|
||||
|
||||
if($conf === AirtimeIni200::CONF_FILE_AIRTIME) {
|
||||
// Parse with sections
|
||||
$newSettings = parse_ini_file($conf, true);
|
||||
$oldSettings = parse_ini_file("$conf$suffix.bak", true);
|
||||
}
|
||||
else {
|
||||
$newSettings = AirtimeIni200::ReadPythonConfig($conf);
|
||||
$oldSettings = AirtimeIni200::ReadPythonConfig("$conf$suffix.bak");
|
||||
}
|
||||
|
||||
$settings = array_keys($newSettings);
|
||||
|
||||
foreach($settings as $section) {
|
||||
if(isset($oldSettings[$section])) {
|
||||
if(is_array($oldSettings[$section])) {
|
||||
$sectionKeys = array_keys($newSettings[$section]);
|
||||
foreach($sectionKeys as $sectionKey) {
|
||||
// skip airtim_dir as we want to use new value
|
||||
if($sectionKey != "airtime_dir"){
|
||||
if(isset($oldSettings[$section][$sectionKey])) {
|
||||
AirtimeIni200::UpdateIniValue($conf, $sectionKey, $oldSettings[$section][$sectionKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
AirtimeIni200::UpdateIniValue($conf, $section, $oldSettings[$section]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Re: http://dev.sourcefabric.org/browse/CC-2797
|
||||
* We don't want config files to be world-readable so we
|
||||
* set the strictest permissions possible. */
|
||||
public static function changeConfigFilePermissions(){
|
||||
if (!self::ChangeFileOwnerGroupMod(AirtimeIni200::CONF_FILE_AIRTIME, self::CONF_WWW_DATA_GRP)){
|
||||
echo "Could not set ownership of api_client.cfg to 'pypo'. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!self::ChangeFileOwnerGroupMod(AirtimeIni200::CONF_FILE_API_CLIENT, self::CONF_PYPO_GRP)){
|
||||
echo "Could not set ownership of api_client.cfg to 'pypo'. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!self::ChangeFileOwnerGroupMod(AirtimeIni200::CONF_FILE_PYPO, self::CONF_PYPO_GRP)){
|
||||
echo "Could not set ownership of pypo.cfg to 'pypo'. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!self::ChangeFileOwnerGroupMod(AirtimeIni200::CONF_FILE_RECORDER, self::CONF_PYPO_GRP)){
|
||||
echo "Could not set ownership of recorder.cfg to 'pypo'. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!self::ChangeFileOwnerGroupMod(AirtimeIni200::CONF_FILE_LIQUIDSOAP, self::CONF_PYPO_GRP)){
|
||||
echo "Could not set ownership of liquidsoap.cfg to 'pypo'. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!self::ChangeFileOwnerGroupMod(AirtimeIni200::CONF_FILE_MEDIAMONITOR, self::CONF_PYPO_GRP)){
|
||||
echo "Could not set ownership of media-monitor.cfg to 'pypo'. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static function ChangeFileOwnerGroupMod($filename, $user){
|
||||
return (chown($filename, $user) &&
|
||||
chgrp($filename, $user) &&
|
||||
chmod($filename, 0640));
|
||||
}
|
||||
|
||||
public static function upgradeConfigFiles(){
|
||||
|
||||
$configFiles = array(AirtimeIni200::CONF_FILE_AIRTIME,
|
||||
AirtimeIni200::CONF_FILE_PYPO,
|
||||
AirtimeIni200::CONF_FILE_RECORDER,
|
||||
AirtimeIni200::CONF_FILE_LIQUIDSOAP,
|
||||
AirtimeIni200::CONF_FILE_MEDIAMONITOR,
|
||||
AirtimeIni200::CONF_FILE_API_CLIENT);
|
||||
|
||||
// Backup the config files
|
||||
$suffix = date("Ymdhis")."-2.0.0";
|
||||
foreach ($configFiles as $conf) {
|
||||
// do not back up monit cfg
|
||||
if (file_exists($conf)) {
|
||||
echo "Backing up $conf to $conf$suffix.bak".PHP_EOL;
|
||||
//copy($conf, $conf.$suffix.".bak");
|
||||
exec("cp -p $conf $conf$suffix.bak"); //use cli version to preserve file attributes
|
||||
}
|
||||
}
|
||||
|
||||
$default_suffix = "200";
|
||||
AirtimeIni200::CreateIniFiles($default_suffix);
|
||||
AirtimeIni200::MergeConfigFiles($configFiles, $suffix);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function creates the /etc/airtime configuration folder
|
||||
* and copies the default config files to it.
|
||||
*/
|
||||
public static function CreateIniFiles($suffix)
|
||||
{
|
||||
if (!file_exists("/etc/airtime/")){
|
||||
if (!mkdir("/etc/airtime/", 0755, true)){
|
||||
echo "Could not create /etc/airtime/ directory. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!copy(__DIR__."/airtime.conf.$suffix", AirtimeIni200::CONF_FILE_AIRTIME)){
|
||||
echo "Could not copy airtime.conf to /etc/airtime/. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!copy(__DIR__."/pypo.cfg.$suffix", AirtimeIni200::CONF_FILE_PYPO)){
|
||||
echo "Could not copy pypo.cfg to /etc/airtime/. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!copy(__DIR__."/recorder.cfg.$suffix", AirtimeIni200::CONF_FILE_RECORDER)){
|
||||
echo "Could not copy recorder.cfg to /etc/airtime/. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
/*if (!copy(__DIR__."/liquidsoap.cfg.$suffix", AirtimeIni200::CONF_FILE_LIQUIDSOAP)){
|
||||
echo "Could not copy liquidsoap.cfg to /etc/airtime/. Exiting.";
|
||||
exit(1);
|
||||
}*/
|
||||
if (!copy(__DIR__."/api_client.cfg.$suffix", AirtimeIni200::CONF_FILE_API_CLIENT)){
|
||||
echo "Could not copy airtime-monit.cfg to /etc/monit/conf.d/. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Airtime200Upgrade::connectToDatabase();
|
||||
AirtimeInstall::SetDefaultTimezone();
|
||||
|
||||
AirtimeInstall::InstallBinaries();
|
||||
AirtimeInstall::CreateSymlinksToUtils();
|
||||
|
||||
/* Airtime 2.0.0 starts interpreting all database times in UTC format. Prior to this, all the times
|
||||
* were stored using the local time zone. Let's convert to UTC time. */
|
||||
ConvertToUtc::setPhpDefaultTimeZoneToSystemTimezone();
|
||||
ConvertToUtc::convert_cc_playlist();
|
||||
ConvertToUtc::convert_cc_schedule();
|
||||
ConvertToUtc::convert_cc_show_days();
|
||||
ConvertToUtc::convert_cc_show_instances();
|
||||
|
||||
// merging/updating config files
|
||||
echo "* Updating configFiles\n";
|
||||
AirtimeIni200::changeConfigFilePermissions();
|
||||
AirtimeIni200::upgradeConfigFiles();
|
||||
|
||||
$values = parse_ini_file(AirtimeIni200::CONF_FILE_AIRTIME, true);
|
||||
$phpDir = $values['general']['airtime_dir'];
|
||||
Airtime200Upgrade::InstallAirtimePhpServerCode($phpDir);
|
||||
|
||||
if(AirtimeInstall::DbTableExists('doctrine_migration_versions') === false) {
|
||||
$migrations = array('20110312121200', '20110331111708', '20110402164819', '20110406182005', '20110629143017', '20110711161043', '20110713161043');
|
||||
foreach($migrations as $migration) {
|
||||
AirtimeInstall::BypassMigrations(__DIR__, $migration);
|
||||
}
|
||||
}
|
||||
|
||||
AirtimeInstall::MigrateTablesToVersion(__DIR__, '20110925171256');
|
||||
|
||||
AirtimeInstall::SetDefaultStreamSetting();
|
||||
|
||||
AirtimeInstall::GetOldLiquidsoapCfgAndUpdate();
|
||||
|
||||
AirtimeUpgrade::RemoveOldMonitFile();
|
||||
|
||||
// restart monit
|
||||
exec("service monit restart");
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once('DB.php');
|
||||
|
||||
/* These are helper functions that are common to each upgrade such as
|
||||
* creating connections to a database, backing up config files etc.
|
||||
*/
|
||||
|
@ -29,29 +27,28 @@ class UpgradeCommon{
|
|||
|
||||
public static function connectToDatabase($p_exitOnError = true)
|
||||
{
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
$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;
|
||||
try {
|
||||
$con = Propel::getConnection();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage().PHP_EOL;
|
||||
echo "Database connection problem.".PHP_EOL;
|
||||
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
|
||||
" with corresponding permissions.".PHP_EOL;
|
||||
echo "Check if database exists with corresponding permissions.".PHP_EOL;
|
||||
if ($p_exitOnError) {
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static function DbTableExists($p_name)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT * FROM ".$p_name;
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
$con = Propel::getConnection();
|
||||
try {
|
||||
$sql = "SELECT * FROM ".$p_name." LIMIT 1";
|
||||
$con->query($sql);
|
||||
} catch (PDOException $e){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -239,11 +236,12 @@ class UpgradeCommon{
|
|||
}
|
||||
|
||||
public static function queryDb($p_sql){
|
||||
global $CC_DBC;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$result = $CC_DBC->getRow($p_sql, $fetchmode=DB_FETCHMODE_ASSOC);
|
||||
if (PEAR::isError($result)) {
|
||||
echo "Error executing $sql. Exiting.";
|
||||
try {
|
||||
$result = $con->exec($p_sql);
|
||||
} catch (Exception $e) {
|
||||
echo "Error executing $p_sql. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,586 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Airtime
|
||||
* @subpackage StorageServer
|
||||
* @copyright 2010 Sourcefabric O.P.S.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
*/
|
||||
|
||||
set_include_path(__DIR__.'/../../../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
|
||||
set_include_path(__DIR__.'/../../../airtime_mvc/library/pear' . PATH_SEPARATOR . get_include_path());
|
||||
set_include_path(__DIR__.'/../../../airtime_mvc/application/models' . PATH_SEPARATOR . get_include_path());
|
||||
set_include_path(__DIR__.'/../../../airtime_mvc/application/configs' . PATH_SEPARATOR . get_include_path());
|
||||
require_once 'conf.php';
|
||||
require_once 'DB.php';
|
||||
|
||||
require_once 'propel/runtime/lib/Propel.php';
|
||||
Propel::init(__DIR__."/../../../airtime_mvc/application/configs/airtime-conf.php");
|
||||
|
||||
class AirtimeInstall{
|
||||
const CONF_DIR_BINARIES = "/usr/lib/airtime";
|
||||
|
||||
public static function SetDefaultTimezone()
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
$defaultTimezone = date_default_timezone_get();
|
||||
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', '$defaultTimezone')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function GetUtilsSrcDir()
|
||||
{
|
||||
return __DIR__."/../../../utils";
|
||||
}
|
||||
|
||||
public static function InstallBinaries()
|
||||
{
|
||||
echo "* Installing binaries to ".AirtimeInstall::CONF_DIR_BINARIES.PHP_EOL;
|
||||
exec("mkdir -p ".AirtimeInstall::CONF_DIR_BINARIES);
|
||||
exec("cp -R ".AirtimeInstall::GetUtilsSrcDir()." ".AirtimeInstall::CONF_DIR_BINARIES);
|
||||
}
|
||||
|
||||
public static function CreateSymlinksToUtils()
|
||||
{
|
||||
echo "* Installing airtime-log".PHP_EOL;
|
||||
$dir = AirtimeInstall::CONF_DIR_BINARIES."/utils/airtime-log";
|
||||
copy(AirtimeInstall::GetUtilsSrcDir()."/airtime-log.php", AirtimeInstall::CONF_DIR_BINARIES."/utils/airtime-log.php");
|
||||
|
||||
exec("ln -s $dir /usr/bin/airtime-log");
|
||||
}
|
||||
|
||||
public static function SetDefaultStreamSetting()
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
echo "* Setting up default stream setting".PHP_EOL;
|
||||
$sql = "INSERT INTO cc_pref(keystr, valstr) VALUES('stream_type', 'ogg, mp3');
|
||||
INSERT INTO cc_pref(keystr, valstr) VALUES('stream_bitrate', '24, 32, 48, 64, 96, 128, 160, 192, 224, 256, 320');
|
||||
INSERT INTO cc_pref(keystr, valstr) VALUES('num_of_streams', '3');
|
||||
INSERT INTO cc_pref(keystr, valstr) VALUES('max_bitrate', '128');
|
||||
INSERT INTO cc_pref(keystr, valstr) VALUES('plan_level', 'disabled');
|
||||
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('output_sound_device', 'false', 'boolean');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('icecast_vorbis_metadata', 'false', 'boolean');
|
||||
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_output', 'icecast', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_type', 'ogg', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_bitrate', '128', 'integer');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_host', '127.0.0.1', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_port', '8000', 'integer');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_user', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_pass', 'hackme', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_mount', 'airtime_128', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_url', 'http://airtime.sourcefabric.org', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_description', 'Airtime Radio! Stream #1', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_genre', 'genre', 'string');
|
||||
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_output', 'disabled', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_type', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_bitrate', '', 'integer');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_host', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_port', '', 'integer');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_user', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_pass', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_mount', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_url', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_description', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_genre', '', 'string');
|
||||
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_output', 'disabled', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_type', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_bitrate', '', 'integer');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_host', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_port', '', 'integer');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_user', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_pass', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_mount', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_url', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_description', '', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_genre', '', 'string');";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function BypassMigrations($dir, $version)
|
||||
{
|
||||
$appDir = AirtimeInstall::GetAirtimeSrcDir();
|
||||
$command = "php $appDir/library/doctrine/migrations/doctrine-migrations.phar ".
|
||||
"--configuration=$dir/../../DoctrineMigrations/migrations.xml ".
|
||||
"--db-configuration=$appDir/library/doctrine/migrations/migrations-db.php ".
|
||||
"--no-interaction --add migrations:version $version";
|
||||
system($command);
|
||||
}
|
||||
|
||||
public static function MigrateTablesToVersion($dir, $version)
|
||||
{
|
||||
$appDir = AirtimeInstall::GetAirtimeSrcDir();
|
||||
$command = "php $appDir/library/doctrine/migrations/doctrine-migrations.phar ".
|
||||
"--configuration=$dir/../../DoctrineMigrations/migrations.xml ".
|
||||
"--db-configuration=$appDir/library/doctrine/migrations/migrations-db.php ".
|
||||
"--no-interaction migrations:migrate $version";
|
||||
system($command);
|
||||
}
|
||||
|
||||
public static function GetAirtimeSrcDir()
|
||||
{
|
||||
return __DIR__."/../../../airtime_mvc";
|
||||
}
|
||||
|
||||
public static function DbTableExists($p_name)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT * FROM ".$p_name;
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static function GetOldLiquidsoapCfgAndUpdate(){
|
||||
global $CC_DBC;
|
||||
echo "* Retrieving old liquidsoap configuration".PHP_EOL;
|
||||
$map = array();
|
||||
$fh = fopen("/etc/airtime/liquidsoap.cfg", 'r');
|
||||
$newConfigMap = array();
|
||||
|
||||
while(!feof($fh)){
|
||||
$line = fgets($fh);
|
||||
if(substr(trim($line), 0, 1) == '#' || trim($line) == ""){
|
||||
continue;
|
||||
}else{
|
||||
$info = explode('=', $line, 2);
|
||||
$map[trim($info[0])] = trim($info[1]);
|
||||
}
|
||||
}
|
||||
$newConfigMap['output_sound_device'] = $map['output_sound_device'];
|
||||
$newConfigMap['icecast_vorbis_metadata'] = $map['output_icecast_vorbis_metadata'];
|
||||
$newConfigMap['log_file'] = $map['log_file'];
|
||||
|
||||
$count = 1;
|
||||
if( $map['output_icecast_vorbis'] == 'true'){
|
||||
$newConfigMap['s'.$count.'_output'] = 'icecast';
|
||||
$newConfigMap['s'.$count.'_host'] = $map['icecast_host'];
|
||||
$newConfigMap['s'.$count.'_port'] = $map['icecast_port'];
|
||||
$newConfigMap['s'.$count.'_pass'] = $map['icecast_pass'];
|
||||
$newConfigMap['s'.$count.'_mount'] = $map['mount_point_vorbis'];
|
||||
$newConfigMap['s'.$count.'_url'] = $map['icecast_url'];
|
||||
$newConfigMap['s'.$count.'_description'] = $map['icecast_description'];
|
||||
$newConfigMap['s'.$count.'_genre'] = $map['icecast_genre'];
|
||||
$newConfigMap['s'.$count.'_type'] = "ogg";
|
||||
$newConfigMap['s'.$count.'_bitrate'] = "128";
|
||||
$count++;
|
||||
}
|
||||
if($map['output_icecast_mp3'] == 'true'){
|
||||
$newConfigMap['s'.$count.'_output'] = 'icecast';
|
||||
$newConfigMap['s'.$count.'_host'] = $map['icecast_host'];
|
||||
$newConfigMap['s'.$count.'_port'] = $map['icecast_port'];
|
||||
$newConfigMap['s'.$count.'_pass'] = $map['icecast_pass'];
|
||||
$newConfigMap['s'.$count.'_mount'] = $map['mount_point_mp3'];
|
||||
$newConfigMap['s'.$count.'_url'] = $map['icecast_url'];
|
||||
$newConfigMap['s'.$count.'_description'] = $map['icecast_description'];
|
||||
$newConfigMap['s'.$count.'_genre'] = $map['icecast_genre'];
|
||||
$newConfigMap['s'.$count.'_type'] = "mp3";
|
||||
$newConfigMap['s'.$count.'_bitrate'] = "128";
|
||||
$count++;
|
||||
}
|
||||
if($map['output_shoutcast'] == 'true'){
|
||||
$newConfigMap['s'.$count.'_output'] = 'shoutcast';
|
||||
$newConfigMap['s'.$count.'_host'] = $map['shoutcast_host'];
|
||||
$newConfigMap['s'.$count.'_port'] = $map['shoutcast_port'];
|
||||
$newConfigMap['s'.$count.'_pass'] = $map['shoutcast_pass'];
|
||||
$newConfigMap['s'.$count.'_url'] = $map['shoutcast_url'];
|
||||
$newConfigMap['s'.$count.'_genre'] = $map['shoutcast_genre'];
|
||||
$newConfigMap['s'.$count.'_type'] = "mp3";
|
||||
$newConfigMap['s'.$count.'_bitrate'] = "128";
|
||||
$count++;
|
||||
}
|
||||
|
||||
$sql = "";
|
||||
foreach( $newConfigMap as $key=>$val){
|
||||
if(substr($val, 0, 1) == '"' && substr($val, strlen($val)-1,1)){
|
||||
$val = ltrim($val, '"');
|
||||
$val = rtrim($val, '"');
|
||||
}
|
||||
$sql .= "UPDATE cc_stream_setting SET value='$val' WHERE keyname='$key';";
|
||||
}
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class Airtime200Upgrade{
|
||||
|
||||
public static function connectToDatabase(){
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
|
||||
$values = parse_ini_file('/etc/airtime/airtime.conf', true);
|
||||
|
||||
// Database config
|
||||
$CC_CONFIG['dsn']['username'] = $values['database']['dbuser'];
|
||||
$CC_CONFIG['dsn']['password'] = $values['database']['dbpass'];
|
||||
$CC_CONFIG['dsn']['hostspec'] = $values['database']['host'];
|
||||
$CC_CONFIG['dsn']['phptype'] = 'pgsql';
|
||||
$CC_CONFIG['dsn']['database'] = $values['database']['dbname'];
|
||||
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], FALSE);
|
||||
}
|
||||
|
||||
public static function InstallAirtimePhpServerCode($phpDir)
|
||||
{
|
||||
|
||||
$AIRTIME_SRC = realpath(__DIR__.'/../../../airtime_mvc');
|
||||
|
||||
// delete old files
|
||||
exec("rm -rf ".$phpDir);
|
||||
echo "* Installing PHP code to ".$phpDir.PHP_EOL;
|
||||
exec("mkdir -p ".$phpDir);
|
||||
exec("cp -R ".$AIRTIME_SRC."/* ".$phpDir);
|
||||
}
|
||||
|
||||
public static function RemoveOldMonitFile(){
|
||||
unlink("/etc/monit/conf.d/airtime-monit.cfg");
|
||||
}
|
||||
}
|
||||
|
||||
class ConvertToUtc{
|
||||
|
||||
public static function setPhpDefaultTimeZoneToSystemTimezone(){
|
||||
//we can get the default system timezone on debian/ubuntu by reading "/etc/timezone"
|
||||
$filename = "/etc/timezone";
|
||||
$handle = fopen($filename, "r");
|
||||
$contents = trim(fread($handle, filesize($filename)));
|
||||
echo "System timezone detected as: $contents".PHP_EOL;
|
||||
fclose($handle);
|
||||
|
||||
date_default_timezone_set($contents);
|
||||
}
|
||||
|
||||
public static function convert_cc_playlist(){
|
||||
/* cc_playlist has a field that keeps track of when the playlist was last modified. */
|
||||
$playlists = CcPlaylistQuery::create()->find();
|
||||
|
||||
foreach ($playlists as $pl){
|
||||
$dt = new DateTime($pl->getDbMtime(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$pl->setDbMtime($dt);
|
||||
|
||||
$pl->save();
|
||||
}
|
||||
}
|
||||
|
||||
public static function convert_cc_schedule(){
|
||||
/* cc_schedule has start and end fields that need to be changed to UTC. */
|
||||
$schedules = CcScheduleQuery::create()->find();
|
||||
|
||||
foreach ($schedules as $s){
|
||||
$dt = new DateTime($s->getDbStarts(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$s->setDbStarts($dt);
|
||||
|
||||
$dt = new DateTime($s->getDbEnds(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$s->setDbEnds($dt);
|
||||
|
||||
$s->save();
|
||||
}
|
||||
}
|
||||
|
||||
public static function convert_cc_show_days(){
|
||||
/* cc_show_days has first_show, last_show and start_time fields that need to be changed to UTC. */
|
||||
$showDays = CcShowDaysQuery::create()->find();
|
||||
|
||||
foreach ($showDays as $sd){
|
||||
$dt = new DateTime($sd->getDbFirstShow()." ".$sd->getDbStartTime(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$sd->setDbFirstShow($dt->format("Y-m-d"));
|
||||
$sd->setDbStartTime($dt->format("H:i:s"));
|
||||
|
||||
$dt = new DateTime($sd->getDbLastShow()." ".$sd->getDbStartTime(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$sd->setDbLastShow($dt->format("Y-m-d"));
|
||||
|
||||
$sd->save();
|
||||
}
|
||||
}
|
||||
|
||||
public static function convert_cc_show_instances(){
|
||||
/* convert_cc_show_instances has starts and ends fields that need to be changed to UTC. */
|
||||
$showInstances = CcShowInstancesQuery::create()->find();
|
||||
|
||||
foreach ($showInstances as $si){
|
||||
$dt = new DateTime($si->getDbStarts(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$si->setDbStarts($dt);
|
||||
|
||||
$dt = new DateTime($si->getDbEnds(), new DateTimeZone(date_default_timezone_get()));
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
$si->setDbEnds($dt);
|
||||
|
||||
$si->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AirtimeIni200{
|
||||
|
||||
const CONF_FILE_AIRTIME = "/etc/airtime/airtime.conf";
|
||||
const CONF_FILE_PYPO = "/etc/airtime/pypo.cfg";
|
||||
const CONF_FILE_RECORDER = "/etc/airtime/recorder.cfg";
|
||||
const CONF_FILE_LIQUIDSOAP = "/etc/airtime/liquidsoap.cfg";
|
||||
const CONF_FILE_MEDIAMONITOR = "/etc/airtime/media-monitor.cfg";
|
||||
const CONF_FILE_API_CLIENT = "/etc/airtime/api_client.cfg";
|
||||
|
||||
const CONF_PYPO_GRP = "pypo";
|
||||
const CONF_WWW_DATA_GRP = "www-data";
|
||||
|
||||
/**
|
||||
* This function updates an INI style config file.
|
||||
*
|
||||
* A property and the value the property should be changed to are
|
||||
* supplied. If the property is not found, then no changes are made.
|
||||
*
|
||||
* @param string $p_filename
|
||||
* The path the to the file.
|
||||
* @param string $p_property
|
||||
* The property to look for in order to change its value.
|
||||
* @param string $p_value
|
||||
* The value the property should be changed to.
|
||||
*
|
||||
*/
|
||||
public static function UpdateIniValue($p_filename, $p_property, $p_value)
|
||||
{
|
||||
$lines = file($p_filename);
|
||||
$n=count($lines);
|
||||
foreach ($lines as &$line) {
|
||||
if ($line[0] != "#"){
|
||||
$key_value = explode("=", $line);
|
||||
$key = trim($key_value[0]);
|
||||
|
||||
if ($key == $p_property){
|
||||
$line = "$p_property = $p_value".PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fp=fopen($p_filename, 'w');
|
||||
for($i=0; $i<$n; $i++){
|
||||
fwrite($fp, $lines[$i]);
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
public static function ReadPythonConfig($p_filename)
|
||||
{
|
||||
$values = array();
|
||||
|
||||
$fh = fopen($p_filename, 'r');
|
||||
|
||||
while(!feof($fh)){
|
||||
$line = fgets($fh);
|
||||
if(substr(trim($line), 0, 1) == '#' || trim($line) == ""){
|
||||
continue;
|
||||
}else{
|
||||
$info = explode('=', $line, 2);
|
||||
$values[trim($info[0])] = trim($info[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
public static function MergeConfigFiles($configFiles, $suffix) {
|
||||
foreach ($configFiles as $conf) {
|
||||
// we want to use new liquidsoap.cfg so don't merge
|
||||
// also for monit
|
||||
if( $conf == AirtimeIni200::CONF_FILE_LIQUIDSOAP){
|
||||
continue;
|
||||
}
|
||||
if (file_exists("$conf$suffix.bak")) {
|
||||
|
||||
if($conf === AirtimeIni200::CONF_FILE_AIRTIME) {
|
||||
// Parse with sections
|
||||
$newSettings = parse_ini_file($conf, true);
|
||||
$oldSettings = parse_ini_file("$conf$suffix.bak", true);
|
||||
}
|
||||
else {
|
||||
$newSettings = AirtimeIni200::ReadPythonConfig($conf);
|
||||
$oldSettings = AirtimeIni200::ReadPythonConfig("$conf$suffix.bak");
|
||||
}
|
||||
|
||||
$settings = array_keys($newSettings);
|
||||
|
||||
foreach($settings as $section) {
|
||||
if(isset($oldSettings[$section])) {
|
||||
if(is_array($oldSettings[$section])) {
|
||||
$sectionKeys = array_keys($newSettings[$section]);
|
||||
foreach($sectionKeys as $sectionKey) {
|
||||
// skip airtim_dir as we want to use new value
|
||||
if($sectionKey != "airtime_dir"){
|
||||
if(isset($oldSettings[$section][$sectionKey])) {
|
||||
AirtimeIni200::UpdateIniValue($conf, $sectionKey, $oldSettings[$section][$sectionKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
AirtimeIni200::UpdateIniValue($conf, $section, $oldSettings[$section]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Re: http://dev.sourcefabric.org/browse/CC-2797
|
||||
* We don't want config files to be world-readable so we
|
||||
* set the strictest permissions possible. */
|
||||
public static function changeConfigFilePermissions(){
|
||||
if (!self::ChangeFileOwnerGroupMod(AirtimeIni200::CONF_FILE_AIRTIME, self::CONF_WWW_DATA_GRP)){
|
||||
echo "Could not set ownership of api_client.cfg to 'pypo'. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!self::ChangeFileOwnerGroupMod(AirtimeIni200::CONF_FILE_API_CLIENT, self::CONF_PYPO_GRP)){
|
||||
echo "Could not set ownership of api_client.cfg to 'pypo'. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!self::ChangeFileOwnerGroupMod(AirtimeIni200::CONF_FILE_PYPO, self::CONF_PYPO_GRP)){
|
||||
echo "Could not set ownership of pypo.cfg to 'pypo'. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!self::ChangeFileOwnerGroupMod(AirtimeIni200::CONF_FILE_RECORDER, self::CONF_PYPO_GRP)){
|
||||
echo "Could not set ownership of recorder.cfg to 'pypo'. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!self::ChangeFileOwnerGroupMod(AirtimeIni200::CONF_FILE_LIQUIDSOAP, self::CONF_PYPO_GRP)){
|
||||
echo "Could not set ownership of liquidsoap.cfg to 'pypo'. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!self::ChangeFileOwnerGroupMod(AirtimeIni200::CONF_FILE_MEDIAMONITOR, self::CONF_PYPO_GRP)){
|
||||
echo "Could not set ownership of media-monitor.cfg to 'pypo'. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static function ChangeFileOwnerGroupMod($filename, $user){
|
||||
return (chown($filename, $user) &&
|
||||
chgrp($filename, $user) &&
|
||||
chmod($filename, 0640));
|
||||
}
|
||||
|
||||
public static function upgradeConfigFiles(){
|
||||
|
||||
$configFiles = array(AirtimeIni200::CONF_FILE_AIRTIME,
|
||||
AirtimeIni200::CONF_FILE_PYPO,
|
||||
AirtimeIni200::CONF_FILE_RECORDER,
|
||||
AirtimeIni200::CONF_FILE_LIQUIDSOAP,
|
||||
AirtimeIni200::CONF_FILE_MEDIAMONITOR,
|
||||
AirtimeIni200::CONF_FILE_API_CLIENT);
|
||||
|
||||
// Backup the config files
|
||||
$suffix = date("Ymdhis")."-2.0.0";
|
||||
foreach ($configFiles as $conf) {
|
||||
// do not back up monit cfg
|
||||
if (file_exists($conf)) {
|
||||
echo "Backing up $conf to $conf$suffix.bak".PHP_EOL;
|
||||
//copy($conf, $conf.$suffix.".bak");
|
||||
exec("cp -p $conf $conf$suffix.bak"); //use cli version to preserve file attributes
|
||||
}
|
||||
}
|
||||
|
||||
$default_suffix = "200";
|
||||
AirtimeIni200::CreateIniFiles($default_suffix);
|
||||
AirtimeIni200::MergeConfigFiles($configFiles, $suffix);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function creates the /etc/airtime configuration folder
|
||||
* and copies the default config files to it.
|
||||
*/
|
||||
public static function CreateIniFiles($suffix)
|
||||
{
|
||||
if (!file_exists("/etc/airtime/")){
|
||||
if (!mkdir("/etc/airtime/", 0755, true)){
|
||||
echo "Could not create /etc/airtime/ directory. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!copy(__DIR__."/airtime.conf.$suffix", AirtimeIni200::CONF_FILE_AIRTIME)){
|
||||
echo "Could not copy airtime.conf to /etc/airtime/. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!copy(__DIR__."/pypo.cfg.$suffix", AirtimeIni200::CONF_FILE_PYPO)){
|
||||
echo "Could not copy pypo.cfg to /etc/airtime/. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
if (!copy(__DIR__."/recorder.cfg.$suffix", AirtimeIni200::CONF_FILE_RECORDER)){
|
||||
echo "Could not copy recorder.cfg to /etc/airtime/. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
/*if (!copy(__DIR__."/liquidsoap.cfg.$suffix", AirtimeIni200::CONF_FILE_LIQUIDSOAP)){
|
||||
echo "Could not copy liquidsoap.cfg to /etc/airtime/. Exiting.";
|
||||
exit(1);
|
||||
}*/
|
||||
if (!copy(__DIR__."/api_client.cfg.$suffix", AirtimeIni200::CONF_FILE_API_CLIENT)){
|
||||
echo "Could not copy airtime-monit.cfg to /etc/monit/conf.d/. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Airtime200Upgrade::connectToDatabase();
|
||||
AirtimeInstall::SetDefaultTimezone();
|
||||
|
||||
AirtimeInstall::InstallBinaries();
|
||||
AirtimeInstall::CreateSymlinksToUtils();
|
||||
|
||||
/* Airtime 2.0.0 starts interpreting all database times in UTC format. Prior to this, all the times
|
||||
* were stored using the local time zone. Let's convert to UTC time. */
|
||||
ConvertToUtc::setPhpDefaultTimeZoneToSystemTimezone();
|
||||
ConvertToUtc::convert_cc_playlist();
|
||||
ConvertToUtc::convert_cc_schedule();
|
||||
ConvertToUtc::convert_cc_show_days();
|
||||
ConvertToUtc::convert_cc_show_instances();
|
||||
|
||||
// merging/updating config files
|
||||
echo "* Updating configFiles\n";
|
||||
AirtimeIni200::changeConfigFilePermissions();
|
||||
AirtimeIni200::upgradeConfigFiles();
|
||||
|
||||
$values = parse_ini_file(AirtimeIni200::CONF_FILE_AIRTIME, true);
|
||||
$phpDir = $values['general']['airtime_dir'];
|
||||
Airtime200Upgrade::InstallAirtimePhpServerCode($phpDir);
|
||||
|
||||
if(AirtimeInstall::DbTableExists('doctrine_migration_versions') === false) {
|
||||
$migrations = array('20110312121200', '20110331111708', '20110402164819', '20110406182005', '20110629143017', '20110711161043', '20110713161043');
|
||||
foreach($migrations as $migration) {
|
||||
AirtimeInstall::BypassMigrations(__DIR__, $migration);
|
||||
}
|
||||
}
|
||||
|
||||
AirtimeInstall::MigrateTablesToVersion(__DIR__, '20110925171256');
|
||||
|
||||
AirtimeInstall::SetDefaultStreamSetting();
|
||||
|
||||
AirtimeInstall::GetOldLiquidsoapCfgAndUpdate();
|
||||
|
||||
AirtimeUpgrade::RemoveOldMonitFile();
|
||||
|
||||
// restart monit
|
||||
exec("service monit restart");
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once('DB.php');
|
||||
|
||||
/* These are helper functions that are common to each upgrade such as
|
||||
/*
|
||||
* These are helper functions that are common to each upgrade such as
|
||||
* creating connections to a database, backing up config files etc.
|
||||
*/
|
||||
class UpgradeCommon {
|
||||
|
@ -18,31 +17,37 @@ class UpgradeCommon{
|
|||
const CONF_BACKUP_SUFFIX = "200";
|
||||
const VERSION_NUMBER = "2.0.0";
|
||||
|
||||
/**
|
||||
* Check if the connection to the database is working.
|
||||
* Return true if it is working, false if not.
|
||||
*
|
||||
* @param boolean $p_exitOnError
|
||||
* $return boolean
|
||||
*/
|
||||
public static function connectToDatabase($p_exitOnError = true)
|
||||
{
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
$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;
|
||||
try {
|
||||
$con = Propel::getConnection();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage().PHP_EOL;
|
||||
echo "Database connection problem.".PHP_EOL;
|
||||
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
|
||||
" with corresponding permissions.".PHP_EOL;
|
||||
echo "Check if database exists with corresponding permissions.".PHP_EOL;
|
||||
if ($p_exitOnError) {
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static function DbTableExists($p_name)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT * FROM ".$p_name;
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
$con = Propel::getConnection();
|
||||
try {
|
||||
$sql = "SELECT * FROM ".$p_name." LIMIT 1";
|
||||
$con->query($sql);
|
||||
} catch (PDOException $e){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -15,7 +15,6 @@ set_include_path(APPLICATION_PATH . get_include_path() . PATH_SEPARATOR . '/cont
|
|||
|
||||
|
||||
require_once APPLICATION_PATH.'/configs/conf.php';
|
||||
require_once 'DB.php';
|
||||
require_once(APPLICATION_PATH.'/../library/propel/runtime/lib/Propel.php');
|
||||
|
||||
require_once 'Soundcloud.php';
|
||||
|
@ -31,17 +30,6 @@ require_once 'Preference.php';
|
|||
// Initialize Propel with the runtime configuration
|
||||
Propel::init(__DIR__."/../../../application/configs/airtime-conf.php");
|
||||
|
||||
|
||||
$dsn = $CC_CONFIG['dsn'];
|
||||
|
||||
$CC_DBC = DB::connect($dsn, FALSE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
|
||||
$playlistName = "pypo_playlist_test";
|
||||
$secondsFromNow = 30;
|
||||
|
||||
|
@ -70,10 +58,6 @@ if (is_null($mediaFile)) {
|
|||
echo "Adding test audio clip to the database.\n";
|
||||
$v = array("filepath" => __DIR__."/../../../audio_samples/vorbis.com/Hydrate-Kenny_Beltrey.ogg");
|
||||
$mediaFile = Application_Model_StoredFile::Insert($v);
|
||||
if (PEAR::isError($mediaFile)) {
|
||||
var_dump($mediaFile);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
$pl->addAudioClip($mediaFile->getId());
|
||||
echo "done.\n";
|
||||
|
|
|
@ -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,19 +44,8 @@ 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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue